Skip to content

Commit 861ab62

Browse files
authored
Merge pull request #1 from arduino-libraries/white-led-rename
Replace occurrences of white LED with orange LED
2 parents e557a63 + 139fdcc commit 861ab62

File tree

9 files changed

+94
-91
lines changed

9 files changed

+94
-91
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# 🤖 Nicla Sense Env Arduino Library
22

3-
[![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)
3+
[![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)
4+
[![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)
5+
[![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)
6+
[![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)
47

58
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).
69

@@ -9,7 +12,7 @@ This library contains an API to read data from the Nicla Sense Env board and con
912
This library supports the complete API exposed by the Nicla Sense Env sensor board over I2C.
1013

1114
- 🌈 RGB LED control
12-
- ⚪️ White LED control
15+
- 🟠 Orange LED control
1316
- 💤 Board control (sleep, reset, factory reset)
1417
- 🔧 Board configuration (e.g. changing the I2C address)
1518
- 🏠 Indoor Air Quality Sensor control

docs/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ void setup(){
2121
// ...
2222
auto rgbLED = device.rgbLED();
2323
// ...
24-
auto whiteLED = device.whiteLED();
24+
auto orangeLED = device.orangeLED();
2525
// ...
2626
}
2727
}
2828
```
29-
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).
29+
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).
3030

3131
## 🧑‍💻 API
3232
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
4343
- [RGBLED.ino](../examples/RGBLED/RGBLED.ino): Demonstrates how to control the board's RGB LED.
4444
- [TemperatureHumidity.ino](../examples/TemperatureHumidity/TemperatureHumidity.ino): Demonstrates how to read the temperature and humidity data from the board's sensors.
4545
- [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.
46-
- [WhiteLED.ino](../examples/WhiteLED/WhiteLED.ino): Demonstrates how to control the board's white LED.
46+
- [OrangeLED.ino](../examples/OrangeLED/OrangeLED.ino): Demonstrates how to control the board's orange LED.

examples/WhiteLED/WhiteLED.ino

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* This example shows how to control the white LED on the Nicla Sense Env board.
2+
* This example shows how to control the orange LED on the Nicla Sense Env board.
33
*
44
* Initial author: Sebastian Romero ([email protected])
55
*/
66

77
#include "NiclaSenseEnv.h"
88

9-
void pulseLED(WhiteLED& led) {
9+
void pulseLED(OrangeLED& led) {
1010
// Fade in
1111
for (uint8_t i = 0; i < 64; ++i) {
1212
led.setBrightness(i);
@@ -29,17 +29,17 @@ void setup() {
2929
NiclaSenseEnv device;
3030

3131
if (device.begin()) {
32-
auto whiteLED = device.whiteLED();
32+
auto orangeLED = device.orangeLED();
3333

34-
Serial.print("🔢 White LED error status enabled: ");
35-
Serial.println(whiteLED.errorStatusEnabled());
36-
Serial.print("💡 White LED brightness: ");
37-
Serial.println(whiteLED.brightness());
34+
Serial.print("🔢 Orange LED error status enabled: ");
35+
Serial.println(orangeLED.errorStatusEnabled());
36+
Serial.print("💡 Orange LED brightness: ");
37+
Serial.println(orangeLED.brightness());
3838

39-
pulseLED(whiteLED);
39+
pulseLED(orangeLED);
4040

41-
// Enable sensor error indication on white LED (LED should turn off if sensors are okay)
42-
whiteLED.setErrorStatusEnabled(true);
41+
// Enable sensor error indication on orange LED (LED should turn off if sensors are okay)
42+
orangeLED.setErrorStatusEnabled(true);
4343
} else {
4444
Serial.println("🤷 Device could not be found. Please double-check the wiring.");
4545
}

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version=1.0.0
33
author=Arduino
44
maintainer=Arduino <[email protected]>
55
sentence=Read sensor data from the Nicla Sense Env board and control the board behaviour.
6-
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
6+
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
77
category=Device Control
88
url=https://github.com/arduino-libraries/Arduino_NiclaSenseEnv
99
architectures=samd,mbed_portenta,renesas_portenta,renesas_uno,mbed_nicla,esp32,mbed_nano

src/NiclaSenseEnv.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ RGBLED& NiclaSenseEnv::rgbLED() {
4343
return *rgbLed;
4444
}
4545

46-
WhiteLED& NiclaSenseEnv::whiteLED() {
47-
if (!whiteLed) {
48-
whiteLed = new WhiteLED(this->bus, this->i2cDeviceAddress);
46+
OrangeLED& NiclaSenseEnv::orangeLED() {
47+
if (!orangeLed) {
48+
orangeLed = new OrangeLED(this->bus, this->i2cDeviceAddress);
4949
}
50-
return *whiteLed;
50+
return *orangeLed;
5151
}
5252

5353
void NiclaSenseEnv::end() {
@@ -67,9 +67,9 @@ void NiclaSenseEnv::end() {
6767
delete rgbLed;
6868
rgbLed = nullptr;
6969
}
70-
if (whiteLed) {
71-
delete whiteLed;
72-
whiteLed = nullptr;
70+
if (orangeLed) {
71+
delete orangeLed;
72+
orangeLed = nullptr;
7373
}
7474
}
7575

src/NiclaSenseEnv.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "IndoorAirQualitySensor.h"
77
#include "OutdoorAirQualitySensor.h"
88
#include "RGBLED.h"
9-
#include "WhiteLED.h"
9+
#include "OrangeLED.h"
1010

1111
/**
1212
* @brief The NiclaSenseEnv class represents a NiclaSenseEnv device.
@@ -69,11 +69,11 @@ class NiclaSenseEnv : public I2CDevice {
6969
RGBLED& rgbLED();
7070

7171
/**
72-
* @brief Returns a reference to the WhiteLED object to interact with the white LED.
72+
* @brief Returns a reference to the OrangeLED object to interact with the orange LED.
7373
*
74-
* @return WhiteLED& Reference to the WhiteLED object.
74+
* @return OrangeLED& Reference to the OrangeLED object.
7575
*/
76-
WhiteLED& whiteLED();
76+
OrangeLED& orangeLED();
7777

7878
/**
7979
* @brief Ends the operation of the NiclaSenseEnv class.
@@ -97,8 +97,8 @@ class NiclaSenseEnv : public I2CDevice {
9797
* - Indoor air quality sensor mode
9898
* - Outdoor air quality sensor mode
9999
* - Temperature sensor enabled
100-
* - White LED brightness
101-
* - White LED error status enabled
100+
* - Orange LED brightness
101+
* - Orange LED error status enabled
102102
* - RGB LED brightness
103103
* - RGB LED color
104104
*
@@ -250,7 +250,7 @@ class NiclaSenseEnv : public I2CDevice {
250250
IndoorAirQualitySensor* indoorAirQualitySensorInstance = nullptr;
251251
OutdoorAirQualitySensor* outdoorAirQualitySensorInstance = nullptr;
252252
RGBLED* rgbLed = nullptr;
253-
WhiteLED* whiteLed = nullptr;
253+
OrangeLED* orangeLed = nullptr;
254254
};
255255

256256
#endif

src/WhiteLED.cpp renamed to src/OrangeLED.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#include "WhiteLED.h"
1+
#include "OrangeLED.h"
22

3-
WhiteLED::WhiteLED(TwoWire& bus, uint8_t deviceAddress) : I2CDevice(bus, deviceAddress) {}
3+
OrangeLED::OrangeLED(TwoWire& bus, uint8_t deviceAddress) : I2CDevice(bus, deviceAddress) {}
44

5-
WhiteLED::WhiteLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {}
5+
OrangeLED::OrangeLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {}
66

7-
uint8_t WhiteLED::brightness() {
8-
// Read bits 0 - 5 from white_led register
7+
uint8_t OrangeLED::brightness() {
8+
// Read bits 0 - 5 from orange_led register
99
uint8_t data = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
1010
return data & 63;
1111
}
1212

13-
void WhiteLED::setBrightness(uint8_t brightness) {
13+
void OrangeLED::setBrightness(uint8_t brightness) {
1414
if (brightness > 63) {
1515
return; // Invalid brightness value
1616
}
@@ -20,13 +20,13 @@ void WhiteLED::setBrightness(uint8_t brightness) {
2020
writeToRegister<uint8_t>(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~63) | brightness);
2121
}
2222

23-
bool WhiteLED::errorStatusEnabled() {
24-
// Read bit 7 from white_led register
23+
bool OrangeLED::errorStatusEnabled() {
24+
// Read bit 7 from orange_led register
2525
uint8_t data = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
2626
return data & (1 << 7);
2727
}
2828

29-
void WhiteLED::setErrorStatusEnabled(bool enabled) {
29+
void OrangeLED::setErrorStatusEnabled(bool enabled) {
3030
uint8_t currentRegisterData = readFromRegister<uint8_t>(WHITE_LED_REGISTER_INFO);
3131
// Set bit 7 to 1 if enabled or 0 if disabled while keeping the other bits unchanged
3232
writeToRegister<uint8_t>(WHITE_LED_REGISTER_INFO, (currentRegisterData & ~(1 << 7)) | (enabled << 7));

src/OrangeLED.h

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include "I2CDevice.h"
2+
3+
/**
4+
* @brief Represents the orange on-board LED controlled via I2C.
5+
*
6+
* The OrangeLED class provides methods to control the brightness and error status of the orange LED.
7+
* It inherits from the I2CDevice class.
8+
*/
9+
class OrangeLED : public I2CDevice {
10+
public:
11+
12+
/**
13+
* @brief Constructs a OrangeLED object.
14+
*
15+
* @param bus The I2C bus to use (default is Wire).
16+
* @param deviceAddress The I2C device address (default is 0x21).
17+
*/
18+
OrangeLED(TwoWire& bus = Wire, uint8_t deviceAddress = DEFAULT_DEVICE_ADDRESS);
19+
20+
/**
21+
* @brief Constructs a OrangeLED object with the specified device address.
22+
*
23+
* @param deviceAddress The I2C address of the OrangeLED device.
24+
*/
25+
OrangeLED(uint8_t deviceAddress);
26+
27+
/**
28+
* Gets the brightness of the orange LED.
29+
* @return The brightness of the orange LED. Range is 0 to 63.
30+
*/
31+
uint8_t brightness();
32+
33+
/**
34+
* Sets the brightness of the orange LED.
35+
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the orange LED brightness to make the change persistent.
36+
* @param brightness : The brightness of the orange LED. Range is 0 to 63.
37+
*/
38+
void setBrightness(uint8_t brightness = 63);
39+
40+
/**
41+
* Determines whether the orange LED is used to indicate an error status of one of the sensors.
42+
* @return True if the orange LED is used for error status, false otherwise.
43+
*/
44+
bool errorStatusEnabled();
45+
46+
/**
47+
* Enables or disables the orange LED to indicate an error status of one of the sensors.
48+
* Call storeSettingsInFlash() on NiclaSenseEnv instance after enabling/disabling the orange LED error status to make the change persistent.
49+
* @param enabled : Whether to enable or disable the orange LED error status.
50+
*/
51+
void setErrorStatusEnabled(bool enabled);
52+
};

src/WhiteLED.h

-52
This file was deleted.

0 commit comments

Comments
 (0)