@@ -15,8 +15,6 @@ class Arduino_Robot_Firmware{
1515 APDS9960 * apds9960;
1616 int bottom_red, bottom_green, bottom_blue, bottom_clear, bottom_proximity;
1717
18-
19-
2018 public:
2119 RGBled * led1;
2220 RGBled * led2;
@@ -27,82 +25,22 @@ class Arduino_Robot_Firmware{
2725 TwoWire * wire;
2826
2927
30- Arduino_Robot_Firmware (){
31- // I2C internal bus
32- wire = new TwoWire (I2C_1_SDA, I2C_1_SCL);
33-
34- // RGB leds
35- led1 = new RGBled (LED_1_RED,LED_1_GREEN,LED_1_BLUE);
36- led2 = new RGBled (LED_2_RED,LED_2_GREEN,LED_2_BLUE);
37-
38- // motors
39- motor_left = new DCmotor (MOTOR_LEFT_A,MOTOR_LEFT_A_CH, MOTOR_LEFT_B, MOTOR_LEFT_B_CH,true );
40- motor_right = new DCmotor (MOTOR_RIGHT_A,MOTOR_RIGHT_A_CH,MOTOR_RIGHT_B,MOTOR_RIGHT_B_CH);
41-
42- // encoders
43- encoder_left = new Encoder (TIM3);
44- encoder_right = new Encoder (TIM5);
45-
46- // color sensor
47- apds9960 = new APDS9960 (*wire,APDS_INT);
48-
49- }
50-
51- int begin (){
52- // setup alternate functions
53- AF_Tim2_pwm ();
54- AF_Tim5_pins_encoder ();
55- AF_Tim3_pins_encoder ();
56-
57- // turn off leds
58- led1->clear ();
59- led2->clear ();
60-
61- motor_left->begin ();
62- motor_right->begin ();
63- motor_left->stop ();
64- motor_right->stop ();
65-
66- encoder_left->begin ();
67- encoder_right->begin ();
68-
69- wire->begin ();
70-
71- pinMode (APDS_LED,OUTPUT);
72- digitalWrite (APDS_LED,HIGH);
73- apds9960->begin ();
74-
75-
76-
77- return 0 ;
78- }
79-
80- void updateAPDS (){
81- if (apds9960->proximityAvailable ()){
82- bottom_proximity=apds9960->readProximity ();
83- }
84- // digitalWrite(APDS_LED,HIGH);
85- if (apds9960->colorAvailable ()){
86- apds9960->readColor (bottom_red,bottom_green,bottom_blue,bottom_clear);
87- }
88- // digitalWrite(APDS_LED,LOW);
89- }
28+ Arduino_Robot_Firmware ();
9029
91- int getRed (){
92- return bottom_red;
93- }
30+ int begin ();
9431
95- int getGreen (){
96- return bottom_green;
97- }
9832
99- int getBlue (){
100- return bottom_blue;
101- }
10233
103- int getProximity (){
104- return bottom_proximity;
105- }
34+ // Color sensor, APDS9960
35+ int beginAPDS (); // initialize all components required by color detection
36+ void updateAPDS (); // refresh data
37+ void setIlluminator (uint8_t value); // set white leds
38+ void enableIlluminator (); // white leds on
39+ void disableIlluminator (); // white leds off
40+ int getRed (); // red value 0-255
41+ int getGreen (); // green value 0-255
42+ int getBlue (); // blue value 0-255
43+ int getProximity (); // proximity value 0-127
10644};
10745
10846#endif
0 commit comments