ThinkNodeM1Board.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. // built-ins
  5. #define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
  6. #define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
  7. #define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
  8. #define PIN_VBAT_READ (4)
  9. #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
  10. class ThinkNodeM1Board : public mesh::MainBoard {
  11. protected:
  12. uint8_t startup_reason;
  13. public:
  14. void begin();
  15. uint16_t getBattMilliVolts() override;
  16. bool startOTAUpdate(const char* id, char reply[]) override;
  17. uint8_t getStartupReason() const override {
  18. return startup_reason;
  19. }
  20. #if defined(P_LORA_TX_LED)
  21. void onBeforeTransmit() override {
  22. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
  23. }
  24. void onAfterTransmit() override {
  25. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  26. }
  27. #endif
  28. const char* getManufacturerName() const override {
  29. return "Elecrow ThinkNode-M1";
  30. }
  31. void reboot() override {
  32. NVIC_SystemReset();
  33. }
  34. void powerOff() override {
  35. // turn off all leds, sd_power_system_off will not do this for us
  36. #ifdef P_LORA_TX_LED
  37. digitalWrite(P_LORA_TX_LED, LOW);
  38. #endif
  39. // power off board
  40. sd_power_system_off();
  41. }
  42. };