Browse Source

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

Marcio Teixeira 6 years ago
parent
commit
08f21335a6

+ 38
- 2
Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_st7920_sw_spi.cpp View File

99
     spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
99
     spiSend_sw_DUE(rs ? 0x0FA : 0x0F8); // Command or Data
100
     DELAY_US(40); // give the controller some time to process the data: 20 is bad, 30 is OK, 40 is safe
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
   spiSend_sw_DUE(val << 4);
103
   spiSend_sw_DUE(val << 4);
104
 }
104
 }
105
 
105
 
168
   return 1;
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
 #endif // ARDUINO_ARCH_SAM
209
 #endif // ARDUINO_ARCH_SAM

+ 1
- 31
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp View File

158
 // function for scroll_or_addr_select()
158
 // function for scroll_or_addr_select()
159
 void ST7920_Lite_Status_Screen::_scroll_or_addr_select(const bool sa) {
159
 void ST7920_Lite_Status_Screen::_scroll_or_addr_select(const bool sa) {
160
   extended_function_set(true);
160
   extended_function_set(true);
161
-  cmd(0b00100010 |
162
-    (sa   ? 0b000001 : 0)
163
-  );
161
+  cmd(0b00000010 | (sa ? 0b00000001 : 0));
164
   current_bits.sa = sa;
162
   current_bits.sa = sa;
165
 }
163
 }
166
 
164
 
907
   ncs();
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
 void MarlinUI::draw_status_screen() {
908
 void MarlinUI::draw_status_screen() {
939
   ST7920_Lite_Status_Screen::update(false);
909
   ST7920_Lite_Status_Screen::update(false);
940
 }
910
 }

+ 7
- 5
Marlin/src/lcd/dogm/status_screen_lite_ST7920.h View File

15
  */
15
  */
16
 #pragma once
16
 #pragma once
17
 
17
 
18
+#include "../../HAL/shared/HAL_ST7920.h"
19
+
18
 #include "../../core/macros.h"
20
 #include "../../core/macros.h"
19
 #include "../../libs/duration_t.h"
21
 #include "../../libs/duration_t.h"
20
 
22
 
28
       uint8_t sa       : 1;
30
       uint8_t sa       : 1;
29
     } current_bits;
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
     FORCE_INLINE static void write_word(const uint16_t w) {
39
     FORCE_INLINE static void write_word(const uint16_t w) {
38
       write_byte((w >> 8) & 0xFF);
40
       write_byte((w >> 8) & 0xFF);

+ 9
- 0
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp View File

134
 
134
 
135
 #pragma GCC reset_options
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
 #endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__
146
 #endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__

Loading…
Cancel
Save