main/task_user.c

changeset 23
58a328e91881
parent 22
cceb36fd3a2a
child 24
64078aa15512
--- a/main/task_user.c	Thu Nov 07 11:47:15 2019 +0100
+++ b/main/task_user.c	Thu Nov 07 15:09:51 2019 +0100
@@ -107,29 +107,39 @@
 {
     int	key = *curkey;
     int	rc = 0;
+    int8_t	ascent = u8g2_GetAscent(&u8g2);
+    int8_t	charheight = u8g2_GetMaxCharHeight(&u8g2);
+    int8_t	charwidth = u8g2_GetMaxCharWidth(&u8g2);
 
     u8g2_DrawHLine(&u8g2, x, y+3, 12);
     u8g2_SendBuffer(&u8g2);
 
+    ESP_LOGI(TAG, "getkey(%c, %d, %d, %d) a %d  h %d  w %d", key, type, x, y, ascent, charheight, charwidth);
+
     for (;;) {
     	if (xQueueReceive(event_queue, &event, 100 / portTICK_PERIOD_MS) == pdTRUE) {
 	    UserTimer = INACTIVITY;
 	    if (event.state.position != 0) {
 
-		u8g2_SetDrawColor(&u8g2, 0);
-		u8g2_DrawGlyph(&u8g2, x, y, key);
-		u8g2_SetDrawColor(&u8g2, 1);
+//		u8g2_SetDrawColor(&u8g2, 0);
+//		u8g2_DrawGlyph(&u8g2, x, y, key);
+//		u8g2_SetDrawColor(&u8g2, 1);
+
+		u8g2_DrawBox(&u8g2, x, y - ascent, 16, 16);
+//		u8g2_UpdateDisplayArea(&u8g2, x, y, 16, 16);
 		u8g2_SendBuffer(&u8g2);
 
 	    	if (event.state.position > 0) {
-		    if (key == 126)
-		    	key = 171;
-		    else if (key < 126)
+//		    if (key == 126)
+//		    	key = 171;
+//		    else
+		    if (key < 127)
 		    	key++;
 	    	} else if (event.state.position < 0) {
-		    if (key == 171)
-		    	key = 126;
-		    else if (key > 32)
+//		    if (key == 171)
+//		    	key = 126;
+//		    else 
+		    if (key > 32)
 		    	key--;
 		}
 
@@ -183,10 +193,12 @@
 	u8g2_SetFont(&u8g2, u8g2_font_t0_12b_tf);
 	u8g2_DrawStr(&u8g2, 0, 61, errmsg);
     }
-    u8g2_SetFont(&u8g2, u8g2_font_t0_12_tf);
+    u8g2_SetFont(&u8g2, u8g2_font_unifont_t_symbols);
+//    u8g2_SetFont(&u8g2, u8g2_font_t0_12_tf);
     y = 36;
     u8g2_DrawStr(&u8g2, 0, y, txt);
     u8g2_SendBuffer(&u8g2);
+    ESP_LOGI(TAG, "rotary_editer(%s, %s, %s, %d, %d)", label, txt, errmsg, len, type);
 
     for (;;) {
 	x = u8g2_GetUTF8Width(&u8g2, txt);
@@ -299,6 +311,8 @@
     	    u8g2_DrawUTF8(&u8g2, ((42 - w) / 2) + i * 43,63, buf);
 	}
 	xSemaphoreGive(xSemaphoreUnits);
+    } else {
+	ESP_LOGE(TAG, "screen_main() lock error");
     }
     u8g2_SendBuffer(&u8g2);
     u8g2_SetPowerSave(&u8g2, 0); // wake up display
@@ -326,10 +340,12 @@
     	sprintf(buf, "%.2f bar", units[no].pressure / 1000.0);
     	w = u8g2_GetUTF8Width(&u8g2, buf);
     	u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf);
+	u8g2_SendBuffer(&u8g2);
 
 	xSemaphoreGive(xSemaphoreUnits);
+    } else {
+	ESP_LOGE(TAG, "screen_unit(%d) lock error", no);
     }
-    u8g2_SendBuffer(&u8g2);
 }
 
 

mercurial