ThinkNodeM3Board.cpp 693 B

12345678910111213141516171819202122232425262728
  1. #include <Arduino.h>
  2. #include "ThinkNodeM3Board.h"
  3. #include <Wire.h>
  4. #include <bluefruit.h>
  5. void ThinkNodeM3Board::begin() {
  6. NRF52Board::begin();
  7. btn_prev_state = HIGH;
  8. Wire.begin();
  9. delay(10); // give sx1262 some time to power up
  10. }
  11. uint16_t ThinkNodeM3Board::getBattMilliVolts() {
  12. int adcvalue = 0;
  13. analogReference(AR_INTERNAL_2_4);
  14. analogReadResolution(ADC_RESOLUTION);
  15. delay(10);
  16. // ADC range is 0..2400mV and resolution is 12-bit (0..4095)
  17. adcvalue = analogRead(PIN_VBAT_READ);
  18. // Convert the raw value to compensated mv, taking the resistor-
  19. // divider into account (providing the actual LIPO voltage)
  20. return (uint16_t)((float)adcvalue * ADC_FACTOR);
  21. }