-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1473746
commit 3948be7
Showing
50 changed files
with
8,418 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.271 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NKH.MindSqualls", "Source\NKH.MindSqualls\NKH.MindSqualls.csproj", "{9973018E-FC09-4549-A484-0B702ADE1EE9}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUsbWrapper", "Source\WinUsbWrapper\WinUsbWrapper.csproj", "{40C6E946-D5AC-43B8-AEDE-D896E9CBB3E2}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9973018E-FC09-4549-A484-0B702ADE1EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9973018E-FC09-4549-A484-0B702ADE1EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9973018E-FC09-4549-A484-0B702ADE1EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9973018E-FC09-4549-A484-0B702ADE1EE9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{40C6E946-D5AC-43B8-AEDE-D896E9CBB3E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{40C6E946-D5AC-43B8-AEDE-D896E9CBB3E2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{40C6E946-D5AC-43B8-AEDE-D896E9CBB3E2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{40C6E946-D5AC-43B8-AEDE-D896E9CBB3E2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8B249E41-851F-4D50-833E-D2BE5AD69896} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
namespace NKH.MindSqualls.HiTechnic | ||
{ | ||
/// <summary> | ||
/// <para>Class representing the Acceleration / Tilt Sensor sensor from HiTechnic: | ||
/// <a href="http://www.hitechnic.com" target="_blank">http://www.hitechnic.com</a></para> | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>A special thanks to the people at HiTechnic for providing me with the necessary technical information.</para> | ||
/// <para>Also a special thanks to Ronny H. for providing me with qualified implementation details on the acceleration sensor before I had purchased my own copy.</para> | ||
/// </remarks> | ||
public class HiTechnicAccelerationSensor : NxtDigitalSensor | ||
{ | ||
/// <summary> | ||
/// <para>Constructor.</para> | ||
/// </summary> | ||
public HiTechnicAccelerationSensor() | ||
: base() | ||
{ } | ||
|
||
#region Sensor readings. | ||
|
||
/// <summary> | ||
/// <para>Acceleration coordinate of the X-axis.</para> | ||
/// </summary> | ||
/// <returns>The acceleration coordinate</returns> | ||
public double? XAxisAcceleration() | ||
{ | ||
return XyzAxisAcceleration(XAxisUpper8Bits()); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Acceleration coordinate of the Y-axis.</para> | ||
/// </summary> | ||
/// <returns>The acceleration coordinate</returns> | ||
public double? YAxisAcceleration() | ||
{ | ||
return XyzAxisAcceleration(YAxisUpper8Bits()); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Acceleration coordinate of the Z-axis.</para> | ||
/// </summary> | ||
/// <returns>The acceleration coordinate</returns> | ||
public double? ZAxisAcceleration() | ||
{ | ||
return XyzAxisAcceleration(ZAxisUpper8Bits()); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Change this value, to finetune the value of the acceleration sensor.</para> | ||
/// <para>The current value, = 9.82/206.3, is the best fit for my own sensor.</para> | ||
/// <remarks> | ||
/// <para>The component used in the sensor is only guaranteed to be accurate to +/- 10%.</para> | ||
/// </remarks> | ||
/// </summary> | ||
public double scalíng = 9.82 / 200; | ||
|
||
private double? XyzAxisAcceleration(sbyte? xyz) | ||
{ | ||
if (!xyz.HasValue) return null; | ||
|
||
int tmpXyz = xyz.Value; | ||
|
||
// Reverse the sign. | ||
tmpXyz *= -1; | ||
|
||
// Shift 2 bits up. | ||
tmpXyz = tmpXyz << 2; | ||
|
||
return scalíng * tmpXyz; | ||
} | ||
|
||
#endregion | ||
|
||
#region I2C protocol. | ||
|
||
/// <summary> | ||
/// <para>X axis upper 8 bits</para> | ||
/// </summary> | ||
/// <returns>The X-component of the acceleration vector</returns> | ||
/// <seealso cref="YAxisUpper8Bits"/> | ||
/// <seealso cref="ZAxisUpper8Bits"/> | ||
/// <seealso cref="XAxisLower2Bits"/> | ||
public sbyte? XAxisUpper8Bits() | ||
{ | ||
byte? xAxisUpper8 = ReadByteFromAddress(0x42); | ||
if (xAxisUpper8.HasValue) | ||
return (sbyte)xAxisUpper8.Value; | ||
else | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// <para>Y axis upper 8 bits</para> | ||
/// </summary> | ||
/// <returns>The Y-component of the acceleration vector</returns> | ||
/// <seealso cref="XAxisUpper8Bits"/> | ||
/// <seealso cref="ZAxisUpper8Bits"/> | ||
/// <seealso cref="YAxisLower2Bits"/> | ||
public sbyte? YAxisUpper8Bits() | ||
{ | ||
byte? yAxisUpper8 = ReadByteFromAddress(0x43); | ||
if (yAxisUpper8.HasValue) | ||
return (sbyte)yAxisUpper8.Value; | ||
else | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// <para>Z axis upper 8 bits</para> | ||
/// </summary> | ||
/// <returns>The Z-component of the acceleration vector</returns> | ||
/// <seealso cref="XAxisUpper8Bits"/> | ||
/// <seealso cref="YAxisUpper8Bits"/> | ||
/// <seealso cref="ZAxisLower2Bits"/> | ||
public sbyte? ZAxisUpper8Bits() | ||
{ | ||
byte? zAxisUpper8 = ReadByteFromAddress(0x44); | ||
if (zAxisUpper8.HasValue) | ||
return (sbyte)zAxisUpper8.Value; | ||
else | ||
return null; | ||
} | ||
|
||
/// <summary> | ||
/// <para>X axis lower 2 bits</para> | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>Should only be used if the full precision is needed.</para> | ||
/// </remarks> | ||
/// <returns>The lower 2 bits of the X-component of the acceleration vector</returns> | ||
/// <seealso cref="XAxisUpper8Bits"/> | ||
public byte? XAxisLower2Bits() | ||
{ | ||
return ReadByteFromAddress(0x45); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Y axis lower 2 bits</para> | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>Should only be used if the full precision is needed.</para> | ||
/// </remarks> | ||
/// <returns>The lower 2 bits of the Y-component of the acceleration vector</returns> | ||
/// <seealso cref="YAxisUpper8Bits"/> | ||
public byte? YAxisLower2Bits() | ||
{ | ||
return ReadByteFromAddress(0x46); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Z axis lower 2 bits</para> | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>Should only be used if the full precision is needed.</para> | ||
/// </remarks> | ||
/// <returns>The lower 2 bits of the Z-component of the acceleration vector</returns> | ||
/// <seealso cref="ZAxisUpper8Bits"/> | ||
public byte? ZAxisLower2Bits() | ||
{ | ||
return ReadByteFromAddress(0x47); | ||
} | ||
|
||
#endregion | ||
|
||
#region NXT-G like events & NxtPollable overrides. | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
using System; | ||
|
||
namespace NKH.MindSqualls.HiTechnic | ||
{ | ||
/// <summary> | ||
/// <para>Class representing the Color sensor from HiTechnic: | ||
/// <a href="http://www.hitechnic.com" target="_blank">http://www.hitechnic.com</a></para> | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>The HiTechnic color sensor should not be confused with the NXT 2.0 color sensor.</para> | ||
/// <para>A special thanks to the people at HiTechnic for providing me with the necessary technical information.</para> | ||
/// </remarks> | ||
/// <seealso cref="Nxt2ColorSensor"/> | ||
public class HiTechnicColorSensor : NxtDigitalSensor | ||
{ | ||
/// <summary> | ||
/// <para>Constructor.</para> | ||
/// </summary> | ||
public HiTechnicColorSensor() | ||
: base() | ||
{ } | ||
|
||
#region Sensor readings | ||
#endregion | ||
|
||
#region I2C protocol | ||
|
||
/// <summary> | ||
/// <para>Returns a single number color estimate.</para> | ||
/// </summary> | ||
public byte? ColorNumber | ||
{ | ||
get { return ReadByteFromAddress(0x42); } | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current detection level for the color red.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public byte? RedReading() | ||
{ | ||
return ReadByteFromAddress(0x43); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current detection level for the color green.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public byte? GreenReading() | ||
{ | ||
return ReadByteFromAddress(0x44); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current detection level for the color blue.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public byte? BlueReading() | ||
{ | ||
return ReadByteFromAddress(0x45); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current sensor analog signal level for the color red.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public UInt16? RawRedSensorReading() | ||
{ | ||
return ReadWordFromAdress(0x46); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current sensor analog signal level for the color green.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public UInt16? RawGreenSensorReading() | ||
{ | ||
return ReadWordFromAdress(0x48); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns the current sensor analog signal level for the color blue.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public UInt16? RawBlueSensorReading() | ||
{ | ||
return ReadWordFromAdress(0x4A); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Returns a single 6 bit number color index. Bits 5 and 4 encode the red signal level, bits 3 and 2 encode the green signal level and bits 1 and 0 encode the blue signal levels.</para> | ||
/// </summary> | ||
/// <returns>... TBD ...</returns> | ||
public byte? ColorIndexNumber() | ||
{ | ||
return ReadByteFromAddress(0x4C); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Return the current relative level for the red color component.</para> | ||
/// </summary> | ||
/// <remarks>The normalization sets the highest value of the three red, green and blue reading to 255 and adjusts the other two proportionately.</remarks> | ||
/// <returns>... TBD ...</returns> | ||
public byte? NormalizedRedReading() | ||
{ | ||
return ReadByteFromAddress(0x4D); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Return the current relative level for the green color component.</para> | ||
/// </summary> | ||
/// <remarks>The normalization sets the highest value of the three red, green and blue reading to 255 and adjusts the other two proportionately.</remarks> | ||
/// <returns>... TBD ...</returns> | ||
public byte? NormalizedGreenReading() | ||
{ | ||
return ReadByteFromAddress(0x4E); | ||
} | ||
|
||
/// <summary> | ||
/// <para>Return the current relative level for the blue color component.</para> | ||
/// </summary> | ||
/// <remarks>The normalization sets the highest value of the three red, green and blue reading to 255 and adjusts the other two proportionately.</remarks> | ||
/// <returns>... TBD ...</returns> | ||
public byte? NormalizedBlueReading() | ||
{ | ||
return ReadByteFromAddress(0x4F); | ||
} | ||
|
||
#endregion | ||
|
||
#region NXT-G like events & NxtPollable overrides | ||
#endregion | ||
} | ||
} |
Oops, something went wrong.