mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-04 03:36:32 +02:00
clarifying method/variable/class names
This commit is contained in:
@ -14,11 +14,11 @@ const char *LED_BAR_MODE_NAMES[] = {
|
||||
|
||||
/**
|
||||
* @brief Get LedBarMode Name
|
||||
*
|
||||
*
|
||||
* @param mode LedBarMode value
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::getLedBarModeName(LedBarMode mode) {
|
||||
String Configuration::getLedBarModeName(LedBarMode mode) {
|
||||
if (mode == LedBarModeOff) {
|
||||
return String(LED_BAR_MODE_NAMES[LedBarModeOff]);
|
||||
} else if (mode == LedBarModePm) {
|
||||
@ -31,9 +31,9 @@ String AgConfigure::getLedBarModeName(LedBarMode mode) {
|
||||
|
||||
/**
|
||||
* @brief Save configure to device storage (EEPROM)
|
||||
*
|
||||
*
|
||||
*/
|
||||
void AgConfigure::saveConfig(void) {
|
||||
void Configuration::saveConfig(void) {
|
||||
config._check = 0;
|
||||
int len = sizeof(config) - sizeof(config._check);
|
||||
uint8_t *data = (uint8_t *)&config;
|
||||
@ -51,7 +51,7 @@ void AgConfigure::saveConfig(void) {
|
||||
logInfo("Save Config");
|
||||
}
|
||||
|
||||
void AgConfigure::loadConfig(void) {
|
||||
void Configuration::loadConfig(void) {
|
||||
bool readSuccess = false;
|
||||
#ifdef ESP8266
|
||||
uint8_t *data = (uint8_t *)&config;
|
||||
@ -85,9 +85,9 @@ void AgConfigure::loadConfig(void) {
|
||||
|
||||
/**
|
||||
* @brief Set configuration default
|
||||
*
|
||||
*
|
||||
*/
|
||||
void AgConfigure::defaultConfig(void) {
|
||||
void Configuration::defaultConfig(void) {
|
||||
// Default country is null
|
||||
memset(config.country, 0, sizeof(config.country));
|
||||
// Default MQTT broker is null.
|
||||
@ -109,30 +109,31 @@ void AgConfigure::defaultConfig(void) {
|
||||
|
||||
/**
|
||||
* @brief Show configuration as JSON string message over log
|
||||
*
|
||||
*
|
||||
*/
|
||||
void AgConfigure::printConfig(void) { logInfo(toString().c_str()); }
|
||||
void Configuration::printConfig(void) { logInfo(toString().c_str()); }
|
||||
|
||||
/**
|
||||
* @brief Construct a new Ag Configure:: Ag Configure object
|
||||
*
|
||||
*
|
||||
* @param debugLog Serial Stream
|
||||
*/
|
||||
AgConfigure::AgConfigure(Stream &debugLog) : PrintLog(debugLog, "Configure") {}
|
||||
Configuration::Configuration(Stream &debugLog)
|
||||
: PrintLog(debugLog, "Configure") {}
|
||||
|
||||
/**
|
||||
* @brief Destroy the Ag Configure:: Ag Configure object
|
||||
*
|
||||
*
|
||||
*/
|
||||
AgConfigure::~AgConfigure() {}
|
||||
Configuration::~Configuration() {}
|
||||
|
||||
/**
|
||||
* @brief Initialize configuration
|
||||
*
|
||||
*
|
||||
* @return true Success
|
||||
* @return false Failure
|
||||
*/
|
||||
bool AgConfigure::begin(void) {
|
||||
bool Configuration::begin(void) {
|
||||
EEPROM.begin(512);
|
||||
loadConfig();
|
||||
printConfig();
|
||||
@ -149,7 +150,7 @@ bool AgConfigure::begin(void) {
|
||||
* @return true Success
|
||||
* @return false Failure
|
||||
*/
|
||||
bool AgConfigure::parse(String data, bool isLocal) {
|
||||
bool Configuration::parse(String data, bool isLocal) {
|
||||
JSONVar root = JSON.parse(data);
|
||||
if (JSON.typeof_(root) == "undefined") {
|
||||
logError("Configuration JSON invalid");
|
||||
@ -392,15 +393,16 @@ bool AgConfigure::parse(String data, bool isLocal) {
|
||||
}
|
||||
printConfig();
|
||||
|
||||
udpated = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current configuration value as JSON string
|
||||
*
|
||||
* @return String
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::toString(void) {
|
||||
String Configuration::toString(void) {
|
||||
JSONVar root;
|
||||
|
||||
/** "country" */
|
||||
@ -449,85 +451,87 @@ String AgConfigure::toString(void) {
|
||||
|
||||
/**
|
||||
* @brief Temperature unit (F or C)
|
||||
*
|
||||
*
|
||||
* @return true F
|
||||
* @return false C
|
||||
*/
|
||||
bool AgConfigure::isTemperatureUnitInF(void) {
|
||||
bool Configuration::isTemperatureUnitInF(void) {
|
||||
return (config.temperatureUnit == 'f');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Country name, it's short name ex: TH = Thailand
|
||||
*
|
||||
* @return String
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::getCountry(void) { return String(config.country); }
|
||||
String Configuration::getCountry(void) { return String(config.country); }
|
||||
|
||||
/**
|
||||
* @brief PM unit standard (USAQI, ugm3)
|
||||
*
|
||||
*
|
||||
* @return true USAQI
|
||||
* @return false ugm3
|
||||
*/
|
||||
bool AgConfigure::isPmStandardInUSAQI(void) { return config.inUSAQI; }
|
||||
bool Configuration::isPmStandardInUSAQI(void) { return config.inUSAQI; }
|
||||
|
||||
/**
|
||||
* @brief Get CO2 calibration ABC time
|
||||
*
|
||||
*
|
||||
* @return int Number of day
|
||||
*/
|
||||
int AgConfigure::getCO2CalirationAbcDays(void) { return config.abcDays; }
|
||||
int Configuration::getCO2CalibrationAbcDays(void) { return config.abcDays; }
|
||||
|
||||
/**
|
||||
* @brief Get Led Bar Mode
|
||||
*
|
||||
* @return LedBarMode
|
||||
*
|
||||
* @return LedBarMode
|
||||
*/
|
||||
LedBarMode AgConfigure::getLedBarMode(void) {
|
||||
LedBarMode Configuration::getLedBarMode(void) {
|
||||
return (LedBarMode)config.useRGBLedBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get LED bar mode name
|
||||
*
|
||||
* @return String
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::getLedBarModeName(void) {
|
||||
String Configuration::getLedBarModeName(void) {
|
||||
return getLedBarModeName((LedBarMode)config.useRGBLedBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get display mode
|
||||
*
|
||||
*
|
||||
* @return true On
|
||||
* @return false Off
|
||||
*/
|
||||
bool AgConfigure::getDisplayMode(void) { return config.displayMode; }
|
||||
bool Configuration::getDisplayMode(void) { return config.displayMode; }
|
||||
|
||||
/**
|
||||
* @brief Get MQTT uri
|
||||
*
|
||||
* @return String
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::getMqttBrokerUri(void) { return String(config.mqttBroker); }
|
||||
String Configuration::getMqttBrokerUri(void) {
|
||||
return String(config.mqttBroker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get configuratoin post data to AirGradient cloud
|
||||
*
|
||||
*
|
||||
* @return true Post
|
||||
* @return false No-Post
|
||||
*/
|
||||
bool AgConfigure::isPostDataToAirGradient(void) {
|
||||
bool Configuration::isPostDataToAirGradient(void) {
|
||||
return config.postDataToAirGradient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current configuration control
|
||||
*
|
||||
* @return ConfigurationControl
|
||||
*
|
||||
* @return ConfigurationControl
|
||||
*/
|
||||
ConfigurationControl AgConfigure::getConfigurationControl(void) {
|
||||
ConfigurationControl Configuration::getConfigurationControl(void) {
|
||||
return (ConfigurationControl)config.configurationControl;
|
||||
}
|
||||
|
||||
@ -538,7 +542,7 @@ ConfigurationControl AgConfigure::getConfigurationControl(void) {
|
||||
* @return true Requested
|
||||
* @return false Not requested
|
||||
*/
|
||||
bool AgConfigure::isCo2CalibrationRequested(void) {
|
||||
bool Configuration::isCo2CalibrationRequested(void) {
|
||||
bool requested = co2CalibrationRequested;
|
||||
co2CalibrationRequested = false; // clear requested
|
||||
return requested;
|
||||
@ -551,7 +555,7 @@ bool AgConfigure::isCo2CalibrationRequested(void) {
|
||||
* @return true Requested
|
||||
* @return false Not requested
|
||||
*/
|
||||
bool AgConfigure::isLedBarTestRequested(void) {
|
||||
bool Configuration::isLedBarTestRequested(void) {
|
||||
bool requested = ledBarTestRequested;
|
||||
ledBarTestRequested = false;
|
||||
return requested;
|
||||
@ -560,7 +564,7 @@ bool AgConfigure::isLedBarTestRequested(void) {
|
||||
/**
|
||||
* @brief Reset default configure
|
||||
*/
|
||||
void AgConfigure::reset(void) {
|
||||
void Configuration::reset(void) {
|
||||
defaultConfig();
|
||||
logInfo("Reset to default configure");
|
||||
printConfig();
|
||||
@ -571,4 +575,10 @@ void AgConfigure::reset(void) {
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String AgConfigure::getModel(void) { return String(config.model); }
|
||||
String Configuration::getModel(void) { return String(config.model); }
|
||||
|
||||
bool Configuration::isUpdated(void) {
|
||||
bool updated = this->udpated;
|
||||
this->udpated = false;
|
||||
return updated;
|
||||
}
|
||||
|
Reference in New Issue
Block a user