ThinkNodeM6Board.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_COMP ADC_MULTIPLIER // Compensation factor for the VBAT divider
  7. #define PIN_VBAT_READ BATTERY_PIN
  8. #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
  9. class ThinkNodeM6Board : public mesh::MainBoard {
  10. protected:
  11. uint8_t startup_reason;
  12. public:
  13. void begin();
  14. uint16_t getBattMilliVolts() override;
  15. bool startOTAUpdate(const char* id, char reply[]) override;
  16. uint8_t getStartupReason() const override {
  17. return startup_reason;
  18. }
  19. #if defined(P_LORA_TX_LED)
  20. void onBeforeTransmit() override {
  21. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
  22. }
  23. void onAfterTransmit() override {
  24. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  25. }
  26. #endif
  27. const char* getManufacturerName() const override {
  28. return "Elecrow ThinkNode-M6";
  29. }
  30. void reboot() override {
  31. NVIC_SystemReset();
  32. }
  33. void powerOff() override {
  34. // turn off all leds, sd_power_system_off will not do this for us
  35. #ifdef P_LORA_TX_LED
  36. digitalWrite(P_LORA_TX_LED, LOW);
  37. #endif
  38. // power off board
  39. sd_power_system_off();
  40. }
  41. };