File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -969,10 +969,14 @@ void Arduino_AlvikCarrier::beginBehaviours(){
969
969
prev_illuminator_state = illuminator_state;
970
970
behaviours = 0 ;
971
971
first_lift = true ;
972
+ battery_alert_time = millis ();
973
+ battery_alert_wave = 100 ;
972
974
}
973
975
974
976
975
977
void Arduino_AlvikCarrier::updateBehaviours (){
978
+
979
+ // illuminator off on lift
976
980
if ((1 <<(LIFT_ILLUMINATOR-1 )) & behaviours){
977
981
978
982
if (isLifted ()&&first_lift){
@@ -990,11 +994,24 @@ void Arduino_AlvikCarrier::updateBehaviours(){
990
994
}
991
995
}
992
996
993
- if ((1 << (BATTERY_ALERT-1 )) & behaviours){
994
- led1->setRed (true );
995
- }
996
- else {
997
- led1->setRed (false );
997
+ // battery alert
998
+ if ((1 <<(BATTERY_ALERT-1 )) & behaviours){
999
+ if (getBatteryVoltage ()<BATTERY_ALERT_MINIMUM_VOLTAGE){
1000
+ if (battery_alert_time-millis ()>battery_alert_wave){
1001
+ battery_alert_time = millis ();
1002
+ if (battery_alert_wave==100 ){
1003
+ setAllLeds (COLOR_RED);
1004
+ battery_alert_wave=400 ;
1005
+ }
1006
+ else {
1007
+ setAllLeds (COLOR_BLACK);
1008
+ battery_alert_wave=100 ;
1009
+ }
1010
+ setRpm (0 ,0 );
1011
+ motor_left->stop ();
1012
+ motor_right->stop ();
1013
+ }
1014
+ }
998
1015
}
999
1016
1000
1017
}
Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ class Arduino_AlvikCarrier{
94
94
bool prev_illuminator_state;
95
95
uint8_t behaviours;
96
96
bool first_lift;
97
+ unsigned long battery_alert_time;
98
+ unsigned long battery_alert_wave;
97
99
98
100
99
101
Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ const float MOTION_FX_PERIOD = (1000U / MOTION_FX_FREQ);
95
95
#define VERSION_BYTE_MID 0
96
96
#define VERSION_BYTE_LOW 3
97
97
98
+ // Battery stats
99
+ #define BATTERY_ALERT_MINIMUM_VOLTAGE 3.4
100
+
98
101
99
102
100
103
#endif
You can’t perform that action at this time.
0 commit comments