R1NeoBoard.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. #include "NullDisplayDriver.h"
  6. #include "MomentaryButton.h"
  7. #define DISPLAY_CLASS NullDisplayDriver
  8. class R1NeoBoard : public NRF52BoardDCDC {
  9. protected:
  10. #ifdef NRF52_POWER_MANAGEMENT
  11. void initiateShutdown(uint8_t reason) override;
  12. #endif
  13. public:
  14. R1NeoBoard() : NRF52Board("R1NEO_OTA") {}
  15. void begin();
  16. #if defined(P_LORA_TX_LED)
  17. void onBeforeTransmit() override {
  18. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
  19. #if defined(LED_BLUE)
  20. // turn off that annoying blue LED before transmitting
  21. digitalWrite(LED_BLUE, LOW);
  22. #endif
  23. }
  24. void onAfterTransmit() override {
  25. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  26. #if defined(LED_BLUE)
  27. // do it after transmitting too, just in case
  28. digitalWrite(LED_BLUE, LOW);
  29. #endif
  30. }
  31. #endif
  32. #define BATTERY_SAMPLES 8
  33. uint16_t getBattMilliVolts() override {
  34. analogReadResolution(12);
  35. uint32_t raw = 0;
  36. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  37. raw += analogRead(PIN_VBAT_READ);
  38. }
  39. raw = raw / BATTERY_SAMPLES;
  40. return (ADC_MULTIPLIER * raw) / 4096;
  41. }
  42. const char* getManufacturerName() const override {
  43. return "muzi works R1 Neo";
  44. }
  45. };