Skip to content

Commit db4c882

Browse files
committed
Fix compiler issues
1 parent bfd0a2d commit db4c882

File tree

9 files changed

+19
-54
lines changed

9 files changed

+19
-54
lines changed

examples/RGBLED/RGBLED.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ void pulseLED(RGBLED &led) {
2121
}
2222

2323
void pulseColors(RGBLED &led) {
24-
// Brightness can also be set via 4th struct element
25-
led.setColor({255, 0, 0}, 255); // Red
24+
led.setColor({255, 0, 0}); // Red
2625
pulseLED(led);
2726

2827
// Color can be set via Color struct or 3 separate uint8_t values

src/IndoorAirQualitySensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool IndoorAirQualitySensor::setMode(IndoorAirQualitySensorMode sensorMode, bool
5858

5959
// Check if the existing value is already the same
6060
if ((currentRegisterData & (7 << 1)) == (mode << 1)) {
61-
return;
61+
return true;
6262
}
6363
if(!writeToRegister(STATUS_REGISTER_INFO, (currentRegisterData & ~(7 << 1)) | (mode << 1))){
6464
return false;
@@ -95,7 +95,7 @@ bool IndoorAirQualitySensor::enabled() {
9595

9696
bool IndoorAirQualitySensor::setEnabled(bool isEnabled, bool persist) {
9797
if (isEnabled == enabled()) {
98-
return;
98+
return true;
9999
}
100100

101101
auto mode = isEnabled ? IndoorAirQualitySensorMode::indoorAirQuality : IndoorAirQualitySensorMode::powerDown;

src/IndoorAirQualitySensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class IndoorAirQualitySensor : public I2CDevice {
120120
* When persist is true, the mode setting of OutdoorAirQualitySensor and TemperatureHumiditySensor will also be persisted.
121121
* @return True if the mode was set successfully, false otherwise.
122122
*/
123-
bool setMode(IndoorAirQualitySensorMode sensorMode, bool persist);
123+
bool setMode(IndoorAirQualitySensorMode sensorMode, bool persist = false);
124124

125125
/**
126126
* @brief Get the mode as a string.

src/NiclaSenseEnv.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ int NiclaSenseEnv::UARTBaudRate() {
155155
bool NiclaSenseEnv::setUARTBaudRate(int baudRate, bool persist) {
156156
int baudRateIndex = baudRateNativeValue(baudRate);
157157
if (baudRateIndex == -1) {
158-
return; // Baud rate not found
158+
return false; // Baud rate not found
159159
}
160160

161161
uint8_t uartControlRegisterData = readFromRegister<uint8_t>(UART_CONTROL_REGISTER_INFO);
162162
if ((uartControlRegisterData & 7) == baudRateIndex) {
163-
return; // Value is already the same
163+
return true; // Value is already the same
164164
}
165165
if(!writeToRegister(UART_CONTROL_REGISTER_INFO, (uartControlRegisterData & ~7) | baudRateIndex)){
166166
return false;
@@ -181,7 +181,7 @@ bool NiclaSenseEnv::isUARTCSVOutputEnabled() {
181181
bool NiclaSenseEnv::setUARTCSVOutputEnabled(bool enabled, bool persist) {
182182
uint8_t boardControlRegisterData = readFromRegister<uint8_t>(CONTROL_REGISTER_INFO);
183183
if ((boardControlRegisterData & 2) == static_cast<int>(enabled)) {
184-
return; // Value is already the same
184+
return true; // Value is already the same
185185
}
186186
if(!writeToRegister(CONTROL_REGISTER_INFO, (boardControlRegisterData & ~2) | (enabled << 1))){
187187
return false;
@@ -202,15 +202,15 @@ char NiclaSenseEnv::CSVDelimiter() {
202202
bool NiclaSenseEnv::setCSVDelimiter(char delimiter, bool persist) {
203203
char currentDelimiter = CSVDelimiter();
204204
if (currentDelimiter == delimiter) {
205-
return; // Value is already the same
205+
return true; // Value is already the same
206206
}
207207

208208
// Define prohibited delimiters
209209
const char prohibitedDelimiters[] = {'\r', '\n', '\\', '"', '\''};
210210

211211
for (auto prohibitedDelimiter : prohibitedDelimiters) {
212212
if (delimiter == prohibitedDelimiter) {
213-
return; // Delimiter is prohibited
213+
return false; // Delimiter is prohibited
214214
}
215215
}
216216

@@ -234,7 +234,7 @@ bool NiclaSenseEnv::isDebuggingEnabled() {
234234
bool NiclaSenseEnv::setDebuggingEnabled(bool enabled, bool persist) {
235235
uint8_t boardControlRegisterData = readFromRegister<uint8_t>(CONTROL_REGISTER_INFO);
236236
if ((boardControlRegisterData & 1) == static_cast<int>(enabled)) {
237-
return; // Value is already the same
237+
return true; // Value is already the same
238238
}
239239
if(!writeToRegister(CONTROL_REGISTER_INFO, (boardControlRegisterData & ~1) | enabled)){
240240
return false;
@@ -249,12 +249,12 @@ bool NiclaSenseEnv::setDebuggingEnabled(bool enabled, bool persist) {
249249

250250
bool NiclaSenseEnv::setDeviceAddress(int address, bool persist) {
251251
if (address < 0 || address > 127) {
252-
return; // Invalid address
252+
return false; // Invalid address
253253
}
254254
uint8_t addressRegisterData = readFromRegister<uint8_t>(SLAVE_ADDRESS_REGISTER_INFO);
255255
// Check bits 0 - 6
256256
if ((addressRegisterData & 127) == address) {
257-
return; // Value is already the same
257+
return true; // Value is already the same
258258
}
259259
if(!writeToRegister(SLAVE_ADDRESS_REGISTER_INFO, (addressRegisterData & ~127) | address)){
260260
return false;

src/OrangeLED.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uint8_t OrangeLED::brightness() {
1313

1414
bool OrangeLED::setBrightness(uint8_t brightness, bool persist) {
1515
if (brightness > 255) {
16-
return; // Invalid brightness value
16+
return false; // Invalid brightness value
1717
}
1818

1919
uint8_t mappedBrightness = map(brightness, 0, 255, 0, 63);

src/OutdoorAirQualitySensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool OutdoorAirQualitySensor::setMode(OutdoorAirQualitySensorMode sensorMode, bo
4949

5050
// Check if the existing value is already the same
5151
if ((currentRegisterData & (3 << 4)) == (mode << 4)) {
52-
return;
52+
return true;
5353
}
5454

5555
// Overwrite bits 4 and 5 with the new value
@@ -84,7 +84,7 @@ bool OutdoorAirQualitySensor::enabled() {
8484
bool OutdoorAirQualitySensor::setEnabled(bool isEnabled, bool persist) {
8585
// Ignore the request if the sensor is already in the desired state to maintain the current mode
8686
if (isEnabled == enabled()) {
87-
return;
87+
return true;
8888
}
8989

9090
auto mode = isEnabled ? OutdoorAirQualitySensorMode::outdoorAirQuality : OutdoorAirQualitySensorMode::powerDown;

src/RGBLED.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,25 @@ RGBLED::RGBLED(TwoWire& bus, uint8_t deviceAddress) : I2CDevice(bus, deviceAddre
66
RGBLED::RGBLED(uint8_t deviceAddress) : I2CDevice(deviceAddress) {}
77

88
bool RGBLED::enableIndoorAirQualityStatus(uint8_t brightness, bool persist) {
9-
return setColor(0, 0, 0, brightness, persist);
9+
return setColor(0, 0, 0, persist) && setBrightness(brightness, persist);
1010
}
1111

1212
bool RGBLED::setColor(uint8_t r, uint8_t g, uint8_t b, bool persist) {
13-
return setColor(r, g, b, 255, persist); // Default maximum brightness
14-
}
15-
16-
bool RGBLED::setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool persist) {
1713
if(!writeToRegister(RGB_LED_RED_REGISTER_INFO, r)) return false;
1814
if(!writeToRegister(RGB_LED_GREEN_REGISTER_INFO, g)) return false;
1915
if(!writeToRegister(RGB_LED_BLUE_REGISTER_INFO, b)) return false;
20-
if(!writeToRegister(INTENSITY_REGISTER_INFO, brightness)) return false;
2116

2217
if (persist) {
2318
return persistRegister(RGB_LED_RED_REGISTER_INFO) &&
2419
persistRegister(RGB_LED_GREEN_REGISTER_INFO) &&
25-
persistRegister(RGB_LED_BLUE_REGISTER_INFO) &&
26-
persistRegister(INTENSITY_REGISTER_INFO);
20+
persistRegister(RGB_LED_BLUE_REGISTER_INFO);
2721
}
2822

2923
return true;
3024
}
3125

3226
bool RGBLED::setColor(Color color, bool persist) {
33-
return setColor(color, 255, persist); // Default maximum brightness
34-
}
35-
36-
bool RGBLED::setColor(Color color, uint8_t brightness, bool persist) {
37-
return setColor(color.red, color.green, color.blue, brightness, persist);
27+
return setColor(color.red, color.green, color.blue, persist);
3828
}
3929

4030
Color RGBLED::color() {

src/RGBLED.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,44 +52,20 @@ class RGBLED : public I2CDevice {
5252
* @param g The green value (0-255).
5353
* @param b The blue value (0-255).
5454
* @param persist If true, the change will be saved to flash memory.
55-
* When persist is True, the brightness will also be persisted.
5655
* @return True if the color was set successfully, false otherwise.
5756
*/
5857
bool setColor(uint8_t r, uint8_t g, uint8_t b, bool persist = false);
5958

60-
/**
61-
* Sets the RGB values of the LED along with the specified brightness.
62-
* @param r The red value (0-255).
63-
* @param g The green value (0-255).
64-
* @param b The blue value (0-255).
65-
* @param brightness The brightness value (0-255).
66-
* @param persist If true, the change will be saved to flash memory.
67-
* When persist is True, the brightness will also be persisted.
68-
* @return True if the color was set successfully, false otherwise.
69-
*/
70-
bool setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t brightness, bool persist = false); ;
71-
7259
/**
7360
* @brief Sets the RGB color of the LED using a Color object.
7461
* The Color object contains the red, green, and blue values that can be changed individually.
7562
* Note: A value of 0, 0, 0 will set the color based on the IAQ value from the Indoor Air Quality sensor.
7663
* @param color The RGB color to set.
7764
* @param persist If true, the change will be saved to flash memory.
78-
* When persist is True, the brightness will also be persisted.
7965
* @return True if the color was set successfully, false otherwise.
8066
*/
8167
bool setColor(Color color, bool persist = false);
8268

83-
/**
84-
* @brief Sets the RGB color and brightness of the LED using a Color object.
85-
* @param color The desired RGB color.
86-
* @param brightness The desired brightness level (0-255).
87-
* @param persist If true, the change will be saved to flash memory.
88-
* When persist is True, the brightness will also be persisted.
89-
* @return True if the color was set successfully, false otherwise.
90-
*/
91-
bool setColor(Color color, uint8_t brightness, bool persist = false);
92-
9369
/**
9470
* @brief Gets the current RGB color of the LED.
9571
*

src/TemperatureHumiditySensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool TemperatureHumiditySensor::setEnabled(bool enabled, bool persist) {
2929

3030
// Check if current value is already the desired value
3131
if (static_cast<bool>(status & 1) == enabled) {
32-
return;
32+
return true;
3333
}
3434

3535
status = enabled ? (status | 1) : (status & 0xFE);

0 commit comments

Comments
 (0)