clean up target list order (#3040)
[ExpressLRS.git] / src / lib / Handset / devHandset.cpp
blobbb9d2f0edd24551b5ec7a8e3da9cc9d6c65ed594
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 bool initialize()
18 #if defined(PLATFORM_ESP32)
19 if (GPIO_PIN_RCSIGNAL_RX == GPIO_PIN_RCSIGNAL_TX)
21 handset = new AutoDetect();
22 return true;
24 #endif
25 handset = new CRSFHandset();
26 return true;
29 static int start()
31 handset->Begin();
32 #if defined(DEBUG_TX_FREERUN)
33 handset->forceConnection();
34 #endif
35 return DURATION_IMMEDIATELY;
38 static int timeout()
40 handset->handleInput();
41 return DURATION_IMMEDIATELY;
44 static int event()
46 // An event should be generated every time the TX power changes
47 CRSF::LinkStatistics.uplink_TX_Power = powerToCrsfPower(PowerLevelContainer::currPower());
48 return DURATION_IGNORE;
51 device_t Handset_device = {
52 .initialize = initialize,
53 .start = start,
54 .event = event,
55 .timeout = timeout,
56 .subscribe = EVENT_POWER_CHANGED
58 #endif