OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3243|回复: 0

利用核心板STM32F103核心板与液晶显示屏和矩阵电路建立起来?

[复制链接]

1

主题

7

帖子

0

精华

新手上路

积分
22
金钱
22
注册时间
2020-11-13
在线时间
4 小时
发表于 2020-11-21 10:46:29 | 显示全部楼层 |阅读模式

#include  "stm32f10x.h"
#include  "stm32f10x_conf.h"
#include  "bsp.h"
#include  "LCD12864.h"
/* Private variables ---------------------------------------------------------*/
// Systick delay
__IO uint32_t TimingDelay = 0 ;



//void LCD_Display_Fresh(void);
//uint8_t TxBuffer4[TxBufferSize4];
//uint8_t RxBuffer4[RxBufferSize4], rec_f4;
uint8_t TxBuffer4[4];
uint8_t RxBuffer4[4], rec_f4;
__IO uint8_t TxCounter4 = 0x00;
__IO uint8_t RxCounter4 = 0x00;
//uint8_t NbrOfDataToTransfer4 = TxBufferSize4;
//uint8_t NbrOfDataToRead4 = RxBufferSize4;
__IO TestStatus TransferStatus4 = FAILED;

uint8_t TxBuffer5[4];
uint8_t RxBuffer5[4], rec_f5;
__IO uint8_t TxCounter5 = 0x00;
__IO uint8_t RxCounter5 = 0x00;
unsigned char i;
unsigned char press_flag1=0;
unsigned char press_flag2=0;
unsigned char press_flag3=0;
unsigned char press_flag4=0;

unsigned char        key_Pressed;
unsigned char        key_val=0;
unsigned char        key_flag;

unsigned char LCD_First_Line0[] ={"日期: 2020:11:16"};
unsigned char LCD_Second_Line0[] ={"时间:   19:22:00"};
unsigned char LCD_Line[] ={"                "};  
unsigned char LCD_fourth_Line[] ={"矩阵按键:  "};
unsigned char LCD_third_Line0[] ={"苏州经贸职业学院"};  
void LCD_Display_Fresh(void);

int main(void)
{

    BSP_Configuration();
        gpio_12864_initout();
        BSP_USART_Configuration(UART4);
    BSP_USART_Configuration(UART5);       
         
    if (SysTick_Config(72000))                    //时钟节拍中断时1ms一次  用于定时
    {  
        while (1);
    }
        LCD_Init();
        GPIO_ResetBits(GPIOC, BSP_GPIOC_LED1);
        GPIO_ResetBits(GPIOC, BSP_GPIOC_LED2);
        Delay(500);
        GPIO_SetBits(GPIOC, BSP_GPIOC_LED1);
        GPIO_SetBits(GPIOC, BSP_GPIOC_LED2);
        Alarm_Ctrl();
    while (1)
    {
               key_scan();
                  Key_Event();
                if(rec_f4==1)
                {
                        rec_f4=0;
            Alarm_Ctrl();
                        BSP_USART_OUT(UART4,&TxBuffer4[0],0x04);
                }
                      if(rec_f5==1)
                {
                        rec_f5=0;
            Alarm_Ctrl();
                        BSP_USART_OUT(UART5,&TxBuffer5[0],0x04);
                }
                LCD_Display_Fresh();

               
         }
}
void LCD_Display_Fresh(void)
{

          LCD_Position(1,0);                              // "日期:"
          for(i=0;i<16;i++)
          {
              LCD_WriteData(LCD_First_Line0[i]);
          }


          LCD_Position(2,0);                              // Set second line display
          for(i=0;i<16;i++)                                // "时间:"
          {
              LCD_WriteData(LCD_Second_Line0[i]);
          }


          LCD_Position(3,0);
                  if ((press_flag1==1)|(press_flag2==1)|(press_flag3==1)|(press_flag4==1))
                  {
                             for(i=0;i<16;i++)                              
            {
                LCD_WriteData(LCD_third_Line0[i]);
            }
                  }                           
          else
                  for(i=0;i<16;i++)                              
          {
              LCD_WriteData(LCD_Line[i]);
          }
          LCD_Position(4,0);                              
          for(i=0;i<10;i++)                                
          {
              LCD_WriteData(LCD_fourth_Line[i]);
          }
                  LCD_WriteData(0x30+key_val/10);
                  LCD_WriteData(0x30+key_val%10);
                  for(i=13;i<16;i++)                                
          {
              LCD_WriteData(LCD_fourth_Line[i]);
          }
          Delay(20);

}


正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-22 18:32

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表