feat: 添加u8g2测试显示页面

This commit is contained in:
Alvin Young 2025-03-22 18:49:01 +08:00
parent b0e0ddebf4
commit 3bd1e07432
6 changed files with 399 additions and 0 deletions

View File

@ -14,6 +14,7 @@ idf_component_register(
"utilities/u8g2/src" "utilities/u8g2/src"
"utilities/u8g2/port" "utilities/u8g2/port"
"services/display_service" "services/display_service"
"components/screen_pages/test_page"
EXCLUDE_SRCS EXCLUDE_SRCS
"utilities/imp_util_ring_queue/ring_queue_test.c" "utilities/imp_util_ring_queue/ring_queue_test.c"
@ -34,6 +35,7 @@ idf_component_register(
"utilities/u8g2/src" "utilities/u8g2/src"
"utilities/u8g2/port" "utilities/u8g2/port"
"services/display_service" "services/display_service"
"components/screen_pages/test_page"
LDFRAGMENTS LDFRAGMENTS
"utilities/letter_shell/port/esp-idf/shell.lf" "utilities/letter_shell/port/esp-idf/shell.lf"

View File

View File

@ -0,0 +1,250 @@
/**
* @file test_page.c
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2025-03-22
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2025 impressionyang
*
* @par :
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-03-22 <td>v1.0 <td>Alvin Young <td>
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "test_page.h"
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
/* Private function(only *.c) -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
static void draw(u8g2_t* u8g2)
{
// Layer 1
u8g2_SetFont(u8g2, u8g2_font_profont29_tr);
u8g2_DrawStr(u8g2, 19, 40, "12:00");
// Layer 2
u8g2_SetFont(u8g2, u8g2_font_profont17_tr);
u8g2_DrawStr(u8g2, 101, 40, "00");
// Layer 3
u8g2_SetFont(u8g2, u8g2_font_helvB08_tr);
u8g2_DrawStr(u8g2, 105, 49, "PM");
// Layer 4
u8g2_DrawLine(u8g2, 13, 23, 21, 15);
// Layer 5
u8g2_DrawLine(u8g2, 21, 15, 99, 15);
// Layer 6
u8g2_DrawLine(u8g2, 99, 15, 109, 23);
// Layer 7
u8g2_DrawLine(u8g2, 109, 23, 119, 23);
// Layer 9
u8g2_DrawLine(u8g2, 119, 23, 122, 26);
// Layer 10
u8g2_DrawLine(u8g2, 122, 26, 122, 48);
// Layer 11
u8g2_DrawLine(u8g2, 122, 48, 116, 54);
// Layer 12
u8g2_DrawLine(u8g2, 115, 54, 68, 54);
// Layer 14
u8g2_DrawLine(u8g2, 13, 24, 13, 44);
// Layer 16
u8g2_DrawLine(u8g2, 14, 45, 58, 45);
// Layer 17
u8g2_DrawLine(u8g2, 59, 45, 68, 54);
// Layer 17
u8g2_DrawLine(u8g2, 96, 43, 107, 54);
// Layer 18
u8g2_DrawLine(u8g2, 58, 45, 60, 43);
// Layer 19
u8g2_DrawLine(u8g2, 61, 43, 95, 43);
// Layer 19
u8g2_DrawFrame(u8g2, 0, 0, 128, 64);
// Layer 20
u8g2_SetDrawColor(u8g2, 2);
u8g2_SetFont(u8g2, u8g2_font_helvB08_tr);
u8g2_DrawStr(u8g2, 73, 53, "Sun");
// Layer 21
u8g2_SetDrawColor(u8g2, 1);
u8g2_SetFont(u8g2, u8g2_font_profont10_tr);
u8g2_DrawStr(u8g2, 12, 56, "01/01/2023");
// Layer 23
u8g2_DrawLine(u8g2, 68, 54, 63, 59);
// Layer 24
u8g2_DrawLine(u8g2, 7, 51, 7, 55);
// Layer 25
u8g2_DrawLine(u8g2, 0, 0, 0, 0);
// Layer 26
u8g2_DrawLine(u8g2, 11, 59, 63, 59);
// Layer 26
u8g2_DrawLine(u8g2, 13, 45, 7, 51);
// Layer 26
u8g2_DrawLine(u8g2, 0, 0, 0, 0);
// Layer 27
u8g2_DrawLine(u8g2, 7, 55, 11, 59);
// Layer 28
u8g2_SetDrawColor(u8g2, 2);
u8g2_DrawBox(u8g2, 68, 44, 30, 10);
// Layer 29
u8g2_SetDrawColor(u8g2, 1);
u8g2_DrawBox(u8g2, 60, 43, 9, 4);
// Layer 30 (copy)
u8g2_DrawFrame(u8g2, 64, 49, 7, 2);
// Layer 30
u8g2_DrawBox(u8g2, 62, 47, 6, 2);
// Layer 30 (copy)
u8g2_DrawFrame(u8g2, 64, 49, 7, 2);
// Layer 30 (copy)
u8g2_DrawFrame(u8g2, 64, 49, 7, 2);
// Layer 30 (copy)
u8g2_DrawFrame(u8g2, 64, 49, 4, 2);
// Layer 30 (copy) (copy)
u8g2_DrawFrame(u8g2, 66, 51, 3, 2);
// Layer 30 (copy) (copy)
u8g2_DrawFrame(u8g2, 66, 51, 7, 2);
// Layer 30 (copy) (copy)
u8g2_DrawFrame(u8g2, 97, 53, 10, 2);
// Layer 30 (copy) (copy)
u8g2_DrawFrame(u8g2, 66, 51, 7, 2);
// Layer 30 (copy) (copy) (copy)
u8g2_DrawFrame(u8g2, 95, 51, 10, 2);
// Layer 30 (copy) (copy) (copy)
u8g2_DrawFrame(u8g2, 99, 50, 4, 2);
// Layer 30 (copy) (copy) (copy)
u8g2_DrawFrame(u8g2, 97, 49, 6, 2);
// Layer 30 (copy) (copy) (copy)
u8g2_DrawFrame(u8g2, 97, 47, 4, 2);
// Layer 30 (copy) (copy) (copy)
u8g2_DrawFrame(u8g2, 95, 45, 4, 2);
// Layer 45
u8g2_DrawEllipse(u8g2, 5, 5, 2, 2, U8G2_DRAW_ALL);
// Layer 46
u8g2_DrawLine(u8g2, 5, 3, 5, 7);
// Layer 45 (copy)
u8g2_DrawEllipse(u8g2, 122, 5, 2, 2, U8G2_DRAW_ALL);
// Layer 45 (copy)
u8g2_DrawEllipse(u8g2, 5, 58, 2, 2, U8G2_DRAW_ALL);
// Layer 45 (copy)
u8g2_DrawEllipse(u8g2, 122, 58, 2, 2, U8G2_DRAW_ALL);
// Layer 50
u8g2_DrawLine(u8g2, 120, 5, 123, 5);
// Layer 51
u8g2_DrawLine(u8g2, 122, 56, 122, 59);
// Layer 52
u8g2_DrawLine(u8g2, 3, 58, 6, 58);
// Battery
u8g2_DrawXBM(u8g2, 89, 4, 26, 8, image_Battery_bits);
// Layer 53
u8g2_DrawBox(u8g2, 91, 6, 20, 4);
// Layer 54
u8g2_DrawFrame(u8g2, 11, 9, 51, 2);
// Layer 55
u8g2_DrawBox(u8g2, 62, 9, 25, 5);
// Layer 56
u8g2_DrawLine(u8g2, 59, 11, 61, 13);
// Layer 57
u8g2_DrawXBM(u8g2, 60, 11, 2, 2, image_Layer_57_bits);
// Layer 58
u8g2_DrawLine(u8g2, 55, 13, 4, 13);
// Layer 59
u8g2_DrawLine(u8g2, 16, 15, 4, 15);
// Layer 60
u8g2_DrawLine(u8g2, 13, 17, 4, 17);
// Layer 61
u8g2_DrawLine(u8g2, 9, 19, 4, 19);
// Layer 63
u8g2_DrawBox(u8g2, 11, 4, 2, 4);
// Layer 64
u8g2_DrawLine(u8g2, 0, 0, 0, 0);
// Layer 65
u8g2_SetDrawColor(u8g2, 2);
u8g2_DrawRBox(u8g2, 98, 26, 22, 17, 5);
// Layer 62 (copy) (copy) (copy)
u8g2_SetDrawColor(u8g2, 1);
u8g2_DrawLine(u8g2, 86, 3, 86, 13);
}
void test_page_draw_page(u8g2_t* u8g2)
{
u8g2_ClearBuffer(u8g2);
u8g2_SetBitmapMode(u8g2, 1);
u8g2_SetFontMode(u8g2, 1);
draw(u8g2);
u8g2_SendBuffer(u8g2);
}
/*
* EOF
*/

View File

@ -0,0 +1,38 @@
/**
* @file test_page.h
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2025-03-22
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2025 impressionyang
*
* @par :
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-03-22 <td>v1.0 <td>Alvin Young <td>
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "u8g2.h"
#include "u8x8.h"
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
static const uint8_t image_Battery_bits[] = {0xfe,0xff,0x7f,0x00,0x01,0x00,0x80,0x00,0x01,0x00,0x80,0x03,0x01,0x00,0x80,0x02,0x01,0x00,0x80,0x02,0x01,0x00,0x80,0x03,0x01,0x00,0x80,0x00,0xfe,0xff,0x7f,0x00};
static const uint8_t image_Layer_57_bits[] = {0x03,0x03};
/* Private function(only *.c) -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void test_page_draw_page(u8g2_t *u8g2);
void test_page_draw_page2(u8g2_t *u8g2);
/*
* EOF
*/

View File

@ -0,0 +1,91 @@
/**
* @file test_page2.c
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2025-03-22
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2025 impressionyang
*
* @par :
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2025-03-22 <td>v1.0 <td>Alvin Young <td>
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "test_page.h"
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
/* Private function(only *.c) -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
static const uint8_t image_wifi_75_bits[] = {
0x80, 0x0f, 0x00, 0x60, 0x30, 0x00, 0x18, 0xc0, 0x00, 0x84, 0x0f, 0x01,
0xe2, 0x3f, 0x02, 0xf1, 0x78, 0x04, 0x3a, 0xe7, 0x02, 0xdc, 0xdf, 0x01,
0xe8, 0xb8, 0x00, 0x70, 0x77, 0x00, 0xa0, 0x2f, 0x00, 0xc0, 0x1d, 0x00,
0x80, 0x0a, 0x00, 0x00, 0x07, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t image_download_bits[] = {
0x80, 0x03, 0x00, 0x40, 0x02, 0x00, 0x20, 0x42, 0x00, 0x10, 0x82, 0x00,
0x0f, 0x0a, 0x01, 0x01, 0x12, 0x01, 0x01, 0x22, 0x02, 0x01, 0x22, 0x02,
0x01, 0x22, 0x02, 0x01, 0x12, 0x01, 0x0f, 0x0a, 0x01, 0x10, 0x82, 0x00,
0x20, 0x42, 0x00, 0x40, 0x02, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00
};
static const uint8_t image_download_1_bits[] = {
0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0x00
};
static void draw(u8g2_t* u8g2)
{
// wifi_75
u8g2_DrawXBM(u8g2, 6, 6, 19, 16, image_wifi_75_bits);
// Layer 2
u8g2_DrawFrame(u8g2, 2, 2, 124, 60);
// download
u8g2_DrawXBM(u8g2, 34, 6, 18, 16, image_download_bits);
// download
u8g2_DrawXBM(u8g2, 56, 5, 65, 18, image_download_1_bits);
// Layer 5
u8g2_DrawLine(u8g2, 29, 21, 29, 6);
// Layer 6
u8g2_DrawBox(u8g2, 58, 6, 25, 15);
}
void test_page_draw_page2(u8g2_t* u8g2)
{
u8g2_ClearBuffer(u8g2);
u8g2_SetBitmapMode(u8g2, 1);
u8g2_SetFontMode(u8g2, 1);
draw(u8g2);
u8g2_SendBuffer(u8g2);
}
/*
* EOF
*/

View File

@ -33,6 +33,7 @@
#include "esp_log.h" #include "esp_log.h"
#include "test_page.h"
/* define --------------------------------------------------------------------*/ /* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/ /* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/ /* variables -----------------------------------------------------------------*/
@ -40,6 +41,7 @@
static imp_msg_queue_t* msg_q_handle = NULL; static imp_msg_queue_t* msg_q_handle = NULL;
static u8g2_t u8g2; static u8g2_t u8g2;
char build_time[100] = { 0 }; char build_time[100] = { 0 };
/* Private function(only *.c) -----------------------------------------------*/ /* Private function(only *.c) -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
@ -80,6 +82,22 @@ void imp_display_service_task(void*)
u8g2_DrawStr(&u8g2, 0, 64, build_time); u8g2_DrawStr(&u8g2, 0, 64, build_time);
u8g2_SendBuffer(&u8g2); // 一定要发送buffer u8g2_SendBuffer(&u8g2); // 一定要发送buffer
break; break;
case 3:
test_page_draw_page(&u8g2);
break;
case 4:
test_page_draw_page2(&u8g2);
break;
case 5: {
static int w = 0;
u8g2_SetDrawColor(&u8g2, 0);
u8g2_DrawBox(&u8g2, 58, 6, 62, 16);
u8g2_SetDrawColor(&u8g2, 0xFF);
u8g2_DrawBox(&u8g2, 58, 6, w * 5 + 2, 16);
u8g2_SendBuffer(&u8g2);
w = (w + 1) % 13;
cdc_printf("width : %d\r\n", w);
} break;
} }
} }
vTaskDelay(1 / portTICK_PERIOD_MS); vTaskDelay(1 / portTICK_PERIOD_MS);