-
Notifications
You must be signed in to change notification settings - Fork 1
/
telemetry.cpp
77 lines (62 loc) · 1.91 KB
/
telemetry.cpp
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
/*
* 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 "telemetry.h"
RCSportEmu sport(PIN_SPORT, 2, 1);
RCSport::data_t *rssi = NULL;
RCSport::data_t *battery = NULL;
ARCommands *tele_md;
extern ARNetwork mdLink;
uint32_t lastUpdate = 0;
uint32_t updateTime = 2000;
/*
void isrSport(){
sport.isr();
}
*/
void telemetry_init(ARCommands *ar){
tele_md = ar;
// timerAttachInterrupt(sport.getTimer(), isrSport, false);
rssi = sport.addSensor();
rssi->id = RCSport::RSSI_ID;
// rssi->value = tele_md->getRSSI();
// rssi->value = 100;
battery = sport.addSensor();
battery->id = RCSport::BATT_ID;
battery->value = tele_md->getBattery();
// Serial.println("telemetry init'd");
// lastUpdate = millis();
}
bool telemetry_update(){
// Serial.println("update ?");
if(!sport.update()) return false;
// Serial.println("yes !");
battery->value = tele_md->getBattery();
// rssi->value = tele_md->getRSSI();
// Check what offset to add.
rssi->value = 100 + mdLink.getRSSI();
// Serial.printf("RSSI from MD : %i\n", tele_md->getRSSI());
return true;
}
void telemetry_start(){
// Serial.println("telemetry started");
sport.start();
}
void telemetry_stop(){
// Serial.println("telemetry stopped");
sport.stop();
}