GAT562MeshTrackerProBoard.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. class GAT562MeshTrackerProBoard : public NRF52BoardDCDC {
  6. protected:
  7. #ifdef NRF52_POWER_MANAGEMENT
  8. void initiateShutdown(uint8_t reason) override;
  9. #endif
  10. public:
  11. GAT562MeshTrackerProBoard() : NRF52Board("GAT562_OTA") {}
  12. void begin();
  13. #define BATTERY_SAMPLES 8
  14. uint16_t getBattMilliVolts() override {
  15. analogReadResolution(12);
  16. uint32_t raw = 0;
  17. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  18. raw += analogRead(PIN_VBAT_READ);
  19. }
  20. raw = raw / BATTERY_SAMPLES;
  21. return (ADC_MULTIPLIER * raw) / 4096;
  22. }
  23. const char* getManufacturerName() const override {
  24. return "GAT562 Mesh Tracker Pro";
  25. }
  26. #if defined(P_LORA_TX_LED)
  27. void onBeforeTransmit() override {
  28. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
  29. }
  30. void onAfterTransmit() override {
  31. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  32. }
  33. #endif
  34. void powerOff() override {
  35. uint32_t button_pin = PIN_BUTTON1;
  36. nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
  37. nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
  38. sd_power_system_off();
  39. }
  40. };