浏览代码

Fix bad opcode in LIGHTWEIGHT_UI; add 32-bit HAL and Due compatibility (#13751)

Marcio Teixeira 5 年前
父节点
当前提交
08f21335a6

+ 38
- 2
Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp 查看文件

@@ -99,7 +99,7 @@ static void u8g_com_DUE_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
99 99
     spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
100 100
     DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
101 101
   }
102
-  spiSend_sw_DUE(val & 0x0F0);
102
+  spiSend_sw_DUE(val & 0xF0);
103 103
   spiSend_sw_DUE(val << 4);
104 104
 }
105 105
 
@@ -168,6 +168,42 @@ uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_va
168 168
   return 1;
169 169
 }
170 170
 
171
-#endif // HAS_GRAPHICAL_LCD
171
+#if ENABLED(LIGHTWEIGHT_UI)
172
+  #include "../../lcd/ultralcd.h"
173
+  #include "../shared/HAL_ST7920.h"
174
+
175
+  #define ST7920_CS_PIN LCD_PINS_RS
176
+
177
+  #if DOGM_SPI_DELAY_US > 0
178
+    #define U8G_DELAY() DELAY_US(DOGM_SPI_DELAY_US)
179
+  #else
180
+    #define U8G_DELAY() DELAY_US(10)
181
+  #endif
182
+
183
+  void ST7920_cs() {
184
+    WRITE(ST7920_CS_PIN, HIGH);
185
+    U8G_DELAY();
186
+  }
187
+
188
+  void ST7920_ncs() {
189
+    WRITE(ST7920_CS_PIN, LOW);
190
+  }
172 191
 
192
+  void ST7920_set_cmd() {
193
+    spiSend_sw_DUE(0xF8);
194
+    DELAY_US(40);
195
+  }
196
+
197
+  void ST7920_set_dat() {
198
+    spiSend_sw_DUE(0xFA);
199
+    DELAY_US(40);
200
+  }
201
+
202
+  void ST7920_write_byte(const uint8_t val) {
203
+    spiSend_sw_DUE(val & 0xF0);
204
+    spiSend_sw_DUE(val << 4);
205
+  }
206
+#endif // LIGHTWEIGHT_UI
207
+
208
+#endif // HAS_GRAPHICAL_LCD
173 209
 #endif // ARDUINO_ARCH_SAM

+ 1
- 31
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp 查看文件

@@ -158,9 +158,7 @@ void ST7920_Lite_Status_Screen::entry_mode_select(const bool ac_increase, const
158 158
 // function for scroll_or_addr_select()
159 159
 void ST7920_Lite_Status_Screen::_scroll_or_addr_select(const bool sa) {
160 160
   extended_function_set(true);
161
-  cmd(0b00100010 |
162
-    (sa   ? 0b000001 : 0)
163
-  );
161
+  cmd(0b00000010 | (sa ? 0b00000001 : 0));
164 162
   current_bits.sa = sa;
165 163
 }
166 164
 
@@ -907,34 +905,6 @@ void ST7920_Lite_Status_Screen::clear_text_buffer() {
907 905
   ncs();
908 906
 }
909 907
 
910
-#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
911
-
912
-  #include "ultralcd_st7920_u8glib_rrd_AVR.h"
913
-
914
-  void ST7920_Lite_Status_Screen::cs() {
915
-    ST7920_CS();
916
-    current_bits.synced = false;
917
-  }
918
-
919
-  void ST7920_Lite_Status_Screen::ncs() {
920
-    ST7920_NCS();
921
-    current_bits.synced = false;
922
-  }
923
-
924
-  void ST7920_Lite_Status_Screen::sync_cmd() {
925
-    ST7920_SET_CMD();
926
-  }
927
-
928
-  void ST7920_Lite_Status_Screen::sync_dat() {
929
-    ST7920_SET_DAT();
930
-  }
931
-
932
-  void ST7920_Lite_Status_Screen::write_byte(const uint8_t data) {
933
-    ST7920_WRITE_BYTE(data);
934
-  }
935
-
936
-#endif
937
-
938 908
 void MarlinUI::draw_status_screen() {
939 909
   ST7920_Lite_Status_Screen::update(false);
940 910
 }

+ 7
- 5
Marlin/src/lcd/dogm/status_screen_lite_ST7920.h 查看文件

@@ -15,6 +15,8 @@
15 15
  */
16 16
 #pragma once
17 17
 
18
+#include "../../HAL/shared/HAL_ST7920.h"
19
+
18 20
 #include "../../core/macros.h"
19 21
 #include "../../libs/duration_t.h"
20 22
 
@@ -28,11 +30,11 @@ class ST7920_Lite_Status_Screen {
28 30
       uint8_t sa       : 1;
29 31
     } current_bits;
30 32
 
31
-    static void cs();
32
-    static void ncs();
33
-    static void sync_cmd();
34
-    static void sync_dat();
35
-    static void write_byte(const uint8_t w);
33
+    static void cs()                        { ST7920_cs(); current_bits.synced = false; }
34
+    static void ncs()                       { ST7920_cs(); current_bits.synced = false; }
35
+    static void sync_cmd()                  { ST7920_set_cmd(); }
36
+    static void sync_dat()                  { ST7920_set_dat(); }
37
+    static void write_byte(const uint8_t w) { ST7920_write_byte(w); }
36 38
 
37 39
     FORCE_INLINE static void write_word(const uint16_t w) {
38 40
       write_byte((w >> 8) & 0xFF);

+ 9
- 0
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp 查看文件

@@ -134,4 +134,13 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g
134 134
 
135 135
 #pragma GCC reset_options
136 136
 
137
+#if ENABLED(LIGHTWEIGHT_UI)
138
+  #include "../../HAL/shared/HAL_ST7920.h"
139
+  void ST7920_cs()                          { ST7920_CS(); }
140
+  void ST7920_ncs()                         { ST7920_NCS(); }
141
+  void ST7920_set_cmd()                     { ST7920_SET_CMD(); }
142
+  void ST7920_set_dat()                     { ST7920_SET_DAT(); }
143
+  void ST7920_write_byte(const uint8_t val) { ST7920_WRITE_BYTE(val); }
144
+#endif
145
+
137 146
 #endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__

正在加载...
取消
保存