mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
38 lines
783 B
C++
38 lines
783 B
C++
#pragma once
|
|
|
|
#include <MeshCore.h>
|
|
#include <Arduino.h>
|
|
#include <helpers/NRF52Board.h>
|
|
|
|
// built-ins
|
|
#define PIN_VBAT_READ 5
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
|
|
|
class RAK4631Board : public NRF52BoardDCDC {
|
|
protected:
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
void initiateShutdown(uint8_t reason) override;
|
|
#endif
|
|
|
|
public:
|
|
RAK4631Board() : NRF52Board("RAK4631_OTA") {}
|
|
void begin();
|
|
|
|
#define BATTERY_SAMPLES 8
|
|
|
|
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";
|
|
}
|
|
};
|