|
|
|
@ -22,11 +22,18 @@ void TechoBoard::begin() { |
|
|
|
// for future use, sub-classes SHOULD call this from their begin()
|
|
|
|
startup_reason = BD_STARTUP_NORMAL; |
|
|
|
|
|
|
|
pinMode(PIN_VBAT_READ, INPUT); |
|
|
|
|
|
|
|
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) |
|
|
|
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL) |
|
|
|
#endif |
|
|
|
delay(200); |
|
|
|
pinMode(PIN_PWR_EN, OUTPUT); |
|
|
|
digitalWrite(PIN_PWR_EN, HIGH); |
|
|
|
pinMode(PIN_BUTTON1, INPUT_PULLUP); |
|
|
|
pinMode(PIN_BUTTON2, INPUT_PULLUP); |
|
|
|
pinMode(LED_RED, OUTPUT); |
|
|
|
pinMode(LED_GREEN, OUTPUT); |
|
|
|
pinMode(LED_BLUE, OUTPUT); |
|
|
|
delay(200); |
|
|
|
|
|
|
|
pinMode(PIN_TXCO, OUTPUT); |
|
|
|
digitalWrite(PIN_TXCO, HIGH); |
|
|
|
|
|
|
|
Wire.begin(); |
|
|
|
|
|
|
|
@ -35,6 +42,20 @@ void TechoBoard::begin() { |
|
|
|
delay(10); // give sx1262 some time to power up
|
|
|
|
} |
|
|
|
|
|
|
|
uint16_t TechoBoard::getBattMilliVolts() { |
|
|
|
int adcvalue = 0; |
|
|
|
|
|
|
|
analogReference(AR_INTERNAL_3_0); |
|
|
|
analogReadResolution(12); |
|
|
|
delay(10); |
|
|
|
|
|
|
|
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
|
|
|
|
adcvalue = analogRead(PIN_VBAT_READ); |
|
|
|
// Convert the raw value to compensated mv, taking the resistor-
|
|
|
|
// divider into account (providing the actual LIPO voltage)
|
|
|
|
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB); |
|
|
|
} |
|
|
|
|
|
|
|
bool TechoBoard::startOTAUpdate(const char* id, char reply[]) { |
|
|
|
// Config the peripheral connection with maximum bandwidth
|
|
|
|
// more SRAM required by SoftDevice
|
|
|
|
|