T114Board.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. // built-ins
  6. #define PIN_VBAT_READ 4
  7. #define PIN_BAT_CTL 6
  8. #define MV_LSB (3000.0F / 4096.0F) // 12-bit ADC with 3.0V input range
  9. class T114Board : public NRF52BoardDCDC {
  10. public:
  11. T114Board() : NRF52Board("T114_OTA") {}
  12. void begin();
  13. #if defined(P_LORA_TX_LED)
  14. void onBeforeTransmit() override {
  15. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
  16. }
  17. void onAfterTransmit() override {
  18. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
  19. }
  20. #endif
  21. uint16_t getBattMilliVolts() override {
  22. int adcvalue = 0;
  23. analogReadResolution(12);
  24. analogReference(AR_INTERNAL_3_0);
  25. pinMode(PIN_BAT_CTL, OUTPUT); // battery adc can be read only ctrl pin 6 set to high
  26. digitalWrite(PIN_BAT_CTL, 1);
  27. delay(10);
  28. adcvalue = analogRead(PIN_VBAT_READ);
  29. digitalWrite(6, 0);
  30. return (uint16_t)((float)adcvalue * MV_LSB * 4.9);
  31. }
  32. const char* getManufacturerName() const override {
  33. return "Heltec T114";
  34. }
  35. void powerOff() override {
  36. #ifdef LED_PIN
  37. digitalWrite(LED_PIN, HIGH);
  38. #endif
  39. #if ENV_INCLUDE_GPS == 1
  40. pinMode(GPS_EN, OUTPUT);
  41. digitalWrite(GPS_EN, LOW);
  42. #endif
  43. sd_power_system_off();
  44. }
  45. };