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={0x0F}>Time Module (0x0F)</MenuItem>
|
||||||
<MenuItem value={0x12}>Alarm Module (0x12)</MenuItem>
|
<MenuItem value={0x12}>Alarm Module (0x12)</MenuItem>
|
||||||
</SelectValidator>
|
</SelectValidator>
|
||||||
|
<BlockFormControlLabel
|
||||||
|
control={
|
||||||
|
<Checkbox
|
||||||
|
checked={data.hide_led}
|
||||||
|
onChange={handleValueChange('hide_led')}
|
||||||
|
value="hide_led"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Hide LED"
|
||||||
|
/>
|
||||||
<BlockFormControlLabel
|
<BlockFormControlLabel
|
||||||
control={
|
control={
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class DummySettings {
|
|||||||
uint8_t master_thermostat = 0;
|
uint8_t master_thermostat = 0;
|
||||||
bool shower_timer = false;
|
bool shower_timer = false;
|
||||||
bool shower_alert = false;
|
bool shower_alert = false;
|
||||||
|
bool hide_led = false;
|
||||||
uint16_t publish_time = 10; // seconds
|
uint16_t publish_time = 10; // seconds
|
||||||
uint8_t mqtt_format = 1; // 1=single, 2=nested, 3=ha, 4=custom
|
uint8_t mqtt_format = 1; // 1=single, 2=nested, 3=ha, 4=custom
|
||||||
uint8_t mqtt_qos = 0;
|
uint8_t mqtt_qos = 0;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ void EMSESPSettings::read(EMSESPSettings & settings, JsonObject & root) {
|
|||||||
root["master_thermostat"] = settings.master_thermostat;
|
root["master_thermostat"] = settings.master_thermostat;
|
||||||
root["shower_timer"] = settings.shower_timer;
|
root["shower_timer"] = settings.shower_timer;
|
||||||
root["shower_alert"] = settings.shower_alert;
|
root["shower_alert"] = settings.shower_alert;
|
||||||
|
root["hide_led"] = settings.hide_led;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateUpdateResult EMSESPSettings::update(JsonObject & root, EMSESPSettings & settings) {
|
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.master_thermostat = root["master_thermostat"] | EMSESP_DEFAULT_MASTER_THERMOSTAT;
|
||||||
settings.shower_timer = root["shower_timer"] | EMSESP_DEFAULT_SHOWER_TIMER;
|
settings.shower_timer = root["shower_timer"] | EMSESP_DEFAULT_SHOWER_TIMER;
|
||||||
settings.shower_alert = root["shower_alert"] | EMSESP_DEFAULT_SHOWER_ALERT;
|
settings.shower_alert = root["shower_alert"] | EMSESP_DEFAULT_SHOWER_ALERT;
|
||||||
|
settings.hide_led = root["hide_led"] | EMSESP_DEFAULT_HIDE_LED;
|
||||||
|
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
}
|
}
|
||||||
@@ -56,7 +58,8 @@ StateUpdateResult EMSESPSettings::update(JsonObject & root, EMSESPSettings & set
|
|||||||
void EMSESPSettingsService::onUpdate() {
|
void EMSESPSettingsService::onUpdate() {
|
||||||
EMSESP::shower_.start();
|
EMSESP::shower_.start();
|
||||||
// EMSESP::system_.syslog_init(); // changing SysLog will require a restart
|
// EMSESP::system_.syslog_init(); // changing SysLog will require a restart
|
||||||
EMSESP::reset_tx();
|
EMSESP::init_tx();
|
||||||
|
System::set_led();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EMSESPSettingsService::begin() {
|
void EMSESPSettingsService::begin() {
|
||||||
|
|||||||
@@ -27,14 +27,13 @@
|
|||||||
|
|
||||||
#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0
|
#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0
|
||||||
#define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key
|
#define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key
|
||||||
|
|
||||||
#define EMSESP_DEFAULT_SYSLOG_LEVEL -1 // OFF
|
#define EMSESP_DEFAULT_SYSLOG_LEVEL -1 // OFF
|
||||||
#define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0
|
#define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0
|
||||||
#define EMSESP_DEFAULT_SYSLOG_HOST ""
|
#define EMSESP_DEFAULT_SYSLOG_HOST ""
|
||||||
|
|
||||||
#define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set
|
#define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set
|
||||||
#define EMSESP_DEFAULT_SHOWER_TIMER false
|
#define EMSESP_DEFAULT_SHOWER_TIMER false
|
||||||
#define EMSESP_DEFAULT_SHOWER_ALERT false
|
#define EMSESP_DEFAULT_SHOWER_ALERT false
|
||||||
|
#define EMSESP_DEFAULT_HIDE_LED false
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
@@ -42,13 +41,12 @@ enum MQTT_format : uint8_t { SINGLE = 1, NESTED, HA, CUSTOM };
|
|||||||
|
|
||||||
class EMSESPSettings {
|
class EMSESPSettings {
|
||||||
public:
|
public:
|
||||||
uint8_t tx_mode;
|
uint8_t tx_mode;
|
||||||
uint8_t ems_bus_id;
|
uint8_t ems_bus_id;
|
||||||
uint8_t master_thermostat;
|
uint8_t master_thermostat;
|
||||||
bool shower_timer;
|
bool shower_timer;
|
||||||
bool shower_alert;
|
bool shower_alert;
|
||||||
|
bool hide_led;
|
||||||
// syslog
|
|
||||||
int8_t syslog_level; // uuid::log::Level
|
int8_t syslog_level; // uuid::log::Level
|
||||||
uint32_t syslog_mark_interval;
|
uint32_t syslog_mark_interval;
|
||||||
String syslog_host;
|
String syslog_host;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ uuid::syslog::SyslogService System::syslog_;
|
|||||||
uint32_t System::heap_start_ = 0;
|
uint32_t System::heap_start_ = 0;
|
||||||
int System::reset_counter_ = 0;
|
int System::reset_counter_ = 0;
|
||||||
bool System::upload_status_ = false;
|
bool System::upload_status_ = false;
|
||||||
|
bool System::hide_led_ = false;
|
||||||
|
|
||||||
// send on/off to a gpio pin
|
// send on/off to a gpio pin
|
||||||
// value: true = HIGH, false = LOW
|
// value: true = HIGH, false = LOW
|
||||||
@@ -145,16 +146,20 @@ void System::start() {
|
|||||||
EMSESP::esp8266React.getWiFiSettingsService()->read(
|
EMSESP::esp8266React.getWiFiSettingsService()->read(
|
||||||
[&](WiFiSettings & wifiSettings) { LOG_INFO(F("System %s booted (EMS-ESP version %s)"), wifiSettings.hostname.c_str(), EMSESP_APP_VERSION); });
|
[&](WiFiSettings & wifiSettings) { LOG_INFO(F("System %s booted (EMS-ESP version %s)"), wifiSettings.hostname.c_str(), EMSESP_APP_VERSION); });
|
||||||
|
|
||||||
syslog_init(); // init SysLog
|
syslog_init(); // init SysLog
|
||||||
|
set_led(); // init LED
|
||||||
|
EMSESP::init_tx(); // start UART
|
||||||
|
}
|
||||||
|
|
||||||
if (LED_GPIO) {
|
// set the LED to on or off when in normal operating mode
|
||||||
pinMode(LED_GPIO, OUTPUT); // LED pin, 0 means disabled
|
void System::set_led() {
|
||||||
}
|
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) {
|
||||||
|
hide_led_ = settings.hide_led;
|
||||||
EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) { tx_mode_ = settings.tx_mode; });
|
if (LED_GPIO) {
|
||||||
#ifndef EMSESP_FORCE_SERIAL
|
pinMode(LED_GPIO, OUTPUT); // LED_GPIO 0 means disabled
|
||||||
EMSuart::start(tx_mode_); // start UART
|
digitalWrite(LED_GPIO, hide_led_ ? !LED_ON : LED_ON); // LED on, for ever
|
||||||
#endif
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if OTA is uploading
|
// returns true if OTA is uploading
|
||||||
@@ -261,7 +266,7 @@ void System::system_check() {
|
|||||||
if (!system_healthy_) {
|
if (!system_healthy_) {
|
||||||
system_healthy_ = true;
|
system_healthy_ = true;
|
||||||
if (LED_GPIO) {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,7 +560,7 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
shell.printfln(F_(wifi_password_fmt), wifiSettings.ssid.isEmpty() ? F_(unset) : F_(asterisks));
|
shell.printfln(F_(wifi_password_fmt), wifiSettings.ssid.isEmpty() ? F_(unset) : F_(asterisks));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
flash_string_vector{F_(show), F_(mqtt)},
|
flash_string_vector{F_(show), F_(mqtt)},
|
||||||
|
|||||||
12
src/system.h
12
src/system.h
@@ -63,6 +63,8 @@ class System {
|
|||||||
|
|
||||||
static void show_mem(const char * note);
|
static void show_mem(const char * note);
|
||||||
|
|
||||||
|
static void set_led();
|
||||||
|
|
||||||
void check_upgrade();
|
void check_upgrade();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -115,11 +117,11 @@ class System {
|
|||||||
static bool upload_status_; // true if we're in the middle of a OTA firmware upload
|
static bool upload_status_; // true if we're in the middle of a OTA firmware upload
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
uint8_t tx_mode_;
|
bool system_heartbeat_;
|
||||||
bool system_heartbeat_;
|
static bool hide_led_;
|
||||||
uint8_t syslog_level_;
|
uint8_t syslog_level_;
|
||||||
uint32_t syslog_mark_interval_;
|
uint32_t syslog_mark_interval_;
|
||||||
String syslog_host_;
|
String syslog_host_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
Reference in New Issue
Block a user