R1NeoBoard.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifdef NRF52_POWER_MANAGEMENT
  17. void powerOff() override {
  18. initiateShutdown(SHUTDOWN_REASON_USER);
  19. }
  20. #endif
  21. #if defined(P_LORA_TX_LED)
  22. void onBeforeTransmit() override {
  23. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
  24. #if defined(LED_BLUE)
  25. // turn off that annoying blue LED before transmitting
  26. digitalWrite(LED_BLUE, LOW);
  27. #endif
  28. }
  29. void onAfterTransmit() override {
  30. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  31. #if defined(LED_BLUE)
  32. // do it after transmitting too, just in case
  33. digitalWrite(LED_BLUE, LOW);
  34. #endif
  35. }
  36. #endif
  37. #define BATTERY_SAMPLES 8
  38. uint16_t getBattMilliVolts() override {
  39. MESH_DEBUG_PRINTLN("R1Neo: Sampling battery");
  40. analogReadResolution(12);
  41. uint32_t raw = 0;
  42. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  43. raw += analogRead(PIN_VBAT_READ);
  44. }
  45. raw = raw / BATTERY_SAMPLES;
  46. return (ADC_MULTIPLIER * raw) / 4096;
  47. }
  48. const char* getManufacturerName() const override {
  49. return "muzi works R1 Neo";
  50. }
  51. };