Skip to content

Commit 3979129

Browse files
committed
fix behaviour
1 parent a7a796f commit 3979129

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

examples/firmware/firmware.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ void loop(){
213213
case 1:
214214
alvik.setBehaviour(LIFT_ILLUMINATOR, true);
215215
break;
216+
case 2:
217+
alvik.setBehaviour(BATTERY_ALERT, true);
218+
break;
216219
default:
217220
alvik.setBehaviour(ALL_BEHAVIOURS, false);
218221
}

src/Arduino_AlvikCarrier.cpp

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -973,39 +973,30 @@ void Arduino_AlvikCarrier::beginBehaviours(){
973973

974974

975975
void Arduino_AlvikCarrier::updateBehaviours(){
976-
if (behaviours|=1 == 1){
977-
/*
976+
if ((1<<(LIFT_ILLUMINATOR-1)) & behaviours){
977+
978978
if (isLifted()&&first_lift){
979-
first_lift = false;
980-
prev_illuminator_state = illuminator_state;
981-
disableIlluminator();
979+
//disableIlluminator();
980+
setIlluminator(LOW);
981+
first_lift=false;
982982
}
983-
if (isLifted()&&!first_lift) {
984-
if (prev_illuminator_state!=0){
985-
disableIlluminator();
983+
else{
984+
if (!isLifted()){
985+
setIlluminator(prev_illuminator_state);
986986
}
987-
}
988-
if (!isLifted()&&!first_lift){
989-
if (prev_illuminator_state!=0){
990-
//first_lift = true;
991-
enableIlluminator();
987+
if (!isLifted()&&!first_lift){
988+
first_lift = true;
992989
}
993990
}
994-
*/
995-
if (isLifted()&&first_lift){
996-
//disableIlluminator();
997-
setIlluminator(LOW);
998-
first_lift=false;
999-
}
1000-
else{
1001-
if (!isLifted()){
1002-
setIlluminator(prev_illuminator_state);
1003-
}
1004-
if (!isLifted()&&!first_lift){
1005-
first_lift = true;
1006-
}
1007-
}
1008991
}
992+
993+
if ((1 << (BATTERY_ALERT-1)) & behaviours){
994+
led1->setRed(true);
995+
}
996+
else{
997+
led1->setRed(false);
998+
}
999+
10091000
}
10101001

10111002
void Arduino_AlvikCarrier::setBehaviour(const uint8_t behaviour, const bool enable){

src/definitions/robot_definitions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const float MOTOR_RATIO = MOTOR_CPR*MOTOR_GEAR_RATIO;
6868

6969
#define ALL_BEHAVIOURS 255
7070
#define LIFT_ILLUMINATOR 1
71+
#define BATTERY_ALERT 2
7172

7273

7374

0 commit comments

Comments
 (0)