diff --git a/variants/heltec_ct62/HT-CT62Board.h b/variants/heltec_ct62/HT-CT62Board.h new file mode 100644 index 00000000..e5a627b8 --- /dev/null +++ b/variants/heltec_ct62/HT-CT62Board.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include + +#if defined(ESP_PLATFORM) + +#include + +class Heltec_CT62_Board : public ESP32Board { +public: + +uint16_t getBattMilliVolts() override { + #ifdef PIN_VBAT_READ + analogReadResolution(12); // ESP32-C3 ADC is 12-bit - 3.3/4096 (ref voltage/max counts) + uint32_t raw = 0; + for (int i = 0; i < 8; i++) { + raw += analogRead(PIN_VBAT_READ); + } + raw = raw / 8; + + return ((6.52 * raw) / 1024.0) * 1000; + #else + return 0; // not supported + #endif + } + + const char* getManufacturerName() const override { + return "Heltec CT62"; + } +}; + +#endif diff --git a/variants/heltec_ct62/platformio.ini b/variants/heltec_ct62/platformio.ini index bf7116a2..ba23a5a6 100644 --- a/variants/heltec_ct62/platformio.ini +++ b/variants/heltec_ct62/platformio.ini @@ -12,12 +12,13 @@ build_flags = -D P_LORA_TX_LED=18 -D PIN_BOARD_SDA=0 -D PIN_BOARD_SCL=1 - -D PIN_USER_BTN=9 + ;-D PIN_USER_BTN=9 -D PIN_VBAT_READ=2 -D P_LORA_DIO_1=3 -D P_LORA_NSS=8 -D P_LORA_RESET=5 - -D P_LORA_RESET=RADIOLIB_NC + -D P_LORA_DIO_0=RADIOLIB_NC + -D P_LORA_DIO_2=RADIOLIB_NC -D P_LORA_BUSY=4 -D P_LORA_SCLK=10 -D P_LORA_MISO=6 @@ -80,6 +81,7 @@ build_flags = ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_ct62.build_src_filter} +<../examples/companion_radio> + + lib_deps = ${Heltec_ct62.lib_deps} ${esp32_ota.lib_deps} diff --git a/variants/heltec_ct62/target.cpp b/variants/heltec_ct62/target.cpp index df43bc45..eae43bd1 100644 --- a/variants/heltec_ct62/target.cpp +++ b/variants/heltec_ct62/target.cpp @@ -1,14 +1,9 @@ #include #include "target.h" -ESP32Board board; - -#if defined(P_LORA_SCLK) - RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); -#else - RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); -#endif +Heltec_CT62_Board board; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); WRAPPER_CLASS radio_driver(radio, board); ESP32RTCClock fallback_clock; @@ -72,4 +67,4 @@ void radio_set_tx_power(uint8_t dbm) { mesh::LocalIdentity radio_new_identity() { RadioNoiseListener rng(radio); return mesh::LocalIdentity(&rng); // create new random identity -} +} \ No newline at end of file diff --git a/variants/heltec_ct62/target.h b/variants/heltec_ct62/target.h index eef923ab..ff114e6e 100644 --- a/variants/heltec_ct62/target.h +++ b/variants/heltec_ct62/target.h @@ -3,12 +3,12 @@ #define RADIOLIB_STATIC_ONLY 1 #include #include -#include +#include "HT-CT62Board.h" #include #include #include -extern ESP32Board board; +extern Heltec_CT62_Board board; extern WRAPPER_CLASS radio_driver; extern AutoDiscoverRTCClock rtc_clock; extern SensorManager sensors; @@ -17,4 +17,4 @@ bool radio_init(); uint32_t radio_get_rng_seed(); void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); void radio_set_tx_power(uint8_t dbm); -mesh::LocalIdentity radio_new_identity(); +mesh::LocalIdentity radio_new_identity(); \ No newline at end of file