Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation changes (second half): Use only a single README.md per device #1610

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/devices/Lps25h/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,40 @@ Some of the applications mentioned by the datasheet:
- Weather station equipment
- Sport watches

See [samples](samples/README.md) for information about usage.

## References
## Documentation

- https://www.st.com/resource/en/datasheet/lps25h.pdf

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while you are at adjusting those elements, make it with the proper pattern so something like:

Official LPS25H documentation can be found [here](https://www.st.com/resource/en/datasheet/lps25h.pdf)

I've tried to adjust all those URLs as well

## Usage

```csharp
class Program
{
// I2C address on SenseHat board
public const int I2cAddress = 0x5c;

static void Main(string[] args)
{
using (var th = new Lps25h(CreateI2cDevice()))
{
while (true)
{
var tempValue = th.Temperature;
var preValue = th.Pressure;
var altValue = WeatherHelper.CalculateAltitude(preValue, defaultSeaLevelPressure, tempValue);

Console.WriteLine($"Temperature: {tempValue.Celsius:0.#}\u00B0C");
Console.WriteLine($"Pressure: {preValue.Hectopascal:0.##}hPa");
Console.WriteLine($"Altitude: {altValue:0.##}m");
Thread.Sleep(1000);
}
}
}

private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return I2cDevice.Create(settings);
}
}
```
33 changes: 0 additions & 33 deletions src/devices/Lps25h/samples/README.md

This file was deleted.

106 changes: 103 additions & 3 deletions src/devices/Lsm9Ds1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,108 @@ LSM9DS1 internally uses 2 buses:

and therefore functionality has been split into 2 classes which allows using them independently.

See [samples](samples/README.md) for information about usage.

## References
## Documentation

- https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

## Usage

### Accelerometer and gyroscope

```csharp
class Program
{
public const int I2cAddress = 0x6A;

static void Main(string[] args)
{
using (var ag = new Lsm9Ds1AccelerometerAndGyroscope(CreateI2cDevice()))
{
while (true)
{
Console.WriteLine($"Acceleration={ag.Acceleration}");
Console.WriteLine($"AngularRate={ag.AngularRate}");
Thread.Sleep(100);
}
}
}

private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return I2cDevice.Create(settings);
}
}
```

### Magnetometer

```csharp
class Magnetometer
{
public const int I2cAddress = 0x1C;

public static void Run()
{
using (var m = new Lsm9Ds1Magnetometer(CreateI2cDevice()))
{
Console.WriteLine("Calibrating...");
Console.WriteLine("Move the sensor around Z for the next 20 seconds, try covering every angle");
Stopwatch sw = Stopwatch.StartNew();
Vector3 min = m.MagneticInduction;
Vector3 max = m.MagneticInduction;
while (sw.ElapsedMilliseconds < 20 * 1000)
{
Vector3 sample = m.MagneticInduction;
min = Vector3.Min(min, sample);
max = Vector3.Max(max, sample);
Thread.Sleep(50);
}
Console.WriteLine("Stop moving for some time...");
Thread.Sleep(3000);
const int intervals = 32;
bool[,] data = new bool[32,32];
Vector3 size = max - min;
int n = 0;
while (true)
{
n++;
Vector3 sample = m.MagneticInduction;
Vector3 pos = Vector3.Divide(Vector3.Multiply((sample - min), intervals - 1), size);
int x = Math.Clamp((int)pos.X, 0, intervals - 1);
int y = Math.Clamp((int)pos.Y, 0, intervals - 1);
data[x, y] = true;
if (n % 10 == 0)
{
Console.Clear();
Console.WriteLine("Now move the sensor around again but slower...");
for (int i = 0; i < intervals; i++)
{
for (int j = 0; j < intervals; j++)
{
if (i == x && y == j)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write('#');
Console.ResetColor();
}
else
{
Console.Write(data[i, j] ? '#' : ' ');
}
}
Console.WriteLine();
}
}
Thread.Sleep(50);
}
}
}

private static I2cDevice CreateI2cDevice()
{
var settings = new I2cConnectionSettings(1, I2cAddress);
return I2cDevice.Create(settings);
}
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markdown tip: you need to finish the file with an empty line, so adding an extra enter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the other Markdown tips left there and there :-) the enum at the beginning of the file is not correct as it should havre an empty line before also reinforce by the fact you have a title.

101 changes: 0 additions & 101 deletions src/devices/Lsm9Ds1/samples/README.md

This file was deleted.

35 changes: 32 additions & 3 deletions src/devices/Max31856/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
# Max31856 - cold-junction compensated thermocouple to digital converter

## Summary
The Max31856 device is a SPI interface cold-junction compensated thermocouple to digital converter.

## Sensor Image
![Illustration of wiring from a Raspberry Pi device](device.jpg)

**Note:** _ThermocoupleType.K is configured for a K type thermocouple if you want to use a B,E,J,K,N,R,S, or T simply change the K to the thermocouple type of your choosing._

## References
## Documentation

**Max31856** [datasheet](https://datasheets.maximintegrated.com/en/ds/Max31856.pdf)

## Usage
The Max31856.samples file contains a sample usage of the device. Note that this reads two temperatures. One is a connected thermocouple reading which can be read using the ```TryGetTemperature``` command and the other is the temperature of the device itself which can be read using the ```GetColdJunctionTemperature``` command. The Cold Junction Temperature is used internally to increase the accuracy of the thermocouple but can also be read if you find a use for it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marktdown tips:

  • all titles except the first level one, must have an empty line and an empty line after.
  • all code blocks need to be separated with an empty line before and after
  • al enums need to be grouped without extra enter between them
  • for code blocks, use only "csharp" and not the c# version, all lowercase


Create a new ```SpiConnectionSettings``` Class if using a Raspberry Pi do not change these settings.

```csharp
SpiConnectionSettings settings = new(0, 0)
{
ClockFrequency = Max31856.SpiClockFrequency,
Mode = Max31856.SpiMode,
DataFlow = 0
};
```

Create a new ```SpiDevice``` with the settings from above. Then create a new Max31856 device with the ```SpiDevice``` as well as the correct ```ThermocoupleType``` (see note below)
```csharp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so here you miss an enter before the code block

using SpiDevice device = SpiDevice.Create(settings);
using Max31856 sensor = new(device, ThermocoupleType.K);
```

Now read the temperature from the device. Using the UnitsNet nuget you can see the units of your choosing. In this example you chan change```DegreesFahrenheit``` to ```DegreesCelsius``` or any other unit by changing ```.GetTemperature().DegreesFahrenheit``` to another unit of your choice.

```csharp
while (true)
{
Temperature tempColdJunction = sensor.GetColdJunctionTemperature();
Console.WriteLine($"Temperature: {tempColdJunction} ℃");
Thread.Sleep(2000);
}
```
30 changes: 0 additions & 30 deletions src/devices/Max31856/samples/README.md

This file was deleted.

Loading