Skip to content

Commit

Permalink
fix: docs (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich authored Jun 9, 2024
1 parent 98f2cfa commit 4654ce7
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 20 deletions.
Binary file added Docs/Examples/signalization.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ Includes following features:

## Setup

All setup related operations are processed via **Makefile** placed in the root directory.
First of all connect your device to the board using pin-out given below. Then connect your board to serial port.

First of all connect your board to the serial port.
![](https://www.waveshare.com/w/A6Y79bcq/Kdy80nYY.php?f=TSL25911-Arduino-WS.jpg&width=900)

In order to build **IOC** project it's required to **CubeMX** to generate **ELF** upload it with the help of
In order to build **IOC** project using **light_detector.ioc** file it's required to use **STM CubeMX** to generate **ELF** file and upload it with the help of
**STM Programmer**.

> If **ProtocolBuffers** files need to be regenerated it's required to execute the following command:
All supportive setup related operations are processed via **Makefile** placed in the project root directory.

> If **ProtocolBuffers** bindings need to be regenerated it's required to execute the following command:
```shell
make generate
```

After successful installation, the board should signalize successful connection with the device:

![](./Docs/Examples/signalization.gif)

## Scripts

### CLI
Expand Down
86 changes: 73 additions & 13 deletions Scripts/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ Includes following features:
All the operations are perform with the usage of **ProtocolBuffers**.

## Setup

First of all connect your board with device installed to serial port. Your board needs to have
already installed software build, which allows communication with **TSL2591X** device.

![](https://www.waveshare.com/w/A6Y79bcq/Kdy80nYY.php?f=TSL25911-Arduino-WS.jpg&width=900)
Your board needs to have already installed software build, which allows communication with **TSL2591X** device.
The device should be connected.

All setup related operations are processed via **Makefile** placed in the root directory.

Expand Down Expand Up @@ -61,7 +59,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.GAIN: 'Gain'>,
device_id: 1,
device_id: 80,
nonce: 4,
value: 16
```
Expand All @@ -80,7 +78,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.INTEGRAL_TIME: 'IntegralTime'>,
device_id: 1,
device_id: 80,
nonce: 5,
value: 1
```
Expand All @@ -101,7 +99,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.PROCESSED_REQUESTS: 'ProcessedRequests'>,
device_id: 1,
device_id: 80,
nonce: 6,
value: 20
```
Expand All @@ -114,7 +112,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600"

instance(RetrievedInfoDto):
data_type: <InfoTypeCompound.DEVICE_AVAILABLE: 'DeviceAvailable'>,
device_id: 1,
device_id: 80,
nonce: 7,
value: 1
```
Expand All @@ -123,6 +121,68 @@ Available **device available** values:
* 1 - device available
* 0 - device is not available

## Set settings

The examples below show all the possible ways to modify device settings. Baud rate is important to be the exact-supported value,
otherwise requests will be ignored(in the given examples baud rate is equal to **9600**).

Successful operation will be signalized with LED blinking.

![](../../Docs/Examples/signalization.gif)

### Reset

The next example shows how to reset all the settings of the device
```shell
$ light-detector-cli set_settings --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="reset"

instance(SetSettingsDto):
device_id: 80,
nonce: 5,
result: True,
settings_type: <SettingsTypeCompound.RESET: 'Reset'>
```

### Set Gain

The next example shows how to modify gain setting of the device.
```shell
$ light-detector-cli set_settings --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="set_gain" --value="low"

instance(SetSettingsDto):
device_id: 80,
nonce: 7,
result: True,
settings_type: <SettingsTypeCompound.SET_GAIN_LOW: 'SetGainLow'>
```

Available **set_gain** values:
* low - 0
* medium - 16
* high - 32
* max - 48

### Set Integral Time

The next example shows how to modify integral time setting of the device.
```shell
$ light-detector-cli set_settings --device="/dev/cu.usbmodem1203" --baud_rate="9600" --type="set_integral_time" --value="first"

instance(SetSettingsDto):
device_id: 80,
nonce: 8,
result: True,
settings_type: <SettingsTypeCompound.SET_INTEGRAL_TIME_FIRST: 'SetIntegralTimeFirst'>
```

Available **set_integral_time** values:
* first - 100ms
* second - 200ms
* third - 300ms
* forth - 400ms
* fifth - 500ms
* sixth - 600ms

## Get data

The examples below show all the possible ways to retrieve data information from the board.
Expand All @@ -133,7 +193,7 @@ $ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600"
[
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
device_id: 80,
nonce: 4,
value: 121
]
Expand All @@ -153,22 +213,22 @@ $ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600"
[
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
device_id: 80,
nonce: 26,
value: 51
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
device_id: 80,
nonce: 27,
value: 80
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
device_id: 80,
nonce: 28,
value: 97
instance(RetrievedDataDto):
data_type: <DataTypeCompound.RAW: 'Raw'>,
device_id: 1,
device_id: 80,
nonce: 29,
value: 41
]
Expand Down
4 changes: 2 additions & 2 deletions Scripts/cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def read_requirements() -> list[str]:


setup(
name="light-sensor-cli",
name="light-detector-cli",
version="0.0.1",
description="A tool used to allows to perform operations on STM32L476RG board with installed TSL2591X light sensor with the help of serial connection.",
url="https://github.com/YarikRevich/light-detector",
Expand All @@ -43,6 +43,6 @@ def read_requirements() -> list[str]:
packages=find_packages(exclude=["tests", ".github"]),
install_requires=read_requirements(),
entry_points={
"console_scripts": ["light-sensor-cli = src.__main__:main"]
"console_scripts": ["light-detector-cli = src.__main__:main"]
},
)
2 changes: 1 addition & 1 deletion Scripts/cli/src/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_settings(device: str, baud_rate: int, type: str, value: Optional[str] =
"""
Sets given settings to the board.
The available settings types are 'reset', 'set_gain'(with values 'low', 'medium', 'high', 'max'),
'set_integral_time'(with values 'first'(100ms), 'second'(200ms), 'third'(300ms), 'forth'(400ms), 'fifth'(500mx),
'set_integral_time'(with values 'first'(100ms), 'second'(200ms), 'third'(300ms), 'forth'(400ms), 'fifth'(500ms),
'sixth'(600ms)).
"""

Expand Down

0 comments on commit 4654ce7

Please sign in to comment.