From bd35dd63a5333386ae420282d5d401211a03855d Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 12 Jun 2024 13:02:43 +0200 Subject: [PATCH 1/3] Replace occurrences of white LED with orange LED --- README.md | 2 +- docs/README.md | 6 +++--- examples/WhiteLED/WhiteLED.ino | 20 +++++++++---------- library.properties | 2 +- src/NiclaSenseEnv.cpp | 14 ++++++------- src/NiclaSenseEnv.h | 14 ++++++------- src/WhiteLED.cpp | 18 ++++++++--------- src/WhiteLED.h | 36 +++++++++++++++++----------------- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 7d40a71..33037e2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This library contains an API to read data from the Nicla Sense Env board and con This library supports the complete API exposed by the Nicla Sense Env sensor board over I2C. - 🌈 RGB LED control -- ⚪️ White LED control +- 🟠 Orange LED control - 💤 Board control (sleep, reset, factory reset) - 🔧 Board configuration (e.g. changing the I2C address) - 🏠 Indoor Air Quality Sensor control diff --git a/docs/README.md b/docs/README.md index fdbb303..9a21ce0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -21,12 +21,12 @@ void setup(){ // ... auto rgbLED = device.rgbLED(); // ... - auto whiteLED = device.whiteLED(); + auto orangeLED = device.orangeLED(); // ... } } ``` -Once the desired object is obtained you can call functions on these objects such as `temperatureSensor.getTemperature()`. A complete list of these functions can be found in the [API documentation](./api.md). +Once the desired object is obtained you can call functions on these objects such as `temperatureSensor.temperature()`. A complete list of these functions can be found in the [API documentation](./api.md). ## 🧑‍💻 API The API documentation can be found [here](./api.md). @@ -43,4 +43,4 @@ The following scripts are examples of how to use the Nicla Sense Env board with - [RGBLED.ino](../examples/RGBLED/RGBLED.ino): Demonstrates how to control the board's RGB LED. - [TemperatureHumidity.ino](../examples/TemperatureHumidity/TemperatureHumidity.ino): Demonstrates how to read the temperature and humidity data from the board's sensors. - [UARTRead.ino](../examples/UARTRead/UARTRead.ino): Shows how to read data from the UART port on the board when not connecting to it over I2C. -- [WhiteLED.ino](../examples/WhiteLED/WhiteLED.ino): Demonstrates how to control the board's white LED. +- [OrangeLED.ino](../examples/OrangeLED/OrangeLED.ino): Demonstrates how to control the board's orange LED. diff --git a/examples/WhiteLED/WhiteLED.ino b/examples/WhiteLED/WhiteLED.ino index 7b73ad0..31b1e89 100644 --- a/examples/WhiteLED/WhiteLED.ino +++ b/examples/WhiteLED/WhiteLED.ino @@ -1,12 +1,12 @@ /** - * This example shows how to control the white LED on the Nicla Sense Env board. + * This example shows how to control the orange LED on the Nicla Sense Env board. * * Initial author: Sebastian Romero (s.romero@arduino.cc) */ #include "NiclaSenseEnv.h" -void pulseLED(WhiteLED& led) { +void pulseLED(OrangeLED& led) { // Fade in for (uint8_t i = 0; i < 64; ++i) { led.setBrightness(i); @@ -29,17 +29,17 @@ void setup() { NiclaSenseEnv device; if (device.begin()) { - auto whiteLED = device.whiteLED(); + auto orangeLED = device.orangeLED(); - Serial.print("🔢 White LED error status enabled: "); - Serial.println(whiteLED.errorStatusEnabled()); - Serial.print("💡 White LED brightness: "); - Serial.println(whiteLED.brightness()); + Serial.print("🔢 Orange LED error status enabled: "); + Serial.println(orangeLED.errorStatusEnabled()); + Serial.print("💡 Orange LED brightness: "); + Serial.println(orangeLED.brightness()); - pulseLED(whiteLED); + pulseLED(orangeLED); - // Enable sensor error indication on white LED (LED should turn off if sensors are okay) - whiteLED.setErrorStatusEnabled(true); + // Enable sensor error indication on orange LED (LED should turn off if sensors are okay) + orangeLED.setErrorStatusEnabled(true); } else { Serial.println("🤷 Device could not be found. Please double-check the wiring."); } diff --git a/library.properties b/library.properties index 5513f22..a183903 100644 --- a/library.properties +++ b/library.properties @@ -3,7 +3,7 @@ version=1.0.0 author=Arduino maintainer=Arduino sentence=Read sensor data from the Nicla Sense Env board and control the board behaviour. -paragraph=This library comes with the following features to interact with the Nicla Sense Env board: RGB LED control, White LED control, Board control (sleep, reset, factory reset), Board configuration (e.g. changing the I2C address or enabling UART CSV output), Indoor Air Quality Sensor control, Outdoor Air Quality Sensor control, Temperature/Humidity Sensor Control, UART CSV output +paragraph=This library comes with the following features to interact with the Nicla Sense Env board: RGB LED control, Orange LED control, Board control (sleep, reset, factory reset), Board configuration (e.g. changing the I2C address or enabling UART CSV output), Indoor Air Quality Sensor control, Outdoor Air Quality Sensor control, Temperature/Humidity Sensor Control, UART CSV output category=Device Control url=https://github.com/arduino-libraries/Arduino_NiclaSenseEnv architectures=samd,mbed_portenta,renesas_portenta,renesas_uno,mbed_nicla,esp32,mbed_nano diff --git a/src/NiclaSenseEnv.cpp b/src/NiclaSenseEnv.cpp index 2bd7d72..3e1bc7c 100644 --- a/src/NiclaSenseEnv.cpp +++ b/src/NiclaSenseEnv.cpp @@ -43,11 +43,11 @@ RGBLED& NiclaSenseEnv::rgbLED() { return *rgbLed; } -WhiteLED& NiclaSenseEnv::whiteLED() { - if (!whiteLed) { - whiteLed = new WhiteLED(this->bus, this->i2cDeviceAddress); +OrangeLED& NiclaSenseEnv::orangeLED() { + if (!orangeLed) { + orangeLed = new OrangeLED(this->bus, this->i2cDeviceAddress); } - return *whiteLed; + return *orangeLed; } void NiclaSenseEnv::end() { @@ -67,9 +67,9 @@ void NiclaSenseEnv::end() { delete rgbLed; rgbLed = nullptr; } - if (whiteLed) { - delete whiteLed; - whiteLed = nullptr; + if (orangeLed) { + delete orangeLed; + orangeLed = nullptr; } } diff --git a/src/NiclaSenseEnv.h b/src/NiclaSenseEnv.h index 278e1b9..77d5865 100644 --- a/src/NiclaSenseEnv.h +++ b/src/NiclaSenseEnv.h @@ -6,7 +6,7 @@ #include "IndoorAirQualitySensor.h" #include "OutdoorAirQualitySensor.h" #include "RGBLED.h" -#include "WhiteLED.h" +#include "OrangeLED.h" /** * @brief The NiclaSenseEnv class represents a NiclaSenseEnv device. @@ -69,11 +69,11 @@ class NiclaSenseEnv : public I2CDevice { RGBLED& rgbLED(); /** - * @brief Returns a reference to the WhiteLED object to interact with the white LED. + * @brief Returns a reference to the OrangeLED object to interact with the orange LED. * - * @return WhiteLED& Reference to the WhiteLED object. + * @return OrangeLED& Reference to the OrangeLED object. */ - WhiteLED& whiteLED(); + OrangeLED& orangeLED(); /** * @brief Ends the operation of the NiclaSenseEnv class. @@ -97,8 +97,8 @@ class NiclaSenseEnv : public I2CDevice { * - Indoor air quality sensor mode * - Outdoor air quality sensor mode * - Temperature sensor enabled - * - White LED brightness - * - White LED error status enabled + * - Orange LED brightness + * - Orange LED error status enabled * - RGB LED brightness * - RGB LED color * @@ -250,7 +250,7 @@ class NiclaSenseEnv : public I2CDevice { IndoorAirQualitySensor* indoorAirQualitySensorInstance = nullptr; OutdoorAirQualitySensor* outdoorAirQualitySensorInstance = nullptr; RGBLED* rgbLed = nullptr; - WhiteLED* whiteLed = nullptr; + OrangeLED* orangeLed = nullptr; }; #endif diff --git a/src/WhiteLED.cpp b/src/WhiteLED.cpp index 7e1e2ad..0bdc1e6 100644 --- a/src/WhiteLED.cpp +++ b/src/WhiteLED.cpp @@ -1,16 +1,16 @@ -#include "WhiteLED.h" +#include "OrangeLED.h" -WhiteLED::WhiteLED(TwoWire& bus, uint8_t deviceAddress) : I2CDevice(bus, deviceAddress) {} +OrangeLED::OrangeLED(TwoWire& bus, uint8_t deviceAddress) : I2CDevice(bus, deviceAddress) {} -WhiteLED::WhiteLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {} +OrangeLED::OrangeLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {} -uint8_t WhiteLED::brightness() { - // Read bits 0 - 5 from white_led register +uint8_t OrangeLED::brightness() { + // Read bits 0 - 5 from orange_led register uint8_t data = readFromRegister(WHITE_LED_REGISTER_INFO); return data & 63; } -void WhiteLED::setBrightness(uint8_t brightness) { +void OrangeLED::setBrightness(uint8_t brightness) { if (brightness > 63) { return; // Invalid brightness value } @@ -20,13 +20,13 @@ void WhiteLED::setBrightness(uint8_t brightness) { writeToRegister(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~63) | brightness); } -bool WhiteLED::errorStatusEnabled() { - // Read bit 7 from white_led register +bool OrangeLED::errorStatusEnabled() { + // Read bit 7 from orange_led register uint8_t data = readFromRegister(WHITE_LED_REGISTER_INFO); return data & (1 << 7); } -void WhiteLED::setErrorStatusEnabled(bool enabled) { +void OrangeLED::setErrorStatusEnabled(bool enabled) { uint8_t currentRegisterData = readFromRegister(WHITE_LED_REGISTER_INFO); // Set bit 7 to 1 if enabled or 0 if disabled while keeping the other bits unchanged writeToRegister(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~(1 << 7)) | (enabled << 7)); diff --git a/src/WhiteLED.h b/src/WhiteLED.h index d7841c6..d09941b 100644 --- a/src/WhiteLED.h +++ b/src/WhiteLED.h @@ -1,52 +1,52 @@ #include "I2CDevice.h" /** - * @brief Represents the white on-board LED controlled via I2C. + * @brief Represents the orange on-board LED controlled via I2C. * - * The WhiteLED class provides methods to control the brightness and error status of the white LED. + * The OrangeLED class provides methods to control the brightness and error status of the orange LED. * It inherits from the I2CDevice class. */ -class WhiteLED : public I2CDevice { +class OrangeLED : public I2CDevice { public: /** - * @brief Constructs a WhiteLED object. + * @brief Constructs a OrangeLED object. * * @param bus The I2C bus to use (default is Wire). * @param deviceAddress The I2C device address (default is 0x21). */ - WhiteLED(TwoWire& bus = Wire, uint8_t deviceAddress = DEFAULT_DEVICE_ADDRESS); + OrangeLED(TwoWire& bus = Wire, uint8_t deviceAddress = DEFAULT_DEVICE_ADDRESS); /** - * @brief Constructs a WhiteLED object with the specified device address. + * @brief Constructs a OrangeLED object with the specified device address. * - * @param deviceAddress The I2C address of the WhiteLED device. + * @param deviceAddress The I2C address of the OrangeLED device. */ - WhiteLED(uint8_t deviceAddress); + OrangeLED(uint8_t deviceAddress); /** - * Gets the brightness of the white LED. - * @return The brightness of the white LED. Range is 0 to 63. + * Gets the brightness of the orange LED. + * @return The brightness of the orange LED. Range is 0 to 63. */ uint8_t brightness(); /** - * Sets the brightness of the white LED. - * Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the white LED brightness to make the change persistent. - * @param brightness : The brightness of the white LED. Range is 0 to 63. + * Sets the brightness of the orange LED. + * Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the orange LED brightness to make the change persistent. + * @param brightness : The brightness of the orange LED. Range is 0 to 63. */ void setBrightness(uint8_t brightness = 63); /** - * Determines whether the white LED is used to indicate an error status of one of the sensors. - * @return True if the white LED is used for error status, false otherwise. + * Determines whether the orange LED is used to indicate an error status of one of the sensors. + * @return True if the orange LED is used for error status, false otherwise. */ bool errorStatusEnabled(); /** - * Enables or disables the white LED to indicate an error status of one of the sensors. - * Call storeSettingsInFlash() on NiclaSenseEnv instance after enabling/disabling the white LED error status to make the change persistent. - * @param enabled : Whether to enable or disable the white LED error status. + * Enables or disables the orange LED to indicate an error status of one of the sensors. + * Call storeSettingsInFlash() on NiclaSenseEnv instance after enabling/disabling the orange LED error status to make the change persistent. + * @param enabled : Whether to enable or disable the orange LED error status. */ void setErrorStatusEnabled(bool enabled); }; From 11ba6ec5e72d3cd3788e0fd440e2d0f56076e44b Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 12 Jun 2024 13:05:58 +0200 Subject: [PATCH 2/3] Add badge for API docs --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33037e2..4c2c9fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # 🤖 Nicla Sense Env Arduino Library -[![Arduino Lint](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/arduino-lint.yml) [![Compile Examples](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/compile-examples.yml) [![Spell Check](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/spell-check.yml) +[![Arduino Lint](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/arduino-lint.yml) +[![Compile Examples](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/compile-examples.yml) +[![Spell Check](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/spell-check.yml) +[![API Documentation](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/render-documentation.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_NiclaSenseEnv/actions/workflows/render-documentation.yml) This library contains an API to read data from the Nicla Sense Env board and control its behaviour. The board host three different sensors which can be read simultaneously: **ZMOD4410** (Indoor Air Quality), **ZMOD4510** (Outdoor Air Quality), **HS4001** (Temperature & Humidity). From 139fdcc3024dcfb02a43ed433b1f2dbe00ca7e9e Mon Sep 17 00:00:00 2001 From: Sebastian Romero Date: Wed, 12 Jun 2024 14:01:28 +0200 Subject: [PATCH 3/3] Rename source files --- src/{WhiteLED.cpp => OrangeLED.cpp} | 0 src/{WhiteLED.h => OrangeLED.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{WhiteLED.cpp => OrangeLED.cpp} (100%) rename src/{WhiteLED.h => OrangeLED.h} (100%) diff --git a/src/WhiteLED.cpp b/src/OrangeLED.cpp similarity index 100% rename from src/WhiteLED.cpp rename to src/OrangeLED.cpp diff --git a/src/WhiteLED.h b/src/OrangeLED.h similarity index 100% rename from src/WhiteLED.h rename to src/OrangeLED.h