tdse-tf_3-02

Controlador PID para derretidor de miel con control local via botones y remoto via WiFi
Index Commits Files Refs Submodules README
commit 35c8d0a59126ce89555c9747b03cb65c050da664
parent 2068d6e7d5126387f761357f57dcd6b450dbb27e
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date:   Sun,  3 May 2026 21:05:34 -0300

Reescribir secuencia de inicializacion del display

Diffstat:
Mfirmware-nucleo/App/Src/display_i2c.c | 94++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 48 insertions(+), 46 deletions(-)
diff --git a/firmware-nucleo/App/Src/display_i2c.c b/firmware-nucleo/App/Src/display_i2c.c
@@ -13,36 +13,43 @@
 #include "dwt.h"
 #include "systick.h"
 
-#define DISPLAY_I2C_ADDRESS        0x27
-#define DISPLAY_ASYNC_QUEUE_LEN    256
-#define DISPLAY_ASYNC_CLEAR_DEL_MS 2ul
-
-#define DISPLAY_CMD_CLEAR_DISPLAY   0b00000001
-#define DISPLAY_CMD_SET_CURSOR_HOME 0b00000010
-#define DISPLAY_CMD_ENTRY_MODE_SET  0b00000100
-#define DISPLAY_CMD_DISPLAY_CONTROL 0b00001000
-#define DISPLAY_CMD_FUNCTION_SET    0b00100000
-#define DISPLAY_DDRAM_ADDR          0b10000000
-
-#define DISPLAY_CMD_FUNCTION_SET_8BITS    0b00010000
-#define DISPLAY_CMD_FUNCTION_SET_4BITS    0b00100000
-#define DISPLAY_CMD_FUNCTION_SET_5x8DOTS  0b00000000
-#define DISPLAY_CMD_FUNCTION_SET_2LINES   0b00001000
-
-#define DISPLAY_CMD_ENTRY_MODE_SET_INCREMENT_CURSOR 0b00000010
-#define DISPLAY_CMD_ENTRY_MODE_SET_DECREMENT_CURSOR 0b00000000
-#define DISPLAY_CMD_ENTRY_MODE_SET_SHIFT            0b00000001
-#define DISPLAY_CMD_ENTRY_MODE_SET_NO_SHIFT         0b00000000
-
-#define DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_ON  0b00000100
-#define DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_OFF 0b00000000
-#define DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_ON   0b00000010
-#define DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_OFF  0b00000000
-#define DISPLAY_CMD_DISPLAY_CONTROL_BLINK_ON    0b00000001
-#define DISPLAY_CMD_DISPLAY_CONTROL_BLINK_OFF   0b00000000
+#define DISPLAY_I2C_ADDRESS         0x27
+#define DISPLAY_ASYNC_QUEUE_LEN     256
+#define DISPLAY_ASYNC_CLEAR_DEL_MS  2ul
 #define DISPLAY_TICK_CNT_INI_MS     0ul
 #define DISPLAY_TICK_DMA_TIMEOUT_MS 100ul
 
+#define DISPLAY_INIT_SET_8BIT 0x03
+#define DISPLAY_INIT_SET_4BIT   0x02
+
+#define DISPLAY_CMD_CLEAR_DISPLAY   0x01
+#define DISPLAY_CMD_SET_CURSOR_HOME 0x02
+#define DISPLAY_CMD_ENTRY_MODE_SET  0x04
+#define DISPLAY_CMD_DISPLAY_CONTROL 0x08
+#define DISPLAY_CMD_SHIFT_CONTROL   0x10
+#define DISPLAY_CMD_FUNCTION_SET    0x20
+#define DISPLAY_CGRAM_ADDR          0x40
+#define DISPLAY_DDRAM_ADDR          0x80
+
+#define DISPLAY_CMD_FUNCTION_SET_8BITS    0x10
+#define DISPLAY_CMD_FUNCTION_SET_4BITS    0x00
+#define DISPLAY_CMD_FUNCTION_SET_5x8DOTS  0x00
+#define DISPLAY_CMD_FUNCTION_SET_2LINES   0x08
+#define DISPLAY_CMD_FUNCTION_SET_1LINE    0x00
+#define DISPLAY_CMD_FUNCTION_SET_5x10DOTS 0x04
+
+#define DISPLAY_CMD_ENTRY_MODE_SET_INCREMENT_CURSOR 0x02
+#define DISPLAY_CMD_ENTRY_MODE_SET_DECREMENT_CURSOR 0x00
+#define DISPLAY_CMD_ENTRY_MODE_SET_SHIFT            0x01
+#define DISPLAY_CMD_ENTRY_MODE_SET_NO_SHIFT         0x00
+
+#define DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_ON   0x04
+#define DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_OFF  0x00
+#define DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_ON    0x02
+#define DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_OFF   0x00
+#define DISPLAY_CMD_DISPLAY_CONTROL_BLINK_ON     0x01
+#define DISPLAY_CMD_DISPLAY_CONTROL_BLINK_OFF    0x00
+
 #define DISPLAY_LINE1_FIRST_CHAR_ADDR 0
 #define DISPLAY_LINE2_FIRST_CHAR_ADDR 64
 #define DISPLAY_LINE3_FIRST_CHAR_ADDR 20
@@ -87,47 +94,41 @@ void display_i2c_init(void)
 {
     HAL_Delay(50);
 
-    display_i2c_send_cmd(DISPLAY_CMD_FUNCTION_SET |
-                         DISPLAY_CMD_FUNCTION_SET_8BITS);
+    display_i2c_send_cmd(DISPLAY_INIT_SET_8BIT);
     HAL_Delay(5);
 
-    display_i2c_send_cmd(DISPLAY_CMD_FUNCTION_SET |
-                         DISPLAY_CMD_FUNCTION_SET_8BITS);
-    HAL_Delay(2);
+    display_i2c_send_cmd(DISPLAY_INIT_SET_8BIT);
+    HAL_Delay(1);
 
-    display_i2c_send_cmd(DISPLAY_CMD_FUNCTION_SET |
-                         DISPLAY_CMD_FUNCTION_SET_8BITS);
-    HAL_Delay(2);
+    display_i2c_send_cmd(DISPLAY_INIT_SET_8BIT);
+    HAL_Delay(1);
 
-    display_i2c_send_cmd(DISPLAY_CMD_FUNCTION_SET |
-                         DISPLAY_CMD_FUNCTION_SET_4BITS);
-    HAL_Delay(2);
+    display_i2c_send_cmd(DISPLAY_INIT_SET_4BIT);
+    HAL_Delay(1);
 
     display_i2c_send_cmd(DISPLAY_CMD_FUNCTION_SET |
                          DISPLAY_CMD_FUNCTION_SET_4BITS |
                          DISPLAY_CMD_FUNCTION_SET_2LINES |
                          DISPLAY_CMD_FUNCTION_SET_5x8DOTS);
-    HAL_Delay(2);
+    HAL_Delay(1);
 
     display_i2c_send_cmd(DISPLAY_CMD_DISPLAY_CONTROL |
-                         DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_OFF |
-                         DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_OFF |
-                         DISPLAY_CMD_DISPLAY_CONTROL_BLINK_OFF);
-    HAL_Delay(2);
+                         DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_OFF);
+    HAL_Delay(1);
 
     display_i2c_send_cmd(DISPLAY_CMD_CLEAR_DISPLAY);
-    HAL_Delay(2);
+    HAL_Delay(1);
 
     display_i2c_send_cmd(DISPLAY_CMD_ENTRY_MODE_SET |
                          DISPLAY_CMD_ENTRY_MODE_SET_INCREMENT_CURSOR |
                          DISPLAY_CMD_ENTRY_MODE_SET_NO_SHIFT);
-    HAL_Delay(2);
+    HAL_Delay(1);
 
     display_i2c_send_cmd(DISPLAY_CMD_DISPLAY_CONTROL |
                          DISPLAY_CMD_DISPLAY_CONTROL_DISPLAY_ON |
                          DISPLAY_CMD_DISPLAY_CONTROL_CURSOR_OFF |
                          DISPLAY_CMD_DISPLAY_CONTROL_BLINK_OFF);
-    HAL_Delay(2);
+    HAL_Delay(1);
 
     b_display_i2c_dma_done = true;
     g_display_i2c_tick = DISPLAY_TICK_CNT_INI_MS;
@@ -238,6 +239,7 @@ void display_i2c_async_tick(void)
             }
 
             display_i2c_async_write(curr_tx_data);
+        }
     }
 }