-
Notifications
You must be signed in to change notification settings - Fork 1
/
parrot_esp.ino
98 lines (76 loc) · 2.47 KB
/
parrot_esp.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* This program is part an esp32-based controller to pilot Parrot Minidrones
* Copyright (C) 2021 Pierre-Loup Martin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parrot_esp.h"
ARCommands minidrone;
ARNetwork mdLink(&minidrone);
void initSystems(){
// testConvertTools();
mdLink.init();
telemetry_init(&minidrone);
control_init(&minidrone);
minidrone.sendAllSettings();
// Optionnal
minidrone.sendPreferredPilotingMode(2);
telemetry_start();
}
void mainLoop(){
// Check that connexion is sitll alive, or try to reconnect. Not really tried yet.
if(!mdLink.checkConnection()){
telemetry_stop();
if(mdLink.checkConnection()) telemetry_start();
return;
}
// check for new controls from transmitter.
control_update();
minidrone.update();
mdLink.update();
// Serial.printf("RSSI : %i\n", mdLink.getRSSI());
telemetry_update();
}
void setup(){
// Use for "debug" purpose only.
// Part of the debug informations use the log library made avaiable by the esp ide. Set debug level when compiling.
Serial.begin(115200);
initSystems();
// Telemetry initialisation.
// telemetry_init();
}
void loop(){
mainLoop();
// telemetry_update();
}
// Developpement only.
void testConvertTools(){
uint8_t table[] = {0x00, 0x12, 0xCD, 0xFF};
int16_t value = tools_bufferToInt16t(table);
uint16_t unsignedValue = tools_bufferToUint16t(table);
Serial.printf("bytes : ");
for(uint8_t i = 0; i < 4; ++i){
Serial.printf("%02X ", table[i]);
}
Serial.println();
Serial.printf("int16_t : %04X\n", value);
Serial.printf("uint16_t : %04X\n", unsignedValue);
int32_t value2 = tools_bufferToInt32t(table);
uint32_t unsignedValue2 = tools_bufferToUint32t(table);
Serial.printf("int32_t : %08X\n", value2);
Serial.printf("uint32_t : %08X\n", unsignedValue2);
Serial.printf("size of float : %i\n", sizeof(float));
Serial.printf("size of double : %i\n", sizeof(double));
while(1);
}