2025-02-14 09:54:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <MeshCore.h>
|
|
|
|
|
#include <Arduino.h>
|
2025-12-12 19:01:15 +07:00
|
|
|
#include <helpers/NRF52Board.h>
|
2025-02-14 09:54:06 +01:00
|
|
|
|
2025-12-20 10:44:13 +01:00
|
|
|
class T1000eBoard : public NRF52BoardDCDC {
|
2025-02-14 09:54:06 +01:00
|
|
|
protected:
|
2025-02-25 14:02:19 +01:00
|
|
|
uint8_t btn_prev_state;
|
2025-02-14 09:54:06 +01:00
|
|
|
|
|
|
|
|
public:
|
2025-12-20 10:44:13 +01:00
|
|
|
T1000eBoard() : NRF52Board("T1000E_OTA") {}
|
2025-02-25 19:00:07 +11:00
|
|
|
void begin();
|
2025-02-14 09:54:06 +01:00
|
|
|
|
|
|
|
|
uint16_t getBattMilliVolts() override {
|
2025-02-26 18:19:38 +11:00
|
|
|
#ifdef BATTERY_PIN
|
2025-04-15 15:15:06 +10:00
|
|
|
#ifdef PIN_3V3_EN
|
2025-04-10 22:00:25 +02:00
|
|
|
digitalWrite(PIN_3V3_EN, HIGH);
|
2025-04-15 15:15:06 +10:00
|
|
|
#endif
|
2025-03-08 20:18:15 +11:00
|
|
|
analogReference(AR_INTERNAL_3_0);
|
2025-02-25 14:02:19 +01:00
|
|
|
analogReadResolution(12);
|
2025-04-10 22:00:25 +02:00
|
|
|
delay(10);
|
2025-02-25 14:02:19 +01:00
|
|
|
float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096;
|
2025-04-15 15:15:06 +10:00
|
|
|
#ifdef PIN_3V3_EN
|
2025-04-10 22:00:25 +02:00
|
|
|
digitalWrite(PIN_3V3_EN, LOW);
|
2025-04-15 15:15:06 +10:00
|
|
|
#endif
|
2025-03-08 20:18:15 +11:00
|
|
|
|
|
|
|
|
analogReference(AR_DEFAULT); // put back to default
|
|
|
|
|
analogReadResolution(10);
|
|
|
|
|
|
2025-02-25 14:02:19 +01:00
|
|
|
return volts * 1000;
|
2025-02-26 18:19:38 +11:00
|
|
|
#else
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
2025-02-14 09:54:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* getManufacturerName() const override {
|
2026-01-06 20:11:19 +01:00
|
|
|
return "Seeed Tracker T1000-E";
|
2025-02-14 09:54:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-25 14:02:19 +01:00
|
|
|
int buttonStateChanged() {
|
2025-02-26 18:19:38 +11:00
|
|
|
#ifdef BUTTON_PIN
|
2025-02-25 14:02:19 +01:00
|
|
|
uint8_t v = digitalRead(BUTTON_PIN);
|
|
|
|
|
if (v != btn_prev_state) {
|
|
|
|
|
btn_prev_state = v;
|
|
|
|
|
return (v == LOW) ? 1 : -1;
|
|
|
|
|
}
|
2025-02-26 18:19:38 +11:00
|
|
|
#endif
|
2025-02-25 14:02:19 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 17:11:55 +01:00
|
|
|
void powerOff() override {
|
2025-02-25 16:46:06 +01:00
|
|
|
#ifdef HAS_GPS
|
2025-02-25 14:02:19 +01:00
|
|
|
digitalWrite(GPS_VRTC_EN, LOW);
|
2025-02-25 16:46:06 +01:00
|
|
|
digitalWrite(GPS_RESET, LOW);
|
2025-02-25 14:02:19 +01:00
|
|
|
digitalWrite(GPS_SLEEP_INT, LOW);
|
|
|
|
|
digitalWrite(GPS_RTC_INT, LOW);
|
2025-09-06 18:45:08 +02:00
|
|
|
digitalWrite(GPS_EN, LOW);
|
2025-02-25 14:02:19 +01:00
|
|
|
#endif
|
2025-09-04 23:31:05 +02:00
|
|
|
|
2025-02-25 16:46:06 +01:00
|
|
|
#ifdef BUZZER_EN
|
|
|
|
|
digitalWrite(BUZZER_EN, LOW);
|
2025-02-25 14:02:19 +01:00
|
|
|
#endif
|
2025-09-04 23:31:05 +02:00
|
|
|
|
2025-02-25 14:02:19 +01:00
|
|
|
#ifdef PIN_3V3_EN
|
|
|
|
|
digitalWrite(PIN_3V3_EN, LOW);
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-09-06 18:45:08 +02:00
|
|
|
#ifdef PIN_3V3_ACC_EN
|
|
|
|
|
digitalWrite(PIN_3V3_ACC_EN, LOW);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef SENSOR_EN
|
|
|
|
|
digitalWrite(SENSOR_EN, LOW);
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-08-17 16:28:02 +02:00
|
|
|
// set led on and wait for button release before poweroff
|
|
|
|
|
#ifdef LED_PIN
|
|
|
|
|
digitalWrite(LED_PIN, HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef BUTTON_PIN
|
|
|
|
|
while(digitalRead(BUTTON_PIN));
|
|
|
|
|
#endif
|
2025-02-26 18:19:38 +11:00
|
|
|
#ifdef LED_PIN
|
2025-02-25 14:02:19 +01:00
|
|
|
digitalWrite(LED_PIN, LOW);
|
2025-02-26 18:19:38 +11:00
|
|
|
#endif
|
2025-08-17 16:28:02 +02:00
|
|
|
|
2025-02-26 18:19:38 +11:00
|
|
|
#ifdef BUTTON_PIN
|
2025-09-06 18:45:08 +02:00
|
|
|
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
|
2025-02-26 18:19:38 +11:00
|
|
|
#endif
|
2025-08-17 16:28:02 +02:00
|
|
|
|
2025-02-25 14:02:19 +01:00
|
|
|
sd_power_system_off();
|
|
|
|
|
}
|
2026-01-06 20:11:19 +01:00
|
|
|
};
|