Files
arduino/src/AgConfigure.h

103 lines
3.1 KiB
C
Raw Normal View History

2024-04-03 07:04:55 +07:00
#ifndef _AG_CONFIG_H_
#define _AG_CONFIG_H_
2024-04-03 21:26:04 +07:00
#include "App/AppDef.h"
#include "Main/PrintLog.h"
2024-04-25 06:49:14 +07:00
#include "AirGradient.h"
2024-04-03 07:04:55 +07:00
#include <Arduino.h>
2024-04-07 16:39:01 +07:00
class Configuration : public PrintLog {
2024-04-03 07:04:55 +07:00
private:
struct Config {
char model[20];
char country[3]; /** Country name has only 2 character, ex: TH = Thailand */
char mqttBroker[256]; /** MQTT broker URI */
bool inUSAQI; /** If PM standard "ugm3" inUSAQI = false, otherwise is true
*/
bool inF; /** Temperature unit F */
2024-04-03 21:26:04 +07:00
bool postDataToAirGradient; /** If true, monitor will not POST data to
airgradient server. Make sure no error
message shown on monitor */
uint8_t configurationControl; /** If true, configuration from airgradient
server will be ignored */
bool displayMode; /** true if enable display */
2024-04-03 07:04:55 +07:00
uint8_t useRGBLedBar;
uint8_t abcDays;
2024-05-01 21:25:35 +07:00
uint8_t ledBarBrightness;
uint8_t displayBrightness;
2024-04-03 07:04:55 +07:00
int tvocLearningOffset;
int noxLearningOffset;
char temperatureUnit; // 'f' or 'c'
uint32_t _check;
};
struct Config config;
bool co2CalibrationRequested;
bool ledBarTestRequested;
2024-04-07 16:39:01 +07:00
bool udpated;
2024-04-08 10:15:45 +07:00
String failedMessage;
bool _noxLearnOffsetChanged;
bool _tvocLearningOffsetChanged;
2024-05-01 21:25:35 +07:00
bool ledBarBrightnessChanged = false;
bool displayBrightnessChanged = false;
2024-04-03 07:04:55 +07:00
2024-04-25 06:49:14 +07:00
AirGradient* ag;
2024-04-03 07:04:55 +07:00
String getLedBarModeName(LedBarMode mode);
void saveConfig(void);
void loadConfig(void);
void defaultConfig(void);
void printConfig(void);
2024-04-08 10:15:45 +07:00
String jsonTypeInvalidMessage(String name, String type);
String jsonValueInvalidMessage(String name, String value);
void jsonInvalid(void);
void configLogInfo(String name, String fromValue, String toValue);
String getPMStandardString(bool usaqi);
String getDisplayModeString(bool dispMode);
String getAbcDayString(int value);
2024-04-03 07:04:55 +07:00
public:
2024-04-07 16:39:01 +07:00
Configuration(Stream &debugLog);
~Configuration();
bool hasSensorS8 = true;
bool hasSensorPMS1 = true;
bool hasSensorPMS2 = true;
bool hasSensorSGP = true;
bool hasSensorSHT = true;
2024-04-03 07:04:55 +07:00
bool begin(void);
bool parse(String data, bool isLocal);
String toString(void);
bool isTemperatureUnitInF(void);
String getCountry(void);
bool isPmStandardInUSAQI(void);
2024-04-07 16:39:01 +07:00
int getCO2CalibrationAbcDays(void);
2024-04-03 07:04:55 +07:00
LedBarMode getLedBarMode(void);
String getLedBarModeName(void);
bool getDisplayMode(void);
String getMqttBrokerUri(void);
bool isPostDataToAirGradient(void);
ConfigurationControl getConfigurationControl(void);
bool isCo2CalibrationRequested(void);
bool isLedBarTestRequested(void);
void reset(void);
String getModel(void);
2024-04-07 16:39:01 +07:00
bool isUpdated(void);
2024-04-08 10:15:45 +07:00
String getFailedMesage(void);
void setPostToAirGradient(bool enable);
bool noxLearnOffsetChanged(void);
bool tvocLearnOffsetChanged(void);
int getTvocLearningOffset(void);
int getNoxLearningOffset(void);
2024-04-25 06:49:14 +07:00
String wifiSSID(void);
String wifiPass(void);
void setAirGradient(AirGradient *ag);
2024-05-01 21:25:35 +07:00
bool isLedBarBrightnessChanged(void);
int getLedBarBrightness(void);
bool isDisplayBrightnessChanged(void);
int getDisplayBrightness(void);
2024-04-03 07:04:55 +07:00
};
#endif /** _AG_CONFIG_H_ */