diff --git a/src/configuration.h b/src/configuration.h
index b9b05dc61..ab66a69ec 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -37,8 +37,8 @@ along with this program. If not, see .
// -----------------------------------------------------------------------------
// Select which T-Beam board is being used. Only uncomment one.
-#define T_BEAM_V10 // AKA Rev1 (second board released)
-
+// #define T_BEAM_V10 // AKA Rev1 (second board released)
+#define HELTEC_LORA32
#define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate
@@ -74,12 +74,9 @@ along with this program. If not, see .
// General
// -----------------------------------------------------------------------------
-#define I2C_SDA 21
-#define I2C_SCL 22
-#if defined(T_BEAM_V10)
-#define BUTTON_PIN 38
-#endif
+
+
// -----------------------------------------------------------------------------
// OLED
@@ -108,12 +105,36 @@ along with this program. If not, see .
#define MISO_GPIO 19
#define MOSI_GPIO 27
#define NSS_GPIO 18
+
#if defined(T_BEAM_V10)
+
+#define I2C_SDA 21
+#define I2C_SCL 22
+
+#define BUTTON_PIN 38
+
#define RESET_GPIO 14
-#endif
#define DIO0_GPIO 26
#define DIO1_GPIO 33 // Note: not really used on this board
#define DIO2_GPIO 32 // Note: not really used on this board
+#define PMU_IRQ 35
+
+#elif defined(HELTEC_LORA32)
+#define I2C_SDA 4
+#define I2C_SCL 15
+
+#define RESET_OLED 16
+
+#define VEXT_ENABLE 21 // active low, powers the oled display
+#define LED_PIN 25
+#define BUTTON_PIN 0
+
+#define RESET_GPIO 14
+#define DIO0_GPIO 34
+#define DIO1_GPIO 35
+#define DIO2_GPIO 32 // Note: not really used on this board
+#endif
+
// -----------------------------------------------------------------------------
// AXP192 (Rev1-specific options)
@@ -122,4 +143,4 @@ along with this program. If not, see .
// #define AXP192_SLAVE_ADDRESS 0x34 // Now defined in axp20x.h
#define GPS_POWER_CTRL_CH 3
#define LORA_POWER_CTRL_CH 2
-#define PMU_IRQ 35
+
diff --git a/src/gps.ino b/src/gps.ino
index 69e4d6a1d..02b6d55cf 100644
--- a/src/gps.ino
+++ b/src/gps.ino
@@ -56,73 +56,15 @@ uint8_t gps_sats() {
}
void gps_setup() {
+ #ifdef GPS_RX_PIN
_serial_gps.begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
+ #endif
}
static void gps_loop() {
+ #ifdef GPX_RX_PIN
while (_serial_gps.available()) {
_gps.encode(_serial_gps.read());
}
+ #endif
}
-
-#if defined(PAYLOAD_USE_FULL)
-
- // More data than PAYLOAD_USE_CAYENNE
- void buildPacket(uint8_t txBuffer[10])
- {
- LatitudeBinary = ((_gps.location.lat() + 90) / 180.0) * 16777215;
- LongitudeBinary = ((_gps.location.lng() + 180) / 360.0) * 16777215;
- altitudeGps = _gps.altitude.meters();
- hdopGps = _gps.hdop.value() / 10;
- sats = _gps.satellites.value();
-
- sprintf(t, "Lat: %f", _gps.location.lat());
- Serial.println(t);
- sprintf(t, "Lng: %f", _gps.location.lng());
- Serial.println(t);
- sprintf(t, "Alt: %d", altitudeGps);
- Serial.println(t);
- sprintf(t, "Hdop: %d", hdopGps);
- Serial.println(t);
- sprintf(t, "Sats: %d", sats);
- Serial.println(t);
-
- txBuffer[0] = ( LatitudeBinary >> 16 ) & 0xFF;
- txBuffer[1] = ( LatitudeBinary >> 8 ) & 0xFF;
- txBuffer[2] = LatitudeBinary & 0xFF;
- txBuffer[3] = ( LongitudeBinary >> 16 ) & 0xFF;
- txBuffer[4] = ( LongitudeBinary >> 8 ) & 0xFF;
- txBuffer[5] = LongitudeBinary & 0xFF;
- txBuffer[6] = ( altitudeGps >> 8 ) & 0xFF;
- txBuffer[7] = altitudeGps & 0xFF;
- txBuffer[8] = hdopGps & 0xFF;
- txBuffer[9] = sats & 0xFF;
- }
-
-#elif defined(PAYLOAD_USE_CAYENNE)
-
- // CAYENNE DF
- void buildPacket(uint8_t txBuffer[11])
- {
- sprintf(t, "Lat: %f", _gps.location.lat());
- Serial.println(t);
- sprintf(t, "Lng: %f", _gps.location.lng());
- Serial.println(t);
- sprintf(t, "Alt: %f", _gps.altitude.meters());
- Serial.println(t);
- int32_t lat = _gps.location.lat() * 10000;
- int32_t lon = _gps.location.lng() * 10000;
- int32_t alt = _gps.altitude.meters() * 100;
-
- txBuffer[2] = lat >> 16;
- txBuffer[3] = lat >> 8;
- txBuffer[4] = lat;
- txBuffer[5] = lon >> 16;
- txBuffer[6] = lon >> 8;
- txBuffer[7] = lon;
- txBuffer[8] = alt >> 16;
- txBuffer[9] = alt >> 8;
- txBuffer[10] = alt;
- }
-
-#endif
diff --git a/src/main.ino b/src/main.ino
index 44e6d8b6f..28442abd9 100644
--- a/src/main.ino
+++ b/src/main.ino
@@ -59,16 +59,19 @@ void doDeepSleep(uint64_t msecToWake)
// FIXME, shutdown radio headinterups before powering off device
+ #ifdef T_BEAM_V10
if(axp192_found) {
// turn on after initial testing with real hardware
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); // LORA radio
axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // GPS main power
}
+ #endif
// FIXME - use an external 10k pulldown so we can leave the RTC peripherals powered off
// until then we need the following lines
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
+#ifdef BUTTON_PIN
// Only GPIOs which are have RTC functionality can be used in this bit map: 0,2,4,12-15,25-27,32-39.
uint64_t gpioMask = (1ULL << BUTTON_PIN);
@@ -76,6 +79,7 @@ void doDeepSleep(uint64_t msecToWake)
gpio_pullup_en((gpio_num_t) BUTTON_PIN);
esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ALL_LOW);
+#endif
esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
esp_deep_sleep_start(); // TBD mA sleep current (battery)
@@ -127,10 +131,12 @@ void scanI2Cdevice(void)
ssd1306_found = true;
Serial.println("ssd1306 display found");
}
+ #ifdef T_BEAM_V10
if (addr == AXP192_SLAVE_ADDRESS) {
axp192_found = true;
Serial.println("axp192 PMU found");
}
+ #endif
} else if (err == 4) {
Serial.print("Unknow error at address 0x");
if (addr < 16)
@@ -156,6 +162,7 @@ void scanI2Cdevice(void)
LDO3 200mA -> GPS
*/
void axp192Init() {
+ #ifdef T_BEAM_V10
if (axp192_found) {
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
Serial.println("AXP192 Begin PASS");
@@ -200,6 +207,7 @@ void axp192Init() {
} else {
Serial.println("AXP192 not found");
}
+ #endif
}
@@ -227,20 +235,29 @@ void setup() {
initDeepSleep();
// delay(1000); FIXME - remove
+#ifdef VEXT_ENABLE
+ pinMode(VEXT_ENABLE, OUTPUT);
+ digitalWrite(VEXT_ENABLE, 0); // turn on the display power
+#endif
+
+#ifdef RESET_OLED
+ pinMode(RESET_OLED, OUTPUT);
+ digitalWrite(RESET_OLED, 1);
+#endif
+
Wire.begin(I2C_SDA, I2C_SCL);
scanI2Cdevice();
- // FIXME - remove once we know dynamic probing is working
- #ifdef T_BEAM_V10
- // axp192_found = true;
- // ssd1306_found = true;
- #endif
axp192Init();
// Buttons & LED
+#ifdef BUTTON_PIN
pinMode(BUTTON_PIN, INPUT_PULLUP);
+ digitalWrite(BUTTON_PIN, 1);
+#endif
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
+ digitalWrite(LED_PIN, 0); // turn off for now
#endif
// Hello
@@ -280,6 +297,7 @@ void loop() {
sleep();
}
+#ifdef BUTTON_PIN
// if user presses button for more than 3 secs, discard our network prefs and reboot (FIXME, use a debounce lib instead of this boilerplate)
static bool wasPressed = false;
static uint32_t minPressMs; // what tick should we call this press long enough
@@ -299,6 +317,7 @@ void loop() {
// ESP.restart();
}
}
+#endif
// Send every SEND_INTERVAL millis
static uint32_t last = 0;