Skip to content

Commit 6f74a6e

Browse files
committed
fixed get version
1 parent b3bde5c commit 6f74a6e

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

examples/firmware_01/firmware_01.ino

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ uint8_t code;
2828
uint8_t label;
2929
uint8_t control_type;
3030
uint8_t msg_size;
31-
uint8_t ack_required=0;
32-
bool ack_check=false;
33-
uint8_t ack_code=0;
31+
uint8_t ack_required = 0;
32+
bool ack_check = false;
33+
uint8_t ack_code = 0;
3434
uint8_t behaviours;
3535

36-
unsigned long tmotor=0;
37-
unsigned long tsend=0;
38-
unsigned long tsensor=0;
39-
unsigned long timu=0;
40-
unsigned long tack=0;
41-
unsigned long tbehaviours=0;
36+
unsigned long tmotor = 0;
37+
unsigned long tsend = 0;
38+
unsigned long tsensor = 0;
39+
unsigned long timu = 0;
40+
unsigned long tack = 0;
41+
unsigned long tbehaviours = 0;
4242

4343

4444
float left, right, value;
@@ -54,6 +54,9 @@ float x, y, theta;
5454

5555
uint8_t servo_A, servo_B;
5656

57+
int counter_version = 9;
58+
uint8_t version[3];
59+
5760

5861
void setup(){
5962
Serial.begin(115200);
@@ -64,7 +67,7 @@ void setup(){
6467
line.begin();
6568
tof.begin();
6669

67-
uint8_t version[3];
70+
6871
alvik.getVersion(version[0], version[1], version[2]);
6972
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
7073
alvik.serial->write(packeter.msg,msg_size);
@@ -256,6 +259,12 @@ void loop(){
256259
// acknowledge
257260
if (millis()-tack > 100){
258261
tack = millis();
262+
if (counter_version>0){
263+
counter_version--;
264+
alvik.getVersion(version[0], version[1], version[2]);
265+
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
266+
alvik.serial->write(packeter.msg,msg_size);
267+
}
259268
if (ack_check && alvik.isTargetReached()){
260269
if (ack_required == MOVEMENT_ROTATE){
261270
msg_size = packeter.packetC1B('x', 'R');

0 commit comments

Comments
 (0)