2025-01-20 20:22:40 +11:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <MeshCore.h>
|
|
|
|
|
#include <Arduino.h>
|
2025-12-12 19:01:15 +07:00
|
|
|
#include <helpers/NRF52Board.h>
|
2025-01-20 20:22:40 +11:00
|
|
|
|
|
|
|
|
// built-ins
|
2025-02-02 09:44:59 +11:00
|
|
|
#define PIN_VBAT_READ 5
|
2025-02-06 08:44:06 +11:00
|
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
2025-01-20 20:22:40 +11:00
|
|
|
|
2025-12-20 10:44:13 +01:00
|
|
|
class RAK4631Board : public NRF52BoardDCDC {
|
2026-01-23 17:18:41 +11:00
|
|
|
protected:
|
|
|
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
|
|
|
void initiateShutdown(uint8_t reason) override;
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-01-20 20:22:40 +11:00
|
|
|
public:
|
2025-12-20 10:44:13 +01:00
|
|
|
RAK4631Board() : NRF52Board("RAK4631_OTA") {}
|
2025-02-25 19:00:07 +11:00
|
|
|
void begin();
|
2025-01-20 20:22:40 +11:00
|
|
|
|
2025-02-02 09:44:59 +11:00
|
|
|
#define BATTERY_SAMPLES 8
|
2025-01-20 20:22:40 +11:00
|
|
|
|
|
|
|
|
uint16_t getBattMilliVolts() override {
|
|
|
|
|
analogReadResolution(12);
|
|
|
|
|
|
|
|
|
|
uint32_t raw = 0;
|
|
|
|
|
for (int i = 0; i < BATTERY_SAMPLES; i++) {
|
|
|
|
|
raw += analogRead(PIN_VBAT_READ);
|
|
|
|
|
}
|
|
|
|
|
raw = raw / BATTERY_SAMPLES;
|
|
|
|
|
|
|
|
|
|
return (ADC_MULTIPLIER * raw) / 4096;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* getManufacturerName() const override {
|
|
|
|
|
return "RAK 4631";
|
|
|
|
|
}
|
2025-02-03 12:53:38 +11:00
|
|
|
};
|