Merge pull request #50 from acevest/longan_nano_lcd
add LCD driver for longan nano
This commit is contained in:
552
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcd.c
Normal file
552
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcd.c
Normal file
@@ -0,0 +1,552 @@
|
|||||||
|
#include "lcd.h"
|
||||||
|
#include "lcdfont.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
||||
|
||||||
|
|------|
|
||||||
|
+==============+
|
||||||
|
| |
|
||||||
|
| 0.96 inch |
|
||||||
|
| |
|
||||||
|
| IPS RGB LCD |
|
||||||
|
| |
|
||||||
|
| 80 x 160 |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
+==============+
|
||||||
|
|
||||||
|
这个屏是80x160,但它的显存是132x162
|
||||||
|
所以它的四点的坐标分别是
|
||||||
|
|
||||||
|
(26, 1)----80----(106, 1)
|
||||||
|
| |
|
||||||
|
160 160
|
||||||
|
| |
|
||||||
|
(26, 161)----80----(106, 1611)
|
||||||
|
|
||||||
|
|
||||||
|
接下来按上图说明它的度坐标系统,默认情况
|
||||||
|
|
||||||
|
x
|
||||||
|
+------> 80
|
||||||
|
|
|
||||||
|
y |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
v
|
||||||
|
160
|
||||||
|
|
||||||
|
|
||||||
|
如果只想交互x,y坐标轴,则只需要在0x36写入的MV==1
|
||||||
|
|
||||||
|
y
|
||||||
|
+------> 80
|
||||||
|
|
|
||||||
|
x |
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
v
|
||||||
|
160
|
||||||
|
|
||||||
|
但此时看到的画面是反的,即对于正常画面关于x=y轴镜像的画面
|
||||||
|
|
||||||
|
因此,想扯到正常的两面,在交换坐标轴(MV=1)的同时,要么做 x 轴镜像,要么做 y 轴镜像
|
||||||
|
|
||||||
|
即0x36写入 MY=0 MX=1 MV=1
|
||||||
|
或0x36写入 MY=1 MX=0 MV=1
|
||||||
|
|
||||||
|
1. 关于x轴镜像,MV=1 MX=1
|
||||||
|
y
|
||||||
|
80 <------+
|
||||||
|
|
|
||||||
|
| x
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
V
|
||||||
|
160
|
||||||
|
|
||||||
|
2. 关于y轴镜像,MV=1 MY=1
|
||||||
|
|
||||||
|
160
|
||||||
|
^
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
x |
|
||||||
|
|
|
||||||
|
+------> 80
|
||||||
|
y
|
||||||
|
|
||||||
|
|
||||||
|
最后综上所述,此屏的(0, 0)对准显存的点是(26, 1),因此
|
||||||
|
竖屏显示的时候,所有坐标点(x, y) 要变换成 (x+26, y+1)
|
||||||
|
横屏显示的时候,所有坐标点(x, y) 要变换成 (x+1, y+26)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t BACK_COLOR; //背景色
|
||||||
|
uint8_t max_width = 0;
|
||||||
|
uint8_t max_height= 0;
|
||||||
|
lcd_display_mode_t display_mode = LCD_DISPMODE_VERTICAL;
|
||||||
|
|
||||||
|
void LCD_Writ_Bus(uint8_t dat)
|
||||||
|
{
|
||||||
|
#if USE_HARDWARE_SPI
|
||||||
|
LCD_CS_Clr();
|
||||||
|
|
||||||
|
while(RESET == spi_i2s_flag_get(SPI0, SPI_FLAG_TBE));
|
||||||
|
spi_i2s_data_transmit(SPI0, dat);
|
||||||
|
while(RESET == spi_i2s_flag_get(SPI0, SPI_FLAG_RBNE));
|
||||||
|
spi_i2s_data_receive(SPI0);
|
||||||
|
|
||||||
|
LCD_CS_Set();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_HARDWARE_DMA_SPI
|
||||||
|
spi_dma_enable(SPI0, SPI_DMA_TRANSMIT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_SOFTWARE_SPI
|
||||||
|
uint8_t i;
|
||||||
|
LCD_CS_Clr();
|
||||||
|
for(i=0;i<8;i++)
|
||||||
|
{
|
||||||
|
LCD_SCLK_Clr();
|
||||||
|
if(dat&0x80)
|
||||||
|
LCD_SDIN_Set();
|
||||||
|
else
|
||||||
|
LCD_SDIN_Clr();
|
||||||
|
LCD_SCLK_Set();
|
||||||
|
dat<<=1;
|
||||||
|
}
|
||||||
|
LCD_CS_Set();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_WR_DATA8(uint8_t dat)
|
||||||
|
{
|
||||||
|
LCD_DC_Set();
|
||||||
|
LCD_Writ_Bus(dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_WR_DATA(uint16_t dat)
|
||||||
|
{
|
||||||
|
LCD_DC_Set();
|
||||||
|
LCD_Writ_Bus(dat>>8);
|
||||||
|
LCD_Writ_Bus(dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_WR_REG(uint8_t dat)
|
||||||
|
{
|
||||||
|
LCD_DC_Clr();
|
||||||
|
LCD_Writ_Bus(dat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_Address_Set(uint16_t x,uint16_t y,uint16_t width,uint16_t height)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
LCD_WR_REG(0x2a);//列地址设置
|
||||||
|
LCD_WR_DATA(1+x);
|
||||||
|
LCD_WR_DATA(1+x+width-1);
|
||||||
|
LCD_WR_REG(0x2b);//行地址设置
|
||||||
|
LCD_WR_DATA(26+y);
|
||||||
|
LCD_WR_DATA(26+y+height-1);
|
||||||
|
LCD_WR_REG(0x2c);//储存器写
|
||||||
|
|
||||||
|
return ;
|
||||||
|
#endif
|
||||||
|
if(width == 0 || height == 0) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(display_mode == LCD_DISPMODE_HORIZONTAL
|
||||||
|
|| display_mode == LCD_DISPMODE_HORIZONTAL_MIRROR) {
|
||||||
|
x += 1;
|
||||||
|
y += 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(display_mode == LCD_DISPMODE_VERTICAL
|
||||||
|
|| display_mode == LCD_DISPMODE_VERTICAL_MIRROR) {
|
||||||
|
x += 26;
|
||||||
|
y += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// column
|
||||||
|
LCD_WR_REG(0x2a);
|
||||||
|
LCD_WR_DATA(x);
|
||||||
|
LCD_WR_DATA(x+width-1);
|
||||||
|
|
||||||
|
// row
|
||||||
|
LCD_WR_REG(0x2b);
|
||||||
|
LCD_WR_DATA(y);
|
||||||
|
LCD_WR_DATA(y+height-1);
|
||||||
|
|
||||||
|
// store
|
||||||
|
LCD_WR_REG(0x2c);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USE_HARDWARE_DMA_SPI
|
||||||
|
void dma_config(void)
|
||||||
|
{
|
||||||
|
dma_parameter_struct dma_init_struct;
|
||||||
|
|
||||||
|
/* SPI0 transmit dma config:DMA0,DMA_CH2 */
|
||||||
|
dma_deinit(DMA0, DMA_CH2);
|
||||||
|
dma_struct_para_init(&dma_init_struct);
|
||||||
|
|
||||||
|
dma_init_struct.periph_addr = (uint32_t)&SPI_DATA(SPI0);
|
||||||
|
dma_init_struct.memory_addr = (uint32_t)image;
|
||||||
|
dma_init_struct.direction = DMA_MEMORY_TO_PERIPHERAL;
|
||||||
|
dma_init_struct.memory_width = DMA_MEMORY_WIDTH_8BIT;
|
||||||
|
dma_init_struct.periph_width = DMA_PERIPHERAL_WIDTH_8BIT;
|
||||||
|
dma_init_struct.priority = DMA_PRIORITY_LOW;
|
||||||
|
dma_init_struct.number = ((max_width)*(max_height)*2);
|
||||||
|
dma_init_struct.periph_inc = DMA_PERIPH_INCREASE_DISABLE;
|
||||||
|
dma_init_struct.memory_inc = DMA_MEMORY_INCREASE_ENABLE;
|
||||||
|
dma_init(DMA0, DMA_CH2, &dma_init_struct);
|
||||||
|
/* configure DMA mode */
|
||||||
|
dma_circulation_disable(DMA0, DMA_CH2);
|
||||||
|
dma_memory_to_memory_disable(DMA0, DMA_CH2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_HARDWARE_SPI
|
||||||
|
void spi_config(void)
|
||||||
|
{
|
||||||
|
spi_parameter_struct spi_init_struct;
|
||||||
|
/* deinitilize SPI and the parameters */
|
||||||
|
LCD_CS_Set();
|
||||||
|
spi_struct_para_init(&spi_init_struct);
|
||||||
|
|
||||||
|
/* SPI0 parameter config */
|
||||||
|
spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX;
|
||||||
|
spi_init_struct.device_mode = SPI_MASTER;
|
||||||
|
spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT;
|
||||||
|
spi_init_struct.clock_polarity_phase = SPI_CK_PL_HIGH_PH_2EDGE;
|
||||||
|
spi_init_struct.nss = SPI_NSS_SOFT;
|
||||||
|
spi_init_struct.prescale = SPI_PSC_8;
|
||||||
|
spi_init_struct.endian = SPI_ENDIAN_MSB;
|
||||||
|
spi_init(SPI0, &spi_init_struct);
|
||||||
|
|
||||||
|
spi_crc_polynomial_set(SPI0,7);
|
||||||
|
spi_enable(SPI0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void delay_1ms(uint32_t count)
|
||||||
|
{
|
||||||
|
uint64_t start_mtime, delta_mtime;
|
||||||
|
|
||||||
|
/* don't start measuruing until we see an mtime tick */
|
||||||
|
uint64_t tmp = get_timer_value();
|
||||||
|
|
||||||
|
do{
|
||||||
|
start_mtime = get_timer_value();
|
||||||
|
}while(start_mtime == tmp);
|
||||||
|
|
||||||
|
do{
|
||||||
|
delta_mtime = get_timer_value() - start_mtime;
|
||||||
|
}while(delta_mtime <(SystemCoreClock/4000.0 *count));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_On() {
|
||||||
|
LCD_WR_REG(0x29);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCD_SetDisplayMode(lcd_display_mode_t m) {
|
||||||
|
uint8_t d = 0x00;
|
||||||
|
|
||||||
|
switch(m) {
|
||||||
|
case LCD_DISPMODE_HORIZONTAL:
|
||||||
|
d = 0x60;
|
||||||
|
max_width = 160;
|
||||||
|
max_height = 80;
|
||||||
|
break;
|
||||||
|
case LCD_DISPMODE_HORIZONTAL_MIRROR:
|
||||||
|
d = 0xA0;
|
||||||
|
max_width = 160;
|
||||||
|
max_height = 80;
|
||||||
|
break;
|
||||||
|
case LCD_DISPMODE_VERTICAL:
|
||||||
|
d = 0x00;
|
||||||
|
max_width = 80;
|
||||||
|
max_height = 160;
|
||||||
|
break;
|
||||||
|
case LCD_DISPMODE_VERTICAL_MIRROR:
|
||||||
|
d = 0xC0;
|
||||||
|
max_width = 80;
|
||||||
|
max_height = 160;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
LCD_WR_REG(0x36);
|
||||||
|
LCD_WR_DATA8(d | 0x08);
|
||||||
|
display_mode = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCD_Init(void)
|
||||||
|
{
|
||||||
|
rcu_periph_clock_enable(RCU_GPIOA);
|
||||||
|
rcu_periph_clock_enable(RCU_GPIOB);
|
||||||
|
|
||||||
|
#if USE_HARDWARE_SPI
|
||||||
|
rcu_periph_clock_enable(RCU_AF);
|
||||||
|
rcu_periph_clock_enable(RCU_SPI0);
|
||||||
|
/* SPI0 GPIO config: NSS/PA4, SCK/PA5, MOSI/PA7 */
|
||||||
|
gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5 |GPIO_PIN_6| GPIO_PIN_7);
|
||||||
|
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
|
||||||
|
|
||||||
|
spi_config();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_HARDWARE_DMA_SPI
|
||||||
|
rcu_periph_clock_enable(RCU_DMA0);
|
||||||
|
rcu_periph_clock_enable(RCU_SPI0);
|
||||||
|
|
||||||
|
/* SPI0 GPIO config: NSS/PA4, SCK/PA5, MOSI/PA7 */
|
||||||
|
gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_7);
|
||||||
|
/* SPI0 GPIO config: MISO/PA6 */
|
||||||
|
gpio_init(GPIOA, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_6);
|
||||||
|
|
||||||
|
dma_config();
|
||||||
|
|
||||||
|
dma_channel_enable(DMA0,DMA_CH2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_SOFTWARE_SPI
|
||||||
|
gpio_init(GPIOA, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5 | GPIO_PIN_7);
|
||||||
|
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_2);
|
||||||
|
|
||||||
|
gpio_bit_reset(GPIOA, GPIO_PIN_5 | GPIO_PIN_7);
|
||||||
|
gpio_bit_reset(GPIOB, GPIO_PIN_2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gpio_init(GPIOB, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0 | GPIO_PIN_1);
|
||||||
|
gpio_bit_reset(GPIOB, GPIO_PIN_0 | GPIO_PIN_1);
|
||||||
|
|
||||||
|
LCD_RST_Clr();
|
||||||
|
delay_1ms(200);
|
||||||
|
LCD_RST_Set();
|
||||||
|
delay_1ms(20);
|
||||||
|
|
||||||
|
LCD_WR_REG(0x11);
|
||||||
|
delay_1ms(100);
|
||||||
|
|
||||||
|
// display inversion on
|
||||||
|
LCD_WR_REG(0x21);
|
||||||
|
|
||||||
|
// power
|
||||||
|
LCD_WR_REG(0xC0);
|
||||||
|
LCD_WR_DATA8(0x62);
|
||||||
|
LCD_WR_DATA8(0x02);
|
||||||
|
LCD_WR_DATA8(0x04);
|
||||||
|
|
||||||
|
LCD_WR_REG(0xC1);
|
||||||
|
LCD_WR_DATA8(0xC0);
|
||||||
|
|
||||||
|
LCD_WR_REG(0xC2);
|
||||||
|
LCD_WR_DATA8(0x0D);
|
||||||
|
LCD_WR_DATA8(0x00);
|
||||||
|
|
||||||
|
LCD_WR_REG(0xC3);
|
||||||
|
LCD_WR_DATA8(0x8D);
|
||||||
|
LCD_WR_DATA8(0x6A);
|
||||||
|
|
||||||
|
LCD_WR_REG(0xC4);
|
||||||
|
LCD_WR_DATA8(0x8D);
|
||||||
|
LCD_WR_DATA8(0xEE);
|
||||||
|
|
||||||
|
// vcom
|
||||||
|
LCD_WR_REG(0xC5);
|
||||||
|
LCD_WR_DATA8(0x0E);
|
||||||
|
|
||||||
|
// 16bit color mode
|
||||||
|
LCD_WR_REG(0x3A);
|
||||||
|
LCD_WR_DATA8(0x05);
|
||||||
|
|
||||||
|
LCD_SetDisplayMode(LCD_DISPMODE_HORIZONTAL);
|
||||||
|
|
||||||
|
LCD_On();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_Clear(uint16_t Color)
|
||||||
|
{
|
||||||
|
LCD_Address_Set(0, 0, max_width, max_height);
|
||||||
|
for(uint16_t i=0; i<max_width; i++) {
|
||||||
|
for (uint16_t j=0; j<max_height; j++) {
|
||||||
|
LCD_WR_DATA(Color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCD_ShowChinese(uint16_t x, uint16_t y, uint8_t index, uint16_t color)
|
||||||
|
{
|
||||||
|
const uint8_t *p = (uint8_t*) &(Hzk[index*2][0]);
|
||||||
|
|
||||||
|
//[数据排列]:从左到右从上到下 [取模方式]:纵向8点下高位 [正负反色]:否
|
||||||
|
LCD_Address_Set(x, y, 16, 16);
|
||||||
|
|
||||||
|
for(uint8_t i=0; i<8; i++) {
|
||||||
|
for(uint8_t j=0; j<16; j++) {
|
||||||
|
LCD_WR_DATA((p[j] & (1<<i)) == 0 ? BACK_COLOR : color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i=0; i<8; i++) {
|
||||||
|
for(uint8_t j=16; j<32; j++) {
|
||||||
|
LCD_WR_DATA((p[j] & (1<<i)) == 0 ? BACK_COLOR : color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color)
|
||||||
|
{
|
||||||
|
LCD_Address_Set(x, y, 1, 1);
|
||||||
|
LCD_WR_DATA(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_Fill(uint16_t xsta, uint16_t ysta, uint16_t xend, uint16_t yend, uint16_t color)
|
||||||
|
{
|
||||||
|
LCD_Address_Set(xsta, ysta, xend-xsta, yend-ysta);
|
||||||
|
for(uint8_t i=ysta; i<=yend; i++) {
|
||||||
|
for(uint8_t j=xsta;j<=xend;j++) {
|
||||||
|
LCD_WR_DATA(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int abs(int n) {
|
||||||
|
return n >= 0 ? n : -n;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCD_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
|
||||||
|
{
|
||||||
|
int16_t dx = x2 - x1;
|
||||||
|
int16_t dy = y2 - y1;
|
||||||
|
int16_t ux = ((dx > 0) << 1) - 1;//x的增量方向,取或-1
|
||||||
|
int16_t uy = ((dy > 0) << 1) - 1;//y的增量方向,取或-1
|
||||||
|
int16_t x = x1, y = y1, eps;//eps为累加误差
|
||||||
|
|
||||||
|
eps = 0;dx = abs(dx); dy = abs(dy);
|
||||||
|
if (dx > dy) {
|
||||||
|
for (x = x1; x != x2; x += ux) {
|
||||||
|
LCD_DrawPoint(x, y, color);
|
||||||
|
eps += dy;
|
||||||
|
if ((eps << 1) >= dx) {
|
||||||
|
y += uy; eps -= dx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (y = y1; y != y2; y += uy) {
|
||||||
|
LCD_DrawPoint(x, y, color);
|
||||||
|
eps += dx;
|
||||||
|
if ((eps << 1) >= dy) {
|
||||||
|
x += ux; eps -= dy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint16_t color)
|
||||||
|
{
|
||||||
|
LCD_DrawLine(x1,y1,x2,y1,color);
|
||||||
|
LCD_DrawLine(x1,y1,x1,y2,color);
|
||||||
|
LCD_DrawLine(x1,y2,x2,y2,color);
|
||||||
|
LCD_DrawLine(x2,y1,x2,y2,color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_DrawCircle(uint16_t x0,uint16_t y0,uint8_t r,uint16_t color)
|
||||||
|
{
|
||||||
|
int a,b;
|
||||||
|
a=0;b=r;
|
||||||
|
while(a<=b)
|
||||||
|
{
|
||||||
|
LCD_DrawPoint(x0-b,y0-a,color); //3
|
||||||
|
LCD_DrawPoint(x0+b,y0-a,color); //0
|
||||||
|
LCD_DrawPoint(x0-a,y0+b,color); //1
|
||||||
|
LCD_DrawPoint(x0-a,y0-b,color); //2
|
||||||
|
LCD_DrawPoint(x0+b,y0+a,color); //4
|
||||||
|
LCD_DrawPoint(x0+a,y0-b,color); //5
|
||||||
|
LCD_DrawPoint(x0+a,y0+b,color); //6
|
||||||
|
LCD_DrawPoint(x0-b,y0+a,color); //7
|
||||||
|
a++;
|
||||||
|
if((a*a+b*b)>(r*r))//判断要画的点是否过远
|
||||||
|
{
|
||||||
|
b--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t chr, uint16_t color)
|
||||||
|
{
|
||||||
|
if(x > max_width || y > max_height) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *p = F8X16 + (chr - ' ')*16;
|
||||||
|
|
||||||
|
LCD_Address_Set(x, y, 8, 16); //设置光标位置
|
||||||
|
|
||||||
|
for(uint8_t i=0; i<8; i++) {
|
||||||
|
for(uint8_t j=0; j<8; j++) {
|
||||||
|
LCD_WR_DATA((p[0+j] & (1<<i)) == 0 ? BACK_COLOR : color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t i=0; i<8; i++) {
|
||||||
|
for(uint8_t j=0; j<8; j++) {
|
||||||
|
LCD_WR_DATA((p[8+j] & (1<<i)) == 0 ? BACK_COLOR : color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_ShowString(uint16_t x,uint16_t y,const uint8_t *p,uint16_t color)
|
||||||
|
{
|
||||||
|
while(*p) {
|
||||||
|
LCD_ShowChar(x,y,*p,color);
|
||||||
|
x += 8;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_ShowNum(uint16_t x, uint16_t y, uint16_t n, uint16_t color)
|
||||||
|
{
|
||||||
|
const uint8_t max_len = 5; // 65536 max length 5
|
||||||
|
uint8_t buf[max_len];
|
||||||
|
|
||||||
|
int pos = max_len;
|
||||||
|
do {
|
||||||
|
pos--;
|
||||||
|
buf[pos] = n % 10 + '0';
|
||||||
|
n /= 10;
|
||||||
|
} while(n > 0);
|
||||||
|
|
||||||
|
for(uint8_t i=0; pos < max_len; i++, pos++) {
|
||||||
|
LCD_ShowChar(x+i*8, y, buf[pos], color);
|
||||||
|
}
|
||||||
|
}
|
96
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcd.h
Normal file
96
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcd.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
#ifndef __LCD_H
|
||||||
|
#define __LCD_H
|
||||||
|
|
||||||
|
#include "stdlib.h"
|
||||||
|
#include "gd32vf103_gpio.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
LCD_DISPMODE_HORIZONTAL,
|
||||||
|
LCD_DISPMODE_HORIZONTAL_MIRROR,
|
||||||
|
LCD_DISPMODE_VERTICAL,
|
||||||
|
LCD_DISPMODE_VERTICAL_MIRROR
|
||||||
|
} lcd_display_mode_t;
|
||||||
|
|
||||||
|
#define USE_HARDWARE_SPI 1
|
||||||
|
//#define USE_HARDWARE_DMA_SPI 1
|
||||||
|
//#define USE_SOFTWARE_SPI 1
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_HARDWARE_SPI
|
||||||
|
#define LCD_SCLK_Clr()
|
||||||
|
#define LCD_SCLK_Set()
|
||||||
|
#define LCD_SDIN_Clr()
|
||||||
|
#define LCD_SDIN_Set()
|
||||||
|
#define LCD_CS_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_2) //CS PB2
|
||||||
|
#define LCD_CS_Set() gpio_bit_set( GPIOB, GPIO_PIN_2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_HARDWARE_DMA_SPI
|
||||||
|
#define LCD_SCLK_Clr()
|
||||||
|
#define LCD_SCLK_Set()
|
||||||
|
#define LCD_SDIN_Clr()
|
||||||
|
#define LCD_SDIN_Set()
|
||||||
|
#define LCD_CS_Clr()
|
||||||
|
#define LCD_CS_Set()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_SOFTWARE_SPI
|
||||||
|
#define LCD_SCLK_Clr() gpio_bit_reset( GPIOA, GPIO_PIN_5) //CLK PA5
|
||||||
|
#define LCD_SCLK_Set() gpio_bit_set( GPIOA, GPIO_PIN_5)
|
||||||
|
#define LCD_SDIN_Clr() gpio_bit_reset( GPIOA, GPIO_PIN_7) //DIN PA7
|
||||||
|
#define LCD_SDIN_Set() gpio_bit_set( GPIOA, GPIO_PIN_7)
|
||||||
|
#define LCD_CS_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_2) //CS PB2
|
||||||
|
#define LCD_CS_Set() gpio_bit_set( GPIOB, GPIO_PIN_2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LCD_RST_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_1) //RES PB1
|
||||||
|
#define LCD_RST_Set() gpio_bit_set( GPIOB, GPIO_PIN_1)
|
||||||
|
#define LCD_DC_Clr() gpio_bit_reset( GPIOB, GPIO_PIN_0) //DC PB0
|
||||||
|
#define LCD_DC_Set() gpio_bit_set( GPIOB, GPIO_PIN_0)
|
||||||
|
|
||||||
|
|
||||||
|
void LCD_Writ_Bus(uint8_t dat);
|
||||||
|
void LCD_WR_DATA8(uint8_t dat);
|
||||||
|
void LCD_WR_DATA(uint16_t dat);
|
||||||
|
void LCD_WR_REG(uint8_t dat);
|
||||||
|
|
||||||
|
void LCD_Init(void);
|
||||||
|
void LCD_Address_Set(uint16_t x1, uint16_t y1, uint16_t x2,uint16_t y2);
|
||||||
|
void LCD_SetDisplayMode(lcd_display_mode_t m);
|
||||||
|
|
||||||
|
void LCD_Clear(uint16_t Color);
|
||||||
|
void LCD_ShowChinese(uint16_t x,uint16_t y,uint8_t index,uint16_t color);
|
||||||
|
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color);
|
||||||
|
void LCD_Fill(uint16_t xsta,uint16_t ysta,uint16_t xend,uint16_t yend,uint16_t color);
|
||||||
|
void LCD_DrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
|
||||||
|
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint16_t color);
|
||||||
|
void LCD_DrawCircle(uint16_t x0,uint16_t y0,uint8_t r,uint16_t color);
|
||||||
|
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t ch,uint16_t color);
|
||||||
|
void LCD_ShowString(uint16_t x,uint16_t y,const uint8_t *p,uint16_t color);
|
||||||
|
void LCD_ShowNum(uint16_t x,uint16_t y,uint16_t num,uint16_t color);
|
||||||
|
|
||||||
|
#define WHITE 0xFFFF
|
||||||
|
#define BLACK 0x0000
|
||||||
|
#define BLUE 0x001F
|
||||||
|
#define BRED 0XF81F
|
||||||
|
#define GRED 0XFFE0
|
||||||
|
#define GBLUE 0X07FF
|
||||||
|
#define RED 0xF800
|
||||||
|
#define MAGENTA 0xF81F
|
||||||
|
#define GREEN 0x07E0
|
||||||
|
#define CYAN 0x7FFF
|
||||||
|
#define YELLOW 0xFFE0
|
||||||
|
#define BROWN 0XBC40
|
||||||
|
#define BRRED 0XFC07
|
||||||
|
#define GRAY 0X8430
|
||||||
|
#define DARKBLUE 0x01CF
|
||||||
|
#define LIGHTBLUE 0x7D7C
|
||||||
|
#define GRAYBLUE 0x5458
|
||||||
|
#define LIGHTGREEN 0x841F
|
||||||
|
#define LGRAY 0xC618
|
||||||
|
#define LGRAYBLUE 0xA651
|
||||||
|
#define LBBLUE 0x2B12
|
||||||
|
|
||||||
|
#endif
|
246
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcdfont.h
Normal file
246
board/Sipeed_LonganNano/BSP/Hardware/lcd/lcdfont.h
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
#ifndef __LCD_FONT_H
|
||||||
|
#define __LCD_FONT_H
|
||||||
|
|
||||||
|
const unsigned char F6x8[][6] =
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
|
||||||
|
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
|
||||||
|
0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
|
||||||
|
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
|
||||||
|
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
|
||||||
|
0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
|
||||||
|
0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
|
||||||
|
0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
|
||||||
|
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
|
||||||
|
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
|
||||||
|
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
|
||||||
|
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
|
||||||
|
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
|
||||||
|
0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
|
||||||
|
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
|
||||||
|
0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
|
||||||
|
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
|
||||||
|
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
|
||||||
|
0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
|
||||||
|
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
|
||||||
|
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
|
||||||
|
0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
|
||||||
|
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
|
||||||
|
0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
|
||||||
|
0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
|
||||||
|
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
|
||||||
|
0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
|
||||||
|
0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
|
||||||
|
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
|
||||||
|
0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
|
||||||
|
0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
|
||||||
|
0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
|
||||||
|
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
|
||||||
|
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
|
||||||
|
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
|
||||||
|
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
|
||||||
|
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
|
||||||
|
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
|
||||||
|
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
|
||||||
|
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
|
||||||
|
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
|
||||||
|
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
|
||||||
|
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
|
||||||
|
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
|
||||||
|
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
|
||||||
|
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
|
||||||
|
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
|
||||||
|
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
|
||||||
|
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
|
||||||
|
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
|
||||||
|
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
|
||||||
|
0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
|
||||||
|
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
|
||||||
|
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
|
||||||
|
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
|
||||||
|
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
|
||||||
|
0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
|
||||||
|
0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
|
||||||
|
0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
|
||||||
|
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
|
||||||
|
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
|
||||||
|
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
|
||||||
|
0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
|
||||||
|
0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
|
||||||
|
0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
|
||||||
|
0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
|
||||||
|
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
|
||||||
|
0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
|
||||||
|
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
|
||||||
|
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
|
||||||
|
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
|
||||||
|
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
|
||||||
|
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
|
||||||
|
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
|
||||||
|
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
|
||||||
|
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
|
||||||
|
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
|
||||||
|
0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
|
||||||
|
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
|
||||||
|
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
|
||||||
|
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
|
||||||
|
0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
|
||||||
|
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
|
||||||
|
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
|
||||||
|
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
|
||||||
|
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
|
||||||
|
0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
|
||||||
|
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
|
||||||
|
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
|
||||||
|
0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char F8X16[]=
|
||||||
|
{
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||||
|
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
|
||||||
|
0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
|
||||||
|
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
|
||||||
|
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
|
||||||
|
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
|
||||||
|
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
|
||||||
|
0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
|
||||||
|
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
|
||||||
|
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
|
||||||
|
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
|
||||||
|
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
|
||||||
|
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
|
||||||
|
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
|
||||||
|
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
|
||||||
|
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
|
||||||
|
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
|
||||||
|
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
|
||||||
|
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
|
||||||
|
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
|
||||||
|
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
|
||||||
|
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
|
||||||
|
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
|
||||||
|
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
|
||||||
|
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
|
||||||
|
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
|
||||||
|
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
|
||||||
|
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
|
||||||
|
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
|
||||||
|
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
|
||||||
|
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
|
||||||
|
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
|
||||||
|
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
|
||||||
|
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
|
||||||
|
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
|
||||||
|
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
|
||||||
|
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
|
||||||
|
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
|
||||||
|
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
|
||||||
|
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
|
||||||
|
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
|
||||||
|
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
|
||||||
|
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
|
||||||
|
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
|
||||||
|
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
|
||||||
|
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
|
||||||
|
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
|
||||||
|
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
|
||||||
|
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
|
||||||
|
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
|
||||||
|
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
|
||||||
|
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
|
||||||
|
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
|
||||||
|
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
|
||||||
|
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
|
||||||
|
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
|
||||||
|
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
|
||||||
|
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
|
||||||
|
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
|
||||||
|
0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
|
||||||
|
0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
|
||||||
|
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
|
||||||
|
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
|
||||||
|
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
|
||||||
|
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
|
||||||
|
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
|
||||||
|
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
|
||||||
|
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
|
||||||
|
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
|
||||||
|
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
|
||||||
|
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
|
||||||
|
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
|
||||||
|
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
|
||||||
|
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
|
||||||
|
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
|
||||||
|
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
|
||||||
|
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
|
||||||
|
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
|
||||||
|
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
|
||||||
|
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
|
||||||
|
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
|
||||||
|
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
|
||||||
|
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
|
||||||
|
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
|
||||||
|
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
|
||||||
|
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
|
||||||
|
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
|
||||||
|
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
|
||||||
|
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
|
||||||
|
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
|
||||||
|
0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><D2B4>ϵ<EFBFBD><CFB5><EFBFBD> [ȡģ<C8A1><C4A3>ʽ]:<3A><><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD>¸<EFBFBD>λ [<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ]:<3A><>
|
||||||
|
const char Hzk[][16]={
|
||||||
|
{0x00,0xFE,0x22,0x22,0xFE,0x28,0xA9,0x6E,0x28,0x3F,0x28,0x6C,0xAB,0x28,0x20,0x00},
|
||||||
|
{0x80,0x7F,0x02,0x82,0xFF,0x01,0x20,0x2D,0x29,0x29,0x29,0x4F,0x88,0x79,0x01,0x00},/*"<22><>",0*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x40,0x40,0x42,0xCC,0x00,0x82,0x82,0xFE,0x82,0x82,0x02,0xFE,0x00,0x00,0x00,0x00},
|
||||||
|
{0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x00,0x00,0x00,0x0F,0x30,0x40,0xF8,0x00},/*"Ѷ",1*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x40,0x3C,0x10,0xFF,0x10,0x10,0x20,0x10,0x8F,0x78,0x08,0xF8,0x08,0xF8,0x00,0x00},
|
||||||
|
{0x02,0x06,0x02,0xFF,0x01,0x01,0x04,0x42,0x21,0x18,0x46,0x81,0x40,0x3F,0x00,0x00},/*"<22><>",2*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00},
|
||||||
|
{0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00},/*"<22><>",3*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00},
|
||||||
|
{0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00},/*"<22><>",4*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x00,0x80,0x60,0xF8,0x07,0x00,0xFE,0x52,0x52,0x52,0x52,0x52,0xFE,0x00,0x00,0x00},
|
||||||
|
{0x01,0x00,0x00,0xFF,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x29,0x4F,0x88,0x08,0x00},/*"<22><>",3*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x00,0x00,0xE0,0x9C,0x84,0x84,0x84,0xF4,0x82,0x82,0x83,0x82,0x80,0x80,0x00,0x00},
|
||||||
|
{0x00,0x20,0x10,0x08,0x06,0x40,0x80,0x7F,0x00,0x00,0x02,0x04,0x08,0x30,0x00,0x00},/*"<22><>",4*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x40,0x44,0x54,0x65,0x46,0x44,0x64,0x54,0x44,0x40,0xFE,0x02,0x22,0xDA,0x06,0x00},
|
||||||
|
{0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0xFF,0x08,0x10,0x08,0x07,0x00},/*"<22><>",5*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
|
||||||
|
{0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00},/*"<22><>",5*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
|
||||||
|
{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"<22><>",6*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x10,0x60,0x02,0x8C,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00},
|
||||||
|
{0x04,0x04,0x7E,0x01,0x44,0x48,0x50,0x7F,0x40,0x40,0x7F,0x50,0x48,0x44,0x40,0x00},/*"ʪ",7*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00},
|
||||||
|
{0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00},/*"<22><>",8*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x40,0x40,0x42,0x44,0x58,0xC0,0x40,0x7F,0x40,0xC0,0x50,0x48,0x46,0x40,0x40,0x00},
|
||||||
|
{0x80,0x80,0x40,0x20,0x18,0x07,0x00,0x00,0x00,0x3F,0x40,0x40,0x40,0x40,0x78,0x00},/*"<22><>",9*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
{0x02,0xE2,0x22,0x22,0x3E,0x00,0x80,0x9E,0x92,0x92,0xF2,0x92,0x92,0x9E,0x80,0x00},
|
||||||
|
{0x00,0x43,0x82,0x42,0x3E,0x40,0x47,0x44,0x44,0x44,0x7F,0x44,0x44,0x54,0xE7,0x00},/*"ǿ",10*/
|
||||||
|
/* (16 X 16 , <20><><EFBFBD><EFBFBD> )*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -1,5 +1,5 @@
|
|||||||
#include "mcu_init.h"
|
#include "mcu_init.h"
|
||||||
|
#include "lcd.h"
|
||||||
void board_init() {
|
void board_init() {
|
||||||
|
|
||||||
SystemInit();
|
SystemInit();
|
||||||
@@ -14,4 +14,7 @@ void board_init() {
|
|||||||
gpio_bit_set(LEDR_GPIO_PORT, LEDR_PIN);
|
gpio_bit_set(LEDR_GPIO_PORT, LEDR_PIN);
|
||||||
gpio_bit_set(LEDG_GPIO_PORT, LEDG_PIN);
|
gpio_bit_set(LEDG_GPIO_PORT, LEDG_PIN);
|
||||||
gpio_bit_set(LEDB_GPIO_PORT, LEDB_PIN);
|
gpio_bit_set(LEDB_GPIO_PORT, LEDB_PIN);
|
||||||
|
|
||||||
|
LCD_Init(); // init LCD
|
||||||
|
LCD_Clear(BLACK);
|
||||||
}
|
}
|
||||||
|
@@ -148,6 +148,8 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/kernel/evtdrv/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/kernel/evtdrv/include}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/Application/Inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/Application/Inc}""/>
|
||||||
|
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/Application/Hardware/lcd}""/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
@@ -39,6 +39,11 @@
|
|||||||
<type>2</type>
|
<type>2</type>
|
||||||
<locationURI>virtual:/virtual</locationURI>
|
<locationURI>virtual:/virtual</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>Application/Hardware</name>
|
||||||
|
<type>2</type>
|
||||||
|
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/BSP/Hardware</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>Application/Inc</name>
|
<name>Application/Inc</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
|
@@ -1,11 +1,17 @@
|
|||||||
#include "mcu_init.h"
|
#include "mcu_init.h"
|
||||||
#include "tos.h"
|
#include "tos.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
#define TASK_SIZE 1024
|
#define TASK_SIZE 1024
|
||||||
k_task_t k_task_task1;
|
|
||||||
k_task_t k_task_task2;
|
|
||||||
uint8_t k_task1_stk[TASK_SIZE];
|
k_task_t task1_handle;
|
||||||
uint8_t k_task2_stk[TASK_SIZE];
|
k_task_t task2_handle;
|
||||||
|
k_task_t led_handle;
|
||||||
|
|
||||||
|
uint8_t task1_stk[TASK_SIZE];
|
||||||
|
uint8_t task2_stk[TASK_SIZE];
|
||||||
|
uint8_t led_stk[TASK_SIZE/2];
|
||||||
|
|
||||||
int share = 0xCBA7F9;
|
int share = 0xCBA7F9;
|
||||||
k_sem_t sem;
|
k_sem_t sem;
|
||||||
@@ -21,7 +27,8 @@ Led_t leds[] = {
|
|||||||
{ LEDB_GPIO_PORT, LEDB_PIN }
|
{ LEDB_GPIO_PORT, LEDB_PIN }
|
||||||
};
|
};
|
||||||
|
|
||||||
void task1(void *pdata)
|
|
||||||
|
void task1(void *arg)
|
||||||
{
|
{
|
||||||
int task_cnt1 = 0;
|
int task_cnt1 = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -35,7 +42,7 @@ void task1(void *pdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void task2(void *pdata)
|
void task2(void *arg)
|
||||||
{
|
{
|
||||||
int task_cnt2 = 0;
|
int task_cnt2 = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -48,6 +55,32 @@ void task2(void *pdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void task_led(void *arg)
|
||||||
|
{
|
||||||
|
uint16_t color_table[] = { WHITE, BLUE, RED, GREEN, CYAN, YELLOW, GRAY};
|
||||||
|
|
||||||
|
for(int i=0; ; i++) {
|
||||||
|
LCD_SetDisplayMode((i % 2) ? LCD_DISPMODE_HORIZONTAL_MIRROR : LCD_DISPMODE_HORIZONTAL);
|
||||||
|
LCD_Clear(BLACK);
|
||||||
|
|
||||||
|
uint16_t color = color_table[i % (sizeof(color_table)/sizeof(uint16_t))];
|
||||||
|
|
||||||
|
|
||||||
|
LCD_ShowChinese(50, 16, 0, color);
|
||||||
|
LCD_ShowChinese(50+16+28, 16, 1, color);
|
||||||
|
|
||||||
|
for(int j=0; j<6; j++) {
|
||||||
|
LCD_ShowChinese(22+j*20, 48, j+2, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
tos_task_delay(5000);
|
||||||
|
LCD_Clear(BLACK);
|
||||||
|
|
||||||
|
LCD_ShowString(24, 32, "TencentOS tiny", color);
|
||||||
|
|
||||||
|
tos_task_delay(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
board_init();
|
board_init();
|
||||||
@@ -56,8 +89,10 @@ void main(void) {
|
|||||||
|
|
||||||
tos_knl_init();
|
tos_knl_init();
|
||||||
|
|
||||||
tos_task_create(&k_task_task1, "task1", task1, NULL, 3, k_task1_stk, TASK_SIZE, 0);
|
|
||||||
tos_task_create(&k_task_task2, "task2", task2, NULL, 3, k_task2_stk, TASK_SIZE, 0);
|
tos_task_create(&task1_handle, "task1", task1, NULL, 3, task1_stk, TASK_SIZE, 0);
|
||||||
|
tos_task_create(&task2_handle, "task2", task2, NULL, 3, task2_stk, TASK_SIZE, 0);
|
||||||
|
tos_task_create(&led_handle, "led", task_led, NULL, 5, led_stk, TASK_SIZE/2, 0);
|
||||||
|
|
||||||
k_err_t err = tos_sem_create(&sem, 1);
|
k_err_t err = tos_sem_create(&sem, 1);
|
||||||
if (err != K_ERR_NONE) {
|
if (err != K_ERR_NONE) {
|
||||||
|
@@ -194,6 +194,7 @@ void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
|
|||||||
OLED_WR_Byte(F6x8[c][i],OLED_DATA);
|
OLED_WR_Byte(F6x8[c][i],OLED_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//m^n函数
|
//m^n函数
|
||||||
uint32_t oled_pow(uint8_t m,uint8_t n)
|
uint32_t oled_pow(uint8_t m,uint8_t n)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user