mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Small refactors
This commit is contained in:
parent
7e34936e6b
commit
e06793eb8c
@ -224,13 +224,13 @@ void ButtonInit(void) {
|
|||||||
// Button.last_state[i] = digitalRead(Pin(GPIO_KEY1, i)); // Set global now so doesn't change the saved power state on first button check
|
// Button.last_state[i] = digitalRead(Pin(GPIO_KEY1, i)); // Set global now so doesn't change the saved power state on first button check
|
||||||
Button.last_state[i] = (digitalRead(Pin(GPIO_KEY1, i)) != bitRead(Button.inverted_mask, i));
|
Button.last_state[i] = (digitalRead(Pin(GPIO_KEY1, i)) != bitRead(Button.inverted_mask, i));
|
||||||
}
|
}
|
||||||
Button.virtual_state[i] = Button.last_state[i];
|
|
||||||
}
|
}
|
||||||
#ifdef USE_ADC
|
#ifdef USE_ADC
|
||||||
else if (PinUsed(GPIO_ADC_BUTTON, i) || PinUsed(GPIO_ADC_BUTTON_INV, i)) {
|
else if (PinUsed(GPIO_ADC_BUTTON, i) || PinUsed(GPIO_ADC_BUTTON_INV, i)) {
|
||||||
Button.present++;
|
Button.present++;
|
||||||
}
|
}
|
||||||
#endif // USE_ADC
|
#endif // USE_ADC
|
||||||
|
Button.virtual_state[i] = Button.last_state[i];
|
||||||
}
|
}
|
||||||
if (Button.present) {
|
if (Button.present) {
|
||||||
Button.first_change = true;
|
Button.first_change = true;
|
||||||
|
@ -197,7 +197,7 @@ void SwitchInit(void) {
|
|||||||
|
|
||||||
Switch.present = 0;
|
Switch.present = 0;
|
||||||
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
||||||
Switch.last_state[i] = 1; // Init global to virtual switch state;
|
Switch.last_state[i] = NOT_PRESSED; // Init global to virtual switch state;
|
||||||
if (PinUsed(GPIO_SWT1, i)) {
|
if (PinUsed(GPIO_SWT1, i)) {
|
||||||
Switch.present++;
|
Switch.present++;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
@ -266,9 +266,9 @@ void EnergyUpdateToday(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (delta_sum_balanced > 0) {
|
if (delta_sum_balanced > 0) {
|
||||||
Energy.daily_sum_import_balanced += (float) delta_sum_balanced / 100000;
|
Energy.daily_sum_import_balanced += (float)delta_sum_balanced / 100000;
|
||||||
} else {
|
} else {
|
||||||
Energy.daily_sum_export_balanced += (float) abs(delta_sum_balanced) / 100000;
|
Energy.daily_sum_export_balanced += (float)abs(delta_sum_balanced) / 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RtcTime.valid){ // We calc the difference only if we have a valid RTC time.
|
if (RtcTime.valid){ // We calc the difference only if we have a valid RTC time.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user