Files
MeshCore-Solo/variants/heltec_v2/HeltecV2Board.h
T

47 lines
1.0 KiB
C++
Raw Normal View History

2025-02-11 12:36:26 +11:00
#pragma once
#include <Arduino.h>
2025-10-11 23:35:10 +02:00
#include <helpers/ESP32Board.h>
2025-02-11 12:36:26 +11:00
// built-ins
#define PIN_VBAT_READ 37
#define PIN_LED_BUILTIN 25
class HeltecV2Board : public ESP32Board {
public:
void begin() {
ESP32Board::begin();
esp_reset_reason_t reason = esp_reset_reason();
if (reason == ESP_RST_DEEPSLEEP) {
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
2026-02-13 23:13:46 +07:00
if (wakeup_source & (1 << P_LORA_DIO_0)) { // received a LoRa packet (while in deep sleep)
2025-02-11 12:36:26 +11:00
startup_reason = BD_STARTUP_RX_PACKET;
}
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
2026-02-13 23:13:46 +07:00
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_0);
2025-02-11 12:36:26 +11:00
}
}
uint16_t getBattMilliVolts() override {
analogReadResolution(10);
uint32_t raw = 0;
for (int i = 0; i < 8; i++) {
raw += analogRead(PIN_VBAT_READ);
}
raw = raw / 8;
2025-06-20 10:31:39 -07:00
return (1.98 * (2 / 1024.0) * raw) * 1000;
2025-02-11 12:36:26 +11:00
}
const char* getManufacturerName() const override {
return "Heltec V2";
}
2026-02-13 23:13:46 +07:00
uint32_t getIRQGpio() override {
return P_LORA_DIO_0; // default for SX1276
}
2025-02-11 12:36:26 +11:00
};