Skip to content

Commit

Permalink
Resume of SkyWatch sketch development
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Jun 1, 2020
1 parent b5523aa commit b6ab102
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ script:
- if [[ "$BOARD" =~ "esp32:esp32:" ]]; then
arduino --verify --verbose-build --board $BOARD $PWD/software/firmware/source/SkyView/SkyView.ino ;
fi ;
- if [[ "$BOARD" =~ "esp32:esp32:" ]]; then
arduino --verify --board $BOARD $PWD/software/firmware/source/SkyWatch/SkyWatch.ino ;
fi ;
- if [[ "$BOARD" =~ "STM32:stm32:" ]]; then
arduino --verify --verbose-build --board $BOARD $PWD/software/firmware/source/SoftRF/SoftRF.ino ;
fi ;
Expand Down
31 changes: 31 additions & 0 deletions software/firmware/source/SkyWatch/Platform_ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,36 @@ static void ESP32_WDT_fini()
disableLoopWDT();
}

static void ESP32_Service_Mode(boolean arg)
{
if (arg) {
// Serial.begin(SERIAL_IN_BR, SERIAL_IN_BITS);
Serial.updateBaudRate(SERIAL_IN_BR);
WiFi_fini();
axp.setGPIOMode(AXP_GPIO_2, AXP_IO_OUTPUT_LOW_MODE); // MCU_reset
delay(10);
axp.setGPIOMode(AXP_GPIO_1, AXP_IO_OUTPUT_HIGH_MODE); // BOOT0 high
delay(100);
axp.setGPIOMode(AXP_GPIO_2, AXP_IO_FLOATING_MODE); // release MCU_reset (it has pull-up)
delay(500);
axp.setGPIOMode(AXP_GPIO_1, AXP_IO_FLOATING_MODE); // release BOOT0 (it has pull-down)

inServiceMode = true;
} else {
// Serial.begin(SERIAL_OUT_BR, SERIAL_OUT_BITS);
Serial.updateBaudRate(SERIAL_OUT_BR);
axp.setGPIOMode(AXP_GPIO_2, AXP_IO_OUTPUT_LOW_MODE); // MCU_reset
delay(10);
axp.setGPIOMode(AXP_GPIO_1, AXP_IO_OUTPUT_LOW_MODE); // BOOT0 low
delay(100);
axp.setGPIOMode(AXP_GPIO_2, AXP_IO_FLOATING_MODE); // release MCU_reset (it has pull-up)
delay(500);
axp.setGPIOMode(AXP_GPIO_1, AXP_IO_FLOATING_MODE); // release BOOT0 (it has pull-down)

inServiceMode = false;
}
}

const SoC_ops_t ESP32_ops = {
SOC_ESP32,
"ESP32",
Expand Down Expand Up @@ -992,6 +1022,7 @@ const SoC_ops_t ESP32_ops = {
ESP32_Baro_setup,
ESP32_WDT_setup,
ESP32_WDT_fini,
ESP32_Service_Mode,
&ESP32_Bluetooth_ops
};

Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyWatch/Platform_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ extern volatile bool BMA_Irq;
extern PCF8563_Class *rtc;

#define NMEA_TCP_SERVICE
//#define USE_DNS_SERVER

#define POWER_SAVING_WIFI_TIMEOUT 300000UL /* 5 minutes */

Expand Down
9 changes: 8 additions & 1 deletion software/firmware/source/SkyWatch/SkyWatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ typedef struct hardware_info {
byte gnss;
byte baro;
byte display;

byte storage;
} hardware_info_t;

enum
Expand Down Expand Up @@ -259,6 +259,12 @@ enum
ANTI_GHOSTING_10MIN
};

enum
{
STORAGE_NONE,
STORAGE_uSD
};

enum
{
DB_AUTO,
Expand Down Expand Up @@ -357,6 +363,7 @@ enum

extern ufo_t ThisDevice;
extern hardware_info_t hw_info;
extern bool inServiceMode;

extern void shutdown(const char *);

Expand Down
50 changes: 47 additions & 3 deletions software/firmware/source/SkyWatch/SkyWatch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ hardware_info_t hw_info = {
.rf = RF_IC_NONE,
.gnss = GNSS_MODULE_NONE,
.baro = BARO_MODULE_NONE,
.display = DISPLAY_NONE
.display = DISPLAY_NONE,
.storage = STORAGE_NONE
};

#if DEBUG_POWER
Expand All @@ -82,12 +83,14 @@ void print_current(const char *s, bool d)
}
#endif

bool inServiceMode = false;

void setup()
{
hw_info.soc = SoC_setup(); // Has to be very first procedure in the execution order

delay(300);
Serial.begin(SERIAL_OUT_BR);
Serial.begin(SERIAL_OUT_BR, SERIAL_OUT_BITS);
Serial.println();

EEPROM_setup();
Expand Down Expand Up @@ -122,7 +125,9 @@ void setup()
break;
}

SoC->DB_init();
if (SoC->DB_init()) {
hw_info.storage = STORAGE_uSD;
}

Web_setup();
Traffic_setup();
Expand All @@ -131,6 +136,15 @@ void setup()
}

void loop()
{
if (inServiceMode) {
service_loop();
} else {
normal_loop();
}
}

void normal_loop()
{
Baro_loop();

Expand Down Expand Up @@ -169,6 +183,36 @@ void loop()
yield();
}

void service_loop()
{
bool bypass_inactive = true;

while (Serial.available() > 0) {
SerialInput.write(Serial.read());
bypass_inactive = false;
}
while (SerialInput.available() > 0) {
Serial.write(SerialInput.read());
bypass_inactive = false;
}
if (bypass_inactive) {
// TFT_loop();

// Traffic_ClearExpired();

// WiFi_loop();

// Handle Web
// Web_loop();

SoC->Button_loop();

SoC->loop();

// Battery_loop();
}
}

void shutdown(const char *msg)
{
SoC->WDT_fini();
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyWatch/SoCHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct SoC_ops_struct {
bool (*Baro_setup)();
void (*WDT_setup)();
void (*WDT_fini)();
void (*Service_Mode)(boolean);
Bluetooth_ops_t *Bluetooth;
} SoC_ops_t;

Expand Down
Loading

0 comments on commit b6ab102

Please sign in to comment.