Files
MeshCore-Solo/variants/ikoka_nano_nrf/IkokaNanoNRFBoard.h
T

53 lines
1.4 KiB
C++
Raw Normal View History

2025-10-09 17:31:32 -05:00
#pragma once
#include <MeshCore.h>
#include <Arduino.h>
#include <helpers/NRF52Board.h>
2025-10-09 17:31:32 -05:00
#ifdef XIAO_NRF52
class IkokaNanoNRFBoard : public NRF52BoardDCDC {
2025-10-09 17:31:32 -05:00
public:
IkokaNanoNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
2025-10-09 17:31:32 -05:00
void begin();
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
#if defined(LED_BLUE)
// turn off that annoying blue LED before transmitting
digitalWrite(LED_BLUE, HIGH);
#endif
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
#if defined(LED_BLUE)
// do it after transmitting too, just in case
digitalWrite(LED_BLUE, HIGH);
#endif
}
#endif
uint16_t getBattMilliVolts() override {
2026-05-20 08:31:28 +02:00
// Please read before going further ;)
2025-10-09 17:31:32 -05:00
// https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
// We can't drive VBAT_ENABLE to HIGH as long
2026-05-20 08:31:28 +02:00
// as we don't know whether we are charging or not ...
2025-10-09 17:31:32 -05:00
// this is a 3mA loss (4/1500)
digitalWrite(VBAT_ENABLE, LOW);
int adcvalue = 0;
analogReadResolution(12);
analogReference(AR_INTERNAL_3_0);
delay(10);
adcvalue = analogRead(PIN_VBAT);
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
}
const char *getManufacturerName() const override {
return MANUFACTURER_STRING;
}
};
#endif