Updated start sequence, added boot graphics
This commit is contained in:
parent
8e64bc2aa6
commit
21e040eb97
33
Bluetooth.h
33
Bluetooth.h
@ -71,33 +71,16 @@ char bt_devname[11];
|
||||
}
|
||||
}
|
||||
|
||||
bool bt_early_init_done = false;
|
||||
bool bt_early_init() {
|
||||
if (!bt_early_init_done) {
|
||||
bool bt_setup_hw() {
|
||||
if (!bt_ready) {
|
||||
if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) {
|
||||
bt_enabled = true;
|
||||
} else {
|
||||
bt_enabled = false;
|
||||
}
|
||||
if (btStart()) {
|
||||
if (esp_bluedroid_init() == ESP_OK) {
|
||||
if (esp_bluedroid_enable() == ESP_OK) {
|
||||
const uint8_t* bda_ptr = esp_bt_dev_get_address();
|
||||
memcpy(dev_bt_mac, bda_ptr, BT_DEV_HASH_LEN);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool bt_setup_hw() {
|
||||
if (!bt_ready) {
|
||||
if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) { bt_enabled = true; } else { bt_enabled = false; }
|
||||
if (bt_early_init()) {
|
||||
const uint8_t* bda_ptr = esp_bt_dev_get_address();
|
||||
char *data = (char*)malloc(BT_DEV_ADDR_LEN+1);
|
||||
for (int i = 0; i < BT_DEV_ADDR_LEN; i++) {
|
||||
@ -118,6 +101,8 @@ char bt_devname[11];
|
||||
return true;
|
||||
|
||||
} else { return false; }
|
||||
} else { return false; }
|
||||
} else { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
|
2
Device.h
2
Device.h
@ -113,7 +113,7 @@ bool device_firmware_ok() {
|
||||
}
|
||||
|
||||
bool device_init() {
|
||||
if (bt_early_init()) {
|
||||
if (bt_ready) {
|
||||
for (uint8_t i=0; i<EEPROM_SIG_LEN; i++){dev_eeprom_signature[i]=EEPROM.read(eeprom_addr(ADDR_SIGNATURE+i));}
|
||||
mbedtls_md_context_t ctx;
|
||||
mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256;
|
||||
|
@ -253,6 +253,7 @@ void draw_waterfall(int px, int py) {
|
||||
|
||||
bool stat_area_intialised = false;
|
||||
void draw_stat_area() {
|
||||
if (device_init_done) {
|
||||
if (!stat_area_intialised) {
|
||||
stat_area.drawBitmap(0, 0, bm_frame, 64, 64, SSD1306_WHITE, SSD1306_BLACK);
|
||||
stat_area_intialised = true;
|
||||
@ -269,6 +270,7 @@ void draw_stat_area() {
|
||||
draw_waterfall(27, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_stat_area() {
|
||||
draw_stat_area();
|
||||
@ -284,6 +286,9 @@ void update_stat_area() {
|
||||
const uint8_t pages = 3;
|
||||
uint8_t disp_page = START_PAGE;
|
||||
void draw_disp_area() {
|
||||
if (!device_init_done) {
|
||||
disp_area.drawBitmap(0, 37, bm_boot, disp_area.width(), 27, SSD1306_WHITE, SSD1306_BLACK);
|
||||
} else {
|
||||
if (!disp_ext_fb or bt_ssp_pin != 0) {
|
||||
if (device_signatures_ok()) {
|
||||
disp_area.drawBitmap(0, 0, bm_def_lc, disp_area.width(), 37, SSD1306_WHITE, SSD1306_BLACK);
|
||||
@ -354,6 +359,7 @@ void draw_disp_area() {
|
||||
disp_area.drawBitmap(0, 0, fb, disp_area.width(), disp_area.height(), SSD1306_WHITE, SSD1306_BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void update_disp_area() {
|
||||
draw_disp_area();
|
||||
|
17
Graphics.h
17
Graphics.h
@ -27,6 +27,23 @@ const unsigned char bm_bt [] PROGMEM = {
|
||||
0x29, 0x94, 0x11, 0x48, 0x03, 0x20, 0x05, 0x10, 0x09, 0x20, 0x01, 0x40, 0x01, 0x80, 0x01, 0x00
|
||||
};
|
||||
|
||||
const unsigned char bm_boot [] PROGMEM = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xfc, 0x38, 0x66, 0x67, 0x1c, 0x3f, 0xff, 0xff, 0xfc, 0x99, 0xe6, 0x66, 0x4c, 0xff, 0xff,
|
||||
0xff, 0xfc, 0x98, 0x70, 0xe6, 0x7c, 0x3f, 0xff, 0xff, 0xfc, 0x99, 0xf0, 0xe6, 0x4c, 0xff, 0xff,
|
||||
0xff, 0xfc, 0x38, 0x79, 0xe7, 0x1c, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0x0c, 0x38, 0xe1, 0xc3, 0x33, 0x38, 0x7f, 0xfe, 0x7e, 0x72, 0x64, 0xe7, 0x31, 0x33, 0xff,
|
||||
0xff, 0x1e, 0x70, 0x61, 0xe7, 0x30, 0x32, 0x7f, 0xff, 0xce, 0x72, 0x61, 0xe7, 0x32, 0x32, 0x7f,
|
||||
0xfe, 0x1e, 0x72, 0x64, 0xe7, 0x33, 0x38, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
const unsigned char bm_version [] PROGMEM = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
|
@ -52,8 +52,7 @@ char sbuf[128];
|
||||
|
||||
void setup() {
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
// TODO: Reset?
|
||||
// delay(500);
|
||||
boot_seq();
|
||||
EEPROM.begin(EEPROM_SIZE);
|
||||
Serial.setRxBufferSize(CONFIG_UART_BUFFER_SIZE);
|
||||
#endif
|
||||
@ -90,16 +89,22 @@ void setup() {
|
||||
// pins for the LoRa module
|
||||
LoRa.setPins(pin_cs, pin_reset, pin_dio);
|
||||
|
||||
#if HAS_DISPLAY
|
||||
disp_ready = display_init();
|
||||
update_display();
|
||||
#endif
|
||||
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
#if HAS_PMU == true
|
||||
pmu_ready = init_pmu();
|
||||
#endif
|
||||
|
||||
kiss_indicate_reset();
|
||||
#if HAS_BLUETOOTH
|
||||
bt_init();
|
||||
bt_init_ran = true;
|
||||
#endif
|
||||
|
||||
#if HAS_DISPLAY
|
||||
disp_ready = display_init();
|
||||
kiss_indicate_reset();
|
||||
#endif
|
||||
|
||||
// Validate board health, EEPROM and config
|
||||
@ -832,7 +837,10 @@ void validate_status() {
|
||||
hw_ready = false;
|
||||
Serial.write("Error, invalid hardware check state\r\n");
|
||||
#if HAS_DISPLAY
|
||||
if (disp_ready) update_display();
|
||||
if (disp_ready) {
|
||||
device_init_done = true;
|
||||
update_display();
|
||||
}
|
||||
#endif
|
||||
led_indicate_boot_error();
|
||||
}
|
||||
@ -846,7 +854,10 @@ void validate_status() {
|
||||
} else {
|
||||
Serial.write("Error, indeterminate boot vector\r\n");
|
||||
#if HAS_DISPLAY
|
||||
if (disp_ready) update_display();
|
||||
if (disp_ready) {
|
||||
device_init_done = true;
|
||||
update_display();
|
||||
}
|
||||
#endif
|
||||
led_indicate_boot_error();
|
||||
}
|
||||
@ -881,7 +892,10 @@ void validate_status() {
|
||||
hw_ready = false;
|
||||
Serial.write("Error, incorrect boot vector\r\n");
|
||||
#if HAS_DISPLAY
|
||||
if (disp_ready) update_display();
|
||||
if (disp_ready) {
|
||||
device_init_done = true;
|
||||
update_display();
|
||||
}
|
||||
#endif
|
||||
led_indicate_boot_error();
|
||||
}
|
||||
@ -947,11 +961,6 @@ void loop() {
|
||||
#endif
|
||||
|
||||
#if HAS_BLUETOOTH
|
||||
if (!bt_init_ran && millis() > 1000) {
|
||||
bt_init();
|
||||
bt_init_ran = true;
|
||||
}
|
||||
|
||||
if (bt_ready) update_bt();
|
||||
#endif
|
||||
}
|
||||
|
14
Utilities.h
14
Utilities.h
@ -66,6 +66,20 @@ uint8_t boot_vector = 0x00;
|
||||
pixels.show();
|
||||
}
|
||||
}
|
||||
|
||||
void boot_seq() {
|
||||
uint8_t rs[] = { 0x00, 0x00, 0x00 };
|
||||
uint8_t gs[] = { 0x10, 0x08, 0x00 };
|
||||
uint8_t bs[] = { 0x00, 0x08, 0x10 };
|
||||
for (int i = 0; i < 1*sizeof(rs); i++) {
|
||||
npset(rs[i%sizeof(rs)], gs[i%sizeof(gs)], bs[i%sizeof(bs)]);
|
||||
delay(33);
|
||||
npset(0x00, 0x00, 0x00);
|
||||
delay(66);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void boot_seq() { }
|
||||
#endif
|
||||
|
||||
#if MCU_VARIANT == MCU_1284P || MCU_VARIANT == MCU_2560
|
||||
|
Loading…
Reference in New Issue
Block a user