main
parent
6c9a999c71
commit
8f7f72712c
|
@ -5,6 +5,6 @@
|
||||||
#ifndef HW_LIB_T_ARG_H
|
#ifndef HW_LIB_T_ARG_H
|
||||||
#define HW_LIB_T_ARG_H
|
#define HW_LIB_T_ARG_H
|
||||||
|
|
||||||
void Test_argpase(void *pVoid);
|
int Test_argpase(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_ARG_H
|
#endif //HW_LIB_T_ARG_H
|
||||||
|
|
|
@ -11,7 +11,7 @@ Option Opts[6] = {{"T0", T0},
|
||||||
{"T4", T4},
|
{"T4", T4},
|
||||||
{"T5", T5}};
|
{"T5", T5}};
|
||||||
|
|
||||||
void Test_argpase(void *pVoid) {
|
int Test_argpase(void *pVoid) {
|
||||||
OptList *Head = Options_Creat("Head", -1);
|
OptList *Head = Options_Creat("Head", -1);
|
||||||
OptList *t;
|
OptList *t;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
#ifndef HW_LIB_T_IIC_H
|
#ifndef HW_LIB_T_IIC_H
|
||||||
#define HW_LIB_T_IIC_H
|
#define HW_LIB_T_IIC_H
|
||||||
|
|
||||||
void Test_iic(void *pVoid);
|
int Test_iic(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_IIC_H
|
#endif //HW_LIB_T_IIC_H
|
||||||
|
|
|
@ -28,7 +28,7 @@ uint8_t SDA_Read() {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_iic(void *pVoid) {
|
int Test_iic(void *pVoid) {
|
||||||
SW_Dev_IIC dev = {
|
SW_Dev_IIC dev = {
|
||||||
.CLK_SET = CLK_Pin,
|
.CLK_SET = CLK_Pin,
|
||||||
.SDA_SET = SDA_Set,
|
.SDA_SET = SDA_Set,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef HW_LIB_T_KEY_H
|
#ifndef HW_LIB_T_KEY_H
|
||||||
#define HW_LIB_T_KEY_H
|
#define HW_LIB_T_KEY_H
|
||||||
|
|
||||||
void Test_Key(void *pVoid);
|
int Test_Key(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_KEY_H
|
#endif //HW_LIB_T_KEY_H
|
||||||
|
|
|
@ -38,7 +38,7 @@ void Key_Call(Key_t *key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_Key(void *pVoid) {
|
int Test_Key(void *pVoid) {
|
||||||
Key_t k1, k2, k3, k4, k5, k6, ks;
|
Key_t k1, k2, k3, k4, k5, k6, ks;
|
||||||
key_init(&k1, SIM_KEY_UP, 1, SIM_Key_UP);
|
key_init(&k1, SIM_KEY_UP, 1, SIM_Key_UP);
|
||||||
key_init(&k2, SIM_KEY_DOWN, 1, SIM_Key_DOWN);
|
key_init(&k2, SIM_KEY_DOWN, 1, SIM_Key_DOWN);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#ifndef HW_LIB_T_LIST_H
|
#ifndef HW_LIB_T_LIST_H
|
||||||
#define HW_LIB_T_LIST_H
|
#define HW_LIB_T_LIST_H
|
||||||
|
|
||||||
extern void Test_List(void *pVoid);
|
extern int Test_List(void *pVoid);
|
||||||
|
|
||||||
extern void Test_Queue(void *pVoid1);
|
extern int Test_Queue(void *pVoid1);
|
||||||
#endif //HW_LIB_T_LIST_H
|
#endif //HW_LIB_T_LIST_H
|
||||||
|
|
|
@ -38,7 +38,7 @@ void print(List_t *list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_List(void *pVoid) {
|
int Test_List(void *pVoid) {
|
||||||
List_t list;
|
List_t list;
|
||||||
list_init(&list); // 初始化链表
|
list_init(&list); // 初始化链表
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void Test_List(void *pVoid) {
|
||||||
list_destroy(&list, NULL); // 销毁链表
|
list_destroy(&list, NULL); // 销毁链表
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_Queue(void *pVoid) {
|
int Test_Queue(void *pVoid) {
|
||||||
Queue_List_t *deque = newQueue_List(sizeof(int)); // 创建一个int类型的双端队列
|
Queue_List_t *deque = newQueue_List(sizeof(int)); // 创建一个int类型的双端队列
|
||||||
|
|
||||||
// 测试入队操作
|
// 测试入队操作
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
#ifndef HW_LIB_T_LVGL_H
|
#ifndef HW_LIB_T_LVGL_H
|
||||||
#define HW_LIB_T_LVGL_H
|
#define HW_LIB_T_LVGL_H
|
||||||
|
|
||||||
void Test_lvgl(void *pVoid);
|
int Test_lvgl(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_LVGL_H
|
#endif //HW_LIB_T_LVGL_H
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "t_lvgl.h"
|
#include "t_lvgl.h"
|
||||||
|
#include "SDL3/SDL.h"
|
||||||
|
|
||||||
static void btn_event_cb(lv_event_t *e) {
|
static void btn_event_cb(lv_event_t *e) {
|
||||||
lv_event_code_t code = lv_event_get_code(e);
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
@ -33,21 +33,21 @@ void lv_example_get_started_1(void) {
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_lvgl(void *pVoid) {
|
int Test_lvgl(void *pVoid) {
|
||||||
lv_init();
|
lv_init();
|
||||||
lv_port_disp_init();
|
lv_port_disp_init();
|
||||||
lv_port_indev_init();
|
// lv_port_indev_init();
|
||||||
|
|
||||||
lv_example_get_started_1();
|
lv_example_get_started_1();
|
||||||
// lv_demo_widgets();
|
// lv_demo_widgets();
|
||||||
printf("\nTEST Widgets\n");
|
// printf("\nTEST Widgets\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Periodically call the lv_task handler.
|
/* Periodically call the lv_task handler.
|
||||||
* It could be done in a timer interrupt or an OS task too.*/
|
* It could be done in a timer interrupt or an OS task too.*/
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
lv_tick_inc(5);
|
lv_tick_inc(5);
|
||||||
Sleep(5);
|
SDL_Delay(5);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef HW_LIB_T_OLED_H
|
#ifndef HW_LIB_T_OLED_H
|
||||||
#define HW_LIB_T_OLED_H
|
#define HW_LIB_T_OLED_H
|
||||||
|
|
||||||
void Test_OLED(void *pVoid);
|
int Test_OLED(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_OLED_H
|
#endif //HW_LIB_T_OLED_H
|
||||||
|
|
|
@ -111,7 +111,7 @@ OLED_T oled = {
|
||||||
.call=Refresh_Call,
|
.call=Refresh_Call,
|
||||||
};
|
};
|
||||||
|
|
||||||
void Test_OLED(void *pVoid) {
|
int Test_OLED(void *pVoid) {
|
||||||
SIM_OLED_INIT(128, 64, CYAN, 0x0, 5, 0);
|
SIM_OLED_INIT(128, 64, CYAN, 0x0, 5, 0);
|
||||||
|
|
||||||
OLED_Init(&oled);
|
OLED_Init(&oled);
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
#ifndef HW_LIB_T_SPI_H
|
#ifndef HW_LIB_T_SPI_H
|
||||||
#define HW_LIB_T_SPI_H
|
#define HW_LIB_T_SPI_H
|
||||||
|
|
||||||
void Test_spi(void *pVoid);
|
int Test_spi(void *pVoid);
|
||||||
#endif //HW_LIB_T_SPI_H
|
#endif //HW_LIB_T_SPI_H
|
||||||
|
|
|
@ -32,7 +32,7 @@ uint8_t Miso_Pin() {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_spi(void *pVoid) {
|
int Test_spi(void *pVoid) {
|
||||||
SW_Dev_Spi ltl = {
|
SW_Dev_Spi ltl = {
|
||||||
.MOSI_SET=Mosi_Pin,
|
.MOSI_SET=Mosi_Pin,
|
||||||
.SCK_SET=Sck_Pin,
|
.SCK_SET=Sck_Pin,
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
#ifndef HW_LIB_T_TASK_H
|
#ifndef HW_LIB_T_TASK_H
|
||||||
#define HW_LIB_T_TASK_H
|
#define HW_LIB_T_TASK_H
|
||||||
|
|
||||||
_Noreturn void Test_task(void *pVoid);
|
_Noreturn int Test_task(void *pVoid);
|
||||||
|
|
||||||
#endif //HW_LIB_T_TASK_H
|
#endif //HW_LIB_T_TASK_H
|
||||||
|
|
|
@ -40,7 +40,7 @@ void exampleTimer4Callback(Task_t *task, void *userData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_task(void *pVoid) {
|
int Test_task(void *pVoid) {
|
||||||
TaskInit(GetTick);
|
TaskInit(GetTick);
|
||||||
TaskCreat(task1, 1000, -1, exampleTimer1Callback, "1000ms CYCLE task");
|
TaskCreat(task1, 1000, -1, exampleTimer1Callback, "1000ms CYCLE task");
|
||||||
TaskCreat(task2, 5000, -1, exampleTimer2Callback, "5000ms ONCE task");
|
TaskCreat(task2, 5000, -1, exampleTimer2Callback, "5000ms ONCE task");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef HW_LIB_T_TFT_H
|
#ifndef HW_LIB_T_TFT_H
|
||||||
#define HW_LIB_T_TFT_H
|
#define HW_LIB_T_TFT_H
|
||||||
|
|
||||||
void Test_tft(void *);
|
int Test_tft(void *);
|
||||||
|
|
||||||
#endif //HW_LIB_T_TFT_H
|
#endif //HW_LIB_T_TFT_H
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
TFT_T demo_tft;
|
TFT_T demo_tft;
|
||||||
uint16_t xs = 0, ys = 0, xe = 0, ye = 0;
|
uint16_t xs = 0, ys = 0, xe = 0, ye = 0;
|
||||||
bool fill;
|
bool fill;
|
||||||
static SIM_Display_t tft_display;
|
SIM_Display_t tft_display;
|
||||||
//屏幕指令
|
//屏幕指令
|
||||||
#define WGRAM_CMD 0x5C
|
#define WGRAM_CMD 0x5C
|
||||||
#define SETXCMD 0x2A
|
#define SETXCMD 0x2A
|
||||||
|
@ -79,7 +79,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) {
|
||||||
if (len == 2) {
|
if (len == 2) {
|
||||||
color_u.u8[1] = *data;
|
color_u.u8[1] = *data;
|
||||||
color_u.u8[0] = *data++;
|
color_u.u8[0] = *data++;
|
||||||
SIM_Color_DrawPiexl(&tft_display, (SIM_Color_t) RGB565_to_RGB888(color_u.u16, true), xs, ys);
|
SIM_Color_DrawPiexl(&tft_display, (SIM_Color_t) RGB565_to_ARGB8888(color_u.u16, true), xs, ys);
|
||||||
// LOGT("Piexl","color:%x,x:%d,y:%d,len:%d",color_u.u16,xs,ys,len);
|
// LOGT("Piexl","color:%x,x:%d,y:%d,len:%d",color_u.u16,xs,ys,len);
|
||||||
// SIM_Color_ImgFromBuffer(color,xs, ys, uint16_t width, 1)
|
// SIM_Color_ImgFromBuffer(color,xs, ys, uint16_t width, 1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +88,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) {
|
||||||
data++;
|
data++;
|
||||||
color_u.u8[0] = *data;
|
color_u.u8[0] = *data;
|
||||||
data++;
|
data++;
|
||||||
color[i] = RGB565_to_RGB888(color_u.u16, true) | 0xFF000000;
|
color[i] = RGB565_to_ARGB8888(color_u.u16, true);
|
||||||
}
|
}
|
||||||
SIM_Color_ImgFromBuffer(&tft_display, color, xs, ys, len / 2 - 1, 1);
|
SIM_Color_ImgFromBuffer(&tft_display, color, xs, ys, len / 2 - 1, 1);
|
||||||
// SIM_Color_DrawHLineBuffer(color, xs, ys, len / 2);
|
// SIM_Color_DrawHLineBuffer(color, xs, ys, len / 2);
|
||||||
|
@ -103,8 +103,7 @@ uint8_t tft_senddata(uint8_t *data, size_t len) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_tft(void *) {
|
int Test_tft(void *arg) {
|
||||||
|
|
||||||
//设备信息预填充
|
//设备信息预填充
|
||||||
demo_tft.width = 480;//实际如有支持不用填(如ST7735/7796)
|
demo_tft.width = 480;//实际如有支持不用填(如ST7735/7796)
|
||||||
demo_tft.height = 320;//实际如有支持不用填(如ST7735/7796)
|
demo_tft.height = 320;//实际如有支持不用填(如ST7735/7796)
|
||||||
|
@ -159,9 +158,10 @@ void Test_tft(void *) {
|
||||||
TFT_ShowBar(&demo_tft, 0, 142, demo_tft.width, 12, p);
|
TFT_ShowBar(&demo_tft, 0, 142, demo_tft.width, 12, p);
|
||||||
TFT_ShowBar(&demo_tft, 0, 155, demo_tft.width, 3, p);
|
TFT_ShowBar(&demo_tft, 0, 155, demo_tft.width, 3, p);
|
||||||
}
|
}
|
||||||
while (1) {
|
// while (1) {
|
||||||
|
//
|
||||||
Sleep(5);
|
// Sleep(5);
|
||||||
}
|
// }
|
||||||
|
SIM_Display_STOP(&tft_display);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
14
main.c
14
main.c
|
@ -160,15 +160,15 @@ int main(int argc, char *argv[]) {
|
||||||
// char str[] = "123.456";
|
// char str[] = "123.456";
|
||||||
// float result = Str2Float(str);
|
// float result = Str2Float(str);
|
||||||
// printf("Result: %.3f\n", result);
|
// printf("Result: %.3f\n", result);
|
||||||
// Test_Run("SPI", Test_spi);
|
// Test_Run("SPI", Test_spi,NULL);
|
||||||
// Test_Run("IIC", Test_iic);
|
// Test_Run("IIC", Test_iic,NULL);
|
||||||
// Test_Run("ArgPase", Test_argpase);
|
// Test_Run("ArgPase", Test_argpase,NULL);
|
||||||
// Test_Run("List", Test_List);
|
// Test_Run("List", Test_List,NULL);
|
||||||
// Test_RunTime("Key", Test_Key);
|
// Test_RunTime("Key", Test_Key);
|
||||||
// Test_RunTime("Queue", Test_Queue);
|
// Test_RunTime("Queue", Test_Queue);
|
||||||
// Test_RunTime("Task", Test_task);
|
// Test_RunTime("Task", Test_task);
|
||||||
// Test_Run("OLED", Test_OLED);
|
// Test_RunTime("OLED", Test_OLED);
|
||||||
// Test_Run("LVGL", Test_lvgl);
|
Test_RunTime("LVGL", Test_lvgl);
|
||||||
Test_RunTime("TFT", Test_tft);
|
// Test_RunTime("TFT", Test_tft);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <syncstream>
|
#include <syncstream>
|
||||||
#include "sim_test.h"
|
#include "sim_test.h"
|
||||||
|
|
||||||
void Test_RunTime(char *name, void (*pFunction)(void *)) {
|
void Test_RunTime(char *name, int (*pFunction)(void *)) {
|
||||||
clock_t start, end;
|
clock_t start, end;
|
||||||
double cpu_time_used;
|
double cpu_time_used;
|
||||||
|
|
||||||
|
@ -24,11 +24,7 @@ void Test_RunTime(char *name, void (*pFunction)(void *)) {
|
||||||
printf("\nTime taken by %s: %f seconds\n", name, cpu_time_used);
|
printf("\nTime taken by %s: %f seconds\n", name, cpu_time_used);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test_Run(char *name, void (*pFunction)(void *)) {
|
SDL_Thread *Test_Run(char *name, int (*pFunction)(void *), void *arg) {
|
||||||
|
|
||||||
|
|
||||||
printf("\n------< %s TEST >------\n", name);
|
printf("\n------< %s TEST >------\n", name);
|
||||||
_beginthread(pFunction, 0, NULL);
|
return ThreadCreat(pFunction, name, arg);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#include "sim_thread.h"
|
||||||
/**
|
/**
|
||||||
* @brief 测试函数执行时间
|
* @brief 测试函数执行时间
|
||||||
* @param name: [输入] 测试名称
|
* @param name: [输入] 测试名称
|
||||||
|
@ -15,9 +15,9 @@ extern "C" {
|
||||||
* @return void
|
* @return void
|
||||||
* @example Test("FunctionName", functionName);
|
* @example Test("FunctionName", functionName);
|
||||||
**/
|
**/
|
||||||
void Test_RunTime(char *name, void (*pFunction)(void *));
|
void Test_RunTime(char *name, int (*pFunction)(void *));
|
||||||
|
|
||||||
void Test_Run(char *name, void (*pFunction)(void *));
|
SDL_Thread *Test_Run(char *name, int (*pFunction)(void *), void *arg);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
#define GET_BIT(x, bit) ((x & (1 << bit)) >> bit)
|
||||||
|
|
||||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) {
|
uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR) {
|
||||||
uint8_t r5 = (rgb565 >> 11) & 0x1F;
|
uint8_t r5 = (rgb565 >> 11) & 0x1F;
|
||||||
uint8_t g6 = (rgb565 >> 5) & 0x3F;
|
uint8_t g6 = (rgb565 >> 5) & 0x3F;
|
||||||
uint8_t b5 = rgb565 & 0x1F;
|
uint8_t b5 = rgb565 & 0x1F;
|
||||||
|
@ -14,12 +14,11 @@ uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR) {
|
||||||
uint8_t b8 = (b5 * 527 + 23) >> 6;
|
uint8_t b8 = (b5 * 527 + 23) >> 6;
|
||||||
|
|
||||||
if (isBGR) {
|
if (isBGR) {
|
||||||
return (b8 << 16) | (g8 << 8) | r8;
|
return 0xFF000000 | (b8 << 16) | (g8 << 8) | r8;
|
||||||
} else {
|
} else {
|
||||||
return (r8 << 16) | (g8 << 8) | b8;
|
return 0xFF000000 | (r8 << 16) | (g8 << 8) | b8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USER_SDL3
|
#ifndef USER_SDL3
|
||||||
static uint32_t pixelColor, backgroundColor;
|
static uint32_t pixelColor, backgroundColor;
|
||||||
static int scaleFactor, w, h;
|
static int scaleFactor, w, h;
|
||||||
|
@ -211,8 +210,8 @@ void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x,
|
||||||
void
|
void
|
||||||
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye) {
|
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye) {
|
||||||
SIM_Color_t color;
|
SIM_Color_t color;
|
||||||
for (int y_i = ys; y_i < ye; y_i++) {
|
for (int y_i = ys; y_i <= ye; y_i++) {
|
||||||
for (int x_i = xs; x_i < xe; x_i++) {
|
for (int x_i = xs; x_i <= xe; x_i++) {
|
||||||
color.full = *buf;
|
color.full = *buf;
|
||||||
SIM_Color_DrawPiexl(display, color, x_i, y_i);
|
SIM_Color_DrawPiexl(display, color, x_i, y_i);
|
||||||
buf++;
|
buf++;
|
||||||
|
@ -221,6 +220,9 @@ SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uin
|
||||||
SDL_RenderPresent(display->renderer);
|
SDL_RenderPresent(display->renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SIM_Display_Refresh(SIM_Display_t *display) {
|
||||||
|
SDL_RenderPresent(display->renderer);
|
||||||
|
}
|
||||||
|
|
||||||
void SIM_Display_STOP(SIM_Display_t *display) {
|
void SIM_Display_STOP(SIM_Display_t *display) {
|
||||||
SDL_DestroyRenderer(display->renderer);
|
SDL_DestroyRenderer(display->renderer);
|
||||||
|
|
|
@ -153,7 +153,6 @@ typedef struct {
|
||||||
bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale,
|
bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint32_t backcolor, int scale,
|
||||||
SIM_Display_t *display);
|
SIM_Display_t *display);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 在指定的坐标位置绘制一个像素点
|
* @brief 在指定的坐标位置绘制一个像素点
|
||||||
* @param display: [输入] 输入窗口实例
|
* @param display: [输入] 输入窗口实例
|
||||||
|
@ -163,6 +162,13 @@ bool SIM_Display_Init(char *name, int width, int height, uint32_t pixcolor, uint
|
||||||
*/
|
*/
|
||||||
void SIM_Color_DrawPiexl(SIM_Display_t *display, SIM_Color_t color, uint16_t x, uint16_t y);
|
void SIM_Color_DrawPiexl(SIM_Display_t *display, SIM_Color_t color, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 从颜色缓冲区绘制单色图像到模拟显示器
|
||||||
|
* @param display 模拟显示器指针
|
||||||
|
* @param buf 颜色缓冲区指针
|
||||||
|
* @param width 绘制区域宽度
|
||||||
|
* @param height 绘制区域高度
|
||||||
|
*/
|
||||||
void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t width, uint16_t height);
|
void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t width, uint16_t height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,8 +182,8 @@ void SIM_OneColor_DrawFromBuffer(SIM_Display_t *display, uint8_t *buf, uint16_t
|
||||||
* @return void
|
* @return void
|
||||||
* @example SIM_Color_ImgFromBuffer(buf, 100, 50, 320, 240);
|
* @example SIM_Color_ImgFromBuffer(buf, 100, 50, 320, 240);
|
||||||
**/
|
**/
|
||||||
void
|
void SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y,
|
||||||
SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
uint16_t width, uint16_t height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 从缓冲区中填充颜色
|
* @brief 从缓冲区中填充颜色
|
||||||
|
@ -193,6 +199,12 @@ SIM_Color_ImgFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t x, uint1
|
||||||
void
|
void
|
||||||
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
SIM_Color_FillFromBuffer(SIM_Display_t *display, uint32_t *buf, uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 刷新模拟显示器
|
||||||
|
*
|
||||||
|
* @param display 模拟显示器指针
|
||||||
|
*/
|
||||||
|
void SIM_Display_Refresh(SIM_Display_t *display);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 停止模拟 显示
|
* @brief 停止模拟 显示
|
||||||
|
@ -204,7 +216,7 @@ void SIM_Display_STOP(SIM_Display_t *display);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
uint32_t RGB565_to_RGB888(uint16_t rgb565, bool isBGR);
|
uint32_t RGB565_to_ARGB8888(uint16_t rgb565, bool isBGR);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|
||||||
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
||||||
#define LV_COLOR_DEPTH 16
|
#define LV_COLOR_DEPTH 32
|
||||||
|
|
||||||
/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
|
/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
|
||||||
#define LV_COLOR_16_SWAP 0
|
#define LV_COLOR_16_SWAP 0
|
||||||
|
@ -230,7 +230,7 @@
|
||||||
*-----------*/
|
*-----------*/
|
||||||
|
|
||||||
/*Enable the log module*/
|
/*Enable the log module*/
|
||||||
#define LV_USE_LOG 1
|
#define LV_USE_LOG 0
|
||||||
#if LV_USE_LOG
|
#if LV_USE_LOG
|
||||||
|
|
||||||
/*How important log should be added:
|
/*How important log should be added:
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
**********************/
|
**********************/
|
||||||
static SIM_Display_t lvgl_display;
|
SIM_Display_t lvgl_display;
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -142,7 +142,7 @@ void lv_port_disp_init(void)
|
||||||
static void disp_init(void)
|
static void disp_init(void)
|
||||||
{
|
{
|
||||||
/*You code here*/
|
/*You code here*/
|
||||||
SIM_Display_Init("LVGL", MY_DISP_HOR_RES, MY_DISP_VER_RES, 0xffffff, BLACK, 1, &lvgl_display);
|
SIM_Display_Init("LVGL", MY_DISP_HOR_RES, MY_DISP_VER_RES, 0xffffff, BLACK, 2, &lvgl_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile bool disp_flush_enabled = true;
|
volatile bool disp_flush_enabled = true;
|
||||||
|
@ -165,7 +165,7 @@ void colortorgb24(lv_color_t* color_p, uint32_t* color, size_t len)
|
||||||
{
|
{
|
||||||
while (len)
|
while (len)
|
||||||
{
|
{
|
||||||
*color = RGB565_to_RGB888(color_p->full, false);
|
*color = RGB565_to_ARGB8888(color_p->full, false);
|
||||||
color_p++;
|
color_p++;
|
||||||
color++;
|
color++;
|
||||||
len--;
|
len--;
|
||||||
|
@ -180,13 +180,13 @@ static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_
|
||||||
if (disp_flush_enabled)
|
if (disp_flush_enabled)
|
||||||
{
|
{
|
||||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||||
uint32_t* color;
|
// uint32_t* color;
|
||||||
size_t l = (area->x2 - area->x1) * (area->y2 - area->y1);
|
size_t l = (area->x2 - area->x1 + 1) * (area->y2 - area->y1 + 1);
|
||||||
color = (uint32_t*)malloc(sizeof(uint32_t) * l);
|
// color = (uint32_t*)malloc(sizeof(uint32_t) * l);
|
||||||
|
//
|
||||||
colortorgb24(color_p, color, l);
|
// colortorgb24(color_p, color, l);
|
||||||
SIM_Color_FillFromBuffer(&lvgl_display, color, area->x1, area->y1, area->x2, area->y2);
|
SIM_Color_FillFromBuffer(&lvgl_display, (uint32_t *) color_p, area->x1, area->y1, area->x2, area->y2);
|
||||||
free(color);
|
// free(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*IMPORTANT!!!
|
/*IMPORTANT!!!
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void (*Thread_Func_t)(void *pArg);
|
#include "SDL3/SDL.h"
|
||||||
|
|
||||||
void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg);
|
typedef int (*Thread_Func_t)(void *pArg);
|
||||||
void ThreadStop();
|
|
||||||
|
SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg);
|
||||||
|
|
||||||
|
void ThreadStop(SDL_Thread *t);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
#include "sim_thread.h"
|
#include "sim_thread.h"
|
||||||
#include <windows.h>
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
void ThreadCreat(Thread_Func_t func, unsigned int stackSize, void *pArg) {
|
SDL_Thread *ThreadCreat(Thread_Func_t func, char *name, void *pArg) {
|
||||||
_beginthread(func, stackSize, pArg);
|
SDL_Thread *t = SDL_CreateThread(func, name, NULL);
|
||||||
|
if (!t) {
|
||||||
|
SDL_Log("CreateThread: %s", SDL_GetError);
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadStop() {
|
void ThreadStop(SDL_Thread *t) {
|
||||||
_endthread();
|
SDL_WaitThread(t, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue