Skip to content

Commit b94e34c

Browse files
committed
added behaviour alert
1 parent f950145 commit b94e34c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Arduino_Alvik.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 //

src/Arduino_Alvik.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Arduino_Alvik{
8888
float battery_soc;
8989
uint16_t battery_val = 0;
9090
uint8_t battery_v[2];
91+
bool battery_is_charging;
9192

9293

9394

@@ -266,6 +267,7 @@ class Arduino_Alvik{
266267
bool check_firmware_compatibility();
267268

268269
int get_battery_charge();
270+
bool is_battery_charging();
269271
};
270272

271273

src/definitions.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
#define LIB_VER_UP 1
2121
#define LIB_VER_MID 0
22-
#define LIB_VER_LOW 2
22+
#define LIB_VER_LOW 3
2323

2424
#define REQUIRED_FW_VER_UP 1
2525
#define REQUIRED_FW_VER_MID 0
26-
#define REQUIRED_FW_VER_LOW 3
26+
#define REQUIRED_FW_VER_LOW 4
2727

2828

2929
#define RUN_ON_CORE_0 0
@@ -92,6 +92,7 @@ const float ROTATIONAL_SPEED_UNITS[4] = {1.0, 0.16666666666, 9.54929658551, 60.0
9292
// behaviours
9393
#define BEHAVIOUR_DISABLED 0
9494
#define BEHAVIOUR_ILLUMINATOR_RISE 1
95+
#define BEHAVIOUR_BATTERY_ALERT 2
9596

9697

9798
// colors

0 commit comments

Comments
 (0)