mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-11 10:47:10 +01:00
crash,lights: ensure that settings contain positive value
This commit is contained in:
@@ -190,7 +190,7 @@ void crashSetup() {
|
||||
// Minumum of 16 and align for column formatter in crashDump()
|
||||
// Maximum of flash sector size minus reserved space at the beginning
|
||||
const uint16_t trace_max = constrain(
|
||||
((getSetting("sysTraceMax", SAVE_CRASH_STACK_TRACE_MAX).toInt() + 15) & -16),
|
||||
abs((getSetting("sysTraceMax", SAVE_CRASH_STACK_TRACE_MAX).toInt() + 15) & -16),
|
||||
0, (SPI_FLASH_SEC_SIZE - crashUsedSpace())
|
||||
);
|
||||
|
||||
|
||||
@@ -1172,6 +1172,10 @@ void _lightAPISetup() {
|
||||
|
||||
#if TERMINAL_SUPPORT
|
||||
|
||||
void _lightChannelDebug(unsigned char id) {
|
||||
DEBUG_MSG_P(PSTR("Channel #%u (%s): %d\n"), id, lightDesc(id).c_str(), lightChannel(id));
|
||||
}
|
||||
|
||||
void _lightInitCommands() {
|
||||
|
||||
terminalRegisterCommand(F("BRIGHTNESS"), [](Embedis* e) {
|
||||
@@ -1184,14 +1188,17 @@ void _lightInitCommands() {
|
||||
});
|
||||
|
||||
terminalRegisterCommand(F("CHANNEL"), [](Embedis* e) {
|
||||
if (e->argc < 2) {
|
||||
terminalError(F("CHANNEL <ID> [<VALUE>]"));
|
||||
return;
|
||||
if (!lightChannels()) return;
|
||||
|
||||
auto id = -1;
|
||||
if (e->argc > 1) {
|
||||
id = String(e->argv[1]).toInt();
|
||||
}
|
||||
|
||||
const int id = String(e->argv[1]).toInt();
|
||||
if (id < 0 || id >= lightChannels()) {
|
||||
terminalError(F("Channel value out of range"));
|
||||
if (id < 0 || id >= static_cast<decltype(id)>(lightChannels())) {
|
||||
for (unsigned char index = 0; index < lightChannels(); ++index) {
|
||||
_lightChannelDebug(index);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1200,7 +1207,8 @@ void _lightInitCommands() {
|
||||
lightUpdate(true, true);
|
||||
}
|
||||
|
||||
DEBUG_MSG_P(PSTR("Channel #%u (%s): %d\n"), id, lightDesc(id).c_str(), lightChannel(id));
|
||||
_lightChannelDebug(id);
|
||||
|
||||
terminalOK();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user