Skip to content

Commit 3cfec7f

Browse files
authored
Merge pull request #13 from gbr1/dev
0.0.5
2 parents 700229c + 305ebd8 commit 3cfec7f

33 files changed

+1610
-95
lines changed

examples/battery/battery.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221

322
Arduino_Robot_Firmware robot;

examples/blink/blink.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221

322

examples/demo_01/demo_01.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221
#include "sensor_line.h"
322

examples/demo_02/demo_02.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221
#include "sensor_line.h"
322

examples/firmware_01/firmware_01.ino

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
This file is part of the Arduino_GroveI2C_Ultrasonic library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include "Arduino_Robot_Firmware.h"
21+
#include "sensor_line.h"
22+
#include "sensor_tof_matrix.h"
23+
#include "ucPack.h"
24+
25+
Arduino_Robot_Firmware robot;
26+
SensorLine line(EXT_A2,EXT_A1,EXT_A0);
27+
SensorTofMatrix tof(robot.wire, EXT_GPIO3, EXT_GPIO2);
28+
29+
30+
ucPack packeter(200);
31+
32+
uint8_t code;
33+
uint8_t msg_size;
34+
35+
unsigned long tmotor=0;
36+
unsigned long tsend=0;
37+
unsigned long tsensor=0;
38+
39+
40+
float left, right;
41+
uint8_t leds;
42+
43+
uint8_t sensor_id = 0;
44+
45+
46+
uint8_t pid;
47+
float kp, ki, kd;
48+
49+
50+
51+
void setup(){
52+
Serial.begin(115200);
53+
robot.begin();
54+
robot.setLedBuiltin(HIGH);
55+
line.begin();
56+
tof.begin();
57+
58+
uint8_t version[3];
59+
robot.getVersion(version[0], version[1], version[2]);
60+
msg_size = packeter.packetC3B(0x7E, version[0], version[1], version[2]);
61+
robot.serial->write(packeter.msg,msg_size);
62+
63+
robot.setLedBuiltin(LOW);
64+
65+
66+
code=0;
67+
tmotor=millis();
68+
tsend=millis();
69+
tsensor=millis();
70+
}
71+
72+
void loop(){
73+
while(robot.serial->available() > 0) {
74+
packeter.buffer.push(robot.serial->read());
75+
}
76+
if (packeter.checkPayload()) {
77+
code = packeter.payloadTop();
78+
switch (code){
79+
case 'J':
80+
packeter.unpacketC2F(code,left,right);
81+
robot.setRpm(left, right);
82+
break;
83+
/*
84+
case 'S':
85+
robot.setRpm(0,0);
86+
break;
87+
*/
88+
case 'L':
89+
packeter.unpacketC1B(code,leds);
90+
robot.setAllLeds(leds);
91+
break;
92+
93+
case 'P':
94+
packeter.unpacketC1B3F(code,pid,kp,ki,kd);
95+
if (pid=='L'){
96+
robot.setKPidLeft(kp,ki,kd);
97+
}
98+
if (pid=='R'){
99+
robot.setKPidRight(kp,ki,kd);
100+
}
101+
break;
102+
}
103+
}
104+
105+
if (millis()-tsensor>10){
106+
tsensor=millis();
107+
switch(sensor_id){
108+
case 0:
109+
line.update();
110+
msg_size = packeter.packetC3I('l', line.getLeft(), line.getCenter(), line.getRight());
111+
robot.serial->write(packeter.msg,msg_size);
112+
break;
113+
case 1:
114+
robot.updateTouch();
115+
msg_size = packeter.packetC1B('t', robot.getTouchKeys());
116+
robot.serial->write(packeter.msg,msg_size);
117+
break;
118+
case 2:
119+
robot.updateAPDS();
120+
msg_size = packeter.packetC3I('c', robot.getRed(), robot.getGreen(), robot.getBlue());
121+
robot.serial->write(packeter.msg,msg_size);
122+
break;
123+
case 3:
124+
tof.update();
125+
msg_size = packeter.packetC7I('f', tof.getLeft(), tof.getCenterLeft(), tof.getCenter(), tof.getCenterRight(), tof.getRight(), tof.get_min_range_top_mm(), tof.get_max_range_bottom_mm());
126+
robot.serial->write(packeter.msg,msg_size);
127+
break;
128+
case 4:
129+
msg_size = packeter.packetC3F('q', robot.getRoll(), robot.getPitch(), robot.getYaw());
130+
robot.serial->write(packeter.msg,msg_size);
131+
break;
132+
}
133+
sensor_id++;
134+
if (sensor_id>4){
135+
sensor_id=0;
136+
}
137+
}
138+
139+
if (millis()-tmotor>10){
140+
tmotor=millis();
141+
robot.updateMotors();
142+
robot.updateImu();
143+
msg_size = packeter.packetC2F('j', robot.getRpmLeft(),robot.getRpmRight());
144+
robot.serial->write(packeter.msg,msg_size);
145+
msg_size = packeter.packetC6F('i', robot.getAccelerationX(), robot.getAccelerationY(), robot.getAccelerationZ(), robot.getAngularVelocityX(), robot.getAngularVelocityY(), robot.getAngularVelocityZ());
146+
robot.serial->write(packeter.msg,msg_size);
147+
}
148+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef _PLATFORM_CONFIG_DEFAULT_H_
2+
#define _PLATFORM_CONFIG_DEFAULT_H_
3+
4+
5+
#ifndef VL53L7CX_NB_TARGET_PER_ZONE
6+
#define VL53L7CX_NB_TARGET_PER_ZONE 1U
7+
#endif
8+
9+
10+
// #define VL53L7CX_USE_RAW_FORMAT
11+
12+
13+
#define VL53L7CX_DISABLE_AMBIENT_PER_SPAD
14+
#define VL53L7CX_DISABLE_NB_SPADS_ENABLED
15+
#define VL53L7CX_DISABLE_NB_TARGET_DETECTED
16+
#define VL53L7CX_DISABLE_SIGNAL_PER_SPAD
17+
#define VL53L7CX_DISABLE_RANGE_SIGMA_MM
18+
// #define VL53L7CX_DISABLE_DISTANCE_MM
19+
#define VL53L7CX_DISABLE_REFLECTANCE_PERCENT
20+
#define VL53L7CX_DISABLE_TARGET_STATUS
21+
#define VL53L7CX_DISABLE_MOTION_INDICATOR
22+
23+
#endif // _PLATFORM_CONFIG_DEFAULT_H_

examples/imu/imu.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Wire.h"
221
#include "motion_fx.h"
322
#include "LSM6DSOSensor.h"

examples/line/line.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221
#include "sensor_line.h"
322

examples/motor/motor.ino

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
This file is part of the Arduino Alvik library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
120
#include "Arduino_Robot_Firmware.h"
221

322
Arduino_Robot_Firmware robot;

0 commit comments

Comments
 (0)