}
void bt_stop() {
+ display_unblank();
if (bt_state != BT_STATE_OFF) {
SerialBT.end();
bt_allow_pairing = false;
}
void bt_start() {
+ display_unblank();
if (bt_state == BT_STATE_OFF) {
SerialBT.begin(bt_devname);
bt_state = BT_STATE_ON;
}
void bt_enable_pairing() {
+ display_unblank();
if (bt_state == BT_STATE_OFF) bt_start();
bt_allow_pairing = true;
bt_pairing_started = millis();
}
void bt_disable_pairing() {
+ display_unblank();
bt_allow_pairing = false;
bt_ssp_pin = 0;
bt_state = BT_STATE_ON;
}
void bt_pairing_complete(boolean success) {
+ display_unblank();
if (success) {
bt_disable_pairing();
} else {
}
}
- void bt_connection_callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param){
+ void bt_connection_callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
+ display_unblank();
if(event == ESP_SPP_SRV_OPEN_EVT) {
bt_state = BT_STATE_CONNECTED;
cable_state = CABLE_STATE_DISCONNECTED;
#elif HAS_BLE == true
void bt_stop() {
+ display_unblank();
if (bt_state != BT_STATE_OFF) {
bt_allow_pairing = false;
bt_state = BT_STATE_OFF;
}
void bt_disable_pairing() {
+ display_unblank();
bt_allow_pairing = false;
bt_ssp_pin = 0;
bt_state = BT_STATE_ON;
}
void bt_connect_callback(uint16_t conn_handle) {
+ display_unblank();
bt_state = BT_STATE_CONNECTED;
cable_state = CABLE_STATE_DISCONNECTED;
}
void bt_disconnect_callback(uint16_t conn_handle, uint8_t reason) {
+ display_unblank();
bt_state = BT_STATE_ON;
}
}
void bt_start() {
+ display_unblank();
if (bt_state == BT_STATE_OFF) {
bt_state = BT_STATE_ON;
// TODO: Implement
}
void bt_enable_pairing() {
+ display_unblank();
if (bt_state == BT_STATE_OFF) bt_start();
bt_allow_pairing = true;
bt_pairing_started = millis();
uint8_t battery_state = 0x00;
uint8_t display_intensity = 0xFF;
uint8_t display_addr = 0xFF;
+ bool display_blanking_enabled = false;
bool display_diagnostics = true;
bool device_init_done = false;
bool eeprom_ok = false;
#define DISP_MODE_LANDSCAPE 0x01
#define DISP_MODE_PORTRAIT 0x02
#define DISP_PIN_SIZE 6
+#define DISPLAY_BLANKING_TIMEOUT 15*1000
uint8_t disp_mode = DISP_MODE_UNKNOWN;
uint8_t disp_ext_fb = false;
unsigned char fb[512];
uint32_t last_disp_update = 0;
+uint32_t last_unblank_event = 0;
+uint32_t display_blanking_timeout = DISPLAY_BLANKING_TIMEOUT;
+uint8_t display_unblank_intensity = display_intensity;
uint8_t disp_target_fps = 7;
int disp_update_interval = 1000/disp_target_fps;
uint32_t last_page_flip = 0;
uint8_t display_address = DISP_ADDR;
#endif
+ #if HAS_EEPROM
+ if (EEPROM.read(eeprom_addr(ADDR_CONF_BSET)) == CONF_OK_BYTE) {
+ uint8_t db_timeout = EEPROM.read(eeprom_addr(ADDR_CONF_DBLK));
+ if (db_timeout == 0x00) {
+ display_blanking_enabled = false;
+ } else {
+ display_blanking_enabled = true;
+ display_blanking_timeout = db_timeout*1000;
+ }
+ }
+ #endif
if(!display.begin(SSD1306_SWITCHCAPVCC, display_address)) {
return false;
}
void update_display(bool blank = false) {
+ if (display_blanking_enabled && millis()-last_unblank_event >= display_blanking_timeout) {
+ blank = true;
+ if (display_intensity != 0) {
+ display_unblank_intensity = display_intensity;
+ }
+ display_intensity = 0;
+ } else {
+ if (display_unblank_intensity != 0x00) {
+ display_intensity = display_unblank_intensity;
+ display_unblank_intensity = 0x00;
+ }
+ }
+
if (blank) {
- if (display_contrast != display_intensity) {
- display_contrast = display_intensity;
- set_contrast(&display, display_contrast);
+ if (millis()-last_disp_update >= disp_update_interval) {
+ if (display_contrast != display_intensity) {
+ display_contrast = display_intensity;
+ set_contrast(&display, display_contrast);
+ }
+ display.clearDisplay();
+ display.display();
+ last_disp_update = millis();
}
- display.clearDisplay();
- display.display();
} else {
if (millis()-last_disp_update >= disp_update_interval) {
if (display_contrast != display_intensity) {
}
}
+void display_unblank() {
+ last_unblank_event = millis();
+}
+
void ext_fb_enable() {
disp_ext_fb = true;
}
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:ttgo-lora32
@sleep 1
rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.ttgo-lora32/RNode_Firmware.ino.bin)
- @sleep 3
- python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
+ #@sleep 3
+ #python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
upload-t3s3:
@echo
eeprom_update(eeprom_addr(ADDR_CONF_DSET), CONF_OK_BYTE);
eeprom_update(eeprom_addr(ADDR_CONF_DINT), 0xFF);
}
+ display_unblank();
disp_ready = display_init();
update_display();
#endif
if (!queue_flushing) {
queue_flushing = true;
+ display_unblank();
led_tx_on();
uint16_t processed = 0;
fifo16_push(&packet_lengths, l);
current_packet_start = queue_cursor;
+ display_unblank();
}
}
if (frame_len == 0 && command == CMD_UNKNOWN) {
command = sbyte;
} else if (command == CMD_DATA) {
- if (bt_state != BT_STATE_CONNECTED) cable_state = CABLE_STATE_CONNECTED;
+ if (bt_state != BT_STATE_CONNECTED) {
+ cable_state = CABLE_STATE_CONNECTED;
+ display_unblank();
+ }
if (sbyte == FESC) {
ESCAPE = true;
} else {
kiss_indicate_implicit_length();
} else if (command == CMD_LEAVE) {
if (sbyte == 0xFF) {
+ display_unblank();
cable_state = CABLE_STATE_DISCONNECTED;
current_rssi = -292;
last_rssi = -292;
last_snr_raw = 0x80;
}
} else if (command == CMD_RADIO_STATE) {
- if (bt_state != BT_STATE_CONNECTED) cable_state = CABLE_STATE_CONNECTED;
+ if (bt_state != BT_STATE_CONNECTED) {
+ cable_state = CABLE_STATE_CONNECTED;
+ display_unblank();
+ }
if (sbyte == 0xFF) {
kiss_indicate_radiostate();
} else if (sbyte == 0x00) {
}
display_intensity = sbyte;
di_conf_save(display_intensity);
+ display_unblank();
}
#endif
if (sbyte == TFESC) sbyte = FESC;
ESCAPE = false;
}
- if (sbyte == 0x00) {
- db_conf_save(0x00);
- } else {
- db_conf_save(0x01);
- }
+ db_conf_save(sbyte);
+ display_unblank();
}
#endif
}
void button_event(uint8_t event, unsigned long duration) {
+ display_unblank();
if (duration > 6000) {
bt_enable_pairing();
} else if (duration > 4000) {
#define ADDR_CONF_DSET 0xB1
#define ADDR_CONF_DINT 0xB2
#define ADDR_CONF_DADR 0xB3
+ #define ADDR_CONF_BSET 0xB7
#define ADDR_CONF_DBLK 0xB4
#define ADDR_CONF_PSET 0xB5
#define ADDR_CONF_PINT 0xB6
}
void db_conf_save(uint8_t val) {
+ if (val == 0x00) {
+ display_blanking_enabled = false;
+ } else {
+ display_blanking_enabled = true;
+ display_blanking_timeout = val*1000;
+ }
+ eeprom_update(eeprom_addr(ADDR_CONF_BSET), CONF_OK_BYTE);
eeprom_update(eeprom_addr(ADDR_CONF_DBLK), val);
}