]> mj.ucw.cz Git - home-hw.git/commitdiff
Display debugged
authorMartin Mares <mj@ucw.cz>
Sun, 24 Jun 2018 23:31:32 +0000 (01:31 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 24 Jun 2018 23:31:32 +0000 (01:31 +0200)
Src/display.c

index 06c5fe22aff217f9ccb761f2a73e19d87a7cd737..3ef49bca14a8b1f41ce300debc1724abf53a6e27 100644 (file)
@@ -56,8 +56,7 @@ static const byte display_init_cmds[] = {
   SSD1306_SETCONTRAST, 0x7F,         // contrast level 127
   SSD1306_SETPRECHARGE, 0xF1,        // pre-charge period (1, 15)
   SSD1306_SETVCOMDETECT, 0x40,       // vcomh regulator level-
-  // SSD1306_DISPLAYALLON_RESUME,
-  SSD1306_DISPLAYALLON,
+  SSD1306_DISPLAYALLON_RESUME,
   SSD1306_NORMALDISPLAY,
   SSD1306_DISPLAYON,
 };
@@ -80,6 +79,8 @@ static void display_cmd(byte cmd)
   LL_I2C_ClearFlag_ADDR(I2C2);
   display_send_byte(0x00);                     // Will send a command
   display_send_byte(cmd);
+  while (!LL_I2C_IsActiveFlag_TXE(I2C2))
+    ;
   LL_I2C_GenerateStopCondition(I2C2);
 }
 
@@ -102,6 +103,8 @@ static void display_data(byte d)
 
 static void display_data_end(void)
 {
+  while (!LL_I2C_IsActiveFlag_TXE(I2C2))
+    ;
   LL_I2C_GenerateStopCondition(I2C2);
 }
 
@@ -128,7 +131,6 @@ void display_init(void)
 
 void display_counter(uint cnt)
 {
-#if 0
   byte d[5];
   for (uint i=0; i<5; i++)
     {
@@ -155,5 +157,4 @@ void display_counter(uint cnt)
        }
       display_data_end();
     }
-#endif
 }