TL8772GWP芯片支持RGB模式LCD。用户不需要从头开始编写屏幕驱动程序,只需要几个简单的步骤就可以驱动LCD屏幕。RTL8772GWP的RGB信号是固定引脚,不能任意映射,只有一套,如下所示。在演示项目中,我们使用RGB888接口中的EK9716显示驱动程序,尺寸为 800 x 480 的面板作为目标显示,输入格式将使用RGB565,输出格式为RGB888。
└── Project: dashboard
└── app includes app main
├── menu_config.h
├── main.c
├── dashboard_init.c
├── flash_map.h
├── board.h
└── mem_config.h
└── Device includes startup code
├── startup_rtl.c
└── system_rtl.c
├── Lib includes all binary symbol files that user application is built on
├── Peripheral includes all peripheral drivers and module code used by the application
└── Profile includes BLE profiles or services used by the find my application
├── ancs_client.c
├── gatt_client.c
├── bas.c
├── dis.c
├── dfu_service.c
├── ota_service.c
└── tps.c tx power service
└── dfu includes the dashboard dfu application implementation
├── dfu_common.c
└── ble_dfu_transport.c
└── dfu_task includes the dashboard dfu task application implementation
├── dfu_main.c
├── dfu_task.c
└── dfu_app.c
├── rtk_gui includes all gui port
├── realgui/3rd includes Third-party library
├── realgui/app includes Realtek gui app
├── realgui/dc includes Realtek gui app
├── realgui/engine includes all gui engine
├── realgui/demo includes all gui demo
├── realgui/input includes all gui input
├── realgui/misc includes all gui misc
├── realgui/widget includes all gui widget
├── database includes all database
└── fs includes the file system
└── romfs.c
└── hal_drivers includes the dashboard hardware layer driver
├── drv_flash.c
├── drv_dlps.c
├── drv_lcd.c
└── drv_gpio.c
└── lcd_low_driver includes the dashboard hardware layer lcd driver
└── EK9716_800480_rgb.c
└── Compiler includes the dashboard compiler
├── syscall.c
└── syscall_mem.c
└── bt_app includes the dashboard bluetooth app
├── app_le_link_util.c
├── app_ble_bas.c
├── ancs.c
├── app_gap.c
├── app_task.c
├── his_ms.c
├── writband_private_service.c
├── app_ble_ota.c
├── app_ble_bwps.c
└── app_ble_dfu.c
├── communication includes all communication drivers and module code used by the application
└── findmy
voidapp_dashboard_create_main_display(gui_win_t*target_main_display){/* set update callback */gui_win_set_animate(target_main_display,1000,-1,paint_main_display_cb,target_main_display);/* set Image data */dashboard_background=gui_img_create_from_mem(target_main_display,"dashboard_background",BACKGROUND_BIN,0,0,800,480);speed_high_digital=gui_img_create_from_mem(target_main_display,"speed_high_digital",SPED0_BIN,360,202,40,60);speed_low_digital=gui_img_create_from_mem(target_main_display,"speed_low_digital",SPED0_BIN,406,202,40,60);bluetooth_status=gui_img_create_from_mem(target_main_display,"bluetooth_status",BTOF_BIN,48,10,23,30);left_turn_light_status=gui_img_create_from_mem(target_main_display,"left_turn_light_status",TL_OF_BIN,48,208,42,40);right_turn_light_status=gui_img_create_from_mem(target_main_display,"right_turn_light_status",TR_OF_BIN,710,208,42,40);hour_high_digital=gui_img_create_from_mem(target_main_display,"hour_high_digital",TIMER0_BIN,355,12,9,16);hour_low_digital=gui_img_create_from_mem(target_main_display,"hour_low_digital",TIMER0_BIN,366,12,9,16);min_high_digital=gui_img_create_from_mem(target_main_display,"min_high_digital",TIMER0_BIN,387,12,9,18);min_low_digital=gui_img_create_from_mem(target_main_display,"min_low_digital",TIMER0_BIN,399,12,9,18);tense_high_digital=gui_img_create_from_mem(target_main_display,"tense_high_digital",APM_A_BIN,417,12,9,18);tense_low_digital=gui_img_create_from_mem(target_main_display,"tense_low_digital",APM_M_BIN,432,12,9,18);bat_high_digital=gui_img_create_from_mem(target_main_display,"bat_high_digital",TIMER0_BIN,394,360,9,18);bat_low_digital=gui_img_create_from_mem(target_main_display,"bat_low_digital",TIMER0_BIN,406,360,9,18);tel_box=gui_img_create_from_mem(target_main_display,"tel_box",TELBOX_BIN,253,410,295,49);tel_accept=gui_img_create_from_mem(target_main_display,"tel_accept",TELBOX_BIN,253,410,295,49);tel_reject_end=gui_img_create_from_mem(target_main_display,"tel_reject_end",TELBOX_BIN,253,410,295,49);refuse_button=gui_img_create_from_mem(target_main_display,"refuse_button",REFUS_BIN,263,416,36,36);ans_button=gui_img_create_from_mem(target_main_display,"ans_button",ANS_BIN,500,416,36,36);tel_box_left_button=gui_img_create_from_mem(target_main_display,"tel_box_left_button",SYMB1_BIN,315,416,36,36);tel_box_right_button=gui_img_create_from_mem(target_main_display,"tel_box_right_button",SYMB2_BIN,479,416,36,36);dashboard_pointer=gui_img_create_from_mem(target_main_display,"dashboard_Cpointer",DASHBOARD_0_BIN,243,84,0,0);short_message=gui_img_create_from_mem(target_main_display,"short_message",MESSAGE_BIN,221,0,359,80);/* set font data */app_phone_datacurrent_phone_status;app_dashboard_data_get_phone_status(¤t_phone_status);short_tel_number=gui_text_create(target_main_display,"short_tel_number",322,415,158,30);memcpy(&show_tel_number[0],¤t_phone_status.current_phone_number[0],current_phone_status.current_phone_number_len);gui_text_set(short_tel_number,(char*)show_tel_number,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_phone_status.current_phone_number_len,28);gui_text_mode_set(short_tel_number,CENTER);short_tel_accept=gui_text_create(target_main_display,"short_tel_accept",360,415,800,30);gui_text_set(short_tel_accept,"calling",GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),7,32);app_message_datacurrent_message_status;app_dashboard_data_get_message_data_update(¤t_message_status);memcpy(&show_message_data[0],¤t_message_status.wechat_msg[0],current_message_status.wechat_msg_len);short_message_data=gui_text_create(target_main_display,"short_message_data",300,10,240,50);gui_text_set(short_message_data,(char*)show_message_data,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),(current_message_status.wechat_msg_len-1),32);gui_text_mode_set(short_message_data,MULTI_LEFT);/* Prepare the intial data */app_dashboard_update_main_display_time_info();app_dashboard_update_main_display_tense_apm_info(app_dashboard_data_get_tense_timer_info());app_dashboard_update_main_display_battery_info(app_dashboard_data_get_battery_level());app_dashboard_update_main_display_speed_info(app_dashboard_data_get_car_speed());app_dashboard_update_main_display_turn_info(app_dashboard_data_get_car_turn_info());app_dashboard_update_main_display_bluetooth_info(app_dashboard_data_get_bluetooth_status());app_dashboard_update_main_display_phone_infor(¤t_phone_status);app_dashboard_update_main_display_message_infor(¤t_message_status);}
BLE连接状态布局
voidapp_dashboard_create_connected_display(gui_win_t*target_connected_display){/* set update callback */gui_win_set_animate(target_connected_display,1000,-1,paint_connected_display_cb,target_connected_display);/* set Image data */dashboard_c_background=gui_img_create_from_mem(target_connected_display,"dashboard_c_background",BACKGROUND_C_BIN,0,0,800,480);speed_high_c_digital=gui_img_create_from_mem(target_connected_display,"speed_high_c_digital",SPED_C0_BIN,214,232,27,40);speed_low_c_digital=gui_img_create_from_mem(target_connected_display,"speed_low_c_digital",SPED_C0_BIN,251,232,27,40);hour_high_c_digital=gui_img_create_from_mem(target_connected_display,"hour_high_digital",TIMER0_BIN,355,12,9,16);hour_low_c_digital=gui_img_create_from_mem(target_connected_display,"hour_low_digital",TIMER0_BIN,366,12,9,16);min_high_c_digital=gui_img_create_from_mem(target_connected_display,"min_high_digital",TIMER0_BIN,387,12,9,18);min_low_c_digital=gui_img_create_from_mem(target_connected_display,"min_low_digital",TIMER0_BIN,399,12,9,18);tense_high_c_digital=gui_img_create_from_mem(target_connected_display,"tense_high_c_digital",APM_CA_BIN,417,12,9,18);tense_low_c_digital=gui_img_create_from_mem(target_connected_display,"tense_low_c_digital",APM_CM_BIN,432,12,9,18);bat_high_c_digital=gui_img_create_from_mem(target_connected_display,"bat_high_c_digital",TIMER0_BIN,238,371,9,18);bat_low_c_digital=gui_img_create_from_mem(target_connected_display,"bat_low_c_digital",TIMER0_BIN,250,371,9,18);left_turn_light_c_status=gui_img_create_from_mem(target_connected_display,"left_turn_light_c_status",TL_OF_C_BIN,110,10,42,40);right_turn_light_c_status=gui_img_create_from_mem(target_connected_display,"right_turn_light_c_status",TR_OF_C_BIN,665,10,42,40);navi_c_status=gui_img_create_from_mem(target_connected_display,"navi_c_status",NAVI_C1_BIN,505,170,268,218);refuse_c_button=gui_img_create_from_mem(target_connected_display,"refuse_c_button",REFUS_BIN,502,410,36,36);ans_c_button=gui_img_create_from_mem(target_connected_display,"ans_c_button",ANS_BIN,740,410,36,36);tel_box_left_c_button=gui_img_create_from_mem(target_connected_display,"tel_box_left_c_button",SYMB1_BIN,554,414,36,36);tel_box_right_c_button=gui_img_create_from_mem(target_connected_display,"tel_box_right_c_button",SYMB2_BIN,718,414,36,36);dashboard_Cpointer=gui_img_create_from_mem(target_connected_display,"dashboard_Cpointer",DASHBOARD_C2_BIN,110,133,9,18);short_c_message=gui_img_create_from_mem(target_connected_display,"short_c_message",MESSAGE_BIN,221,0,359,80);/* set font data */app_navi_datacurrent_navi_data;app_dashboard_data_get_navi_data_update(¤t_navi_data);memcpy(&show_c_navigation_msg[0],¤t_navi_data.navigation_msg[0],current_navi_data.navigation_num_len);short_c_navi_message_1=gui_text_create(target_connected_display,"short_c_navi_message_1",490,88,150,60);gui_text_set(short_c_navi_message_1,(char*)show_c_navigation_msg,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_navi_data.navigation_num_len,56);gui_text_mode_set(short_c_navi_message_1,RIGHT);memcpy(&show_c_navigation_unit[0],¤t_navi_data.navigation_unit[0],current_navi_data.navigation_unit_len);short_c_navi_message_3=gui_text_create(target_connected_display,"short_c_navi_message_3",640,108,150,40);gui_text_set(short_c_navi_message_3,(char*)show_c_navigation_unit,GUI_FONT_SRC_BMP,gui_rgb(0xcc,0xcc,0xcc),current_navi_data.navigation_unit_len,32);gui_text_mode_set(short_c_navi_message_3,LEFT);memcpy(&show_c_road_names[0],¤t_navi_data.road_names[0],current_navi_data.road_num_len);short_c_navi_message_2=gui_text_create(target_connected_display,"short_c_navi_message_2",490,148,300,40);gui_text_set(short_c_navi_message_2,(char*)show_c_road_names,GUI_FONT_SRC_BMP,gui_rgb(0xcc,0xcc,0xcc),current_navi_data.road_num_len,32);gui_text_mode_set(short_c_navi_message_2,CENTER);app_phone_datacurrent_phone_status;app_dashboard_data_get_phone_status(¤t_phone_status);short_c_tel_number=gui_text_create(target_connected_display,"short_c_tel_number",560,410,158,30);memcpy(&show_c_tel_number[0],¤t_phone_status.current_phone_number[0],current_phone_status.current_phone_number_len);gui_text_set(short_c_tel_number,(char*)show_c_tel_number,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),current_phone_status.current_phone_number_len,28);gui_text_mode_set(short_c_tel_number,CENTER);short_c_tel_accept=gui_text_create(target_connected_display,"short_c_tel_accept",600,410,800,30);gui_text_set(short_c_tel_accept,"calling",GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),7,28);app_message_datacurrent_message_status;app_dashboard_data_get_message_data_update(¤t_message_status);memcpy(&show_c_message_data[0],¤t_message_status.wechat_msg[0],current_message_status.wechat_msg_len);short_c_message_data=gui_text_create(target_connected_display,"short_c_message_data",300,10,240,50);gui_text_set(short_c_message_data,(char*)show_c_message_data,GUI_FONT_SRC_BMP,gui_rgb(UINT8_MAX,UINT8_MAX,UINT8_MAX),(current_message_status.wechat_msg_len-1),32);gui_text_mode_set(short_c_message_data,MULTI_LEFT);/* Prepare the intial data */app_dashboard_update_connected_display_time_info();app_dashboard_update_connected_display_tense_apm_info(app_dashboard_data_get_tense_timer_info());app_dashboard_update_connected_display_battery_info(app_dashboard_data_get_battery_level());app_dashboard_update_connected_display_speed_info(app_dashboard_data_get_car_speed());app_dashboard_update_connected_display_turn_info(app_dashboard_data_get_car_turn_info());app_dashboard_update_connected_display_phone_infor(¤t_phone_status);app_dashboard_update_connected_display_message_infor(¤t_message_status);}
通信任务负责BLE数据传输的管理,根据当前传输数据命令格式将数据打包并通过蓝牙协议栈发送出去。 客户一般使用自己的蓝牙数据交互格式,任务可以作为发送方法的参考,也可以自己实现。开发者必须参考 Bluetooth,熟悉BLE服务结构以及如何处理消息。在本设计文档中,我们将通过仪表板应用程序的指定 BLE 服务作为演示。开发人员可以根据自己的产品需求选择手机应用程序采用哪些 BLE 服务。
移动应用程序成功连接到仪表板设备后,应用程序可以使用 BLE 写入请求向设备传送必要的信息,所有消息都将通过特征写入。
/** * @brief write characteristic data from stack. ** @param ServiceId ServiceId generated when register to upper stack.* @param iAttribIndex Attribute index of getting characteristic data.* @param wLength length of data to be written.* @param pValue pointer of data to be written.* @return TProfileResult profile procedure results. */T_APP_RESULTbwps_service_attr_write_cb(uint8_tconn_id,T_SERVER_IDservice_id,uint16_tattrib_index,T_WRITE_TYPEwrite_type,uint16_tlength,uint8_t*p_value,P_FUN_WRITE_IND_POST_PROC*p_write_ind_post_proc){T_APP_RESULTwCause=APP_RESULT_SUCCESS;uint8_t*buf=NULL;APP_PRINT_INFO2("bwps_service_attr_write_cb: attrib_index = %d, data %b",attrib_index,CE_BINARY(length,p_value));if(p_value==NULL){APP_PRINT_ERROR0("bwps_service_attr_write_cb, p_value is NULL");wCause=APP_RESULT_INVALID_VALUE_SIZE;returnwCause;}switch(attrib_index){default:wCause=APP_RESULT_ATTR_NOT_FOUND;APP_PRINT_ERROR2("bwps_service_attr_write_cb Error: attrib_index 0x%x, length %d",attrib_index,length);break;caseGATT_SRV_BWPS_TX_INDEX:APP_PRINT_INFO0("bwps_service_attr_write_cb, GATT_SRV_BWPS_TX_INDEX");/* copy gatt write value in tx_buffer, the first byte is value length*/#if 1buf=malloc((length+1)*sizeof(uint8_t));buf[0]=length;memcpy(buf+1,p_value,length);externvoid*raw_data_receive_queue_handle;if(os_msg_send(raw_data_receive_queue_handle,&buf,0)==false){APP_PRINT_ERROR0("send_msg_to_l1send_task_fail");free(buf);}#endifbreak;caseGATT_SRV_BWPS_DEVNAME_INDEX:APP_PRINT_INFO0("BWPS: update device name\n");break;}returnwCause;}
/** * @brief canSend task to send CANFestival messages. * @param p_param: Parameters sending to the task * @return void */voidcanSend_Task(void*p_param){staticCAN_TxMsgDefCO_TxMsg;#if CAN_RX_FIFO_ENuint8_tTxMsgBuf_MaxCnt=12;//when Rx_FIFO enable, only index_0~11 MBs can be used for Tx.#elseuint8_tTxMsgBuf_MaxCnt=16;#endifwhile(true){/*wait for CANOpen tx message*/if(!loop_queue_is_empty(p_canSend_queue)){if(true==loop_queue_read_buf(p_canSend_queue,&CO_TxMsg,sizeof(CAN_TxMsgDef))){for(uint8_tTxMsgBufId=0;TxMsgBufId<CAN_MESSAGE_BUFFER_MAX_CNT;TxMsgBufId++){/* if the MB is idle, then it can send the data. */FlagStatusTx_req=CAN_GetMBnStatusTxReqFlag(TxMsgBufId);FlagStatusRx_vld=CAN_GetMBnStatusRxValidFlag(TxMsgBufId);FlagStatusRx_rdy=CAN_GetMBnStatusRxReadyFlag(TxMsgBufId);if((Tx_req==RESET)&&(Rx_vld==RESET)&&(Rx_rdy==RESET)){CO_TxMsg.CO_TxFrame.msg_buf_id=TxMsgBufId;CANError_TypeDeftx_error=CAN_SetMsgBufTxMode(&CO_TxMsg.CO_TxFrame,CO_TxMsg.data,CO_TxMsg.dlc);CAN_MBTxINTConfig(CO_TxMsg.CO_TxFrame.msg_buf_id,ENABLE);break;}}}}}}