Skip to content

Commit 22b75b6

Browse files
author
jenkie
committed
Move shutdown checks from slow loop to fast loop
1 parent bfc2e75 commit 22b75b6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Arduino_Pedelec_Controller/Arduino_Pedelec_Controller.ino

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,19 @@ void loop()
801801
throttle_pre = throttle_stat;
802802
}
803803
}
804-
#endif
804+
#endif
805+
806+
#if HARDWARE_REV >= 2
807+
// Emergency power down to protect battery from undervoltage. Also saves to EEPROM
808+
// Don't shut down on USB power.
809+
if (voltage < vemergency_shutdown
810+
&& voltage_2s > 6.0)
811+
{
812+
display_show_important_info(FROM_FLASH(msg_emergency_shutdown), 60);
813+
save_shutdown();
814+
}
815+
#endif
816+
805817
//slow loop start----------------------//use this subroutine to place any functions which should happen only once a second
806818
if (millis()-last_writetime > 1000) //don't do this more than once a second
807819
{
@@ -847,16 +859,6 @@ void loop()
847859
}
848860
}
849861

850-
// Emergency power down to protect battery from undervoltage.
851-
// Also checks averaged voltage to prevent ADC read errors killing the system.
852-
// Don't shut down on USB power, too.
853-
if (voltage < vemergency_shutdown && voltage_display < vemergency_shutdown
854-
&& voltage > 6.0)
855-
{
856-
display_show_important_info(FROM_FLASH(msg_emergency_shutdown), 60);
857-
delay(1000);
858-
save_shutdown();
859-
}
860862
#endif
861863
#ifdef SUPPORT_HRMI
862864
pulse_human=getHeartRate();

0 commit comments

Comments
 (0)