增加CAN接口的读写操作
This commit is contained in:
parent
36377d17d6
commit
c402ffe1a8
@ -29,7 +29,12 @@ void screen_home_init(lv_ui *ui)
|
|||||||
#ifdef USE_CUSTOM_CODE
|
#ifdef USE_CUSTOM_CODE
|
||||||
lv_obj_set_style_text_font(ui->screen_home_table_1, lv_ft_MHEIGB[24].font, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
lv_obj_set_style_text_font(ui->screen_home_table_1, lv_ft_MHEIGB[24].font, LV_PART_ITEMS|LV_STATE_DEFAULT);
|
||||||
#endif
|
#endif
|
||||||
lv_table_set_col_width(ui->screen_home_table_1,0,60);
|
lv_table_set_col_width(ui->screen_home_table_1,0,70);
|
||||||
|
// lv_table_set_col_width(ui->screen_home_table_1,1,200);
|
||||||
|
// lv_table_set_col_width(ui->screen_home_table_1,2,200);
|
||||||
|
lv_table_set_col_width(ui->screen_home_table_1,3,80);
|
||||||
|
lv_table_set_col_width(ui->screen_home_table_1,4,70);
|
||||||
|
lv_table_set_col_width(ui->screen_home_table_1,5,400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,6 +139,8 @@ static void screen_home_btnm_1_event_handler (lv_event_t *e)
|
|||||||
lv_btnmatrix_set_ctrl_map(obj, btnm_state_map);
|
lv_btnmatrix_set_ctrl_map(obj, btnm_state_map);
|
||||||
|
|
||||||
sockfd_can0 = socket_can_init("can1");
|
sockfd_can0 = socket_can_init("can1");
|
||||||
|
|
||||||
|
start_can_receive_task(sockfd_can0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (2):
|
case (2):
|
||||||
@ -144,6 +151,7 @@ static void screen_home_btnm_1_event_handler (lv_event_t *e)
|
|||||||
btnm_state_map[1] = 0;
|
btnm_state_map[1] = 0;
|
||||||
lv_btnmatrix_set_ctrl_map(obj, btnm_state_map);
|
lv_btnmatrix_set_ctrl_map(obj, btnm_state_map);
|
||||||
sockfd_can0 = socket_can_close(sockfd_can0);
|
sockfd_can0 = socket_can_close(sockfd_can0);
|
||||||
|
stop_can_receive_task();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -188,6 +196,25 @@ static void screen_home_btnm_2_event_handler (lv_event_t *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void screen_home_table_1_event_handler(lv_event_t *e)
|
||||||
|
{
|
||||||
|
lv_event_code_t code = lv_event_get_code(e);
|
||||||
|
switch (code) {
|
||||||
|
case LV_EVENT_CLICKED:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int *data = (int *)lv_event_get_param(e);
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
printf("%02X ", data[i]);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void screen_home_win_1_item0_event_handler (lv_event_t *e)
|
static void screen_home_win_1_item0_event_handler (lv_event_t *e)
|
||||||
{
|
{
|
||||||
@ -209,12 +236,22 @@ static void screen_home_btn_3_event_handler (lv_event_t *e)
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
case LV_EVENT_CLICKED:
|
case LV_EVENT_CLICKED:
|
||||||
{
|
{
|
||||||
printf("LV_EVENT_CLICKED\r\n");
|
// printf("LV_EVENT_CLICKED\r\n");
|
||||||
uint8_t data[8] = {1,2,3,4,5,6,7,8};
|
// uint8_t data[8] = {1,2,3,4,5,6,7,8};
|
||||||
if(sockfd_can0 != -1)
|
// if(sockfd_can0 != -1)
|
||||||
{
|
// {
|
||||||
socket_can_send(sockfd_can0,0x12,data);
|
// socket_can_send(sockfd_can0,0x12,data);
|
||||||
}
|
// lv_event_send(guider_ui.screen_home_table_1, 0x30, data);
|
||||||
|
// }
|
||||||
|
// 动态分配数组
|
||||||
|
int *data = (int *)malloc(8 * sizeof(int));
|
||||||
|
data[0] = 10;
|
||||||
|
data[1] = 20;
|
||||||
|
data[2] = 30;
|
||||||
|
|
||||||
|
// 手动发送事件,并传递动态数组指针
|
||||||
|
lv_event_send(guider_ui.screen_home_table_1, 0x30, data);
|
||||||
|
lv_event_send(guider_ui.screen_home_table_1, 0x30, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -246,6 +283,7 @@ void events_init_screen_home (lv_ui *ui)
|
|||||||
lv_obj_add_event_cb(ui->screen_home_btn_3, screen_home_btn_3_event_handler, LV_EVENT_ALL, ui);
|
lv_obj_add_event_cb(ui->screen_home_btn_3, screen_home_btn_3_event_handler, LV_EVENT_ALL, ui);
|
||||||
lv_obj_add_event_cb(ui->screen_home_btn_5, screen_home_btn_5_event_handler, LV_EVENT_ALL, ui);
|
lv_obj_add_event_cb(ui->screen_home_btn_5, screen_home_btn_5_event_handler, LV_EVENT_ALL, ui);
|
||||||
lv_obj_add_event_cb(ui->screen_home_btnm_2, screen_home_btnm_2_event_handler, LV_EVENT_ALL, ui);
|
lv_obj_add_event_cb(ui->screen_home_btnm_2, screen_home_btnm_2_event_handler, LV_EVENT_ALL, ui);
|
||||||
|
lv_obj_add_event_cb(ui->screen_home_table_1, screen_home_table_1_event_handler, 0x30, ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -686,6 +686,17 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
|
|||||||
0xa1, 0xc0, 0x0, 0xc0, 0x9, 0xd4, 0x70, 0xcb,
|
0xa1, 0xc0, 0x0, 0xc0, 0x9, 0xd4, 0x70, 0xcb,
|
||||||
0xbb, 0xc0,
|
0xbb, 0xc0,
|
||||||
|
|
||||||
|
/* U+63A5 "接" */
|
||||||
|
0x0, 0xb0, 0x0, 0x77, 0x0, 0x0, 0x0, 0xb0,
|
||||||
|
0x37, 0x7d, 0x97, 0x60, 0x2a, 0xea, 0x47, 0x74,
|
||||||
|
0x49, 0x30, 0x1, 0xb1, 0x1, 0xc1, 0x66, 0x0,
|
||||||
|
0x0, 0xb0, 0x57, 0xa8, 0xf7, 0x71, 0x0, 0xba,
|
||||||
|
0x33, 0x58, 0x33, 0x30, 0x2b, 0xe1, 0x8a, 0xcc,
|
||||||
|
0xaa, 0xa4, 0x1, 0xb0, 0x3, 0xb1, 0x57, 0x10,
|
||||||
|
0x0, 0xb0, 0xa, 0xc7, 0xc0, 0x0, 0x0, 0xb0,
|
||||||
|
0x2, 0xab, 0xaa, 0x20, 0xb, 0xb4, 0xca, 0x40,
|
||||||
|
0x2, 0xb1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||||
|
|
||||||
/* U+64CD "操" */
|
/* U+64CD "操" */
|
||||||
0x0, 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb0,
|
0x0, 0xb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb0,
|
||||||
0xc, 0xbb, 0xbc, 0x0, 0x5, 0xc5, 0x1c, 0x33,
|
0xc, 0xbb, 0xbc, 0x0, 0x5, 0xc5, 0x1c, 0x33,
|
||||||
@ -1635,85 +1646,86 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
|
|||||||
{.bitmap_index = 2788, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 2788, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 2860, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 2860, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 2938, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 2938, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3004, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 3004, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3070, .adv_w = 192, .box_w = 11, .box_h = 13, .ofs_x = 1, .ofs_y = -2},
|
{.bitmap_index = 3076, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3142, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3142, .adv_w = 192, .box_w = 11, .box_h = 13, .ofs_x = 1, .ofs_y = -2},
|
||||||
{.bitmap_index = 3220, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3214, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3292, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
{.bitmap_index = 3292, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3353, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 3364, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
||||||
{.bitmap_index = 3419, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 3425, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3485, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3491, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3557, .adv_w = 192, .box_w = 12, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 3557, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3617, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 3629, .adv_w = 192, .box_w = 12, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3683, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3689, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 3755, .adv_w = 192, .box_w = 8, .box_h = 11, .ofs_x = 2, .ofs_y = -1},
|
{.bitmap_index = 3755, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3799, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3827, .adv_w = 192, .box_w = 8, .box_h = 11, .ofs_x = 2, .ofs_y = -1},
|
||||||
{.bitmap_index = 3871, .adv_w = 192, .box_w = 13, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3871, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 3949, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 3943, .adv_w = 192, .box_w = 13, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4021, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4021, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4093, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4093, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4165, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
{.bitmap_index = 4165, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4220, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
{.bitmap_index = 4237, .adv_w = 192, .box_w = 10, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
||||||
{.bitmap_index = 4281, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4292, .adv_w = 192, .box_w = 11, .box_h = 11, .ofs_x = 1, .ofs_y = -1},
|
||||||
{.bitmap_index = 4359, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 4353, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4413, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 4431, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 4479, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 4485, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 4533, .adv_w = 132, .box_w = 9, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 4551, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 4574, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4605, .adv_w = 132, .box_w = 9, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 4652, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4646, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4730, .adv_w = 216, .box_w = 14, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 4724, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4807, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4802, .adv_w = 216, .box_w = 14, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 4885, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 4879, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 4948, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 4957, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 5026, .adv_w = 96, .box_w = 6, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5020, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 5056, .adv_w = 144, .box_w = 9, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5098, .adv_w = 96, .box_w = 6, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5101, .adv_w = 216, .box_w = 14, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 5128, .adv_w = 144, .box_w = 9, .box_h = 10, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5192, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 5173, .adv_w = 216, .box_w = 14, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 5246, .adv_w = 132, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 5264, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 5305, .adv_w = 168, .box_w = 8, .box_h = 12, .ofs_x = 1, .ofs_y = -2},
|
{.bitmap_index = 5318, .adv_w = 132, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 5353, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 5377, .adv_w = 168, .box_w = 8, .box_h = 12, .ofs_x = 1, .ofs_y = -2},
|
||||||
{.bitmap_index = 5425, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5425, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 5486, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5497, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5547, .adv_w = 168, .box_w = 8, .box_h = 12, .ofs_x = 1, .ofs_y = -2},
|
{.bitmap_index = 5558, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5595, .adv_w = 168, .box_w = 12, .box_h = 11, .ofs_x = -1, .ofs_y = -1},
|
{.bitmap_index = 5619, .adv_w = 168, .box_w = 8, .box_h = 12, .ofs_x = 1, .ofs_y = -2},
|
||||||
{.bitmap_index = 5661, .adv_w = 120, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5667, .adv_w = 168, .box_w = 12, .box_h = 11, .ofs_x = -1, .ofs_y = -1},
|
||||||
{.bitmap_index = 5700, .adv_w = 120, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5733, .adv_w = 120, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5739, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 5772, .adv_w = 120, .box_w = 7, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5800, .adv_w = 168, .box_w = 11, .box_h = 3, .ofs_x = 0, .ofs_y = 3},
|
{.bitmap_index = 5811, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 5817, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 5872, .adv_w = 168, .box_w = 11, .box_h = 3, .ofs_x = 0, .ofs_y = 3},
|
||||||
{.bitmap_index = 5880, .adv_w = 240, .box_w = 16, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 5889, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 5984, .adv_w = 216, .box_w = 15, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
{.bitmap_index = 5952, .adv_w = 240, .box_w = 16, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 6082, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 6056, .adv_w = 216, .box_w = 15, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
||||||
{.bitmap_index = 6148, .adv_w = 168, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 1},
|
{.bitmap_index = 6154, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 6187, .adv_w = 168, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 1},
|
{.bitmap_index = 6220, .adv_w = 168, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 1},
|
||||||
{.bitmap_index = 6226, .adv_w = 240, .box_w = 16, .box_h = 10, .ofs_x = -1, .ofs_y = 0},
|
{.bitmap_index = 6259, .adv_w = 168, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 1},
|
||||||
{.bitmap_index = 6306, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 6298, .adv_w = 240, .box_w = 16, .box_h = 10, .ofs_x = -1, .ofs_y = 0},
|
||||||
{.bitmap_index = 6360, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 6378, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 6438, .adv_w = 192, .box_w = 13, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
{.bitmap_index = 6432, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 6523, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 6510, .adv_w = 192, .box_w = 13, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
||||||
{.bitmap_index = 6584, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 6595, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 6656, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 6656, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 6717, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 6728, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 6778, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 6789, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 6832, .adv_w = 120, .box_w = 9, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
{.bitmap_index = 6850, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 6891, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 6904, .adv_w = 120, .box_w = 9, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
||||||
{.bitmap_index = 6963, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 6963, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 7035, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7035, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 7098, .adv_w = 192, .box_w = 14, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
{.bitmap_index = 7107, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7189, .adv_w = 144, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 7170, .adv_w = 192, .box_w = 14, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
||||||
{.bitmap_index = 7248, .adv_w = 240, .box_w = 15, .box_h = 12, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 7261, .adv_w = 144, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 7338, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7320, .adv_w = 240, .box_w = 15, .box_h = 12, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 7406, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7410, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7474, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7478, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7542, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7546, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7610, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7614, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7678, .adv_w = 240, .box_w = 16, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
{.bitmap_index = 7682, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 7766, .adv_w = 168, .box_w = 10, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 7750, .adv_w = 240, .box_w = 16, .box_h = 11, .ofs_x = 0, .ofs_y = -1},
|
||||||
{.bitmap_index = 7831, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 7838, .adv_w = 168, .box_w = 10, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 7903, .adv_w = 192, .box_w = 13, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
{.bitmap_index = 7903, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
{.bitmap_index = 7988, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
{.bitmap_index = 7975, .adv_w = 192, .box_w = 13, .box_h = 13, .ofs_x = -1, .ofs_y = -2},
|
||||||
{.bitmap_index = 8056, .adv_w = 144, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
{.bitmap_index = 8060, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0},
|
||||||
{.bitmap_index = 8115, .adv_w = 193, .box_w = 13, .box_h = 9, .ofs_x = 0, .ofs_y = 0}
|
{.bitmap_index = 8128, .adv_w = 144, .box_w = 9, .box_h = 13, .ofs_x = 0, .ofs_y = -2},
|
||||||
|
{.bitmap_index = 8187, .adv_w = 193, .box_w = 13, .box_h = 9, .ofs_x = 0, .ofs_y = 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*---------------------
|
/*---------------------
|
||||||
@ -1722,17 +1734,17 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
|
|||||||
|
|
||||||
static const uint16_t unicode_list_1[] = {
|
static const uint16_t unicode_list_1[] = {
|
||||||
0x0, 0x3c, 0x2a6, 0x435, 0x4b1, 0x4d7, 0x4f1, 0x8da,
|
0x0, 0x3c, 0x2a6, 0x435, 0x4b1, 0x4d7, 0x4f1, 0x8da,
|
||||||
0xd35, 0xf07, 0xf18, 0xf6f, 0xf86, 0x1349, 0x144e, 0x15ad,
|
0xd35, 0xf07, 0xf18, 0xf6f, 0xf86, 0x1349, 0x144e, 0x1485,
|
||||||
0x1616, 0x1650, 0x1699, 0x16d6, 0x180c, 0x18e7, 0x1c01, 0x1c43,
|
0x15ad, 0x1616, 0x1650, 0x1699, 0x16d6, 0x180c, 0x18e7, 0x1c01,
|
||||||
0x2aeb, 0x2f87, 0x32ca, 0x3ca6, 0x4073, 0x40bc, 0x40e1, 0x465f,
|
0x1c43, 0x2aeb, 0x2f87, 0x32ca, 0x3ca6, 0x4073, 0x40bc, 0x40e1,
|
||||||
0x46d4, 0x4bb8, 0xa0e1, 0xa0e8, 0xa0eb, 0xa0ec, 0xa0ed, 0xa0f1,
|
0x465f, 0x46d4, 0x4bb8, 0xa0e1, 0xa0e8, 0xa0eb, 0xa0ec, 0xa0ed,
|
||||||
0xa0f3, 0xa0f5, 0xa0f9, 0xa0fc, 0xa101, 0xa106, 0xa107, 0xa108,
|
0xa0f1, 0xa0f3, 0xa0f5, 0xa0f9, 0xa0fc, 0xa101, 0xa106, 0xa107,
|
||||||
0xa11e, 0xa123, 0xa128, 0xa12b, 0xa12c, 0xa12d, 0xa131, 0xa132,
|
0xa108, 0xa11e, 0xa123, 0xa128, 0xa12b, 0xa12c, 0xa12d, 0xa131,
|
||||||
0xa133, 0xa134, 0xa147, 0xa148, 0xa14e, 0xa150, 0xa151, 0xa154,
|
0xa132, 0xa133, 0xa134, 0xa147, 0xa148, 0xa14e, 0xa150, 0xa151,
|
||||||
0xa157, 0xa158, 0xa159, 0xa15b, 0xa173, 0xa175, 0xa1a4, 0xa1a5,
|
0xa154, 0xa157, 0xa158, 0xa159, 0xa15b, 0xa173, 0xa175, 0xa1a4,
|
||||||
0xa1a7, 0xa1a9, 0xa1c0, 0xa1c7, 0xa1ca, 0xa1d3, 0xa1fc, 0xa204,
|
0xa1a5, 0xa1a7, 0xa1a9, 0xa1c0, 0xa1c7, 0xa1ca, 0xa1d3, 0xa1fc,
|
||||||
0xa23b, 0xa2cb, 0xa320, 0xa321, 0xa322, 0xa323, 0xa324, 0xa367,
|
0xa204, 0xa23b, 0xa2cb, 0xa320, 0xa321, 0xa322, 0xa323, 0xa324,
|
||||||
0xa373, 0xa3cd, 0xa3e4, 0xa63a, 0xa8a2, 0xa982
|
0xa367, 0xa373, 0xa3cd, 0xa3e4, 0xa63a, 0xa8a2, 0xa982
|
||||||
};
|
};
|
||||||
|
|
||||||
/*Collect the unicode lists and glyph_id offsets*/
|
/*Collect the unicode lists and glyph_id offsets*/
|
||||||
@ -1744,7 +1756,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.range_start = 20256, .range_length = 43395, .glyph_id_start = 96,
|
.range_start = 20256, .range_length = 43395, .glyph_id_start = 96,
|
||||||
.unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 94, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
|
.unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 95, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -680,8 +680,8 @@ void setup_scr_screen_home(lv_ui *ui)
|
|||||||
lv_table_set_cell_value(ui->screen_home_table_1,1,0,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,1,0,"0");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,2,0,"1");
|
lv_table_set_cell_value(ui->screen_home_table_1,2,0,"1");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,0,1,"传输方向");
|
lv_table_set_cell_value(ui->screen_home_table_1,0,1,"传输方向");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,1,1,"$1");
|
lv_table_set_cell_value(ui->screen_home_table_1,1,1,"发送");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,2,1,"$2");
|
lv_table_set_cell_value(ui->screen_home_table_1,2,1,"接收");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,0,2,"时间标识");
|
lv_table_set_cell_value(ui->screen_home_table_1,0,2,"时间标识");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,1,2,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,1,2,"0");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,2,2,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,2,2,"0");
|
||||||
@ -692,8 +692,8 @@ void setup_scr_screen_home(lv_ui *ui)
|
|||||||
lv_table_set_cell_value(ui->screen_home_table_1,1,4,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,1,4,"0");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,2,4,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,2,4,"0");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,0,5,"数据");
|
lv_table_set_cell_value(ui->screen_home_table_1,0,5,"数据");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,1,5,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,1,5,"01 02 03 04 05 06 07 08");
|
||||||
lv_table_set_cell_value(ui->screen_home_table_1,2,5,"0");
|
lv_table_set_cell_value(ui->screen_home_table_1,2,5,"01 02 03 04 05 06 07 08");
|
||||||
lv_obj_set_pos(ui->screen_home_table_1, -16, 49);
|
lv_obj_set_pos(ui->screen_home_table_1, -16, 49);
|
||||||
lv_obj_set_scrollbar_mode(ui->screen_home_table_1, LV_SCROLLBAR_MODE_OFF);
|
lv_obj_set_scrollbar_mode(ui->screen_home_table_1, LV_SCROLLBAR_MODE_OFF);
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,13 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
#include <linux/can/raw.h>
|
#include <linux/can/raw.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
int sockfd_can0;
|
int sockfd_can0;
|
||||||
|
// 全局变量,用于线程间通信
|
||||||
|
static int can_sockfd = -1;
|
||||||
|
static pthread_t can_thread;
|
||||||
|
static volatile int can_thread_running = 1; // 线程运行标志
|
||||||
|
|
||||||
int socket_can_init(char* can_dev)
|
int socket_can_init(char* can_dev)
|
||||||
{
|
{
|
||||||
@ -57,6 +62,33 @@ int socket_can_send(int sockfd,uint32_t can_id,uint8_t data[8])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 CAN 套接字中读取数据
|
||||||
|
* @param sockfd CAN 套接字文件描述符
|
||||||
|
* @param data 存储接收到的 CAN 数据
|
||||||
|
* @return 成功返回读取的字节数,失败返回 -1
|
||||||
|
*/
|
||||||
|
int socket_can_receive(int sockfd, uint8_t *data) {
|
||||||
|
struct can_frame frame;
|
||||||
|
int nbytes;
|
||||||
|
|
||||||
|
// 读取 CAN 数据帧
|
||||||
|
nbytes = read(sockfd, &frame, sizeof(struct can_frame));
|
||||||
|
if (nbytes < 0) {
|
||||||
|
perror("Error reading from CAN socket");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查读取的字节数是否正确
|
||||||
|
if (nbytes != sizeof(struct can_frame)) {
|
||||||
|
fprintf(stderr, "Incomplete CAN frame read\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 CAN 数据帧的内容复制到输出缓冲区
|
||||||
|
memcpy(data, frame.data, frame.can_dlc); // frame.can_dlc 是数据长度
|
||||||
|
return frame.can_dlc; // 返回实际读取的数据长度
|
||||||
|
}
|
||||||
int socket_can_close(int sockfd)
|
int socket_can_close(int sockfd)
|
||||||
{
|
{
|
||||||
// 关闭套接字
|
// 关闭套接字
|
||||||
@ -65,6 +97,90 @@ int socket_can_close(int sockfd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/select.h> // 添加 select 头文件
|
||||||
|
|
||||||
|
void *can_receive_task(void *arg) {
|
||||||
|
int sockfd = *(int *)arg; // 从参数中获取 sockfd
|
||||||
|
struct can_frame frame;
|
||||||
|
fd_set read_fds;
|
||||||
|
|
||||||
|
while (can_thread_running) {
|
||||||
|
// 初始化 fd_set
|
||||||
|
FD_ZERO(&read_fds);
|
||||||
|
FD_SET(sockfd, &read_fds);
|
||||||
|
|
||||||
|
// 设置超时时间(100ms)
|
||||||
|
struct timeval timeout;
|
||||||
|
timeout.tv_sec = 0;
|
||||||
|
timeout.tv_usec = 100000;
|
||||||
|
|
||||||
|
// 等待 CAN 数据
|
||||||
|
int ret = select(sockfd + 1, &read_fds, NULL, NULL, &timeout);
|
||||||
|
if (ret < 0) {
|
||||||
|
perror("Error in select");
|
||||||
|
break;
|
||||||
|
} else if (ret == 0) {
|
||||||
|
// 超时,继续循环
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有数据可读
|
||||||
|
if (FD_ISSET(sockfd, &read_fds)) {
|
||||||
|
int nbytes = read(sockfd, &frame, sizeof(struct can_frame));
|
||||||
|
if (nbytes < 0) {
|
||||||
|
perror("Error reading from CAN socket");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查读取的字节数是否正确
|
||||||
|
if (nbytes != sizeof(struct can_frame)) {
|
||||||
|
fprintf(stderr, "Incomplete CAN frame read\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印接收到的 CAN 数据
|
||||||
|
printf("Received CAN frame: ID=0x%X, Data=", frame.can_id);
|
||||||
|
for (int i = 0; i < frame.can_dlc; i++) {
|
||||||
|
printf("%02X ", frame.data[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 线程退出
|
||||||
|
printf("CAN receive task stopped.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int start_can_receive_task(int sockfd) {
|
||||||
|
|
||||||
|
if(sockfd > 0)
|
||||||
|
{
|
||||||
|
can_thread_running = 1;
|
||||||
|
}
|
||||||
|
// 创建线程
|
||||||
|
if (pthread_create(&can_thread, NULL, can_receive_task, &sockfd) != 0) {
|
||||||
|
perror("Error creating CAN receive thread");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("CAN receive task started.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止 CAN 数据读取任务
|
||||||
|
*/
|
||||||
|
void stop_can_receive_task() {
|
||||||
|
// 设置线程运行标志为 0
|
||||||
|
can_thread_running = 0;
|
||||||
|
|
||||||
|
// 等待线程退出
|
||||||
|
pthread_join(can_thread, NULL);
|
||||||
|
printf("CAN receive task stopped.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int test() {
|
int test() {
|
||||||
int sockfd;
|
int sockfd;
|
||||||
struct sockaddr_can addr;
|
struct sockaddr_can addr;
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
extern int socket_can_init(char* can_dev);
|
extern int socket_can_init(char* can_dev);
|
||||||
extern int socket_can_send(int sockfd,uint32_t can_id,uint8_t data[8]);
|
extern int socket_can_send(int sockfd,uint32_t can_id,uint8_t data[8]);
|
||||||
extern int socket_can_close(int sockfd);
|
extern int socket_can_close(int sockfd);
|
||||||
|
extern int socket_can_receive(int sockfd, uint8_t *data);
|
||||||
|
extern int start_can_receive_task(int sockfd);
|
||||||
|
extern void stop_can_receive_task();
|
||||||
|
|
||||||
extern int sockfd_can0;
|
extern int sockfd_can0;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user