@@ -188,6 +188,8 @@ int Arduino_Alvik::begin(const bool verbose, const uint8_t core){
188188
189189 set_illuminator (true );
190190 set_behaviour (BEHAVIOUR_ILLUMINATOR_RISE);
191+ set_behaviour (BEHAVIOUR_BATTERY_ALERT);
192+ set_servo_positions (servo_positions[0 ],servo_positions[1 ]);
191193
192194 return 0 ;
193195}
@@ -210,6 +212,7 @@ void Arduino_Alvik::idle(){
210212 while (!is_on ()){
211213 // read battery value
212214 battery = battery_measure ();
215+ battery_is_charging = true ;
213216 if (verbose_output){
214217 Serial.print (round (battery));
215218 Serial.println (" %" );
@@ -245,6 +248,7 @@ void Arduino_Alvik::update(const int delay_value){
245248 wait_for_ack ();
246249 set_illuminator (true );
247250 set_behaviour (BEHAVIOUR_ILLUMINATOR_RISE);
251+ set_behaviour (BEHAVIOUR_BATTERY_ALERT);
248252 }
249253 if (read_message ()){
250254 parse_message ();
@@ -372,6 +376,8 @@ int Arduino_Alvik::parse_message(){
372376 // get battery parcentage: state of charge
373377 case ' p' :
374378 packeter->unpacketC1F (code, battery);
379+ battery_is_charging = (battery > 0 ) ? true : false ;
380+ battery = abs (battery);
375381 break ;
376382
377383 // nothing is parsed, the command is newer to this library
@@ -927,6 +933,10 @@ int Arduino_Alvik::get_battery_charge(){
927933 return round (battery);
928934}
929935
936+ bool Arduino_Alvik::is_battery_charging (){
937+ return battery_is_charging;
938+ }
939+
930940
931941// -----------------------------------------------------------------------------------------------//
932942// leds and peripherials //
0 commit comments