IkokaStickNRFBoard.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. #ifdef XIAO_NRF52
  6. class IkokaStickNRFBoard : public NRF52BoardDCDC {
  7. public:
  8. IkokaStickNRFBoard() : NRF52Board("XIAO_NRF52_OTA") {}
  9. void begin();
  10. #if defined(P_LORA_TX_LED)
  11. void onBeforeTransmit() override {
  12. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
  13. #if defined(LED_BLUE)
  14. // turn off that annoying blue LED before transmitting
  15. digitalWrite(LED_BLUE, HIGH);
  16. #endif
  17. }
  18. void onAfterTransmit() override {
  19. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
  20. #if defined(LED_BLUE)
  21. // do it after transmitting too, just in case
  22. digitalWrite(LED_BLUE, HIGH);
  23. #endif
  24. }
  25. #endif
  26. uint16_t getBattMilliVolts() override {
  27. // Please read before going further ;)
  28. // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
  29. // We can't drive VBAT_ENABLE to HIGH as long
  30. // as we don't know whether we are charging or not ...
  31. // this is a 3mA loss (4/1500)
  32. digitalWrite(VBAT_ENABLE, LOW);
  33. int adcvalue = 0;
  34. analogReadResolution(12);
  35. analogReference(AR_INTERNAL_3_0);
  36. delay(10);
  37. adcvalue = analogRead(PIN_VBAT);
  38. return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
  39. }
  40. const char *getManufacturerName() const override {
  41. return MANUFACTURER_STRING;
  42. }
  43. };
  44. #endif