Skip to content

Commit

Permalink
Rename function to persistSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Jun 13, 2024
1 parent de57a80 commit 1c38a72
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/ChangeI2CAddress/ChangeI2CAddress.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void setup() {
checkConnection(device);

// Store the new address in flash
device.storeSettingsInFlash();
device.persistSettings();

Serial.println("🔄 Resetting device to check if change is persistent...");
device.reset();
Expand Down
2 changes: 1 addition & 1 deletion examples/UARTRead/UARTRead.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* NiclaSenseEnv device;
* device.begin();
* device.setUARTCSVOutputEnabled(true);
* device.storeSettingsInFlash() # Store the settings so they are not lost after a reset
* device.persistSettings() # Store the settings so they are not lost after a reset
*
* Initial author: Sebastian Romero ([email protected])
*
Expand Down
4 changes: 2 additions & 2 deletions src/IndoorAirQualitySensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class IndoorAirQualitySensor : public I2CDevice {

/**
* @brief Set the mode of the IndoorAirQualitySensor.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the mode to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the mode to make the change persistent.
*
* Note on cleaning mode:
* The cleaning mode performs a thermal cleaning cycle of the MOx element. It can eliminate some light pollution
Expand Down Expand Up @@ -136,7 +136,7 @@ class IndoorAirQualitySensor : public I2CDevice {

/**
* @brief Set the sensor enabled or disabled.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* @param isEnabled True to enable the sensor, false to disable it.
*/
void setEnabled(bool isEnabled);
Expand Down
4 changes: 2 additions & 2 deletions src/NiclaSenseEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void NiclaSenseEnv::end() {
}
}

bool NiclaSenseEnv::storeSettingsInFlash() {
bool NiclaSenseEnv::persistSettings() {
uint8_t controlRegisterData = readFromRegister<uint8_t>(CONTROL_REGISTER_INFO);

writeToRegister(CONTROL_REGISTER_INFO, controlRegisterData | (1 << 7));
Expand Down Expand Up @@ -137,7 +137,7 @@ bool NiclaSenseEnv::restoreFactorySettings() {
boardControlRegisterData = readFromRegister<uint8_t>(CONTROL_REGISTER_INFO);

if ((boardControlRegisterData & (1 << 5)) == 0) {
return storeSettingsInFlash();
return persistSettings();
}
Serial.println("⌛️ Waiting for factory reset to complete...");
// Exponential sleep duration
Expand Down
14 changes: 7 additions & 7 deletions src/NiclaSenseEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class NiclaSenseEnv : public I2CDevice {
*
* @return true if the settings were successfully stored, false otherwise.
*/
bool storeSettingsInFlash();
bool persistSettings();

/**
* @brief Retrieves the serial number of the device.
Expand Down Expand Up @@ -148,7 +148,7 @@ class NiclaSenseEnv : public I2CDevice {
/**
* @brief Restores the factory settings.
* This will reset among other properties the device address to the default value.
* See storeSettingsInFlash() for a complete list of properties that are affected by this method.
* See persistSettings() for a complete list of properties that are affected by this method.
*
* @return true if the factory settings were successfully restored, false otherwise.
*/
Expand All @@ -163,7 +163,7 @@ class NiclaSenseEnv : public I2CDevice {

/**
* @brief Sets the baud rate for the UART communication.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the baud rate to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the baud rate to make the change persistent.
* @param baudRate The desired baud rate for the UART communication.
The supported values are: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
*/
Expand All @@ -179,7 +179,7 @@ class NiclaSenseEnv : public I2CDevice {
/**
* @brief Sets the UART CSV output enabled or disabled.
* Enables or disables CSV output over UART.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the CSV output mode to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the CSV output mode to make the change persistent.
*
* The column names and their order are:
* HS4001 sample counter, HS4001 temperature (degC), HS4001 humidity (%RH), ZMOD4510 status, ZMOD4510 sample counter,
Expand All @@ -205,7 +205,7 @@ class NiclaSenseEnv : public I2CDevice {

/**
* @brief Sets the CSV delimiter for parsing CSV data.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the CSV delimiter to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the CSV delimiter to make the change persistent.
* @param delimiter The character to be used as the CSV delimiter.
*/
void setCSVDelimiter(char delimiter);
Expand All @@ -220,14 +220,14 @@ class NiclaSenseEnv : public I2CDevice {
/**
* @brief Toggles the debugging mode.
* When debugging mode is enabled, the board will send additional debug messages over UART.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the debugging mode to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the debugging mode to make the change persistent.
* @param enabled A boolean value indicating whether debugging is enabled or not.
*/
void setDebuggingEnabled(bool enabled);

/**
* @brief Sets the I2C address of the device.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the address to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the address to make the change persistent.
*
* @param address The new I2C address. Valid values are 0 to 127.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/OrangeLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ class OrangeLED : public I2CDevice {

/**
* Sets the brightness of the orange LED.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the orange LED brightness to make the change persistent.
* Call persistSettings() 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 orange LED is used to indicate an error status of one of the sensors.
* When a board error condition occurs the LED blinks, independently of the brightness setting.
* @return True if the orange LED is used for error status, false otherwise.
*/
bool errorStatusEnabled();

/**
* 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.
* Call persistSettings() 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);
Expand Down
5 changes: 3 additions & 2 deletions src/OutdoorAirQualitySensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class OutdoorAirQualitySensor : public I2CDevice {
* This function allows you to set the mode of the outdoor air quality sensor.
* Possible values are: powerDown, cleaning, outdoorAirQuality.
* See OutdoorAirQualitySensorMode for more information.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the mode to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the mode to make the change persistent.
*
* Note on cleaning mode:
* The cleaning mode performs a thermal cleaning cycle of the MOx element. It can eliminate some light pollution
Expand Down Expand Up @@ -126,7 +126,8 @@ class OutdoorAirQualitySensor : public I2CDevice {
/**
* @brief Sets the enabled state of the outdoor air quality sensor.
* When disabled the sensor goes in power down mode.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* When the sensor is enabled after being disabled, the sensor will go back to the default mode.
* Call persistSettings() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* @param isEnabled True to enable the sensor, false to disable it.
*/
void setEnabled(bool isEnabled);
Expand Down
12 changes: 6 additions & 6 deletions src/RGBLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RGBLED : public I2CDevice {
/**
* Enables the indoor air quality status indicator on the RGB LED.
* When enabled, the RGB LED will change color based on the air quality (red = bad, green = good)
* Call storeSettingsInFlash() on NiclaSenseEnv instance after enabling the indoor air quality status to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after enabling the indoor air quality status to make the change persistent.
* @param brightness The brightness level of the indicator (0-255).
*/
void enableIndoorAirQualityStatus(uint8_t brightness);
Expand All @@ -51,7 +51,7 @@ class RGBLED : public I2CDevice {
* @brief Sets the RGB values of the LED.
*
* This function sets the red, green, and blue values of the LED using individual values.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the color to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the color to make the change persistent.
* @param r The red value (0-255).
* @param g The green value (0-255).
* @param b The blue value (0-255).
Expand All @@ -60,7 +60,7 @@ class RGBLED : public I2CDevice {

/**
* Sets the RGB values of the LED along with the specified brightness.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the color to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the color to make the change persistent.
* @param r The red value (0-255).
* @param g The green value (0-255).
* @param b The blue value (0-255).
Expand All @@ -71,14 +71,14 @@ class RGBLED : public I2CDevice {
/**
* @brief Sets the RGB color of the LED using a Color object.
* The Color object contains the red, green, and blue values that can be changed individually.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the color to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the color to make the change persistent.
* @param color The RGB color to set.
*/
void setColor(Color color);

/**
* @brief Sets the RGB color and brightness of the LED using a Color object.
* Call Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the color / brightness to make the change persistent.
* Call Call persistSettings() on NiclaSenseEnv instance after changing the color / brightness to make the change persistent.
* @param color The desired RGB color.
* @param brightness The desired brightness level (0-255).
*/
Expand All @@ -101,7 +101,7 @@ class RGBLED : public I2CDevice {
/**
* @brief Sets the brightness of the RGB LED.
* This function allows you to adjust the brightness of the RGB LED.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the brightness to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the brightness to make the change persistent.
* @param brightness The brightness level to set (0-255).
*/
void setBrightness(uint8_t brightness);
Expand Down
2 changes: 1 addition & 1 deletion src/TemperatureHumiditySensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TemperatureHumiditySensor : public I2CDevice {
/**
* @brief Sets the enabled state of the temperature and humidity sensor.
* When disabled the sensor goes in power down mode.
* Call storeSettingsInFlash() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* Call persistSettings() on NiclaSenseEnv instance after changing the enabled state to make the change persistent.
* @param enabled The desired enabled state. True to enable the sensor, false to disable it.
*/
void setEnabled(bool enabled);
Expand Down

0 comments on commit 1c38a72

Please sign in to comment.