From 6b52cf5c15bfd27053d15e4d0e849c2ee5ffbd01 Mon Sep 17 00:00:00 2001 From: Christian Herzog Date: Wed, 15 Jan 2020 19:19:54 +0100 Subject: [PATCH 1/4] fully hide dummy iframe --- components/wifi-manager/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/components/wifi-manager/style.css b/components/wifi-manager/style.css index 55921866..1e4ea057 100644 --- a/components/wifi-manager/style.css +++ b/components/wifi-manager/style.css @@ -362,6 +362,7 @@ td.value { iframe#dummyframe { float: right; + border: none; } div#message { From 87713e4c93ddc229fa15031ae3f74b3ca18ccea8 Mon Sep 17 00:00:00 2001 From: philippe44 Date: Wed, 15 Jan 2020 15:08:19 -0800 Subject: [PATCH 2/4] much faster display update by modified "byte rows" --- components/display/display.c | 21 +++++++++ components/display/driver_SSD1306.c | 71 +++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/components/display/display.c b/components/display/display.c index 289b272f..565963b8 100644 --- a/components/display/display.c +++ b/components/display/display.c @@ -35,6 +35,27 @@ static void (*chained_notify)(in_addr_t ip, u16_t hport, u16_t cport); static void server_attach(in_addr_t ip, u16_t hport, u16_t cport); static bool display_handler(u8_t *data, int len); +/* scrolling undocumented information + grfs + B: screen number + B:1 = left, 2 = right, + Q: scroll pause once done (ms) + Q: scroll speed (ms) + W: # of pixels to scroll each time + W: 0 = continue scrolling after pause, 1 = scroll to scrollend and then stop, 2 = scroll to scrollend and then end animation (causing new update) + W: width of total scroll area in pixels + + grfd + W: screen number + W: width of scrollable area in pixels + +ANIC flags +ANIM_TRANSITION 0x01 # A transition animation has finished +ANIM_SCROLL_ONCE 0x02 # A scrollonce has finished +ANIM_SCREEN_1 0x04 # For scrollonce only, screen 1 was scrolling +ANIM_SCREEN_2 0x08 # For scrollonce only, screen 2 was scrolling +*/ + /**************************************************************************************** * */ diff --git a/components/display/driver_SSD1306.c b/components/display/driver_SSD1306.c index 68209e70..52b67dee 100644 --- a/components/display/driver_SSD1306.c +++ b/components/display/driver_SSD1306.c @@ -47,7 +47,7 @@ struct display_handle_s SSD1306_handle = { NULL, NULL, }; -static struct SSD1306_Device I2CDisplay; +static struct SSD1306_Device Display; static SSD1306_AddressMode AddressMode = AddressMode_Invalid; static const unsigned char BitReverseTable256[] = @@ -86,10 +86,10 @@ static bool display_init(char *config, char *welcome) { if (width != -1 && height != -1) { SSD1306_I2CMasterInitDefault( i2c_system_port, -1, -1 ) ; - SSD1306_I2CMasterAttachDisplayDefault( &I2CDisplay, width, height, I2C_ADDRESS, -1 ); - SSD1306_SetHFlip( &I2CDisplay, strcasestr(config, "HFlip") ? true : false); - SSD1306_SetVFlip( &I2CDisplay, strcasestr(config, "VFlip") ? true : false); - SSD1306_SetFont( &I2CDisplay, &Font_droid_sans_fallback_15x17 ); + SSD1306_I2CMasterAttachDisplayDefault( &Display, width, height, I2C_ADDRESS, -1 ); + SSD1306_SetHFlip( &Display, strcasestr(config, "HFlip") ? true : false); + SSD1306_SetVFlip( &Display, strcasestr(config, "VFlip") ? true : false); + SSD1306_SetFont( &Display, &Font_droid_sans_fallback_15x17 ); print_message(welcome); ESP_LOGI(TAG, "Initialized I2C display %dx%d", width, height); res = true; @@ -109,11 +109,11 @@ static bool display_init(char *config, char *welcome) { static void print_message(char *msg) { if (!msg) return; SSD1306_AddressMode Mode = AddressMode; - SSD1306_Clear( &I2CDisplay, SSD_COLOR_BLACK ); - SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode_Horizontal ); - SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_Center, msg, SSD_COLOR_WHITE ); - SSD1306_Update( &I2CDisplay ); - SSD1306_SetDisplayAddressMode( &I2CDisplay, Mode ); + SSD1306_Clear( &Display, SSD_COLOR_BLACK ); + SSD1306_SetDisplayAddressMode( &Display, AddressMode_Horizontal ); + SSD1306_FontDrawAnchoredString( &Display, TextAnchor_Center, msg, SSD_COLOR_WHITE ); + SSD1306_Update( &Display ); + SSD1306_SetDisplayAddressMode( &Display, Mode ); } /**************************************************************************************** @@ -178,17 +178,17 @@ static void show_display_buffer(char *ddram) { ESP_LOGI(TAG, "\n\t%.40s\n\t%.40s", line1, line2); - SSD1306_Clear( &I2CDisplay, SSD_COLOR_BLACK ); - SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_NorthWest, line1, SSD_COLOR_WHITE ); - SSD1306_FontDrawAnchoredString( &I2CDisplay, TextAnchor_SouthWest, line2, SSD_COLOR_WHITE ); + SSD1306_Clear( &Display, SSD_COLOR_BLACK ); + SSD1306_FontDrawAnchoredString( &Display, TextAnchor_NorthWest, line1, SSD_COLOR_WHITE ); + SSD1306_FontDrawAnchoredString( &Display, TextAnchor_SouthWest, line2, SSD_COLOR_WHITE ); // check addressing mode by rows if (AddressMode != AddressMode_Horizontal) { AddressMode = AddressMode_Horizontal; - SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode ); + SSD1306_SetDisplayAddressMode( &Display, AddressMode ); } - SSD1306_Update( &I2CDisplay ); + SSD1306_Update( &Display ); } /**************************************************************************************** @@ -245,16 +245,47 @@ void grfe_handler( u8_t *data, int len) { data += 8; len -= 8; +#ifndef FULL_REFRESH + // force addressing mode by lines + if (AddressMode != AddressMode_Horizontal) { + AddressMode = AddressMode_Horizontal; + SSD1306_SetDisplayAddressMode( &Display, AddressMode ); + } + + // try to minmize I2C traffic which is very slow + int rows = Display.Height / 8; + for (int r = 0; r < rows; r++) { + uint8_t first = 0, last; + uint8_t *optr = Display.Framebuffer + r*Display.Width, *iptr = data + r; + + // row/col swap, frame buffr comparison and bit-reversing + for (int c = 0; c < Display.Width; c++) { + if (*iptr != *optr) { + if (first) last = c; + else first = c; + } + *optr++ = BitReverseTable256[*iptr]; + iptr += rows; + } + + // now update the display by "byte rows" + if (first--) { + SSD1306_SetColumnAddress( &Display, first, last ); + SSD1306_SetPageAddress( &Display, r, r); + SSD1306_WriteRawData( &Display, Display.Framebuffer + r*Display.Width + first, last - first + 1); + } + } +#else // to be verified, but this is as fast as using a pointer on data for (int i = len - 1; i >= 0; i--) data[i] = BitReverseTable256[data[i]]; - - // check addressing mode by columns + + // force addressing mode by columns if (AddressMode != AddressMode_Vertical) { AddressMode = AddressMode_Vertical; - SSD1306_SetDisplayAddressMode( &I2CDisplay, AddressMode ); + SSD1306_SetDisplayAddressMode( &Display, AddressMode ); } - - SSD1306_WriteRawData( &I2CDisplay, data, len); + SSD1306_WriteRawData( &Display, data, len); + #endif } From 7c5e21287880035c61ddf8c0c4dad16b5455b83b Mon Sep 17 00:00:00 2001 From: philippe44 Date: Wed, 15 Jan 2020 15:18:06 -0800 Subject: [PATCH 3/4] set default I2C speed to 400k --- components/services/services.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/services/services.c b/components/services/services.c index 15af1491..92d497c9 100644 --- a/components/services/services.c +++ b/components/services/services.c @@ -28,7 +28,7 @@ static const char *TAG = "services"; * */ void services_init(void) { - int scl = -1, sda = -1, i2c_speed = 250000; + int scl = -1, sda = -1, i2c_speed = 400000; char *nvs_item, *p; gpio_install_isr_service(0); From f0a4233b3930ce16425328b1eee07fad632fb48b Mon Sep 17 00:00:00 2001 From: philippe44 Date: Wed, 15 Jan 2020 16:17:22 -0800 Subject: [PATCH 4/4] process_button fix + option for remap --- components/services/audio_controls.c | 23 +++++++++++++---------- components/services/audio_controls.h | 7 +++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/services/audio_controls.c b/components/services/audio_controls.c index 5700ec54..a1da7c52 100644 --- a/components/services/audio_controls.c +++ b/components/services/audio_controls.c @@ -18,7 +18,7 @@ * along with this program. If not, see . * */ -//#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE + #include #include #include @@ -68,18 +68,18 @@ static const char * TAG = "audio controls"; static actrls_config_t *json_config; static actrls_t default_controls, current_controls; -static void control_handler(void *id, button_event_e event, button_press_e press, bool long_press) { - actrls_config_t *key = (actrls_config_t*) id; +static void control_handler(void *client, button_event_e event, button_press_e press, bool long_press) { + actrls_config_t *key = (actrls_config_t*) client; actrls_action_e action; switch(press) { case BUTTON_NORMAL: - if (long_press) action = key->longpress[event == BUTTON_PRESSED ? 0 : 1]; - else action = key->normal[event == BUTTON_PRESSED ? 0 : 1]; + if (long_press) action = key->longpress[event == BUTTON_PRESSED ? 0 : 1].action; + else action = key->normal[event == BUTTON_PRESSED ? 0 : 1].action; break; case BUTTON_SHIFTED: - if (long_press) action = key->longshifted[event == BUTTON_PRESSED ? 0 : 1]; - else action = key->shifted[event == BUTTON_PRESSED ? 0 : 1]; + if (long_press) action = key->longshifted[event == BUTTON_PRESSED ? 0 : 1].action; + else action = key->shifted[event == BUTTON_PRESSED ? 0 : 1].action; break; default: action = ACTRLS_NONE; @@ -88,8 +88,11 @@ static void control_handler(void *id, button_event_e event, button_press_e press ESP_LOGD(TAG, "control gpio:%u press:%u long:%u event:%u action:%u", key->gpio, press, long_press, event, action); - if (action != ACTRLS_NONE) { - ESP_LOGD(TAG, " calling action %u", action); + if (action > ACTRLS_MAX) { + // need to do the remap here + ESP_LOGD(TAG, "remapping buttons"); + } else if (action != ACTRLS_NONE) { + ESP_LOGD(TAG, "calling action %u", action); if (current_controls[action]) (*current_controls[action])(); } } @@ -227,7 +230,7 @@ esp_err_t actrls_process_member(const cJSON * member, actrls_config_t *cur_confi } esp_err_t actrls_process_button(const cJSON * button, actrls_config_t *cur_config) { - esp_err_t err= ESP_FAIL; + esp_err_t err= ESP_OK; const cJSON *member; cJSON_ArrayForEach(member, button) diff --git a/components/services/audio_controls.h b/components/services/audio_controls.h index eaddfe40..2a63f1df 100644 --- a/components/services/audio_controls.h +++ b/components/services/audio_controls.h @@ -31,14 +31,17 @@ typedef void (*actrls_handler)(void); typedef actrls_handler actrls_t[ACTRLS_MAX - ACTRLS_NONE - 1]; // BEWARE any change to struct below must be mapped to actrls_config_map -typedef struct { +typedef struct actrl_config_s { int gpio; int type; bool pull; int debounce; int long_press; int shifter_gpio; - actrls_action_e normal[2], longpress[2], shifted[2], longshifted[2]; // [0] keypressed, [1] keyreleased + union { + actrls_action_e action; + struct actrl_config_s *config; + } normal[2], longpress[2], shifted[2], longshifted[2]; // [0] keypressed, [1] keyreleased } actrls_config_t; esp_err_t actrls_init(int n, const actrls_config_t *config);