期末大作业-增加了字和图片,修复了显示屏影响矩阵键盘和数码管的问题。
由于没有外部中断,所以在系统时钟中断里读取矩阵键盘了。并且在定时器中断里设置时间。把显示屏这个比较耗费时间的部分都放到主函数里。初始化显示屏也比较费时间,所以最后初始化。 但是现在的时间误差还是比较大的。
This commit is contained in:
		
							parent
							
								
									de909caa14
								
							
						
					
					
						commit
						324328bd25
					
				@ -35,7 +35,24 @@ const uint8_t HanziTab[] = /*"
 | 
				
			|||||||
0x44,0x10,0x88,0x10,0x88,0x08,0x00,0x04,0xFE,0x7F,0x02,0x40,0x01,0x20,0xF8,0x07,
 | 
					0x44,0x10,0x88,0x10,0x88,0x08,0x00,0x04,0xFE,0x7F,0x02,0x40,0x01,0x20,0xF8,0x07,
 | 
				
			||||||
0x00,0x02,0x80,0x01,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00,/*"ѧ",13*/
 | 
					0x00,0x02,0x80,0x01,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x00,0x40,0x00,/*"ѧ",13*/
 | 
				
			||||||
0x00,0x02,0x1E,0x04,0xD2,0x7F,0x4A,0x40,0x2A,0x20,0x86,0x1F,0x0A,0x00,0x12,0x00,
 | 
					0x00,0x02,0x1E,0x04,0xD2,0x7F,0x4A,0x40,0x2A,0x20,0x86,0x1F,0x0A,0x00,0x12,0x00,
 | 
				
			||||||
0xD2,0x7F,0x12,0x09,0x16,0x09,0x0A,0x09,0x82,0x48,0x82,0x48,0x42,0x70,0x22,0x00};/*"Ժ",14*/
 | 
					0xD2,0x7F,0x12,0x09,0x16,0x09,0x0A,0x09,0x82,0x48,0x82,0x48,0x42,0x70,0x22,0x00,/*"院",14*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					0x00,0x04,0xFE,0x05,0x12,0x04,0x12,0x04,0x12,0x04,0xFE,0x0C,0x82,0x14,0x82,0x24,
 | 
				
			||||||
 | 
					0x82,0x44,0xFE,0x44,0x12,0x04,0x12,0x04,0x12,0x04,0xFE,0x05,0x00,0x04,0x00,0x04,/*"卧",15*/
 | 
				
			||||||
 | 
					/* (16 X 16 , 宋体 )*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					0x08,0x09,0x08,0x09,0xE8,0x7F,0x08,0x09,0xDF,0x3F,0x48,0x29,0xCC,0x3F,0x5C,0x29,
 | 
				
			||||||
 | 
					0xEA,0x3F,0x0A,0x00,0x89,0x1F,0x88,0x10,0x88,0x1F,0x88,0x10,0x88,0x1F,0x88,0x10,/*"槽",16*/
 | 
				
			||||||
 | 
					/* (16 X 16 , 宋体 )*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					0x80,0x00,0x88,0x00,0x88,0x00,0x88,0x00,0xF8,0x1F,0x84,0x00,0x82,0x00,0x80,0x00,
 | 
				
			||||||
 | 
					0x80,0x00,0xFF,0x7F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,/*"牛",17*/
 | 
				
			||||||
 | 
					/* (16 X 16 , 宋体 )*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					0x00,0x00,0xE4,0x3F,0x08,0x00,0xC8,0x1F,0x40,0x10,0xC0,0x1F,0x0F,0x00,0xE8,0x3F,
 | 
				
			||||||
 | 
					0x28,0x22,0xE8,0x3F,0x28,0x22,0xE8,0x3F,0x28,0x20,0x14,0x00,0xE2,0x7F,0x00,0x00};/*"逼",18*/
 | 
				
			||||||
 | 
					/* (16 X 16 , 宋体 )*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t const ScanTab[] =
 | 
					uint16_t const ScanTab[] =
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -29,6 +29,7 @@
 | 
				
			|||||||
#include "test.h"
 | 
					#include "test.h"
 | 
				
			||||||
#include "SegLed.h"
 | 
					#include "SegLed.h"
 | 
				
			||||||
#include "MatrixKey.h"
 | 
					#include "MatrixKey.h"
 | 
				
			||||||
 | 
					#include "gui.h"
 | 
				
			||||||
/* USER CODE END Includes */
 | 
					/* USER CODE END Includes */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Private typedef -----------------------------------------------------------*/
 | 
					/* Private typedef -----------------------------------------------------------*/
 | 
				
			||||||
@ -51,7 +52,7 @@
 | 
				
			|||||||
/* USER CODE BEGIN PV */
 | 
					/* USER CODE BEGIN PV */
 | 
				
			||||||
uint16_t mPos=0;
 | 
					uint16_t mPos=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t mNum=0;
 | 
					uint16_t mNum=15;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
stSysTickTimer sSysTickTimer = {
 | 
					stSysTickTimer sSysTickTimer = {
 | 
				
			||||||
  0, 0, 0, 0
 | 
					  0, 0, 0, 0
 | 
				
			||||||
@ -66,6 +67,10 @@ structTime stTime = {
 | 
				
			|||||||
  .mTenMilCount = 0,
 | 
					  .mTenMilCount = 0,
 | 
				
			||||||
  .bTenMilIsOk = 0
 | 
					  .bTenMilIsOk = 0
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					uint8_t KeyValue = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const unsigned char gImage_qq[3200];
 | 
				
			||||||
 | 
					extern const unsigned char gImage_Neuro_Sama[40704];
 | 
				
			||||||
/* USER CODE END PV */
 | 
					/* USER CODE END PV */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Private function prototypes -----------------------------------------------*/
 | 
					/* Private function prototypes -----------------------------------------------*/
 | 
				
			||||||
@ -76,7 +81,31 @@ void SystemClock_Config(void);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Private user code ---------------------------------------------------------*/
 | 
					/* Private user code ---------------------------------------------------------*/
 | 
				
			||||||
/* USER CODE BEGIN 0 */
 | 
					/* USER CODE BEGIN 0 */
 | 
				
			||||||
 | 
					void Gui_Drawbmp_full(uint16_t x,uint16_t y,const unsigned char *p) //显示159*128 图片
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  int i; 
 | 
				
			||||||
 | 
						unsigned char picH,picL; 
 | 
				
			||||||
 | 
						LCD_SetWindows(x,y,x+159-1,y+128-1);//窗口设置
 | 
				
			||||||
 | 
					  for(i=0;i<159*128;i++)
 | 
				
			||||||
 | 
						{	
 | 
				
			||||||
 | 
						 	picL=*(p+i*2);	//数据低位在前
 | 
				
			||||||
 | 
							picH=*(p+i*2+1);				
 | 
				
			||||||
 | 
							Lcd_WriteData_16Bit(picH<<8|picL);  						
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
						LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);//恢复显示窗口为全屏	
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					void my_test(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						LCD_direction(1);
 | 
				
			||||||
 | 
					  // LCD_Clear(WHITE);
 | 
				
			||||||
 | 
						// DrawTestPage("图片显示测试");
 | 
				
			||||||
 | 
						//LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
 | 
				
			||||||
 | 
						Gui_Drawbmp_full(0,0,gImage_Neuro_Sama);
 | 
				
			||||||
 | 
						// Show_Str(20+12,75,BLUE,YELLOW,"QQ",16,1);
 | 
				
			||||||
 | 
						// Gui_Drawbmp16(70,30,gImage_qq);
 | 
				
			||||||
 | 
						// Show_Str(70+12,75,BLUE,YELLOW,"QQ",16,1);
 | 
				
			||||||
 | 
						HAL_Delay(1200);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
/* USER CODE END 0 */
 | 
					/* USER CODE END 0 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -87,8 +116,7 @@ int main(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* USER CODE BEGIN 1 */
 | 
					  /* USER CODE BEGIN 1 */
 | 
				
			||||||
  uint8_t KeyValue = 0;
 | 
					
 | 
				
			||||||
	uint16_t cnt = 0;
 | 
					 | 
				
			||||||
  /* USER CODE END 1 */
 | 
					  /* USER CODE END 1 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* MCU Configuration--------------------------------------------------------*/
 | 
					  /* MCU Configuration--------------------------------------------------------*/
 | 
				
			||||||
@ -112,9 +140,9 @@ int main(void)
 | 
				
			|||||||
  MX_SPI2_Init();
 | 
					  MX_SPI2_Init();
 | 
				
			||||||
  MX_TIM3_Init();
 | 
					  MX_TIM3_Init();
 | 
				
			||||||
  /* USER CODE BEGIN 2 */
 | 
					  /* USER CODE BEGIN 2 */
 | 
				
			||||||
  LCD_Init();
 | 
					 | 
				
			||||||
  HAL_TIM_Base_Start_IT(&htim3);
 | 
					  HAL_TIM_Base_Start_IT(&htim3);
 | 
				
			||||||
  TimeToBuff(&stTime);
 | 
					  TimeToBuff(&stTime);
 | 
				
			||||||
 | 
					  LCD_Init();
 | 
				
			||||||
  /* USER CODE END 2 */
 | 
					  /* USER CODE END 2 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Infinite loop */
 | 
					  /* Infinite loop */
 | 
				
			||||||
@ -126,34 +154,9 @@ int main(void)
 | 
				
			|||||||
    /* USER CODE BEGIN 3 */
 | 
					    /* USER CODE BEGIN 3 */
 | 
				
			||||||
    if (sSysTickTimer.bTenMilSecOk) {
 | 
					    if (sSysTickTimer.bTenMilSecOk) {
 | 
				
			||||||
      sSysTickTimer.bTenMilSecOk = 0;
 | 
					      sSysTickTimer.bTenMilSecOk = 0;
 | 
				
			||||||
			if(++cnt>=30)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				cnt=0;
 | 
					 | 
				
			||||||
				if(++mNum>=6)
 | 
					 | 
				
			||||||
					mNum=0;	
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
      KeyValue = MatrixKeyScan();
 | 
					 | 
				
			||||||
      if (KeyValue != NO_KEY) {
 | 
					 | 
				
			||||||
        for (int i = 0; i < 16; i++) {
 | 
					 | 
				
			||||||
          if (KeyValue == KeyTable[i]) {
 | 
					 | 
				
			||||||
            tempValue = i;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        DispToBuff(tempValue);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (stTime.bSecondIsOk) {
 | 
					    if (stTime.bSecondIsOk) {
 | 
				
			||||||
      stTime.bSecondIsOk = 0;
 | 
					      stTime.bSecondIsOk = 0;
 | 
				
			||||||
      if (++stTime.mSecond >= 60) {
 | 
					 | 
				
			||||||
        stTime.mSecond = 0;
 | 
					 | 
				
			||||||
        if (++stTime.mMinute >= 60) {
 | 
					 | 
				
			||||||
          stTime.mMinute = 0;
 | 
					 | 
				
			||||||
          if (++stTime.mHour >= 24) {
 | 
					 | 
				
			||||||
            stTime.mHour = 0;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      TimeToBuff(&stTime);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // main_test();
 | 
					    // main_test();
 | 
				
			||||||
    // Test_Color();
 | 
					    // Test_Color();
 | 
				
			||||||
@ -167,6 +170,7 @@ int main(void)
 | 
				
			|||||||
    if (sSysTickTimer.bTimeOk) {
 | 
					    if (sSysTickTimer.bTimeOk) {
 | 
				
			||||||
      sSysTickTimer.bTimeOk = 0;
 | 
					      sSysTickTimer.bTimeOk = 0;
 | 
				
			||||||
      HAL_GPIO_TogglePin(TickLed_GPIO_Port, TickLed_Pin);
 | 
					      HAL_GPIO_TogglePin(TickLed_GPIO_Port, TickLed_Pin);
 | 
				
			||||||
 | 
					      my_test();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /* USER CODE END 3 */
 | 
					  /* USER CODE END 3 */
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,8 @@
 | 
				
			|||||||
/* USER CODE BEGIN Includes */
 | 
					/* USER CODE BEGIN Includes */
 | 
				
			||||||
#include "variable.h"
 | 
					#include "variable.h"
 | 
				
			||||||
#include "hc595.h"
 | 
					#include "hc595.h"
 | 
				
			||||||
 | 
					#include "SegLed.h"
 | 
				
			||||||
 | 
					#include "MatrixKey.h"
 | 
				
			||||||
/* USER CODE END Includes */
 | 
					/* USER CODE END Includes */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Private typedef -----------------------------------------------------------*/
 | 
					/* Private typedef -----------------------------------------------------------*/
 | 
				
			||||||
@ -62,6 +64,11 @@ extern TIM_HandleTypeDef htim3;
 | 
				
			|||||||
extern stSysTickTimer sSysTickTimer;
 | 
					extern stSysTickTimer sSysTickTimer;
 | 
				
			||||||
extern structTime stTime;
 | 
					extern structTime stTime;
 | 
				
			||||||
extern void Display(void);
 | 
					extern void Display(void);
 | 
				
			||||||
 | 
					extern uint16_t mPos;
 | 
				
			||||||
 | 
					extern uint16_t mNum;
 | 
				
			||||||
 | 
					extern uint8_t tempValue;
 | 
				
			||||||
 | 
					extern uint8_t KeyValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* USER CODE END EV */
 | 
					/* USER CODE END EV */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/******************************************************************************/
 | 
					/******************************************************************************/
 | 
				
			||||||
@ -195,9 +202,20 @@ void SysTick_Handler(void)
 | 
				
			|||||||
  if (++sSysTickTimer.mMilSecCount >= 10) {
 | 
					  if (++sSysTickTimer.mMilSecCount >= 10) {
 | 
				
			||||||
    sSysTickTimer.mMilSecCount = 0;
 | 
					    sSysTickTimer.mMilSecCount = 0;
 | 
				
			||||||
    sSysTickTimer.bTenMilSecOk = 1;
 | 
					    sSysTickTimer.bTenMilSecOk = 1;
 | 
				
			||||||
 | 
					    KeyValue = MatrixKeyScan();
 | 
				
			||||||
 | 
					    if (KeyValue != NO_KEY) {
 | 
				
			||||||
 | 
					      for (int i = 0; i < 16; i++) {
 | 
				
			||||||
 | 
					        if (KeyValue == KeyTable[i]) {
 | 
				
			||||||
 | 
					          tempValue = i;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      DispToBuff(tempValue);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (++sSysTickTimer.mTimeCount >= 100) {
 | 
					    if (++sSysTickTimer.mTimeCount >= 100) {
 | 
				
			||||||
      sSysTickTimer.mTimeCount = 0;
 | 
					      sSysTickTimer.mTimeCount = 0;
 | 
				
			||||||
      sSysTickTimer.bTimeOk = 1;
 | 
					      sSysTickTimer.bTimeOk = 1;
 | 
				
			||||||
 | 
					      if(++mNum>=19)
 | 
				
			||||||
 | 
					        mNum=15;	
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /* USER CODE END SysTick_IRQn 1 */
 | 
					  /* USER CODE END SysTick_IRQn 1 */
 | 
				
			||||||
@ -227,6 +245,16 @@ void TIM3_IRQHandler(void)
 | 
				
			|||||||
    if (++stTime.mTimeCount >= 100) {
 | 
					    if (++stTime.mTimeCount >= 100) {
 | 
				
			||||||
      stTime.mTimeCount = 0;
 | 
					      stTime.mTimeCount = 0;
 | 
				
			||||||
      stTime.bSecondIsOk = 1;
 | 
					      stTime.bSecondIsOk = 1;
 | 
				
			||||||
 | 
					      TimeToBuff(&stTime);
 | 
				
			||||||
 | 
					      if (++stTime.mSecond >= 60) {
 | 
				
			||||||
 | 
					        stTime.mSecond = 0;
 | 
				
			||||||
 | 
					        if (++stTime.mMinute >= 60) {
 | 
				
			||||||
 | 
					          stTime.mMinute = 0;
 | 
				
			||||||
 | 
					          if (++stTime.mHour >= 24) {
 | 
				
			||||||
 | 
					            stTime.mHour = 0;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  /* USER CODE END TIM3_IRQn 1 */
 | 
					  /* USER CODE END TIM3_IRQn 1 */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user