File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,17 @@ void blink_collision(void)
110110 led_right_off ();
111111}
112112
113+ /**
114+ * @brief Warn low battery using speaker sounds.
115+ */
116+ void warn_low_battery (void )
117+ {
118+ speaker_play ('C' , 4 , 0 , 0.05 );
119+ sleep_ticks (50 );
120+ speaker_play ('C' , 3 , 0 , 0.05 );
121+ sleep_ticks (50 );
122+ }
123+
113124/**
114125 * @brief Function to read button left.
115126 */
Original file line number Diff line number Diff line change 55
66#include "clock.h"
77#include "detection.h"
8+ #include "speaker.h"
89#include "speed.h"
910
1011void led_left_toggle (void );
@@ -18,6 +19,7 @@ void led_right_off(void);
1819void led_bluepill_off (void );
1920void repeat_blink (uint8_t count , uint16_t time );
2021void blink_collision (void );
22+ void warn_low_battery (void );
2123bool button_left_read (void );
2224bool button_right_read (void );
2325bool button_left_read_consecutive (uint32_t count );
Original file line number Diff line number Diff line change @@ -47,6 +47,24 @@ static void user_configuration(bool run)
4747 set_speed_mode (mode , run );
4848}
4949
50+ /**
51+ * @brief Check battery voltage and warn if the voltage is getting too low.
52+ */
53+ static void check_battery_voltage (void )
54+ {
55+ float voltage ;
56+
57+ voltage = get_battery_voltage ();
58+ if (voltage < 3.6 )
59+ warn_low_battery ();
60+ if (voltage < 3.5 )
61+ warn_low_battery ();
62+ if (voltage < 3.4 )
63+ warn_low_battery ();
64+ if (voltage < 3.3 )
65+ speaker_play ('C' , 3 , 0 , 2. );
66+ }
67+
5068/**
5169 * @brief Includes the functions to be executed before robot starts to move.
5270 */
@@ -56,6 +74,7 @@ static void before_moving(void)
5674 disable_walls_control ();
5775 repeat_blink (10 , 100 );
5876 sleep_us (5000000 );
77+ check_battery_voltage ();
5978 led_left_on ();
6079 led_right_on ();
6180 wait_front_sensor_close_signal (0.12 );
@@ -79,6 +98,7 @@ static void after_moving(void)
7998 repeat_blink (10 , 100 );
8099 }
81100 reset_motion ();
101+ check_battery_voltage ();
82102}
83103
84104/**
You can’t perform that action at this time.
0 commit comments