From 575cf45c4e5a83af5fb489c0dcd3b1813738cba8 Mon Sep 17 00:00:00 2001 From: Nils Date: Thu, 7 Oct 2021 14:48:58 +0200 Subject: [PATCH] this message --- main/main.cpp | 95 +++++++++++++++++++++++++++------------------------ sdkconfig.old | 18 +++++----- 2 files changed, 61 insertions(+), 52 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 220d109..867b257 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -27,13 +27,49 @@ u8g2_esp32_hal_t u8g2_esp32_hal; struct timeval tv_now; -static int x; -static char* text; +/* + Fontname: Untitledthisfon + Copyright: Created with Fony 1.4.0.2 + Glyphs: 224/256 + BBX Build Mode: 0 +*/ +const uint8_t BT_font[939] U8G2_FONT_SECTION("BT_font") = + "\340\0\3\3\4\4\1\1\5\10\17\0\0\17\0\0\0\0\204\1\20\3\216 \4\0c!\4\0c\42" + "\4\0c#\4\0c$\4\0c%\4\0c&\4\0c'\4\0c(\4\0c)\4\0c*" + "\4\0c+\4\0c,\4\0c-\4\0c.\4\0c/\4\0c\60\4\0c\61\4\0c\62" + "\4\0c\63\4\0c\64\4\0c\65\4\0c\66\4\0c\67\4\0c\70\4\0c\71\4\0c:" + "\4\0c;\4\0c<\4\0c=\4\0c>\4\0c\77\4\0c@\4\0cA\20\370\343\211" + "\245D\66\221\236,\207!\343X\34B\4\0cC\4\0cD\4\0cE\4\0cF\4\0cG" + "\4\0cH\4\0cI\4\0cJ\4\0cK\4\0cL\4\0cM\4\0cN\4\0cO" + "\4\0cP\4\0cQ\4\0cR\4\0cS\4\0cT\4\0cU\4\0cV\4\0cW" + "\4\0cX\4\0cY\4\0cZ\4\0c[\4\0c\134\4\0c]\4\0c^\4\0c_" + "\4\0c`\4\0ca\4\0cb\4\0cc\4\0cd\4\0ce\4\0cf\4\0cg" + "\4\0ch\4\0ci\4\0cj\4\0ck\4\0cl\4\0cm\4\0cn\4\0co" + "\4\0cp\4\0cq\4\0cr\4\0cs\4\0ct\4\0cu\4\0cv\4\0cw" + "\4\0cx\4\0cy\4\0cz\4\0c{\4\0c|\4\0c}\4\0c~\4\0c\177" + "\4\0c\200\4\0c\201\4\0c\202\4\0c\203\4\0c\204\4\0c\205\4\0c\206\4\0c\207" + "\4\0c\210\4\0c\211\4\0c\212\4\0c\213\4\0c\214\4\0c\215\4\0c\216\4\0c\217" + "\4\0c\220\4\0c\221\4\0c\222\4\0c\223\4\0c\224\4\0c\225\4\0c\226\4\0c\227" + "\4\0c\230\4\0c\231\4\0c\232\4\0c\233\4\0c\234\4\0c\235\4\0c\236\4\0c\237" + "\4\0c\240\4\0c\241\4\0c\242\4\0c\243\4\0c\244\4\0c\245\4\0c\246\4\0c\247" + "\4\0c\250\4\0c\251\4\0c\252\4\0c\253\4\0c\254\4\0c\255\4\0c\256\4\0c\257" + "\4\0c\260\4\0c\261\4\0c\262\4\0c\263\4\0c\264\4\0c\265\4\0c\266\4\0c\267" + "\4\0c\270\4\0c\271\4\0c\272\4\0c\273\4\0c\274\4\0c\275\4\0c\276\4\0c\277" + "\4\0c\300\4\0c\301\4\0c\302\4\0c\303\4\0c\304\4\0c\305\4\0c\306\4\0c\307" + "\4\0c\310\4\0c\311\4\0c\312\4\0c\313\4\0c\314\4\0c\315\4\0c\316\4\0c\317" + "\4\0c\320\4\0c\321\4\0c\322\4\0c\323\4\0c\324\4\0c\325\4\0c\326\4\0c\327" + "\4\0c\330\4\0c\331\4\0c\332\4\0c\333\4\0c\334\4\0c\335\4\0c\336\4\0c\337" + "\4\0c\340\4\0c\341\4\0c\342\4\0c\343\4\0c\344\4\0c\345\4\0c\346\4\0c\347" + "\4\0c\350\4\0c\351\4\0c\352\4\0c\353\4\0c\354\4\0c\355\4\0c\356\4\0c\357" + "\4\0c\360\4\0c\361\4\0c\362\4\0c\363\4\0c\364\4\0c\365\4\0c\366\4\0c\367" + "\4\0c\370\4\0c\371\4\0c\372\4\0c\373\4\0c\374\4\0c\375\4\0c\376\4\0c\377" + "\4\0c\0\0\0\4\377\377\0"; + +static char* text = (char*) "Disconnected!"; static int textWidth; -static bool scrolling = false; static bool connected = false; - -void scrollText(char*); +static int SCREENHEIGHT; +static int SCREENWIDTH; void update_display(al_event_cb_t, al_event_cb_param_t*); void draw(); @@ -57,8 +93,11 @@ extern "C" { u8x8_SetI2CAddress(&u8g2.u8x8, 0x3C); u8g2_InitDisplay(&u8g2); u8g2_SetPowerSave(&u8g2, 0); - u8g2_SetFont(&u8g2, u8g2_font_ncenR24_tf); + u8g2_SetFont(&u8g2, BT_font); + SCREENWIDTH = u8g2_GetDisplayWidth(&u8g2); + SCREENHEIGHT = u8g2_GetDisplayHeight(&u8g2); + textWidth = u8g2_GetStrWidth(&u8g2, text); Audiosource.set_I2S(26, 27, 25); @@ -68,70 +107,39 @@ extern "C" { Audiosource.add_combined_filter(highshelf_filter); Audiosource.add_combined_filter(lowpass_filter); Audiosource.start(); - - while (true) { - while (connected) { - - - - - } + while (true) { draw(); - vTaskDelay(pdMS_TO_TICKS(100)); } } } -void draw() { - u8g2_ClearBuffer(&u8g2); - u8g2_DrawStr(&u8g2, x, 32, text); - u8g2_SendBuffer(&u8g2); -} -void scrollText(char* text) { - u8g2_ClearBuffer(&u8g2); - u8g2_DrawStr(&u8g2, x, 32, text); +void draw() { + u8g2_DrawStr(&u8g2, 0, SCREENHEIGHT, "AAAAAAAAAA"); u8g2_SendBuffer(&u8g2); - if (x == 0) { - vTaskDelay(pdMS_TO_TICKS(990)); - } - - if ((textWidth + x) > u8g2_GetDisplayWidth(&u8g2)) { - x -= 1; - } - - else { - x = 0; - vTaskDelay(pdMS_TO_TICKS(990)); - } vTaskDelay(pdMS_TO_TICKS(10)); } void update_display(al_event_cb_t event, al_event_cb_param_t* param) { - x = 0; switch (event) { case AL_CONNECTED: - scrolling = true; text = (char*) "Connected!"; printf("AL, Connected\n"); connected = true; break; case AL_DISCONNECTED: - scrolling = true; text = (char*) "Disconnected!"; printf("AL, Disconnected\n"); break; case AL_PLAYING: - scrolling = false; text = (char*) "PLAY"; printf("AL, Playing\n"); break; case AL_PAUSED: - scrolling = false; text = (char*) "PAUSE"; printf("AL, Paused\n"); break; @@ -141,8 +149,6 @@ void update_display(al_event_cb_t event, al_event_cb_param_t* param) { break; case AL_META_UPDATE: - scrolling = true; - int titleLen = strlen(param->metadata.title); int artistLen = strlen(param->metadata.artist); @@ -152,13 +158,14 @@ void update_display(al_event_cb_t event, al_event_cb_param_t* param) { memcpy(text + titleLen + 3, param->metadata.artist, artistLen); *(text + titleLen + 3 + artistLen) = *"\0"; - textWidth = u8g2_GetUTF8Width(&u8g2, text); - printf("%d\n", textWidth); printf("%s\n", text); printf("AL, Meta_Update\n"); break; + } + textWidth = u8g2_GetStrWidth(&u8g2, text); + draw(); } diff --git a/sdkconfig.old b/sdkconfig.old index 1fed36d..8b7fc89 100644 --- a/sdkconfig.old +++ b/sdkconfig.old @@ -99,13 +99,13 @@ CONFIG_ESPTOOLPY_AFTER_RESET=y CONFIG_ESPTOOLPY_AFTER="hard_reset" # CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set # CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set -CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B is not set # CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set # CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set -# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB=y # CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=2000000 # end of Serial flasher config # @@ -789,7 +789,8 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 CONFIG_FREERTOS_ISR_STACKSIZE=1536 # CONFIG_FREERTOS_LEGACY_HOOKS is not set CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -# CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION is not set +CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 @@ -1271,13 +1272,13 @@ CONFIG_FLASHMODE_DIO=y # CONFIG_FLASHMODE_DOUT is not set # CONFIG_MONITOR_BAUD_9600B is not set # CONFIG_MONITOR_BAUD_57600B is not set -CONFIG_MONITOR_BAUD_115200B=y +# CONFIG_MONITOR_BAUD_115200B is not set # CONFIG_MONITOR_BAUD_230400B is not set # CONFIG_MONITOR_BAUD_921600B is not set -# CONFIG_MONITOR_BAUD_2MB is not set +CONFIG_MONITOR_BAUD_2MB=y # CONFIG_MONITOR_BAUD_OTHER is not set CONFIG_MONITOR_BAUD_OTHER_VAL=115200 -CONFIG_MONITOR_BAUD=115200 +CONFIG_MONITOR_BAUD=2000000 CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y # CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y @@ -1547,7 +1548,8 @@ CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 CONFIG_MB_TIMER_PORT_ENABLED=y CONFIG_MB_TIMER_GROUP=0 CONFIG_MB_TIMER_INDEX=0 -# CONFIG_SUPPORT_STATIC_ALLOCATION is not set +CONFIG_SUPPORT_STATIC_ALLOCATION=y +# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set CONFIG_TIMER_TASK_PRIORITY=1 CONFIG_TIMER_TASK_STACK_DEPTH=2048 CONFIG_TIMER_QUEUE_LENGTH=10 -- 2.30.2