LR1121 FSK (#2789)
[ExpressLRS.git] / src / lib / Handset / devHandset.cpp
blobe1892ca9ef2987ccac216ae5ade186be92849c35
1 #include "targets.h"
3 #ifdef TARGET_TX
5 #include "CRSF.h"
6 #include "CRSFHandset.h"
7 #include "POWERMGNT.h"
8 #include "devHandset.h"
10 #if defined(PLATFORM_ESP32)
11 #include "AutoDetect.h"
12 #endif
14 Handset *handset;
16 static void initialize()
18 #if defined(PLATFORM_ESP32)
19 if (GPIO_PIN_RCSIGNAL_RX == GPIO_PIN_RCSIGNAL_TX)
21 handset = new AutoDetect();
22 return;
24 #endif
25 handset = new CRSFHandset();
28 static int start()
30 handset->Begin();
31 #if defined(DEBUG_TX_FREERUN)
32 if (!handset->connect())
34 ERRLN("CRSF::connected has not been initialised");
36 #endif
37 return DURATION_IMMEDIATELY;
40 static int timeout()
42 handset->handleInput();
43 return DURATION_IMMEDIATELY;
46 static int event()
48 // An event should be generated every time the TX power changes
49 CRSF::LinkStatistics.uplink_TX_Power = powerToCrsfPower(PowerLevelContainer::currPower());
50 return DURATION_IGNORE;
53 device_t Handset_device = {
54 .initialize = initialize,
55 .start = start,
56 .event = event,
57 .timeout = timeout};
58 #endif