Subversion Repositories CharLCD

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. extern "C"
  2. {
  3. #include "main.h"
  4. }
  5.  
  6. #include "runner.h"
  7.  
  8. #include "libCharLCD/lcd.h"
  9.  
  10. #if defined __cplusplus
  11. extern "C"
  12. {
  13. #endif
  14.  
  15.     lcd_t lcd(LCD_40X2,
  16.               {rsBit_GPIO_Port, rsBit_Pin},
  17.               {rwBit_GPIO_Port, rwBit_Pin},
  18.               {eBit_GPIO_Port, eBit_Pin}, lcdDataLines_t{{lcd_D0_GPIO_Port, lcd_D0_Pin}, {lcd_D1_GPIO_Port, lcd_D1_Pin}, {lcd_D2_GPIO_Port, lcd_D2_Pin}, {lcd_D3_GPIO_Port, lcd_D3_Pin}});
  19.  
  20.     void initialise()
  21.     {
  22.         uint8_t def[] = {0, 0, 0, 0, 0, 0, 0, 0};
  23.         lcd.init();
  24.         lcd.clear();
  25.         lcd.enable(true);
  26.         for (int i = 0; i < 8; i++)
  27.         {
  28.             for (int j = 7; j >= 0; j--)
  29.             {
  30.                 if (j == 7)
  31.                 {
  32.                     def[j] = 0b11111;
  33.                     continue;
  34.                 }
  35.                 if (j == (7-i))
  36.                 {
  37.                     def[j] = 0b01110;
  38.                     continue;
  39.                 }
  40.                 if (j < (7-i))
  41.                 {
  42.                     def[j] = 0b00000;
  43.                     continue;
  44.                 }
  45.                
  46.                 def[j] = (j&1) ? 0b11001 : 0b10011;
  47.             }
  48.  
  49.             lcd.defineChar(i, def);
  50.         }
  51.     }
  52.  
  53.     uint8_t base = 0;
  54.     void runner()
  55.     {
  56.         char buf2[40];
  57.         lcd.gotoxy(0, 0);
  58.         lcd.printString("hello");
  59.         lcd.gotoxy(0, 1);
  60.         for (uint8_t i = 0; i < 40; i++)
  61.             buf2[i] = base + i;
  62.  
  63.         lcd.printString(buf2, 40);
  64.         HAL_Delay(200);
  65.          base++;
  66.     }
  67.  
  68. #if defined __cplusplus
  69. }
  70. #endif
  71.