yuyy1989 发表于 2023-10-30 19:58

【AT-START-F423测评】8.综合应用实现简单的信息显示屏

#申请原创# @21小跑堂

综合前面已经实现的功能用这些东西简单做一个信息显示屏

显示屏分3个页面,用开发板上的按键进行切换
第1页显示一些欢迎信息

void lcd_change()
{
    yuyy_hs12864g18b_clear_screen(&hs12864_dev);
    if(mode == 0)
    {
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,0,0,(uint8_t *)" AT32F423 TEST");
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,2,0,(uint8_t *)"    WELCOME   ");
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,4,0,(uint8_t *)" Press userkey");
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,6,0,(uint8_t *)"Code by yuyy1989");
    }
    else if(mode == 1)
    {
      bmp280_readpress();
      dht11_readHT();
    }
    else
    {
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,2,0,(uint8_t *)"   Wait data    ");
    }
}第2页显示时钟和传感器数据
uint8_t *WeekdayStr= {"SUN","MON","TUE","WED","THU","FRI","SAT"};
void showtime()
{
    ertc_time_type time;
    char out;
    ertc_calendar_get(&time);
    if(mode != 1)
      return;
    sprintf(out," 20%02d-%02d-%02d %s ",time.year, time.month, time.day,WeekdayStr);
    yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,0,0,(uint8_t *)out);
    sprintf(out,"    %02d:%02d:%02d    ",time.hour, time.min, time.sec);
    yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,2,0,(uint8_t *)out);
}
void bmp280_readpress()
{
    float temp,press;
    char out;
    temp = yuyy_bmp280_readtemp(&bmp280_dev);
    press = yuyy_bmp280_readpress(&bmp280_dev);
   if(mode != 1)
            return;
    sprintf(out,"   %.1fPa",press);
    yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,6,0,(uint8_t *)out);
}
void dht11_readHT()
{
    float humi,temp;
    char out;
    uint8_t outlen;
    uint8_t result = yuyy_dht11_readHT(&dht11_dev,&temp,&humi);
    if(YUYY_DHT11_OK == result)
    {
      if(mode != 1)
            return;
      outlen = sprintf(out,"%.1f%% %.1f",humi,temp);
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,4,0,(uint8_t *)out);
      yuyy_hs12864g18b_display_graphic_16x16(&hs12864_dev,0,4,8*outlen,(uint8_t *)test16x16temp);
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,4,8*(outlen+2),(uint8_t *)"   ");
    }
}第3页显示电脑CPU内存占用和网速,通过串口接收上位机发送过来的数据并显示
uint8_t lcdhead = {'L','C','D',':'};
uint8_t lcdbuf = {0};
uint8_t lcdheadindex = 0;
uint8_t lcdrowindex = 0;
uint8_t lcdcolindex = 0;
uint8_t lcd_showflag = 0;
void uart_receivebyte(uint8_t dat)
{
    if(lcdheadindex < 4)
    {
      if(dat == lcdhead)
            lcdheadindex += 1;
      else
            lcdheadindex = 0;
    }
    else
    {
      if(dat == '\n')
      {
            lcd_showflag = 1;
      }
      else if(dat == '#')
      {
            lcdrowindex += 1;
            lcdcolindex = 0;
      }
      else if(lcdrowindex < 4 && lcdcolindex < 16)
      {
            lcdbuf = dat;
            lcdcolindex += 1;
      }
    }
}
void procLcddata()
{
    if(mode != 2)
            return;
    uint8_t i = 0;
    while(i<4)
    {
      yuyy_hs12864g18b_display_string_8x16(&hs12864_dev,0,i*2,0,lcdbuf);
      i += 1;
    }
    memset(lcdbuf,' ',68);
    lcdbuf = 0;
    lcdbuf = 0;
    lcdbuf = 0;
    lcdbuf = 0;
    lcdheadindex = 0;
    lcdrowindex = 0;
    lcdcolindex = 0;
}运行效果
https://www.bilibili.com/video/BV1ww411B79p/

tpgf 发表于 2023-11-7 17:24

屏幕的刷新频率达到多少不会出现闪烁的情况呢

guanjiaer 发表于 2023-11-8 08:35

可以通过这种方式来现实一些系统实时运行的信息

木木guainv 发表于 2023-11-8 09:40

这种屏幕可以实现屏幕分辨率的自适应显示吗

xiaoqizi 发表于 2023-11-8 12:30

可以使用这个方式进行程序的监控

renzheshengui 发表于 2023-11-8 16:37

这个屏幕是 使用的串口通讯方式是吧

wakayi 发表于 2023-11-8 18:00

可以多加几个按钮 丰富显示的内容
页: [1]
查看完整版本: 【AT-START-F423测评】8.综合应用实现简单的信息显示屏