mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
added hide_led - #463
This commit is contained in:
@@ -76,6 +76,16 @@ function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps)
|
||||
<MenuItem value={0x0F}>Time Module (0x0F)</MenuItem>
|
||||
<MenuItem value={0x12}>Alarm Module (0x12)</MenuItem>
|
||||
</SelectValidator>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.hide_led}
|
||||
onChange={handleValueChange('hide_led')}
|
||||
value="hide_led"
|
||||
/>
|
||||
}
|
||||
label="Hide LED"
|
||||
/>
|
||||
<BlockFormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
|
||||
@@ -22,6 +22,7 @@ class DummySettings {
|
||||
uint8_t master_thermostat = 0;
|
||||
bool shower_timer = false;
|
||||
bool shower_alert = false;
|
||||
bool hide_led = false;
|
||||
uint16_t publish_time = 10; // seconds
|
||||
uint8_t mqtt_format = 1; // 1=single, 2=nested, 3=ha, 4=custom
|
||||
uint8_t mqtt_qos = 0;
|
||||
|
||||
@@ -36,6 +36,7 @@ void EMSESPSettings::read(EMSESPSettings & settings, JsonObject & root) {
|
||||
root["master_thermostat"] = settings.master_thermostat;
|
||||
root["shower_timer"] = settings.shower_timer;
|
||||
root["shower_alert"] = settings.shower_alert;
|
||||
root["hide_led"] = settings.hide_led;
|
||||
}
|
||||
|
||||
StateUpdateResult EMSESPSettings::update(JsonObject & root, EMSESPSettings & settings) {
|
||||
@@ -47,6 +48,7 @@ StateUpdateResult EMSESPSettings::update(JsonObject & root, EMSESPSettings & set
|
||||
settings.master_thermostat = root["master_thermostat"] | EMSESP_DEFAULT_MASTER_THERMOSTAT;
|
||||
settings.shower_timer = root["shower_timer"] | EMSESP_DEFAULT_SHOWER_TIMER;
|
||||
settings.shower_alert = root["shower_alert"] | EMSESP_DEFAULT_SHOWER_ALERT;
|
||||
settings.hide_led = root["hide_led"] | EMSESP_DEFAULT_HIDE_LED;
|
||||
|
||||
return StateUpdateResult::CHANGED;
|
||||
}
|
||||
@@ -56,7 +58,8 @@ StateUpdateResult EMSESPSettings::update(JsonObject & root, EMSESPSettings & set
|
||||
void EMSESPSettingsService::onUpdate() {
|
||||
EMSESP::shower_.start();
|
||||
// EMSESP::system_.syslog_init(); // changing SysLog will require a restart
|
||||
EMSESP::reset_tx();
|
||||
EMSESP::init_tx();
|
||||
System::set_led();
|
||||
}
|
||||
|
||||
void EMSESPSettingsService::begin() {
|
||||
|
||||
@@ -27,14 +27,13 @@
|
||||
|
||||
#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0
|
||||
#define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key
|
||||
|
||||
#define EMSESP_DEFAULT_SYSLOG_LEVEL -1 // OFF
|
||||
#define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0
|
||||
#define EMSESP_DEFAULT_SYSLOG_HOST ""
|
||||
|
||||
#define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set
|
||||
#define EMSESP_DEFAULT_SHOWER_TIMER false
|
||||
#define EMSESP_DEFAULT_SHOWER_ALERT false
|
||||
#define EMSESP_DEFAULT_HIDE_LED false
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
@@ -47,8 +46,7 @@ class EMSESPSettings {
|
||||
uint8_t master_thermostat;
|
||||
bool shower_timer;
|
||||
bool shower_alert;
|
||||
|
||||
// syslog
|
||||
bool hide_led;
|
||||
int8_t syslog_level; // uuid::log::Level
|
||||
uint32_t syslog_mark_interval;
|
||||
String syslog_host;
|
||||
|
||||
@@ -33,6 +33,7 @@ uuid::syslog::SyslogService System::syslog_;
|
||||
uint32_t System::heap_start_ = 0;
|
||||
int System::reset_counter_ = 0;
|
||||
bool System::upload_status_ = false;
|
||||
bool System::hide_led_ = false;
|
||||
|
||||
// send on/off to a gpio pin
|
||||
// value: true = HIGH, false = LOW
|
||||
@@ -146,15 +147,19 @@ void System::start() {
|
||||
[&](WiFiSettings & wifiSettings) { LOG_INFO(F("System %s booted (EMS-ESP version %s)"), wifiSettings.hostname.c_str(), EMSESP_APP_VERSION); });
|
||||
|
||||
syslog_init(); // init SysLog
|
||||
|
||||
if (LED_GPIO) {
|
||||
pinMode(LED_GPIO, OUTPUT); // LED pin, 0 means disabled
|
||||
set_led(); // init LED
|
||||
EMSESP::init_tx(); // start UART
|
||||
}
|
||||
|
||||
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) { tx_mode_ = settings.tx_mode; });
|
||||
#ifndef EMSESP_FORCE_SERIAL
|
||||
EMSuart::start(tx_mode_); // start UART
|
||||
#endif
|
||||
// set the LED to on or off when in normal operating mode
|
||||
void System::set_led() {
|
||||
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) {
|
||||
hide_led_ = settings.hide_led;
|
||||
if (LED_GPIO) {
|
||||
pinMode(LED_GPIO, OUTPUT); // LED_GPIO 0 means disabled
|
||||
digitalWrite(LED_GPIO, hide_led_ ? !LED_ON : LED_ON); // LED on, for ever
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// returns true if OTA is uploading
|
||||
@@ -261,7 +266,7 @@ void System::system_check() {
|
||||
if (!system_healthy_) {
|
||||
system_healthy_ = true;
|
||||
if (LED_GPIO) {
|
||||
digitalWrite(LED_GPIO, LED_ON); // LED on, for ever
|
||||
digitalWrite(LED_GPIO, hide_led_ ? !LED_ON : LED_ON); // LED on, for ever
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ class System {
|
||||
|
||||
static void show_mem(const char * note);
|
||||
|
||||
static void set_led();
|
||||
|
||||
void check_upgrade();
|
||||
|
||||
private:
|
||||
@@ -115,8 +117,8 @@ class System {
|
||||
static bool upload_status_; // true if we're in the middle of a OTA firmware upload
|
||||
|
||||
// settings
|
||||
uint8_t tx_mode_;
|
||||
bool system_heartbeat_;
|
||||
static bool hide_led_;
|
||||
uint8_t syslog_level_;
|
||||
uint32_t syslog_mark_interval_;
|
||||
String syslog_host_;
|
||||
|
||||
Reference in New Issue
Block a user