Notes: The 10.1-inch LCD screen for the car dashboard and the STONE LCD screen combined with RTL8762CJF MCU are used to develop and make an onboard display dashboard.
Introduction
In the process of daily use of the car, we need to always understand the state of the car, to avoid damage to the important parts of the car, but also to eliminate potential dangers. Often, the information displayed on the dashboard is a way to know the state of the vehicle.
This time I’m going to use a 10.1-inch TFT LCD screen to make an onboard display dashboard. As we all know, the development of STONE intelligent TFT LCD module display is convenient and quick, without too many tedious instructions. This is not only suitable for the majority of learning enthusiasts, but in the actual project can speed up the development, save development time, quickly occupy the market.
I use the more commonly used RTL8762CJF SCM to develop, through IIC or serial port to achieve the purpose of uploading data to the TFT LCD screen. This time will also use the voice broadcast function, to give the driver a better simulation experience.
LCD screen car dashboard Project function
Here we need to do a used car display project, the project mainly through touch regulation, microcontroller upload instructions manner, simulation with buttons, when MCU button press, through a serial port command to STVC101WT – 01 serial interface screen instructions to upload data, the screen will automatically data parsing, and displayed in the LCD screen. At the same time, there is also a button function on the screen to achieve the serial port instruction, so as to control the MCU.
In summary, five functions
- The serial port screen realizes the bitmap display function;
- to achieve the dial rotation function;
- to achieve the touch command issued;
- to achieve voice broadcasting;
- to achieve data instruction upload.
The function is determined, and then the module selection:
- Model of the touch screen;
- what kind of MCU module to use;
- voice broadcast module.
Hardware introduction and principle
The horn
Because the STONE serial port screen comes with an Audio driver and reserved the corresponding interface, so you can use the most common magnet loudspeaker, commonly known as horn. The loudspeaker is a kind of transducer that converts electrical signals into sound signals. The loudspeaker is one of the weakest components in sound equipment and one of the most important components for sound effects. There are many kinds of loudspeakers and the prices vary greatly. Audio electrical energy produces sound by making its paper basin or diaphragm vibrate and resonate (resonate) with the surrounding air through an electromagnetic, piezoelectric, or electrostatic effect.
Purchase link: http://dwz.date/afdC
STVC101WT-01 serial LCD screen description
- 10.1-inch 1024×600 industrial-grade TFT panel and 4-wire resistive touch screen;
- Brightness 300cd/m2;
- LED backlight;
- RGB color 65 k;
- The visible area is 222.7mm * 125.3mm;
- Visual Angle 70/70/50/60;
- Working life 20,000 hours.
- 32-bit cortex-m4 200Hz CPU;
- CPLD EPM240 tft-lcd controller;
- 128MB (or 1GB) of flash memory;
- USB port (U disk) download;
- Toolbox software for GUI design;
- Simple and powerful hexadecimal instruction.
The basic function
- 8m-128m bytes Flash memory space, SDWe series 128M bytes, SDWa series 8M/16M bytes;
- Support hardware JPG decoding, storage more efficient, faster display;
- Support U disk offline batch download, effectively improve the efficiency of batch download, reduce the professional quality requirements of operators;
- 256-byte register space;
- 64K word (128K bytes) variable memory space, 8 channel curve storage, very fast (80ms) variable display
- Response speed;
- Support up to 128 display variables per page;
- Integrated real-time clock RTC, touch buzzer sound function;
- Support software 90 degrees, 180 degrees, 270-degree screen rotation, adjust the appropriate visual Angle;
- Support backlight brightness adjustment, auto standby screensaver function;
- Support external matrix keyboard;
- Support audio and video playback;
- Industry-leading electromagnetic radiation index, help you easily deal with ClassB;
- The file name naming rule is simple, without corresponding to the Flash block number, also without tedious manual allocation Flash block Function;
- Support virtual serial screen function.
STONE STVC101WT – 01 display module is via a serial port communication with MCU, need to use it in this project, we need only through the PC to design good UI images through the menu bar options button, text box, background images, and logical page to add, then generate configuration files, download to the display screen can be run at last.
RTL8762C EVB Introduction
8762C evaluation board provides the hardware environment developed by the customer, including:
- Power conversion module;
- 26-axis motion sensor;
- 4 LEDs and 6 buttons;
- Button battery and lithium battery holder;
- USB to UART conversion chip, FT232RL.
Evaluate board block and interface distribution
A detailed description of the evaluation board block
Evaluation board block and interface distribution, see the following figure:
The keys
There are a total of reset keys and 5 sets of independent keys,
as shown in the following figure:
The main chip 8762 c
- Flexible GPIO design
- Hardware Keyscan and decoder
- Embedded IR transceiver
- Real-time counter (RTC)
- SPI master/from x two;Timer x 8;I2C x 2;PWM x 8;UART x 2
- 400ksps, 12bit, 8-channel AUXADC
- I2S interface for external audio codecs
- I8080 interface for LCD
- Internal 32K RCOSC keeps BLE links
- Embedded PGA and audio ADC with 5 band equalizer
STONE TOOL Box Development steps
In general, there are only three steps:
- using TOOL2019 upper computer software design;
- MCU and screen communication development;
- audio file production and import.
Installation of STONE TOOL
The TOOL can be downloaded on the website https://www.stone-hmi.com/, as well as relevant USB serial driver.
The installation of the KEIL
1、Download link: https://pan.baidu.com/s/1smropvXeXKXw413W_-rvtw
2、Download after decompression
Open the folder after unzipping
4、Double-click the file c51v900. exe, and click Next in the dialog box.
STONE TOOL 2019 interface design
Using the installed TOOL 2019, click the new project in the upper left corner, and then click OK.
A default project is generated with a blue background by default. Select it, right-click, and select remove to remove the background. Next, right-click picture file and click add to add your own picture background, as:
follows:
Select the corresponding background image.
In the same way, we add bitmap files and audio files to the project.
Then add the required controls, here is mainly the button control, numeric add and subtract control, data variable control.
Then configure the variable address of each control, here we have the following configuration:
- The air conditioning button address is configured as 0x000C;
- High beam button address is configured as 0x000D;
- speed dial address is configured as 0x001B;
- electricity icon address is configured as 0x0018;
- the PM2.5 address is configured as 0x001C;
When the button is configured, the following figure shows once:
- the configuration button press effect;
- configure the control of the variable address, used to write its value;
- configuration plus or minus operations;
- configure the value range.
When configuring the digital text box, the following figure is shown in turn:
set the control variable address;
set the number of digits;
set the size of the number;
set the number of the alignment.
When configuring the speedometer, the following figure shows in turn:
Selected library file;
Which file to specify in the gallery file;
Set the center coordinates around the pointer icon;
Set the rotation range of the pointer.
Set the rotation angle of the pointer.
Finally, we click on the build configuration tool.
Note:
Control buttons are associated with their corresponding bitmaps via variable addresses, so consistency is required to achieve proper control.
Therefore, the serial port instruction is as follows:
Battery: 0xA5, 0x5A, 0x05, 0x82, 0x00, 0x18, 0x00, 0x00
Speed: 0xA5, 0x5A, 0x05, 0x82, 0x00, 0x1B, 0x00, 0x00
PM2.5: 0xA5, 0x5A, 0x05, 0x82, 0x00, 0x1C, 0x00, 0x00
The development of RTL8762C
Open KEIL and import our project file, as shown in the following figure:
Since it is the first time to use, the FLASH algorithm needs to be adjusted accordingly:
Click the options button to go to the Flash Download configuration box and change the algorithm to look like the following figure.
Since the button control is used here, the following changes need to be made in the code:
/**
* @file main.c
* @brief uart demo polling tx and rx.
* @details
* @author wangzex
* @date 2018-06-28
* @version v0.1
*********************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include
#include "rtl876x_nvic.h"
#include "rtl876x_pinmux.h"
#include "rtl876x_rcc.h"
#include "rtl876x_uart.h"
#include "trace.h"
#include "rtl876x_gpio.h"
#include "os_timer.h"
#include "os_sched.h"
/* Defines ------------------------------------------------------------------*/
#define UART_TX_PIN P0_0//P4_0
#define UART_RX_PIN P0_1//P4_1
/* Defines ------------------------------------------------------------------*/
#define GPIO_INPUT_PIN_BAT_UP P4_0// KEY0
#define GPIO_BAT_UP_INPUT GPIO_GetPin(GPIO_INPUT_PIN_BAT_UP)
#define GPIO_INPUT_PIN_BAT_DN P4_1// KEY1
#define GPIO_BAT_DN_INPUT GPIO_GetPin(GPIO_INPUT_PIN_BAT_DN)
#define GPIO_INPUT_PIN_SPEED_UP P2_4//KEY2
#define GPIO_SPEED_UP_INPUT GPIO_GetPin(GPIO_INPUT_PIN_SPEED_UP)
#define GPIO_INPUT_PIN_SPEED_DN P2_3// KEY3
#define GPIO_SPEED_DN_INPUT GPIO_GetPin(GPIO_INPUT_PIN_SPEED_DN)
#define GPIO_INPUT_PIN_SWITCH P0_5//KEY4
#define GPIO_SWITCH_INPUT GPIO_GetPin(GPIO_INPUT_PIN_SWITCH)
#define KEYSCAN_SW_INTERVAL (165)/* 200ms */
#define KEYSCAN_SW_RELEASE_TIMEOUT (10)/* 10ms */
uint8_t data_buf_bat[] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x18, 0x00, 0x00};
uint8_t data_buf_speed[] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x1B, 0x00, 0x00};
uint8_t data_buf_pm25[] = {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x1C, 0x00, 0x00};//the last byte is data
void *KeyScan_Timer_Handle = NULL;
void timer_keyscan_callback(void *p_xTimer)
{
uint8_t gpio_input_data_level = 0;
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_BAT_UP_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_SWITCH_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
data_buf_pm25[7] ++;
UART_SendData(UART, data_buf_pm25, 8);
}
else
{
data_buf_bat[7] ++;
UART_SendData(UART, data_buf_bat, 8);
}
}
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_BAT_DN_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_SWITCH_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
data_buf_pm25[7] --;
UART_SendData(UART, data_buf_pm25, 8);
}
else
{
data_buf_bat[7] --;
UART_SendData(UART, data_buf_bat, 8);
}
}
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_SPEED_UP_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
data_buf_speed[7] ++;
UART_SendData(UART, data_buf_speed, 8);
}
gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_SPEED_DN_INPUT);//KEY0
DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
if(!gpio_input_data_level)
{
data_buf_speed[7] --;
UART_SendData(UART, data_buf_speed, 8);
}
// gpio_input_data_level = GPIO_ReadInputDataBit(GPIO_PM25_INPUT);//KEY0
// DBG_DIRECT("GPIO_BAT_UP_INPUT = %d\n", gpio_input_data_level);
// if(!gpio_input_data_level)
// {
// data_buf_pm25[7] --;
// UART_SendData(UART, data_buf_pm25, 8);
// }
os_timer_restart(&KeyScan_Timer_Handle, KEYSCAN_SW_INTERVAL);
}
void timer_keyscan_init(void)
{
DBG_DIRECT("[io_keyscan] timer_keyscan_init: keyscan timer init");
if (false == os_timer_create(&KeyScan_Timer_Handle, "keyscan_timer", 1, \
KEYSCAN_SW_INTERVAL, false, timer_keyscan_callback))
{
DBG_DIRECT("[io_keyscan] timer_keyscan_init: timer creat failed!");
}
os_timer_start(&KeyScan_Timer_Handle);
}
/** @brief UART_BaudRate_Table
* div ovsr ovsr_adj :These three parameters set the baud rate calibration parameters of UART.
baudrate | div | ovsr | ovsr_adj
--------------------------------------------------------
1200Hz | 2589 | 7 | 0x7F7
9600Hz | 271 | 10 | 0x24A
14400Hz | 271 | 5 | 0x222
19200Hz | 165 | 7 | 0x5AD
28800Hz | 110 | 7 | 0x5AD
38400Hz | 85 | 7 | 0x222
57600Hz | 55 | 7 | 0x5AD
76800Hz | 35 | 9 | 0x7EF
115200Hz | 20 | 12 | 0x252
128000Hz | 25 | 7 | 0x555
153600Hz | 15 | 12 | 0x252
230400Hz | 10 | 12 | 0x252
460800Hz | 5 | 12 | 0x252
500000Hz | 8 | 5 | 0
921600Hz | 4 | 5 | 0x3F7
1000000Hz | 4 | 5 | 0
1382400Hz | 2 | 9 | 0x2AA
1444400Hz | 2 | 8 | 0x5F7
1500000Hz | 2 | 8 | 0x492
1843200Hz | 2 | 5 | 0x3F7
2000000Hz | 2 | 5 | 0
2100000Hz | 1 | 14 | 0x400
2764800Hz | 1 | 9 | 0x2AA
3000000Hz | 1 | 8 | 0x492
3250000Hz | 1 | 7 | 0x112
3692300Hz | 1 | 5 | 0x5F7
3750000Hz | 1 | 5 | 0x36D
4000000Hz | 1 | 5 | 0
6000000Hz | 1 | 1 | 0x36D
-----------------------------------------------------
*/ /* End of UART_BaudRate_Table */
/* Globals ------------------------------------------------------------------*/
typedef struct
{
uint16_t div;
uint16_t ovsr;
uint16_t ovsr_adj;
} UART_BaudRate_TypeDef;
const UART_BaudRate_TypeDef BaudRate_Table[10] =
{
{271, 10, 0x24A}, // BAUD_RATE_9600
{165, 7, 0x5AD}, // BAUD_RATE_19200
{20, 12, 0x252}, // BAUD_RATE_115200
{10, 12, 0x252}, // BAUD_RATE_230400
{5, 12, 0x252}, // BAUD_RATE_460800
{4, 5, 0x3F7}, // BAUD_RATE_921600
{2, 5, 0}, // BAUD_RATE_2000000
{1, 8, 0x492}, // BAUD_RATE_3000000
{1, 5, 0}, // BAUD_RATE_4000000
{1, 1, 0x36D}, // BAUD_RATE_6000000
};
void board_gpio_init(void)
{
Pad_Config(GPIO_INPUT_PIN_BAT_UP, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(GPIO_INPUT_PIN_BAT_UP, DWGPIO);
Pad_Config(GPIO_INPUT_PIN_BAT_DN, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(GPIO_INPUT_PIN_BAT_DN, DWGPIO);
Pad_Config(GPIO_INPUT_PIN_SPEED_UP, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(GPIO_INPUT_PIN_SPEED_UP, DWGPIO);
Pad_Config(GPIO_INPUT_PIN_SPEED_DN, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(GPIO_INPUT_PIN_SPEED_DN, DWGPIO);
Pad_Config(GPIO_INPUT_PIN_SWITCH, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE,
PAD_OUT_HIGH);
Pinmux_Config(GPIO_INPUT_PIN_SWITCH, DWGPIO);
}
uint8_t String_Buf[100];
/**
* @brief Initialization of pinmux settings and pad settings.
* @param No parameter.
* @return void
*/
void board_uart_init(void)
{
Pad_Config(UART_TX_PIN, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE, PAD_OUT_HIGH);
Pad_Config(UART_RX_PIN, PAD_PINMUX_MODE, PAD_IS_PWRON, PAD_PULL_UP, PAD_OUT_DISABLE, PAD_OUT_HIGH);
Pinmux_Config(UART_TX_PIN, UART0_TX);
Pinmux_Config(UART_RX_PIN, UART0_RX);
}
/**
* @brief Initialize GPIO peripheral.
* @param No parameter.
* @return void
*/
void driver_gpio_init(void)
{
/* Initialize GPIO peripheral */
RCC_PeriphClockCmd(APBPeriph_GPIO, APBPeriph_GPIO_CLOCK, ENABLE);
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_StructInit(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PIN_BAT_UP;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_ITCmd = DISABLE;
GPIO_Init(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PIN_BAT_DN;
GPIO_Init(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PIN_SPEED_UP;
GPIO_Init(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PIN_SPEED_DN;
GPIO_Init(&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Pin = GPIO_INPUT_PIN_SWITCH;
GPIO_Init(&GPIO_InitStruct);
}
/**
* @brief Demo code of operation about gpio.
* @param No parameter.
* @return void
*/
void gpio_demo(void)
{
/* Configure pad and pinmux firstly! */
board_gpio_init();
/* Initialize gpio peripheral */
driver_gpio_init();
}
/**
* @brief Initialize uart peripheral.
* @param No parameter.
* @return void
*/
void driver_uart_init(void)
{
UART_DeInit(UART);
RCC_PeriphClockCmd(APBPeriph_UART0, APBPeriph_UART0_CLOCK, ENABLE);
/* uart init */
UART_InitTypeDef UART_InitStruct;
UART_StructInit(&UART_InitStruct);
/* Config uart baudrate */
UART_InitStruct.div = BaudRate_Table[BAUD_RATE_115200].div;
UART_InitStruct.ovsr = BaudRate_Table[BAUD_RATE_115200].ovsr;
UART_InitStruct.ovsr_adj = BaudRate_Table[BAUD_RATE_115200].ovsr_adj;
UART_InitStruct.parity = UART_PARITY_NO_PARTY;
UART_InitStruct.stopBits = UART_STOP_BITS_1;
UART_InitStruct.wordLen = UART_WROD_LENGTH_8BIT;
UART_InitStruct.rxTriggerLevel = 16; //1~29
UART_InitStruct.idle_time = UART_RX_IDLE_2BYTE; //idle interrupt wait time
UART_Init(UART, &UART_InitStruct);
}
/**
* @brief UARt send data continuous.
* @param No parameter.
* @return void
*/
void uart_senddata_continuous(UART_TypeDef *UARTx, const uint8_t *pSend_Buf, uint16_t vCount)
{
uint8_t count;
while (vCount / UART_TX_FIFO_SIZE > 0)
{
while (UART_GetFlagState(UARTx, UART_FLAG_THR_EMPTY) == 0);
for (count = UART_TX_FIFO_SIZE; count > 0; count--)
{
UARTx->RB_THR = *pSend_Buf++;
}
vCount -= UART_TX_FIFO_SIZE;
}
while (UART_GetFlagState(UARTx, UART_FLAG_THR_EMPTY) == 0);
while (vCount--)
{
UARTx->RB_THR = *pSend_Buf++;
}
}
/**
* @brief Demo code of uart.
* @param No parameter.
* @return void
*/
void uart_demo(void)
{
uint16_t demo_str_len = 0;
// uint8_t rx_byte = 0;
board_uart_init();
driver_uart_init();
char *demo_str = "### Uart demo polling read uart data ###\r\n";
demo_str_len = strlen(demo_str);
memcpy(String_Buf, demo_str, demo_str_len);
/* Send demo tips */
uart_senddata_continuous(UART, String_Buf, demo_str_len);
/* Loop rx and tx */
// while (1)
// {
// if (UART_GetFlagState(UART, UART_FLAG_RX_DATA_RDY) == SET)
// {
// rx_byte = UART_ReceiveByte(UART);
// UART_SendByte(UART, rx_byte);
// }
// }
}
/**
* @brief Entry of app code
* @return int (To avoid compile warning)
*/
int main(void)
{
uart_demo();
gpio_demo();
timer_keyscan_init();
os_sched_start();
return 0;
}
Finally, just connect the MCU to the serial port LCD screen LCD for the car dashboard
and connect the speaker to demonstrate.