diff --git a/Docs/Examples/signalization.gif b/Docs/Examples/signalization.gif new file mode 100644 index 0000000..de640c3 Binary files /dev/null and b/Docs/Examples/signalization.gif differ diff --git a/README.md b/README.md index 6220d6c..67ffb00 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Scripts/cli/README.md b/Scripts/cli/README.md index aaf126f..df96077 100644 --- a/Scripts/cli/README.md +++ b/Scripts/cli/README.md @@ -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. @@ -61,7 +59,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" instance(RetrievedInfoDto): data_type: , - device_id: 1, + device_id: 80, nonce: 4, value: 16 ``` @@ -80,7 +78,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" instance(RetrievedInfoDto): data_type: , - device_id: 1, + device_id: 80, nonce: 5, value: 1 ``` @@ -101,7 +99,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" instance(RetrievedInfoDto): data_type: , - device_id: 1, + device_id: 80, nonce: 6, value: 20 ``` @@ -114,7 +112,7 @@ $ light-detector-cli get_info --device="/dev/cu.usbmodem1203" --baud_rate="9600" instance(RetrievedInfoDto): data_type: , - device_id: 1, + device_id: 80, nonce: 7, value: 1 ``` @@ -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: +``` + +### 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: +``` + +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: +``` + +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. @@ -133,7 +193,7 @@ $ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600" [ instance(RetrievedDataDto): data_type: , - device_id: 1, + device_id: 80, nonce: 4, value: 121 ] @@ -153,22 +213,22 @@ $ light-detector-cli get_data --device="/dev/cu.usbmodem1203" --baud_rate="9600" [ instance(RetrievedDataDto): data_type: , - device_id: 1, + device_id: 80, nonce: 26, value: 51 instance(RetrievedDataDto): data_type: , - device_id: 1, + device_id: 80, nonce: 27, value: 80 instance(RetrievedDataDto): data_type: , - device_id: 1, + device_id: 80, nonce: 28, value: 97 instance(RetrievedDataDto): data_type: , - device_id: 1, + device_id: 80, nonce: 29, value: 41 ] diff --git a/Scripts/cli/setup.py b/Scripts/cli/setup.py index a93a6d3..976ab80 100644 --- a/Scripts/cli/setup.py +++ b/Scripts/cli/setup.py @@ -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", @@ -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"] }, ) diff --git a/Scripts/cli/src/command/base.py b/Scripts/cli/src/command/base.py index e8fb91e..70a3890 100644 --- a/Scripts/cli/src/command/base.py +++ b/Scripts/cli/src/command/base.py @@ -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)). """