2025-03-06 20:43:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <MeshCore.h>
|
|
|
|
|
#include <Arduino.h>
|
2025-12-12 19:01:15 +07:00
|
|
|
#include <helpers/NRF52Board.h>
|
2025-03-06 20:43:56 +01:00
|
|
|
|
|
|
|
|
// built-ins
|
|
|
|
|
#define PIN_VBAT_READ 4
|
2025-03-20 11:08:13 +01:00
|
|
|
#define PIN_BAT_CTL 6
|
|
|
|
|
#define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
|
2025-03-06 20:43:56 +01:00
|
|
|
|
2025-12-20 10:44:13 +01:00
|
|
|
class T114Board : public NRF52BoardDCDC {
|
2026-01-23 17:18:41 +11:00
|
|
|
protected:
|
|
|
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
|
|
|
void initiateShutdown(uint8_t reason) override;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-06 20:43:56 +01:00
|
|
|
public:
|
2025-12-20 10:44:13 +01:00
|
|
|
T114Board() : NRF52Board("T114_OTA") {}
|
2025-03-06 20:43:56 +01:00
|
|
|
void begin();
|
|
|
|
|
|
2025-03-07 21:37:05 +11:00
|
|
|
#if defined(P_LORA_TX_LED)
|
|
|
|
|
void onBeforeTransmit() override {
|
|
|
|
|
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
|
|
|
|
|
}
|
|
|
|
|
void onAfterTransmit() override {
|
|
|
|
|
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-06 20:43:56 +01:00
|
|
|
uint16_t getBattMilliVolts() override {
|
2025-03-20 11:08:13 +01:00
|
|
|
int adcvalue = 0;
|
2025-03-06 20:43:56 +01:00
|
|
|
analogReadResolution(12);
|
2025-03-20 11:08:13 +01:00
|
|
|
analogReference(AR_INTERNAL_3_0);
|
|
|
|
|
pinMode(PIN_BAT_CTL, OUTPUT); // battery adc can be read only ctrl pin 6 set to high
|
|
|
|
|
digitalWrite(PIN_BAT_CTL, 1);
|
|
|
|
|
|
|
|
|
|
delay(10);
|
|
|
|
|
adcvalue = analogRead(PIN_VBAT_READ);
|
|
|
|
|
digitalWrite(6, 0);
|
2025-03-06 20:43:56 +01:00
|
|
|
|
2025-03-20 11:08:13 +01:00
|
|
|
return (uint16_t)((float)adcvalue * MV_LSB * 4.9);
|
2025-03-06 20:43:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* getManufacturerName() const override {
|
|
|
|
|
return "Heltec T114";
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-08 20:01:31 +10:00
|
|
|
void powerOff() override {
|
2026-01-23 17:18:41 +11:00
|
|
|
#ifdef LED_PIN
|
2025-11-22 02:06:44 +01:00
|
|
|
digitalWrite(LED_PIN, HIGH);
|
2026-01-23 17:18:41 +11:00
|
|
|
#endif
|
|
|
|
|
#if ENV_INCLUDE_GPS == 1
|
2025-11-22 02:06:44 +01:00
|
|
|
pinMode(GPS_EN, OUTPUT);
|
|
|
|
|
digitalWrite(GPS_EN, LOW);
|
2026-01-23 17:18:41 +11:00
|
|
|
#endif
|
2025-08-08 20:01:31 +10:00
|
|
|
sd_power_system_off();
|
|
|
|
|
}
|
2025-03-06 20:43:56 +01:00
|
|
|
};
|