Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.39 KB | None | 0 0
  1. #include "Board_GLCD.h"
  2. #include "Board_LED.h"
  3. #include "stm32f2xx_hal.h"
  4. #include "GLCD_Config.h"
  5. #include "JOY.h"
  6. #include "Serial.h"
  7.  
  8. extern GLCD_FONT GLCD_Font_16x24;
  9. uint32_t fw,fh,dx,dy;
  10. bool ready;
  11.  
  12. /**Initialize the peripherals: Already Done**/
  13. void setup(void){
  14.     GLCD_Initialize();
  15.     LED_Initialize();
  16.     JOY_Init();
  17.     SER_Init(115200);
  18.     GLCD_SetFont(&GLCD_Font_16x24);
  19.     GLCD_SetBackgroundColor(GLCD_COLOR_PURPLE);
  20.     fw = GLCD_Font_16x24.width;// font width
  21.     fh = GLCD_Font_16x24.height; //font height
  22.     //minimum x position on the screen. Corresponds to column 0
  23.     dx = (GLCD_WIDTH - 16*fw)>>1;
  24.     //minimum y position on the screen. Corresponds to row 0
  25.     dy = (GLCD_HEIGHT - 6 * fh) >> 1;
  26.     //use to prevent Joy stick sampling when the joy stick has not be initialized
  27.     ready = true;
  28. }
  29.  
  30. /**Checks if the direction of the joy stick and move the cursor in the joy stick's direction. If the cursor is at the bounds, cursor will not be moved**/
  31. void sampleJoystick(void){
  32.    
  33.         if(!ready)return;   //initialization has not completed, abort
  34.             uint32_t key = JOY_GetKeys();
  35.  
  36. // Put code here //
  37.        
  38. }
  39.  
  40.  
  41. /**Draw ascii characters on the screen**/
  42. void draw(void){
  43.  
  44.     GLCD_DrawChar(0, 0, 0x36);
  45.     GLCD_DrawChar(18, 0, 0x39);
  46. }
  47.  
  48. int main(void){
  49.     SystemCoreClockUpdate();
  50.         HAL_Init();
  51.         SysTick_Config(SystemCoreClock/1000);
  52.         setup();
  53.         GLCD_ClearScreen();
  54.         draw();
  55.    
  56.  
  57. // Add Additional lines of code if required //
  58.  
  59.         while(1){}
  60. }
  61.  
  62.  
  63. /*SysTick ISR*/
  64. void SysTick_Handler(void){
  65.     //increment HAL tick variable; this is required for LCD Display Config.
  66.     HAL_IncTick();
  67.     //check for joy stick movement to configure Joystick Sampling
  68.     sampleJoystick();
  69. }
  70.  
  71.  
  72.  
  73.  
  74. /**Highlight the character c in the 16x6 grid **/
  75. void highlightText(uint32_t c){
  76.  
  77. // Put code here //
  78.    
  79. }
  80.  
  81.  
  82.  
  83. /**Convert row and column to actual x y position: p[0] = column p[1] = row **/
  84. void toPosition(int * p){
  85.  
  86. // Put code here //
  87.  
  88. }
  89.  
  90.  
  91.  
  92. /**Fill the array p with the row and column number of the character ch: p[0] column p[1] = row **/
  93. void getPos(uint32_t ch,int *p){
  94.    
  95. // Put code here //
  96.  
  97. }
  98.  
  99.  
  100. /**Toggle the LED based on the bits of the character c.
  101. 1 LED will be turned on
  102. 0 LED will be turned off **/
  103. void LED (uint32_t c){
  104.    
  105. // Put code here //
  106.            
  107. }
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /** Clear any previous highlight and highlight c **/
  114. void ClearHighlight(uint32_t c){
  115.  
  116. // Put code here //
  117.    
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement