Browse Source

Add LULZBOT_TOUCH_UI (#14967)

Marcio Teixeira 4 years ago
parent
commit
274934ad81
100 changed files with 12526 additions and 28 deletions
  1. 6
    0
      Marlin/Configuration.h
  2. 47
    0
      Marlin/Configuration_adv.h
  3. 1
    1
      Marlin/src/HAL/HAL_DUE/fastio_Due.h
  4. 6
    6
      Marlin/src/HAL/HAL_DUE/usb/compiler.h
  5. 4
    4
      Marlin/src/HAL/HAL_LINUX/include/serial.h
  6. 2
    2
      Marlin/src/HAL/HAL_SAMD51/Servo_SAMD51.cpp
  7. 1
    1
      Marlin/src/HAL/HAL_STM32/fastio_STM32.h
  8. 2
    2
      Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h
  9. 6
    6
      Marlin/src/core/macros.h
  10. 2
    2
      Marlin/src/core/serial.h
  11. 1
    1
      Marlin/src/feature/leds/leds.cpp
  12. 1
    1
      Marlin/src/gcode/calibrate/G33.cpp
  13. 1
    1
      Marlin/src/gcode/calibrate/G34_M422.cpp
  14. 1
    1
      Marlin/src/inc/Conditionals_LCD.h
  15. 3
    0
      Marlin/src/inc/Conditionals_adv.h
  16. 1
    0
      Marlin/src/inc/SanityCheck.h
  17. 560
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.cpp
  18. 110
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h
  19. 63
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.cpp
  20. 44
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h
  21. 61
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h
  22. 98
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h
  23. 674
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/LICENSE.txt
  24. 28
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/README.md
  25. 183
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/boards.h
  26. 1174
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp
  27. 258
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.h
  28. 411
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/constants.h
  29. 118
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/display_list.h
  30. 40
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/ftdi_basic.h
  31. 150
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/registers_ft800.h
  32. 185
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/registers_ft810.h
  33. 128
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/resolutions.h
  34. 178
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/spi.cpp
  35. 128
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/spi.h
  36. 211
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h
  37. 49
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/bitmap_info.h
  38. 29
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/command_processor.cpp
  39. 347
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/command_processor.h
  40. 176
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/dl_cache.cpp
  41. 69
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/dl_cache.h
  42. 230
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/event_loop.cpp
  43. 74
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/event_loop.h
  44. 45
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/ftdi_extended.h
  45. 98
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/grid_layout.h
  46. 96
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/polygon.h
  47. 44
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/rgb_t.h
  48. 106
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/screen_types.cpp
  49. 215
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/screen_types.h
  50. 38
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_list.h
  51. 111
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_player.cpp
  52. 70
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_player.h
  53. 129
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/text_box.cpp
  54. 30
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/text_box.h
  55. 51
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/tiny_timer.cpp
  56. 56
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/tiny_timer.h
  57. 100
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/circular_progress.h
  58. 395
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/poly_ui.h
  59. 278
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/svg2cpp.py
  60. 27
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/ftdi_eve_lib.h
  61. 128
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/marlin_events.cpp
  62. 142
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/pin_mappings.h
  63. 80
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/about_screen.cpp
  64. 191
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/advanced_settings_menu.cpp
  65. 70
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/alert_dialog_box.cpp
  66. 72
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/backlash_compensation_screen.cpp
  67. 342
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_numeric_adjustment_screen.cpp
  68. 83
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp
  69. 137
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_advanced_settings.cpp
  70. 56
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_confirm_home_e.cpp
  71. 53
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_confirm_home_xyz.cpp
  72. 79
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_main_menu.cpp
  73. 75
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_printer_ui.h
  74. 155
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_printing_dialog_box.cpp
  75. 349
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp
  76. 87
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_tune_menu.cpp
  77. 113
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/boot_screen.cpp
  78. 323
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/change_filament_screen.cpp
  79. 47
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_abort_print_dialog_box.cpp
  80. 48
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_auto_calibration_dialog_box.cpp
  81. 54
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_erase_flash_dialog_box.cpp
  82. 58
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_user_request_alert_box.cpp
  83. 63
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/default_acceleration_screen.cpp
  84. 150
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/developer_menu.cpp
  85. 83
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/dialog_box_base_class.cpp
  86. 61
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/display_tuning_screen.cpp
  87. 155
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp
  88. 52
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/feedrate_percent_screen.cpp
  89. 101
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/filament_menu.cpp
  90. 65
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/filament_runout_screen.cpp
  91. 264
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/files_screen.cpp
  92. 285
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/interface_settings_screen.cpp
  93. 160
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/interface_sounds_screen.cpp
  94. 65
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/jerk_screen.cpp
  95. 54
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/junction_deviation_screen.cpp
  96. 62
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/kill_screen.cpp
  97. 77
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/linear_advance_screen.cpp
  98. 214
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/lock_screen.cpp
  99. 123
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/main_menu.cpp
  100. 0
    0
      Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/max_acceleration_screen.cpp

+ 6
- 0
Marlin/Configuration.h View File

@@ -2034,6 +2034,12 @@
2034 2034
 //#define MALYAN_LCD
2035 2035
 
2036 2036
 //
2037
+// LulzBot Color Touch UI for FTDI EVE (FT800/FT810) displays
2038
+// See Configuration_adv.h for all configuration options.
2039
+//
2040
+//#defined LULZBOT_TOUCH_UI
2041
+
2042
+//
2037 2043
 // Third-party or vendor-customized controller interfaces.
2038 2044
 // Sources should be installed in 'src/lcd/extensible_ui'.
2039 2045
 //

+ 47
- 0
Marlin/Configuration_adv.h View File

@@ -1143,6 +1143,53 @@
1143 1143
 
1144 1144
 #endif // HAS_GRAPHICAL_LCD
1145 1145
 
1146
+//
1147
+// Lulzbot Touch UI
1148
+//
1149
+#if ENABLED(LULZBOT_TOUCH_UI)
1150
+  // Display board used
1151
+  //#define LCD_FTDI_VM800B35A        // FTDI 3.5" with FT800 (320x240)
1152
+  //#define LCD_4DSYSTEMS_4DLCD_FT843 // 4D Systems 4.3" (480x272)
1153
+  //#define LCD_HAOYU_FT800CB         // Haoyu with 4.3" or 5" (480x272)
1154
+  //#define LCD_HAOYU_FT810CB         // Haoyu with 5" (800x480)
1155
+  //#define LCD_ALEPHOBJECTS_CLCD_UI  // Aleph Objects Color LCD UI
1156
+
1157
+  // Correct the resolution if not using the stock TFT panel.
1158
+  //#define TOUCH_UI_320x240
1159
+  //#define TOUCH_UI_480x272
1160
+  //#define TOUCH_UI_800x480
1161
+
1162
+  // Mappings for boards with a standard RepRapDiscount Display connector
1163
+  //#define AO_EXP1_PINMAP    // AlephObjects CLCD UI EXP1 mapping
1164
+  //#define AO_EXP2_PINMAP    // AlephObjects CLCD UI EXP2 mapping
1165
+  //#define CR10_TFT_PINMAP   // Rudolph Riedel's CR10 pin mapping
1166
+  //#define OTHER_PIN_LAYOUT  // Define pins manually below
1167
+  #if ENABLED(OTHER_PIN_LAYOUT)
1168
+    // The pins for CS and MOD_RESET (PD) must be chosen.
1169
+    #define CLCD_MOD_RESET  9
1170
+    #define CLCD_SPI_CS    10
1171
+
1172
+    // If using software SPI, specify pins for SCLK, MOSI, MISO
1173
+    //#define CLCD_USE_SOFT_SPI
1174
+    #if ENABLED(CLCD_USE_SOFT_SPI)
1175
+      #define CLCD_SOFT_SPI_MOSI 11
1176
+      #define CLCD_SOFT_SPI_MISO 12
1177
+      #define CLCD_SOFT_SPI_SCLK 13
1178
+    #endif
1179
+  #endif
1180
+
1181
+  // Display Orientation. An inverted (i.e. upside-down) display
1182
+  // is supported on the FT800. The FT810 and beyond also support
1183
+  // portrait and mirrored orientations.
1184
+  //#define TOUCH_UI_INVERTED
1185
+  //#define TOUCH_UI_PORTRAIT
1186
+  //#define TOUCH_UI_MIRRORED
1187
+
1188
+  // Use a numeric passcode for "Screen lock" keypad.
1189
+  // (recommended for smaller displays)
1190
+  //#define TOUCH_UI_PASSCODE
1191
+#endif
1192
+
1146 1193
 // @section safety
1147 1194
 
1148 1195
 /**

+ 1
- 1
Marlin/src/HAL/HAL_DUE/fastio_Due.h View File

@@ -70,7 +70,7 @@
70 70
   const uint32_t mask = MASK(DIO ## IO ## _PIN); \
71 71
   if (V) port->PIO_SODR = mask; \
72 72
   else port->PIO_CODR = mask; \
73
-} while(0)
73
+}while(0)
74 74
 
75 75
 // Toggle a pin
76 76
 #define _TOGGLE(IO) _WRITE(IO, !READ(IO))

+ 6
- 6
Marlin/src/HAL/HAL_DUE/usb/compiler.h View File

@@ -112,7 +112,7 @@
112 112
  * \def unused
113 113
  * \brief Marking \a v as a unused parameter or value.
114 114
  */
115
-#define unused(v)          do { (void)(v); } while(0)
115
+#define unused(v)          do { (void)(v); }while(0)
116 116
 
117 117
 /**
118 118
  * \def barrier
@@ -169,7 +169,7 @@
169 169
  * heuristics and inline the function no matter how big it thinks it
170 170
  * becomes.
171 171
  */
172
-#if defined(__CC_ARM)
172
+#ifdef __CC_ARM
173 173
 #   define __always_inline   __forceinline
174 174
 #elif (defined __GNUC__)
175 175
 #ifdef __always_inline
@@ -187,7 +187,7 @@
187 187
  * This annotation instructs the compiler to ignore its inlining
188 188
  * heuristics and not inline the function.
189 189
  */
190
-#if defined(__CC_ARM)
190
+#ifdef __CC_ARM
191 191
 #   define __no_inline   __attribute__((noinline))
192 192
 #elif (defined __GNUC__)
193 193
 #	define __no_inline   __attribute__((__noinline__))
@@ -204,7 +204,7 @@
204 204
  *
205 205
  * \param expr  Expression to evaluate and supposed to be nonzero.
206 206
  */
207
-#if defined(_ASSERT_ENABLE_)
207
+#ifdef _ASSERT_ENABLE_
208 208
 #  if defined(TEST_SUITE_DEFINE_ASSERT_MACRO)
209 209
      // Assert() is defined in unit_test/suite.h
210 210
 #    include "unit_test/suite.h"
@@ -998,14 +998,14 @@ typedef U8                  Byte;       //!< 8-bit unsigned integer.
998 998
 #endif  // #ifndef __ASSEMBLY__
999 999
 
1000 1000
 
1001
-#if defined(__ICCARM__)
1001
+#ifdef __ICCARM__
1002 1002
 #define SHORTENUM           __packed
1003 1003
 #elif defined(__GNUC__)
1004 1004
 #define SHORTENUM           __attribute__((packed))
1005 1005
 #endif
1006 1006
 
1007 1007
 /* No operation */
1008
-#if defined(__ICCARM__)
1008
+#ifdef __ICCARM__
1009 1009
 #define nop()               __no_operation()
1010 1010
 #elif defined(__GNUC__)
1011 1011
 #define nop()               (__NOP())

+ 4
- 4
Marlin/src/HAL/HAL_LINUX/include/serial.h View File

@@ -142,10 +142,10 @@ public:
142 142
   void print_bin(uint32_t value, uint8_t num_digits) {
143 143
     uint32_t mask = 1 << (num_digits -1);
144 144
     for (uint8_t i = 0; i < num_digits; i++) {
145
-      if (!(i % 4) && i)    write(' ');
146
-      if (!(i % 16)  && i)  write(' ');
147
-      if (value & mask)     write('1');
148
-      else                  write('0');
145
+      if (!(i %  4) && i) write(' ');
146
+      if (!(i % 16) && i) write(' ');
147
+      if (value & mask)   write('1');
148
+      else                write('0');
149 149
       value <<= 1;
150 150
     }
151 151
   }

+ 2
- 2
Marlin/src/HAL/HAL_SAMD51/Servo_SAMD51.cpp View File

@@ -115,12 +115,12 @@ HAL_SERVO_TIMER_ISR() {
115 115
       tc->COUNT16.CC[tcChannel].reg = (uint16_t)(tcCounterValue - 4UL);               // at least REFRESH_INTERVAL has elapsed
116 116
   }
117 117
   if (tcChannel == 0) {
118
-    SYNC(tc->COUNT16.SYNCBUSY.bit.CC0); 
118
+    SYNC(tc->COUNT16.SYNCBUSY.bit.CC0);
119 119
     // Clear the interrupt
120 120
     tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0;
121 121
   }
122 122
   else {
123
-    SYNC(tc->COUNT16.SYNCBUSY.bit.CC1); 
123
+    SYNC(tc->COUNT16.SYNCBUSY.bit.CC1);
124 124
     // Clear the interrupt
125 125
     tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC1;
126 126
   }

+ 1
- 1
Marlin/src/HAL/HAL_STM32/fastio_STM32.h View File

@@ -53,7 +53,7 @@ void FastIO_init(); // Must be called before using fast io macros
53 53
   #define _WRITE(IO, V) do { \
54 54
     if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \
55 55
     else   FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR  = _BV32(STM_PIN(digitalPin[IO])) ; \
56
-  } while(0)
56
+  }while(0)
57 57
 #else
58 58
   #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO]) + (V ? 0 : 16)))
59 59
 #endif

+ 2
- 2
Marlin/src/HAL/HAL_STM32F1/fastio_STM32F1.h View File

@@ -38,8 +38,8 @@
38 38
 #define _SET_OUTPUT(IO)       _SET_MODE(IO, GPIO_OUTPUT_PP)
39 39
 #define _SET_OUTPUT_OD(IO)    _SET_MODE(IO, GPIO_OUTPUT_OD)
40 40
 
41
-#define OUT_WRITE(IO,V)       do{ _SET_OUTPUT(IO); WRITE(IO,V); } while(0)
42
-#define OUT_WRITE_OD(IO,V)    do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); } while(0)
41
+#define OUT_WRITE(IO,V)       do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
42
+#define OUT_WRITE_OD(IO,V)    do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
43 43
 
44 44
 #define SET_INPUT(IO)         _SET_MODE(IO, GPIO_INPUT_FLOATING)
45 45
 #define SET_INPUT_PULLUP(IO)  _SET_MODE(IO, GPIO_INPUT_PU)

+ 6
- 6
Marlin/src/core/macros.h View File

@@ -118,24 +118,24 @@
118 118
   // Using GCC extensions, but Travis GCC version does not like it and gives
119 119
   //  "error: statement-expressions are not allowed outside functions nor in template-argument lists"
120 120
   #define NOLESS(v, n) \
121
-    do { \
121
+    do{ \
122 122
       __typeof__(n) _n = (n); \
123 123
       if (v < _n) v = _n; \
124
-    } while(0)
124
+    }while(0)
125 125
 
126 126
   #define NOMORE(v, n) \
127
-    do { \
127
+    do{ \
128 128
       __typeof__(n) _n = (n); \
129 129
       if (v > _n) v = _n; \
130
-    } while(0)
130
+    }while(0)
131 131
 
132 132
   #define LIMIT(v, n1, n2) \
133
-    do { \
133
+    do{ \
134 134
       __typeof__(n1) _n1 = (n1); \
135 135
       __typeof__(n2) _n2 = (n2); \
136 136
       if (v < _n1) v = _n1; \
137 137
       else if (v > _n2) v = _n2; \
138
-    } while(0)
138
+    }while(0)
139 139
 
140 140
 #endif
141 141
 

+ 2
- 2
Marlin/src/core/serial.h View File

@@ -184,5 +184,5 @@ void print_bin(const uint16_t val);
184 184
 
185 185
 void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
186 186
 void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
187
-#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR("  " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
188
-#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(PSTR(PREFIX), nullptr, V); } while(0)
187
+#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR("  " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0)
188
+#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(PSTR(PREFIX), nullptr, V); }while(0)

+ 1
- 1
Marlin/src/feature/leds/leds.cpp View File

@@ -125,7 +125,7 @@ void LEDLights::set_color(const LEDColor &incol
125 125
     // If the pins can do PWM then their intensity will be set.
126 126
     #define UPDATE_RGBW(C,c) do { if (PWM_PIN(RGB_LED_##C##_PIN)) \
127 127
         analogWrite(pin_t(RGB_LED_##C##_PIN), incol.c); \
128
-      else WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); } while(0)
128
+      else WRITE(RGB_LED_##C##_PIN, incol.c ? HIGH : LOW); }while(0)
129 129
     UPDATE_RGBW(R,r);
130 130
     UPDATE_RGBW(G,g);
131 131
     UPDATE_RGBW(B,b);

+ 1
- 1
Marlin/src/gcode/calibrate/G33.cpp View File

@@ -445,7 +445,7 @@ void GcodeSuite::G33() {
445 445
              _tower_results       = (_4p_calibration && towers_set) || probe_points >= 3,
446 446
              _opposite_results    = (_4p_calibration && !towers_set) || probe_points >= 3,
447 447
              _endstop_results     = probe_points != 1 && probe_points != -1 && probe_points != 0,
448
-             _angle_results       = probe_points >= 3  && towers_set;
448
+             _angle_results       = probe_points >= 3 && towers_set;
449 449
   static const char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
450 450
   int8_t iterations = 0;
451 451
   float test_precision,

+ 1
- 1
Marlin/src/gcode/calibrate/G34_M422.cpp View File

@@ -284,7 +284,7 @@ void GcodeSuite::G34() {
284 284
     // Home Z after the alignment procedure
285 285
     process_subcommands_now_P(PSTR("G28 Z"));
286 286
 
287
-  } while(0);
287
+  }while(0);
288 288
 
289 289
   if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G34");
290 290
 }

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h View File

@@ -368,7 +368,7 @@
368 368
 #endif
369 369
 
370 370
 // Extensible UI serial touch screens. (See src/lcd/extensible_ui)
371
-#if EITHER(MALYAN_LCD, DGUS_LCD)
371
+#if ANY(MALYAN_LCD, DGUS_LCD, LULZBOT_TOUCH_UI)
372 372
   #define IS_EXTUI
373 373
   #define EXTENSIBLE_UI
374 374
 #endif

+ 3
- 0
Marlin/src/inc/Conditionals_adv.h View File

@@ -99,3 +99,6 @@
99 99
     #define LED_USER_PRESET_BRIGHTNESS 255
100 100
   #endif
101 101
 #endif
102
+
103
+// Extensible UI pin mapping for RepRapDiscount
104
+#define TOUCH_UI_ULTIPANEL ENABLED(LULZBOT_TOUCH_UI) && ANY(AO_EXP1_PINMAP, AO_EXP2_PINMAP, CR10_TFT_PINMAP)

+ 1
- 0
Marlin/src/inc/SanityCheck.h View File

@@ -1892,6 +1892,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1892 1892
   + ENABLED(OVERLORD_OLED) \
1893 1893
   + ENABLED(DGUS_LCD) \
1894 1894
   + ENABLED(MALYAN_LCD) \
1895
+  + ENABLED(LULZBOT_TOUCH_UI) \
1895 1896
   + ENABLED(FSMC_GRAPHICAL_TFT)
1896 1897
   #error "Please select no more than one LCD controller option."
1897 1898
 #endif

+ 560
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.cpp View File

@@ -0,0 +1,560 @@
1
+/*********************
2
+ * flash_storage.cpp *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../compat.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "../ftdi_eve_lib/ftdi_eve_lib.h"
28
+
29
+#include "media_file_reader.h"
30
+#include "flash_storage.h"
31
+
32
+// The following must be changed whenever the layout of the flash
33
+// data is changed in a manner that would render the data invalid.
34
+
35
+constexpr uint32_t flash_eeprom_version = 1;
36
+
37
+/* SPI Flash Memory Map:
38
+ *
39
+ * The following offsets and sizes are specified in 4k erase units:
40
+ *
41
+ * Page    Size     Description
42
+ * 0       16       DATA STORAGE AREA
43
+ * 16      1        VERSIONING DATA
44
+ * 17      inf      MEDIA STORAGE AREA
45
+ *
46
+ */
47
+
48
+#define DATA_STORAGE_SIZE_64K
49
+
50
+using namespace FTDI::SPI;
51
+using namespace FTDI::SPI::most_significant_byte_first;
52
+
53
+bool UIFlashStorage::is_present = false;
54
+
55
+#ifdef SPI_FLASH_SS
56
+/************************** SPI Flash Chip Interface **************************/
57
+
58
+  void SPIFlash::wait_while_busy() {
59
+    uint8_t status;
60
+    safe_delay(1);
61
+    do {
62
+     spi_flash_select();
63
+     spi_write_8(READ_STATUS_1);
64
+     status = spi_read_8();
65
+     spi_flash_deselect();
66
+     safe_delay(1);
67
+    } while (status & 1);
68
+  }
69
+
70
+  void SPIFlash::erase_sector_4k(uint32_t addr) {
71
+    spi_flash_select();
72
+    spi_write_8(WRITE_ENABLE);
73
+    spi_flash_deselect();
74
+
75
+    spi_flash_select();
76
+    spi_write_8(ERASE_4K);
77
+    spi_write_24(addr);
78
+    spi_flash_deselect();
79
+
80
+    wait_while_busy();
81
+  }
82
+
83
+  void SPIFlash::erase_sector_64k(uint32_t addr) {
84
+    spi_flash_select();
85
+    spi_write_8(WRITE_ENABLE);
86
+    spi_flash_deselect();
87
+
88
+    spi_flash_select();
89
+    spi_write_8(ERASE_64K);
90
+    spi_write_24(addr);
91
+    spi_flash_deselect();
92
+
93
+    wait_while_busy();
94
+  }
95
+
96
+  void SPIFlash::spi_write_begin(uint32_t addr) {
97
+    spi_flash_select();
98
+    spi_write_8(WRITE_ENABLE);
99
+    spi_flash_deselect();
100
+
101
+    spi_flash_select();
102
+    spi_write_8(PAGE_PROGRAM);
103
+    spi_write_24(addr);
104
+  }
105
+
106
+  void SPIFlash::spi_write_end() {
107
+    spi_flash_deselect();
108
+    wait_while_busy();
109
+  }
110
+
111
+  void SPIFlash::spi_read_begin(uint32_t addr) {
112
+    spi_flash_select();
113
+    spi_write_8(READ_DATA);
114
+    spi_write_24(addr);
115
+  }
116
+
117
+  void SPIFlash::spi_read_end() {
118
+    spi_flash_deselect();
119
+  }
120
+
121
+  void SPIFlash::erase_chip() {
122
+    spi_flash_select();
123
+    spi_write_8(WRITE_ENABLE);
124
+    spi_flash_deselect();
125
+
126
+    spi_flash_select();
127
+    spi_write_8(ERASE_CHIP);
128
+    spi_flash_deselect();
129
+    wait_while_busy();
130
+  }
131
+
132
+  void SPIFlash::read_jedec_id(uint8_t &manufacturer_id, uint8_t &device_type, uint8_t &capacity) {
133
+    spi_flash_select();
134
+    spi_write_8(READ_JEDEC_ID);
135
+    manufacturer_id = spi_recv();
136
+    device_type     = spi_recv();
137
+    capacity        = spi_recv();
138
+    spi_flash_deselect ();
139
+  }
140
+
141
+  /* This function writes "size" bytes from "data" starting at addr, while properly
142
+   * taking into account the special case of writing across a 256 byte page boundary.
143
+   * Returns the addr directly after the write.
144
+   */
145
+  uint32_t SPIFlash::write(uint32_t addr, const void *_data, size_t size) {
146
+    const uint8_t *data = (const uint8_t*) _data;
147
+    while (size) {
148
+      const uint32_t page_start = addr & 0xFFFF00ul;
149
+      const uint32_t page_end   = page_start + 256;
150
+      const uint32_t write_size = min(page_end - addr, size);
151
+      spi_write_begin(addr);
152
+      spi_write_bulk<ram_write>(data, write_size);
153
+      spi_write_end();
154
+      addr += write_size;
155
+      size -= write_size;
156
+      data += write_size;
157
+    }
158
+    return addr;
159
+  }
160
+
161
+  uint32_t SPIFlash::read(uint32_t addr, void *data, size_t size) {
162
+    spi_read_begin(addr);
163
+    spi_read_bulk(data, size);
164
+    spi_read_end();
165
+    return addr + size;
166
+  }
167
+
168
+  /********************************** UTILITY ROUTINES *********************************/
169
+
170
+  bool UIFlashStorage::check_known_device() {
171
+    uint8_t manufacturer_id, device_type, capacity;
172
+    read_jedec_id(manufacturer_id, device_type, capacity);
173
+
174
+    const bool is_known =
175
+        ((manufacturer_id == 0xEF) && (device_type == 0x40) && (capacity == 0x15)) || // unknown
176
+        ((manufacturer_id == 0x01) && (device_type == 0x40) && (capacity == 0x15)) || // Cypress S25FL116K
177
+        ((manufacturer_id == 0xEF) && (device_type == 0x14) && (capacity == 0x15)) || // Winbond W25Q16JV
178
+        ((manufacturer_id == 0x1F) && (device_type == 0x86) && (capacity == 0x01)) ;  // Adesto AT255F161
179
+
180
+    if (!is_known) {
181
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Unable to locate supported SPI Flash Memory.");
182
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("  Manufacturer ID, got: ", manufacturer_id);
183
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("  Device Type    , got: ", device_type);
184
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("  Capacity       , got: ", capacity);
185
+    }
186
+
187
+    return is_known;
188
+  }
189
+
190
+  void UIFlashStorage::initialize() {
191
+    for(uint8_t i = 0; i < 10; i++) {
192
+      if (check_known_device()) {
193
+        is_present = true;
194
+        break;
195
+      }
196
+      safe_delay(1000);
197
+    }
198
+  }
199
+
200
+  /**************************** DATA STORAGE AREA (first 4K or 64k) ********************/
201
+
202
+  #ifdef DATA_STORAGE_SIZE_64K
203
+    constexpr uint32_t data_storage_area_size = 64 * 1024; // Large erase unit
204
+  #else
205
+    constexpr uint32_t data_storage_area_size =  4 * 1024; // Small erase unit
206
+  #endif
207
+
208
+  /* In order to provide some degree of wear leveling, each data write to the
209
+   * SPI Flash chip is appended to data that was already written before, until
210
+   * the data storage area is completely filled. New data is written preceeded
211
+   * with a 32-bit delimiter 'LULZ', so that we can distinguish written and
212
+   * unwritten data:
213
+   *
214
+   *        'LULZ'         <--- 1st record delimiter
215
+   *        <data_byte>
216
+   *        <data_byte>
217
+   *        <data_byte>
218
+   *        'LULZ'         <--- 2nd record delimiter
219
+   *        <data_byte>
220
+   *        <data_byte>
221
+   *        <data_byte>
222
+   *           ...
223
+   *        'LULZ'         <--- Last record delimiter
224
+   *        <data_byte>
225
+   *        <data_byte>
226
+   *        <data_byte>
227
+   *        0xFF           <--- Start of free space
228
+   *        0xFF
229
+   *           ...
230
+   *
231
+   * This function walks down the data storage area, verifying that the
232
+   * delimiters are either 'LULZ' or 0xFFFFFFFF. In the case that an invalid
233
+   * delimiter is found, this function returns -1, indicating that the Flash
234
+   * data is invalid (this will happen if the block_size changed with respect
235
+   * to earlier firmware). Otherwise, it returns the offset of the last
236
+   * valid delimiter 'LULZ', indicating the most recently written data.
237
+   */
238
+  int32_t UIFlashStorage::get_config_read_offset(uint32_t block_size) {
239
+    uint16_t stride = 4 + block_size;
240
+    int32_t read_offset = -1;
241
+
242
+    for(uint32_t offset = 0; offset < (data_storage_area_size - stride); offset += stride) {
243
+      uint32_t delim;
244
+      spi_read_begin(offset);
245
+      spi_read_bulk (&delim, sizeof(delim));
246
+      spi_read_end();
247
+      switch (delim) {
248
+        case 0xFFFFFFFFul: return read_offset;
249
+        case delimiter:    read_offset = offset; break;
250
+        default:
251
+          SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("Invalid delimiter in Flash: ", delim);
252
+          return -1;
253
+      }
254
+    }
255
+    SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("No LULZ delimiter found.");
256
+    return -1;
257
+  }
258
+
259
+  /* This function returns the offset at which new data should be
260
+   * appended, or -1 if the Flash needs to be erased */
261
+  int32_t UIFlashStorage::get_config_write_offset(uint32_t block_size) {
262
+    int32_t read_offset = get_config_read_offset(block_size);
263
+    if (read_offset == -1) return -1; // The SPI flash is invalid
264
+
265
+    int32_t write_offset = read_offset + 4 + block_size;
266
+    if ((write_offset + 4 + block_size) > data_storage_area_size) {
267
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Not enough free space in Flash.");
268
+      return -1; // Not enough free space
269
+    }
270
+    return write_offset;
271
+  }
272
+
273
+  bool UIFlashStorage::verify_config_data(const void *data, size_t size) {
274
+    if (!is_present) return false;
275
+
276
+    int32_t read_addr = get_config_read_offset(size);
277
+    if (read_addr == -1) return false;
278
+
279
+    uint32_t delim;
280
+    spi_read_begin(read_addr);
281
+    spi_read_bulk (&delim, sizeof(delim));
282
+    bool ok = spi_verify_bulk(data,size);
283
+    spi_read_end();
284
+    return ok && delim == delimiter;
285
+  }
286
+
287
+  bool UIFlashStorage::read_config_data(void *data, size_t size) {
288
+    if (!is_present) return false;
289
+
290
+    int32_t read_addr = get_config_read_offset(size);
291
+    if (read_addr == -1) return false;
292
+
293
+    uint32_t delim;
294
+    spi_read_begin(read_addr);
295
+    spi_read_bulk (&delim, sizeof(delim));
296
+    spi_read_bulk (data, size);
297
+    spi_read_end();
298
+    return delim == delimiter;
299
+  }
300
+
301
+  void UIFlashStorage::write_config_data(const void *data, size_t size) {
302
+    if (!is_present) {
303
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("SPI Flash chip not present. Not saving UI settings.");
304
+      return;
305
+    }
306
+
307
+    // Since Flash storage has a limited number of write cycles,
308
+    // make sure that the data is different before rewriting.
309
+
310
+    if (verify_config_data(data, size)) {
311
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("UI settings already written, skipping write.");
312
+      return;
313
+    }
314
+
315
+    int16_t write_addr = get_config_write_offset(size);
316
+    if (write_addr == -1) {
317
+      SERIAL_ECHO_START();
318
+      SERIAL_ECHOPGM("Erasing UI settings from SPI Flash... ");
319
+      #ifdef DATA_STORAGE_SIZE_64K
320
+        erase_sector_64k(0);
321
+      #else
322
+        erase_sector_4k(0);
323
+      #endif
324
+      write_addr = 0;
325
+      SERIAL_ECHOLNPGM("DONE");
326
+    }
327
+
328
+    SERIAL_ECHO_START();
329
+    SERIAL_ECHOPAIR("Writing UI settings to SPI Flash (offset ", write_addr);
330
+    SERIAL_ECHOPGM(")...");
331
+
332
+    const uint32_t delim = delimiter;
333
+    write_addr = write(write_addr, &delim, sizeof(delim));
334
+    write_addr = write(write_addr, data, size);
335
+
336
+    SERIAL_ECHOLNPGM("DONE");
337
+  }
338
+
339
+  /************************** VERSIONING INFO AREA ************************/
340
+
341
+  /* The version info area follows the data storage area. If the version
342
+   * is incorrect, the data on the chip is invalid and format_flash should
343
+   * be called.
344
+   */
345
+
346
+  typedef struct {
347
+    uint32_t magic;
348
+    uint32_t version;
349
+  } flash_version_info;
350
+
351
+  constexpr uint32_t version_info_addr = data_storage_area_size;
352
+  constexpr uint32_t version_info_size = 4 * 1024; // Small erase unit
353
+
354
+  bool UIFlashStorage::is_valid() {
355
+    flash_version_info info;
356
+
357
+    spi_read_begin(version_info_addr);
358
+    spi_read_bulk (&info, sizeof(flash_version_info));
359
+    spi_read_end();
360
+
361
+    return info.magic == delimiter && info.version == flash_eeprom_version;
362
+  }
363
+
364
+  void UIFlashStorage::write_version_info() {
365
+    flash_version_info info;
366
+
367
+    info.magic   = delimiter;
368
+    info.version = flash_eeprom_version;
369
+
370
+    spi_write_begin(version_info_addr);
371
+    spi_write_bulk<ram_write>(&info, sizeof(flash_version_info));
372
+    spi_write_end();
373
+  }
374
+
375
+  /**************************** MEDIA STORAGE AREA *****************************/
376
+
377
+  /* The media storage area follows the versioning info area. It consists
378
+   * of a file index followed by the data for one or more media files.
379
+   *
380
+   * The file index consists of an array of 32-bit file sizes. If a file
381
+   * is not present, the file's size will be set to 0xFFFFFFFF
382
+   */
383
+
384
+  constexpr uint32_t media_storage_addr    = version_info_addr + version_info_size;
385
+  constexpr uint8_t  media_storage_slots   = 4;
386
+
387
+  void UIFlashStorage::format_flash() {
388
+    SERIAL_ECHO_START(); SERIAL_ECHOPGM("Erasing SPI Flash...");
389
+    SPIFlash::erase_chip();
390
+    SERIAL_ECHOLNPGM("DONE");
391
+
392
+    write_version_info();
393
+  }
394
+
395
+  uint32_t UIFlashStorage::get_media_file_start(uint8_t slot) {
396
+    uint32_t addr = media_storage_addr + sizeof(uint32_t) * media_storage_slots;
397
+    spi_read_begin(media_storage_addr);
398
+    for(uint8_t i = 0; i < slot; i++) {
399
+      addr += spi_read_32();
400
+    }
401
+    spi_read_end();
402
+    return addr;
403
+  }
404
+
405
+  void UIFlashStorage::set_media_file_size(uint8_t slot, uint32_t size) {
406
+    spi_write_begin(media_storage_addr + sizeof(uint32_t) * slot);
407
+    spi_write_32(size);
408
+    spi_write_end();
409
+  }
410
+
411
+  uint32_t UIFlashStorage::get_media_file_size(uint8_t slot) {
412
+    spi_read_begin(media_storage_addr + sizeof(uint32_t) * slot);
413
+    uint32_t size = spi_read_32();
414
+    spi_read_end();
415
+    return size;
416
+  }
417
+
418
+  /* Writes a media file from the SD card/USB flash drive into a slot on the SPI Flash. Media
419
+   * files must be written sequentially following by a chip erase and it is not possible to
420
+   * overwrite files. */
421
+  UIFlashStorage::error_t UIFlashStorage::write_media_file(progmem_str filename, uint8_t slot) {
422
+    #if ENABLED(SDSUPPORT)
423
+      uint32_t addr;
424
+      uint8_t buff[write_page_size];
425
+
426
+      strcpy_P( (char*) buff, (const char*) filename);
427
+
428
+      MediaFileReader reader;
429
+      if (!reader.open((char*) buff)) {
430
+        SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Unable to find media file");
431
+        return FILE_NOT_FOUND;
432
+      }
433
+
434
+      if (get_media_file_size(slot) != 0xFFFFFFFFUL) {
435
+        SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Media file already exists");
436
+        return WOULD_OVERWRITE;
437
+      }
438
+
439
+      SERIAL_ECHO_START(); SERIAL_ECHOPGM("Writing SPI Flash...");
440
+
441
+      set_media_file_size(slot, reader.size());
442
+      addr = get_media_file_start(slot);
443
+
444
+      // Write out the file itself
445
+      for(;;) {
446
+        const int16_t nBytes = reader.read(buff, write_page_size);
447
+        if (nBytes == -1) {
448
+          SERIAL_ECHOLNPGM("Failed to read from file");
449
+          return READ_ERROR;
450
+        }
451
+
452
+        addr = write(addr, buff, nBytes);
453
+        if (nBytes != write_page_size)
454
+          break;
455
+
456
+        #if ENABLED(EXTENSIBLE_UI)
457
+          ExtUI::yield();
458
+        #endif
459
+      }
460
+
461
+      SERIAL_ECHOLNPGM("DONE");
462
+
463
+      SERIAL_ECHO_START(); SERIAL_ECHOPGM("Verifying SPI Flash...");
464
+
465
+      bool verifyOk = true;
466
+
467
+      // Verify the file index
468
+
469
+      if (get_media_file_start(slot+1) != (get_media_file_start(slot) + reader.size())) {
470
+        SERIAL_ECHOLNPGM("File index verification failed. ");
471
+        verifyOk = false;
472
+      }
473
+
474
+      // Verify the file itself
475
+      addr = get_media_file_start(slot);
476
+      reader.rewind();
477
+
478
+      while (verifyOk) {
479
+        const int16_t nBytes = reader.read(buff, write_page_size);
480
+        if (nBytes == -1) {
481
+          SERIAL_ECHOPGM("Failed to read from file");
482
+          verifyOk = false;
483
+          break;
484
+        }
485
+
486
+        spi_read_begin(addr);
487
+        if (!spi_verify_bulk(buff, nBytes)) {
488
+          verifyOk = false;
489
+          spi_read_end();
490
+          break;
491
+        }
492
+        spi_read_end();
493
+
494
+        addr += nBytes;
495
+        if (nBytes != write_page_size) break;
496
+        #if ENABLED(EXTENSIBLE_UI)
497
+          ExtUI::yield();
498
+        #endif
499
+      };
500
+
501
+      if (verifyOk) {
502
+        SERIAL_ECHOLNPGM("DONE");
503
+        return SUCCESS;
504
+      } else {
505
+        SERIAL_ECHOLNPGM("FAIL");
506
+        return VERIFY_ERROR;
507
+      }
508
+    #else
509
+      return VERIFY_ERROR;
510
+    #endif // ENABLED(SDSUPPORT)
511
+  }
512
+
513
+  bool UIFlashStorage::BootMediaReader::isAvailable(uint32_t slot) {
514
+    if (!is_present) return false;
515
+
516
+    bytes_remaining = get_media_file_size(slot);
517
+    if (bytes_remaining != 0xFFFFFFFFUL) {
518
+      SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR("Boot media file size:", bytes_remaining);
519
+      addr = get_media_file_start(slot);
520
+      return true;
521
+    } else {
522
+      return false;
523
+    }
524
+  }
525
+
526
+  int16_t UIFlashStorage::BootMediaReader::read(void *data, const size_t size) {
527
+    if (bytes_remaining == 0xFFFFFFFFUL) return -1;
528
+
529
+    if (size > bytes_remaining)
530
+      return read(data, bytes_remaining);
531
+
532
+    if (size > 0) {
533
+      spi_read_begin(addr);
534
+      spi_read_bulk(data, size);
535
+      spi_read_end();
536
+      addr += size;
537
+      bytes_remaining -= size;
538
+    }
539
+
540
+    return size;
541
+  }
542
+
543
+  int16_t UIFlashStorage::BootMediaReader::read(void *obj, void *data, const size_t size) {
544
+    return reinterpret_cast<UIFlashStorage::BootMediaReader*>(obj)->read(data, size);
545
+  }
546
+
547
+#else
548
+  void UIFlashStorage::initialize()                                           {}
549
+  bool UIFlashStorage::is_valid()                                             {return true;}
550
+  void UIFlashStorage::write_config_data(const void *, size_t)                {}
551
+  bool UIFlashStorage::verify_config_data(const void *, size_t)               {return false;}
552
+  bool UIFlashStorage::read_config_data(void *, size_t )                      {return false;}
553
+  UIFlashStorage::error_t UIFlashStorage::write_media_file(progmem_str, uint8_t) {return FILE_NOT_FOUND;}
554
+  void UIFlashStorage::format_flash()                                         {}
555
+
556
+  bool UIFlashStorage::BootMediaReader::isAvailable(uint32_t)                 {return false;}
557
+  int16_t UIFlashStorage::BootMediaReader::read(void *, const size_t)         {return -1;}
558
+  int16_t UIFlashStorage::BootMediaReader::read(void *, void *, const size_t) {return -1;}
559
+#endif // SPI_FLASH_SS
560
+#endif // LULZBOT_TOUCH_UI

+ 110
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/flash_storage.h View File

@@ -0,0 +1,110 @@
1
+/*******************
2
+ * flash_storage.h *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#ifdef LULZBOT_TOUCH_UI
24
+
25
+class SPIFlash {
26
+  public:
27
+    static constexpr uint32_t erase_unit_size = 4 * 1024; // Minimum erase unit
28
+    static constexpr uint32_t write_page_size = 256;      // Minimum page write unit
29
+
30
+    enum {
31
+      READ_STATUS_1 = 0x05,
32
+      READ_STATUS_2 = 0x35,
33
+      READ_STATUS_3 = 0x33,
34
+      WRITE_ENABLE  = 0x06,
35
+      WRITE_DISABLE = 0x04,
36
+      READ_ID       = 0x90,
37
+      READ_JEDEC_ID = 0x9F,
38
+      READ_DATA     = 0x03,
39
+      PAGE_PROGRAM  = 0x02,
40
+      ERASE_4K      = 0x20,
41
+      ERASE_64K     = 0xD8,
42
+      ERASE_CHIP    = 0xC7
43
+    };
44
+
45
+    static void wait_while_busy();
46
+    static void erase_sector_4k(uint32_t addr);
47
+    static void erase_sector_64k(uint32_t addr);
48
+    static void erase_chip  ();
49
+
50
+    static void read_jedec_id(uint8_t &manufacturer_id, uint8_t &device_type, uint8_t &capacity);
51
+
52
+    static void spi_read_begin(uint32_t addr);
53
+    static void spi_read_end();
54
+
55
+    static void spi_write_begin(uint32_t addr);
56
+    static void spi_write_end();
57
+
58
+    static uint32_t write(uint32_t addr, const void *data, size_t size);
59
+    static uint32_t read(uint32_t addr, void *data, size_t size);
60
+};
61
+
62
+class UIFlashStorage : private SPIFlash {
63
+  private:
64
+
65
+    static bool is_present;
66
+    static int32_t  get_config_read_offset(uint32_t block_size);
67
+    static int32_t  get_config_write_offset(uint32_t block_size);
68
+
69
+    static uint32_t get_media_file_start(uint8_t slot);
70
+    static void     set_media_file_size(uint8_t slot, uint32_t size);
71
+    static uint32_t get_media_file_size(uint8_t slot);
72
+
73
+    static constexpr uint32_t delimiter = 0x4C554C5A; // 'LULZ'
74
+  public:
75
+    enum error_t {
76
+      SUCCESS,
77
+      FILE_NOT_FOUND,
78
+      READ_ERROR,
79
+      VERIFY_ERROR,
80
+      WOULD_OVERWRITE
81
+    };
82
+
83
+    static void    initialize  ();
84
+    static void    format_flash ();
85
+    static bool    check_known_device();
86
+
87
+    static bool    is_valid ();
88
+    static void    write_version_info();
89
+
90
+    static void    write_config_data  (const void *data, size_t size);
91
+    static bool    verify_config_data (const void *data, size_t size);
92
+    static bool    read_config_data   (void *data, size_t size);
93
+    static error_t write_media_file   (progmem_str filename, uint8_t slot = 0);
94
+
95
+    class BootMediaReader;
96
+};
97
+
98
+class UIFlashStorage::BootMediaReader {
99
+  private:
100
+    uint32_t addr;
101
+    uint32_t bytes_remaining;
102
+
103
+  public:
104
+    bool isAvailable(uint32_t slot = 0);
105
+    int16_t read(void *buffer, size_t const size);
106
+
107
+    static int16_t read(void *obj, void *buffer, const size_t size);
108
+};
109
+
110
+#endif // LULZBOT_TOUCH_UI

+ 63
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.cpp View File

@@ -0,0 +1,63 @@
1
+/************************
2
+ * media_filereader.cpp *
3
+ ************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../compat.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+  #include "media_file_reader.h"
27
+
28
+  #if ENABLED(SDSUPPORT)
29
+    bool MediaFileReader::open(const char* filename) {
30
+      card.init(SPI_SPEED, SDSS);
31
+      volume.init(&card);
32
+      root.openRoot(&volume);
33
+      return file.open(&root, filename, O_READ);
34
+    }
35
+
36
+    int16_t MediaFileReader::read(void *buff, size_t bytes) {
37
+      return file.read(buff, bytes);
38
+    }
39
+
40
+    void MediaFileReader::close() {
41
+      file.close();
42
+    }
43
+
44
+    uint32_t MediaFileReader::size() {
45
+      return file.fileSize();
46
+    }
47
+
48
+    void MediaFileReader::rewind() {
49
+      file.rewind();
50
+    }
51
+
52
+    int16_t MediaFileReader::read(void *obj, void *buff, size_t bytes) {
53
+      return reinterpret_cast<MediaFileReader*>(obj)->read(buff, bytes);
54
+    }
55
+  #else
56
+    bool MediaFileReader::open(const char*)               {return -1;}
57
+    int16_t MediaFileReader::read(void *, size_t)         {return 0;}
58
+    void MediaFileReader::close()                         {}
59
+    uint32_t MediaFileReader::size()                      {return 0;}
60
+    void MediaFileReader::rewind()                        {}
61
+    int16_t MediaFileReader::read(void *, void *, size_t) {return 0;}
62
+  #endif
63
+#endif // LULZBOT_TOUCH_UI

+ 44
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/archim2-flash/media_file_reader.h View File

@@ -0,0 +1,44 @@
1
+/**********************
2
+ * media_filereader.h *
3
+ **********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#include "../../../../../sd/SdFile.h"
26
+#include "../../../../../sd/cardreader.h"
27
+
28
+class MediaFileReader {
29
+  private:
30
+    #if ENABLED(SDSUPPORT)
31
+      Sd2Card  card;
32
+      SdVolume volume;
33
+      SdFile   root, file;
34
+    #endif
35
+
36
+  public:
37
+    bool open(const char* filename);
38
+    int16_t read(void *buff, size_t bytes);
39
+    uint32_t size();
40
+    void rewind();
41
+    void close();
42
+
43
+    static int16_t read(void *obj, void *buff, size_t bytes);
44
+};

+ 61
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/compat.h View File

@@ -0,0 +1,61 @@
1
+/************
2
+ * compat.h *
3
+ ************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/**
25
+ * This following provides compatibility whether compiling
26
+ * as a part of Marlin or outside it
27
+ */
28
+
29
+#if defined __has_include
30
+  #if __has_include ("../../ui_api.h")
31
+    #include "../../ui_api.h"
32
+  #endif
33
+#else
34
+  #include "../../ui_api.h"
35
+#endif
36
+
37
+#ifdef __MARLIN_FIRMWARE__
38
+    // If __MARLIN_FIRMWARE__ exists, then we are being
39
+    // compiled inside Marlin.
40
+    #include "pin_mappings.h"
41
+#else
42
+  // Messages that are declared in Marlin
43
+  #define WELCOME_MSG     "Printer Ready"
44
+  #define MSG_SD_INSERTED "Media Inserted"
45
+  #define MSG_SD_REMOVED  "Media Removed"
46
+
47
+  // Define macros for compatibility
48
+  #define EXTENSIBLE_UI
49
+  #define _CAT(a, ...) a ## __VA_ARGS__
50
+  #define SWITCH_ENABLED_      1
51
+  #define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
52
+  #define DISABLED(b) !ENABLED(b)
53
+
54
+  namespace UI {
55
+    static inline uint32_t safe_millis() {return millis();};
56
+    static inline void     yield()       {};
57
+  };
58
+#endif
59
+
60
+class __FlashStringHelper;
61
+typedef const __FlashStringHelper *progmem_str;

+ 98
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/config.h View File

@@ -0,0 +1,98 @@
1
+/************
2
+ * config.h *
3
+ ************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+#include "compat.h"
25
+
26
+// Define the display board used (see "ftdi_eve_boards.h" for definitions)
27
+
28
+//#define LCD_FTDI_VM800B35A        // FTDI 3.5" 320x240 with FT800
29
+//#define LCD_4DSYSTEMS_4DLCD_FT843 // 4D Systems 4.3" 480x272
30
+//#define LCD_HAOYU_FT800CB         // Haoyu with 4.3" or 5" 480x272
31
+//#define LCD_HAOYU_FT810CB         // Haoyu with 5" 800x480
32
+//#define LCD_ALEPHOBJECTS_CLCD_UI  // Aleph Objects Color LCD User Interface
33
+
34
+// Leave the following commented out to use a board's default resolution.
35
+// If you have changed the LCD panel, you may override the resolution
36
+// below (see "ftdi_eve_resolutions.h" for definitions):
37
+
38
+//#define TOUCH_UI_320x240
39
+//#define TOUCH_UI_480x272
40
+//#define TOUCH_UI_800x480
41
+
42
+// Define the printer interface or pins used (see "ui_pin_mappings.h" for definitions):
43
+
44
+//#define CR10_TFT_PINMAP
45
+//#define AO_EXP1_DEPRECATED_PINMAP  // UltraLCD EXP1 connector, old AlephObject's wiring
46
+//#define AO_EXP1_PINMAP  // UltraLCD EXP1 connector, new AlephObject's wiring
47
+//#define AO_EXP2_PINMAP  // UltraLCD EXP2 connector, new AlephObject's wiring
48
+//#define OTHER_PIN_LAYOUT
49
+
50
+// Otherwise. Define all the pins manually:
51
+
52
+#ifdef OTHER_PIN_LAYOUT
53
+    // Select interfacing pins, the following pin specifiers are supported:
54
+    //
55
+    //     ARDUINO_DIGITAL_1  - Arduino pin via digitalWrite/digitalRead
56
+    //     AVR_A1             - Fast AVR port access via PORTA/PINA/DDRA
57
+    //     1                  - When compiling Marlin, use Marlin pin IDs.
58
+
59
+    // The pins for CS and MOD_RESET (PD) must be chosen.
60
+    #define CLCD_MOD_RESET                      9
61
+    #define CLCD_SPI_CS                        10
62
+
63
+    // If using software SPI, specify pins for SCLK, MOSI, MISO
64
+    //#define CLCD_USE_SOFT_SPI
65
+    #ifdef CLCD_USE_SOFT_SPI
66
+        #define CLCD_SOFT_SPI_MOSI             11
67
+        #define CLCD_SOFT_SPI_MISO             12
68
+        #define CLCD_SOFT_SPI_SCLK             13
69
+    #endif
70
+#endif
71
+
72
+// Defines how to orient the display. An inverted (i.e. upside-down) display
73
+// is supported on the FT800. The FT810 or better also support a portrait
74
+// and mirrored orientation.
75
+//#define TOUCH_UI_INVERTED
76
+//#define TOUCH_UI_PORTRAIT
77
+//#define TOUCH_UI_MIRRORED
78
+
79
+// Use a numeric passcode for "Parental lock".
80
+// This is a recommended for smaller displays.
81
+//#define TOUCH_UI_PASSCODE
82
+
83
+// Define number of seconds after which the menu screens
84
+// timeout and returns the user to the status screen
85
+//#define LCD_TIMEOUT_TO_STATUS 120
86
+
87
+// Enable this to debug the event framework
88
+//#define UI_FRAMEWORK_DEBUG
89
+
90
+// Enable the developer's menu and screens
91
+//#define DEVELOPER_SCREENS
92
+
93
+// Maximum feed rate for manual extrusion (mm/s)
94
+//#define MAX_MANUAL_FEEDRATE 240
95
+
96
+// Sets the SPI speed in Hz
97
+
98
+#define SPI_FREQUENCY 8000000 >> SPI_SPEED

+ 674
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/LICENSE.txt View File

@@ -0,0 +1,674 @@
1
+                    GNU GENERAL PUBLIC LICENSE
2
+                       Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+                            Preamble
9
+
10
+  The GNU General Public License is a free, copyleft license for
11
+software and other kinds of works.
12
+
13
+  The licenses for most software and other practical works are designed
14
+to take away your freedom to share and change the works.  By contrast,
15
+the GNU General Public License is intended to guarantee your freedom to
16
+share and change all versions of a program--to make sure it remains free
17
+software for all its users.  We, the Free Software Foundation, use the
18
+GNU General Public License for most of our software; it applies also to
19
+any other work released this way by its authors.  You can apply it to
20
+your programs, too.
21
+
22
+  When we speak of free software, we are referring to freedom, not
23
+price.  Our General Public Licenses are designed to make sure that you
24
+have the freedom to distribute copies of free software (and charge for
25
+them if you wish), that you receive source code or can get it if you
26
+want it, that you can change the software or use pieces of it in new
27
+free programs, and that you know you can do these things.
28
+
29
+  To protect your rights, we need to prevent others from denying you
30
+these rights or asking you to surrender the rights.  Therefore, you have
31
+certain responsibilities if you distribute copies of the software, or if
32
+you modify it: responsibilities to respect the freedom of others.
33
+
34
+  For example, if you distribute copies of such a program, whether
35
+gratis or for a fee, you must pass on to the recipients the same
36
+freedoms that you received.  You must make sure that they, too, receive
37
+or can get the source code.  And you must show them these terms so they
38
+know their rights.
39
+
40
+  Developers that use the GNU GPL protect your rights with two steps:
41
+(1) assert copyright on the software, and (2) offer you this License
42
+giving you legal permission to copy, distribute and/or modify it.
43
+
44
+  For the developers' and authors' protection, the GPL clearly explains
45
+that there is no warranty for this free software.  For both users' and
46
+authors' sake, the GPL requires that modified versions be marked as
47
+changed, so that their problems will not be attributed erroneously to
48
+authors of previous versions.
49
+
50
+  Some devices are designed to deny users access to install or run
51
+modified versions of the software inside them, although the manufacturer
52
+can do so.  This is fundamentally incompatible with the aim of
53
+protecting users' freedom to change the software.  The systematic
54
+pattern of such abuse occurs in the area of products for individuals to
55
+use, which is precisely where it is most unacceptable.  Therefore, we
56
+have designed this version of the GPL to prohibit the practice for those
57
+products.  If such problems arise substantially in other domains, we
58
+stand ready to extend this provision to those domains in future versions
59
+of the GPL, as needed to protect the freedom of users.
60
+
61
+  Finally, every program is threatened constantly by software patents.
62
+States should not allow patents to restrict development and use of
63
+software on general-purpose computers, but in those that do, we wish to
64
+avoid the special danger that patents applied to a free program could
65
+make it effectively proprietary.  To prevent this, the GPL assures that
66
+patents cannot be used to render the program non-free.
67
+
68
+  The precise terms and conditions for copying, distribution and
69
+modification follow.
70
+
71
+                       TERMS AND CONDITIONS
72
+
73
+  0. Definitions.
74
+
75
+  "This License" refers to version 3 of the GNU General Public License.
76
+
77
+  "Copyright" also means copyright-like laws that apply to other kinds of
78
+works, such as semiconductor masks.
79
+
80
+  "The Program" refers to any copyrightable work licensed under this
81
+License.  Each licensee is addressed as "you".  "Licensees" and
82
+"recipients" may be individuals or organizations.
83
+
84
+  To "modify" a work means to copy from or adapt all or part of the work
85
+in a fashion requiring copyright permission, other than the making of an
86
+exact copy.  The resulting work is called a "modified version" of the
87
+earlier work or a work "based on" the earlier work.
88
+
89
+  A "covered work" means either the unmodified Program or a work based
90
+on the Program.
91
+
92
+  To "propagate" a work means to do anything with it that, without
93
+permission, would make you directly or secondarily liable for
94
+infringement under applicable copyright law, except executing it on a
95
+computer or modifying a private copy.  Propagation includes copying,
96
+distribution (with or without modification), making available to the
97
+public, and in some countries other activities as well.
98
+
99
+  To "convey" a work means any kind of propagation that enables other
100
+parties to make or receive copies.  Mere interaction with a user through
101
+a computer network, with no transfer of a copy, is not conveying.
102
+
103
+  An interactive user interface displays "Appropriate Legal Notices"
104
+to the extent that it includes a convenient and prominently visible
105
+feature that (1) displays an appropriate copyright notice, and (2)
106
+tells the user that there is no warranty for the work (except to the
107
+extent that warranties are provided), that licensees may convey the
108
+work under this License, and how to view a copy of this License.  If
109
+the interface presents a list of user commands or options, such as a
110
+menu, a prominent item in the list meets this criterion.
111
+
112
+  1. Source Code.
113
+
114
+  The "source code" for a work means the preferred form of the work
115
+for making modifications to it.  "Object code" means any non-source
116
+form of a work.
117
+
118
+  A "Standard Interface" means an interface that either is an official
119
+standard defined by a recognized standards body, or, in the case of
120
+interfaces specified for a particular programming language, one that
121
+is widely used among developers working in that language.
122
+
123
+  The "System Libraries" of an executable work include anything, other
124
+than the work as a whole, that (a) is included in the normal form of
125
+packaging a Major Component, but which is not part of that Major
126
+Component, and (b) serves only to enable use of the work with that
127
+Major Component, or to implement a Standard Interface for which an
128
+implementation is available to the public in source code form.  A
129
+"Major Component", in this context, means a major essential component
130
+(kernel, window system, and so on) of the specific operating system
131
+(if any) on which the executable work runs, or a compiler used to
132
+produce the work, or an object code interpreter used to run it.
133
+
134
+  The "Corresponding Source" for a work in object code form means all
135
+the source code needed to generate, install, and (for an executable
136
+work) run the object code and to modify the work, including scripts to
137
+control those activities.  However, it does not include the work's
138
+System Libraries, or general-purpose tools or generally available free
139
+programs which are used unmodified in performing those activities but
140
+which are not part of the work.  For example, Corresponding Source
141
+includes interface definition files associated with source files for
142
+the work, and the source code for shared libraries and dynamically
143
+linked subprograms that the work is specifically designed to require,
144
+such as by intimate data communication or control flow between those
145
+subprograms and other parts of the work.
146
+
147
+  The Corresponding Source need not include anything that users
148
+can regenerate automatically from other parts of the Corresponding
149
+Source.
150
+
151
+  The Corresponding Source for a work in source code form is that
152
+same work.
153
+
154
+  2. Basic Permissions.
155
+
156
+  All rights granted under this License are granted for the term of
157
+copyright on the Program, and are irrevocable provided the stated
158
+conditions are met.  This License explicitly affirms your unlimited
159
+permission to run the unmodified Program.  The output from running a
160
+covered work is covered by this License only if the output, given its
161
+content, constitutes a covered work.  This License acknowledges your
162
+rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+  You may make, run and propagate covered works that you do not
165
+convey, without conditions so long as your license otherwise remains
166
+in force.  You may convey covered works to others for the sole purpose
167
+of having them make modifications exclusively for you, or provide you
168
+with facilities for running those works, provided that you comply with
169
+the terms of this License in conveying all material for which you do
170
+not control copyright.  Those thus making or running the covered works
171
+for you must do so exclusively on your behalf, under your direction
172
+and control, on terms that prohibit them from making any copies of
173
+your copyrighted material outside their relationship with you.
174
+
175
+  Conveying under any other circumstances is permitted solely under
176
+the conditions stated below.  Sublicensing is not allowed; section 10
177
+makes it unnecessary.
178
+
179
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+  No covered work shall be deemed part of an effective technological
182
+measure under any applicable law fulfilling obligations under article
183
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+similar laws prohibiting or restricting circumvention of such
185
+measures.
186
+
187
+  When you convey a covered work, you waive any legal power to forbid
188
+circumvention of technological measures to the extent such circumvention
189
+is effected by exercising rights under this License with respect to
190
+the covered work, and you disclaim any intention to limit operation or
191
+modification of the work as a means of enforcing, against the work's
192
+users, your or third parties' legal rights to forbid circumvention of
193
+technological measures.
194
+
195
+  4. Conveying Verbatim Copies.
196
+
197
+  You may convey verbatim copies of the Program's source code as you
198
+receive it, in any medium, provided that you conspicuously and
199
+appropriately publish on each copy an appropriate copyright notice;
200
+keep intact all notices stating that this License and any
201
+non-permissive terms added in accord with section 7 apply to the code;
202
+keep intact all notices of the absence of any warranty; and give all
203
+recipients a copy of this License along with the Program.
204
+
205
+  You may charge any price or no price for each copy that you convey,
206
+and you may offer support or warranty protection for a fee.
207
+
208
+  5. Conveying Modified Source Versions.
209
+
210
+  You may convey a work based on the Program, or the modifications to
211
+produce it from the Program, in the form of source code under the
212
+terms of section 4, provided that you also meet all of these conditions:
213
+
214
+    a) The work must carry prominent notices stating that you modified
215
+    it, and giving a relevant date.
216
+
217
+    b) The work must carry prominent notices stating that it is
218
+    released under this License and any conditions added under section
219
+    7.  This requirement modifies the requirement in section 4 to
220
+    "keep intact all notices".
221
+
222
+    c) You must license the entire work, as a whole, under this
223
+    License to anyone who comes into possession of a copy.  This
224
+    License will therefore apply, along with any applicable section 7
225
+    additional terms, to the whole of the work, and all its parts,
226
+    regardless of how they are packaged.  This License gives no
227
+    permission to license the work in any other way, but it does not
228
+    invalidate such permission if you have separately received it.
229
+
230
+    d) If the work has interactive user interfaces, each must display
231
+    Appropriate Legal Notices; however, if the Program has interactive
232
+    interfaces that do not display Appropriate Legal Notices, your
233
+    work need not make them do so.
234
+
235
+  A compilation of a covered work with other separate and independent
236
+works, which are not by their nature extensions of the covered work,
237
+and which are not combined with it such as to form a larger program,
238
+in or on a volume of a storage or distribution medium, is called an
239
+"aggregate" if the compilation and its resulting copyright are not
240
+used to limit the access or legal rights of the compilation's users
241
+beyond what the individual works permit.  Inclusion of a covered work
242
+in an aggregate does not cause this License to apply to the other
243
+parts of the aggregate.
244
+
245
+  6. Conveying Non-Source Forms.
246
+
247
+  You may convey a covered work in object code form under the terms
248
+of sections 4 and 5, provided that you also convey the
249
+machine-readable Corresponding Source under the terms of this License,
250
+in one of these ways:
251
+
252
+    a) Convey the object code in, or embodied in, a physical product
253
+    (including a physical distribution medium), accompanied by the
254
+    Corresponding Source fixed on a durable physical medium
255
+    customarily used for software interchange.
256
+
257
+    b) Convey the object code in, or embodied in, a physical product
258
+    (including a physical distribution medium), accompanied by a
259
+    written offer, valid for at least three years and valid for as
260
+    long as you offer spare parts or customer support for that product
261
+    model, to give anyone who possesses the object code either (1) a
262
+    copy of the Corresponding Source for all the software in the
263
+    product that is covered by this License, on a durable physical
264
+    medium customarily used for software interchange, for a price no
265
+    more than your reasonable cost of physically performing this
266
+    conveying of source, or (2) access to copy the
267
+    Corresponding Source from a network server at no charge.
268
+
269
+    c) Convey individual copies of the object code with a copy of the
270
+    written offer to provide the Corresponding Source.  This
271
+    alternative is allowed only occasionally and noncommercially, and
272
+    only if you received the object code with such an offer, in accord
273
+    with subsection 6b.
274
+
275
+    d) Convey the object code by offering access from a designated
276
+    place (gratis or for a charge), and offer equivalent access to the
277
+    Corresponding Source in the same way through the same place at no
278
+    further charge.  You need not require recipients to copy the
279
+    Corresponding Source along with the object code.  If the place to
280
+    copy the object code is a network server, the Corresponding Source
281
+    may be on a different server (operated by you or a third party)
282
+    that supports equivalent copying facilities, provided you maintain
283
+    clear directions next to the object code saying where to find the
284
+    Corresponding Source.  Regardless of what server hosts the
285
+    Corresponding Source, you remain obligated to ensure that it is
286
+    available for as long as needed to satisfy these requirements.
287
+
288
+    e) Convey the object code using peer-to-peer transmission, provided
289
+    you inform other peers where the object code and Corresponding
290
+    Source of the work are being offered to the general public at no
291
+    charge under subsection 6d.
292
+
293
+  A separable portion of the object code, whose source code is excluded
294
+from the Corresponding Source as a System Library, need not be
295
+included in conveying the object code work.
296
+
297
+  A "User Product" is either (1) a "consumer product", which means any
298
+tangible personal property which is normally used for personal, family,
299
+or household purposes, or (2) anything designed or sold for incorporation
300
+into a dwelling.  In determining whether a product is a consumer product,
301
+doubtful cases shall be resolved in favor of coverage.  For a particular
302
+product received by a particular user, "normally used" refers to a
303
+typical or common use of that class of product, regardless of the status
304
+of the particular user or of the way in which the particular user
305
+actually uses, or expects or is expected to use, the product.  A product
306
+is a consumer product regardless of whether the product has substantial
307
+commercial, industrial or non-consumer uses, unless such uses represent
308
+the only significant mode of use of the product.
309
+
310
+  "Installation Information" for a User Product means any methods,
311
+procedures, authorization keys, or other information required to install
312
+and execute modified versions of a covered work in that User Product from
313
+a modified version of its Corresponding Source.  The information must
314
+suffice to ensure that the continued functioning of the modified object
315
+code is in no case prevented or interfered with solely because
316
+modification has been made.
317
+
318
+  If you convey an object code work under this section in, or with, or
319
+specifically for use in, a User Product, and the conveying occurs as
320
+part of a transaction in which the right of possession and use of the
321
+User Product is transferred to the recipient in perpetuity or for a
322
+fixed term (regardless of how the transaction is characterized), the
323
+Corresponding Source conveyed under this section must be accompanied
324
+by the Installation Information.  But this requirement does not apply
325
+if neither you nor any third party retains the ability to install
326
+modified object code on the User Product (for example, the work has
327
+been installed in ROM).
328
+
329
+  The requirement to provide Installation Information does not include a
330
+requirement to continue to provide support service, warranty, or updates
331
+for a work that has been modified or installed by the recipient, or for
332
+the User Product in which it has been modified or installed.  Access to a
333
+network may be denied when the modification itself materially and
334
+adversely affects the operation of the network or violates the rules and
335
+protocols for communication across the network.
336
+
337
+  Corresponding Source conveyed, and Installation Information provided,
338
+in accord with this section must be in a format that is publicly
339
+documented (and with an implementation available to the public in
340
+source code form), and must require no special password or key for
341
+unpacking, reading or copying.
342
+
343
+  7. Additional Terms.
344
+
345
+  "Additional permissions" are terms that supplement the terms of this
346
+License by making exceptions from one or more of its conditions.
347
+Additional permissions that are applicable to the entire Program shall
348
+be treated as though they were included in this License, to the extent
349
+that they are valid under applicable law.  If additional permissions
350
+apply only to part of the Program, that part may be used separately
351
+under those permissions, but the entire Program remains governed by
352
+this License without regard to the additional permissions.
353
+
354
+  When you convey a copy of a covered work, you may at your option
355
+remove any additional permissions from that copy, or from any part of
356
+it.  (Additional permissions may be written to require their own
357
+removal in certain cases when you modify the work.)  You may place
358
+additional permissions on material, added by you to a covered work,
359
+for which you have or can give appropriate copyright permission.
360
+
361
+  Notwithstanding any other provision of this License, for material you
362
+add to a covered work, you may (if authorized by the copyright holders of
363
+that material) supplement the terms of this License with terms:
364
+
365
+    a) Disclaiming warranty or limiting liability differently from the
366
+    terms of sections 15 and 16 of this License; or
367
+
368
+    b) Requiring preservation of specified reasonable legal notices or
369
+    author attributions in that material or in the Appropriate Legal
370
+    Notices displayed by works containing it; or
371
+
372
+    c) Prohibiting misrepresentation of the origin of that material, or
373
+    requiring that modified versions of such material be marked in
374
+    reasonable ways as different from the original version; or
375
+
376
+    d) Limiting the use for publicity purposes of names of licensors or
377
+    authors of the material; or
378
+
379
+    e) Declining to grant rights under trademark law for use of some
380
+    trade names, trademarks, or service marks; or
381
+
382
+    f) Requiring indemnification of licensors and authors of that
383
+    material by anyone who conveys the material (or modified versions of
384
+    it) with contractual assumptions of liability to the recipient, for
385
+    any liability that these contractual assumptions directly impose on
386
+    those licensors and authors.
387
+
388
+  All other non-permissive additional terms are considered "further
389
+restrictions" within the meaning of section 10.  If the Program as you
390
+received it, or any part of it, contains a notice stating that it is
391
+governed by this License along with a term that is a further
392
+restriction, you may remove that term.  If a license document contains
393
+a further restriction but permits relicensing or conveying under this
394
+License, you may add to a covered work material governed by the terms
395
+of that license document, provided that the further restriction does
396
+not survive such relicensing or conveying.
397
+
398
+  If you add terms to a covered work in accord with this section, you
399
+must place, in the relevant source files, a statement of the
400
+additional terms that apply to those files, or a notice indicating
401
+where to find the applicable terms.
402
+
403
+  Additional terms, permissive or non-permissive, may be stated in the
404
+form of a separately written license, or stated as exceptions;
405
+the above requirements apply either way.
406
+
407
+  8. Termination.
408
+
409
+  You may not propagate or modify a covered work except as expressly
410
+provided under this License.  Any attempt otherwise to propagate or
411
+modify it is void, and will automatically terminate your rights under
412
+this License (including any patent licenses granted under the third
413
+paragraph of section 11).
414
+
415
+  However, if you cease all violation of this License, then your
416
+license from a particular copyright holder is reinstated (a)
417
+provisionally, unless and until the copyright holder explicitly and
418
+finally terminates your license, and (b) permanently, if the copyright
419
+holder fails to notify you of the violation by some reasonable means
420
+prior to 60 days after the cessation.
421
+
422
+  Moreover, your license from a particular copyright holder is
423
+reinstated permanently if the copyright holder notifies you of the
424
+violation by some reasonable means, this is the first time you have
425
+received notice of violation of this License (for any work) from that
426
+copyright holder, and you cure the violation prior to 30 days after
427
+your receipt of the notice.
428
+
429
+  Termination of your rights under this section does not terminate the
430
+licenses of parties who have received copies or rights from you under
431
+this License.  If your rights have been terminated and not permanently
432
+reinstated, you do not qualify to receive new licenses for the same
433
+material under section 10.
434
+
435
+  9. Acceptance Not Required for Having Copies.
436
+
437
+  You are not required to accept this License in order to receive or
438
+run a copy of the Program.  Ancillary propagation of a covered work
439
+occurring solely as a consequence of using peer-to-peer transmission
440
+to receive a copy likewise does not require acceptance.  However,
441
+nothing other than this License grants you permission to propagate or
442
+modify any covered work.  These actions infringe copyright if you do
443
+not accept this License.  Therefore, by modifying or propagating a
444
+covered work, you indicate your acceptance of this License to do so.
445
+
446
+  10. Automatic Licensing of Downstream Recipients.
447
+
448
+  Each time you convey a covered work, the recipient automatically
449
+receives a license from the original licensors, to run, modify and
450
+propagate that work, subject to this License.  You are not responsible
451
+for enforcing compliance by third parties with this License.
452
+
453
+  An "entity transaction" is a transaction transferring control of an
454
+organization, or substantially all assets of one, or subdividing an
455
+organization, or merging organizations.  If propagation of a covered
456
+work results from an entity transaction, each party to that
457
+transaction who receives a copy of the work also receives whatever
458
+licenses to the work the party's predecessor in interest had or could
459
+give under the previous paragraph, plus a right to possession of the
460
+Corresponding Source of the work from the predecessor in interest, if
461
+the predecessor has it or can get it with reasonable efforts.
462
+
463
+  You may not impose any further restrictions on the exercise of the
464
+rights granted or affirmed under this License.  For example, you may
465
+not impose a license fee, royalty, or other charge for exercise of
466
+rights granted under this License, and you may not initiate litigation
467
+(including a cross-claim or counterclaim in a lawsuit) alleging that
468
+any patent claim is infringed by making, using, selling, offering for
469
+sale, or importing the Program or any portion of it.
470
+
471
+  11. Patents.
472
+
473
+  A "contributor" is a copyright holder who authorizes use under this
474
+License of the Program or a work on which the Program is based.  The
475
+work thus licensed is called the contributor's "contributor version".
476
+
477
+  A contributor's "essential patent claims" are all patent claims
478
+owned or controlled by the contributor, whether already acquired or
479
+hereafter acquired, that would be infringed by some manner, permitted
480
+by this License, of making, using, or selling its contributor version,
481
+but do not include claims that would be infringed only as a
482
+consequence of further modification of the contributor version.  For
483
+purposes of this definition, "control" includes the right to grant
484
+patent sublicenses in a manner consistent with the requirements of
485
+this License.
486
+
487
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+patent license under the contributor's essential patent claims, to
489
+make, use, sell, offer for sale, import and otherwise run, modify and
490
+propagate the contents of its contributor version.
491
+
492
+  In the following three paragraphs, a "patent license" is any express
493
+agreement or commitment, however denominated, not to enforce a patent
494
+(such as an express permission to practice a patent or covenant not to
495
+sue for patent infringement).  To "grant" such a patent license to a
496
+party means to make such an agreement or commitment not to enforce a
497
+patent against the party.
498
+
499
+  If you convey a covered work, knowingly relying on a patent license,
500
+and the Corresponding Source of the work is not available for anyone
501
+to copy, free of charge and under the terms of this License, through a
502
+publicly available network server or other readily accessible means,
503
+then you must either (1) cause the Corresponding Source to be so
504
+available, or (2) arrange to deprive yourself of the benefit of the
505
+patent license for this particular work, or (3) arrange, in a manner
506
+consistent with the requirements of this License, to extend the patent
507
+license to downstream recipients.  "Knowingly relying" means you have
508
+actual knowledge that, but for the patent license, your conveying the
509
+covered work in a country, or your recipient's use of the covered work
510
+in a country, would infringe one or more identifiable patents in that
511
+country that you have reason to believe are valid.
512
+
513
+  If, pursuant to or in connection with a single transaction or
514
+arrangement, you convey, or propagate by procuring conveyance of, a
515
+covered work, and grant a patent license to some of the parties
516
+receiving the covered work authorizing them to use, propagate, modify
517
+or convey a specific copy of the covered work, then the patent license
518
+you grant is automatically extended to all recipients of the covered
519
+work and works based on it.
520
+
521
+  A patent license is "discriminatory" if it does not include within
522
+the scope of its coverage, prohibits the exercise of, or is
523
+conditioned on the non-exercise of one or more of the rights that are
524
+specifically granted under this License.  You may not convey a covered
525
+work if you are a party to an arrangement with a third party that is
526
+in the business of distributing software, under which you make payment
527
+to the third party based on the extent of your activity of conveying
528
+the work, and under which the third party grants, to any of the
529
+parties who would receive the covered work from you, a discriminatory
530
+patent license (a) in connection with copies of the covered work
531
+conveyed by you (or copies made from those copies), or (b) primarily
532
+for and in connection with specific products or compilations that
533
+contain the covered work, unless you entered into that arrangement,
534
+or that patent license was granted, prior to 28 March 2007.
535
+
536
+  Nothing in this License shall be construed as excluding or limiting
537
+any implied license or other defenses to infringement that may
538
+otherwise be available to you under applicable patent law.
539
+
540
+  12. No Surrender of Others' Freedom.
541
+
542
+  If conditions are imposed on you (whether by court order, agreement or
543
+otherwise) that contradict the conditions of this License, they do not
544
+excuse you from the conditions of this License.  If you cannot convey a
545
+covered work so as to satisfy simultaneously your obligations under this
546
+License and any other pertinent obligations, then as a consequence you may
547
+not convey it at all.  For example, if you agree to terms that obligate you
548
+to collect a royalty for further conveying from those to whom you convey
549
+the Program, the only way you could satisfy both those terms and this
550
+License would be to refrain entirely from conveying the Program.
551
+
552
+  13. Use with the GNU Affero General Public License.
553
+
554
+  Notwithstanding any other provision of this License, you have
555
+permission to link or combine any covered work with a work licensed
556
+under version 3 of the GNU Affero General Public License into a single
557
+combined work, and to convey the resulting work.  The terms of this
558
+License will continue to apply to the part which is the covered work,
559
+but the special requirements of the GNU Affero General Public License,
560
+section 13, concerning interaction through a network will apply to the
561
+combination as such.
562
+
563
+  14. Revised Versions of this License.
564
+
565
+  The Free Software Foundation may publish revised and/or new versions of
566
+the GNU General Public License from time to time.  Such new versions will
567
+be similar in spirit to the present version, but may differ in detail to
568
+address new problems or concerns.
569
+
570
+  Each version is given a distinguishing version number.  If the
571
+Program specifies that a certain numbered version of the GNU General
572
+Public License "or any later version" applies to it, you have the
573
+option of following the terms and conditions either of that numbered
574
+version or of any later version published by the Free Software
575
+Foundation.  If the Program does not specify a version number of the
576
+GNU General Public License, you may choose any version ever published
577
+by the Free Software Foundation.
578
+
579
+  If the Program specifies that a proxy can decide which future
580
+versions of the GNU General Public License can be used, that proxy's
581
+public statement of acceptance of a version permanently authorizes you
582
+to choose that version for the Program.
583
+
584
+  Later license versions may give you additional or different
585
+permissions.  However, no additional obligations are imposed on any
586
+author or copyright holder as a result of your choosing to follow a
587
+later version.
588
+
589
+  15. Disclaimer of Warranty.
590
+
591
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+  16. Limitation of Liability.
601
+
602
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+SUCH DAMAGES.
611
+
612
+  17. Interpretation of Sections 15 and 16.
613
+
614
+  If the disclaimer of warranty and limitation of liability provided
615
+above cannot be given local legal effect according to their terms,
616
+reviewing courts shall apply local law that most closely approximates
617
+an absolute waiver of all civil liability in connection with the
618
+Program, unless a warranty or assumption of liability accompanies a
619
+copy of the Program in return for a fee.
620
+
621
+                     END OF TERMS AND CONDITIONS
622
+
623
+            How to Apply These Terms to Your New Programs
624
+
625
+  If you develop a new program, and you want it to be of the greatest
626
+possible use to the public, the best way to achieve this is to make it
627
+free software which everyone can redistribute and change under these terms.
628
+
629
+  To do so, attach the following notices to the program.  It is safest
630
+to attach them to the start of each source file to most effectively
631
+state the exclusion of warranty; and each file should have at least
632
+the "copyright" line and a pointer to where the full notice is found.
633
+
634
+    <one line to give the program's name and a brief idea of what it does.>
635
+    Copyright (C) <year>  <name of author>
636
+
637
+    This program is free software: you can redistribute it and/or modify
638
+    it under the terms of the GNU General Public License as published by
639
+    the Free Software Foundation, either version 3 of the License, or
640
+    (at your option) any later version.
641
+
642
+    This program is distributed in the hope that it will be useful,
643
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
645
+    GNU General Public License for more details.
646
+
647
+    You should have received a copy of the GNU General Public License
648
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
649
+
650
+Also add information on how to contact you by electronic and paper mail.
651
+
652
+  If the program does terminal interaction, make it output a short
653
+notice like this when it starts in an interactive mode:
654
+
655
+    <program>  Copyright (C) <year>  <name of author>
656
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+    This is free software, and you are welcome to redistribute it
658
+    under certain conditions; type `show c' for details.
659
+
660
+The hypothetical commands `show w' and `show c' should show the appropriate
661
+parts of the General Public License.  Of course, your program's commands
662
+might be different; for a GUI interface, you would use an "about box".
663
+
664
+  You should also get your employer (if you work as a programmer) or school,
665
+if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+For more information on this, and how to apply and follow the GNU GPL, see
667
+<http://www.gnu.org/licenses/>.
668
+
669
+  The GNU General Public License does not permit incorporating your program
670
+into proprietary programs.  If your program is a subroutine library, you
671
+may consider it more useful to permit linking proprietary applications with
672
+the library.  If this is what you want to do, use the GNU Lesser General
673
+Public License instead of this License.  But first, please read
674
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 28
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/README.md View File

@@ -0,0 +1,28 @@
1
+FTDI EVE Library
2
+----------------
3
+
4
+The FTDI EVE Library is a fully open-source library and UI framework for the FTDI
5
+FT800 and FT810 graphics processor.
6
+
7
+Although the library has been developed within Lulzbot for providing a user interface
8
+for Marlin, the library has been written so that it can be used in any Arduino sketch.
9
+
10
+The library is split into two parts. The "basic" API provides a shallow interface to
11
+the underlying FTDI hardware and command FIFO and provides low-level access to the
12
+hardware as closely as possible to the API described in the FTDI Programmer's Guide.
13
+
14
+The "extended" API builds on top of the "basic" API to provide a GUI framework for
15
+handling common challenges in building a usable GUI. The GUI framework provides the
16
+following features:
17
+
18
+- Macros for a resolution-independent placement of widgets based on a grid.
19
+- Class-based UI screens, with press and unpress touch events, as well as touch repeat.
20
+- Event loop with button debouncing and button push visual and auditory feedback.
21
+- Easy screen-to-screen navigation including a navigation stack for going backwards.
22
+- Visual feedback for disabled vs enabled buttons, and custom button styles.
23
+- A sound player class for playing individual notes or complete sound sequences.
24
+- Display list caching, for storing static background elements of a screen in RAM_G.
25
+
26
+See the "examples" folder for Arduino sketches. Modify the "src/config.h" file in
27
+each to suit your particular setup. The "sample_configs" contain sample configuration
28
+files for running the sketches on our 3D printer boards.

+ 183
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/boards.h View File

@@ -0,0 +1,183 @@
1
+/************
2
+ * boards.h *
3
+ ************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#define HAS_RESOLUTION (defined(TOUCH_UI_320x240) || defined(TOUCH_UI_480x272) || defined(TOUCH_UI_800x480))
26
+
27
+#define IS_FT800 \
28
+    constexpr uint16_t ftdi_chip = 800; \
29
+    using namespace FTDI_FT800; \
30
+    namespace DL { \
31
+      using namespace FTDI_FT800_DL; \
32
+    } \
33
+    typedef ft800_memory_map ftdi_memory_map; \
34
+    typedef ft800_registers  ftdi_registers;
35
+
36
+#define IS_FT810 \
37
+    constexpr uint16_t ftdi_chip = 810; \
38
+    using namespace FTDI_FT810; \
39
+    namespace DL { \
40
+      using namespace FTDI_FT800_DL; \
41
+      using namespace FTDI_FT810_DL; \
42
+    } \
43
+    typedef ft810_memory_map ftdi_memory_map; \
44
+    typedef ft810_registers  ftdi_registers;
45
+
46
+
47
+#ifdef LCD_FTDI_VM800B35A
48
+  #if !HAS_RESOLUTION
49
+    #define TOUCH_UI_320x240
50
+  #endif
51
+  #ifndef FTDI_API_LEVEL
52
+    #define FTDI_API_LEVEL                800
53
+  #endif
54
+  namespace FTDI {
55
+    IS_FT800
56
+    constexpr bool Use_Crystal              = true;  // 0 = use internal oscillator, 1 = module has a crystal populated
57
+    constexpr bool GPIO_0_Audio_Enable      = false; /* 1 = does use GPIO00 for amplifier control, 0 = not in use for Audio */
58
+    constexpr bool GPIO_1_Audio_Shutdown    = true;  /* 1 = does use GPIO01 for amplifier control, 0 = not in use for Audio */
59
+    constexpr uint8_t Swizzle               = 2;
60
+    constexpr uint8_t CSpread               = 1;
61
+
62
+    constexpr uint16_t touch_threshold      = 1200; /* touch-sensitivity */
63
+  }
64
+
65
+/*
66
+ * Settings for the Haoyu Electronics, 4.3" Graphical LCD Touchscreen,       480x272, SPI, FT800 (FT800CB-HY43B)
67
+ *                  Haoyu Electronics,   5" Graphical LCD Touchscreen,       480x272, SPI, FT800 (FT800CB-HY50B)
68
+ *
69
+ *    http://www.hotmcu.com/43-graphical-lcd-touchscreen-480x272-spi-ft800-p-111.html?cPath=6_16
70
+ *    http://www.hotmcu.com/5-graphical-lcd-touchscreen-480x272-spi-ft800-p-124.html?cPath=6_16
71
+ *
72
+ * Datasheet:
73
+ *
74
+ *    http://www.hantronix.com/files/data/1278363262430-3.pdf
75
+ *    http://www.haoyuelectronics.com/Attachment/HY43-LCD/LCD%20DataSheet.pdf
76
+ *    http://www.haoyuelectronics.com/Attachment/HY5-LCD-HD/KD50G21-40NT-A1.pdf
77
+ *
78
+ */
79
+
80
+#elif defined(LCD_HAOYU_FT800CB)
81
+  #if !HAS_RESOLUTION
82
+    #define TOUCH_UI_480x272
83
+  #endif
84
+  #ifndef FTDI_API_LEVEL
85
+    #define FTDI_API_LEVEL                800
86
+  #endif
87
+  namespace FTDI {
88
+    IS_FT800
89
+    constexpr bool Use_Crystal              = true; // 0 = use internal oscillator, 1 = module has a crystal populated
90
+    constexpr bool GPIO_0_Audio_Enable      = false;
91
+    constexpr bool GPIO_1_Audio_Shutdown    = false;
92
+    constexpr uint8_t Swizzle               = 0;
93
+    constexpr uint8_t CSpread               = 1;
94
+    constexpr uint16_t touch_threshold      = 2000; /* touch-sensitivity */
95
+  }
96
+
97
+/*
98
+ * Settings for the Haoyu Electronics, 5" Graphical LCD Touchscreen, 800x480, SPI, FT810
99
+ *
100
+ *    http://www.hotmcu.com/5-graphical-lcd-touchscreen-800x480-spi-ft810-p-286.html
101
+ *
102
+ * Datasheet:
103
+ *
104
+ *    http://www.haoyuelectronics.com/Attachment/HY5-LCD-HD/KD50G21-40NT-A1.pdf
105
+ *
106
+ */
107
+
108
+#elif defined(LCD_HAOYU_FT810CB)
109
+  #if !HAS_RESOLUTION
110
+    #define TOUCH_UI_800x480
111
+  #endif
112
+  #ifndef FTDI_API_LEVEL
113
+    #define FTDI_API_LEVEL                810
114
+  #endif
115
+  namespace FTDI {
116
+    IS_FT810
117
+    constexpr bool Use_Crystal              = true; // 0 = use internal oscillator, 1 = module has a crystal populated
118
+    constexpr bool GPIO_0_Audio_Enable      = false;
119
+    constexpr bool GPIO_1_Audio_Shutdown    = false;
120
+    constexpr uint8_t Swizzle               = 0;
121
+    constexpr uint8_t CSpread               = 1;
122
+    constexpr uint16_t touch_threshold      = 2000; /* touch-sensitivity */
123
+  }
124
+
125
+/*
126
+ * Settings for the 4D Systems,        4.3" Embedded SPI Display             480x272, SPI, FT800 (4DLCD-FT843)
127
+ *
128
+ *    http://www.4dsystems.com.au/product/4DLCD_FT843/
129
+ *
130
+ * Datasheet:
131
+ *
132
+ *    http://www.4dsystems.com.au/productpages/4DLCD-FT843/downloads/FT843-4.3-Display_datasheet_R_1_2.pdf
133
+ *
134
+ */
135
+
136
+#elif defined(LCD_4DSYSTEMS_4DLCD_FT843)
137
+  #if !HAS_RESOLUTION
138
+    #define TOUCH_UI_480x272
139
+  #endif
140
+  #ifndef FTDI_API_LEVEL
141
+    #define FTDI_API_LEVEL                800
142
+  #endif
143
+  namespace FTDI {
144
+    IS_FT800
145
+    constexpr bool Use_Crystal              = true; // 0 = use internal oscillator, 1 = module has a crystal populated
146
+    constexpr bool GPIO_0_Audio_Enable      = false;
147
+    constexpr bool GPIO_1_Audio_Shutdown    = true;
148
+    constexpr uint8_t Swizzle               = 0;
149
+    constexpr uint8_t CSpread               = 1;
150
+    constexpr uint16_t touch_threshold      = 1200; /* touch-sensitivity */
151
+  }
152
+
153
+/*
154
+ * Settings for the Aleph Objects Color LCD User Interface
155
+ *
156
+ *    https://code.alephobjects.com/source/aotctl/
157
+ *
158
+ * Datasheet:
159
+ *
160
+ *    http://www.hantronix.com/files/data/s1501799605s500-gh7.pdf
161
+ *
162
+ */
163
+#elif defined(LCD_ALEPHOBJECTS_CLCD_UI)
164
+  #if !HAS_RESOLUTION
165
+    #define TOUCH_UI_800x480
166
+  #endif
167
+  #ifndef FTDI_API_LEVEL
168
+    #define FTDI_API_LEVEL                810
169
+  #endif
170
+  namespace FTDI {
171
+    IS_FT810
172
+    constexpr bool Use_Crystal              = false; // 0 = use internal oscillator, 1 = module has a crystal populated
173
+    constexpr bool GPIO_0_Audio_Enable      = true;  // The AO CLCD uses GPIO0 to enable audio
174
+    constexpr bool GPIO_1_Audio_Shutdown    = false;
175
+    constexpr uint8_t Swizzle               = 0;
176
+    constexpr uint8_t CSpread               = 0;
177
+    constexpr uint16_t touch_threshold      = 2000; /* touch-sensitivity */
178
+  }
179
+
180
+#else
181
+
182
+  #error Unknown or no LULZBOT_TOUCH_UI board specified. To add a new board, modify "ftdi_eve_boards.h"
183
+#endif

+ 1174
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.cpp
File diff suppressed because it is too large
View File


+ 258
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/commands.h View File

@@ -0,0 +1,258 @@
1
+/****************
2
+ * commands.cpp *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+  /****************************************************************************
24
+  *                       FUNCTION MAP                                        *
25
+  *                                                                           *
26
+  * SPI and FT800/810 Commands                                                *
27
+  *                                                                           *
28
+  * CLCD::spi_select()                 Set CS line to 0                       *
29
+  * CLCD::spi_deselect()               Set CS Line to 1                       *
30
+  * CLCD::reset()                      Toggle FT800/810 Power Down Line 50 ms *
31
+  * CLCD::spi_init()                   Configure I/O Lines for SPI            *
32
+  * CLCD::spi_transfer()               Send/Receive 1 SPI Byte                *
33
+  * CLCD::init()                       Set FT800/810 Registers                *
34
+  * CLCD::enable()                     Turn On FT800/810 PCLK                 *
35
+  * CLCD::disable()                    Turn Off FT8880/810 PCLK               *
36
+  * CLCD::set_backlight()              Set LCD Backlight Level                *
37
+  *                                                                           *
38
+  * MEMORY READ FUNCTIONS                                                     *
39
+  *                                                                           *
40
+  * CLCD::mem_read_addr()              Send 32-Bit Address                    *
41
+  * CLCD::mem_read_8()                 Read 1 Byte                            *
42
+  * CLCD::mem_read_16()                Read 2 Bytes                           *
43
+  * CLCD::mem_read_32()                Read 4 Bytes                           *
44
+  *                                                                           *
45
+  * MEMORY WRITE FUNCTIONS                                                    *
46
+  *                                                                           *
47
+  * CLCD::mem_write_addr()             Send 24-Bit Address                    *
48
+  * CLCD::mem_write_8()                Write 1 Byte                           *
49
+  * CLCD::mem_write_16()               Write 2 Bytes                          *
50
+  * CLCD::mem_write_32()               Write 4 Bytes                          *
51
+  *                                                                           *
52
+  * HOST COMMAND FUNCTION                                                     *
53
+  *                                                                           *
54
+  * CLCD::host_cmd()                   Send 24-Bit Host Command               *
55
+  *                                                                           *
56
+  * COMMAND BUFFER FUNCTIONS                                                  *
57
+  *                                                                           *
58
+  * CLCD::cmd()                        Send 32-Bit Value(4 Bytes)CMD Buffer   *
59
+  * CLCD::cmd()                        Send Data Structure with 32-Bit Cmd    *
60
+  * CLCD::str()                        Send Text String in 32-Bit Multiples   *
61
+
62
+  *                                                                           *
63
+  * FT800/810 GRAPHIC COMMANDS                                                *
64
+  *                                                                           *
65
+  * class CLCD:CommandFifo {}          Class to control Cmd FIFO              *
66
+
67
+  * CommandFifo::start()               Wait for CP finish - Set FIFO Ptr      *
68
+  * CommandFifo::execute()             Set REG_CMD_WRITE and start CP         *
69
+  * CommandFifo::reset()               Set Cmd Buffer Pointers to 0           *
70
+  *
71
+  * CommandFifo::fgcolor               Set Graphic Item Foreground Color      *
72
+  * CommandFifo::bgcolor               Set Graphic Item Background Color      *
73
+  * CommandFifo::begin()               Begin Drawing a Primative              *
74
+  * CommandFifo::mem_copy()            Copy a Block of Memory                 *
75
+  * CommandFifo::append()              Append Commands to Current DL          *
76
+  * CommandFifo::gradient_color()      Set 3D Button Highlight Color          *
77
+  * CommandFifo::button()              Draw Button with Bulk Write            *
78
+  * CommandFifo::text()                Draw Text with Bulk Write              *
79
+  *****************************************************************************/
80
+
81
+ /**************************************************
82
+  * RAM_G Graphics RAM Allocation                  *
83
+  *                                                *
84
+  * Address    Use                                 *
85
+  *                                                *
86
+  *    8000    Extruder Bitmap                     *
87
+  *    8100    Bed Heat Bitmap                     *
88
+  *    8200    Fan Bitmap                          *
89
+  *    8300    Thumb Drive Symbol Bitmap           *
90
+  *   35000    Static DL Space (FT800)             *
91
+  *   F5000    Static DL Space (FT810)             *
92
+  **************************************************/
93
+
94
+#pragma once
95
+
96
+typedef const __FlashStringHelper *progmem_str;
97
+
98
+class UIStorage;
99
+
100
+class CLCD {
101
+  friend class UIStorage;
102
+
103
+  public:
104
+    typedef FTDI::ftdi_registers  REG;
105
+    typedef FTDI::ftdi_memory_map MAP;
106
+
107
+    static void     spi_write_addr (uint32_t reg_address);
108
+    static void     spi_read_addr  (uint32_t reg_address);
109
+
110
+    static uint8_t  mem_read_8     (uint32_t reg_address);
111
+    static uint16_t mem_read_16    (uint32_t reg_address);
112
+    static uint32_t mem_read_32    (uint32_t reg_address);
113
+    static void     mem_read_bulk  (uint32_t reg_address, uint8_t *data, uint16_t len);
114
+
115
+    static void     mem_write_8    (uint32_t reg_address, uint8_t w_data);
116
+    static void     mem_write_16   (uint32_t reg_address, uint16_t w_data);
117
+    static void     mem_write_32   (uint32_t reg_address, uint32_t w_data);
118
+    static void     mem_write_bulk (uint32_t reg_address, const void *data, uint16_t len, uint8_t padding = 0);
119
+    static void     mem_write_pgm  (uint32_t reg_address, const void *data, uint16_t len, uint8_t padding = 0);
120
+    static void     mem_write_bulk (uint32_t reg_address, progmem_str str, uint16_t len, uint8_t padding = 0);
121
+    static void     mem_write_xbm  (uint32_t reg_address, progmem_str str, uint16_t len, uint8_t padding = 0);
122
+
123
+  public:
124
+    class CommandFifo;
125
+    class FontMetrics;
126
+
127
+    static void init (void);
128
+    static void default_touch_transform (void);
129
+    static void default_display_orientation (void);
130
+    static void turn_on_backlight (void);
131
+    static void enable (void);
132
+    static void disable (void);
133
+    static void set_brightness (uint8_t brightness);
134
+    static uint8_t get_brightness();
135
+    static void host_cmd (unsigned char host_command, unsigned char byte2);
136
+
137
+    static void get_font_metrics (uint8_t font, struct FontMetrics &fm);
138
+    static uint16_t get_text_width(const uint8_t font, const char *str);
139
+    static uint16_t get_text_width_P(const uint8_t font, const char *str);
140
+
141
+    static uint8_t get_tag ()     {return mem_read_8(REG::TOUCH_TAG);}
142
+    static bool is_touching ()    {return (mem_read_32(REG::TOUCH_DIRECT_XY) & 0x80000000) == 0;}
143
+
144
+    static uint8_t get_tracker (uint16_t &value) {
145
+      uint32_t tracker = mem_read_32(REG::TRACKER);
146
+      value            = tracker >> 16;
147
+      return tracker & 0xFF;
148
+    }
149
+};
150
+
151
+/*************************** FT800/810 Font Metrics ****************************/
152
+
153
+class CLCD::FontMetrics {
154
+  public:
155
+    uint8_t   char_widths[128];
156
+    uint32_t  format;
157
+    uint32_t  stride;
158
+    uint32_t  width;
159
+    uint32_t  height;
160
+    uint32_t  ptr;
161
+
162
+    FontMetrics(uint8_t font) {load(font);}
163
+
164
+    void load(uint8_t font);
165
+
166
+    // Returns width of string, up to a maximum of n characters.
167
+    uint16_t get_text_width(const char *str, size_t n = SIZE_MAX) const;
168
+    uint16_t get_text_width_P(const char *str, size_t n = SIZE_MAX) const;
169
+};
170
+
171
+/******************* FT800/810 Graphic Commands *********************************/
172
+
173
+class CLCD::CommandFifo {
174
+  protected:
175
+    #if FTDI_API_LEVEL >= 810
176
+      uint32_t getRegCmdBSpace();
177
+    #else
178
+      static uint32_t command_write_ptr;
179
+      template <class T> bool _write_unaligned(T data, uint16_t len);
180
+    #endif
181
+    void start(void);
182
+
183
+  public:
184
+    template <class T> bool write(T data, uint16_t len);
185
+
186
+  public:
187
+    CommandFifo() {start();}
188
+
189
+    static void reset (void);
190
+    static bool is_processing();
191
+    static bool has_fault();
192
+
193
+    void execute(void);
194
+
195
+    void cmd(uint32_t cmd32);
196
+    void cmd(void* data, uint16_t len);
197
+
198
+    void dlstart()      {cmd(FTDI::CMD_DLSTART);}
199
+    void swap()         {cmd(FTDI::CMD_SWAP);}
200
+    void coldstart()    {cmd(FTDI::CMD_COLDSTART);}
201
+    void screensaver()  {cmd(FTDI::CMD_SCREENSAVER);}
202
+    void stop()         {cmd(FTDI::CMD_STOP);}
203
+    void loadidentity() {cmd(FTDI::CMD_LOADIDENTITY);}
204
+    void setmatrix()    {cmd(FTDI::CMD_SETMATRIX);}
205
+
206
+    void fgcolor     (uint32_t rgb);
207
+    void bgcolor     (uint32_t rgb);
208
+    void gradcolor   (uint32_t rgb);
209
+
210
+    void track       (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t tag);
211
+    void clock       (int16_t x, int16_t y, int16_t r,            uint16_t options, int16_t h, int16_t m, int16_t s, int16_t ms);
212
+    void gauge       (int16_t x, int16_t y, int16_t r,            uint16_t options, uint16_t major, uint16_t minor, uint16_t val, uint16_t range);
213
+    void dial        (int16_t x, int16_t y, int16_t r,            uint16_t options, uint16_t val);
214
+    void slider      (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t options, uint16_t val, uint16_t range);
215
+    void progress    (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t options, uint16_t val, uint16_t range);
216
+    void scrollbar   (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t options, uint16_t val, uint16_t size, uint16_t range);
217
+    void number      (int16_t x, int16_t y, int16_t font, uint16_t options, int32_t n);
218
+    void spinner     (int16_t x, int16_t y, uint16_t style, uint16_t scale);
219
+    void sketch      (int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t ptr, uint16_t format);
220
+    void gradient    (int16_t x0, int16_t y0, uint32_t rgb0, int16_t x1, int16_t y1, uint32_t rgb1);
221
+    void snapshot    (uint32_t ptr);
222
+    void loadimage   (uint32_t ptr, uint32_t options);
223
+    void getprops    (uint32_t ptr, uint32_t width, uint32_t height);
224
+
225
+    void scale       (int32_t sx, int32_t sy);
226
+    void rotate      (int32_t a);
227
+    void translate   (int32_t tx, int32_t ty);
228
+
229
+    #if FTDI_API_LEVEL >= 810
230
+      void setbase   (uint8_t base);
231
+      void setrotate (uint8_t rotation);
232
+      void setbitmap (uint32_t ptr, uint16_t fmt, uint16_t w, uint16_t h);
233
+      void snapshot2 (uint32_t fmt, uint32_t ptr, int16_t x, int16_t y, uint16_t w, uint16_t h);
234
+      void mediafifo (uint32_t ptr, uint32_t size);
235
+      void playvideo (uint32_t options);
236
+      void videostart();
237
+      void videoframe(uint32_t dst, uint32_t ptr);
238
+    #endif
239
+
240
+    // All the following must be followed by str()
241
+    void text      (int16_t x, int16_t y,                       int16_t font, uint16_t options);
242
+    void button    (int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t option);
243
+    void toggle    (int16_t x, int16_t y, int16_t w,            int16_t font, uint16_t options, bool state);
244
+    void keys      (int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options);
245
+
246
+    // Sends the string portion of text, button, toggle and keys.
247
+    void str (const char * data);
248
+    void str (progmem_str data);
249
+
250
+    void memzero  (uint32_t ptr, uint32_t size);
251
+    void memset   (uint32_t ptr, uint32_t value, uint32_t size);
252
+    void memcpy   (uint32_t dst, uint32_t src, uint32_t size);
253
+    void memcrc   (uint32_t ptr, uint32_t num, uint32_t result);
254
+    void memwrite (uint32_t ptr, uint32_t value);
255
+    void inflate  (uint32_t ptr);
256
+    void getptr   (uint32_t result);
257
+    void append   (uint32_t ptr, uint32_t size);
258
+};

+ 411
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/constants.h View File

@@ -0,0 +1,411 @@
1
+/***************
2
+ * constants.h *
3
+ ***************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+/****************************************************************************
24
+ * This header defines constants and commands for the FTDI FT810 LCD Driver *
25
+ * chip.                                                                    *
26
+ ****************************************************************************/
27
+
28
+#pragma once
29
+
30
+// OPTIONS
31
+
32
+namespace FTDI {
33
+  constexpr uint16_t OPT_3D           = 0x0000;
34
+  constexpr uint16_t OPT_RGB565       = 0x0000;
35
+  constexpr uint16_t OPT_MONO         = 0x0001;
36
+  constexpr uint16_t OPT_NODL         = 0x0002;
37
+  constexpr uint16_t OPT_FLAT         = 0x0100;
38
+  constexpr uint16_t OPT_SIGNED       = 0x0100;
39
+  constexpr uint16_t OPT_CENTERX      = 0x0200;
40
+  constexpr uint16_t OPT_CENTERY      = 0x0400;
41
+  constexpr uint16_t OPT_CENTER       = (OPT_CENTERX | OPT_CENTERY);
42
+  constexpr uint16_t OPT_RIGHTX       = 0x0800;
43
+  constexpr uint16_t OPT_NOBACK       = 0x1000;
44
+  constexpr uint16_t OPT_NOTICKS      = 0x2000;
45
+  constexpr uint16_t OPT_NOHM         = 0x4000;
46
+  constexpr uint16_t OPT_NOPOINTER    = 0x4000;
47
+  constexpr uint16_t OPT_NOSECS       = 0x8000;
48
+  constexpr uint16_t OPT_NOHANDS      = (OPT_NOPOINTER | OPT_NOSECS);
49
+}
50
+
51
+namespace FTDI_FT810 {
52
+  constexpr uint16_t OPT_NOTEAR      = 0x0004;
53
+  constexpr uint16_t OPT_FULLSCREEN  = 0x0008;
54
+  constexpr uint16_t OPT_MEDIAFIFO   = 0x0010;
55
+  constexpr uint16_t OPT_SOUND       = 0x0020;
56
+}
57
+
58
+// GPIO Bits
59
+
60
+namespace FTDI {
61
+  constexpr uint8_t GPIO_GP0         = 1 << 0;
62
+  constexpr uint8_t GPIO_GP1         = 1 << 1;
63
+  constexpr uint8_t GPIO_DISP        = 1 << 7;
64
+}
65
+
66
+namespace FTDI_FT810 {
67
+  constexpr uint16_t GPIOX_GP0       = 1 << 0;
68
+  constexpr uint16_t GPIOX_GP1       = 1 << 1;
69
+  constexpr uint16_t GPIOX_DISP      = 1 << 15;
70
+}
71
+
72
+// HOST COMMANDS
73
+
74
+namespace FTDI {
75
+  constexpr uint8_t ACTIVE  = 0x00;
76
+  constexpr uint8_t STANDBY = 0x41;
77
+  constexpr uint8_t SLEEP   = 0x42;
78
+  constexpr uint8_t PWRDOWN = 0x50;
79
+  constexpr uint8_t CLKEXT  = 0x44;
80
+  constexpr uint8_t CLKINT  = 0x48;
81
+  constexpr uint8_t CORESET = 0x68;
82
+}
83
+
84
+namespace FTDI_FT800 {
85
+    constexpr uint8_t CLK48M  = 0x62;
86
+    constexpr uint8_t CLK36M  = 0x61;
87
+}
88
+
89
+namespace FTDI_FT810 {
90
+    constexpr uint8_t CLKSEL  = 0x61;
91
+}
92
+
93
+// DISPLAY LIST COMMANDS
94
+
95
+namespace FTDI {
96
+  constexpr uint8_t ARGB1555                           = 0;
97
+  constexpr uint8_t L1                                 = 1;
98
+  constexpr uint8_t L4                                 = 2;
99
+  constexpr uint8_t L8                                 = 3;
100
+  constexpr uint8_t RGB332                             = 4;
101
+  constexpr uint8_t ARGB2                              = 5;
102
+  constexpr uint8_t ARGB4                              = 6;
103
+  constexpr uint8_t RGB565                             = 7;
104
+  constexpr uint8_t PALETTED                           = 8;
105
+  constexpr uint8_t TEXT8X8                            = 9;
106
+  constexpr uint8_t TEXTVGA                            = 10;
107
+  constexpr uint8_t BARGRAPH                           = 11;
108
+
109
+  constexpr uint8_t ALPHA_FUNC_NEVER                   = 0;
110
+  constexpr uint8_t ALPHA_FUNC_LESS                    = 1;
111
+  constexpr uint8_t ALPHA_FUNC_LEQUAL                  = 2;
112
+  constexpr uint8_t ALPHA_FUNC_GREATER                 = 3;
113
+  constexpr uint8_t ALPHA_FUNC_GEQUAL                  = 4;
114
+  constexpr uint8_t ALPHA_FUNC_EQUAL                   = 5;
115
+  constexpr uint8_t ALPHA_FUNC_NOTEQUAL                = 6;
116
+  constexpr uint8_t ALPHA_FUNC_ALWAYS                  = 7;
117
+
118
+  constexpr uint8_t NEAREST                            = 0;
119
+  constexpr uint8_t BILINEAR                           = 1;
120
+  constexpr uint8_t BORDER                             = 0;
121
+  constexpr uint8_t REPEAT                             = 1;
122
+
123
+  constexpr uint8_t BLEND_FUNC_ZERO                    = 0;
124
+  constexpr uint8_t BLEND_FUNC_ONE                     = 1;
125
+  constexpr uint8_t BLEND_FUNC_SRC_ALPHA               = 2;
126
+  constexpr uint8_t BLEND_FUNC_DST_ALPHA               = 3;
127
+  constexpr uint8_t BLEND_FUNC_ONE_MINUS_SRC_ALPHA     = 4;
128
+  constexpr uint8_t BLEND_FUNC_ONE_MINUS_DST_ALPHA     = 5;
129
+
130
+  constexpr uint32_t COLOR_MASK_RED                    = 8;
131
+  constexpr uint32_t COLOR_MASK_GRN                    = 4;
132
+  constexpr uint32_t COLOR_MASK_BLU                    = 2;
133
+  constexpr uint32_t COLOR_MASK_ALPHA                  = 1;
134
+
135
+  constexpr uint8_t STENCIL_FUNC_NEVER                 = 0;
136
+  constexpr uint8_t STENCIL_FUNC_LESS                  = 1;
137
+  constexpr uint8_t STENCIL_FUNC_LEQUAL                = 2;
138
+  constexpr uint8_t STENCIL_FUNC_GREATER               = 3;
139
+  constexpr uint8_t STENCIL_FUNC_GEQUAL                = 4;
140
+  constexpr uint8_t STENCIL_FUNC_EQUAL                 = 5;
141
+  constexpr uint8_t STENCIL_FUNC_NOTEQUAL              = 6;
142
+  constexpr uint8_t STENCIL_FUNC_ALWAYS                = 7;
143
+
144
+  constexpr uint8_t STENCIL_OP_ZERO                    = 0;
145
+  constexpr uint8_t STENCIL_OP_KEEP                    = 1;
146
+  constexpr uint8_t STENCIL_OP_REPLACE                 = 2;
147
+  constexpr uint8_t STENCIL_OP_INCR                    = 3;
148
+  constexpr uint8_t STENCIL_OP_DECR                    = 4;
149
+  constexpr uint8_t STENCIL_OP_INVERT                  = 5;
150
+
151
+  typedef enum: uint32_t {
152
+   BITMAPS                                             = 1,
153
+   POINTS                                              = 2,
154
+   LINES                                               = 3,
155
+   LINE_STRIP                                          = 4,
156
+   EDGE_STRIP_R                                        = 5,
157
+   EDGE_STRIP_L                                        = 6,
158
+   EDGE_STRIP_A                                        = 7,
159
+   EDGE_STRIP_B                                        = 8,
160
+   RECTS                                               = 9
161
+  } begin_t;
162
+}
163
+
164
+namespace FTDI_FT800_DL {
165
+  constexpr uint32_t ALPHA_FUNC                         = 0x09000000;
166
+  constexpr uint32_t BEGIN                              = 0x1F000000;
167
+  constexpr uint32_t BITMAP_HANDLE                      = 0x05000000;
168
+  constexpr uint32_t BITMAP_LAYOUT                      = 0x07000000;
169
+  constexpr uint32_t BITMAP_SIZE                        = 0x08000000;
170
+  constexpr uint32_t BITMAP_SOURCE                      = 0x01000000;
171
+  constexpr uint32_t BITMAP_TRANSFORM_A                 = 0x15000000;
172
+  constexpr uint32_t BITMAP_TRANSFORM_B                 = 0x16000000;
173
+  constexpr uint32_t BITMAP_TRANSFORM_C                 = 0x17000000;
174
+  constexpr uint32_t BITMAP_TRANSFORM_D                 = 0x18000000;
175
+  constexpr uint32_t BITMAP_TRANSFORM_E                 = 0x19000000;
176
+  constexpr uint32_t BITMAP_TRANSFORM_F                 = 0x1A000000;
177
+  constexpr uint32_t BLEND_FUNC                         = 0x0B000000;
178
+  constexpr uint32_t CALL                               = 0x1D000000;
179
+  constexpr uint32_t CELL                               = 0x06000000;
180
+  constexpr uint32_t CLEAR                              = 0x26000000;
181
+  constexpr uint32_t CLEAR_COLOR_BUFFER                 = 0x00000004;
182
+  constexpr uint32_t CLEAR_STENCIL_BUFFER               = 0x00000002;
183
+  constexpr uint32_t CLEAR_TAG_BUFFER                   = 0x00000001;
184
+  constexpr uint32_t CLEAR_COLOR_A                      = 0x0F000000;
185
+  constexpr uint32_t CLEAR_COLOR_RGB                    = 0x02000000;
186
+  constexpr uint32_t CLEAR_STENCIL                      = 0x11000000;
187
+  constexpr uint32_t CLEAR_TAG                          = 0x12000000;
188
+  constexpr uint32_t COLOR_A                            = 0x10000000;
189
+  constexpr uint32_t COLOR_MASK                         = 0x20000000;
190
+  constexpr uint32_t COLOR_RGB                          = 0x04000000;
191
+  constexpr uint32_t DL_DISPLAY                         = 0x00000000;
192
+  constexpr uint32_t END                                = 0x21000000;
193
+  constexpr uint32_t JUMP                               = 0x1E000000;
194
+  constexpr uint32_t LINE_WIDTH                         = 0x0E000000;
195
+  constexpr uint32_t MACRO                              = 0x25000000;
196
+  constexpr uint32_t POINT_SIZE                         = 0x0D000000;
197
+  constexpr uint32_t RESTORE_CONTEXT                    = 0x23000000;
198
+  constexpr uint32_t RETURN                             = 0x24000000;
199
+  constexpr uint32_t SAVE_CONTEXT                       = 0x22000000;
200
+  constexpr uint32_t SCISSOR_SIZE                       = 0x1C000000;
201
+  constexpr uint32_t SCISSOR_XY                         = 0x1B000000;
202
+  constexpr uint32_t STENCIL_FUNC                       = 0x0A000000;
203
+  constexpr uint32_t STENCIL_MASK                       = 0x13000000;
204
+  constexpr uint32_t STENCIL_OP                         = 0x0C000000;
205
+  constexpr uint32_t TAG                                = 0x03000000;
206
+  constexpr uint32_t TAG_MASK                           = 0x14000000;
207
+  constexpr uint32_t VERTEX2F                           = 0x40000000;
208
+  constexpr uint32_t VERTEX2II                          = 0x80000000;
209
+}
210
+
211
+namespace FTDI_FT810_DL {
212
+  constexpr uint32_t NOP                                = 0x25000000;
213
+  constexpr uint32_t BITMAP_LAYOUT_H                    = 0x28000000;
214
+  constexpr uint32_t BITMAP_SIZE_H                      = 0x29000000;
215
+  constexpr uint32_t VERTEX_FORMAT                      = 0x27000000;
216
+  constexpr uint32_t VERTEX_TRANSLATE_X                 = 0x2B000000;
217
+  constexpr uint32_t VERTEX_TRANSLATE_Y                 = 0x2C000000;
218
+}
219
+
220
+// CO-PROCESSOR ENGINE COMMANDS
221
+namespace FTDI {
222
+  constexpr uint32_t CMD_DLSTART                        = 0xFFFFFF00;
223
+  constexpr uint32_t CMD_SWAP                           = 0xFFFFFF01;
224
+  constexpr uint32_t CMD_COLDSTART                      = 0xFFFFFF32;
225
+  constexpr uint32_t CMD_INTERRUPT                      = 0xFFFFFF02;
226
+  constexpr uint32_t CMD_APPEND                         = 0xFFFFFF1E;
227
+  constexpr uint32_t CMD_REGREAD                        = 0xFFFFFF19;
228
+  constexpr uint32_t CMD_MEMWRITE                       = 0xFFFFFF1A;
229
+  constexpr uint32_t CMD_INFLATE                        = 0xFFFFFF22;
230
+  constexpr uint32_t CMD_LOADIMAGE                      = 0xFFFFFF24;
231
+  constexpr uint32_t CMD_MEMCRC                         = 0xFFFFFF18;
232
+  constexpr uint32_t CMD_MEMZERO                        = 0xFFFFFF1C;
233
+  constexpr uint32_t CMD_MEMSET                         = 0xFFFFFF1B;
234
+  constexpr uint32_t CMD_MEMCPY                         = 0xFFFFFF1D;
235
+  constexpr uint32_t CMD_BUTTON                         = 0xFFFFFF0D;
236
+  constexpr uint32_t CMD_CLOCK                          = 0xFFFFFF14;
237
+  constexpr uint32_t CMD_FGCOLOR                        = 0xFFFFFF0A;
238
+  constexpr uint32_t CMD_BGCOLOR                        = 0xFFFFFF09;
239
+  constexpr uint32_t CMD_GRADCOLOR                      = 0xFFFFFF34;
240
+  constexpr uint32_t CMD_GAUGE                          = 0xFFFFFF13;
241
+  constexpr uint32_t CMD_GRADIENT                       = 0xFFFFFF0B;
242
+  constexpr uint32_t CMD_KEYS                           = 0xFFFFFF0E;
243
+  constexpr uint32_t CMD_PROGRESS                       = 0xFFFFFF0F;
244
+  constexpr uint32_t CMD_SCROLLBAR                      = 0xFFFFFF11;
245
+  constexpr uint32_t CMD_SLIDER                         = 0xFFFFFF10;
246
+  constexpr uint32_t CMD_DIAL                           = 0xFFFFFF2D;
247
+  constexpr uint32_t CMD_TOGGLE                         = 0xFFFFFF12;
248
+  constexpr uint32_t CMD_TEXT                           = 0xFFFFFF0C;
249
+  constexpr uint32_t CMD_NUMBER                         = 0xFFFFFF2E;
250
+  constexpr uint32_t CMD_LOADIDENTITY                   = 0xFFFFFF26;
251
+  constexpr uint32_t CMD_SETMATRIX                      = 0xFFFFFF2A;
252
+  constexpr uint32_t CMD_GETMATRIX                      = 0xFFFFFF33;
253
+  constexpr uint32_t CMD_GETPTR                         = 0xFFFFFF23;
254
+  constexpr uint32_t CMD_GETPROPS                       = 0xFFFFFF25;
255
+  constexpr uint32_t CMD_SCALE                          = 0xFFFFFF28;
256
+  constexpr uint32_t CMD_ROTATE                         = 0xFFFFFF29;
257
+  constexpr uint32_t CMD_TRANSLATE                      = 0xFFFFFF27;
258
+  constexpr uint32_t CMD_CALIBRATE                      = 0xFFFFFF15;
259
+  constexpr uint32_t CMD_SPINNER                        = 0xFFFFFF16;
260
+  constexpr uint32_t CMD_SCREENSAVER                    = 0xFFFFFF2F;
261
+  constexpr uint32_t CMD_SKETCH                         = 0xFFFFFF30;
262
+  constexpr uint32_t CMD_STOP                           = 0xFFFFFF17;
263
+  constexpr uint32_t CMD_SETFONT                        = 0xFFFFFF2B;
264
+  constexpr uint32_t CMD_TRACK                          = 0xFFFFFF2C;
265
+  constexpr uint32_t CMD_SNAPSHOT                       = 0xFFFFFF1F;
266
+  constexpr uint32_t CMD_LOGO                           = 0xFFFFFF31;
267
+}
268
+
269
+namespace FTDI_FT810 {
270
+  constexpr uint32_t CMD_SETROTATE                    = 0xFFFFFF36;
271
+  constexpr uint32_t CMD_SNAPSHOT2                    = 0xFFFFFF37;
272
+  constexpr uint32_t CMD_SETBASE                      = 0xFFFFFF38;
273
+  constexpr uint32_t CMD_MEDIAFIFO                    = 0xFFFFFF39;
274
+  constexpr uint32_t CMD_PLAYVIDEO                    = 0xFFFFFF3A;
275
+  constexpr uint32_t CMD_VIDEOSTART                   = 0xFFFFFF40;
276
+  constexpr uint32_t CMD_VIDEOFRAME                   = 0xFFFFFF41;
277
+  constexpr uint32_t CMD_SETBITMAP                    = 0xFFFFFF43;
278
+}
279
+
280
+namespace FTDI {
281
+  enum effect_t {
282
+    SILENCE                                         = 0x00,
283
+    SQUARE_WAVE                                     = 0x01,
284
+    SINE_WAVE                                       = 0x02,
285
+    SAWTOOTH_WAVE                                   = 0x03,
286
+    TRIANGLE_WAVE                                   = 0x04,
287
+    BEEPING                                         = 0x05,
288
+    ALARM                                           = 0x06,
289
+    WARBLE                                          = 0x07,
290
+    CAROUSEL                                        = 0x08,
291
+    SHORT_PIPS_1                                    = 0x10,
292
+    SHORT_PIPS_2                                    = 0x11,
293
+    SHORT_PIPS_3                                    = 0x12,
294
+    SHORT_PIPS_4                                    = 0x13,
295
+    SHORT_PIPS_5                                    = 0x14,
296
+    SHORT_PIPS_6                                    = 0x15,
297
+    SHORT_PIPS_7                                    = 0x16,
298
+    SHORT_PIPS_8                                    = 0x17,
299
+    SHORT_PIPS_9                                    = 0x18,
300
+    SHORT_PIPS_10                                   = 0x19,
301
+    SHORT_PIPS_11                                   = 0x1A,
302
+    SHORT_PIPS_12                                   = 0x1B,
303
+    SHORT_PIPS_13                                   = 0x1C,
304
+    SHORT_PIPS_14                                   = 0x1D,
305
+    SHORT_PIPS_15                                   = 0x1E,
306
+    SHORT_PIPS_16                                   = 0x1F,
307
+    DTMF_POUND                                      = 0x23,
308
+    DTMF_STAR                                       = 0x2C,
309
+    DTMF_0                                          = 0x30,
310
+    DTMF_1                                          = 0x31,
311
+    DTMF_2                                          = 0x32,
312
+    DTMF_3                                          = 0x33,
313
+    DTMF_4                                          = 0x34,
314
+    DTMF_5                                          = 0x35,
315
+    DTMF_6                                          = 0x36,
316
+    DTMF_7                                          = 0x37,
317
+    DTMF_8                                          = 0x38,
318
+    DTMF_9                                          = 0x39,
319
+    HARP                                            = 0x40,
320
+    XYLOPHONE                                       = 0x41,
321
+    TUBA                                            = 0x42,
322
+    GLOCKENSPIEL                                    = 0x43,
323
+    ORGAN                                           = 0x44,
324
+    TRUMPET                                         = 0x45,
325
+    PIANO                                           = 0x46,
326
+    CHIMES                                          = 0x47,
327
+    MUSIC_BOX                                       = 0x48,
328
+    BELL                                            = 0x49,
329
+    CLICK                                           = 0x50,
330
+    SWITCH                                          = 0x51,
331
+    COWBELL                                         = 0x52,
332
+    NOTCH                                           = 0x53,
333
+    HIHAT                                           = 0x54,
334
+    KICKDRUM                                        = 0x55,
335
+    POP                                             = 0x56,
336
+    CLACK                                           = 0x57,
337
+    CHACK                                           = 0x58,
338
+    MUTE                                            = 0x60,
339
+    UNMUTE                                          = 0x61
340
+  };
341
+
342
+  enum note_t {
343
+    END_SONG                                        = 0xFF,
344
+    REST                                            = 0x00,
345
+
346
+    NOTE_C1                                         = 0x18, // 24
347
+    NOTE_C1S                                        = 0x19,
348
+    NOTE_D1                                         = 0x1A,
349
+    NOTE_D1S                                        = 0x1B,
350
+    NOTE_E1                                         = 0x1C,
351
+    NOTE_F1                                         = 0x1D,
352
+    NOTE_F1S                                        = 0x1E,
353
+    NOTE_G1                                         = 0x1F,
354
+    NOTE_G1S                                        = 0x20,
355
+    NOTE_A1                                         = 0x21,
356
+    NOTE_A1S                                        = 0x22,
357
+    NOTE_B1                                         = 0x23,
358
+
359
+    NOTE_C2                                         = 0x24,  //36
360
+    NOTE_C2S                                        = 0x25,
361
+    NOTE_D2                                         = 0x26,
362
+    NOTE_D2S                                        = 0x27,
363
+    NOTE_E2                                         = 0x28,
364
+    NOTE_F2                                         = 0x29,
365
+    NOTE_F2S                                        = 0x2A,
366
+    NOTE_G2                                         = 0x2B,
367
+    NOTE_G2S                                        = 0x2C,
368
+    NOTE_A2                                         = 0x2D,
369
+    NOTE_A2S                                        = 0x2E,
370
+    NOTE_B2                                         = 0x2F,
371
+
372
+    NOTE_C3                                         = 0x30,
373
+    NOTE_C3S                                        = 0x31,
374
+    NOTE_D3                                         = 0x32,
375
+    NOTE_D3S                                        = 0x33,
376
+    NOTE_E3                                         = 0x34,
377
+    NOTE_F3                                         = 0x35,
378
+    NOTE_F3S                                        = 0x36,
379
+    NOTE_G3                                         = 0x37,
380
+    NOTE_G3S                                        = 0x38,
381
+    NOTE_A3                                         = 0x39,
382
+    NOTE_A3S                                        = 0x3A,
383
+    NOTE_B3                                         = 0x3B,
384
+
385
+    NOTE_C4                                         = 0x3C,
386
+    NOTE_C4S                                        = 0x3D,
387
+    NOTE_D4                                         = 0x3E,
388
+    NOTE_D4S                                        = 0x3F,
389
+    NOTE_E4                                         = 0x40,
390
+    NOTE_F4                                         = 0x41,
391
+    NOTE_F4S                                        = 0x42,
392
+    NOTE_G4                                         = 0x43,
393
+    NOTE_G4S                                        = 0x44,
394
+    NOTE_A4                                         = 0x45,
395
+    NOTE_A4S                                        = 0x46,
396
+    NOTE_B4                                         = 0x47,
397
+
398
+    NOTE_C5                                         = 0x48,
399
+    NOTE_C5S                                        = 0x49,
400
+    NOTE_D5                                         = 0x4A,
401
+    NOTE_D5S                                        = 0x4B,
402
+    NOTE_E5                                         = 0x4C,
403
+    NOTE_F5                                         = 0x4D,
404
+    NOTE_F5S                                        = 0x4E,
405
+    NOTE_G5                                         = 0x4F,
406
+    NOTE_G5S                                        = 0x50,
407
+    NOTE_A5                                         = 0x51,
408
+    NOTE_A5S                                        = 0x52,
409
+    NOTE_B5                                         = 0x53,
410
+  };
411
+}

+ 118
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/display_list.h View File

@@ -0,0 +1,118 @@
1
+/******************
2
+ * display_list.h *
3
+ *****************/
4
+
5
+/**********************************************************************************
6
+ * Adapted from:                                                                  *
7
+ *     https://github.com/RudolphRiedel/FT800-FT813                               *
8
+ *     By Rudolph Riedel                                                          *
9
+ *                                                                                *
10
+ * MIT License                                                                    *
11
+ *                                                                                *
12
+ * Copyright (c) 2017                                                             *
13
+ *                                                                                *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy   *
15
+ * of this software and associated documentation files (the "Software"), to deal  *
16
+ * in the Software without restriction, including without limitation the rights   *
17
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell      *
18
+ * copies of the Software, and to permit persons to whom the Software is          *
19
+ * furnished to do so, subject to the following conditions:                       *
20
+ *                                                                                *
21
+ * The above copyright notice and this permission notice shall be included in all *
22
+ * copies or substantial portions of the Software.                                *
23
+ *                                                                                *
24
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     *
25
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,       *
26
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE    *
27
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER         *
28
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  *
29
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  *
30
+ * SOFTWARE.                                                                      *
31
+ *                                                                                *
32
+ **********************************************************************************/
33
+
34
+#pragma once
35
+
36
+namespace FTDI {
37
+  /* FT8xx graphics engine specific macros useful for static display list generation */
38
+  inline uint32_t ALPHA_FUNC(uint8_t func, uint8_t ref)        {return DL::ALPHA_FUNC|((func&7UL)<<8)|(ref&255UL);}
39
+  inline uint32_t BEGIN(begin_t prim)                          {return DL::BEGIN|(prim&15UL);}
40
+
41
+  inline uint32_t BITMAP_SOURCE(uint32_t ram_g_addr)           {return DL::BITMAP_SOURCE|(ram_g_addr & (FTDI::ftdi_memory_map::RAM_G_SIZE-1));}
42
+  inline uint32_t BITMAP_HANDLE(uint8_t handle)                {return DL::BITMAP_HANDLE|(handle&31UL);}
43
+  inline uint32_t BITMAP_LAYOUT(uint8_t format, uint16_t linestride, uint16_t height)
44
+                                                               {return DL::BITMAP_LAYOUT|((format&31UL)<<19)|((linestride&1023UL)<<9)|(height&511UL);}
45
+
46
+  inline uint32_t BITMAP_SIZE(uint8_t filter, uint8_t wrapx, uint8_t wrapy, uint16_t width, uint16_t height)
47
+                                                               {return DL::BITMAP_SIZE|((filter&1UL)<<20)|((wrapx&1UL)<<19)|((wrapy&1UL)<<18)|((width&511UL)<<9)|(height&511UL);}
48
+  #if FTDI_API_LEVEL >= 810
49
+  inline uint32_t BITMAP_LAYOUT_H(uint8_t linestride, uint8_t height)
50
+                                                               {return DL::BITMAP_LAYOUT_H|((linestride&3UL)<<2)|(height&3UL);}
51
+  inline uint32_t BITMAP_SIZE_H(uint8_t width, uint8_t height)
52
+                                                               {return DL::BITMAP_SIZE_H|((width&3UL)<<2)|(height&3UL);}
53
+  #endif
54
+  inline uint32_t BITMAP_TRANSFORM_A(uint16_t a)               {return DL::BITMAP_TRANSFORM_A|(a&131071UL);}
55
+  inline uint32_t BITMAP_TRANSFORM_B(uint16_t b)               {return DL::BITMAP_TRANSFORM_B|(b&131071UL);}
56
+  inline uint32_t BITMAP_TRANSFORM_C(uint32_t c)               {return DL::BITMAP_TRANSFORM_C|(c&16777215UL);}
57
+  inline uint32_t BITMAP_TRANSFORM_D(uint16_t d)               {return DL::BITMAP_TRANSFORM_D|(d&131071UL);}
58
+  inline uint32_t BITMAP_TRANSFORM_E(uint16_t e)               {return DL::BITMAP_TRANSFORM_E|(e&131071UL);}
59
+  inline uint32_t BITMAP_TRANSFORM_F(uint32_t f)               {return DL::BITMAP_TRANSFORM_F|(f&16777215UL);}
60
+  inline uint32_t BLEND_FUNC(uint8_t src,uint8_t dst)          {return DL::BLEND_FUNC|((src&7UL)<<3)|(dst&7UL);}
61
+  inline uint32_t CALL(uint16_t dest)                          {return DL::CALL|(dest&65535UL);}
62
+  inline uint32_t CELL(uint8_t cell)                           {return DL::CELL|(cell&127UL);}
63
+  inline uint32_t CLEAR(bool c,bool s,bool t)                  {return DL::CLEAR|((c?1UL:0UL)<<2)|((s?1UL:0UL)<<1)|(t?1UL:0UL);}
64
+  inline uint32_t CLEAR_COLOR_A(uint8_t alpha)                 {return DL::CLEAR_COLOR_A|(alpha&255UL);}
65
+  inline uint32_t CLEAR_COLOR_RGB(uint8_t red, uint8_t green, uint8_t blue)
66
+                                                               {return DL::CLEAR_COLOR_RGB|((red&255UL)<<16)|((green&255UL)<<8)|(blue&255UL);}
67
+  inline uint32_t CLEAR_COLOR_RGB(uint32_t rgb)                {return DL::CLEAR_COLOR_RGB|rgb;}
68
+  inline uint32_t CLEAR_STENCIL(uint8_t s)                     {return DL::CLEAR_STENCIL|(s&255UL);}
69
+  inline uint32_t CLEAR_TAG(uint8_t s)                         {return DL::CLEAR_TAG|(s&255UL);}
70
+  inline uint32_t COLOR_A(uint8_t alpha)                       {return DL::COLOR_A|(alpha&255UL);}
71
+  inline uint32_t COLOR_MASK(bool r, bool g, bool b, bool a)   {return DL::COLOR_MASK|((r?1UL:0UL)<<3)|((g?1UL:0UL)<<2)|((b?1UL:0UL)<<1)|(a?1UL:0UL);}
72
+  inline uint32_t COLOR_RGB(uint8_t red,uint8_t green,uint8_t blue)
73
+                                                               {return DL::COLOR_RGB|((red&255UL)<<16)|((green&255UL)<<8)|(blue&255UL);}
74
+  inline uint32_t COLOR_RGB(uint32_t rgb)                      {return DL::COLOR_RGB|rgb;}
75
+  /* inline uint32_t DISPLAY()                                 {return (0UL<<24)) */
76
+  inline uint32_t END()                                        {return DL::END;}
77
+  inline uint32_t JUMP(uint16_t dest)                          {return DL::JUMP|(dest&65535UL);}
78
+  inline uint32_t LINE_WIDTH(uint16_t width)                   {return DL::LINE_WIDTH|(width&4095UL);}
79
+  inline uint32_t MACRO(uint8_t m)                             {return DL::MACRO|(m&1UL);}
80
+  inline uint32_t POINT_SIZE(uint16_t size)                    {return DL::POINT_SIZE|(size&8191UL);}
81
+  inline uint32_t RESTORE_CONTEXT()                            {return DL::RESTORE_CONTEXT;}
82
+  inline uint32_t RETURN ()                                    {return DL::RETURN;}
83
+  inline uint32_t SAVE_CONTEXT()                               {return DL::SAVE_CONTEXT;}
84
+  inline uint32_t SCISSOR_XY(uint16_t x,uint16_t y) {
85
+    return DL::SCISSOR_XY |
86
+      (FTDI::ftdi_chip >= 810
87
+        ? ((x&2047UL)<<11)|(y&2047UL)
88
+        : ((x& 511UL)<<10)|(y&511UL));
89
+  }
90
+  inline uint32_t SCISSOR_SIZE(uint16_t w,uint16_t h) {
91
+    return DL::SCISSOR_SIZE |
92
+      (FTDI::ftdi_chip >= 810
93
+        ? ((w&4095UL)<<12)|(h&4095UL)
94
+        : ((w&1023UL)<<10)|(h&1023UL));
95
+  }
96
+  inline uint32_t SCISSOR_XY()                                 {return DL::SCISSOR_XY;}
97
+  inline uint32_t SCISSOR_SIZE() {
98
+    return DL::SCISSOR_SIZE |
99
+      (FTDI::ftdi_chip >= 810
100
+        ? (2048UL<<12)|(2048UL)
101
+        : ( 512UL<<10)|( 512UL));
102
+  }
103
+  inline uint32_t STENCIL_FUNC(uint16_t func, uint8_t ref, uint8_t mask)
104
+                                                               {return DL::STENCIL_FUNC|((func&7UL)<<16)|((ref&255UL)<<8)|(mask&255UL);}
105
+  inline uint32_t STENCIL_MASK(uint8_t mask)                   {return DL::STENCIL_MASK|(mask&255UL);}
106
+  inline uint32_t STENCIL_OP(uint8_t sfail, uint8_t spass)     {return DL::STENCIL_OP|(((sfail)&7UL)<<3)|(spass&7UL);}
107
+  inline uint32_t TAG(uint8_t s)                               {return DL::TAG|(s&255UL);}
108
+  inline uint32_t TAG_MASK(bool mask)                          {return DL::TAG_MASK|(mask?1:0);}
109
+  inline uint32_t VERTEX2F(uint16_t x, uint16_t y)             {return DL::VERTEX2F|((x&32767UL)<<15)|(y&32767UL);}
110
+  inline uint32_t VERTEX2II(uint16_t x,uint16_t y, uint8_t handle = 0, uint8_t cell = 0)
111
+                                                               {return DL::VERTEX2II|((x&511UL)<<21)|((y&511UL)<<12)|((handle&31UL)<<7)|(cell&127UL);}
112
+
113
+  #if FTDI_API_LEVEL >= 810
114
+  inline uint32_t VERTEX_FORMAT(uint8_t frac)                  {return DL::VERTEX_FORMAT|(frac&7UL);}
115
+  inline uint32_t VERTEX_TRANSLATE_X(int32_t x)                {return DL::VERTEX_TRANSLATE_X|(x&131071UL);}
116
+  inline uint32_t VERTEX_TRANSLATE_Y(int32_t y)                {return DL::VERTEX_TRANSLATE_Y|(y&131071UL);}
117
+  #endif
118
+}

+ 40
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/ftdi_basic.h View File

@@ -0,0 +1,40 @@
1
+/****************
2
+ * ftdi_basic.h *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2019 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#include "../compat.h"
26
+
27
+#if !defined(__MARLIN_FIRMWARE__)
28
+  #define FTDI_BASIC
29
+#endif
30
+
31
+#ifdef FTDI_BASIC
32
+  #include "registers_ft800.h"
33
+  #include "registers_ft810.h"
34
+  #include "constants.h"
35
+  #include "boards.h"
36
+  #include "commands.h"
37
+  #include "spi.h"
38
+  #include "display_list.h"
39
+  #include "resolutions.h"
40
+#endif

+ 150
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/registers_ft800.h View File

@@ -0,0 +1,150 @@
1
+/*********************
2
+ * registers_ft800.h *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+/****************************************************************************
24
+ * This header defines registers for the FTDI FT800 LCD Driver chip.        *
25
+ ****************************************************************************/
26
+
27
+/*******************************************************************************
28
+ * FT810                                                                       *
29
+ *                                                                             *
30
+ * START    END ADDR   SIZE    NAME           DESCRIPTION                      *
31
+ *                                                                             *
32
+ * 0x000000 0x03FFFF   256 kB  RAM_G          Main Graphics RAM                *
33
+ *                                                                             *
34
+ * 0x0C0000 0x0C0003     4  B  ROM_CHIPID     [0:1] 0x800   Chip Id            *
35
+ *                                            [1:2] 0x0100  Vers ID            *
36
+ *                                                                             *
37
+ * 0x0BB23C 0x0FFFFB   275 kB  ROM_FONT       Font table and bitmap            *
38
+ *                                                                             *
39
+ * 0x0FFFFC 0x0FFFFF     4  B  ROM_FONT_ADDR  Font table pointer address       *
40
+ *                                                                             *
41
+ * 0x100000 0x101FFF     8 kB  RAM_DL         Display List RAM                 *
42
+ *                                                                             *
43
+ * 0x102000 0x1023FF     1 kB  RAM_PAL        Palette RAM                      *
44
+ *                                                                             *
45
+ * 0x102400 0x10257F   380  B  *          Registers                        *
46
+ *                                                                             *
47
+ * 0x108000 0x108FFF     4 kB  RAM_CMD        Command Buffer                   *
48
+ *                                                                             *
49
+ *******************************************************************************/
50
+
51
+#pragma once
52
+
53
+namespace FTDI {
54
+  struct ft800_memory_map {
55
+
56
+    //         MEMORY LOCATIONS     FT800
57
+    static constexpr uint32_t RAM_G          = 0x000000;   // Main Graphics RAM
58
+    static constexpr uint32_t ROM_CHIPID     = 0x0C0000;   // Chip ID/Version ID
59
+    static constexpr uint32_t ROM_FONT       = 0x0BB23C;   // Font ROM
60
+    static constexpr uint32_t ROM_FONT_ADDR  = 0x0FFFFC;   // Font Table Pointer
61
+    static constexpr uint32_t RAM_DL         = 0x100000;   // Display List RAM
62
+    static constexpr uint32_t RAM_PAL        = 0x102000;   // Palette RAM
63
+    static constexpr uint32_t RAM_REG        = 0x102400;   // Registers
64
+    static constexpr uint32_t RAM_CMD        = 0x108000;   // Command Buffer
65
+
66
+    static constexpr uint32_t RAM_G_SIZE     = 256*1024l;  // 256k
67
+  };
68
+
69
+  struct ft800_registers {
70
+    // REGISTERS AND ADDRESSES    FT800
71
+
72
+    //             REGISTER              ADDRESS       SIZE    RESET VALUE     TYPE     DESCRIPTION
73
+
74
+    static constexpr uint32_t ID                = 0x102400;  //    8    0x7C               r     Identification Register, Always 0x7C
75
+    static constexpr uint32_t FRAMES            = 0x102404;  //   32    0x00000000         r     Frame Counter, Since Reset
76
+    static constexpr uint32_t CLOCK             = 0x102408;  //   32    0x00000000         r     Clock cycles, Since Reset
77
+    static constexpr uint32_t FREQUENCY         = 0x10240C;  //   28    0x03938700       r/w     Main Clock Frequency
78
+    static constexpr uint32_t RENDERMODE        = 0x102410;  //    1    0x00             r/w     Rendering Mode: 0 = normal, 1 = single-line
79
+    static constexpr uint32_t SNAPY             = 0x102414;  //   11    0x0000           r/w     Scan Line Select for RENDERMODE 1
80
+    static constexpr uint32_t SNAPSHOT          = 0x102418;  //    1    -                  r     Trigger for RENDERMODE 1
81
+    static constexpr uint32_t CPURESET          = 0x10241C;  //    3    0x02             r/w     RESET Bit2 Audio - Bit1 Touch - Bit0 Graphics
82
+    static constexpr uint32_t TAP_CRC           = 0x102420;  //   32    -                  r     Live Video Tap
83
+    static constexpr uint32_t TAP_MASK          = 0x102424;  //   32    0xFFFFFFFF       r/w     Live Video Tap Mask
84
+    static constexpr uint32_t HCYCLE            = 0x102428;  //   12    0x224            r/w     Horizontal Total Cycle Count
85
+    static constexpr uint32_t HOFFSET           = 0x10242C;  //   12    0x02B            r/w     Horizontal Display Start Offset
86
+    static constexpr uint32_t HSIZE             = 0x102430;  //   12    0x1E0            r/w     Horizontal Display Pixel Count
87
+    static constexpr uint32_t HSYNC0            = 0x102434;  //   12    0x000            r/w     Horizontal Sync Fall Offset
88
+    static constexpr uint32_t HSYNC1            = 0x102438;  //   12    0x029            r/w     Horizontal Sync Rise Offset
89
+    static constexpr uint32_t VCYCLE            = 0x10243C;  //   12    0x124            r/w     Vertical Total Cycle Count
90
+    static constexpr uint32_t VOFFSET           = 0x102440;  //   12    0x00C            r/w     Vertical Display Start Offset
91
+    static constexpr uint32_t VSIZE             = 0x102444;  //   12    0x110            r/w     Vertical Display Line Count
92
+    static constexpr uint32_t VSYNC0            = 0x102448;  //   10    0x000            r/w     Vertical Sync Fall Offset
93
+    static constexpr uint32_t VSYNC1            = 0x10244C;  //   10    0x00A            r/w     Vertical Sync Rise Offset
94
+    static constexpr uint32_t DLSWAP            = 0x102450;  //    2    0x00             r/w     Display List Swap Control
95
+    static constexpr uint32_t ROTATE            = 0x102454;  //    3    0x00             r/w     Screen 90,180, 270 degree rotate
96
+    static constexpr uint32_t OUTBITS           = 0x102458;  //    9    0x1B6            r/w     Output Resolution, 3x3x3 Bits
97
+    static constexpr uint32_t DITHER            = 0x10245C;  //    1    0x01             r/w     Output Dither Enable
98
+    static constexpr uint32_t SWIZZLE           = 0x102460;  //    4    0x00             r/w     Output RGB Swizzle, Pin Change for PCB Routing
99
+    static constexpr uint32_t CSPREAD           = 0x102464;  //    1    0x01             r/w     Output Clock Spreading Enable
100
+    static constexpr uint32_t PCLK_POL          = 0x102468;  //    1    0x00             r/w     PCLK Polarity: 0 = Rising Edge, 1 = Falling Edge
101
+    static constexpr uint32_t PCLK              = 0x10246C;  //    8    0x00             r/w     PCLK Frequency Divider, 0 = Disable Clock
102
+    static constexpr uint32_t TAG_X             = 0x102470;  //   11    0x000            r/w     Tag Query X Coordinate
103
+    static constexpr uint32_t TAG_Y             = 0x102474;  //   11    0x000            r/w     Tag Query Y Coordinate
104
+    static constexpr uint32_t TAG               = 0x102478;  //    8    0x00               r     Tag Query Result
105
+    static constexpr uint32_t VOL_PB            = 0x10247C;  //    8    0xFF             r/w     Audio Playback Volume
106
+    static constexpr uint32_t VOL_SOUND         = 0x102480;  //    8    0xFF             r/w     Audio Synthesizer Volume
107
+    static constexpr uint32_t SOUND             = 0x102484;  //   16    0x0000           r/w     Audio Sound Effect Select
108
+    static constexpr uint32_t PLAY              = 0x102488;  //    1    0x00             r/w     Audio Start Effect Playback
109
+    static constexpr uint32_t GPIO_DIR          = 0x10248C;  //    8    0x80             r/w     GPIO Pin Direction: 0 = Input , 1 = Output
110
+    static constexpr uint32_t GPIO              = 0x102490;  //    8    0x00             r/w     GPIO Pin Values for 0, 1, 7 Drive Strength 2, 3, 4, 5, 6
111
+    static constexpr uint32_t INT_FLAGS         = 0x102498;  //    8    0x00               r     Interrupt Flags, Clear by Reading
112
+    static constexpr uint32_t INT_EN            = 0x10249C;  //    1    0x00             r/w     Global Interrupt Enable
113
+    static constexpr uint32_t INT_MASK          = 0x1024A0;  //    8    0xFF             r/w     Interrupt Enable Mask
114
+    static constexpr uint32_t PLAYBACK_START    = 0x1024A4;  //   20    0x00000          r/w     Audio Playback RAM Start Address
115
+    static constexpr uint32_t PLAYBACK_LENGTH   = 0x1024A8;  //   20    0x00000          r/w     Audio Playback Sample Length (Bytes)
116
+    static constexpr uint32_t PLAYBACK_READPTR  = 0x1024AC;  //   20    -                  r     Audio Playback Read Pointer
117
+    static constexpr uint32_t PLAYBACK_FREQ     = 0x1024B0;  //   16    0x1F40           r/w     Audio Playback Frequency (Hz)
118
+    static constexpr uint32_t PLAYBACK_FORMAT   = 0x1024B4;  //    2    0x00             r/w     Audio Playback Format
119
+    static constexpr uint32_t PLAYBACK_LOOP     = 0x1024B8;  //    1    0x00             r/w     Audio Playback Loop Enable
120
+    static constexpr uint32_t PLAYBACK_PLAY     = 0x1024BC;  //    1    0x00               r     Audio Start Playback
121
+    static constexpr uint32_t PWM_HZ            = 0x1024C0;  //   14    0x00FA           r/w     Backlight PWM Frequency (Hz)
122
+    static constexpr uint32_t PWM_DUTY          = 0x1024C4;  //    8    0x80             r/w     Backlight PWM Duty Cycle: 0 = 0%, 128 = 100%
123
+    static constexpr uint32_t MACRO_0           = 0x1024C8;  //   32    0x00000000       r/w     Display List Macro Command 0
124
+    static constexpr uint32_t MACRO_1           = 0x1024CC;  //   32    0x00000000       r/w     Display List Macro Command 1
125
+    static constexpr uint32_t CMD_READ          = 0x1024E4;  //   12    0x000            r/w     Command Buffer Read Pointer
126
+    static constexpr uint32_t CMD_WRITE         = 0x1024E8;  //   12    0x000            r/w     Command Buffer Write Pointer
127
+    static constexpr uint32_t CMD_DL            = 0x1024EC;  //   13    0x0000           r/w     Command Display List Offset
128
+    static constexpr uint32_t TOUCH_MODE        = 0x1024F0;  //    2    0x03             r/w     Touch-Screen Sampling Mode
129
+    static constexpr uint32_t TOUCH_ADC_MODE    = 0x1024F4;  //    1    0x01             r/w     Select Single Ended or Differential Sampling
130
+    static constexpr uint32_t TOUCH_CHARGE      = 0x1024F8;  //   16    0x1770           r/w     Touch Screen Charge Time, n x 6 Clocks
131
+    static constexpr uint32_t TOUCH_SETTLE      = 0x1024FC;  //    4    0x03             r/w     Touch-Screen Settle Time, n x 6 Clocks
132
+    static constexpr uint32_t TOUCH_OVERSAMPLE  = 0x102500;  //    4    0x07             r/w     Touch-Screen Oversample Factor
133
+    static constexpr uint32_t TOUCH_RZTHRESH    = 0x102504;  //   16    0xFFFF           r/w     Touch-Screen Resistance Threshold
134
+    static constexpr uint32_t TOUCH_RAW_XY      = 0x102508;  //   32    -                  r     Touch-Screen Raw (x-MSB16; y-LSB16)
135
+    static constexpr uint32_t TOUCH_RZ          = 0x10250C;  //   16    -                  r     Touch-Screen Resistance
136
+    static constexpr uint32_t TOUCH_SCREEN_XY   = 0x102510;  //   32    -                  r     Touch-Screen Screen (x-MSB16; y-LSB16)
137
+    static constexpr uint32_t TOUCH_TAG_XY      = 0x102514;  //   32    -                  r     Touch-Screen Tag 0 Lookup (x-MSB16; y-LSB16)
138
+    static constexpr uint32_t TOUCH_TAG         = 0x102518;  //    8    -                  r     Touch-Screen Tag 0 Result
139
+    static constexpr uint32_t TOUCH_TRANSFORM_A = 0x10251C;  //   32    0x00010000       r/w     Touch-Screen Transform Coefficient A (s15.16)
140
+    static constexpr uint32_t TOUCH_TRANSFORM_B = 0x102520;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient B (s15.16)
141
+    static constexpr uint32_t TOUCH_TRANSFORM_C = 0x102524;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient C (s15.16)
142
+    static constexpr uint32_t TOUCH_TRANSFORM_D = 0x102528;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient D (s15.16)
143
+    static constexpr uint32_t TOUCH_TRANSFORM_E = 0x10252C;  //   32    0x00010000       r/w     Touch-Screen Transform Coefficient E (s15.16)
144
+    static constexpr uint32_t TOUCH_TRANSFORM_F = 0x102530;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient F (s15.16)
145
+  //               Reserved Addresses      0x102434 - 0x102470
146
+    static constexpr uint32_t TOUCH_DIRECT_XY   = 0x102574;  //   32    -                  r     Touch-Screen Direct Conversions XY (x-MSB16; y-LSB16)
147
+    static constexpr uint32_t TOUCH_DIRECT_Z1Z2 = 0x102578;  //   32    -                  r     Touch-Screen Direct Conversions Z (z1-MSB16; z2-LSB16)
148
+    static constexpr uint32_t TRACKER           = 0x109000;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
149
+  };
150
+}

+ 185
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/registers_ft810.h View File

@@ -0,0 +1,185 @@
1
+/*********************
2
+ * registers_ft810.h *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+/****************************************************************************
24
+ * This header defines registers for the FTDI FT810 LCD Driver chip.        *
25
+ ****************************************************************************/
26
+
27
+/*******************************************************************************
28
+ * FT810                                                                       *
29
+ *                                                                             *
30
+ * START    END ADDR   SIZE    NAME           DESCRIPTION                      *
31
+ *                                                                             *
32
+ * 0x000000 0x0FFFFF  1024 kB  RAM_G          Main Graphics RAM (0 to 1048572) *
33
+ *                                                                             *
34
+ * 0x0C0000 0x0C0003     4  B  ROM_CHIPID     [0:1] 0x800   Chip Id            *
35
+ *                                            [1:2] 0x0100  Vers ID            *
36
+ *                                                                             *
37
+ * 0x1E0000 0x2FFFFB  1152 kB  ROM_FONT       Font table and bitmap            *
38
+ *                                                                             *
39
+ * 0x2FFFFC 0x2FFFFF     4  B  ROM_FONT_ADDR  Font table pointer address       *
40
+ *                                                                             *
41
+ * 0x300000 0x301FFF     8 kB  RAM_DL         Display List RAM                 *
42
+ *                                                                             *
43
+ * 0x302000 0x302FFF     4 kB  *          Registers                        *
44
+ *                                                                             *
45
+ * 0x308000 0x308FFF     4 kB  RAM_CMD        Command Buffer                   *
46
+ *                                                                             *
47
+ *******************************************************************************/
48
+
49
+#pragma once
50
+
51
+namespace FTDI {
52
+  struct ft810_memory_map {
53
+    //         MEMORY LOCATIONS     FT810
54
+    static constexpr uint32_t RAM_G          = 0x000000;   // Main Graphics RAM
55
+    static constexpr uint32_t ROM_CHIPID     = 0x0C0000;   // Chip ID/Version ID
56
+    static constexpr uint32_t ROM_FONT       = 0x1E0000;   // Font ROM
57
+    static constexpr uint32_t ROM_FONT_ADDR  = 0x2FFFFC;   // Font Table Pointer
58
+    static constexpr uint32_t RAM_DL         = 0x300000;   // Display List RAM
59
+    static constexpr uint32_t RAM_REG        = 0x302000;   // Registers
60
+    static constexpr uint32_t RAM_CMD        = 0x308000;   // Command Buffer
61
+
62
+    static constexpr uint32_t RAM_G_SIZE     = 1024*1024l; // 1024k
63
+  };
64
+
65
+  struct ft810_registers {
66
+    // REGISTERS AND ADDRESSES    FT810
67
+
68
+    //             REGISTER              ADDRESS       SIZE    RESET VALUE     TYPE     DESCRIPTION
69
+
70
+    static constexpr uint32_t ID                = 0x302000;  //    8    0x7C               r     Identification Register, Always 0x7C
71
+    static constexpr uint32_t FRAMES            = 0x302004;  //   32    0x00000000         r     Frame Counter, Since Reset
72
+    static constexpr uint32_t CLOCK             = 0x302008;  //   32    0x00000000         r     Clock cycles, Since Reset
73
+    static constexpr uint32_t FREQUENCY         = 0x30200C;  //   28    0x03938700       r/w     Main Clock Frequency
74
+    static constexpr uint32_t RENDERMODE        = 0x302010;  //    1    0x00             r/w     Rendering Mode: 0 = normal, 1 = single-line
75
+    static constexpr uint32_t SNAPY             = 0x302014;  //   11    0x0000           r/w     Scan Line Select for RENDERMODE 1
76
+    static constexpr uint32_t SNAPSHOT          = 0x302018;  //    1    -                  r     Trigger for RENDERMODE 1
77
+    static constexpr uint32_t SNAPFORMAT        = 0x30201C;  //    6    0x20             r/w     Pixel Format for Scanline Readout
78
+    static constexpr uint32_t CPURESET          = 0x302020;  //    3    0x02             r/w     RESET Bit2 Audio - Bit1 Touch - Bit0 Graphics
79
+    static constexpr uint32_t TAP_CRC           = 0x302024;  //   32    -                  r     Live Video Tap
80
+    static constexpr uint32_t TAP_MASK          = 0x302028;  //   32    0xFFFFFFFF       r/w     Live Video Tap Mask
81
+    static constexpr uint32_t HCYCLE            = 0x30202C;  //   12    0x224            r/w     Horizontal Total Cycle Count
82
+    static constexpr uint32_t HOFFSET           = 0x302030;  //   12    0x02B            r/w     Horizontal Display Start Offset
83
+    static constexpr uint32_t HSIZE             = 0x302034;  //   12    0x1E0            r/w     Horizontal Display Pixel Count
84
+    static constexpr uint32_t HSYNC0            = 0x302038;  //   12    0x000            r/w     Horizontal Sync Fall Offset
85
+    static constexpr uint32_t HSYNC1            = 0x30203C;  //   12    0x029            r/w     Horizontal Sync Rise Offset
86
+    static constexpr uint32_t VCYCLE            = 0x302040;  //   12    0x124            r/w     Vertical Total Cycle Count
87
+    static constexpr uint32_t VOFFSET           = 0x302044;  //   12    0x00C            r/w     Vertical Display Start Offset
88
+    static constexpr uint32_t VSIZE             = 0x302048;  //   12    0x110            r/w     Vertical Display Line Count
89
+    static constexpr uint32_t VSYNC0            = 0x30204C;  //   10    0x000            r/w     Vertical Sync Fall Offset
90
+    static constexpr uint32_t VSYNC1            = 0x302050;  //   10    0x00A            r/w     Vertical Sync Rise Offset
91
+    static constexpr uint32_t DLSWAP            = 0x302054;  //    2    0x00             r/w     Display List Swap Control
92
+    static constexpr uint32_t ROTATE            = 0x302058;  //    3    0x00             r/w     Screen 90,180, 270 degree rotate
93
+    static constexpr uint32_t OUTBITS           = 0x30205C;  //    9    0x1B6            r/w     Output Resolution, 3x3x3 Bits
94
+    static constexpr uint32_t DITHER            = 0x302060;  //    1    0x01             r/w     Output Dither Enable
95
+    static constexpr uint32_t SWIZZLE           = 0x302064;  //    4    0x00             r/w     Output RGB Swizzle, Pin Change for PCB Routing
96
+    static constexpr uint32_t CSPREAD           = 0x302068;  //    1    0x01             r/w     Output Clock Spreading Enable
97
+    static constexpr uint32_t PCLK_POL          = 0x30206C;  //    1    0x00             r/w     PCLK Polarity: 0 = Rising Edge, 1 = Falling Edge
98
+    static constexpr uint32_t PCLK              = 0x302070;  //    8    0x00             r/w     PCLK Frequency Divider, 0 = Disable Clock
99
+    static constexpr uint32_t TAG_X             = 0x302074;  //   11    0x000            r/w     Tag Query X Coordinate
100
+    static constexpr uint32_t TAG_Y             = 0x302078;  //   11    0x000            r/w     Tag Query Y Coordinate
101
+    static constexpr uint32_t TAG               = 0x30207C;  //    8    0x00               r     Tag Query Result
102
+    static constexpr uint32_t VOL_PB            = 0x302080;  //    8    0xFF             r/w     Audio Playback Volume
103
+    static constexpr uint32_t VOL_SOUND         = 0x302084;  //    8    0xFF             r/w     Audio Synthesizer Volume
104
+    static constexpr uint32_t SOUND             = 0x302088;  //   16    0x0000           r/w     Audio Sound Effect Select
105
+    static constexpr uint32_t PLAY              = 0x30208C;  //    1    0x00             r/w     Audio Start Effect Playback
106
+    static constexpr uint32_t GPIO_DIR          = 0x302090;  //    8    0x80             r/w     GPIO Pin Direction: 0 = Input , 1 = Output
107
+    static constexpr uint32_t GPIO              = 0x302094;  //    8    0x00             r/w     GPIO Pin Values for 0, 1, 7 Drive Strength 2, 3, 4, 5, 6
108
+    static constexpr uint32_t GPIOX_DIR         = 0x302098;  //   16    0x8000           r/w     Extended GPIO Pin Direction
109
+    static constexpr uint32_t GPIOX             = 0x30209C;  //   16    0x0080           r/w     Extended GPIO Pin Values
110
+    //             Reserved Addr           0x3020A0
111
+    //             Reserved Addr           0x3020A4
112
+    static constexpr uint32_t INT_FLAGS         = 0x3020A8;  //    8    0x00               r     Interrupt Flags, Clear by Reading
113
+    static constexpr uint32_t INT_EN            = 0x3020AC;  //    1    0x00             r/w     Global Interrupt Enable
114
+    static constexpr uint32_t INT_MASK          = 0x3020B0;  //    8    0xFF             r/w     Interrupt Enable Mask
115
+    static constexpr uint32_t PLAYBACK_START    = 0x3020B4;  //   20    0x00000          r/w     Audio Playback RAM Start Address
116
+    static constexpr uint32_t PLAYBACK_LENGTH   = 0x3020B8;  //   20    0x00000          r/w     Audio Playback Sample Length (Bytes)
117
+    static constexpr uint32_t PLAYBACK_READPTR  = 0x3020BC;  //   20    -                  r     Audio Playback Read Pointer
118
+    static constexpr uint32_t PLAYBACK_FREQ     = 0x3020C0;  //   16    0x1F40           r/w     Audio Playback Frequency (Hz)
119
+    static constexpr uint32_t PLAYBACK_FORMAT   = 0x3020C4;  //    2    0x00             r/w     Audio Playback Format
120
+    static constexpr uint32_t PLAYBACK_LOOP     = 0x3020C8;  //    1    0x00             r/w     Audio Playback Loop Enable
121
+    static constexpr uint32_t PLAYBACK_PLAY     = 0x3020CC;  //    1    0x00               r     Audio Start Playback
122
+    static constexpr uint32_t PWM_HZ            = 0x3020D0;  //   14    0x00FA           r/w     Backlight PWM Frequency (Hz)
123
+    static constexpr uint32_t PWM_DUTY          = 0x3020D4;  //    8    0x80             r/w     Backlight PWM Duty Cycle: 0 = 0%, 128 = 100%
124
+    static constexpr uint32_t MACRO_0           = 0x3020D8;  //   32    0x00000000       r/w     Display List Macro Command 0
125
+    static constexpr uint32_t MACRO_1           = 0x3020DC;  //   32    0x00000000       r/w     Display List Macro Command 1
126
+    //             Reserved Addr           0x3020E0
127
+    //             Reserved Addr           0x3020E4
128
+    //             Reserved Addr           0x3020E8
129
+    //             Reserved Addr           0x3020EC
130
+    //             Reserved Addr           0x3020F0
131
+    //             Reserved Addr           0x3020F4
132
+    static constexpr uint32_t CMD_READ          = 0x3020F8;  //   12    0x000            r/w     Command Buffer Read Pointer
133
+    static constexpr uint32_t CMD_WRITE         = 0x3020FC;  //   12    0x000            r/w     Command Buffer Write Pointer
134
+    static constexpr uint32_t CMD_DL            = 0x302100;  //   13    0x0000           r/w     Command Display List Offset
135
+    static constexpr uint32_t TOUCH_MODE        = 0x302104;  //    2    0x03             r/w     Touch-Screen Sampling Mode
136
+    static constexpr uint32_t TOUCH_ADC_MODE    = 0x302108;  //    1    0x01             r/w     Select Single Ended or Differential Sampling
137
+    static constexpr uint32_t TOUCH_CHARGE      = 0x30210C;  //   16    0x1770           r/w     Touch Screen Charge Time, n x 6 Clocks
138
+    static constexpr uint32_t TOUCH_SETTLE      = 0x302110;  //    4    0x03             r/w     Touch-Screen Settle Time, n x 6 Clocks
139
+    static constexpr uint32_t TOUCH_OVERSAMPLE  = 0x302114;  //    4    0x07             r/w     Touch-Screen Oversample Factor
140
+    static constexpr uint32_t TOUCH_RZTHRESH    = 0x302118;  //   16    0xFFFF           r/w     Touch-Screen Resistance Threshold
141
+    static constexpr uint32_t TOUCH_RAW_XY      = 0x30211C;  //   32    -                  r     Touch-Screen Raw (x-MSB16; y-LSB16)
142
+    static constexpr uint32_t TOUCH_RZ          = 0x302120;  //   16    -                  r     Touch-Screen Resistance
143
+    static constexpr uint32_t TOUCH_SCREEN_XY   = 0x302124;  //   32    -                  r     Touch-Screen Screen (x-MSB16; y-LSB16)
144
+    static constexpr uint32_t TOUCH_TAG_XY      = 0x302128;  //   32    -                  r     Touch-Screen Tag 0 Lookup (x-MSB16; y-LSB16)
145
+    static constexpr uint32_t TOUCH_TAG         = 0x30212C;  //    8    -                  r     Touch-Screen Tag 0 Result
146
+    static constexpr uint32_t TOUCH_TAG1_XY     = 0x302130;  //   32    -                  r     Touch-Screen Tag 1 Lookup
147
+    static constexpr uint32_t TOUCH_TAG1        = 0x302134;  //    8    -                  r     Touch-Screen Tag 1 Result
148
+    static constexpr uint32_t TOUCH_TAG2_XY     = 0x302138;  //   32    -                  r     Touch-Screen Tag 2 Lookup
149
+    static constexpr uint32_t TOUCH_TAG2        = 0x30213C;  //    8    -                  r     Touch-Screen Tag 2 Result
150
+    static constexpr uint32_t TOUCH_TAG3_XY     = 0x302140;  //   32    -                  r     Touch-Screen Tag 3 Lookup
151
+    static constexpr uint32_t TOUCH_TAG3        = 0x302144;  //    8    -                  r     Touch-Screen Tag 3 Result
152
+    static constexpr uint32_t TOUCH_TAG4_XY     = 0x302148;  //   32    -                  r     Touch-Screen Tag 4 Lookup
153
+    static constexpr uint32_t TOUCH_TAG4        = 0x30214C;  //    8    -                  r     Touch-Screen Tag 4 Result
154
+    static constexpr uint32_t TOUCH_TRANSFORM_A = 0x302150;  //   32    0x00010000       r/w     Touch-Screen Transform Coefficient A (s15.16)
155
+    static constexpr uint32_t TOUCH_TRANSFORM_B = 0x302154;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient B (s15.16)
156
+    static constexpr uint32_t TOUCH_TRANSFORM_C = 0x302158;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient C (s15.16)
157
+    static constexpr uint32_t TOUCH_TRANSFORM_D = 0x30215C;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient D (s15.16)
158
+    static constexpr uint32_t TOUCH_TRANSFORM_E = 0x302160;  //   32    0x00010000       r/w     Touch-Screen Transform Coefficient E (s15.16)
159
+    static constexpr uint32_t TOUCH_TRANSFORM_F = 0x302164;  //   32    0x00000000       r/w     Touch-Screen Transform Coefficient F (s15.16)
160
+    static constexpr uint32_t TOUCH_CONFIG      = 0x302168;  //   16    0x8381           r/w     Touch Configuration
161
+    static constexpr uint32_t CTOUCH_TOUCH4_X   = 0x30216C;  //   16    -                  r     Extended Mode Touch Screen
162
+    //             Reserved Addresses      0x302170
163
+    static constexpr uint32_t BIST_EN           = 0x302174;  //    1    0                r/w     BIST Memory Mapping Enable
164
+    //             Reserved Addr           0x302178
165
+    //             Reserved Addr           0x30217C
166
+    static constexpr uint32_t TRIM              = 0x302180;  //    8    0                r/w     Internal Clock Trimming
167
+    static constexpr uint32_t ANA_COMP          = 0x302184;  //    8    0                r/w     Analog Control Register
168
+    static constexpr uint32_t SPI_WIDTH         = 0x302188;  //    3    0                r/w     QSPI Bus Width Setting
169
+    static constexpr uint32_t TOUCH_DIRECT_XY   = 0x30218C;  //   32    -                  r     Touch-Screen Direct Conversions XY (x-MSB16; y-LSB16)
170
+    static constexpr uint32_t TOUCH_DIRECT_Z1Z2 = 0x302190;  //   32    -                  r     Touch-Screen Direct Conversions Z (z1-MSB16; z2-LSB16)
171
+    //             Reserved Addresses      0x302194 - 0x302560
172
+    static constexpr uint32_t DATESTAMP         = 0x320564;  //  128    -                  r     Stamp Date Code
173
+    static constexpr uint32_t CMDB_SPACE        = 0x302574;  //   12    0xFFC            r/w     Command DL Space Available
174
+    static constexpr uint32_t CMDB_WRITE        = 0x302578;  //   32    0                  w     Command DL Write
175
+
176
+    static constexpr uint32_t TRACKER           = 0x309000;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
177
+    static constexpr uint32_t TRACKER_1         = 0x309004;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
178
+    static constexpr uint32_t TRACKER_2         = 0x309008;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
179
+    static constexpr uint32_t TRACKER_3         = 0x30900C;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
180
+    static constexpr uint32_t TRACKER_4         = 0x309010;  //   32    0x00000000       r/w     Track Register (Track Value MSB16; Tag Value - LSB8)
181
+
182
+    static constexpr uint32_t MEDIAFIFO_READ    = 0x309014;  //   32    0x00000000       r/w     Media FIFO read pointer
183
+    static constexpr uint32_t MEDIAFIFO_WRITE   = 0x309018;  //   32    0x00000000       r/w     Media FIFO write pointer
184
+  };
185
+}

+ 128
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/resolutions.h View File

@@ -0,0 +1,128 @@
1
+/*****************
2
+ * resolutions.h *
3
+ *****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2019 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+/***
26
+ * The FT8xx has odd registers that don't correspond to timing values in
27
+ * display datasheets. This macro computes the register values using the
28
+ * formulas given in the document:
29
+ *
30
+ *     Bridgetek Application Note
31
+ *     AN_336 FT8xx
32
+ *     Selecting an LCD Display
33
+ *     Version 2.1
34
+ *     Issue Date: 2017-11-14
35
+ *
36
+ */
37
+#define COMPUTE_REGS_FROM_DATASHEET \
38
+    constexpr uint16_t Hoffset              = thfp + thb - 1; \
39
+    constexpr uint16_t Hcycle               = th; \
40
+    constexpr uint16_t Hsync0               = thfp - 1 ; \
41
+    constexpr uint16_t Hsync1               = thfp + thpw - 1; \
42
+    constexpr uint16_t Voffset              = tvfp + tvb - 1; \
43
+    constexpr uint16_t Vcycle               = tv; \
44
+    constexpr uint16_t Vsync0               = tvfp - 1; \
45
+    constexpr uint16_t Vsync1               = tvfp + tvpw - 1; \
46
+    static_assert(thfp + thb + Hsize == th, "Mismatch in display th"); \
47
+    static_assert(tvfp + tvb + Vsize == tv, "Mismatch in display tv");
48
+
49
+#ifdef TOUCH_UI_320x240
50
+  namespace FTDI {
51
+    constexpr uint8_t Pclk                 =    8;
52
+    constexpr uint8_t Pclkpol              =    0;
53
+    constexpr uint16_t Hsize               =  320;
54
+    constexpr uint16_t Vsize               =  240;
55
+    constexpr uint16_t Vsync0              =    0;
56
+    constexpr uint16_t Vsync1              =    2;
57
+    constexpr uint16_t Voffset             =   13;
58
+    constexpr uint16_t Vcycle              =  263;
59
+    constexpr uint16_t Hsync0              =    0;
60
+    constexpr uint16_t Hsync1              =   10;
61
+    constexpr uint16_t Hoffset             =   70;
62
+    constexpr uint16_t Hcycle              =  408;
63
+
64
+    constexpr uint32_t default_transform_a =  0x000054ad;
65
+    constexpr uint32_t default_transform_b =  0xffffff52;
66
+    constexpr uint32_t default_transform_c =  0xfff7f6e4;
67
+    constexpr uint32_t default_transform_d =  0x00000065;
68
+    constexpr uint32_t default_transform_e =  0xffffbe3b;
69
+    constexpr uint32_t default_transform_f =  0x00f68e75;
70
+  }
71
+
72
+#elif defined(TOUCH_UI_480x272)
73
+  namespace FTDI {
74
+    constexpr uint8_t  Pclk                 =    7;
75
+    constexpr uint8_t  Pclkpol              =    1;
76
+    constexpr uint16_t Hsize                =  480;
77
+    constexpr uint16_t Vsize                =  272;
78
+
79
+    constexpr uint16_t th                   =  525; // One horizontal line
80
+    constexpr uint16_t thfp                 =   43; // HS Front porch
81
+    constexpr uint16_t thb                  =    2; // HS Back porch (blanking)
82
+    constexpr uint16_t thpw                 =   41; // HS pulse width
83
+
84
+    constexpr uint16_t tv                   =  286; // Vertical period time
85
+    constexpr uint16_t tvfp                 =   12; // VS Front porch
86
+    constexpr uint16_t tvb                  =    2; // VS Back porch (blanking)
87
+    constexpr uint16_t tvpw                 =   10; // VS pulse width
88
+
89
+    COMPUTE_REGS_FROM_DATASHEET
90
+
91
+    constexpr uint32_t default_transform_a  =  0x00008100;
92
+    constexpr uint32_t default_transform_b  =  0x00000000;
93
+    constexpr uint32_t default_transform_c  =  0xFFF18000;
94
+    constexpr uint32_t default_transform_d  =  0x00000000;
95
+    constexpr uint32_t default_transform_e  =  0xFFFFB100;
96
+    constexpr uint32_t default_transform_f  =  0x0120D000;
97
+  }
98
+
99
+#elif defined(TOUCH_UI_800x480)
100
+  namespace FTDI {
101
+    constexpr uint8_t  Pclk                 =    3;
102
+    constexpr uint8_t  Pclkpol              =    1;
103
+    constexpr uint16_t Hsize                =  800;
104
+    constexpr uint16_t Vsize                =  480;
105
+
106
+    constexpr uint16_t th                   = 1056; // One horizontal line
107
+    constexpr uint16_t thfp                 =  210; // HS Front porch
108
+    constexpr uint16_t thb                  =   46; // HS Back porch (blanking)
109
+    constexpr uint16_t thpw                 =   23; // HS pulse width
110
+
111
+    constexpr uint16_t tv                   =  525; // Vertical period time
112
+    constexpr uint16_t tvfp                 =   22; // VS Front porch
113
+    constexpr uint16_t tvb                  =   23; // VS Back porch (blanking)
114
+    constexpr uint16_t tvpw                 =   10; // VS pulse width
115
+
116
+    COMPUTE_REGS_FROM_DATASHEET
117
+
118
+    constexpr uint32_t default_transform_a  =  0x0000D8B9;
119
+    constexpr uint32_t default_transform_b  =  0x00000124;
120
+    constexpr uint32_t default_transform_c  =  0xFFE23926;
121
+    constexpr uint32_t default_transform_d  =  0xFFFFFF51;
122
+    constexpr uint32_t default_transform_e  =  0xFFFF7E4F;
123
+    constexpr uint32_t default_transform_f  =  0x01F0AF70;
124
+  }
125
+
126
+#else
127
+  #error Unknown or no LULZBOT_TOUCH_UI display resolution specified. To add a display resolution, modify "ftdi_eve_resolutions.h"
128
+#endif

+ 178
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/spi.cpp View File

@@ -0,0 +1,178 @@
1
+/***********
2
+ * spi.cpp *
3
+ ***********/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "ftdi_basic.h"
24
+
25
+#ifdef FTDI_BASIC
26
+
27
+/********************************* SPI Functions *********************************/
28
+
29
+namespace FTDI {
30
+  #if !defined(CLCD_USE_SOFT_SPI)
31
+    SPISettings SPI::spi_settings(SPI_FREQUENCY, MSBFIRST, SPI_MODE0);
32
+  #endif
33
+
34
+  void SPI::spi_init (void) {
35
+    SET_OUTPUT(CLCD_MOD_RESET); // Module Reset (a.k.a. PD, not SPI)
36
+    WRITE(CLCD_MOD_RESET, 0); // start with module in power-down
37
+
38
+    SET_OUTPUT(CLCD_SPI_CS);
39
+    WRITE(CLCD_SPI_CS, 1);
40
+
41
+    #ifdef SPI_FLASH_SS
42
+      SET_OUTPUT(SPI_FLASH_SS);
43
+      WRITE(SPI_FLASH_SS, 1);
44
+    #endif
45
+
46
+    #ifdef CLCD_USE_SOFT_SPI
47
+      SET_OUTPUT(CLCD_SOFT_SPI_MOSI);
48
+      WRITE(CLCD_SOFT_SPI_MOSI, 1);
49
+
50
+      SET_OUTPUT(CLCD_SOFT_SPI_SCLK);
51
+      WRITE(CLCD_SOFT_SPI_SCLK, 0);
52
+
53
+      SET_INPUT_PULLUP(CLCD_SOFT_SPI_MISO);
54
+    #else
55
+      ::SPI.begin();
56
+    #endif
57
+  }
58
+
59
+  #ifdef CLCD_USE_SOFT_SPI
60
+    uint8_t SPI::_soft_spi_xfer (uint8_t spiOutByte) {
61
+      uint8_t spiIndex  = 0x80;
62
+      uint8_t spiInByte = 0;
63
+      uint8_t k;
64
+
65
+      noInterrupts();
66
+      for(k = 0; k <8; k++) {  // Output and Read each bit of spiOutByte and spiInByte
67
+        if (spiOutByte & spiIndex) {   // Output MOSI Bit
68
+          WRITE(CLCD_SOFT_SPI_MOSI, 1);
69
+        }
70
+        else {
71
+          WRITE(CLCD_SOFT_SPI_MOSI, 0);
72
+        }
73
+        WRITE(CLCD_SOFT_SPI_SCLK, 1);   // Pulse Clock
74
+        WRITE(CLCD_SOFT_SPI_SCLK, 0);
75
+
76
+        if (READ(CLCD_SOFT_SPI_MISO)) {
77
+          spiInByte |= spiIndex;
78
+        }
79
+
80
+        spiIndex >>= 1;
81
+      }
82
+      interrupts();
83
+      return spiInByte;
84
+    }
85
+  #endif
86
+
87
+  #ifdef CLCD_USE_SOFT_SPI
88
+    void SPI::_soft_spi_send (uint8_t spiOutByte) {
89
+      uint8_t spiIndex  = 0x80;
90
+      uint8_t k;
91
+
92
+      noInterrupts();
93
+      for(k = 0; k <8; k++) {         // Output each bit of spiOutByte
94
+        if (spiOutByte & spiIndex) {   // Output MOSI Bit
95
+          WRITE(CLCD_SOFT_SPI_MOSI, 1);
96
+        }
97
+        else {
98
+          WRITE(CLCD_SOFT_SPI_MOSI, 0);
99
+        }
100
+        WRITE(CLCD_SOFT_SPI_SCLK, 1);   // Pulse Clock
101
+        WRITE(CLCD_SOFT_SPI_SCLK, 0);
102
+
103
+        spiIndex >>= 1;
104
+      }
105
+      interrupts();
106
+    }
107
+  #endif
108
+
109
+  void SPI::spi_read_bulk (void *data, uint16_t len) {
110
+    uint8_t* p = (uint8_t *)data;
111
+    #if !defined(CLCD_USE_SOFT_SPI)
112
+      ::SPI.transfer(p, len);
113
+    #else
114
+      while (len--) *p++ = spi_recv();
115
+    #endif
116
+  }
117
+
118
+  bool SPI::spi_verify_bulk (const void *data, uint16_t len) {
119
+    const uint8_t* p = (const uint8_t *)data;
120
+    while (len--) if (*p++ != spi_recv()) return false;
121
+    return true;
122
+  }
123
+
124
+  // CLCD SPI - Chip Select
125
+  void SPI::spi_ftdi_select (void) {
126
+    #if !defined(CLCD_USE_SOFT_SPI)
127
+      ::SPI.beginTransaction(spi_settings);
128
+    #endif
129
+    WRITE(CLCD_SPI_CS, 0);
130
+    delayMicroseconds(1);
131
+  }
132
+
133
+  // CLCD SPI - Chip Deselect
134
+  void SPI::spi_ftdi_deselect (void) {
135
+    WRITE(CLCD_SPI_CS, 1);
136
+    #if !defined(CLCD_USE_SOFT_SPI)
137
+      ::SPI.endTransaction();
138
+    #endif
139
+  }
140
+
141
+  #ifdef SPI_FLASH_SS
142
+  // Serial SPI Flash SPI - Chip Select
143
+  void SPI::spi_flash_select () {
144
+    #if !defined(CLCD_USE_SOFT_SPI)
145
+    ::SPI.beginTransaction(spi_settings);
146
+    #endif
147
+    WRITE(SPI_FLASH_SS, 0);
148
+    delayMicroseconds(1);
149
+  }
150
+
151
+  // Serial SPI Flash SPI - Chip Deselect
152
+  void SPI::spi_flash_deselect () {
153
+    WRITE(SPI_FLASH_SS, 1);
154
+    #if !defined(CLCD_USE_SOFT_SPI)
155
+    ::SPI.endTransaction();
156
+    #endif
157
+  }
158
+  #endif
159
+
160
+  // Not really a SPI signal...
161
+  void SPI::ftdi_reset (void) {
162
+    WRITE(CLCD_MOD_RESET, 0);
163
+    delay(6); /* minimum time for power-down is 5ms */
164
+    WRITE(CLCD_MOD_RESET, 1);
165
+    delay(21); /* minimum time to allow from rising PD_N to first access is 20ms */
166
+  }
167
+
168
+  // Not really a SPI signal...
169
+  void SPI::test_pulse(void)
170
+  {
171
+    #ifdef CLCD_AUX_0
172
+      WRITE(CLCD_AUX_0, 1);
173
+      delayMicroseconds(10);
174
+      WRITE(CLCD_AUX_0, 0);
175
+    #endif
176
+  }
177
+}
178
+#endif // FTDI_BASIC

+ 128
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/basic/spi.h View File

@@ -0,0 +1,128 @@
1
+/*********
2
+ * spi.h *
3
+ *********/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#if !defined(CLCD_USE_SOFT_SPI)
26
+  #include <SPI.h>
27
+#endif
28
+
29
+namespace FTDI {
30
+  namespace SPI {
31
+    #if !defined(CLCD_USE_SOFT_SPI)
32
+      extern SPISettings spi_settings;
33
+    #endif
34
+
35
+    uint8_t  _soft_spi_xfer (uint8_t val);
36
+    void     _soft_spi_send (uint8_t val);
37
+
38
+    void     spi_init           ();
39
+
40
+    void     spi_ftdi_select    ();
41
+    void     spi_ftdi_deselect  ();
42
+
43
+    void     spi_flash_select   ();
44
+    void     spi_flash_deselect ();
45
+
46
+    inline uint8_t spi_recv() {
47
+      #ifdef CLCD_USE_SOFT_SPI
48
+        return _soft_spi_xfer(0x00);
49
+      #else
50
+        return ::SPI.transfer(0x00);
51
+      #endif
52
+    };
53
+
54
+    inline void spi_send (uint8_t val) {
55
+      #ifdef CLCD_USE_SOFT_SPI
56
+        _soft_spi_send(val);
57
+      #else
58
+        ::SPI.transfer(val);
59
+      #endif
60
+    };
61
+
62
+    inline void       spi_write_8    (uint8_t val)    {spi_send(val);};
63
+    inline uint8_t    spi_read_8     ()               {return spi_recv();};
64
+
65
+    namespace least_significant_byte_first {
66
+      inline void     spi_write_16   (uint16_t val)   {spi_send(val >> 0);
67
+                                                       spi_send(val >> 8);};
68
+      inline void     spi_write_32   (uint32_t val)   {spi_send(val >> 0);
69
+                                                       spi_send(val >> 8);
70
+                                                       spi_send(val >> 16);
71
+                                                       spi_send(val >> 24);};
72
+
73
+      inline uint8_t  spi_read_8     ()               {return spi_recv();};
74
+      inline uint16_t spi_read_16    ()               {return (((uint16_t) spi_recv()) <<  0) |
75
+                                                              (((uint16_t) spi_recv()) <<  8);};
76
+      inline uint32_t spi_read_32    ()               {return (((uint32_t) spi_recv()) <<  0) |
77
+                                                              (((uint32_t) spi_recv()) <<  8) |
78
+                                                              (((uint32_t) spi_recv()) << 16) |
79
+                                                              (((uint32_t) spi_recv()) << 24);};
80
+    }
81
+
82
+    namespace most_significant_byte_first {
83
+      inline void     spi_write_16   (uint16_t val)   {spi_send(val >> 8);
84
+                                                       spi_send(val >> 0);};
85
+      inline void     spi_write_24   (uint32_t val)   {spi_send(val >> 16);
86
+                                                       spi_send(val >> 8);
87
+                                                       spi_send(val >> 0);};
88
+      inline void     spi_write_32   (uint32_t val)   {spi_send(val >> 24);
89
+                                                       spi_send(val >> 16);
90
+                                                       spi_send(val >> 8);
91
+                                                       spi_send(val >> 0);};
92
+
93
+      inline uint16_t spi_read_16    ()               {return (((uint16_t) spi_recv()) <<  8) |
94
+                                                              (((uint16_t) spi_recv()) <<  0);};
95
+      inline uint32_t spi_read_32    ()               {return (((uint32_t) spi_recv()) << 24) |
96
+                                                              (((uint32_t) spi_recv()) << 16) |
97
+                                                              (((uint32_t) spi_recv()) <<  8) |
98
+                                                              (((uint32_t) spi_recv()) <<  0);};
99
+    }
100
+
101
+    inline uint8_t ram_write(const uint8_t *p) {return *p;}
102
+    inline uint8_t pgm_write(const uint8_t *p) {return pgm_read_byte(p);}
103
+
104
+    typedef uint8_t (*bulk_write_op)(const uint8_t*);
105
+
106
+    // Generic template for function for writing multiple bytes, plus padding bytes.
107
+    // The template parameter op is an inlineable function which is applied to each byte.
108
+
109
+    template<bulk_write_op byte_op>
110
+    void spi_write_bulk(const void *data, uint16_t len, uint8_t padding) {
111
+      const uint8_t* p = (const uint8_t *)data;
112
+      while (len--)     spi_send(byte_op(p++));
113
+      while (padding--) spi_send(0);
114
+    }
115
+
116
+    template<bulk_write_op byte_op>
117
+    void spi_write_bulk(const void *data, uint16_t len) {
118
+      const uint8_t* p = (const uint8_t *)data;
119
+      while (len--) spi_send(byte_op(p++));
120
+    }
121
+
122
+    void spi_read_bulk(      void *data, uint16_t len);
123
+    bool spi_verify_bulk(const void *data, uint16_t len);
124
+
125
+    void ftdi_reset(void);
126
+    void test_pulse(void);
127
+  }
128
+}

+ 211
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/compat.h View File

@@ -0,0 +1,211 @@
1
+/****************************************************************************
2
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
3
+ *                                                                          *
4
+ *   This program is free software: you can redistribute it and/or modify   *
5
+ *   it under the terms of the GNU General Public License as published by   *
6
+ *   the Free Software Foundation, either version 3 of the License, or      *
7
+ *   (at your option) any later version.                                    *
8
+ *                                                                          *
9
+ *   This program is distributed in the hope that it will be useful,        *
10
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
11
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
12
+ *   GNU General Public License for more details.                           *
13
+ *                                                                          *
14
+ *   To view a copy of the GNU General Public License, go to the following  *
15
+ *   location: <http://www.gnu.org/licenses/>.                              *
16
+ ****************************************************************************/
17
+
18
+#pragma once
19
+
20
+#include "../config.h"
21
+
22
+#ifdef __MARLIN_FIRMWARE__
23
+  // Marlin will define the I/O functions for us
24
+
25
+  #if ENABLED(LULZBOT_TOUCH_UI)
26
+    #define FTDI_BASIC
27
+    #define FTDI_EXTENDED
28
+  #endif
29
+#else
30
+  #include "Arduino.h"
31
+
32
+  #if !defined(CLCD_USE_SOFT_SPI)
33
+    #include "SPI.h"
34
+  #endif
35
+
36
+  namespace fast_io {
37
+
38
+    template<typename port_t,uint8_t bits>
39
+    struct port_pin {
40
+      typedef port_t port;
41
+      static inline void set_high()         {port::port() = (port::port() |   bits);}
42
+      static inline void set_low()          {port::port() = (port::port() & (~bits));}
43
+      static inline void set_input()        {port::ddr()  = (port::ddr()  & (~bits));}
44
+      static inline void set_input_pullup() {set_input(); set_high();}
45
+      static inline void set_output()       {port::ddr()  = (port::ddr()  |   bits);}
46
+      static inline uint8_t read()          {return port::pin() & bits;}
47
+      static inline void write(bool v)      {if (v) set_high(); else set_low();}
48
+    };
49
+
50
+    #define MAKE_AVR_PORT_PINS(ID) \
51
+      struct port_##ID { \
52
+        static volatile uint8_t &pin()  {return PIN##ID;}; \
53
+        static volatile uint8_t &port() {return PORT##ID;}; \
54
+        static volatile uint8_t &ddr()  {return DDR##ID;}; \
55
+      }; \
56
+      typedef port_pin<port_##ID, 0b00000001> AVR_##ID##0; \
57
+      typedef port_pin<port_##ID, 0b00000010> AVR_##ID##1; \
58
+      typedef port_pin<port_##ID, 0b00000100> AVR_##ID##2; \
59
+      typedef port_pin<port_##ID, 0b00001000> AVR_##ID##3; \
60
+      typedef port_pin<port_##ID, 0b00010000> AVR_##ID##4; \
61
+      typedef port_pin<port_##ID, 0b00100000> AVR_##ID##5; \
62
+      typedef port_pin<port_##ID, 0b01000000> AVR_##ID##6; \
63
+      typedef port_pin<port_##ID, 0b10000000> AVR_##ID##7;
64
+
65
+    #ifdef PORTA
66
+      MAKE_AVR_PORT_PINS(A);
67
+    #endif
68
+    #ifdef PORTB
69
+      MAKE_AVR_PORT_PINS(B);
70
+    #endif
71
+    #ifdef PORTC
72
+      MAKE_AVR_PORT_PINS(C);
73
+    #endif
74
+    #ifdef PORTD
75
+      MAKE_AVR_PORT_PINS(D);
76
+    #endif
77
+    #ifdef PORTE
78
+      MAKE_AVR_PORT_PINS(E);
79
+    #endif
80
+    #ifdef PORTF
81
+      MAKE_AVR_PORT_PINS(F);
82
+    #endif
83
+    #ifdef PORTG
84
+      MAKE_AVR_PORT_PINS(G);
85
+    #endif
86
+    #ifdef PORTH
87
+      MAKE_AVR_PORT_PINS(H);
88
+    #endif
89
+    #ifdef PORTJ
90
+      MAKE_AVR_PORT_PINS(J);
91
+    #endif
92
+    #ifdef PORTK
93
+      MAKE_AVR_PORT_PINS(K);
94
+    #endif
95
+    #ifdef PORTL
96
+      MAKE_AVR_PORT_PINS(L);
97
+    #endif
98
+    #ifdef PORTQ
99
+      MAKE_AVR_PORT_PINS(Q);
100
+    #endif
101
+    #ifdef PORTR
102
+      MAKE_AVR_PORT_PINS(R);
103
+    #endif
104
+
105
+    #undef MAKE_AVR_PORT_PINS
106
+
107
+    template<uint8_t p>
108
+    struct arduino_digital_pin {
109
+      static constexpr uint8_t pin = p;
110
+      static inline void set_high()          {digitalWrite(p, HIGH);}
111
+      static inline void set_low()           {digitalWrite(p, LOW);}
112
+      static inline void set_input()         {pinMode(p, INPUT);}
113
+      static inline void set_input_pullup()  {pinMode(p, INPUT_PULLUP);}
114
+      static inline void set_output()        {pinMode(p, OUTPUT);}
115
+      static inline uint8_t read()           {return digitalRead(p);}
116
+      static inline void write(bool v)       {digitalWrite(p, v ? HIGH : LOW);}
117
+    };
118
+
119
+    #define MAKE_ARDUINO_PINS(ID) typedef arduino_digital_pin<ID> ARDUINO_DIGITAL_##ID;
120
+    MAKE_ARDUINO_PINS( 0);
121
+    MAKE_ARDUINO_PINS( 1);
122
+    MAKE_ARDUINO_PINS( 2);
123
+    MAKE_ARDUINO_PINS( 3);
124
+    MAKE_ARDUINO_PINS( 4);
125
+    MAKE_ARDUINO_PINS( 5);
126
+    MAKE_ARDUINO_PINS( 6);
127
+    MAKE_ARDUINO_PINS( 7);
128
+    MAKE_ARDUINO_PINS( 8);
129
+    MAKE_ARDUINO_PINS( 9);
130
+    MAKE_ARDUINO_PINS(10);
131
+    MAKE_ARDUINO_PINS(11);
132
+    MAKE_ARDUINO_PINS(12);
133
+    MAKE_ARDUINO_PINS(13);
134
+    MAKE_ARDUINO_PINS(14);
135
+    MAKE_ARDUINO_PINS(15);
136
+    MAKE_ARDUINO_PINS(16);
137
+    MAKE_ARDUINO_PINS(17);
138
+    MAKE_ARDUINO_PINS(18);
139
+    MAKE_ARDUINO_PINS(19);
140
+    MAKE_ARDUINO_PINS(10);
141
+    MAKE_ARDUINO_PINS(21);
142
+    MAKE_ARDUINO_PINS(22);
143
+    MAKE_ARDUINO_PINS(23);
144
+    MAKE_ARDUINO_PINS(24);
145
+    MAKE_ARDUINO_PINS(25);
146
+    MAKE_ARDUINO_PINS(26);
147
+    MAKE_ARDUINO_PINS(27);
148
+    MAKE_ARDUINO_PINS(28);
149
+    MAKE_ARDUINO_PINS(29);
150
+    MAKE_ARDUINO_PINS(30);
151
+    MAKE_ARDUINO_PINS(31);
152
+    MAKE_ARDUINO_PINS(32);
153
+    MAKE_ARDUINO_PINS(33);
154
+    MAKE_ARDUINO_PINS(34);
155
+    MAKE_ARDUINO_PINS(35);
156
+    MAKE_ARDUINO_PINS(36);
157
+    MAKE_ARDUINO_PINS(37);
158
+    MAKE_ARDUINO_PINS(38);
159
+    MAKE_ARDUINO_PINS(39);
160
+    MAKE_ARDUINO_PINS(40);
161
+    MAKE_ARDUINO_PINS(41);
162
+    MAKE_ARDUINO_PINS(42);
163
+    MAKE_ARDUINO_PINS(43);
164
+    MAKE_ARDUINO_PINS(44);
165
+    MAKE_ARDUINO_PINS(45);
166
+    MAKE_ARDUINO_PINS(46);
167
+    MAKE_ARDUINO_PINS(47);
168
+    MAKE_ARDUINO_PINS(48);
169
+    MAKE_ARDUINO_PINS(49);
170
+    MAKE_ARDUINO_PINS(50);
171
+    MAKE_ARDUINO_PINS(51);
172
+    MAKE_ARDUINO_PINS(52);
173
+    MAKE_ARDUINO_PINS(53);
174
+    #undef MAKE_ARDUINO_PINS
175
+  } // namespace fast_io
176
+
177
+  #define SET_INPUT(pin)               fast_io::pin::set_input()
178
+  #define SET_INPUT_PULLUP(pin)        fast_io::pin::set_input(); fast_io::pin::set_high()
179
+  #define SET_OUTPUT(pin)              fast_io::pin::set_output()
180
+  #define READ(pin)                    fast_io::pin::read()
181
+  #define WRITE(pin, value)            fast_io::pin::write(value)
182
+
183
+  #ifndef pgm_read_word_far
184
+  #define pgm_read_word_far pgm_read_word
185
+  #endif
186
+
187
+  #ifndef pgm_read_dword_far
188
+  #define pgm_read_dword_far pgm_read_dword
189
+  #endif
190
+
191
+  #ifndef pgm_read_ptr_far
192
+  #define pgm_read_ptr_far pgm_read_ptr
193
+  #endif
194
+
195
+  #define SERIAL_ECHO_START()
196
+  #define SERIAL_ECHOLNPGM(str)        Serial.println(F(str))
197
+  #define SERIAL_ECHOPGM(str)          Serial.print(F(str))
198
+  #define SERIAL_ECHOLNPAIR(str, val) {Serial.print(F(str)); Serial.println(val);}
199
+  #define SERIAL_ECHOPAIR(str, val)   {Serial.print(F(str)); Serial.print(val);}
200
+
201
+  #define safe_delay delay
202
+
203
+  // Remove compiler warning on an unused variable
204
+  #ifndef UNUSED
205
+    #if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
206
+      #define UNUSED(X) (void)X
207
+    #else
208
+      #define UNUSED(x) ((void)(x))
209
+    #endif
210
+  #endif
211
+#endif //!defined(__MARLIN_FIRMWARE__)

+ 49
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/bitmap_info.h View File

@@ -0,0 +1,49 @@
1
+/*****************
2
+ * bitmap_info.h *
3
+ *****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+#ifndef FORCEDINLINE
25
+  #define FORCEDINLINE __attribute__((always_inline)) inline
26
+#endif
27
+
28
+namespace FTDI {
29
+   // The following functions *must* be inlined since we are relying on the compiler to do
30
+   // substitution of the constants from the data structure rather than actually storing
31
+   // it in PROGMEM (which would fail, since we are not using pgm_read to read them).
32
+   // Plus, by inlining, all the equations are evaluated at compile-time as everything
33
+   // should be a constant.
34
+
35
+   typedef struct {
36
+     const uint8_t  format;
37
+     const uint16_t linestride;
38
+     const uint8_t  filter;
39
+     const uint8_t  wrapx;
40
+     const uint8_t  wrapy;
41
+     const uint32_t RAMG_offset;
42
+     const uint16_t width;
43
+     const uint16_t height;
44
+   } bitmap_info_t;
45
+
46
+   FORCEDINLINE uint32_t BITMAP_SOURCE (const bitmap_info_t& info) {return BITMAP_SOURCE (ftdi_memory_map::RAM_G + info.RAMG_offset);};
47
+   FORCEDINLINE uint32_t BITMAP_LAYOUT (const bitmap_info_t& info) {return BITMAP_LAYOUT (info.format, info.linestride, info.height);};
48
+   FORCEDINLINE uint32_t BITMAP_SIZE   (const bitmap_info_t& info) {return BITMAP_SIZE   (info.filter, info.wrapx, info.wrapy, info.width, info.height);}
49
+}

+ 29
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/command_processor.cpp View File

@@ -0,0 +1,29 @@
1
+/*************************
2
+ * command_processor.cpp *
3
+ *************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018                                        *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#ifdef FTDI_EXTENDED
25
+
26
+CommandProcessor::btn_style_func_t  *CommandProcessor::_btn_style_callback = CommandProcessor::default_button_style_func;
27
+bool CommandProcessor::is_tracking = false;
28
+
29
+#endif // FTDI_EXTENDED

+ 347
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/command_processor.h View File

@@ -0,0 +1,347 @@
1
+/***********************
2
+ * command_processor.h *
3
+ ***********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+typedef struct {
25
+  uint32_t bg;
26
+  uint32_t grad;
27
+  uint32_t fg;
28
+  uint32_t rgb;
29
+} btn_colors;
30
+
31
+/**************************** Enhanced Command Processor **************************/
32
+
33
+/* The CommandProcessor class wraps the CommandFifo with several features to make
34
+ * defining user interfaces much easier.
35
+ *
36
+ *   - Implements chaining on all methods
37
+ *   - Automatically adds text to button, toggle, text and keys.
38
+ *   - Constrains all widgets to fit inside a box for ease of layout.
39
+ *   - Font size is specified using a chained modifier.
40
+ *   - Option argument is given the default OPT_3D value.
41
+ */
42
+
43
+class CommandProcessor : public CLCD::CommandFifo {
44
+  public:
45
+    static constexpr uint8_t STYLE_DISABLED = 0x80;
46
+
47
+  private:
48
+    static bool default_button_style_func(CommandProcessor &, uint8_t tag, uint8_t & /*style*/, uint16_t &options, bool) {
49
+      if (tag != 0 && FTDI::EventLoop::get_pressed_tag() == tag) {
50
+        options = FTDI::OPT_FLAT;
51
+      }
52
+      return false;
53
+    }
54
+
55
+    typedef bool btn_style_func_t(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post);
56
+
57
+    static btn_style_func_t  *_btn_style_callback;
58
+    static bool is_tracking;
59
+    int8_t  _font = 26, _tag = 0;
60
+    uint8_t _style = 0;
61
+
62
+  protected:
63
+    // Returns the cannonical thickness of a widget (i.e. the height of a toggle element)
64
+    uint16_t widget_thickness() {
65
+      CLCD::FontMetrics fm(_font);
66
+      return fm.height * 20.0/16;
67
+    }
68
+
69
+    FORCEDINLINE void linear_widget_box(int16_t &x, int16_t &y, int16_t &w, int16_t &h, bool tracker = false) {
70
+      const uint16_t th = widget_thickness()/2;
71
+      if (w > h) {
72
+        x += tracker ? th * 2.5 : th;
73
+        y += h/2  - th/2;
74
+        w -= tracker ? th * 5.0 : th * 2;
75
+        h  = th;
76
+      } else {
77
+        x += w/2  - th/2;
78
+        y += tracker ? th * 2.5 : th;
79
+        w  = th;
80
+        h -= tracker ? th * 5.0 : th * 2;
81
+      }
82
+    }
83
+
84
+    FORCEDINLINE uint16_t circular_widget_box(int16_t &x, int16_t &y, int16_t &w, int16_t &h) {
85
+      const uint16_t r = min(w,h)/2;
86
+      x += w/2;
87
+      y += h/2;
88
+      w  = 1;
89
+      h  = 1;
90
+      return r;
91
+    }
92
+
93
+  public:
94
+    // Helper method for setting all colors at once
95
+    inline CommandProcessor& colors(const btn_colors &colors) {
96
+      cmd(FTDI::COLOR_RGB(colors.rgb))
97
+        .gradcolor(colors.grad)
98
+        .fgcolor(colors.fg)
99
+        .bgcolor(colors.bg);
100
+      return *this;
101
+    }
102
+
103
+    inline CommandProcessor& bitmap_size(uint8_t filter, uint8_t wrapx, uint8_t wrapy, uint16_t width, uint16_t height) {
104
+      cmd(FTDI::BITMAP_SIZE(filter, wrapx, wrapy, width, height));
105
+      #if FTDI_API_LEVEL >= 810
106
+        if (FTDI::ftdi_chip >= 810)
107
+          cmd(FTDI::BITMAP_SIZE_H(width >> 9, height >> 9));
108
+      #endif
109
+      return *this;
110
+    }
111
+
112
+    inline CommandProcessor& bitmap_layout(uint8_t format, uint16_t linestride, uint16_t height) {
113
+      cmd(FTDI::BITMAP_LAYOUT(format, linestride, height));
114
+      #if FTDI_API_LEVEL >= 810
115
+        if (FTDI::ftdi_chip >= 810)
116
+          cmd(FTDI::BITMAP_LAYOUT_H(linestride >> 10, height >> 9));
117
+      #endif
118
+      return *this;
119
+    }
120
+
121
+    inline CommandProcessor& set_button_style_callback(const btn_style_func_t *func) {
122
+      _btn_style_callback = func ? func : default_button_style_func;
123
+      return *this;
124
+    }
125
+
126
+    inline CommandProcessor& tag      (uint8_t  tag)              {_tag = tag; cmd(FTDI::TAG(tag)); return *this;}
127
+
128
+    inline CommandProcessor& font     (int16_t  font)             {_font = font; return *this;}
129
+
130
+    inline CommandProcessor& enabled  (bool enabled) {
131
+      if (enabled)
132
+        _style &= ~STYLE_DISABLED;
133
+      else
134
+        _style |= STYLE_DISABLED;
135
+      return *this;
136
+    }
137
+
138
+    inline CommandProcessor& style    (uint8_t style) {
139
+      _style = (_style & STYLE_DISABLED) | style;
140
+      return *this;
141
+    }
142
+
143
+    // Wrap all the CommandFifo routines to allow method chaining
144
+
145
+    inline CommandProcessor& cmd      (uint32_t cmd32)            {CLCD::CommandFifo::cmd(cmd32); return *this;}
146
+    inline CommandProcessor& cmd      (void* data, uint16_t len)  {CLCD::CommandFifo::cmd(data, len); return *this;}
147
+    inline CommandProcessor& execute()                            {CLCD::CommandFifo::execute(); return *this;}
148
+
149
+    inline CommandProcessor& fgcolor  (uint32_t rgb)              {CLCD::CommandFifo::fgcolor(rgb); return *this;}
150
+    inline CommandProcessor& bgcolor  (uint32_t rgb)              {CLCD::CommandFifo::bgcolor(rgb); return *this;}
151
+    inline CommandProcessor& gradcolor(uint32_t rgb)              {CLCD::CommandFifo::gradcolor(rgb); return *this;}
152
+
153
+    inline CommandProcessor& snapshot (uint32_t ptr)              {CLCD::CommandFifo::snapshot(ptr); return *this;}
154
+
155
+    inline CommandProcessor& loadimage(uint32_t ptr, uint32_t options)
156
+                                                                  {CLCD::CommandFifo::loadimage(ptr, options); return *this;}
157
+    inline CommandProcessor& sketch   (int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t ptr, uint16_t format)
158
+                                                                  {CLCD::CommandFifo::sketch(x, y, w, h, ptr, format); return *this;}
159
+    inline CommandProcessor& screensaver  ()                      {CLCD::CommandFifo::screensaver(); return *this;}
160
+    #if FTDI_API_LEVEL >= 810
161
+    inline CommandProcessor& setbase  (uint8_t base)              {CLCD::CommandFifo::setbase(base); return *this;}
162
+    #endif
163
+    inline CommandProcessor& loadidentity ()                      {CLCD::CommandFifo::loadidentity(); return *this;}
164
+    inline CommandProcessor& scale    (int32_t sx, int32_t sy)    {CLCD::CommandFifo::scale(sx,sy); return *this;}
165
+    inline CommandProcessor& rotate   (int32_t a)                 {CLCD::CommandFifo::rotate(a); return *this;}
166
+    inline CommandProcessor& translate(int32_t tx, int32_t ty)    {CLCD::CommandFifo::translate(tx,ty); return *this;}
167
+    inline CommandProcessor& setmatrix ()                         {CLCD::CommandFifo::setmatrix(); return *this;}
168
+    inline CommandProcessor& stop ()                              {CLCD::CommandFifo::stop(); return *this;}
169
+
170
+    inline CommandProcessor& memzero  (uint32_t ptr, uint32_t size)
171
+                                                                  {CLCD::CommandFifo::memzero(ptr, size); return *this;}
172
+    inline CommandProcessor& memset   (uint32_t ptr, uint32_t val, uint32_t size)
173
+                                                                  {CLCD::CommandFifo::memset(ptr, val, size); return *this;}
174
+    inline CommandProcessor& memcpy   (uint32_t src, uint32_t dst, uint32_t size)
175
+                                                                  {CLCD::CommandFifo::memcpy(src, dst, size); return *this;}
176
+    inline CommandProcessor& memcrc   (uint32_t ptr, uint32_t num, uint32_t result)
177
+                                                                  {CLCD::CommandFifo::memcrc(ptr, num, result); return *this;}
178
+    inline CommandProcessor& memwrite (uint32_t ptr, uint32_t value)
179
+                                                                  {CLCD::CommandFifo::memwrite(ptr, value); return *this;}
180
+    inline CommandProcessor& inflate  (uint32_t ptr)
181
+                                                                  {CLCD::CommandFifo::inflate(ptr); return *this;}
182
+    inline CommandProcessor& getptr   (uint32_t result)
183
+                                                                  {CLCD::CommandFifo::getptr(result); return *this;}
184
+    inline CommandProcessor& getprops (uint32_t ptr, uint32_t width, uint32_t height)
185
+                                                                  {CLCD::CommandFifo::getprops(ptr, width, height); return *this;}
186
+
187
+    #if FTDI_API_LEVEL >= 810
188
+    inline CommandProcessor& setbitmap (uint32_t ptr, uint16_t fmt, uint16_t w, uint16_t h)
189
+                                                                  {CLCD::CommandFifo::setbitmap(ptr,fmt,w,h); return *this;}
190
+    inline CommandProcessor& snapshot2 (uint32_t fmt, uint32_t ptr, int16_t x, int16_t y, uint16_t w, uint16_t h)
191
+                                                                  {CLCD::CommandFifo::snapshot2(fmt,ptr,x,y,w,h); return *this;}
192
+    inline CommandProcessor& mediafifo (uint32_t p, uint32_t s)   {CLCD::CommandFifo::mediafifo(p, s); return *this;}
193
+    inline CommandProcessor& playvideo(uint32_t options)          {CLCD::CommandFifo::playvideo(options); return *this;}
194
+    #endif
195
+
196
+    inline CommandProcessor& gradient(int16_t x0, int16_t y0, uint32_t rgb0, int16_t x1, int16_t y1, uint32_t rgb1)
197
+                                                                  {CLCD::CommandFifo::gradient(x0,y0,rgb0,x1,y1,rgb1); return *this;}
198
+
199
+    inline CommandProcessor& rectangle(int16_t x, int16_t y, int16_t w, int16_t h) {
200
+      using namespace FTDI;
201
+      CLCD::CommandFifo::cmd(BEGIN(RECTS));
202
+      CLCD::CommandFifo::cmd(VERTEX2F(x*16,y*16));
203
+      CLCD::CommandFifo::cmd(VERTEX2F((x+w)*16,(y+h)*16));
204
+      return *this;
205
+    }
206
+
207
+    template<typename T>
208
+    FORCEDINLINE CommandProcessor& toggle(int16_t x, int16_t y, int16_t w, int16_t h, T text, bool state, uint16_t options = FTDI::OPT_3D) {
209
+      CLCD::FontMetrics fm(_font);
210
+      const int16_t widget_h = fm.height * 20.0/16;
211
+      //const int16_t outer_bar_r = widget_h / 2;
212
+      //const int16_t knob_r      = outer_bar_r - 1.5;
213
+      // The y coordinate of the toggle is the baseline of the text,
214
+      // so we must introduce a fudge factor based on the line height to
215
+      // actually center the control.
216
+      const int16_t fudge_y = fm.height*5/16;
217
+      CLCD::CommandFifo::toggle(x + h/2, y + h/2 - widget_h/2 + fudge_y, w - h, _font, options, state);
218
+      CLCD::CommandFifo::str(text);
219
+      return *this;
220
+    }
221
+
222
+    // Contrained drawing routines. These constrain the widget inside a box for easier layout.
223
+    // The FORCEDINLINE ensures that the code is inlined so that all the math is done at compile time.
224
+
225
+    FORCEDINLINE CommandProcessor& track_linear(int16_t x, int16_t y, int16_t w, int16_t h, int16_t tag) {
226
+      linear_widget_box(x, y, w, h, true);
227
+      CLCD::CommandFifo::track(x, y, w, h, tag);
228
+      is_tracking = true;
229
+      return *this;
230
+    }
231
+
232
+    FORCEDINLINE CommandProcessor& track_circular(int16_t x, int16_t y, int16_t w, int16_t h, int16_t tag) {
233
+      circular_widget_box(x,y, w, h);
234
+      CLCD::CommandFifo::track(x, y, w, h, tag);
235
+      is_tracking = true;
236
+      return *this;
237
+    }
238
+
239
+    uint8_t track_tag (uint16_t &value) {
240
+      if (is_tracking) {
241
+        if (FTDI::EventLoop::is_touch_held()) {
242
+          return CLCD::get_tracker(value);
243
+        } else {
244
+          CLCD::CommandFifo::track(0, 0, 0, 0, 0);
245
+          CLCD::CommandFifo::execute();
246
+          is_tracking = false;
247
+        }
248
+      }
249
+      return 0;
250
+    }
251
+
252
+    FORCEDINLINE CommandProcessor& clock(int16_t x, int16_t y, int16_t w, int16_t h, int16_t hr, int16_t m, int16_t s, int16_t ms, uint16_t options = FTDI::OPT_3D) {
253
+      const uint16_t r = circular_widget_box(x, y, w, h);
254
+      CLCD::CommandFifo::clock(x, y, r, options, hr, m, s, ms);
255
+      return *this;
256
+    }
257
+
258
+    FORCEDINLINE CommandProcessor& gauge(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t major, uint16_t minor, uint16_t val, uint16_t range, uint16_t options = FTDI::OPT_3D) {
259
+      const uint16_t r = circular_widget_box(x, y, w, h);
260
+      CLCD::CommandFifo::gauge(x, y, r, options, major, minor, val, range);
261
+      return *this;
262
+    }
263
+
264
+    FORCEDINLINE CommandProcessor& dial(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t val, uint16_t options = FTDI::OPT_3D) {
265
+      const uint16_t r = circular_widget_box(x, y, w, h);
266
+      CLCD::CommandFifo::dial(x, y, r, options, val);
267
+      return *this;
268
+    }
269
+
270
+    FORCEDINLINE CommandProcessor& slider(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t val, uint16_t range, uint16_t options = FTDI::OPT_3D) {
271
+      linear_widget_box(x, y, w, h);
272
+      CLCD::CommandFifo::slider(x, y, w, h, options, val, range);
273
+      return *this;
274
+    }
275
+
276
+    FORCEDINLINE CommandProcessor& progress(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t val, uint16_t range, uint16_t options = FTDI::OPT_3D) {
277
+      linear_widget_box(x, y, w, h);
278
+      CLCD::CommandFifo::progress(x, y, w, h, options, val, range);
279
+      return *this;
280
+    }
281
+
282
+    FORCEDINLINE CommandProcessor& scrollbar(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t val, uint16_t size, uint16_t range, uint16_t options = 0) {
283
+      linear_widget_box(x, y, w, h);
284
+      CLCD::CommandFifo::scrollbar(x, y, w, h, options, val, size, range);
285
+      return *this;
286
+    }
287
+
288
+    CommandProcessor& number(int16_t x, int16_t y, int16_t w, int16_t h, int32_t n, uint16_t options = FTDI::OPT_CENTER) {
289
+      using namespace FTDI;
290
+      CLCD::CommandFifo::number(
291
+        x + ((options & OPT_CENTERX) ? w/2 : ((options & OPT_RIGHTX) ? w : 0)),
292
+        y + ((options & OPT_CENTERY) ? h/2 : h),
293
+        _font, options, n);
294
+      return *this;
295
+    }
296
+
297
+    template<typename T> FORCEDINLINE
298
+    CommandProcessor& text(int16_t x, int16_t y, int16_t w, int16_t h, T text, uint16_t options = FTDI::OPT_CENTER) {
299
+      using namespace FTDI;
300
+      CLCD::CommandFifo::text(
301
+        x + ((options & OPT_CENTERX) ? w/2 : ((options & OPT_RIGHTX) ? w : 0)),
302
+        y + ((options & OPT_CENTERY) ? h/2 : h),
303
+        _font, options);
304
+      CLCD::CommandFifo::str(text);
305
+      return *this;
306
+    }
307
+
308
+    FORCEDINLINE CommandProcessor& icon(int16_t x, int16_t y, int16_t w, int16_t h, const FTDI::bitmap_info_t& info, const float scale = 1) {
309
+      using namespace FTDI;
310
+      cmd(BEGIN(BITMAPS));
311
+      if (scale != 1) {
312
+        cmd(BITMAP_TRANSFORM_A(uint32_t(float(256)/scale)));
313
+        cmd(BITMAP_TRANSFORM_E(uint32_t(float(256)/scale)));
314
+      }
315
+      cmd(BITMAP_SIZE(info.filter, info.wrapx, info.wrapy, info.width*scale, info.height*scale));
316
+      cmd(VERTEX2F((x + w/2 - info.width*scale/2)*16, (y + h/2 - info.height*scale/2)*16));
317
+      if (scale != 1) {
318
+        cmd(BITMAP_TRANSFORM_A(256));
319
+        cmd(BITMAP_TRANSFORM_E(256));
320
+      }
321
+      return *this;
322
+    }
323
+
324
+    template<typename T>
325
+    CommandProcessor& button(int16_t x, int16_t y, int16_t w, int16_t h, T text, uint16_t options = FTDI::OPT_3D) {
326
+      using namespace FTDI;
327
+      bool styleModified = false;
328
+      if (_btn_style_callback) styleModified = _btn_style_callback(*this, _tag, _style, options, false);
329
+      CLCD::CommandFifo::button(x, y, w, h, _font, options);
330
+      CLCD::CommandFifo::str(text);
331
+      if (_btn_style_callback && styleModified) _btn_style_callback(*this, _tag, _style, options, true);
332
+      return *this;
333
+    }
334
+
335
+    template<typename T>
336
+    CommandProcessor& keys(int16_t x, int16_t y, int16_t w, int16_t h, T keys, uint16_t options = FTDI::OPT_3D) {
337
+      CLCD::CommandFifo::keys(x, y, w, h, _font, options);
338
+      CLCD::CommandFifo::str(keys);
339
+      return *this;
340
+    }
341
+
342
+    FORCEDINLINE CommandProcessor& spinner(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t style = 0, uint16_t scale = 0) {
343
+      circular_widget_box(x, y, w, h);
344
+      CLCD::CommandFifo::spinner(x, y, style, scale);
345
+      return *this;
346
+    }
347
+};

+ 176
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/dl_cache.cpp View File

@@ -0,0 +1,176 @@
1
+/****************
2
+ * dl_cache.cpp *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "ftdi_extended.h"
24
+
25
+#ifdef FTDI_EXTENDED
26
+
27
+/* The Display List Cache mechanism stores the display list corresponding
28
+ * to a menu into RAM_G so that on subsequent calls drawing the menu does
29
+ * not require as much SPI traffic.
30
+ *
31
+ * Layout of Cache memory:
32
+ *
33
+ * The cache memory begins with a table at
34
+ * DL_CACHE_START: each table entry contains
35
+ * an address and size for a cached DL slot.
36
+ *
37
+ * Immediately following the table is the
38
+ * DL_FREE_ADDR, which points to free cache
39
+ * space; following this is occupied DL space,
40
+ * and after that free space that is yet to
41
+ * be used.
42
+ *
43
+ *  location        data        sizeof
44
+ *
45
+ *  DL_CACHE_START  slot0_addr     4
46
+ *                  slot0_size     4
47
+ *                  slot1_addr     4
48
+ *                  slot1_size     4
49
+ *                      ...
50
+ *                  slotN_addr     4
51
+ *                  slotN_size     4
52
+ *  DL_FREE_ADDR    dl_free_ptr    4
53
+ *                  cached data
54
+ *                      ...
55
+ *  dl_free_ptr     empty space
56
+ *                      ...
57
+ */
58
+
59
+#define DL_CACHE_START   MAP::RAM_G_SIZE - 0xFFFF
60
+#define DL_FREE_ADDR     DL_CACHE_START + DL_CACHE_SLOTS * 8
61
+
62
+using namespace FTDI;
63
+
64
+// The init function ensures all cache locations are marked as empty
65
+
66
+void DLCache::init() {
67
+  CLCD::mem_write_32(DL_FREE_ADDR, DL_FREE_ADDR + 4);
68
+  for(uint8_t slot = 0; slot < DL_CACHE_SLOTS; slot++) {
69
+    save_slot(slot, 0, 0);
70
+  }
71
+}
72
+
73
+bool DLCache::has_data() {
74
+  return dl_size != 0;
75
+}
76
+
77
+bool DLCache::wait_until_idle() {
78
+  const unsigned long startTime = millis();
79
+  do {
80
+    if ((millis() - startTime) > 250) {
81
+      SERIAL_ECHO_START();
82
+      SERIAL_ECHOLNPGM("Timeout on DL_Cache::Wait_Until_Idle()");
83
+      CLCD::CommandFifo::reset();
84
+      return false;
85
+    }
86
+    #ifdef __MARLIN_FIRMWARE__
87
+      ExtUI::yield();
88
+    #endif
89
+  } while (CLCD::CommandFifo::is_processing());
90
+  return true;
91
+}
92
+
93
+/* This caches the current display list in RAMG so
94
+ * that it can be appended later. The memory is
95
+ * dynamically allocated following DL_FREE_ADDR.
96
+ *
97
+ * If num_bytes is provided, then that many bytes
98
+ * will be reserved so that the cache may be re-written
99
+ * later with potentially a bigger DL.
100
+ */
101
+
102
+bool DLCache::store(uint32_t num_bytes /* = 0*/) {
103
+  CLCD::CommandFifo cmd;
104
+
105
+  // Execute any commands already in the FIFO
106
+  cmd.execute();
107
+  if (!wait_until_idle())
108
+    return false;
109
+
110
+  // Figure out how long the display list is
111
+  uint32_t new_dl_size = CLCD::mem_read_32(REG::CMD_DL) & 0x1FFF;
112
+  uint32_t free_space  = 0;
113
+  uint32_t dl_alloc    = 0;
114
+
115
+  if (dl_addr == 0) {
116
+    // If we are allocating new space...
117
+    dl_addr     = CLCD::mem_read_32(DL_FREE_ADDR);
118
+    free_space  = MAP::RAM_G_SIZE - dl_addr;
119
+    dl_alloc    = num_bytes ? num_bytes : new_dl_size;
120
+    dl_size     = new_dl_size;
121
+  } else {
122
+    // Otherwise, we can only store as much space
123
+    // as was previously allocated.
124
+    free_space  = num_bytes ? num_bytes : dl_size;
125
+    dl_alloc    = 0;
126
+    dl_size     = new_dl_size;
127
+  }
128
+
129
+  if (dl_size > free_space) {
130
+    // Not enough memory to cache the display list.
131
+    #ifdef UI_FRAMEWORK_DEBUG
132
+      SERIAL_ECHO_START();
133
+      SERIAL_ECHOPAIR("Not enough space in GRAM to cache display list, free space: ", free_space);
134
+      SERIAL_ECHOLNPAIR(" Required: ", dl_size);
135
+    #endif
136
+    return false;
137
+  } else {
138
+    #ifdef UI_FRAMEWORK_DEBUG
139
+      SERIAL_ECHO_START();
140
+      SERIAL_ECHOPAIR("Saving DL to RAMG cache, bytes: ", dl_size);
141
+      SERIAL_ECHOLNPAIR(" Free space: ", free_space);
142
+    #endif
143
+    cmd.memcpy(dl_addr, MAP::RAM_DL, dl_size);
144
+    cmd.execute();
145
+    save_slot(dl_slot, dl_addr, dl_size);
146
+    if (dl_alloc > 0) {
147
+      // If we allocated space dynamically, then adjust dl_free_addr.
148
+      CLCD::mem_write_32(DL_FREE_ADDR, dl_addr + dl_alloc);
149
+    }
150
+    return true;
151
+  }
152
+}
153
+
154
+void DLCache::save_slot(uint8_t dl_slot, uint32_t dl_addr, uint32_t dl_size) {
155
+  CLCD::mem_write_32(DL_CACHE_START + dl_slot * 8 + 0, dl_addr);
156
+  CLCD::mem_write_32(DL_CACHE_START + dl_slot * 8 + 4, dl_size);
157
+}
158
+
159
+void DLCache::load_slot() {
160
+  dl_addr  = CLCD::mem_read_32(DL_CACHE_START + dl_slot * 8 + 0);
161
+  dl_size  = CLCD::mem_read_32(DL_CACHE_START + dl_slot * 8 + 4);
162
+}
163
+
164
+void DLCache::append() {
165
+  CLCD::CommandFifo cmd;
166
+  cmd.append(dl_addr, dl_size);
167
+  #ifdef UI_FRAMEWORK_DEBUG
168
+    cmd.execute();
169
+    wait_until_idle();
170
+    SERIAL_ECHO_START();
171
+    SERIAL_ECHOPAIR("Appending to DL from RAMG cache, bytes: ", dl_size);
172
+    SERIAL_ECHOLNPAIR(" REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL));
173
+  #endif
174
+}
175
+
176
+#endif // FTDI_EXTENDED

+ 69
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/dl_cache.h View File

@@ -0,0 +1,69 @@
1
+/**************
2
+ * dl_cache.h *
3
+ **************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/******************* DISPLAY LIST CACHE MANAGEMENT ************************/
25
+/* The Display List Cache mechanism stores the display list corresponding
26
+ * to a menu into RAM_G so that on subsequent calls drawing the menu does
27
+ * not require as much SPI traffic. Dynamic content, such as indicators,
28
+ * should not be cached.
29
+ *
30
+ * The DLCache can be used like so:
31
+ *
32
+ *   void some_function() {
33
+ *     DLCache dlcache(UNIQUE_ID);
34
+ *
35
+ *     if (dlcache.hasData()) {
36
+ *        dlcache.append();
37
+ *     } else {
38
+ *        // Add stuff to the DL
39
+ *        dlcache.store();
40
+ *     }
41
+ */
42
+class DLCache {
43
+  private:
44
+    typedef FTDI::ftdi_registers  REG;
45
+    typedef FTDI::ftdi_memory_map MAP;
46
+
47
+    uint8_t  dl_slot;
48
+    uint32_t dl_addr;
49
+    uint16_t dl_size;
50
+
51
+    void load_slot();
52
+    static void save_slot(uint8_t dl_slot, uint32_t dl_addr, uint32_t dl_size);
53
+
54
+    bool wait_until_idle();
55
+
56
+  public:
57
+    static void init();
58
+
59
+    DLCache(uint8_t slot) {
60
+      dl_slot = slot;
61
+      load_slot();
62
+    }
63
+
64
+    bool has_data();
65
+    bool store(uint32_t num_bytes = 0);
66
+    void append();
67
+};
68
+
69
+#define DL_CACHE_SLOTS   250

+ 230
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/event_loop.cpp View File

@@ -0,0 +1,230 @@
1
+/******************
2
+ * event_loop.cpp *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "ftdi_extended.h"
24
+
25
+#ifdef FTDI_EXTENDED
26
+using namespace FTDI;
27
+
28
+enum {
29
+  UNPRESSED       = 0x00
30
+};
31
+
32
+tiny_timer_t touch_timer;
33
+UIData::flags_t UIData::flags;
34
+uint8_t pressed_tag  = UNPRESSED;
35
+
36
+uint8_t UIData::get_persistent_data_mask() {
37
+  // A bit mask for flags that should be stored to the EEPROM.
38
+  // Others are considered temporarily values that need not be
39
+  // saved.
40
+  constexpr flags_t persistent_flags = {
41
+    bits: {
42
+      touch_start_sound:  true,
43
+      touch_end_sound:    true,
44
+      touch_repeat_sound: true,
45
+      show_animations:    true
46
+    }
47
+  };
48
+  return persistent_flags.value;
49
+}
50
+
51
+void UIData::reset_persistent_data() {
52
+  // Default values for persistent data
53
+  constexpr flags_t default_flags = {
54
+    bits: {
55
+      touch_start_sound:  true,
56
+      touch_end_sound:    true,
57
+      touch_repeat_sound: true,
58
+      show_animations:    true,
59
+      touch_debouncing:   false,
60
+      ignore_unpress:     false
61
+    }
62
+  };
63
+  flags.value = default_flags.value;
64
+}
65
+
66
+uint8_t UIData::get_persistent_data() {
67
+  return flags.value & get_persistent_data_mask();
68
+}
69
+
70
+void UIData::set_persistent_data(uint8_t value) {
71
+  flags.value = value & get_persistent_data_mask();
72
+}
73
+
74
+
75
+void UIData::enable_touch_sounds(bool enabled) {
76
+  UIData::flags.bits.touch_start_sound  = enabled;
77
+  UIData::flags.bits.touch_end_sound    = enabled;
78
+  UIData::flags.bits.touch_repeat_sound = enabled;
79
+}
80
+
81
+bool UIData::touch_sounds_enabled() {
82
+  return UIData::flags.bits.touch_start_sound || UIData::flags.bits.touch_end_sound || UIData::flags.bits.touch_repeat_sound;
83
+}
84
+
85
+void UIData::enable_animations(bool enabled) {
86
+    UIData::flags.bits.show_animations = enabled;
87
+}
88
+
89
+bool UIData::animations_enabled() {
90
+  return UIData::flags.bits.show_animations;
91
+}
92
+
93
+namespace FTDI {
94
+  uint8_t EventLoop::get_pressed_tag() {
95
+    return pressed_tag;
96
+  }
97
+
98
+  bool EventLoop::is_touch_held() {
99
+    return pressed_tag != 0;
100
+  }
101
+
102
+  /**
103
+   * process_events(): Process events from the touch panel.
104
+   *
105
+   * This function consists of a state machine that accomplishes the following:
106
+   *
107
+   *  - Reads the tag register from the touch panel
108
+   *  - Dispatches onTouchStart and onTouchEnd events to the active screen.
109
+   *  - Handles auto-repetition by sending onTouchHeld to the active screen periodically.
110
+   *  - Plays touch feedback "click" sounds when appropriate.
111
+   *  - Performs debouncing to supress spurious touch events.
112
+   *
113
+   */
114
+  void EventLoop::process_events() {
115
+    // If the LCD is processing commands, don't check
116
+    // for tags since they may be changing and could
117
+    // cause spurious events.
118
+    if (!touch_timer.elapsed(TOUCH_UPDATE_INTERVAL) || CLCD::CommandFifo::is_processing()) {
119
+      return;
120
+    }
121
+
122
+    const uint8_t tag = CLCD::get_tag();
123
+
124
+    switch (pressed_tag) {
125
+      case UNPRESSED:
126
+        if (tag != 0) {
127
+          #ifdef UI_FRAMEWORK_DEBUG
128
+            SERIAL_ECHO_START();
129
+            SERIAL_ECHOLNPAIR("Touch start: ", tag);
130
+          #endif
131
+
132
+          pressed_tag = tag;
133
+          current_screen.onRefresh();
134
+
135
+          // When the user taps on a button, activate the onTouchStart handler
136
+          const uint8_t lastScreen = current_screen.getScreen();
137
+
138
+          if (current_screen.onTouchStart(tag)) {
139
+            touch_timer.start();
140
+            if (UIData::flags.bits.touch_start_sound) sound.play(press_sound);
141
+          }
142
+
143
+          if (lastScreen != current_screen.getScreen()) {
144
+            // In the case in which a touch event triggered a new screen to be
145
+            // drawn, we don't issue a touchEnd since it would be sent to the
146
+            // wrong screen.
147
+            UIData::flags.bits.ignore_unpress = true;
148
+          } else {
149
+            UIData::flags.bits.ignore_unpress = false;
150
+          }
151
+        } else {
152
+          touch_timer.start();
153
+        }
154
+        break;
155
+      default: // PRESSED
156
+        if (!UIData::flags.bits.touch_debouncing) {
157
+          if (tag == pressed_tag) {
158
+            // The user is holding down a button.
159
+            if (touch_timer.elapsed(1000 / TOUCH_REPEATS_PER_SECOND) && current_screen.onTouchHeld(tag)) {
160
+              current_screen.onRefresh();
161
+              if (UIData::flags.bits.touch_repeat_sound) sound.play(repeat_sound);
162
+              touch_timer.start();
163
+            }
164
+          }
165
+          else if (tag == 0) {
166
+            touch_timer.start();
167
+            UIData::flags.bits.touch_debouncing = true;
168
+          }
169
+        }
170
+
171
+        else {
172
+          // Debouncing...
173
+
174
+          if (tag == pressed_tag) {
175
+            // If while debouncing, we detect a press, then cancel debouncing.
176
+            UIData::flags.bits.touch_debouncing = false;
177
+          }
178
+
179
+          else if (touch_timer.elapsed(DEBOUNCE_PERIOD)) {
180
+            UIData::flags.bits.touch_debouncing = false;
181
+
182
+            if (UIData::flags.bits.ignore_unpress) {
183
+              UIData::flags.bits.ignore_unpress = false;
184
+              pressed_tag = UNPRESSED;
185
+              break;
186
+            }
187
+
188
+            if (UIData::flags.bits.touch_end_sound) sound.play(unpress_sound);
189
+
190
+            #ifdef UI_FRAMEWORK_DEBUG
191
+              SERIAL_ECHO_START();
192
+              SERIAL_ECHOLNPAIR("Touch end: ", tag);
193
+            #endif
194
+
195
+            const uint8_t saved_pressed_tag = pressed_tag;
196
+            pressed_tag = UNPRESSED;
197
+            current_screen.onTouchEnd(saved_pressed_tag);
198
+            current_screen.onRefresh();
199
+          }
200
+        }
201
+        break;
202
+    } // switch (pressed_tag)
203
+
204
+  } // processEvents()
205
+
206
+  void EventLoop::setup() {
207
+    CLCD::init();
208
+    DLCache::init();
209
+    UIData::reset_persistent_data();
210
+    current_screen.start();
211
+  }
212
+
213
+  void EventLoop::loop() {
214
+    sound.onIdle();
215
+
216
+    /**
217
+      * Guard against re-entry of UI methods, which can
218
+      * crash. Re-entry can happen because some functions
219
+      * (e.g. planner.synchronize) call idle().
220
+      */
221
+    if (!UIData::flags.bits.prevent_reentry) {
222
+      UIData::flags.bits.prevent_reentry = true;
223
+      current_screen.onIdle();
224
+      process_events();
225
+      UIData::flags.bits.prevent_reentry = false;
226
+    }
227
+  }
228
+} // namespace FTDI
229
+
230
+#endif // FTDI_EXTENDED

+ 74
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/event_loop.h View File

@@ -0,0 +1,74 @@
1
+/****************
2
+ * event_loop.h *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#define STATUS_UPDATE_INTERVAL     1000
26
+#define TOUCH_UPDATE_INTERVAL        50
27
+#define TOUCH_REPEATS_PER_SECOND      4
28
+#define DEBOUNCE_PERIOD             150
29
+
30
+class UIData {
31
+  private:
32
+    typedef union {
33
+      struct {
34
+        uint8_t touch_start_sound  : 1;
35
+        uint8_t touch_end_sound    : 1;
36
+        uint8_t touch_repeat_sound : 1;
37
+        uint8_t show_animations    : 1;
38
+        uint8_t touch_debouncing   : 1;
39
+        uint8_t ignore_unpress     : 1;
40
+        uint8_t prevent_reentry    : 1;
41
+      } bits;
42
+      uint8_t value;
43
+    } flags_t;
44
+
45
+  public:
46
+    static flags_t flags;
47
+
48
+    static uint8_t get_persistent_data_mask();
49
+    static uint8_t get_persistent_data();
50
+    static void set_persistent_data(uint8_t value);
51
+    static void reset_persistent_data();
52
+
53
+    static void enable_touch_sounds(bool enabled);
54
+    static bool touch_sounds_enabled();
55
+    static void enable_animations(bool enabled);
56
+    static bool animations_enabled();
57
+};
58
+
59
+namespace FTDI {
60
+  class EventLoop {
61
+    private:
62
+      static constexpr FTDI::effect_t press_sound   = FTDI::CHACK;
63
+      static constexpr FTDI::effect_t repeat_sound  = FTDI::CHACK;
64
+      static constexpr FTDI::effect_t unpress_sound = FTDI::POP;
65
+      static void process_events();
66
+
67
+    public:
68
+      static void setup();
69
+      static void loop();
70
+
71
+      static uint8_t get_pressed_tag();
72
+      static bool is_touch_held();
73
+  };
74
+}

+ 45
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/ftdi_extended.h View File

@@ -0,0 +1,45 @@
1
+/*******************
2
+ * ftdi_extended.h *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2019 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 201( - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#include "../compat.h"
26
+#include "../basic/ftdi_basic.h"
27
+
28
+#if !defined(__MARLIN_FIRMWARE__)
29
+  #define FTDI_EXTENDED
30
+#endif
31
+
32
+#ifdef FTDI_EXTENDED
33
+  #include "rgb_t.h"
34
+  #include "bitmap_info.h"
35
+  #include "tiny_timer.h"
36
+  #include "grid_layout.h"
37
+  #include "dl_cache.h"
38
+  #include "screen_types.h"
39
+  #include "event_loop.h"
40
+  #include "command_processor.h"
41
+  #include "sound_player.h"
42
+  #include "sound_list.h"
43
+  #include "polygon.h"
44
+  #include "text_box.h"
45
+#endif

+ 98
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/grid_layout.h View File

@@ -0,0 +1,98 @@
1
+/*****************
2
+ * grid_layout.h *
3
+ *****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/* The grid layout macros allow buttons to be arranged on a grid so
25
+ * that their locations become independent of the display size. The
26
+ * layout model is similar to that of HTML TABLEs.
27
+ *
28
+ * These macros are meant to be evaluated into constants at compile
29
+ * time, so resolution independence can be as efficient as using
30
+ * hard-coded coordinates.
31
+ */
32
+
33
+// Margin defines the margin (in pixels) on each side of a button in
34
+// the layout
35
+
36
+#ifdef TOUCH_UI_800x480
37
+  #define MARGIN_L         5
38
+  #define MARGIN_R         5
39
+  #define MARGIN_T         5
40
+  #define MARGIN_B         5
41
+  #define MARGIN_DEFAULT   5
42
+#else
43
+  #define MARGIN_L         3
44
+  #define MARGIN_R         3
45
+  #define MARGIN_T         3
46
+  #define MARGIN_B         3
47
+  #define MARGIN_DEFAULT   3
48
+#endif
49
+
50
+// EDGE_R adds some black space on the right edge of the display
51
+// This shifts some of the screens left to visually center them.
52
+
53
+#define EDGE_R           0
54
+
55
+// GRID_X and GRID_Y computes the positions of the divisions on
56
+// the layout grid.
57
+#define GRID_X(x)        ((x)*(FTDI::display_width-EDGE_R)/GRID_COLS)
58
+#define GRID_Y(y)        ((y)*FTDI::display_height/GRID_ROWS)
59
+
60
+// BTN_X, BTN_Y, BTN_W and BTN_X returns the top-left and width
61
+// and height of a button, taking into account the button margins.
62
+
63
+#define BTN_X(x)         (GRID_X((x)-1) + MARGIN_L)
64
+#define BTN_Y(y)         (GRID_Y((y)-1) + MARGIN_T)
65
+#define BTN_W(w)         (GRID_X(w)   - MARGIN_L - MARGIN_R)
66
+#define BTN_H(h)         (GRID_Y(h)   - MARGIN_T - MARGIN_B)
67
+
68
+// Abbreviations for common phrases, to allow a button to be
69
+// defined in one line of source.
70
+#define BTN_POS(x,y)     BTN_X(x), BTN_Y(y)
71
+#define BTN_SIZE(w,h)    BTN_W(w), BTN_H(h)
72
+
73
+// Draw a reference grid for ease of spacing out widgets.
74
+#define DRAW_LAYOUT_GRID \
75
+  { \
76
+    cmd.cmd(LINE_WIDTH(4)); \
77
+    for(int i = 1; i <= GRID_COLS; i++) { \
78
+      cmd.cmd(BEGIN(LINES)); \
79
+      cmd.cmd(VERTEX2F(GRID_X(i) *16, 0             *16)); \
80
+      cmd.cmd(VERTEX2F(GRID_X(i) *16, FTDI::display_height *16)); \
81
+    } \
82
+    for(int i = 1; i < GRID_ROWS; i++) { \
83
+      cmd.cmd(BEGIN(LINES)); \
84
+      cmd.cmd(VERTEX2F(0                       *16, GRID_Y(i) *16)); \
85
+      cmd.cmd(VERTEX2F(FTDI::display_width     *16, GRID_Y(i) *16)); \
86
+    } \
87
+    cmd.cmd(LINE_WIDTH(16)); \
88
+  }
89
+
90
+namespace FTDI {
91
+  #ifdef TOUCH_UI_PORTRAIT
92
+    constexpr uint16_t display_width  = Vsize;
93
+    constexpr uint16_t display_height = Hsize;
94
+  #else
95
+    constexpr uint16_t display_width  = Hsize;
96
+    constexpr uint16_t display_height = Vsize;
97
+  #endif
98
+}

+ 96
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/polygon.h View File

@@ -0,0 +1,96 @@
1
+/*************
2
+ * polygon.h *
3
+ *************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/**
25
+ * The Polygon class helps drawing filled or stroked polygons on the FTDI EVE:
26
+ *
27
+ *   CommandProcessor cmd;
28
+ *   cmd.cmd(COLOR_RGB(0x00FF00));
29
+ *
30
+ *   Polygon p(cmd);
31
+ *   p.begin_fill();
32
+ *     p.begin_loop();
33
+ *      p(10,10);
34
+ *      p(20,10);
35
+ *      p(20,20);
36
+ *      p(10,20);
37
+ *     p.end_loop();
38
+ *     p.begin_loop();
39
+ *        ...  // Additional closed paths
40
+ *     p.end_loop();
41
+ *        ...
42
+ *   p.end_fill();
43
+ *
44
+ * Based on the example from "Applicaton Note AN_334, FT801 Polygon Application":
45
+ *
46
+ *   https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/AN_334-FT801_Polygon_Application.pdf
47
+ */
48
+
49
+namespace FTDI {
50
+  class Polygon {
51
+    private:
52
+      FTDI::begin_t path_initiator = FTDI::LINE_STRIP;
53
+
54
+    public:
55
+      CommandProcessor &cmd;
56
+
57
+      Polygon(CommandProcessor &c) : cmd(c) {}
58
+
59
+      void begin_fill() {
60
+        using namespace FTDI;
61
+        cmd.cmd(SAVE_CONTEXT());
62
+        cmd.cmd(TAG_MASK(0));
63
+        cmd.cmd(CLEAR(0,1,0));
64
+        cmd.cmd(COLOR_MASK(0,0,0,0));
65
+        cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT));
66
+        cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255));
67
+        // Drawing the edge strip along scan lines
68
+        // seems to yield the best performance
69
+        #ifdef TOUCH_UI_PORTRAIT
70
+          path_initiator = EDGE_STRIP_B;
71
+        #else
72
+          path_initiator = EDGE_STRIP_R;
73
+        #endif
74
+      }
75
+
76
+      // Specify a clipping rectangle to paint fewer pixels and reduce rendering time, otherwise all pixels will be painted.
77
+      void end_fill(const int16_t x1 = 0, const int16_t y1 = 0, const int16_t x2 = display_width * 16, const int16_t y2 = display_height * 16) {
78
+        using namespace FTDI;
79
+        cmd.cmd(RESTORE_CONTEXT());
80
+
81
+        cmd.cmd(SAVE_CONTEXT());
82
+        cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255));
83
+        cmd.cmd(BEGIN(RECTS));
84
+        cmd.cmd(VERTEX2F(x1, y1));
85
+        cmd.cmd(VERTEX2F(x2, y2));
86
+        cmd.cmd(RESTORE_CONTEXT());
87
+      }
88
+
89
+      void begin_stroke() {path_initiator = FTDI::LINE_STRIP;}
90
+      void begin_loop()   {cmd.cmd(FTDI::BEGIN(path_initiator));}
91
+      void end_stroke()   {}
92
+      void end_loop()     {}
93
+
94
+      void operator()(const uint16_t x, const uint16_t y) {cmd.cmd(FTDI::VERTEX2F(x, y));}
95
+  };
96
+}

+ 44
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/rgb_t.h View File

@@ -0,0 +1,44 @@
1
+/***********
2
+ * rgb_t.h *
3
+ ***********/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+struct rgb_t {
25
+    union {
26
+      struct {
27
+        uint8_t  b,g,r,a;
28
+      };
29
+      uint32_t packed;
30
+    };
31
+
32
+    rgb_t()                                : packed(0)              {}
33
+    rgb_t(uint32_t rgb)                    : packed(rgb)            {}
34
+    rgb_t(uint8_t r, uint8_t g, uint8_t b) : b(b), g(g), r(r), a(0) {}
35
+    operator uint32_t() const              {return packed;};
36
+
37
+    static void lerp(float t, const rgb_t a, const rgb_t b, rgb_t &c) {
38
+      c.r = a.r + t * (b.r - a.r);
39
+      c.g = a.g + t * (b.g - a.g);
40
+      c.b = a.b + t * (b.b - a.b);
41
+    }
42
+
43
+    uint8_t luminance() const {return 0.299*r + 0.587*g + 0.114*b;}
44
+};

+ 106
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/screen_types.cpp View File

@@ -0,0 +1,106 @@
1
+/******************
2
+ * screen_types.h *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#ifdef FTDI_EXTENDED
25
+
26
+/********************** VIRTUAL DISPATCH DATA TYPE  ******************************/
27
+
28
+uint8_t ScreenRef::lookupScreen(onRedraw_func_t onRedraw_ptr) {
29
+  for(uint8_t type = 0; type < functionTableSize; type++) {
30
+    if (GET_METHOD(type, onRedraw) == onRedraw_ptr) {
31
+      return type;
32
+    }
33
+  }
34
+  #ifdef UI_FRAMEWORK_DEBUG
35
+    SERIAL_ECHO_START();
36
+    SERIAL_ECHOPAIR("Screen not found: ", (uintptr_t) onRedraw_ptr);
37
+  #endif
38
+  return 0xFF;
39
+}
40
+
41
+void ScreenRef::setScreen(onRedraw_func_t onRedraw_ptr) {
42
+  uint8_t type = lookupScreen(onRedraw_ptr);
43
+  if (type != 0xFF) {
44
+    setType(type);
45
+    #ifdef UI_FRAMEWORK_DEBUG
46
+      SERIAL_ECHO_START();
47
+      SERIAL_ECHOLNPAIR("New screen: ", type);
48
+    #endif
49
+  }
50
+}
51
+
52
+void ScreenRef::initializeAll() {
53
+  for(uint8_t type = 0; type < functionTableSize; type++) {
54
+    GET_METHOD(type, onStartup)();
55
+  }
56
+}
57
+
58
+/********************** SCREEN STACK  ******************************/
59
+
60
+void ScreenStack::start() {
61
+  initializeAll();
62
+  onEntry();
63
+}
64
+
65
+void ScreenStack::push(onRedraw_func_t onRedraw_ptr) {
66
+  stack[3] = stack[2];
67
+  stack[2] = stack[1];
68
+  stack[1] = stack[0];
69
+  stack[0] = lookupScreen(onRedraw_ptr);
70
+}
71
+
72
+void ScreenStack::push() {
73
+  stack[3] = stack[2];
74
+  stack[2] = stack[1];
75
+  stack[1] = stack[0];
76
+  stack[0] = getType();
77
+}
78
+
79
+void ScreenStack::pop() {
80
+  setType(stack[0]);
81
+  forget();
82
+}
83
+
84
+void ScreenStack::forget() {
85
+  stack[0] = stack[1];
86
+  stack[1] = stack[2];
87
+  stack[2] = stack[3];
88
+  stack[3] = 0;
89
+}
90
+
91
+void ScreenStack::goTo(onRedraw_func_t s) {
92
+  push();
93
+  onExit();
94
+  setScreen(s);
95
+  onEntry();
96
+}
97
+
98
+void ScreenStack::goBack() {
99
+  onExit();
100
+  pop();
101
+  onEntry();
102
+}
103
+
104
+ScreenStack current_screen;
105
+
106
+#endif // FTDI_EXTENDED

+ 215
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/screen_types.h View File

@@ -0,0 +1,215 @@
1
+/********************
2
+ * screen_types.cpp *
3
+ ********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+typedef enum {
25
+  BACKGROUND  = 1,
26
+  FOREGROUND  = 2,
27
+  BOTH        = 3
28
+} draw_mode_t;
29
+
30
+ /********************** VIRTUAL DISPATCH DATA TYPE  ******************************/
31
+
32
+// True virtual classes are extremely expensive on the Arduino
33
+// as the compiler stores the virtual function tables in RAM.
34
+// We invent a data type called ScreenRef that gives us
35
+// polymorphism by mapping an ID to virtual methods on various
36
+// classes. This works by keeping a table in PROGMEM of pointers
37
+// to static methods.
38
+
39
+#define DECL_SCREEN(className) { \
40
+  className::onStartup, \
41
+  className::onEntry, \
42
+  className::onExit, \
43
+  className::onIdle, \
44
+  className::onRefresh, \
45
+  className::onRedraw, \
46
+  className::onTouchStart, \
47
+  className::onTouchHeld, \
48
+  className::onTouchEnd \
49
+}
50
+
51
+#define GET_METHOD(type, method) reinterpret_cast<method##_func_t*>(pgm_read_ptr_far(&functionTable[type].method##_ptr))
52
+#define SCREEN_TABLE             PROGMEM const ScreenRef::table_t ScreenRef::functionTable[] =
53
+#define SCREEN_TABLE_POST        const uint8_t ScreenRef::functionTableSize = sizeof(ScreenRef::functionTable)/sizeof(ScreenRef::functionTable[0]);
54
+
55
+class ScreenRef {
56
+  protected:
57
+    typedef void onStartup_func_t(void);
58
+    typedef void onEntry_func_t(void);
59
+    typedef void onExit_func_t(void);
60
+    typedef void onIdle_func_t(void);
61
+    typedef void onRefresh_func_t(void);
62
+    typedef void onRedraw_func_t(draw_mode_t);
63
+    typedef bool onTouchStart_func_t(uint8_t);
64
+    typedef bool onTouchHeld_func_t(uint8_t);
65
+    typedef bool onTouchEnd_func_t(uint8_t);
66
+
67
+  private:
68
+    typedef struct {
69
+      onStartup_func_t     *onStartup_ptr;
70
+      onEntry_func_t       *onEntry_ptr;
71
+      onExit_func_t        *onExit_ptr;
72
+      onIdle_func_t        *onIdle_ptr;
73
+      onRefresh_func_t     *onRefresh_ptr;
74
+      onRedraw_func_t      *onRedraw_ptr;
75
+      onTouchStart_func_t  *onTouchStart_ptr;
76
+      onTouchHeld_func_t   *onTouchHeld_ptr;
77
+      onTouchEnd_func_t    *onTouchEnd_ptr;
78
+    } table_t;
79
+
80
+    uint8_t type = 0;
81
+    static PROGMEM const table_t functionTable[];
82
+    static const uint8_t functionTableSize;
83
+
84
+  public:
85
+    uint8_t getType() {return type;}
86
+
87
+    void setType(uint8_t t) {
88
+      type = t;
89
+    }
90
+
91
+    uint8_t lookupScreen(onRedraw_func_t onRedraw_ptr);
92
+
93
+    void setScreen(onRedraw_func_t onRedraw_ptr);
94
+
95
+    void onStartup()               {GET_METHOD(type, onStartup)();}
96
+    void onEntry()                 {GET_METHOD(type, onEntry)();}
97
+    void onExit()                  {GET_METHOD(type, onExit)();}
98
+    void onIdle()                  {GET_METHOD(type, onIdle)();}
99
+    void onRefresh()               {GET_METHOD(type, onRefresh)();}
100
+    void onRedraw(draw_mode_t dm)  {GET_METHOD(type, onRedraw)(dm);}
101
+    bool onTouchStart(uint8_t tag) {return GET_METHOD(type, onTouchStart)(tag);}
102
+    bool onTouchHeld(uint8_t tag)  {return GET_METHOD(type, onTouchHeld)(tag);}
103
+    bool onTouchEnd(uint8_t tag)   {return GET_METHOD(type, onTouchEnd)(tag);}
104
+
105
+    void initializeAll();
106
+};
107
+
108
+/********************** SCREEN STACK  ******************************/
109
+
110
+// To conserve dynamic memory, the screen stack is hard-coded to
111
+// have four values, allowing a menu of up to four levels.
112
+
113
+class ScreenStack : public ScreenRef {
114
+  private:
115
+    uint8_t stack[4];
116
+
117
+  public:
118
+    void start();
119
+    void push(onRedraw_func_t);
120
+    void push();
121
+    void pop();
122
+    void forget();
123
+    void goTo(onRedraw_func_t);
124
+    void goBack();
125
+
126
+    uint8_t peek()      {return stack[0];}
127
+    uint8_t getScreen() {return getType();}
128
+};
129
+
130
+extern ScreenStack current_screen;
131
+
132
+/********************** BASE SCREEN CLASS ******************************/
133
+
134
+/* UIScreen is the base class for all user interface screens.
135
+ */
136
+class UIScreen {
137
+  public:
138
+    static void onStartup()            {}
139
+    static void onEntry()              {current_screen.onRefresh();}
140
+    static void onExit()               {}
141
+    static void onIdle()               {}
142
+    static bool onTouchStart(uint8_t)  {return true;}
143
+    static bool onTouchHeld(uint8_t)   {return false;}
144
+    static bool onTouchEnd(uint8_t)    {return true;}
145
+};
146
+
147
+#define PUSH_SCREEN(screen)   current_screen.push(screen::onRedraw);
148
+#define GOTO_SCREEN(screen)   current_screen.goTo(screen::onRedraw);
149
+#define GOTO_PREVIOUS()       current_screen.goBack();
150
+#define AT_SCREEN(screen)     (current_screen.getType() == current_screen.lookupScreen(screen::onRedraw))
151
+#define IS_PARENT_SCREEN(screen) (current_screen.peek() == current_screen.lookupScreen(screen::onRedraw))
152
+
153
+/************************** CACHED VS UNCHACHED SCREENS ***************************/
154
+
155
+class UncachedScreen {
156
+  public:
157
+    static void onRefresh() {
158
+      using namespace FTDI;
159
+      CLCD::CommandFifo cmd;
160
+      cmd.cmd(CMD_DLSTART);
161
+
162
+      current_screen.onRedraw(BOTH);
163
+
164
+      cmd.cmd(DL::DL_DISPLAY);
165
+      cmd.cmd(CMD_SWAP);
166
+      cmd.execute();
167
+    }
168
+};
169
+
170
+template<uint8_t DL_SLOT,uint32_t DL_SIZE = 0>
171
+class CachedScreen {
172
+  protected:
173
+    static bool storeBackground(){
174
+      DLCache dlcache(DL_SLOT);
175
+      if (!dlcache.store(DL_SIZE)) {
176
+        SERIAL_ECHO_START();
177
+        SERIAL_ECHOLNPGM("CachedScreen::storeBackground() failed: not enough DL cache space");
178
+        return false;
179
+      }
180
+      return true;
181
+    }
182
+
183
+    static void repaintBackground(){
184
+      using namespace FTDI;
185
+      DLCache dlcache(DL_SLOT);
186
+      CLCD::CommandFifo cmd;
187
+
188
+      cmd.cmd(CMD_DLSTART);
189
+      current_screen.onRedraw(BACKGROUND);
190
+
191
+      dlcache.store(DL_SIZE);
192
+    }
193
+
194
+  public:
195
+    static void onRefresh(){
196
+      using namespace FTDI;
197
+      DLCache dlcache(DL_SLOT);
198
+      CLCD::CommandFifo cmd;
199
+
200
+      cmd.cmd(CMD_DLSTART);
201
+
202
+      if (dlcache.has_data()) {
203
+        dlcache.append();
204
+      } else {
205
+        current_screen.onRedraw(BACKGROUND);
206
+        dlcache.store(DL_SIZE);
207
+      }
208
+
209
+      current_screen.onRedraw(FOREGROUND);
210
+
211
+      cmd.cmd(DL::DL_DISPLAY);
212
+      cmd.cmd(CMD_SWAP);
213
+      cmd.execute();
214
+    }
215
+};

+ 38
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_list.h View File

@@ -0,0 +1,38 @@
1
+/****************
2
+ * sound_list.h *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+class SoundList {
25
+  private:
26
+    static PROGMEM const struct list_t {
27
+      const char *const PROGMEM name;
28
+      const FTDI::SoundPlayer::sound_t* data;
29
+    } list[];
30
+  public:
31
+    static const uint8_t n;
32
+    static inline const char* name(uint8_t val) {
33
+      return (const char* ) pgm_read_ptr_near(&list[val].name);
34
+    }
35
+    static inline FTDI::SoundPlayer::sound_t* data(uint8_t val) {
36
+      return (FTDI::SoundPlayer::sound_t*) pgm_read_ptr_near(&list[val].data);
37
+    }
38
+};

+ 111
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_player.cpp View File

@@ -0,0 +1,111 @@
1
+/********************
2
+ * sound_player.cpp *
3
+ ********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#ifdef FTDI_EXTENDED
25
+
26
+namespace FTDI {
27
+  SoundPlayer sound; // Global sound player object
28
+
29
+  void SoundPlayer::set_volume(uint8_t vol) {
30
+    CLCD::mem_write_8(REG::VOL_SOUND, vol);
31
+  }
32
+
33
+  uint8_t SoundPlayer::get_volume() {
34
+    return CLCD::mem_read_8(REG::VOL_SOUND);
35
+  }
36
+
37
+  void SoundPlayer::play(effect_t effect, note_t note) {
38
+
39
+    #ifdef UI_FRAMEWORK_DEBUG
40
+      SERIAL_ECHO_START();
41
+      SERIAL_ECHOPAIR("Playing note ", note);
42
+      SERIAL_ECHOLNPAIR(", instrument ", effect);
43
+    #endif
44
+
45
+    // Play the note
46
+    CLCD::mem_write_16(REG::SOUND, (note == REST) ? 0 : (((note ? note : NOTE_C4) << 8) | effect));
47
+    CLCD::mem_write_8(REG::PLAY, 1);
48
+  }
49
+
50
+  note_t SoundPlayer::frequency_to_midi_note(const uint16_t frequency_hz) {
51
+    const float f0 = 440;
52
+    return note_t(NOTE_A4 + (log(frequency_hz)-log(f0))*12/log(2) + 0.5);
53
+  }
54
+
55
+  // Plays a tone of a given frequency and duration. Since the FTDI FT810 only
56
+  // supports MIDI notes, we round down to the nearest note.
57
+
58
+  void SoundPlayer::play_tone(const uint16_t frequency_hz, const uint16_t duration_ms) {
59
+    play(ORGAN, frequency_to_midi_note(frequency_hz));
60
+
61
+    // Schedule silence to squelch the note after the duration expires.
62
+    sequence = silence;
63
+    wait = duration_ms;
64
+    timer.start();
65
+  }
66
+
67
+  void SoundPlayer::play(const sound_t* seq, play_mode_t mode) {
68
+    sequence = seq;
69
+    wait     = 250; // Adding this delay causes the note to not be clipped, not sure why.
70
+    timer.start();
71
+
72
+    if (mode == PLAY_ASYNCHRONOUS) return;
73
+
74
+    // If playing synchronously, then play all the notes here
75
+
76
+    while (has_more_notes()) {
77
+      onIdle();
78
+      #ifdef EXTENSIBLE_UI
79
+        ExtUI::yield();
80
+      #endif
81
+    }
82
+  }
83
+
84
+  bool SoundPlayer::is_sound_playing() {
85
+    return CLCD::mem_read_8( REG::PLAY ) & 0x1;
86
+  }
87
+
88
+  void SoundPlayer::onIdle() {
89
+    if (!sequence) return;
90
+
91
+    const bool ready_for_next_note = (wait == 0) ? !is_sound_playing() : timer.elapsed(wait);
92
+
93
+    if (ready_for_next_note) {
94
+      const effect_t fx = effect_t(pgm_read_byte(&sequence->effect));
95
+      const note_t   nt =   note_t(pgm_read_byte(&sequence->note));
96
+      const uint32_t ms = uint32_t(pgm_read_byte(&sequence->sixteenths)) * 1000 / 16;
97
+
98
+      if (ms == 0 && fx == SILENCE && nt == END_SONG) {
99
+        sequence = 0;
100
+        play(SILENCE, REST);
101
+      } else {
102
+        wait = ms;
103
+        timer.start();
104
+        play(fx, nt);
105
+        sequence++;
106
+      }
107
+    }
108
+  }
109
+} // namespace FTDI
110
+
111
+#endif // FTDI_EXTENDED

+ 70
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/sound_player.h View File

@@ -0,0 +1,70 @@
1
+/******************
2
+ * sound_player.h *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+namespace FTDI {
26
+  typedef enum {
27
+    PLAY_ASYNCHRONOUS,
28
+    PLAY_SYNCHRONOUS
29
+  } play_mode_t;
30
+
31
+  class SoundPlayer {
32
+    typedef FTDI::ftdi_registers  REG;
33
+    typedef FTDI::ftdi_memory_map MAP;
34
+
35
+    public:
36
+      struct sound_t {
37
+        effect_t  effect;      // The sound effect number
38
+        note_t    note;        // The MIDI note value
39
+        uint16_t  sixteenths;  // Duration of note, in sixteeths of a second, or zero to play to completion
40
+      };
41
+
42
+      const uint8_t WAIT = 0;
43
+
44
+    private:
45
+      const sound_t   *sequence;
46
+      tiny_timer_t     timer;
47
+      tiny_time_t      wait;
48
+
49
+      note_t frequency_to_midi_note(const uint16_t frequency);
50
+
51
+    public:
52
+      static void set_volume(uint8_t volume);
53
+      static uint8_t get_volume();
54
+
55
+      static void play(effect_t effect, note_t note = NOTE_C4);
56
+      static bool is_sound_playing();
57
+
58
+      void play(const sound_t* seq, play_mode_t mode = PLAY_SYNCHRONOUS);
59
+      void play_tone(const uint16_t frequency_hz, const uint16_t duration_ms);
60
+      bool has_more_notes() {return sequence != 0;};
61
+
62
+      void onIdle();
63
+  };
64
+
65
+  extern SoundPlayer sound;
66
+
67
+  const PROGMEM SoundPlayer::sound_t silence[] = {
68
+    {SILENCE,      END_SONG, 0}
69
+  };
70
+}

+ 129
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/text_box.cpp View File

@@ -0,0 +1,129 @@
1
+/****************
2
+ * text_box.cpp *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#ifdef FTDI_EXTENDED
25
+
26
+namespace FTDI {
27
+  /**
28
+   * Given a str, end will be set to the position at which a line needs to
29
+   * be broken so that the display width is less than w. The line will also
30
+   * be broken after a '\n'. Returns the display width of the line.
31
+   */
32
+  static uint16_t find_line_break(const CLCD::FontMetrics &fm, uint16_t w, const char *str, const char *&end) {
33
+    const char *p = str;
34
+    end = str + strlen(str);
35
+    uint16_t width = fm.get_text_width(str);
36
+    for(;;) {
37
+      // Find next tentative line break.
38
+      char delim = *(p);
39
+      while (delim && delim != ' ' && delim != '\n') {
40
+        delim = *(++p);
41
+      }
42
+      // Check to see whether to break the line.
43
+      const uint16_t margin = fm.get_text_width("  ");
44
+      const uint16_t lw = p > str ? fm.get_text_width(str, p - str) + margin : 0;
45
+      if (lw < w) {
46
+        width = lw;
47
+        switch (delim) {
48
+          case '\0':
49
+            end = p;
50
+            break;
51
+          case '\n':
52
+            end = ++p;
53
+            break;
54
+          case ' ':
55
+            end = ++p;
56
+            continue;
57
+        }
58
+      }
59
+      return width;
60
+    }
61
+  }
62
+
63
+  /**
64
+   * This function returns a measurements of the word-wrapped text box.
65
+   */
66
+  static void measure_text_box(const CLCD::FontMetrics &fm, const char *str, uint16_t &width, uint16_t &height) {
67
+    const char *line_start = (const char*)str;
68
+    const char *line_end;
69
+    const uint16_t wrap_width = width;
70
+    width = height = 0;
71
+    for(;;) {
72
+      uint16_t line_width = find_line_break(fm, wrap_width, line_start, line_end);
73
+      if (line_end == line_start) break;
74
+      width  = max(width, line_width);
75
+      height += fm.height;
76
+      line_start = line_end;
77
+    }
78
+  }
79
+
80
+  /**
81
+   * This function draws text inside a bounding box, doing word wrapping and using the largest font that will fit.
82
+   */
83
+  void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, const char *str, uint16_t options, uint8_t font) {
84
+    CLCD::FontMetrics fm(font);
85
+
86
+    uint16_t box_width, box_height;
87
+
88
+    for(;;) {
89
+      box_width = w;
90
+      measure_text_box(fm, str, box_width, box_height);
91
+      if (box_width <= (uint16_t)w && box_height <= (uint16_t)h) break;
92
+      fm.load(--font);
93
+      if (font == 26) break;
94
+    }
95
+
96
+    const uint16_t dx = (options & OPT_RIGHTX) ? w : (options & OPT_CENTERX) ? w/2 : 0;
97
+    const uint16_t dy = (options & OPT_CENTERY) ? (h - box_height)/2 : 0;
98
+
99
+    const char *line_start = str;
100
+    const char *line_end;
101
+    for(;;) {
102
+      find_line_break(fm, w, line_start, line_end);
103
+      if (line_end == line_start) break;
104
+
105
+      const size_t line_len = line_end - line_start;
106
+      if (line_len) {
107
+        char line[line_len + 1];
108
+        strncpy(line, line_start, line_len);
109
+        line[line_len] = 0;
110
+        if (line[line_len - 1] == '\n' || line[line_len - 1] == ' ')
111
+          line[line_len - 1] = 0;
112
+
113
+        cmd.CLCD::CommandFifo::text(x + dx, y + dy, font, options & ~OPT_CENTERY);
114
+        cmd.CLCD::CommandFifo::str(line);
115
+      }
116
+      y += fm.height;
117
+
118
+      line_start = line_end;
119
+    }
120
+  }
121
+
122
+  void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, progmem_str pstr, uint16_t options, uint8_t font) {
123
+    char str[strlen_P((const char*)pstr) + 1];
124
+    strcpy_P(str, (const char*)pstr);
125
+    draw_text_box(cmd, x, y, w, h, (const char*) str, options, font);
126
+  }
127
+} // namespace FTDI
128
+
129
+#endif // FTDI_EXTENDED

+ 30
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/text_box.h View File

@@ -0,0 +1,30 @@
1
+/**************
2
+ * text_box.h *
3
+ **************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/**
25
+ * This function draws text inside a bounding box, doing word wrapping and using the largest font that will fit.
26
+ */
27
+namespace FTDI {
28
+  void draw_text_box(class CommandProcessor& cmd, int x, int y, int w, int h, progmem_str str, uint16_t options = 0, uint8_t font = 31);
29
+  void draw_text_box(class CommandProcessor& cmd, int x, int y, int w, int h, const char *str, uint16_t options = 0, uint8_t font = 31);
30
+}

+ 51
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/tiny_timer.cpp View File

@@ -0,0 +1,51 @@
1
+/******************
2
+ * tiny_timer.cpp *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#include "ftdi_extended.h"
23
+
24
+#ifdef FTDI_EXTENDED
25
+
26
+bool tiny_timer_t::elapsed(tiny_time_t duration) {
27
+  uint8_t now = tiny_time_t::tiny_time(
28
+    #ifdef __MARLIN_FIRMWARE__
29
+      ExtUI::safe_millis()
30
+    #else
31
+      millis()
32
+    #endif
33
+  );
34
+  uint8_t elapsed = now - _start;
35
+  if (elapsed >= duration._duration) {
36
+    return true;
37
+  } else {
38
+    return false;
39
+  }
40
+}
41
+
42
+void tiny_timer_t::start() {
43
+  _start = tiny_time_t::tiny_time(
44
+    #ifdef __MARLIN_FIRMWARE__
45
+      ExtUI::safe_millis()
46
+    #else
47
+      millis()
48
+    #endif
49
+  );
50
+}
51
+#endif // FTDI_EXTENDED

+ 56
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/tiny_timer.h View File

@@ -0,0 +1,56 @@
1
+/****************
2
+ * tiny_timer.h *
3
+ ****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/* Helpful Reference:
25
+ *
26
+ *  https://arduino.stackexchange.com/questions/12587/how-can-i-handle-the-millis-rollover
27
+ */
28
+
29
+/* tiny_interval_t downsamples a 32-bit millis() value
30
+   into a 8-bit value which can record periods of
31
+   a few seconds with a rougly 1/16th of second
32
+   resolution. This allows us to measure small
33
+   intervals without needing to use four-byte counters.
34
+ */
35
+class tiny_time_t {
36
+  private:
37
+    friend class tiny_timer_t;
38
+    uint8_t _duration;
39
+
40
+    static uint8_t tiny_time(uint32_t ms) {return ceil(float(ms) / 64);};
41
+
42
+  public:
43
+    tiny_time_t()            : _duration(0) {}
44
+    tiny_time_t(uint32_t ms) : _duration(tiny_time(ms)) {}
45
+    tiny_time_t & operator=   (uint32_t ms) {_duration = tiny_time(ms); return *this;}
46
+    bool          operator == (uint32_t ms) {return _duration == tiny_time(ms);}
47
+};
48
+
49
+class tiny_timer_t {
50
+  private:
51
+    uint8_t _start;
52
+
53
+  public:
54
+    void start();
55
+    bool elapsed(tiny_time_t interval);
56
+};

+ 100
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/circular_progress.h View File

@@ -0,0 +1,100 @@
1
+/***********************
2
+ * circular_progress.h *
3
+ ***********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/* This function draws a circular progress "ring" */
25
+
26
+void draw_circular_progress(CommandProcessor& cmd, int x, int y, int w, int h, uint8_t percent, uint32_t bgcolor, uint32_t fgcolor, float rim = 0.3) {
27
+  using namespace FTDI;
28
+
29
+  const float a  = float(percent)/100.0*2.0*PI;
30
+  const float a1 = min(PI/2, a);
31
+  const float a2 = min(PI/2, a-a1);
32
+  const float a3 = min(PI/2, a-a1-a2);
33
+  const float a4 = min(PI/2, a-a1-a2-a3);
34
+
35
+  const int ro  = min(w,h) * 8;
36
+  const int rr = ro * rim;
37
+  const int cx = x * 16 + w * 8;
38
+  const int cy = y * 16 + h * 8;
39
+
40
+  // Load a rim shape into stencil buffer
41
+  cmd.cmd(SAVE_CONTEXT());
42
+  cmd.cmd(TAG_MASK(0));
43
+  cmd.cmd(CLEAR(0,1,0));
44
+  cmd.cmd(COLOR_MASK(0,0,0,0));
45
+  cmd.cmd(STENCIL_OP(STENCIL_OP_KEEP, STENCIL_OP_INVERT));
46
+  cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_ALWAYS, 255, 255));
47
+  cmd.cmd(BEGIN(POINTS));
48
+  cmd.cmd(POINT_SIZE(ro));
49
+  cmd.cmd(VERTEX2F(cx, cy));
50
+  cmd.cmd(POINT_SIZE(ro - rr));
51
+  cmd.cmd(VERTEX2F(cx, cy));
52
+  cmd.cmd(RESTORE_CONTEXT());
53
+
54
+  // Mask further drawing by stencil buffer
55
+  cmd.cmd(SAVE_CONTEXT());
56
+  cmd.cmd(STENCIL_FUNC(STENCIL_FUNC_NOTEQUAL, 0, 255));
57
+
58
+  // Fill the background
59
+  cmd.cmd(COLOR_RGB(bgcolor));
60
+  cmd.cmd(BEGIN(POINTS));
61
+  cmd.cmd(POINT_SIZE(ro));
62
+  cmd.cmd(VERTEX2F(cx, cy));
63
+  cmd.cmd(COLOR_RGB(fgcolor));
64
+
65
+  // Paint upper-right quadrant
66
+  cmd.cmd(BEGIN(EDGE_STRIP_A));
67
+  cmd.cmd(VERTEX2F(cx, cy));
68
+  cmd.cmd(VERTEX2F(cx + ro*sin(a1) + 16,cy - ro*cos(a1) + 8));
69
+
70
+  // Paint lower-right quadrant
71
+  if (a > PI/2) {
72
+    cmd.cmd(BEGIN(EDGE_STRIP_R));
73
+    cmd.cmd(VERTEX2F(cx, cy));
74
+    cmd.cmd(VERTEX2F(cx + ro*cos(a2),cy + ro*sin(a2) + 16));
75
+  }
76
+
77
+  // Paint lower-left quadrant
78
+  if (a > PI) {
79
+    cmd.cmd(BEGIN(EDGE_STRIP_B));
80
+    cmd.cmd(VERTEX2F(cx, cy));
81
+    cmd.cmd(VERTEX2F(cx - ro*sin(a3) - 8,cy + ro*cos(a3)));
82
+  }
83
+
84
+  // Paint upper-left quadrant
85
+  if (a > 1.5*PI) {
86
+    cmd.cmd(BEGIN(EDGE_STRIP_L));
87
+    cmd.cmd(VERTEX2F(cx, cy));
88
+    cmd.cmd(VERTEX2F(cx - ro*cos(a4),cy - ro*sin(a4)));
89
+  }
90
+  cmd.cmd(RESTORE_CONTEXT());
91
+
92
+  // Draw the text
93
+  char str[5];
94
+  sprintf(str,"%d\%%",percent);
95
+
96
+  cmd.cmd(SAVE_CONTEXT());
97
+  cmd.cmd(COLOR_RGB(fgcolor));
98
+  cmd.text(x,y,w,h,str, OPT_CENTERX | OPT_CENTERY);
99
+  cmd.cmd(RESTORE_CONTEXT());
100
+}

+ 395
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/poly_ui.h View File

@@ -0,0 +1,395 @@
1
+/*************
2
+ * poly_ui.h *
3
+ *************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/**
25
+ * The PolyReader class iterates over an array of (x,y) pairs.
26
+ * For supporting polygons with holes an end-of-loop marker may
27
+ * be embedded into the data stream:
28
+ *
29
+ *   const PROGMEM uint16_t data[] = {
30
+ *      x, y, x, y, ..., eol,
31
+ *          ...
32
+ *      x, y, x, y, ..., eol
33
+ *   }
34
+ *
35
+ * The PolyReader object can be used to iterate over the points.
36
+ *
37
+ *   PolyReader r(data, N_ELEMENTS(data));
38
+ *
39
+ *   for(r.start();r.has_more(); r.next()) {
40
+ *     uint16_t x = r.x;
41
+ *     uint16_t y = r.y;
42
+ *
43
+ *     // Do something with the point
44
+ *         ...
45
+ *
46
+ *     // Do something else if this point
47
+ *     // closes a loop.
48
+ *     if (r.end_of_loop()) {
49
+ *       ...
50
+ *     }
51
+ *   }
52
+ *
53
+ */
54
+
55
+class PolyReader {
56
+  private:
57
+    typedef uint16_t type_t;
58
+
59
+    static constexpr type_t eol = 0xFFFF;
60
+
61
+    const type_t *p, *top, *end;
62
+    type_t start_x, start_y;
63
+
64
+    void close_loop() {
65
+      x       = start_x;
66
+      y       = start_y;
67
+      start_x = eol;
68
+      start_y = eol;
69
+    }
70
+
71
+  public:
72
+    type_t x, y;
73
+
74
+    // Begin reading a polygon data structure
75
+    PolyReader(const uint16_t data[], const size_t n_elements) : top(data), end(data + n_elements) {
76
+      start();
77
+    }
78
+
79
+    void start() {
80
+      p       = top;
81
+      start_x = eol;
82
+      next();
83
+    }
84
+
85
+    // Reads the next point in the polygon data structure
86
+    void next() {
87
+      if (!p) return;
88
+
89
+      if (p == end) {
90
+        if (start_x != eol)
91
+          close_loop();
92
+        else
93
+          p = NULL;
94
+      } else {
95
+        x = pgm_read_word_far(p++);
96
+        if (x == eol)
97
+          close_loop();
98
+        else {
99
+          y = pgm_read_word_far(p++);
100
+          if (start_x == eol) {
101
+            start_x = x;
102
+            start_y = y;
103
+          }
104
+        }
105
+      }
106
+    }
107
+
108
+    bool has_more()       {return p != NULL;}
109
+    bool end_of_loop()    {return start_x == eol;}
110
+};
111
+
112
+/**
113
+ * The TransformedPolyReader class works like the PolyReader,
114
+ * but the (x,y) input is assumed to be normalized onto a
115
+ * unit square and then mapped to the full 16-bits, i.e.
116
+ * (0.0,1.0) => (0x0000,0xFFFE). This class will scale the
117
+ * data to fit the entire display, a bounding box, or apply
118
+ * some arbitrary affine transform.
119
+ *
120
+ * This class is suitable for reading data from "svg2cpp.py"
121
+ */
122
+class TransformedPolyReader : public PolyReader {
123
+  private:
124
+    /**
125
+     * Fixed point type for fast transformations, supports
126
+     * values from 0 to 1024, with 1/32 precision.
127
+     */
128
+    static constexpr uint8_t fract_bits = 5;
129
+    typedef int16_t fix_t;
130
+    fix_t makefix(float f) {return f * (1 << fract_bits);}
131
+
132
+    // First two rows of 3x3 transformation matrix
133
+    fix_t a, b, c;
134
+    fix_t d, e, f;
135
+
136
+    void transform() {
137
+      /**
138
+       * Values from PolyReader vary from 0 to FFFE.
139
+       * As an approximation to dividing by FFFE,
140
+       * we perform a bit shift right by 16.
141
+       */
142
+      const int32_t px = PolyReader::x;
143
+      const int32_t py = PolyReader::y;
144
+      const int32_t round = 1 << (fract_bits-1);
145
+      x = (((((a * px) + (b * py)) >> 16) + c) + round) >> fract_bits;
146
+      y = (((((d * px) + (e * py)) >> 16) + f) + round) >> fract_bits;
147
+    }
148
+
149
+    void set_transform(
150
+      fix_t A, fix_t B, fix_t C,
151
+      fix_t D, fix_t E, fix_t F
152
+    ) {
153
+      a = A; b = B; c = C;
154
+      d = D; e = E; f = F;
155
+    }
156
+
157
+  public:
158
+    typedef int16_t type_t;
159
+
160
+    type_t x, y;
161
+
162
+    TransformedPolyReader(const uint16_t data[], const size_t n) : PolyReader(data, n) {
163
+      scale_to_fit();
164
+      transform();
165
+    }
166
+
167
+    // Set an arbitrary affine transform
168
+    void set_transform(
169
+      float A, float B, float C,
170
+      float D, float E, float F
171
+    ) {
172
+      set_transform(
173
+        makefix(A), makefix(B), makefix(C),
174
+        makefix(D), makefix(E), makefix(F)
175
+      );
176
+    }
177
+
178
+    // Scale the data to fit a specified bounding box
179
+    void scale_to_fit(type_t x_min, type_t y_min, type_t x_max, type_t y_max) {
180
+      fix_t sx = makefix(x_max - x_min);
181
+      fix_t sy = makefix(y_max - y_min);
182
+      fix_t tx = makefix(x_min);
183
+      fix_t ty = makefix(y_min);
184
+      set_transform(
185
+        sx,  0, tx,
186
+        0,  sy, ty
187
+      );
188
+    }
189
+
190
+    // Scale to fit the entire display (default)
191
+    void scale_to_fit() {
192
+      scale_to_fit(0, 0, FTDI::display_width, FTDI::display_height);
193
+    }
194
+
195
+    void next() {
196
+      PolyReader::next();
197
+      transform();
198
+    }
199
+};
200
+
201
+/**
202
+ * The DeduplicatedPolyReader wraps around another PolyReader
203
+ * class to remove repeated points from the data. This could
204
+ * happen when scaling down using TransformedPolyReader, for
205
+ * example.
206
+ */
207
+template<class POLY_READER>
208
+class DeduplicatedPolyReader : public POLY_READER {
209
+  private:
210
+    typename POLY_READER::type_t last_x, last_y;
211
+
212
+    static constexpr typename POLY_READER::type_t eol = 0xFFFF;
213
+
214
+  public:
215
+    DeduplicatedPolyReader(const uint16_t data[], const size_t n) : POLY_READER(data, n) {
216
+      last_x = POLY_READER::x;
217
+      last_y = POLY_READER::y;
218
+    }
219
+
220
+    void next() {
221
+      do {
222
+        if (!POLY_READER::has_more()) return;
223
+        POLY_READER::next();
224
+      } while (POLY_READER::x == last_x && POLY_READER::y == last_y && !POLY_READER::end_of_loop());
225
+      if (POLY_READER::end_of_loop()) {
226
+        last_x = last_y = eol;
227
+      } else {
228
+        last_x = POLY_READER::x;
229
+        last_y = POLY_READER::y;
230
+      }
231
+    }
232
+};
233
+
234
+/**
235
+ * The helper class allows you to build an interface based on arbitrary
236
+ * shapes.
237
+ */
238
+template<class POLY_READER=DeduplicatedPolyReader<TransformedPolyReader>>
239
+class GenericPolyUI {
240
+  private:
241
+    CommandProcessor &cmd;
242
+
243
+    // Attributes used to paint buttons
244
+
245
+    uint32_t btn_fill_color   = 0x000000;
246
+    uint32_t btn_shadow_color = 0xF3E0E0;
247
+    uint8_t  btn_shadow_depth = 5;
248
+    uint32_t btn_stroke_color = 0x000000;
249
+    uint8_t  btn_stroke_width = 28;
250
+
251
+    draw_mode_t mode;
252
+
253
+  public:
254
+    typedef POLY_READER poly_reader_t;
255
+
256
+    GenericPolyUI(CommandProcessor &c, draw_mode_t what = BOTH) : cmd(c), mode(what) {}
257
+
258
+    // Fills a polygon with the current COLOR_RGB
259
+    void fill(poly_reader_t r, bool clip = true) {
260
+      using namespace FTDI;
261
+      int16_t x, y, w, h;
262
+
263
+      if (clip) {
264
+        // Clipping reduces the number of pixels that are
265
+        // filled, allowing more complex shapes to be drawn
266
+        // in the alloted time.
267
+        bounds(r, x, y, w, h);
268
+        cmd.cmd(SAVE_CONTEXT());
269
+        cmd.cmd(SCISSOR_XY(x, y));
270
+        cmd.cmd(SCISSOR_SIZE(w, h));
271
+      }
272
+
273
+      Polygon p(cmd);
274
+      p.begin_fill();
275
+      p.begin_loop();
276
+      for(r.start();r.has_more();r.next()) {
277
+        p(r.x * 16, r.y * 16);
278
+        if (r.end_of_loop()) {
279
+          p.end_loop();
280
+          p.begin_loop();
281
+        }
282
+      }
283
+      p.end_loop();
284
+      p.end_fill();
285
+      if (clip)
286
+        cmd.cmd(RESTORE_CONTEXT());
287
+    }
288
+
289
+    void shadow(poly_reader_t r, uint8_t offset) {
290
+      #if FTDI_API_LEVEL >= 810
291
+        using namespace FTDI;
292
+        cmd.cmd(VERTEX_TRANSLATE_X(offset * 16));
293
+        cmd.cmd(VERTEX_TRANSLATE_Y(offset * 16));
294
+        fill(r, false);
295
+        cmd.cmd(VERTEX_TRANSLATE_X(0));
296
+        cmd.cmd(VERTEX_TRANSLATE_Y(0));
297
+      #endif
298
+    }
299
+
300
+    // Strokes a polygon with the current COLOR_RGB
301
+    void stroke(poly_reader_t r) {
302
+      using namespace FTDI;
303
+      Polygon p(cmd);
304
+      p.begin_stroke();
305
+      p.begin_loop();
306
+      for(r.start();r.has_more(); r.next()) {
307
+        p(r.x * 16, r.y * 16);
308
+        if (r.end_of_loop()) {
309
+          p.end_loop();
310
+          p.begin_loop();
311
+        }
312
+      }
313
+      p.end_loop();
314
+      p.end_stroke();
315
+    }
316
+
317
+    // Compute the bounds of a polygon
318
+    void bounds(poly_reader_t r, int16_t &x, int16_t &y, int16_t &w, int16_t &h) {
319
+      int16_t x_min = INT16_MAX;
320
+      int16_t y_min = INT16_MAX;
321
+      int16_t x_max = INT16_MIN;
322
+      int16_t y_max = INT16_MIN;
323
+      for(r.start(); r.has_more(); r.next()) {
324
+        x_min = min(x_min, r.x);
325
+        x_max = max(x_max, r.x);
326
+        y_min = min(y_min, r.y);
327
+        y_max = max(y_max, r.y);
328
+      }
329
+      x = x_min;
330
+      y = y_min;
331
+      w = x_max - x_min;
332
+      h = y_max - y_min;
333
+    }
334
+
335
+    /**
336
+     * Draw shaped buttons. Buttons are drawn out of a polygon which is
337
+     * filled and stroked on top of a drop shadow. The button will
338
+     * become "pushed" when touched.
339
+     */
340
+
341
+    void button_fill(const uint32_t color) {
342
+      btn_fill_color = color;
343
+    }
344
+
345
+    void button_stroke(const uint32_t color, const uint8_t width) {
346
+      btn_stroke_color = color;
347
+      btn_stroke_width = width;
348
+    }
349
+
350
+    void button_shadow(const uint32_t color, const uint8_t depth) {
351
+      btn_shadow_color = color;
352
+      btn_shadow_depth = depth;
353
+    }
354
+
355
+    void button(const uint8_t tag, poly_reader_t r) {
356
+      using namespace FTDI;
357
+      // Draw the shadow
358
+      #if FTDI_API_LEVEL >= 810
359
+      if (mode & BACKGROUND) {
360
+        cmd.cmd(SAVE_CONTEXT());
361
+        cmd.cmd(TAG(tag));
362
+        cmd.cmd(VERTEX_TRANSLATE_X(btn_shadow_depth * 16));
363
+        cmd.cmd(VERTEX_TRANSLATE_Y(btn_shadow_depth * 16));
364
+        cmd.cmd(COLOR_RGB(btn_shadow_color));
365
+        fill(r, false);
366
+        cmd.cmd(RESTORE_CONTEXT());
367
+      }
368
+      #endif
369
+
370
+      if (mode & FOREGROUND) {
371
+        cmd.cmd(SAVE_CONTEXT());
372
+        #if FTDI_API_LEVEL >= 810
373
+          if (EventLoop::get_pressed_tag() == tag) {
374
+            // "Push" the button
375
+            cmd.cmd(VERTEX_TRANSLATE_X(btn_shadow_depth * 16));
376
+            cmd.cmd(VERTEX_TRANSLATE_Y(btn_shadow_depth * 16));
377
+          }
378
+        #endif
379
+        // Draw the fill and stroke
380
+        cmd.cmd(TAG(tag));
381
+        cmd.cmd(COLOR_RGB(btn_fill_color));
382
+        fill(r, false);
383
+        cmd.cmd(COLOR_RGB(btn_stroke_color));
384
+        cmd.cmd(LINE_WIDTH(btn_stroke_width));
385
+        stroke(r);
386
+        cmd.cmd(RESTORE_CONTEXT());
387
+      }
388
+    }
389
+
390
+    void color(const uint32_t color) {
391
+      cmd.cmd(FTDI::COLOR_RGB(color));
392
+    }
393
+};
394
+
395
+typedef GenericPolyUI<> PolyUI;

+ 278
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extras/svg2cpp.py View File

@@ -0,0 +1,278 @@
1
+#!/usr/bin/python
2
+
3
+# Written By Marcio Teixeira 2018 - Aleph Objects, Inc.
4
+#
5
+# This program is free software: you can redistribute it and/or modify
6
+# it under the terms of the GNU General Public License as published by
7
+# the Free Software Foundation, either version 3 of the License, or
8
+# (at your option) any later version.
9
+#
10
+# This program is distributed in the hope that it will be useful,
11
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+# GNU General Public License for more details.
14
+#
15
+# To view a copy of the GNU General Public License, go to the following
16
+# location: <http://www.gnu.org/licenses/>.
17
+
18
+from __future__ import print_function
19
+import argparse, re, sys
20
+
21
+usage = '''
22
+This program extracts line segments from a SVG file and writes
23
+them as coordinates in a C array. The x and y values will be
24
+scaled from 0x0000 to 0xFFFE. 0xFFFF is used as path separator.
25
+
26
+This program can only interpret straight segments, not curves.
27
+It also cannot handle SVG transform attributes. To convert an
28
+SVG file into the proper format, use the following procedure:
29
+
30
+  - Load SVG file into Inkscape
31
+  - Convert all Objects to Paths (Path -> Object to Path)
32
+  - Convert all Strokes to Paths (Path -> Stroke to Path)
33
+  - Combine all paths into one (Path -> Combine) [1]
34
+  - Convert all curves into short line segments
35
+            (Extensions -> Modify Paths -> Flatten Beziers...)
36
+  - Save as new SVG
37
+  - Convert into a header file using this utility
38
+  - To give paths individual names, break apart paths and
39
+    use the XML Editor to set the "id" attributes.
40
+
41
+[1] Combining paths is necessary to remove transforms. You
42
+could also use inkscape-applytransforms Inkscape extension.
43
+
44
+'''
45
+
46
+header = '''
47
+/****************************************************************************
48
+ *   This program is free software: you can redistribute it and/or modify   *
49
+ *   it under the terms of the GNU General Public License as published by   *
50
+ *   the Free Software Foundation, either version 3 of the License, or      *
51
+ *   (at your option) any later version.                                    *
52
+ *                                                                          *
53
+ *   This program is distributed in the hope that it will be useful,        *
54
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
55
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
56
+ *   GNU General Public License for more details.                           *
57
+ *                                                                          *
58
+ *   To view a copy of the GNU General Public License, go to the following  *
59
+ *   location: <http://www.gnu.org/licenses/>.                              *
60
+ ****************************************************************************/
61
+
62
+/**
63
+ * This file was auto-generated using "svg2cpp.pl"
64
+ *
65
+ * The encoding consists of x,y pairs with the min and max scaled to
66
+ * 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the
67
+ * start of a new closed path.
68
+ */
69
+
70
+#pragma once
71
+'''
72
+
73
+class ComputeBoundingBox:
74
+  def reset(self):
75
+    self.x_min    = float(" inf")
76
+    self.y_min    = float(" inf")
77
+    self.x_max    = float("-inf")
78
+    self.y_max    = float("-inf")
79
+    self.n_points = 0
80
+    self.n_paths  = 0
81
+
82
+  def command(self, type, x, y):
83
+    self.x_min = min(self.x_min, x)
84
+    self.x_max = max(self.x_max, x)
85
+    self.y_min = min(self.y_min, y)
86
+    self.y_max = max(self.y_max, y)
87
+
88
+    if type == "M":
89
+      self.n_paths += 1
90
+    self.n_points += 1
91
+
92
+  def scale(self, x, y):
93
+    x -= self.x_min
94
+    y -= self.y_min
95
+    x /= self.x_max - self.x_min
96
+    y /= self.y_max - self.y_min
97
+    #y = 1 - y # Flip upside down
98
+    return (x, y)
99
+
100
+  def path_finished(self, id):
101
+    pass
102
+
103
+  def write(self):
104
+    print("constexpr float x_min = %f;\n" % self.x_min)
105
+    print("constexpr float x_max = %f;\n" % self.x_max)
106
+    print("constexpr float y_min = %f;\n" % self.y_min)
107
+    print("constexpr float y_max = %f;\n" % self.y_max)
108
+
109
+  def from_svg_view_box(self, svg):
110
+    s = re.search('<svg[^>]+>', svg);
111
+    if s:
112
+      m = re.search('viewBox="([0-9-.]+) ([0-9-.]+) ([0-9-.]+) ([0-9-.]+)"', svg)
113
+      if m:
114
+        self.x_min    = float(m.group(1))
115
+        self.y_min    = float(m.group(2))
116
+        self.x_max    = float(m.group(3))
117
+        self.y_max    = float(m.group(4))
118
+        return True
119
+    return False
120
+
121
+class WriteDataStructure:
122
+  def __init__(self, bounding_box):
123
+    self.bounds = bounding_box
124
+
125
+  def reset(self, ):
126
+    self.hex_words = []
127
+
128
+  def push(self, value):
129
+    self.hex_words.append("0x%04X" % value)
130
+
131
+  def command(self, type, x, y):
132
+    if type == "M":
133
+      self.push(0xFFFF)
134
+    x, y = self.bounds.scale(x,y)
135
+    self.push(x * 0xFFFE)
136
+    self.push(y * 0xFFFE)
137
+
138
+  def path_finished(self, id):
139
+    if self.hex_words and self.hex_words[0] == "0xFFFF":
140
+      self.hex_words.pop(0)
141
+    print("const PROGMEM uint16_t", id + "[] = {" + ", ".join (self.hex_words) + "};\n")
142
+    self.hex_words = []
143
+
144
+class Parser:
145
+  def __init__(self, op):
146
+    self.op = op
147
+    self.reset()
148
+
149
+  def reset(self):
150
+    self.last_x = 0
151
+    self.last_y = 0
152
+    self.initial_x = 0
153
+    self.initial_y = 0
154
+
155
+  def process_svg_path_L_or_M(self, cmd, x, y):
156
+    self.op.command(cmd, x, y)
157
+    self.last_x = x
158
+    self.last_y = y
159
+    if cmd == "M":
160
+      self.initial_x = x
161
+      self.initial_y = y
162
+
163
+  def process_svg_path_data_cmd(self, id, cmd, a, b):
164
+    """Converts the various types of moves into L or M commands
165
+    and dispatches to process_svg_path_L_or_M for futher processing."""
166
+    if cmd == "Z" or cmd == "z":
167
+      self.process_svg_path_L_or_M("L", self.initial_x, self.initial_y)
168
+    elif cmd == "H":
169
+      self.process_svg_path_L_or_M("L", a, self.last_y)
170
+    elif cmd == "V":
171
+      self.process_svg_path_L_or_M("L", self.last_x, a)
172
+    elif cmd == "h":
173
+      self.process_svg_path_L_or_M("L", self.last_x + a, self.last_y)
174
+    elif cmd == "v":
175
+      self.process_svg_path_L_or_M("L", self.last_x, self.last_y + a)
176
+    elif cmd == "L":
177
+      self.process_svg_path_L_or_M("L", a, b)
178
+    elif cmd == "l":
179
+      self.process_svg_path_L_or_M("L", self.last_x + a, self.last_y + b)
180
+    elif cmd == "M":
181
+      self.process_svg_path_L_or_M("M", a, b)
182
+    elif cmd == "m":
183
+      self.process_svg_path_L_or_M("M", self.last_x + a, self.last_y + b)
184
+    else:
185
+      print("Unsupported path data command:", cmd, "in path", id, "\n", file=sys.stderr)
186
+      quit()
187
+
188
+  def eat_token(self, regex):
189
+    """Looks for a token at the start of self.d.
190
+       If found, the token is removed."""
191
+    self.m = re.match(regex,self.d)
192
+    if self.m:
193
+      self.d = self.d[self.m.end():]
194
+    return self.m
195
+
196
+  def process_svg_path_data(self, id, d):
197
+    """Breaks up the "d" attribute into individual commands
198
+       and calls "process_svg_path_data_cmd" for each"""
199
+
200
+    self.d = d
201
+    while (self.d):
202
+      if self.eat_token('\s+'):
203
+        pass # Just eat the spaces
204
+
205
+      elif self.eat_token('([LMHVZlmhvz])'):
206
+        cmd = self.m.group(1)
207
+        # The following commands take no arguments
208
+        if cmd == "Z" or cmd == "z":
209
+          self.process_svg_path_data_cmd(id, cmd, 0, 0)
210
+
211
+      elif self.eat_token('([CScsQqTtAa])'):
212
+        print("Unsupported path data command:", self.m.group(1), "in path", id, "\n", file=sys.stderr)
213
+        quit()
214
+
215
+      elif self.eat_token('([ ,]*[-0-9e.]+)+'):
216
+        # Process list of coordinates following command
217
+        coords = re.split('[ ,]+', self.m.group(0))
218
+        # The following commands take two arguments
219
+        if cmd == "L" or cmd == "l":
220
+          while coords:
221
+            self.process_svg_path_data_cmd(id, cmd, float(coords.pop(0)), float(coords.pop(0)))
222
+        elif cmd == "M":
223
+          while coords:
224
+            self.process_svg_path_data_cmd(id, cmd, float(coords.pop(0)), float(coords.pop(0)))
225
+            # If a MOVETO has multiple points, the subsequent ones are assumed to be LINETO
226
+            cmd = "L"
227
+        elif cmd == "m":
228
+          while coords:
229
+            self.process_svg_path_data_cmd(id, cmd, float(coords.pop(0)), float(coords.pop(0)))
230
+            # If a MOVETO has multiple points, the subsequent ones are assumed to be LINETO
231
+            cmd = "l"
232
+        # Assume all other commands are single argument
233
+        else:
234
+          while coords:
235
+            self.process_svg_path_data_cmd(id, cmd, float(coords.pop(0)), 0)
236
+      else:
237
+        print("Syntax error:", d, "in path", id, "\n", file=sys.stderr)
238
+        quit()
239
+
240
+  def process_svg_paths(self, svg):
241
+    self.op.reset()
242
+    for path in re.findall('<path[^>]+>', svg):
243
+      id = "<none>"
244
+      m = re.search(' id="(.*)"', path)
245
+      if m:
246
+        id = m.group(1)
247
+
248
+      m = re.search(' transform="(.*)"', path)
249
+      if m:
250
+        print("Found transform in path", id, "! Cannot process file!", file=sys.stderr)
251
+        quit()
252
+
253
+      m = re.search(' d="(.*)"', path)
254
+      if m:
255
+        self.process_svg_path_data(id, m.group(1))
256
+        self.op.path_finished(id)
257
+        self.reset()
258
+
259
+if __name__ == "__main__":
260
+  parser = argparse.ArgumentParser()
261
+  parser.add_argument("filename")
262
+  args = parser.parse_args()
263
+
264
+  f = open(args.filename, "r")
265
+  data = f.read()
266
+
267
+  print(header)
268
+
269
+  b = ComputeBoundingBox()
270
+  if not b.from_svg_view_box(data):
271
+    # Can't find the view box, so use the bounding box of the elements themselves.
272
+    p = Parser(b)
273
+    p.process_svg_paths(data)
274
+  b.write()
275
+
276
+  w = WriteDataStructure(b)
277
+  p = Parser(w)
278
+  p.process_svg_paths(data)

+ 27
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/ftdi_eve_lib.h View File

@@ -0,0 +1,27 @@
1
+/******************
2
+ * ftdi_eve_lib.h *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2019 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2019 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#pragma once
24
+
25
+#include "compat.h"
26
+#include "basic/ftdi_basic.h"
27
+#include "extended/ftdi_extended.h"

+ 128
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/marlin_events.cpp View File

@@ -0,0 +1,128 @@
1
+/*********************
2
+ * marlin_events.cpp *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "compat.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens/screens.h"
28
+
29
+namespace ExtUI {
30
+  using namespace Theme;
31
+  using namespace FTDI;
32
+
33
+  void onStartup() {
34
+    EventLoop::setup();
35
+  }
36
+
37
+  void onIdle() {
38
+    EventLoop::loop();
39
+  }
40
+
41
+  void onPrinterKilled(PGM_P lcd_msg) {
42
+    KillScreen::show(progmem_str(lcd_msg));
43
+  }
44
+
45
+  void onMediaInserted() {
46
+    if (AT_SCREEN(StatusScreen))
47
+      StatusScreen::setStatusMessage(F(MSG_MEDIA_INSERTED));
48
+    sound.play(media_inserted, PLAY_ASYNCHRONOUS);
49
+  }
50
+
51
+  void onMediaRemoved() {
52
+    if (AT_SCREEN(StatusScreen))
53
+      StatusScreen::setStatusMessage(F(MSG_MEDIA_REMOVED));
54
+    sound.play(media_removed, PLAY_ASYNCHRONOUS);
55
+    if (AT_SCREEN(FilesScreen)) {
56
+      GOTO_SCREEN(StatusScreen)
57
+    }
58
+  }
59
+
60
+  void onMediaError() {
61
+    sound.play(sad_trombone, PLAY_ASYNCHRONOUS);
62
+    AlertDialogBox::showError(F("Unable to read media."));
63
+  }
64
+
65
+  void onStatusChanged(const char* lcd_msg) {
66
+    StatusScreen::setStatusMessage(lcd_msg);
67
+  }
68
+
69
+  void onStatusChanged(progmem_str lcd_msg) {
70
+    StatusScreen::setStatusMessage(lcd_msg);
71
+  }
72
+
73
+  void onPrintTimerStarted() {
74
+    InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_STARTED);
75
+  }
76
+
77
+  void onPrintTimerStopped() {
78
+    InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FINISHED);
79
+  }
80
+
81
+  void onPrintTimerPaused() {
82
+  }
83
+
84
+  void onFilamentRunout(const extruder_t extruder) {
85
+    char lcd_msg[30];
86
+    sprintf_P(lcd_msg, PSTR("Extruder %d Filament Error"), extruder + 1);
87
+    StatusScreen::setStatusMessage(lcd_msg);
88
+    InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED);
89
+  }
90
+
91
+  void onFactoryReset() {
92
+    InterfaceSettingsScreen::defaultSettings();
93
+  }
94
+
95
+  void onStoreSettings(char *buff) {
96
+    InterfaceSettingsScreen::saveSettings(buff);
97
+  }
98
+
99
+  void onLoadSettings(const char *buff) {
100
+    InterfaceSettingsScreen::loadSettings(buff);
101
+  }
102
+
103
+  void onConfigurationStoreWritten(bool success) {
104
+    #ifdef LULZBOT_EEPROM_BACKUP_SIZE
105
+      if (success && InterfaceSettingsScreen::backupEEPROM()) {
106
+        SERIAL_ECHOLNPGM("Made backup of EEPROM to SPI Flash");
107
+      }
108
+    #else
109
+      UNUSED(success);
110
+    #endif
111
+  }
112
+
113
+  void onConfigurationStoreRead(bool) {
114
+  }
115
+
116
+  void onPlayTone(const uint16_t frequency, const uint16_t duration) {
117
+    sound.play_tone(frequency, duration);
118
+  }
119
+
120
+  void onUserConfirmRequired(const char * const msg) {
121
+    if (msg)
122
+      ConfirmUserRequestAlertBox::show(msg);
123
+    else
124
+      ConfirmUserRequestAlertBox::hide();
125
+  }
126
+}
127
+
128
+#endif // LULZBOT_TOUCH_UI

+ 142
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/pin_mappings.h View File

@@ -0,0 +1,142 @@
1
+/******************
2
+ * pin_mappings.h *
3
+ ******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
7
+ *                                                                          *
8
+ *   This program is free software: you can redistribute it and/or modify   *
9
+ *   it under the terms of the GNU General Public License as published by   *
10
+ *   the Free Software Foundation, either version 3 of the License, or      *
11
+ *   (at your option) any later version.                                    *
12
+ *                                                                          *
13
+ *   This program is distributed in the hope that it will be useful,        *
14
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
15
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
16
+ *   GNU General Public License for more details.                           *
17
+ *                                                                          *
18
+ *   To view a copy of the GNU General Public License, go to the following  *
19
+ *   location: <http://www.gnu.org/licenses/>.                              *
20
+ ****************************************************************************/
21
+
22
+#pragma once
23
+
24
+/* This file defines mappings from the ULTRA_LCD pins functions to new
25
+ * functions for the FTDI display. These mappings allows any board that
26
+ * support ULTRA_LCD via EXP1 and EXP2 connectors to use FTDI modules
27
+ * without adding new pin definitions to the board.
28
+ */
29
+
30
+#ifdef CR10_TFT_PINMAP
31
+  #ifndef __MARLIN_FIRMWARE__
32
+    #error This pin mapping requires Marlin.
33
+  #endif
34
+
35
+  #define CLCD_USE_SOFT_SPI
36
+  #define CLCD_SOFT_SPI_SCLK  LCD_PINS_D4      // PORTA1               Pin 6
37
+  #define CLCD_SOFT_SPI_MOSI  LCD_PINS_ENABLE  // PORTC1               Pin 8
38
+  #define CLCD_SPI_CS         LCD_PINS_RS      // PORTA3               Pin 7
39
+  #define CLCD_SOFT_SPI_MISO  16               // PORTC0   BTN_ENC     Pin 2
40
+  #define CLCD_MOD_RESET      11               // PORTD3   BTN_EN1     Pin 3
41
+  #define CLCD_AUX_0          10               // PORTD2   BTN_EN2     Pin 5
42
+  #define CLCD_AUX_1          BEEPER_PIN       // PORTA4               Pin 1
43
+#endif
44
+
45
+/**
46
+ * The AlephObjects pinout for re-purposing the UltraLCD
47
+ * connector EXP1 for software SPI (rev B, obsolete)
48
+ */
49
+
50
+#ifdef AO_EXP1_DEPRECATED_PINMAP
51
+  #ifndef __MARLIN_FIRMWARE__
52
+    #error This pin mapping requires Marlin.
53
+  #endif
54
+
55
+  #define CLCD_MOD_RESET                 LCD_PINS_D4
56
+  #define CLCD_SPI_CS                    LCD_PINS_D5
57
+
58
+  #define CLCD_AUX_0                     LCD_PINS_ENABLE
59
+  #define CLCD_AUX_1                     BTN_ENC
60
+  #define CLCD_AUX_2                     BEEPER_PIN
61
+
62
+  #define CLCD_USE_SOFT_SPI
63
+  #define CLCD_SOFT_SPI_SCLK             LCD_PINS_D7
64
+  #define CLCD_SOFT_SPI_MOSI             LCD_PINS_D6
65
+  #define CLCD_SOFT_SPI_MISO             LCD_PINS_RS
66
+#endif
67
+
68
+/**
69
+ * AO_EXP1_PINMAP
70
+ *
71
+ * The AlephObjects mapping for re-purposing the UltraLCD
72
+ * connector EXP1 for software SPI for display (rev C):
73
+ *
74
+ *     EXP2:      FTDI:   SD -or- USB [1]:     ULTRA_LCD:
75
+ *      1         MISO    MISO    MISO    -->  BEEPER
76
+ *      2         SCLK    SCLK    SCLK    -->  BTN_ENC
77
+ *      3         PD_N      -      -      -->  LCDE
78
+ *      4          -      CS_N    CS_N    -->  LCDRS
79
+ *      5         CS_N      -      -      -->  LCD4
80
+ *      6         MOSI    MOSI    MOSI    -->  LCD5
81
+ *      7          -      SD_DET  INT     -->  LCD6
82
+ *      8         RESET     -     RESET   -->  LCD4
83
+ *      9         GND     GND     GND     -->  GND
84
+ *     10         5V      5V      5V      -->  5V
85
+ *
86
+ *     [1] At the moment, Marlin does not support SD or USB
87
+ *         functionality over software SPI.
88
+ */
89
+
90
+#ifdef AO_EXP1_PINMAP
91
+  #ifndef __MARLIN_FIRMWARE__
92
+    #error This pin mapping requires Marlin.
93
+  #endif
94
+
95
+  #define CLCD_MOD_RESET                 LCD_PINS_ENABLE
96
+  #define CLCD_SPI_CS                    LCD_PINS_D4
97
+
98
+  #define CLCD_USE_SOFT_SPI
99
+  #define CLCD_SOFT_SPI_SCLK             BTN_ENC
100
+  #define CLCD_SOFT_SPI_MOSI             LCD_PINS_D5
101
+  #define CLCD_SOFT_SPI_MISO             BEEPER_PIN
102
+#endif
103
+
104
+/**
105
+ * AO_EXP2_PINMAP
106
+ *
107
+ * The AlephObjects mapping for re-purposing the UltraLCD
108
+ * connector EXP2 for hardware SPI for display and SD card
109
+ * or USB (rev C):
110
+ *
111
+ *     EXP2:      FTDI:   SD -or- USB:         ULTRA_LCD:
112
+ *      1         MISO    MISO    MISO    -->  MISO
113
+ *      2         SCLK    SCLK    SCLK    -->  SCLK
114
+ *      3         PD_N      -      -      -->  BTN_EN2
115
+ *      4          -      CS_N    CS_N    -->  SD_CSEL
116
+ *      5         CS_N      -      -      -->  BTN_EN1
117
+ *      6         MOSI    MOSI    MOSI    -->  MOSI
118
+ *      7          -      SD_DET  INT     -->  SD_DET
119
+ *      8         RESET     -     RESET   -->  RESET
120
+ *      9         GND     GND     GND     -->  GND
121
+ *     10         5V      5V      5V      -->  KILL [3]
122
+ *
123
+ * [1] This configuration is not compatible with the
124
+ *     EinsyRetro 1.1a because there is a level shifter
125
+ *     on MISO enabled by SD/USB chip select.
126
+ *
127
+ * [2] This configuration allows daisy-chaining of the
128
+ *     display and SD/USB on EXP2.
129
+ *
130
+ * [3] Archim Rambo provides 5V on this pin. On any other
131
+ *     board, divert this wire from the ribbon cable and
132
+ *     connect it to 5V at an endstop.
133
+ */
134
+
135
+#ifdef AO_EXP2_PINMAP
136
+  #ifndef __MARLIN_FIRMWARE__
137
+    #error This pin mapping requires Marlin.
138
+  #endif
139
+
140
+  #define CLCD_SPI_CS                    BTN_EN1
141
+  #define CLCD_MOD_RESET                 BTN_EN2
142
+#endif

+ 80
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/about_screen.cpp View File

@@ -0,0 +1,80 @@
1
+/********************
2
+ * about_screen.cpp *
3
+ ********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+#define GRID_COLS 4
30
+#define GRID_ROWS 9
31
+
32
+using namespace FTDI;
33
+using namespace Theme;
34
+using namespace ExtUI;
35
+
36
+void AboutScreen::onEntry() {
37
+  BaseScreen::onEntry();
38
+  sound.play(chimes, PLAY_ASYNCHRONOUS);
39
+}
40
+
41
+void AboutScreen::onRedraw(draw_mode_t) {
42
+  CommandProcessor cmd;
43
+  cmd.cmd(CLEAR_COLOR_RGB(bg_color))
44
+     .cmd(CLEAR(true,true,true))
45
+     .cmd(COLOR_RGB(bg_text_enabled))
46
+     .tag(0);
47
+
48
+  draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(4,1), F(
49
+      #ifdef LULZBOT_LCD_MACHINE_NAME
50
+      LULZBOT_LCD_MACHINE_NAME
51
+      #else
52
+      "Color Touch Panel"
53
+      #endif
54
+    ), OPT_CENTER, font_xlarge);
55
+
56
+  cmd.tag(2);
57
+  draw_text_box(cmd, BTN_POS(1,3), BTN_SIZE(4,3), F(
58
+      #ifdef LULZBOT_LCD_TOOLHEAD_NAME
59
+        "Firmware for toolhead:\n" LULZBOT_LCD_TOOLHEAD_NAME "\n\n"
60
+      #endif
61
+      "(C) 2019 Aleph Objects, Inc.\n\nwww.lulzbot.com"
62
+  ), OPT_CENTER, font_medium);
63
+
64
+  cmd.tag(0);
65
+  draw_text_box(cmd, BTN_POS(1,6), BTN_SIZE(4,2), progmem_str(getFirmwareName_str()), OPT_CENTER, font_medium);
66
+
67
+  cmd.font(font_medium).colors(action_btn).tag(1).button(BTN_POS(2,8), BTN_SIZE(2,1), F("Okay"));
68
+}
69
+
70
+bool AboutScreen::onTouchEnd(uint8_t tag) {
71
+  switch (tag) {
72
+    case 1: GOTO_PREVIOUS();            return true;
73
+#if ENABLED(DEVELOPER_SCREENS)
74
+    case 2: GOTO_SCREEN(DeveloperMenu); return true;
75
+#endif
76
+    default:                            return false;
77
+  }
78
+}
79
+
80
+#endif // LULZBOT_TOUCH_UI

+ 191
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/advanced_settings_menu.cpp View File

@@ -0,0 +1,191 @@
1
+/*****************************
2
+ * advance_settings_menu.cpp *
3
+ *****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && !defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
34
+  if (what & BACKGROUND) {
35
+    CommandProcessor cmd;
36
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
37
+       .cmd(CLEAR(true,true,true));
38
+  }
39
+
40
+  if (what & FOREGROUND) {
41
+    CommandProcessor cmd;
42
+    cmd.colors(normal_btn)
43
+       .font(Theme::font_medium)
44
+    #ifdef TOUCH_UI_PORTRAIT
45
+      #define GRID_ROWS 9
46
+      #define GRID_COLS 2
47
+      #if HAS_BED_PROBE
48
+        .enabled(1)
49
+      #else
50
+        .enabled(0)
51
+      #endif
52
+      .tag(2) .button( BTN_POS(1,1), BTN_SIZE(1,1), F("Z Offset "))
53
+      .enabled(1)
54
+      .tag(3) .button( BTN_POS(2,1), BTN_SIZE(1,1), F("Steps/mm"))
55
+      #if HAS_TRINAMIC
56
+        .enabled(1)
57
+      #else
58
+        .enabled(0)
59
+      #endif
60
+      .tag(13).button( BTN_POS(1,5), BTN_SIZE(1,1), F("Motor mA"))
61
+      #if HAS_TRINAMIC
62
+        .enabled(1)
63
+      #else
64
+        .enabled(0)
65
+      #endif
66
+      .tag(14).button( BTN_POS(1,4), BTN_SIZE(1,1), F("Bump Sense"))
67
+      #if HOTENDS > 1
68
+      .enabled(1)
69
+      #else
70
+      .enabled(0)
71
+      #endif
72
+      .tag(4) .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Nozzle Offset"))
73
+      #if ENABLED(LIN_ADVANCE) || ENABLED(FILAMENT_RUNOUT_SENSOR)
74
+      .enabled(1)
75
+      #else
76
+      .enabled(0)
77
+      #endif
78
+      .tag(11).button( BTN_POS(1,3), BTN_SIZE(1,1), F("Filament"))
79
+      .tag(12).button( BTN_POS(1,6), BTN_SIZE(1,1), F("Endstops"))
80
+      .tag(15).button( BTN_POS(2,6), BTN_SIZE(1,1), F("Display"))
81
+      .tag(9) .button( BTN_POS(1,7), BTN_SIZE(2,1), F("Interface Settings"))
82
+      .tag(10).button( BTN_POS(1,8), BTN_SIZE(2,1), F("Restore Factory Defaults"))
83
+      .tag(5) .button( BTN_POS(2,2), BTN_SIZE(1,1), F("Velocity "))
84
+      .tag(6) .button( BTN_POS(2,3), BTN_SIZE(1,1), F("Acceleration"))
85
+      #if ENABLED(JUNCTION_DEVIATION)
86
+      .tag(7) .button( BTN_POS(2,4), BTN_SIZE(1,1), F("Junc Dev"))
87
+      #else
88
+      .tag(7) .button( BTN_POS(2,4), BTN_SIZE(1,1), F("Jerk"))
89
+      #endif
90
+      #if ENABLED(BACKLASH_GCODE)
91
+      .enabled(1)
92
+      #else
93
+      .enabled(0)
94
+      #endif
95
+      .tag(8).button( BTN_POS(2,5), BTN_SIZE(1,1), F("Backlash"))
96
+      .colors(action_btn)
97
+      .tag(1) .button( BTN_POS(1,9), BTN_SIZE(2,1), F("Back"));
98
+      #undef GRID_COLS
99
+      #undef GRID_ROWS
100
+    #else
101
+      #define GRID_ROWS 6
102
+      #define GRID_COLS 3
103
+      #if HAS_BED_PROBE
104
+        .enabled(1)
105
+      #else
106
+        .enabled(0)
107
+      #endif
108
+      .tag(2) .button( BTN_POS(1,1),  BTN_SIZE(1,2), F("Z Offset "))
109
+      .enabled(1)
110
+      .tag(3) .button( BTN_POS(2,1),  BTN_SIZE(1,1), F("Steps/mm"))
111
+      #if HAS_TRINAMIC
112
+        .enabled(1)
113
+      #else
114
+        .enabled(0)
115
+      #endif
116
+      .tag(13).button( BTN_POS(3,1), BTN_SIZE(1,1), F("Motor mA"))
117
+      #if HAS_TRINAMIC
118
+        .enabled(1)
119
+      #else
120
+        .enabled(0)
121
+      #endif
122
+      .tag(14).button( BTN_POS(3,2), BTN_SIZE(1,1), F("Bump Sense"))
123
+      #if ENABLED(BACKLASH_GCODE)
124
+      .enabled(1)
125
+      #else
126
+      .enabled(0)
127
+      #endif
128
+      .tag(8).button( BTN_POS(3,3),  BTN_SIZE(1,1), F("Backlash"))
129
+      #if HOTENDS > 1
130
+      .enabled(1)
131
+      #else
132
+      .enabled(0)
133
+      #endif
134
+      .tag(4) .button( BTN_POS(1,3),  BTN_SIZE(1,1), F("Nozzle Offsets"))
135
+      .tag(12).button( BTN_POS(3,4),  BTN_SIZE(1,1), F("Endstops"))
136
+      .tag(5) .button( BTN_POS(2,2),  BTN_SIZE(1,1), F("Velocity "))
137
+      .tag(6) .button( BTN_POS(2,3),  BTN_SIZE(1,1), F("Acceleration"))
138
+      #if ENABLED(JUNCTION_DEVIATION)
139
+      .tag(7) .button( BTN_POS(2,4),  BTN_SIZE(1,1), F("Junc Dev"))
140
+      #else
141
+      .tag(7) .button( BTN_POS(2,4),  BTN_SIZE(1,1), F("Jerk"))
142
+      #endif
143
+      .tag(11).button( BTN_POS(1,4),  BTN_SIZE(1,1), F("Filament"))
144
+      .tag(15).button( BTN_POS(3,5),  BTN_SIZE(1,1), F("Display"))
145
+      .tag(9) .button( BTN_POS(1,5),  BTN_SIZE(2,1), F("Interface Settings"))
146
+      .tag(10).button( BTN_POS(1,6),  BTN_SIZE(2,1), F("Restore Defaults"))
147
+      .colors(action_btn)
148
+      .tag(1) .button( BTN_POS(3,6),  BTN_SIZE(1,1), F("Back"));
149
+    #endif
150
+  }
151
+}
152
+
153
+bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
154
+  switch (tag) {
155
+    case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
156
+    #if HAS_BED_PROBE
157
+    case 2:  GOTO_SCREEN(ZOffsetScreen);              break;
158
+    #endif
159
+    case 3:  GOTO_SCREEN(StepsScreen);                break;
160
+    #if HOTENDS > 1
161
+    case 4:  GOTO_SCREEN(NozzleOffsetScreen);         break;
162
+    #endif
163
+    case 5:  GOTO_SCREEN(MaxVelocityScreen);          break;
164
+    case 6:  GOTO_SCREEN(DefaultAccelerationScreen);  break;
165
+    case 7:
166
+      #if ENABLED(JUNCTION_DEVIATION)
167
+        GOTO_SCREEN(JunctionDeviationScreen);
168
+      #else
169
+        GOTO_SCREEN(JerkScreen);
170
+      #endif
171
+      break;
172
+    #if ENABLED(BACKLASH_GCODE)
173
+    case 8:  GOTO_SCREEN(BacklashCompensationScreen); break;
174
+    #endif
175
+    case 9:  GOTO_SCREEN(InterfaceSettingsScreen);  LockScreen::check_passcode(); break;
176
+    case 10: GOTO_SCREEN(RestoreFailsafeDialogBox); LockScreen::check_passcode(); break;
177
+    #if ENABLED(LIN_ADVANCE) || ENABLED(FILAMENT_RUNOUT_SENSOR)
178
+    case 11: GOTO_SCREEN(FilamentMenu); break;
179
+    #endif
180
+    case 12: GOTO_SCREEN(EndstopStatesScreen); break;
181
+    #if HAS_TRINAMIC
182
+    case 13: GOTO_SCREEN(StepperCurrentScreen); break;
183
+    case 14: GOTO_SCREEN(StepperBumpSensitivityScreen); break;
184
+    #endif
185
+    case 15: GOTO_SCREEN(DisplayTuningScreen); break;
186
+    default: return false;
187
+  }
188
+  return true;
189
+}
190
+
191
+#endif // LULZBOT_TOUCH_UI

+ 70
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/alert_dialog_box.cpp View File

@@ -0,0 +1,70 @@
1
+/************************
2
+ * alert_dialog_box.cpp *
3
+ ************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+using namespace Theme;
32
+
33
+void AlertDialogBox::onEntry() {
34
+  BaseScreen::onEntry();
35
+  sound.play(screen_data.AlertDialogBox.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS);
36
+}
37
+
38
+void AlertDialogBox::onRedraw(draw_mode_t what) {
39
+  if (what & FOREGROUND) {
40
+    drawOkayButton();
41
+  }
42
+}
43
+
44
+template<typename T>
45
+void AlertDialogBox::show(const T message) {
46
+  drawMessage(message);
47
+  storeBackground();
48
+  screen_data.AlertDialogBox.isError = false;
49
+  GOTO_SCREEN(AlertDialogBox);
50
+}
51
+
52
+template<typename T>
53
+void AlertDialogBox::showError(const T message) {
54
+  drawMessage(message);
55
+  storeBackground();
56
+  screen_data.AlertDialogBox.isError = true;
57
+  GOTO_SCREEN(AlertDialogBox);
58
+}
59
+
60
+void AlertDialogBox::hide() {
61
+  if (AT_SCREEN(AlertDialogBox))
62
+    GOTO_PREVIOUS();
63
+}
64
+
65
+template void AlertDialogBox::show(const char *);
66
+template void AlertDialogBox::show(const progmem_str);
67
+template void AlertDialogBox::showError(const char *);
68
+template void AlertDialogBox::showError(const progmem_str);
69
+
70
+#endif // LULZBOT_TOUCH_UI

+ 72
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/backlash_compensation_screen.cpp View File

@@ -0,0 +1,72 @@
1
+/************************************
2
+ * backlash_compensation_screen.cpp *
3
+ ************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(BACKLASH_GCODE)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void BacklashCompensationScreen::onRedraw(draw_mode_t what) {
34
+  widgets_t w(what);
35
+  w.precision(2).units(PSTR("mm"));
36
+  w.heading(                  PSTR("Axis Backlash"));
37
+  w.color(x_axis).adjuster(2, PSTR("X:"), getAxisBacklash_mm(X));
38
+  w.color(y_axis).adjuster(4, PSTR("Y:"), getAxisBacklash_mm(Y));
39
+  w.color(z_axis).adjuster(6, PSTR("Z:"), getAxisBacklash_mm(Z));
40
+  #if ENABLED(CALIBRATION_GCODE)
41
+  w.button(12, PSTR("Measure automatically"));
42
+  #endif
43
+  w.color(other).adjuster(8,  PSTR("Smoothing:"), getBacklashSmoothing_mm());
44
+  w.precision(0).units(PSTR("%"))
45
+                .adjuster(10, PSTR("Correction:"), getBacklashCorrection_percent());
46
+  w.precision(2).increments();
47
+}
48
+
49
+bool BacklashCompensationScreen::onTouchHeld(uint8_t tag) {
50
+  const float increment = getIncrement();
51
+  switch (tag) {
52
+    case  2:  UI_DECREMENT(AxisBacklash_mm, X); break;
53
+    case  3:  UI_INCREMENT(AxisBacklash_mm, X); break;
54
+    case  4:  UI_DECREMENT(AxisBacklash_mm, Y); break;
55
+    case  5:  UI_INCREMENT(AxisBacklash_mm, Y); break;
56
+    case  6:  UI_DECREMENT(AxisBacklash_mm, Z); break;
57
+    case  7:  UI_INCREMENT(AxisBacklash_mm, Z); break;
58
+    case  8:  UI_DECREMENT(BacklashSmoothing_mm); break;
59
+    case  9:  UI_INCREMENT(BacklashSmoothing_mm); break;
60
+    case  10: UI_DECREMENT_BY(BacklashCorrection_percent, increment*100);  break;
61
+    case  11: UI_INCREMENT_BY(BacklashCorrection_percent, increment*100);  break;
62
+    #if ENABLED(CALIBRATION_GCODE)
63
+    case  12: GOTO_SCREEN(ConfirmAutoCalibrationDialogBox); return true;
64
+    #endif
65
+    default:
66
+      return false;
67
+  }
68
+  SaveSettingsDialogBox::settingsChanged();
69
+  return true;
70
+}
71
+
72
+#endif // LULZBOT_TOUCH_UI

+ 342
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_numeric_adjustment_screen.cpp View File

@@ -0,0 +1,342 @@
1
+/**************************************
2
+ * base_numeric_adjustment_screen.cpp *
3
+ **************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+using namespace Theme;
32
+
33
+#ifdef TOUCH_UI_PORTRAIT
34
+  #define GRID_COLS 13
35
+  #define GRID_ROWS 10
36
+#else
37
+  #define GRID_COLS 18
38
+  #define GRID_ROWS  7
39
+#endif
40
+
41
+BaseNumericAdjustmentScreen::widgets_t::widgets_t(draw_mode_t what) : _what(what) {
42
+  if (what & BACKGROUND) {
43
+    CommandProcessor cmd;
44
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
45
+       .cmd(CLEAR(true,true,true));
46
+  }
47
+
48
+  if (what & FOREGROUND) {
49
+    CommandProcessor cmd;
50
+    cmd.font(font_medium)
51
+       .colors(action_btn)
52
+    #ifdef TOUCH_UI_PORTRAIT
53
+       .tag(1).button( BTN_POS(1,10), BTN_SIZE(13,1), F("Back"))
54
+    #else
55
+       .tag(1).button( BTN_POS(15,7), BTN_SIZE(4,1),  F("Back"))
56
+    #endif
57
+       .colors(normal_btn);
58
+  }
59
+
60
+  _line = 1;
61
+  _units = PSTR("");
62
+}
63
+
64
+BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) {
65
+  _decimals = decimals;
66
+  if (screen_data.BaseNumericAdjustmentScreen.increment == 0) {
67
+    screen_data.BaseNumericAdjustmentScreen.increment = 243 + (initial - DEFAULT_LOWEST) - _decimals;
68
+  }
69
+  return *this;
70
+}
71
+
72
+void BaseNumericAdjustmentScreen::widgets_t::heading(const char *label) {
73
+  CommandProcessor cmd;
74
+  cmd.font(font_medium).cmd(COLOR_RGB(bg_text_enabled));
75
+  if (_what & BACKGROUND) {
76
+    #ifdef TOUCH_UI_PORTRAIT
77
+      cmd.tag(0).fgcolor(bg_color).button( BTN_POS(1, _line), BTN_SIZE(12,1), progmem_str(label), OPT_FLAT);
78
+    #else
79
+      cmd.tag(0).fgcolor(bg_color).button( BTN_POS(5, _line), BTN_SIZE(8,1),  progmem_str(label), OPT_FLAT);
80
+    #endif
81
+  }
82
+
83
+  _line++;
84
+}
85
+
86
+#ifdef TOUCH_UI_PORTRAIT
87
+  #ifdef TOUCH_UI_800x480
88
+    #undef EDGE_R
89
+    #define EDGE_R 20
90
+  #else
91
+    #undef EDGE_R
92
+    #define EDGE_R 10
93
+  #endif
94
+#endif
95
+
96
+void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(uint8_t, const uint8_t tag) {
97
+  CommandProcessor  cmd;
98
+  const char        *label = PSTR("?");
99
+  uint8_t            pos;
100
+  uint8_t &          increment = screen_data.BaseNumericAdjustmentScreen.increment;
101
+
102
+  if (increment == 0) {
103
+    increment = tag; // Set the default value to be the first.
104
+  }
105
+
106
+  switch (tag) {
107
+    case 240: label = PSTR(   ".001"); pos = _decimals - 3; break;
108
+    case 241: label = PSTR(   ".01" ); pos = _decimals - 2; break;
109
+    case 242: label = PSTR(  "0.1"  ); pos = _decimals - 1; break;
110
+    case 243: label = PSTR(  "1"    ); pos = _decimals + 0; break;
111
+    case 244: label = PSTR( "10"    ); pos = _decimals + 1; break;
112
+    default:  label = PSTR("100"    ); pos = _decimals + 2; break;
113
+  }
114
+
115
+  cmd.tag(tag)
116
+     .colors(increment == tag ? action_btn : normal_btn)
117
+  #ifdef TOUCH_UI_PORTRAIT
118
+     .font(font_small);
119
+  #else
120
+     .font(font_medium);
121
+  #endif
122
+  switch (pos) {
123
+    #ifdef TOUCH_UI_PORTRAIT
124
+      case 0: cmd.button( BTN_POS(5,_line), BTN_SIZE(2,1), progmem_str(label)); break;
125
+      case 1: cmd.button( BTN_POS(7,_line), BTN_SIZE(2,1), progmem_str(label)); break;
126
+      case 2: cmd.button( BTN_POS(9,_line), BTN_SIZE(2,1), progmem_str(label)); break;
127
+    #else
128
+      case 0: cmd.button( BTN_POS(15,2),    BTN_SIZE(4,1), progmem_str(label)); break;
129
+      case 1: cmd.button( BTN_POS(15,3),    BTN_SIZE(4,1), progmem_str(label)); break;
130
+      case 2: cmd.button( BTN_POS(15,4),    BTN_SIZE(4,1), progmem_str(label)); break;
131
+    #endif
132
+  }
133
+  cmd.colors(normal_btn);
134
+}
135
+
136
+
137
+void BaseNumericAdjustmentScreen::widgets_t::increments() {
138
+  if (_what & BACKGROUND) {
139
+    CommandProcessor cmd;
140
+    cmd.fgcolor(bg_color)
141
+       .tag(0)
142
+    #ifdef TOUCH_UI_PORTRAIT
143
+       .font(font_small).button( BTN_POS(1, _line),  BTN_SIZE(4,1), F("Increment:"), OPT_FLAT);
144
+    #else
145
+       .font(font_medium).button( BTN_POS(15,1),     BTN_SIZE(4,1), F("Increment:"), OPT_FLAT);
146
+    #endif
147
+  }
148
+
149
+  if (_what & FOREGROUND) {
150
+      _draw_increment_btn(_line+1, 245 - _decimals);
151
+      _draw_increment_btn(_line+1, 244 - _decimals);
152
+      _draw_increment_btn(_line+1, 243 - _decimals);
153
+  }
154
+
155
+  #ifdef TOUCH_UI_PORTRAIT
156
+  _line++;
157
+  #endif
158
+}
159
+
160
+void BaseNumericAdjustmentScreen::widgets_t::adjuster_sram_val(uint8_t tag, const char *label, const char *value, bool is_enabled) {
161
+  CommandProcessor cmd;
162
+
163
+  if (_what & BACKGROUND) {
164
+    cmd.enabled(1)
165
+       .font(font_small)
166
+       .fgcolor(_color)            .tag(0).button( BTN_POS(5,_line), BTN_SIZE(5,1), F(""),               OPT_FLAT)
167
+       .cmd(COLOR_RGB(bg_text_enabled))
168
+       .fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), (progmem_str) label, OPT_FLAT);
169
+  }
170
+
171
+  if (_what & FOREGROUND) {
172
+    cmd.colors(normal_btn)
173
+       .font(font_medium)
174
+       .tag(is_enabled ? tag   : 0).enabled(is_enabled).button( BTN_POS(10,_line), BTN_SIZE(2,1),  F("-"))
175
+       .tag(is_enabled ? tag+1 : 0).enabled(is_enabled).button( BTN_POS(12,_line), BTN_SIZE(2,1),  F("+"))
176
+       .tag(0).font(font_small)                        .text  ( BTN_POS(5,_line),  BTN_SIZE(5,1),  is_enabled ? value : "-");
177
+  }
178
+
179
+  _line++;
180
+}
181
+
182
+void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, const char *label, const char *value, bool is_enabled) {
183
+  if (_what & BACKGROUND) {
184
+    adjuster_sram_val(tag, label, nullptr);
185
+  }
186
+
187
+  if (_what & FOREGROUND) {
188
+    char b[strlen_P(value)+1];
189
+    strcpy_P(b,value);
190
+    adjuster_sram_val(tag, label, b, is_enabled);
191
+  }
192
+}
193
+
194
+void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, const char *label, float value, bool is_enabled) {
195
+  if (_what & BACKGROUND) {
196
+    adjuster_sram_val(tag, label, nullptr);
197
+  }
198
+
199
+  if (_what & FOREGROUND) {
200
+    char b[32];
201
+    dtostrf(value, 5, _decimals, b);
202
+    strcat_P(b, PSTR(" "));
203
+    strcat_P(b, (const char*) _units);
204
+    adjuster_sram_val(tag, label, b, is_enabled);
205
+  }
206
+}
207
+
208
+void BaseNumericAdjustmentScreen::widgets_t::button(uint8_t tag, const char *label, bool is_enabled) {
209
+  if (_what & FOREGROUND) {
210
+    CommandProcessor cmd;
211
+    cmd.colors(normal_btn)
212
+       .tag(is_enabled ? tag   : 0)
213
+       .enabled(is_enabled)
214
+    #ifdef TOUCH_UI_PORTRAIT
215
+       .font(font_small)
216
+    #else
217
+       .font(font_medium)
218
+    #endif
219
+    .button(BTN_POS(5,_line), BTN_SIZE(9,1), progmem_str(label));
220
+  }
221
+
222
+  _line++;
223
+}
224
+
225
+void BaseNumericAdjustmentScreen::widgets_t::text_field(uint8_t tag, const char *label, const char *value, bool is_enabled) {
226
+  CommandProcessor cmd;
227
+
228
+  if (_what & BACKGROUND) {
229
+    cmd.enabled(1)
230
+       .font(font_small)
231
+       .cmd(COLOR_RGB(bg_text_enabled))
232
+       .fgcolor(_color).tag(0).button( BTN_POS(5,_line), BTN_SIZE(9,1), F(""),               OPT_FLAT)
233
+       .fgcolor(bg_color) .tag(0).button( BTN_POS(1,_line), BTN_SIZE(4,1), (progmem_str) label, OPT_FLAT);
234
+  }
235
+
236
+  if (_what & FOREGROUND) {
237
+    cmd.colors(normal_btn)
238
+       .font(font_medium)
239
+       .tag(tag).font(font_small).text ( BTN_POS(5,_line), BTN_SIZE(9,1), is_enabled ? value : "-");
240
+  }
241
+
242
+  _line++;
243
+}
244
+
245
+void BaseNumericAdjustmentScreen::widgets_t::two_buttons(uint8_t tag1, const char *label1, uint8_t tag2, const char *label2, bool is_enabled) {
246
+  if (_what & FOREGROUND) {
247
+    CommandProcessor cmd;
248
+    cmd.enabled(is_enabled)
249
+    #ifdef TOUCH_UI_PORTRAIT
250
+       .font(font_small)
251
+    #else
252
+       .font(font_medium)
253
+    #endif
254
+    .tag(is_enabled ? tag1: 0).button(BTN_POS(5,_line),   BTN_SIZE(4.5,1), progmem_str(label1))
255
+    .tag(is_enabled ? tag2: 0).button(BTN_POS(9.5,_line), BTN_SIZE(4.5,1), progmem_str(label2));
256
+  }
257
+
258
+  _line++;
259
+}
260
+
261
+void BaseNumericAdjustmentScreen::widgets_t::toggle(uint8_t tag, const char *label, const char *text, bool value, bool is_enabled) {
262
+  if (_what & BACKGROUND) {
263
+    CommandProcessor cmd;
264
+    cmd.fgcolor(bg_color)
265
+       .tag(0)
266
+       .font(font_small)
267
+    #ifdef TOUCH_UI_PORTRAIT
268
+       .button( BTN_POS(1, _line), BTN_SIZE( 8,1), progmem_str(label), OPT_FLAT);
269
+    #else
270
+       .button( BTN_POS(1, _line), BTN_SIZE(10,1), progmem_str(label), OPT_FLAT);
271
+    #endif
272
+  }
273
+
274
+  if (_what & FOREGROUND) {
275
+    CommandProcessor cmd;
276
+    cmd.tag(is_enabled ? tag   : 0)
277
+       .enabled(is_enabled)
278
+       .font(font_small)
279
+       .colors(ui_toggle)
280
+    #ifdef TOUCH_UI_PORTRAIT
281
+      .toggle(BTN_POS( 9,_line), BTN_SIZE(5,1), progmem_str(text), value);
282
+    #else
283
+      .toggle(BTN_POS(10,_line), BTN_SIZE(4,1), progmem_str(text), value);
284
+    #endif
285
+  }
286
+
287
+  _line++;
288
+}
289
+
290
+void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
291
+  if (_what & BACKGROUND) {
292
+    CommandProcessor cmd;
293
+    cmd.fgcolor(bg_color)
294
+       .tag(0)
295
+       .font(font_small)
296
+       .button( BTN_POS(1, _line),  BTN_SIZE(4,1), F("Home:"), OPT_FLAT);
297
+  }
298
+
299
+  if (_what & FOREGROUND) {
300
+    CommandProcessor cmd;
301
+    cmd
302
+    #ifdef TOUCH_UI_PORTRAIT
303
+       .font(font_small)
304
+    #else
305
+       .font(font_medium)
306
+    #endif
307
+       .tag(tag+0).button(BTN_POS(5,_line),  BTN_SIZE(2,1), F("X"))
308
+       .tag(tag+1).button(BTN_POS(7,_line),  BTN_SIZE(2,1), F("Y"))
309
+       .tag(tag+2).button(BTN_POS(9,_line),  BTN_SIZE(2,1), F("Z"))
310
+       .tag(tag+3).button(BTN_POS(11,_line), BTN_SIZE(3,1), F("All"));
311
+  }
312
+
313
+  _line++;
314
+}
315
+
316
+void BaseNumericAdjustmentScreen::onEntry() {
317
+  screen_data.BaseNumericAdjustmentScreen.increment = 0; // This will force the increment to be picked while drawing.
318
+  BaseScreen::onEntry();
319
+}
320
+
321
+bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) {
322
+  switch (tag) {
323
+    case 1:           GOTO_PREVIOUS();                            return true;
324
+    case 240 ... 245: screen_data.BaseNumericAdjustmentScreen.increment = tag; break;
325
+    default:          return current_screen.onTouchHeld(tag);
326
+  }
327
+  return true;
328
+}
329
+
330
+float BaseNumericAdjustmentScreen::getIncrement() {
331
+  switch (screen_data.BaseNumericAdjustmentScreen.increment) {
332
+    case 240: return   0.001;
333
+    case 241: return   0.01;
334
+    case 242: return   0.1;
335
+    case 243: return   1.0;
336
+    case 244: return  10.0;
337
+    case 245: return 100.0;
338
+    default:  return   0.0;
339
+  }
340
+}
341
+
342
+#endif // LULZBOT_TOUCH_UI

+ 83
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp View File

@@ -0,0 +1,83 @@
1
+/*******************
2
+ * base_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+void BaseScreen::onEntry() {
33
+  CommandProcessor cmd;
34
+  cmd.set_button_style_callback(buttonStyleCallback);
35
+  UIScreen::onEntry();
36
+}
37
+
38
+bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t &style, uint16_t &options, bool post) {
39
+  if (post) {
40
+    cmd.colors(normal_btn);
41
+    return false;
42
+  }
43
+
44
+  #ifdef LCD_TIMEOUT_TO_STATUS
45
+    if (EventLoop::get_pressed_tag() != 0) {
46
+      reset_menu_timeout();
47
+    }
48
+  #endif
49
+
50
+  if (tag != 0 && EventLoop::get_pressed_tag() == tag) {
51
+    options = OPT_FLAT;
52
+  }
53
+
54
+  if (style & cmd.STYLE_DISABLED) {
55
+    cmd.tag(0);
56
+    style &= ~cmd.STYLE_DISABLED;
57
+    cmd.colors(disabled_btn);
58
+    return true; // Call me again to reset the colors
59
+  }
60
+  return false;
61
+}
62
+
63
+void BaseScreen::onIdle() {
64
+  #ifdef LCD_TIMEOUT_TO_STATUS
65
+    const uint32_t elapsed = millis() - last_interaction;
66
+    if (elapsed > uint32_t(LCD_TIMEOUT_TO_STATUS) * 1000) {
67
+      reset_menu_timeout();
68
+      GOTO_SCREEN(StatusScreen);
69
+    }
70
+  #endif
71
+}
72
+
73
+void BaseScreen::reset_menu_timeout() {
74
+  #ifdef LCD_TIMEOUT_TO_STATUS
75
+    last_interaction = millis();
76
+  #endif
77
+}
78
+
79
+#ifdef LCD_TIMEOUT_TO_STATUS
80
+  uint32_t BaseScreen::last_interaction;
81
+#endif
82
+
83
+#endif // LULZBOT_TOUCH_UI

+ 137
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_advanced_settings.cpp View File

@@ -0,0 +1,137 @@
1
+/*****************************
2
+ * bio_advanced_settings.cpp *
3
+ *****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
33
+  if (what & BACKGROUND) {
34
+    CommandProcessor cmd;
35
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
36
+       .cmd(CLEAR(true,true,true));
37
+  }
38
+
39
+  if (what & FOREGROUND) {
40
+    CommandProcessor cmd;
41
+    cmd.colors(normal_btn)
42
+       .font(Theme::font_medium)
43
+    #define GRID_ROWS 9
44
+    #define GRID_COLS 2
45
+
46
+      .tag(2) .button( BTN_POS(1,1), BTN_SIZE(1,1), F("Display"))
47
+      #if HAS_TRINAMIC
48
+       .enabled(1)
49
+      #else
50
+       .enabled(0)
51
+      #endif
52
+      .tag(3) .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Motor mA"))
53
+      #if HAS_TRINAMIC
54
+       .enabled(1)
55
+      #else
56
+       .enabled(0)
57
+      #endif
58
+      .tag(4) .button( BTN_POS(1,3), BTN_SIZE(1,1), F("Bump Sense"))
59
+      .tag(5) .button( BTN_POS(1,4), BTN_SIZE(1,1), F("Endstops"))
60
+      #if HOTENDS > 1
61
+      .enabled(1)
62
+      #else
63
+      .enabled(0)
64
+      #endif
65
+      .tag(6) .button( BTN_POS(1,5), BTN_SIZE(1,1), F("Nozzle Offset"))
66
+
67
+
68
+      .tag(7) .button( BTN_POS(2,1), BTN_SIZE(1,1), F("Steps/mm"))
69
+      .tag(8) .button( BTN_POS(2,2), BTN_SIZE(1,1), F("Velocity "))
70
+      .tag(9) .button( BTN_POS(2,3), BTN_SIZE(1,1), F("Acceleration"))
71
+      #if ENABLED(JUNCTION_DEVIATION)
72
+        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), F("Junc Dev"))
73
+      #else
74
+        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), F("Jerk"))
75
+      #endif
76
+      #if ENABLED(BACKLASH_GCODE)
77
+      .enabled(1)
78
+      #else
79
+      .enabled(0)
80
+      #endif
81
+      .tag(11) .button( BTN_POS(2,5), BTN_SIZE(1,1), F("Backlash"))
82
+      #if ENABLED(LIN_ADVANCE)
83
+      .enabled(1)
84
+      #else
85
+      .enabled(0)
86
+      #endif
87
+      .tag(12) .button( BTN_POS(1,6), BTN_SIZE(2,1), F("Linear Advance"))
88
+      .tag(13) .button( BTN_POS(1,7), BTN_SIZE(2,1), F("Interface Settings"))
89
+      .tag(14) .button( BTN_POS(1,8), BTN_SIZE(2,1), F("Restore Factory Defaults"))
90
+      .colors(action_btn)
91
+      .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), F("Back"));
92
+    #undef GRID_COLS
93
+    #undef GRID_ROWS
94
+  }
95
+}
96
+
97
+bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
98
+  using namespace ExtUI;
99
+
100
+  switch (tag) {
101
+    case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
102
+    case 2: GOTO_SCREEN(DisplayTuningScreen);              break;
103
+    #if HAS_TRINAMIC
104
+    case 3: GOTO_SCREEN(StepperCurrentScreen);             break;
105
+    case 4: GOTO_SCREEN(StepperBumpSensitivityScreen);     break;
106
+    #endif
107
+    case 5: GOTO_SCREEN(EndstopStatesScreen);              break;
108
+    #if HOTENDS > 1
109
+    case 6: GOTO_SCREEN(NozzleOffsetScreen);               break;
110
+    #endif
111
+
112
+    case 7: GOTO_SCREEN(StepsScreen);                      break;
113
+    case 8: GOTO_SCREEN(MaxVelocityScreen);                break;
114
+    case 9: GOTO_SCREEN(DefaultAccelerationScreen);        break;
115
+    case 10:
116
+      #if ENABLED(JUNCTION_DEVIATION)
117
+        GOTO_SCREEN(JunctionDeviationScreen);
118
+      #else
119
+        GOTO_SCREEN(JerkScreen);
120
+      #endif
121
+      break;
122
+    #if ENABLED(BACKLASH_GCODE)
123
+    case 11: GOTO_SCREEN(BacklashCompensationScreen);      break;
124
+    #endif
125
+    #if ENABLED(LIN_ADVANCE)
126
+    case 12: GOTO_SCREEN(LinearAdvanceScreen);             break;
127
+    #endif
128
+    case 13: GOTO_SCREEN(InterfaceSettingsScreen);         break;
129
+    case 14: GOTO_SCREEN(RestoreFailsafeDialogBox);        break;
130
+
131
+    default:
132
+      return false;
133
+  }
134
+  return true;
135
+}
136
+
137
+#endif // LULZBOT_TOUCH_UI

+ 56
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_confirm_home_e.cpp View File

@@ -0,0 +1,56 @@
1
+/****************************
2
+ * bio_confirm_home_xyz.cpp *
3
+ ****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+
31
+void BioConfirmHomeE::onRedraw(draw_mode_t) {
32
+  drawMessage(F("About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?"));
33
+  drawYesNoButtons(1);
34
+}
35
+
36
+bool BioConfirmHomeE::onTouchEnd(uint8_t tag) {
37
+  switch (tag) {
38
+    case 1:
39
+      SpinnerDialogBox::enqueueAndWait_P(F(
40
+        "G112\n"                            /* Home extruder */
41
+        LULZBOT_AXIS_LEVELING_COMMANDS      /* Level X axis */
42
+        "G0 X115 Z50 F6000\n"               /* Goto loading position */
43
+        "M400\n"                            /* Wait for moves to finish */
44
+        "M18 X Y"                           /* Unlock motors */
45
+      ));
46
+      current_screen.forget();
47
+      break;
48
+    case 2:
49
+      GOTO_SCREEN(StatusScreen);
50
+      break;
51
+    default:
52
+      return DialogBoxBaseClass::onTouchEnd(tag);
53
+  }
54
+  return true;
55
+}
56
+#endif // LULZBOT_TOUCH_UI

+ 53
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_confirm_home_xyz.cpp View File

@@ -0,0 +1,53 @@
1
+/****************************
2
+ * bio_confirm_home_xyz.cpp *
3
+ ****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+
31
+void BioConfirmHomeXYZ::onRedraw(draw_mode_t) {
32
+  drawMessage(F("About to home to loading position.\nEnsure the top and the bed of the printer are clear.\n\nContinue?"));
33
+  drawYesNoButtons(1);
34
+}
35
+
36
+bool BioConfirmHomeXYZ::onTouchEnd(uint8_t tag) {
37
+  switch (tag) {
38
+    case 1:
39
+      SpinnerDialogBox::enqueueAndWait_P(F(
40
+        "G28 X Y Z\n"             /* Home all axis */
41
+        "G0 X115 Z50 F6000"       /* Move to park position */
42
+      ));
43
+      current_screen.forget();
44
+      break;
45
+    case 2:
46
+      GOTO_SCREEN(StatusScreen);
47
+      break;
48
+    default:
49
+      return DialogBoxBaseClass::onTouchEnd(tag);
50
+  }
51
+  return true;
52
+}
53
+#endif // LULZBOT_TOUCH_UI

+ 79
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_main_menu.cpp View File

@@ -0,0 +1,79 @@
1
+/*********************
2
+ * bio_main_menu.cpp *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+void MainMenu::onRedraw(draw_mode_t what) {
33
+  #define GRID_ROWS 8
34
+  #define GRID_COLS 2
35
+
36
+  if (what & BACKGROUND) {
37
+    CommandProcessor cmd;
38
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
39
+       .cmd(CLEAR(true,true,true));
40
+  }
41
+
42
+  if (what & FOREGROUND) {
43
+    CommandProcessor cmd;
44
+    cmd.cmd(COLOR_RGB(bg_text_enabled))
45
+       .font(font_large).text( BTN_POS(1,1), BTN_SIZE(2,1), F("Main Menu"))
46
+       .colors(normal_btn)
47
+       .font(font_medium)
48
+       .tag(2).button( BTN_POS(1,2), BTN_SIZE(2,1), F("Load Syringe"))
49
+       .tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), F("Unlock XY Axis"))
50
+       .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), F("Bed Temperature"))
51
+       .tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), F("Interface Settings"))
52
+       .tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), F("Advanced Settings"))
53
+       .tag(7).button( BTN_POS(1,7), BTN_SIZE(2,1), F("About Printer"))
54
+       .colors(action_btn)
55
+       .tag(1).button( BTN_POS(1,8), BTN_SIZE(2,1), F("Back"));
56
+  }
57
+
58
+  #undef GRID_COLS
59
+  #undef GRID_ROWS
60
+}
61
+
62
+bool MainMenu::onTouchEnd(uint8_t tag) {
63
+  using namespace ExtUI;
64
+
65
+  switch (tag) {
66
+    case 1: SaveSettingsDialogBox::promptToSaveSettings();                               break;
67
+    case 2: GOTO_SCREEN(BioConfirmHomeXYZ);                                              break;
68
+    case 3: StatusScreen::unlockMotors();                                                break;
69
+    case 4:  GOTO_SCREEN(TemperatureScreen);                                             break;
70
+    case 5: GOTO_SCREEN(InterfaceSettingsScreen);                                        break;
71
+    case 6: GOTO_SCREEN(AdvancedSettingsMenu);                                           break;
72
+    case 7: GOTO_SCREEN(AboutScreen);                                                    break;
73
+    default:
74
+      return false;
75
+  }
76
+  return true;
77
+}
78
+
79
+#endif // LULZBOT_TOUCH_UI

+ 75
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_printer_ui.h View File

@@ -0,0 +1,75 @@
1
+
2
+/****************************************************************************
3
+ *   This program is free software: you can redistribute it and/or modify   *
4
+ *   it under the terms of the GNU General Public License as published by   *
5
+ *   the Free Software Foundation, either version 3 of the License, or      *
6
+ *   (at your option) any later version.                                    *
7
+ *                                                                          *
8
+ *   This program is distributed in the hope that it will be useful,        *
9
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
10
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
11
+ *   GNU General Public License for more details.                           *
12
+ *                                                                          *
13
+ *   To view a copy of the GNU General Public License, go to the following  *
14
+ *   location: <http://www.gnu.org/licenses/>.                              *
15
+ ****************************************************************************/
16
+
17
+/**
18
+ * This file was auto-generated using "svg2cpp.pl"
19
+ *
20
+ * The encoding consists of x,y pairs with the min and max scaled to
21
+ * 0x0000 and 0xFFFE. A single 0xFFFF in the data stream indicates the
22
+ * start of a new closed path.
23
+ */
24
+
25
+#pragma once
26
+
27
+constexpr float x_min = 0.000000;
28
+
29
+constexpr float x_max = 272.000000;
30
+
31
+constexpr float y_min = 0.000000;
32
+
33
+constexpr float y_max = 480.000000;
34
+
35
+const PROGMEM uint16_t z_neg[] = {0xC9B1, 0x96B3, 0xD990, 0x96B3, 0xD990, 0xA8D0, 0xE17F, 0xA8D0, 0xD1A0, 0xB1DF, 0xC1C2, 0xA8D0, 0xC9B1, 0xA8D0, 0xC9B1, 0x96B3};
36
+
37
+const PROGMEM uint16_t z_pos[] = {0xC9B1, 0x8DA4, 0xD990, 0x8DA4, 0xD990, 0x7B86, 0xE17F, 0x7B86, 0xD1A0, 0x7277, 0xC1C2, 0x7B86, 0xC9B1, 0x7B86, 0xC9B1, 0x8DA4};
38
+
39
+const PROGMEM uint16_t y_neg[] = {0x5037, 0x9979, 0x6264, 0x9979, 0x5529, 0xA92A, 0x5E3F, 0xA92A, 0x4575, 0xB103, 0x39E6, 0xA92A, 0x42FC, 0xA92A, 0x5037, 0x9979};
40
+
41
+const PROGMEM uint16_t y_pos[] = {0x5D72, 0x89C7, 0x6F9F, 0x89C7, 0x7CDA, 0x7A15, 0x85F0, 0x7A15, 0x7A61, 0x723D, 0x6197, 0x7A15, 0x6AAD, 0x7A15, 0x5D72, 0x89C7};
42
+
43
+const PROGMEM uint16_t x_neg[] = {0x513D, 0x8DB3, 0x4AA0, 0x958C, 0x2647, 0x958C, 0x22F8, 0x9979, 0x1769, 0x91A0, 0x3033, 0x89C7, 0x2CE4, 0x8DB3, 0x513D, 0x8DB3};
44
+
45
+const PROGMEM uint16_t x_pos[] = {0x7566, 0x8DB3, 0x6EC9, 0x958C, 0x9322, 0x958C, 0x8FD4, 0x9979, 0xA89E, 0x91A0, 0x9D0E, 0x89C7, 0x99C0, 0x8DB3, 0x7566, 0x8DB3};
46
+
47
+const PROGMEM uint16_t syringe_fluid[] = {0x7D1D, 0x4A0F, 0x87FC, 0x4C0E, 0x8CF4, 0x4C0E, 0x9801, 0x4A0F, 0x9801, 0x1AA2, 0x7D1D, 0x1AA2, 0x7D1D, 0x4A0F};
48
+
49
+const PROGMEM uint16_t syringe[] = {0x83C2, 0x42AA, 0x83C2, 0x43FF, 0x8D2C, 0x43FF, 0x8D2C, 0x42AA, 0xFFFF, 0x83C2, 0x3D54, 0x83C2, 0x3EAA, 0x8D2C, 0x3EAA, 0x8D2C, 0x3D54, 0xFFFF, 0x83C2, 0x37FF, 0x83C2, 0x3954, 0x8D2C, 0x3954, 0x8D2C, 0x37FF, 0xFFFF, 0x83C2, 0x32AA, 0x83C2, 0x33FF, 0x8D2C, 0x33FF, 0x8D2C, 0x32AA, 0xFFFF, 0x83C2, 0x2D54, 0x83C2, 0x2EAA, 0x8D2C, 0x2EAA, 0x8D2C, 0x2D54, 0xFFFF, 0x83C2, 0x27FF, 0x83C2, 0x2955, 0x8D2C, 0x2955, 0x8D2C, 0x27FF, 0xFFFF, 0x83C2, 0x22AA, 0x83C2, 0x23FF, 0x8D2C, 0x23FF, 0x8D2C, 0x22AA, 0xFFFF, 0x7AC7, 0x0F4B, 0x7AC7, 0x134A, 0x855B, 0x134A, 0x855B, 0x1949, 0x7AC7, 0x1949, 0x7AC7, 0x4B40, 0x855B, 0x4D40, 0x855B, 0x533F, 0x88E2, 0x533F, 0x88E2, 0x653C, 0x8C69, 0x673C, 0x8C69, 0x533F, 0x8FF0, 0x533F, 0x8FF0, 0x4D40, 0x9A85, 0x4B40, 0x9A85, 0x1949, 0x8FF0, 0x1949, 0x8FF0, 0x134A, 0x9A85, 0x134A, 0x9A85, 0x0F4B, 0xFFFF, 0x88E2, 0x134A, 0x8C69, 0x134A, 0x8C69, 0x1949, 0x88E2, 0x1949, 0x88E2, 0x134A, 0xFFFF, 0x7E4D, 0x1B49, 0x96FE, 0x1B49, 0x96FE, 0x4941, 0x8C69, 0x4B40, 0x88E2, 0x4B40, 0x7E4D, 0x4941, 0x7E4D, 0x1B49};
50
+
51
+const PROGMEM uint16_t syringe_outline[] = {0x7AC7, 0x0F4B, 0x7AC7, 0x134A, 0x855B, 0x134A, 0x855B, 0x1949, 0x7AC7, 0x1949, 0x7AC7, 0x4B40, 0x855B, 0x4D40, 0x855B, 0x533F, 0x88E2, 0x533F, 0x88E2, 0x653C, 0x8C69, 0x673C, 0x8C69, 0x533F, 0x8FF0, 0x533F, 0x8FF0, 0x4D40, 0x9A85, 0x4B40, 0x9A85, 0x1949, 0x8FF0, 0x1949, 0x8FF0, 0x134A, 0x9A85, 0x134A, 0x9A85, 0x0F4B, 0x7AC7, 0x0F4B};
52
+
53
+const PROGMEM uint16_t padlock[] = {0x645A, 0x8017, 0x5F9E, 0x80A1, 0x5BBA, 0x821B, 0x5911, 0x844A, 0x580A, 0x86F7, 0x580A, 0x8931, 0x5970, 0x8A98, 0x5C49, 0x8A98, 0x5DB0, 0x8931, 0x5DB0, 0x8703, 0x5E3C, 0x858E, 0x5FAA, 0x845F, 0x61C5, 0x8394, 0x645A, 0x834A, 0x66F0, 0x8394, 0x690C, 0x845F, 0x6A7A, 0x858D, 0x6B07, 0x8703, 0x6B07, 0x8F23, 0x57C8, 0x8F23, 0x551E, 0x8FC3, 0x5404, 0x9145, 0x5404, 0x9C8F, 0x551E, 0x9E11, 0x57C8, 0x9EB1, 0x70EE, 0x9EB1, 0x7398, 0x9E11, 0x74B2, 0x9C8F, 0x74B2, 0x9145, 0x7398, 0x8FC3, 0x70EE, 0x8F23, 0x70AC, 0x86FA, 0x6FA5, 0x844A, 0x6CFD, 0x821B, 0x6917, 0x80A1};
54
+
55
+const PROGMEM uint16_t home_z[] = {0xD6C9, 0x80CC, 0xBB53, 0x905B, 0xC231, 0x905B, 0xC231, 0x9FEB, 0xCFEC, 0x9FEB, 0xCFEC, 0x9823, 0xDDA7, 0x9823, 0xDDA7, 0x9FEB, 0xEB62, 0x9FEB, 0xEB62, 0x905B, 0xF240, 0x905B, 0xE7A3, 0x8A58, 0xE7A3, 0x82CD, 0xE0C6, 0x82CD, 0xE0C6, 0x8674};
56
+
57
+const PROGMEM uint16_t home_e[] = {0xB94F, 0x25AA, 0x9DD8, 0x353A, 0xA4B6, 0x353A, 0xA4B6, 0x44C9, 0xB271, 0x44C9, 0xB271, 0x3D02, 0xC02C, 0x3D02, 0xC02C, 0x44C9, 0xCDE7, 0x44C9, 0xCDE7, 0x353A, 0xD4C5, 0x353A, 0xCA28, 0x2F36, 0xCA28, 0x27AB, 0xC34B, 0x27AB, 0xC34B, 0x2B53};
58
+
59
+const PROGMEM uint16_t bed_icon[] = {0x1764, 0x2C4C, 0x6135, 0x2C4C, 0x6135, 0x40A8, 0x1764, 0x40A8};
60
+
61
+const PROGMEM uint16_t actual_temp[] = {0x1764, 0x466F, 0x6135, 0x466F, 0x6135, 0x5ACB, 0x1764, 0x5ACB};
62
+
63
+const PROGMEM uint16_t target_temp[] = {0x1764, 0x1228, 0x6135, 0x1228, 0x6135, 0x2684, 0x1764, 0x2684};
64
+
65
+const PROGMEM uint16_t fine_label[] = {0x1AA7, 0xC6D2, 0x9387, 0xC6D2, 0x9387, 0xD316, 0x1AA7, 0xD316};
66
+
67
+const PROGMEM uint16_t fine_toggle[] = {0x9C10, 0xC6D2, 0xE4A3, 0xC6D2, 0xE4A3, 0xD316, 0x9C10, 0xD316};
68
+
69
+const PROGMEM uint16_t usb_btn[] = {0x0B68, 0xE880, 0x7B1A, 0xE880, 0x7B1A, 0xF94B, 0x0B68, 0xF94B, 0x0B68, 0xE880};
70
+
71
+const PROGMEM uint16_t menu_btn[] = {0x84E3, 0xE880, 0xF495, 0xE880, 0xF495, 0xF94B, 0x84E3, 0xF94B, 0x84E3, 0xE880};
72
+
73
+const PROGMEM uint16_t e_pos[] = {0xC9B1, 0x3B2D, 0xD990, 0x3B2D, 0xD990, 0x4D4B, 0xE17F, 0x4D4B, 0xD1A0, 0x565A, 0xC1C2, 0x4D4B, 0xC9B1, 0x4D4B, 0xC9B1, 0x3B2D};
74
+
75
+const PROGMEM uint16_t e_neg[] = {0xC9B1, 0x321E, 0xD990, 0x321E, 0xD990, 0x2000, 0xE17F, 0x2000, 0xD1A0, 0x16F1, 0xC1C2, 0x2000, 0xC9B1, 0x2000, 0xC9B1, 0x321E};

+ 155
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_printing_dialog_box.cpp View File

@@ -0,0 +1,155 @@
1
+/*******************************
2
+ * bio_printing_dialog_box.cpp *
3
+ *******************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+#include "../ftdi_eve_lib/extras/circular_progress.h"
30
+
31
+using namespace FTDI;
32
+using namespace ExtUI;
33
+using namespace Theme;
34
+
35
+#define GRID_COLS 2
36
+#define GRID_ROWS 9
37
+
38
+void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char* message) {
39
+  if (what & BACKGROUND) {
40
+    CommandProcessor cmd;
41
+    cmd.cmd(COLOR_RGB(bg_text_enabled));
42
+    draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(2,2), message, OPT_CENTER, font_large);
43
+  }
44
+}
45
+
46
+void BioPrintingDialogBox::draw_progress(draw_mode_t what) {
47
+  if (what & FOREGROUND) {
48
+    CommandProcessor cmd;
49
+    cmd.font(font_large)
50
+       .text(BTN_POS(1,1), BTN_SIZE(2,2), isPrinting() ? F("Printing...") : F("Finished."))
51
+       .tag(1)
52
+       .font(font_xlarge);
53
+
54
+    draw_circular_progress(cmd, BTN_POS(1,4), BTN_SIZE(2,3), getProgress_percent(), theme_dark, theme_darkest);
55
+  }
56
+}
57
+
58
+void BioPrintingDialogBox::draw_time_remaining(draw_mode_t what) {
59
+  if (what & FOREGROUND) {
60
+    const uint32_t elapsed = getProgress_seconds_elapsed();
61
+    const uint8_t hrs = elapsed/3600;
62
+    const uint8_t min = (elapsed/60)%60;
63
+
64
+    char time_str[10];
65
+    sprintf_P(time_str, PSTR("%02dh %02dm"), hrs, min);
66
+
67
+    CommandProcessor cmd;
68
+    cmd.font(font_large)
69
+       .text(BTN_POS(1,7), BTN_SIZE(2,2), time_str);
70
+  }
71
+}
72
+
73
+void BioPrintingDialogBox::draw_interaction_buttons(draw_mode_t what) {
74
+  if (what & FOREGROUND) {
75
+    CommandProcessor cmd;
76
+    cmd.colors(normal_btn)
77
+       .font(font_medium)
78
+       .colors(isPrinting() ? action_btn : normal_btn)
79
+       .tag(2).button(BTN_POS(1,9), BTN_SIZE(1,1), F("Menu"))
80
+        #if ENABLED(SDSUPPORT)
81
+          .enabled(isPrinting() ? isPrintingFromMedia() : 1)
82
+        #else
83
+          .enabled(isPrinting() ? 0 : 1)
84
+        #endif
85
+       .tag(3)
86
+       .colors(isPrinting() ? normal_btn : action_btn)
87
+       .button( BTN_POS(2,9), BTN_SIZE(1,1), isPrinting() ? F("Cancel") : F("Back"));
88
+  }
89
+}
90
+
91
+void BioPrintingDialogBox::onRedraw(draw_mode_t what) {
92
+  if (what & FOREGROUND) {
93
+    draw_progress(FOREGROUND);
94
+    draw_time_remaining(FOREGROUND);
95
+    draw_interaction_buttons(FOREGROUND);
96
+  }
97
+}
98
+
99
+bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) {
100
+  switch (tag) {
101
+    case 1: GOTO_SCREEN(FeedratePercentScreen); break;
102
+    case 2: GOTO_SCREEN(TuneMenu); break;
103
+    case 3:
104
+     if (isPrinting()) {
105
+       GOTO_SCREEN(ConfirmAbortPrintDialogBox);
106
+     } else {
107
+       GOTO_SCREEN(StatusScreen);
108
+     }
109
+     break;
110
+    default: return false;
111
+  }
112
+  return true;
113
+}
114
+
115
+void BioPrintingDialogBox::setStatusMessage(progmem_str message) {
116
+  char buff[strlen_P((const char * const)message)+1];
117
+  strcpy_P(buff, (const char * const) message);
118
+  setStatusMessage(buff);
119
+}
120
+
121
+void BioPrintingDialogBox::setStatusMessage(const char* message) {
122
+  CommandProcessor cmd;
123
+  cmd.cmd(CMD_DLSTART)
124
+     .cmd(CLEAR_COLOR_RGB(bg_color))
125
+     .cmd(CLEAR(true,true,true));
126
+
127
+  draw_status_message(BACKGROUND, message);
128
+  draw_progress(BACKGROUND);
129
+  draw_time_remaining(BACKGROUND);
130
+  draw_interaction_buttons(BACKGROUND);
131
+  storeBackground();
132
+
133
+  #ifdef UI_FRAMEWORK_DEBUG
134
+    SERIAL_ECHO_START();
135
+    SERIAL_ECHOLNPAIR("New status message: ", message);
136
+  #endif
137
+
138
+  if (AT_SCREEN(BioPrintingDialogBox)) {
139
+    current_screen.onRefresh();
140
+  }
141
+}
142
+
143
+void BioPrintingDialogBox::onIdle() {
144
+  if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
145
+    onRefresh();
146
+    refresh_timer.start();
147
+  }
148
+  BaseScreen::onIdle();
149
+}
150
+
151
+void BioPrintingDialogBox::show() {
152
+  GOTO_SCREEN(BioPrintingDialogBox);
153
+}
154
+
155
+#endif // LULZBOT_TOUCH_UI

+ 349
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp View File

@@ -0,0 +1,349 @@
1
+/*************************
2
+ * bio_status_screen.cpp *
3
+ *************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+#include "../ftdi_eve_lib/extras/poly_ui.h"
30
+#include "bio_printer_ui.h"
31
+
32
+#define E_TRAVEL_LIMIT 60
33
+
34
+#define GRID_COLS 2
35
+#define GRID_ROWS 9
36
+
37
+#define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
38
+
39
+#if ENABLED(SDSUPPORT) && defined(LULZBOT_MANUAL_USB_STARTUP)
40
+  #include "../../../../sd/cardreader.h"
41
+#endif
42
+
43
+const uint8_t shadow_depth = 5;
44
+
45
+using namespace FTDI;
46
+using namespace Theme;
47
+using namespace ExtUI;
48
+
49
+float StatusScreen::increment;
50
+bool  StatusScreen::jog_xy;
51
+bool  StatusScreen::fine_motion;
52
+
53
+void StatusScreen::unlockMotors() {
54
+  injectCommands_P(PSTR("M84 XY"));
55
+  jog_xy = false;
56
+}
57
+
58
+void StatusScreen::draw_temperature(draw_mode_t what) {
59
+  CommandProcessor cmd;
60
+  PolyUI ui(cmd, what);
61
+
62
+  int16_t x, y, h, v;
63
+
64
+  cmd.tag(15);
65
+
66
+  if (what & BACKGROUND) {
67
+    cmd.cmd(COLOR_RGB(bg_color));
68
+
69
+    // Draw touch surfaces
70
+    ui.bounds(POLY(target_temp), x, y, h, v);
71
+    cmd.rectangle(x, y, h, v);
72
+    ui.bounds(POLY(actual_temp), x, y, h, v);
73
+    cmd.rectangle(x, y, h, v);
74
+    ui.bounds(POLY(bed_icon), x, y, h, v);
75
+    cmd.rectangle(x, y, h, v);
76
+
77
+    // Draw bed icon
78
+    cmd.cmd(BITMAP_SOURCE(Bed_Heat_Icon_Info))
79
+       .cmd(BITMAP_LAYOUT(Bed_Heat_Icon_Info))
80
+       .cmd(BITMAP_SIZE  (Bed_Heat_Icon_Info))
81
+       .cmd(COLOR_RGB(shadow_rgb))
82
+       .icon (x + 2, y + 2, h, v, Bed_Heat_Icon_Info, icon_scale * 2)
83
+       .cmd(COLOR_RGB(bg_text_enabled))
84
+       .icon (x, y, h, v, Bed_Heat_Icon_Info, icon_scale * 2);
85
+  }
86
+
87
+  if (what & FOREGROUND) {
88
+    char bed_str[15];
89
+
90
+    cmd.font(font_xlarge)
91
+       .cmd(COLOR_RGB(bg_text_enabled));
92
+
93
+    if (!isHeaterIdle(BED) && getTargetTemp_celsius(BED) > 0) {
94
+      sprintf_P(bed_str, PSTR("%-3d C"), ROUND(getTargetTemp_celsius(BED)));
95
+      ui.bounds(POLY(target_temp), x, y, h, v);
96
+      cmd.text(x, y, h, v, bed_str);
97
+    }
98
+
99
+    sprintf_P(bed_str, PSTR("%-3d C"), ROUND(getActualTemp_celsius(BED)));
100
+    ui.bounds(POLY(actual_temp), x, y, h, v);
101
+    cmd.text(x, y, h, v, bed_str);
102
+  }
103
+}
104
+
105
+void StatusScreen::draw_syringe(draw_mode_t what) {
106
+  int16_t x, y, h, v;
107
+  const float fill_level = 1.0 - min(1.0, max(0.0, getAxisPosition_mm(E0) / E_TRAVEL_LIMIT));
108
+  const bool  e_homed = isAxisPositionKnown(E0);
109
+
110
+  CommandProcessor cmd;
111
+  PolyUI ui(cmd, what);
112
+
113
+  if (what & BACKGROUND) {
114
+    // Paint the shadow for the syringe
115
+    ui.color(shadow_rgb);
116
+    ui.shadow(POLY(syringe_outline), shadow_depth);
117
+  }
118
+
119
+  if (what & FOREGROUND && e_homed) {
120
+    // Paint the syringe icon
121
+    ui.color(syringe_rgb);
122
+    ui.fill(POLY(syringe_outline));
123
+
124
+    ui.color(fill_rgb);
125
+    ui.bounds(POLY(syringe_fluid), x, y, h, v);
126
+    cmd.cmd(SAVE_CONTEXT());
127
+    cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level)));
128
+    cmd.cmd(SCISSOR_SIZE(h,  v *        fill_level));
129
+    ui.fill(POLY(syringe_fluid), false);
130
+    cmd.cmd(RESTORE_CONTEXT());
131
+
132
+    ui.color(stroke_rgb);
133
+    ui.fill(POLY(syringe));
134
+  }
135
+}
136
+
137
+void StatusScreen::draw_arrows(draw_mode_t what) {
138
+  const bool  e_homed = isAxisPositionKnown(E0);
139
+  const bool  z_homed = isAxisPositionKnown(Z);
140
+
141
+  CommandProcessor cmd;
142
+  PolyUI ui(cmd, what);
143
+
144
+  ui.button_fill  (fill_rgb);
145
+  ui.button_stroke(stroke_rgb, 28);
146
+  ui.button_shadow(shadow_rgb, shadow_depth);
147
+
148
+  if ((what & BACKGROUND) || jog_xy) {
149
+    ui.button(1, POLY(x_neg));
150
+    ui.button(2, POLY(x_pos));
151
+    ui.button(3, POLY(y_neg));
152
+    ui.button(4, POLY(y_pos));
153
+  }
154
+
155
+  if ((what & BACKGROUND) || z_homed) {
156
+    ui.button(5, POLY(z_neg));
157
+    ui.button(6, POLY(z_pos));
158
+  }
159
+
160
+  if ((what & BACKGROUND) || e_homed) {
161
+    ui.button(7, POLY(e_neg));
162
+    ui.button(8, POLY(e_pos));
163
+  }
164
+}
165
+
166
+void StatusScreen::draw_fine_motion(draw_mode_t what) {
167
+  int16_t x, y, h, v;
168
+  CommandProcessor cmd;
169
+  PolyUI ui(cmd, what);
170
+
171
+  cmd.font(font_medium)
172
+     .tag(16);
173
+
174
+  if (what & BACKGROUND) {
175
+
176
+    ui.bounds(POLY(fine_label), x, y, h, v);
177
+    cmd.cmd(COLOR_RGB(bg_text_enabled))
178
+       .text(x, y, h, v, F("Fine motion:"));
179
+  }
180
+
181
+  if (what & FOREGROUND) {
182
+    ui.bounds(POLY(fine_toggle), x, y, h, v);
183
+    cmd.colors(ui_toggle)
184
+       .toggle(x, y, h, v, F("no\xFFyes"), fine_motion);
185
+  }
186
+}
187
+
188
+void StatusScreen::draw_overlay_icons(draw_mode_t what) {
189
+  const bool  e_homed = isAxisPositionKnown(E0);
190
+  const bool  z_homed = isAxisPositionKnown(Z);
191
+
192
+  CommandProcessor cmd;
193
+  PolyUI ui(cmd, what);
194
+
195
+  if (what & FOREGROUND) {
196
+    ui.button_fill  (fill_rgb);
197
+    ui.button_stroke(stroke_rgb, 28);
198
+    ui.button_shadow(shadow_rgb, shadow_depth);
199
+
200
+    if (!jog_xy) {
201
+      ui.button(12, POLY(padlock));
202
+    }
203
+
204
+    if (!e_homed) {
205
+      ui.button(13, POLY(home_e));
206
+    }
207
+
208
+    if (!z_homed) {
209
+      ui.button(14, POLY(home_z));
210
+    }
211
+  }
212
+}
213
+
214
+void StatusScreen::draw_buttons(draw_mode_t) {
215
+  const bool has_media = isMediaInserted() && !isPrintingFromMedia();
216
+
217
+  CommandProcessor cmd;
218
+
219
+  cmd.font(font_medium)
220
+     .colors(normal_btn)
221
+    #if ENABLED(USB_FLASH_DRIVE_SUPPORT) && defined(LULZBOT_MANUAL_USB_STARTUP)
222
+      .enabled(!Sd2Card::ready() || has_media)
223
+    #else
224
+      .enabled(has_media)
225
+    #endif
226
+     .colors(has_media ? action_btn : normal_btn)
227
+     .tag(9).button(BTN_POS(1,9), BTN_SIZE(1,1),
228
+        isPrintingFromMedia() ?
229
+          F("Printing") :
230
+      #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
231
+        #ifdef LULZBOT_MANUAL_USB_STARTUP
232
+        (Sd2Card::ready() ? F("USB Drive") : F("Enable USB"))
233
+        #else
234
+        F("USB Drive")
235
+        #endif
236
+      #else
237
+        F("SD Card")
238
+      #endif
239
+      );
240
+
241
+  cmd.colors(!has_media ? action_btn : normal_btn).tag(10).button(BTN_POS(2,9), BTN_SIZE(1,1), F("Menu"));
242
+}
243
+
244
+void StatusScreen::onStartup() {
245
+  // Load the bitmaps for the status screen
246
+  constexpr uint32_t base = ftdi_memory_map::RAM_G;
247
+  CLCD::mem_write_pgm(base + Bed_Heat_Icon_Info.RAMG_offset, Bed_Heat_Icon, sizeof(Bed_Heat_Icon));
248
+}
249
+
250
+void StatusScreen::onRedraw(draw_mode_t what) {
251
+  if (what & BACKGROUND) {
252
+    CommandProcessor cmd;
253
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color));
254
+    cmd.cmd(CLEAR(true,true,true));
255
+  }
256
+
257
+  draw_syringe(what);
258
+  draw_temperature(what);
259
+  draw_arrows(what);
260
+  draw_overlay_icons(what);
261
+  draw_buttons(what);
262
+  draw_fine_motion(what);
263
+}
264
+
265
+bool StatusScreen::onTouchStart(uint8_t) {
266
+  increment = fine_motion ? 0.25 : 1;
267
+  return true;
268
+}
269
+
270
+bool StatusScreen::onTouchEnd(uint8_t tag) {
271
+  switch (tag) {
272
+    case 1:
273
+    case 2:
274
+    case 3:
275
+    case 4:
276
+    case 12:
277
+      if (!jog_xy) {
278
+        jog_xy = true;
279
+        injectCommands_P(PSTR("M17"));
280
+      }
281
+      break;
282
+    case 9:
283
+      #if ENABLED(USB_FLASH_DRIVE_SUPPORT) && defined(LULZBOT_MANUAL_USB_STARTUP)
284
+      if (!Sd2Card::ready()) {
285
+        StatusScreen::setStatusMessage(F("Insert USB drive..."));
286
+        Sd2Card::usbStartup();
287
+      } else {
288
+        GOTO_SCREEN(FilesScreen);
289
+      }
290
+      #else
291
+        GOTO_SCREEN(FilesScreen);
292
+      #endif
293
+      break;
294
+    case 10: GOTO_SCREEN(MainMenu); break;
295
+    case 13: SpinnerDialogBox::enqueueAndWait_P(F("G112"));  break;
296
+    case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
297
+    case 15: GOTO_SCREEN(TemperatureScreen);  break;
298
+    case 16: fine_motion = !fine_motion; break;
299
+    default: return false;
300
+  }
301
+  // If a passcode is enabled, the LockScreen will prevent the
302
+  // user from proceeding.
303
+  LockScreen::check_passcode();
304
+  return true;
305
+}
306
+
307
+bool StatusScreen::onTouchHeld(uint8_t tag) {
308
+  if (tag >= 1 && tag <= 4 && !jog_xy) return false;
309
+  if (ExtUI::isMoving()) return false; // Don't allow moves to accumulate
310
+  #define UI_INCREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis);
311
+  #define UI_DECREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis);
312
+  switch (tag) {
313
+    case 1: UI_DECREMENT_AXIS(X);  break;
314
+    case 2: UI_INCREMENT_AXIS(X);  break;
315
+    case 4: UI_DECREMENT_AXIS(Y);  break; // NOTE: Y directions inverted because bed rather than needle moves
316
+    case 3: UI_INCREMENT_AXIS(Y);  break;
317
+    case 5: UI_DECREMENT_AXIS(Z);  break;
318
+    case 6: UI_INCREMENT_AXIS(Z);  break;
319
+    case 7: UI_DECREMENT_AXIS(E0); break;
320
+    case 8: UI_INCREMENT_AXIS(E0); break;
321
+    default: return false;
322
+  }
323
+  #undef UI_DECREMENT_AXIS
324
+  #undef UI_INCREMENT_AXIS
325
+  if (increment < 10 && !fine_motion)
326
+    increment += 0.5;
327
+  current_screen.onRefresh();
328
+  return false;
329
+}
330
+
331
+void StatusScreen::setStatusMessage(progmem_str pstr) {
332
+  BioPrintingDialogBox::setStatusMessage(pstr);
333
+}
334
+
335
+void StatusScreen::setStatusMessage(const char * const str) {
336
+  BioPrintingDialogBox::setStatusMessage(str);
337
+}
338
+
339
+void StatusScreen::onIdle() {
340
+  if (isPrintingFromMedia())
341
+    BioPrintingDialogBox::show();
342
+
343
+  if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
344
+    onRefresh();
345
+    refresh_timer.start();
346
+  }
347
+}
348
+
349
+#endif // LULZBOT_TOUCH_UI

+ 87
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_tune_menu.cpp View File

@@ -0,0 +1,87 @@
1
+/*********************
2
+ * bio_tune_menu.cpp *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+using namespace ExtUI;
32
+
33
+void TuneMenu::onRedraw(draw_mode_t what) {
34
+  if (what & BACKGROUND) {
35
+    CommandProcessor cmd;
36
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
37
+       .cmd(CLEAR(true,true,true))
38
+       .font(font_medium);
39
+  }
40
+
41
+  #define GRID_ROWS 8
42
+  #define GRID_COLS 2
43
+
44
+  if (what & FOREGROUND) {
45
+    CommandProcessor cmd;
46
+    cmd.cmd(COLOR_RGB(bg_text_enabled))
47
+       .font(font_large).text  ( BTN_POS(1,1), BTN_SIZE(2,1), F("Print Menu"))
48
+       .colors(normal_btn)
49
+       .font(font_medium)
50
+       .enabled(!isPrinting()).tag(2).button( BTN_POS(1,2), BTN_SIZE(2,1), isPrinting() ? F("Printing...") : F("Print Again"))
51
+       .enabled( isPrinting()).tag(3).button( BTN_POS(1,3), BTN_SIZE(2,1), F("Print Speed"))
52
+                              .tag(4).button( BTN_POS(1,4), BTN_SIZE(2,1), F("Bed Temperature"))
53
+        #if ENABLED(BABYSTEPPING)
54
+          .enabled(true)
55
+        #else
56
+          .enabled(false)
57
+        #endif
58
+                              .tag(5).button( BTN_POS(1,5), BTN_SIZE(2,1), F("Nudge Nozzle"))
59
+       .enabled(!isPrinting()).tag(6).button( BTN_POS(1,6), BTN_SIZE(2,1), F("Load Syringe"))
60
+       .enabled(!isPrinting()).tag(7).button( BTN_POS(1,7), BTN_SIZE(2,1), F("Unlock XY Axis"))
61
+       .colors(action_btn)    .tag(1).button( BTN_POS(1,8), BTN_SIZE(2,1), F("Back"));
62
+  }
63
+  #undef GRID_COLS
64
+  #undef GRID_ROWS
65
+}
66
+
67
+bool TuneMenu::onTouchEnd(uint8_t tag) {
68
+  switch (tag) {
69
+    case 1:  GOTO_PREVIOUS();                    break;
70
+    case 2: {
71
+      FileList files;
72
+      printFile(files.shortFilename());
73
+      GOTO_PREVIOUS();
74
+      break;
75
+    }
76
+    case 3: GOTO_SCREEN(FeedratePercentScreen); break;
77
+    case 4: GOTO_SCREEN(TemperatureScreen);     break;
78
+    case 5: GOTO_SCREEN(NudgeNozzleScreen);     break;
79
+    case 6: GOTO_SCREEN(BioConfirmHomeXYZ);     break;
80
+    case 7: StatusScreen::unlockMotors();       break;
81
+    default:
82
+      return false;
83
+  }
84
+  return true;
85
+}
86
+
87
+#endif // LULZBOT_TOUCH_UI

+ 113
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/boot_screen.cpp View File

@@ -0,0 +1,113 @@
1
+/*******************
2
+ * boot_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+#include "../ftdi_eve_lib/extras/poly_ui.h"
30
+#include "../archim2-flash/flash_storage.h"
31
+
32
+#ifdef TOUCH_UI_PORTRAIT
33
+  #include "../theme/bootscreen_logo_portrait.h"
34
+#else
35
+  #include "../theme/bootscreen_logo_landscape.h"
36
+#endif
37
+
38
+using namespace FTDI;
39
+
40
+void BootScreen::onRedraw(draw_mode_t) {
41
+  CommandProcessor cmd;
42
+  cmd.cmd(CLEAR_COLOR_RGB(0x000000));
43
+  cmd.cmd(CLEAR(true,true,true));
44
+
45
+  CLCD::turn_on_backlight();
46
+  SoundPlayer::set_volume(255);
47
+}
48
+
49
+void BootScreen::onIdle() {
50
+  if (CLCD::is_touching()) {
51
+    // If the user is touching the screen at startup, then
52
+    // assume the user wants to re-calibrate the screen.
53
+    // This gives the user the ability to recover a
54
+    // miscalibration that has been stored to EEPROM.
55
+
56
+    // Also reset display parameters to defaults, just
57
+    // in case the display is borked.
58
+    InterfaceSettingsScreen::failSafeSettings();
59
+
60
+    GOTO_SCREEN(TouchCalibrationScreen);
61
+    current_screen.forget();
62
+    PUSH_SCREEN(StatusScreen);
63
+  } else {
64
+    if (!UIFlashStorage::is_valid()) {
65
+      SpinnerDialogBox::show(F("Please wait..."));
66
+      UIFlashStorage::format_flash();
67
+      SpinnerDialogBox::hide();
68
+    }
69
+
70
+    if (UIData::animations_enabled()) {
71
+      // If there is a startup video in the flash SPI, play
72
+      // that, otherwise show a static splash screen.
73
+      if (!MediaPlayerScreen::playBootMedia())
74
+        showSplashScreen();
75
+    }
76
+    #ifdef LULZBOT_USE_BIOPRINTER_UI
77
+      GOTO_SCREEN(BioConfirmHomeXYZ);
78
+      current_screen.forget();
79
+      PUSH_SCREEN(StatusScreen);
80
+      PUSH_SCREEN(BioConfirmHomeE);
81
+    #else
82
+      GOTO_SCREEN(StatusScreen);
83
+    #endif
84
+  }
85
+}
86
+
87
+void BootScreen::showSplashScreen() {
88
+  CommandProcessor cmd;
89
+  cmd.cmd(CMD_DLSTART);
90
+  cmd.cmd(CLEAR_COLOR_RGB(0xDEEA5C));
91
+  cmd.cmd(CLEAR(true,true,true));
92
+
93
+  #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0]))
94
+
95
+  PolyUI ui(cmd);
96
+
97
+  cmd.cmd(COLOR_RGB(0xC1D82F));
98
+  ui.fill(POLY(logo_green));
99
+  cmd.cmd(COLOR_RGB(0x000000));
100
+  ui.fill(POLY(logo_black));
101
+  ui.fill(POLY(logo_type));
102
+  ui.fill(POLY(logo_mark));
103
+  cmd.cmd(COLOR_RGB(0xFFFFFF));
104
+  ui.fill(POLY(logo_white));
105
+
106
+  cmd.cmd(DL::DL_DISPLAY);
107
+  cmd.cmd(CMD_SWAP);
108
+  cmd.execute();
109
+
110
+  ExtUI::delay_ms(2500);
111
+}
112
+
113
+#endif // LULZBOT_TOUCH_UI

+ 323
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/change_filament_screen.cpp View File

@@ -0,0 +1,323 @@
1
+/******************************
2
+ * change_filament_screen.cpp *
3
+ ******************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace ExtUI;
31
+using namespace FTDI;
32
+using namespace Theme;
33
+
34
+#define COOL_TEMP  40
35
+#define LOW_TEMP  180
36
+#define MED_TEMP  200
37
+#define HIGH_TEMP 220
38
+
39
+/****************** COLOR SCALE ***********************/
40
+
41
+uint32_t getWarmColor(uint16_t temp, uint16_t cool, uint16_t low, uint16_t med, uint16_t high) {
42
+  rgb_t R0, R1, mix;
43
+
44
+  float t;
45
+  if (temp < cool) {
46
+    R0 = cool_rgb;
47
+    R1 = low_rgb;
48
+    t  = 0;
49
+  }
50
+  else if (temp < low) {
51
+    R0 = cool_rgb;
52
+    R1 = low_rgb;
53
+    t = (float(temp)-cool)/(low-cool);
54
+  }
55
+  else if (temp < med) {
56
+    R0 = low_rgb;
57
+    R1 = med_rgb;
58
+    t = (float(temp)-low)/(med-low);
59
+  }
60
+  else if (temp < high) {
61
+    R0 = med_rgb;
62
+    R1 = high_rgb;
63
+    t = (float(temp)-med)/(high-med);
64
+  }
65
+  else if (temp >= high) {
66
+    R0 = med_rgb;
67
+    R1 = high_rgb;
68
+    t = 1;
69
+  }
70
+  rgb_t::lerp(t, R0, R1, mix);
71
+  return mix;
72
+}
73
+
74
+void ChangeFilamentScreen::drawTempGradient(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
75
+  CommandProcessor cmd;
76
+  cmd.cmd(SCISSOR_XY   (x, y))
77
+     .cmd(SCISSOR_SIZE (w, h/2))
78
+     .gradient         (x, y,     high_rgb, x, y+h/2, med_rgb)
79
+     .cmd(SCISSOR_XY   (x, y+h/2))
80
+     .cmd(SCISSOR_SIZE (w, h/2))
81
+     .gradient         (x, y+h/2, med_rgb,  x, y+h, low_rgb)
82
+     .cmd(SCISSOR_XY   ())
83
+     .cmd(SCISSOR_SIZE ());
84
+}
85
+
86
+void ChangeFilamentScreen::onEntry() {
87
+  screen_data.ChangeFilamentScreen.e_tag = ExtUI::getActiveTool() + 10;
88
+  screen_data.ChangeFilamentScreen.t_tag = 0;
89
+  screen_data.ChangeFilamentScreen.repeat_tag = 0;
90
+  screen_data.ChangeFilamentScreen.saved_extruder = getActiveTool();
91
+}
92
+
93
+void ChangeFilamentScreen::onExit() {
94
+  setActiveTool(screen_data.ChangeFilamentScreen.saved_extruder, true);
95
+}
96
+
97
+void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
98
+  CommandProcessor cmd;
99
+
100
+  #ifdef TOUCH_UI_PORTRAIT
101
+    #define GRID_COLS 2
102
+    #define GRID_ROWS 11
103
+  #else
104
+    #define GRID_COLS 4
105
+    #define GRID_ROWS 6
106
+  #endif
107
+
108
+  if (what & BACKGROUND) {
109
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
110
+       .cmd(CLEAR(true,true,true))
111
+       .tag(0)
112
+    #ifdef TOUCH_UI_PORTRAIT
113
+       .font(font_large)
114
+    #else
115
+       .font(font_medium)
116
+    #endif
117
+       .text(BTN_POS(1,1), BTN_SIZE(2,1), F("Extruder Selection:"))
118
+    #ifdef TOUCH_UI_PORTRAIT
119
+       .text(BTN_POS(1,7), BTN_SIZE(1,1), F("Current Temp:"))
120
+    #else
121
+       .text(BTN_POS(3,1), BTN_SIZE(2,1), F("Current Temp:"))
122
+       .font(font_small)
123
+    #endif
124
+       .text(BTN_POS(1,3), BTN_SIZE(2,1), F("Removal Temp:"));
125
+    drawTempGradient(BTN_POS(1,4), BTN_SIZE(1,3));
126
+  }
127
+
128
+  if (what & FOREGROUND) {
129
+    char e_str[15];
130
+
131
+    const char *idle = PSTR("%-3d C / idle");
132
+    const char *not_idle = PSTR("%-3d / %-3d C");
133
+
134
+    sprintf_P(
135
+      e_str,
136
+      isHeaterIdle(getExtruder()) ? idle : not_idle,
137
+      ROUND(getActualTemp_celsius(getExtruder())),
138
+      ROUND(getTargetTemp_celsius(getExtruder()))
139
+    );
140
+
141
+    const rgb_t tcol = getWarmColor(getActualTemp_celsius(getExtruder()), COOL_TEMP, LOW_TEMP, MED_TEMP, HIGH_TEMP);
142
+    cmd.cmd(COLOR_RGB(tcol))
143
+       .tag(15)
144
+    #ifdef TOUCH_UI_PORTRAIT
145
+       .rectangle(BTN_POS(2,7), BTN_SIZE(1,1))
146
+    #else
147
+       .rectangle(BTN_POS(3,2), BTN_SIZE(2,1))
148
+    #endif
149
+       .cmd(COLOR_RGB(tcol.luminance() > 128 ? 0x000000 : 0xFFFFFF))
150
+       .font(font_medium)
151
+    #ifdef TOUCH_UI_PORTRAIT
152
+       .text(BTN_POS(2,7), BTN_SIZE(1,1), e_str)
153
+    #else
154
+       .text(BTN_POS(3,2), BTN_SIZE(2,1), e_str)
155
+    #endif
156
+       .colors(normal_btn);
157
+
158
+    const bool t_ok = getActualTemp_celsius(getExtruder()) > getSoftenTemp() - 10;
159
+
160
+    if (screen_data.ChangeFilamentScreen.t_tag && !t_ok) {
161
+      cmd.text(BTN_POS(1,6), BTN_SIZE(1,1), F("Heating..."));
162
+    } else if (getActualTemp_celsius(getExtruder()) > 100) {
163
+      cmd.cmd(COLOR_RGB(0xFF0000))
164
+         .text(BTN_POS(1,4), BTN_SIZE(1,1), F("Caution:"))
165
+         .colors(normal_btn)
166
+         .text(BTN_POS(1,6), BTN_SIZE(1,1), F("Hot!"));
167
+    }
168
+
169
+    #define TOG_STYLE(A) colors(A ? action_btn : normal_btn)
170
+
171
+    const bool tog2  = screen_data.ChangeFilamentScreen.t_tag == 2;
172
+    const bool tog3  = screen_data.ChangeFilamentScreen.t_tag == 3;
173
+    const bool tog4  = screen_data.ChangeFilamentScreen.t_tag == 4;
174
+    const bool tog10 = screen_data.ChangeFilamentScreen.e_tag == 10;
175
+    #if HOTENDS > 1
176
+    const bool tog11 = screen_data.ChangeFilamentScreen.e_tag == 11;
177
+    #endif
178
+
179
+    #ifdef TOUCH_UI_PORTRAIT
180
+      cmd.font(font_large)
181
+    #else
182
+      cmd.font(font_medium)
183
+    #endif
184
+       .TOG_STYLE(tog10)
185
+       .tag(10)          .button (BTN_POS(1,2), BTN_SIZE(1,1), F("1"))
186
+    #if HOTENDS < 2
187
+       .enabled(false)
188
+    #else
189
+       .TOG_STYLE(tog11)
190
+    #endif
191
+       .tag(11)          .button (BTN_POS(2,2), BTN_SIZE(1,1), F("2"));
192
+
193
+    if (!t_ok) reset_menu_timeout();
194
+
195
+    const bool tog7 = screen_data.ChangeFilamentScreen.repeat_tag == 7;
196
+    const bool tog8 = screen_data.ChangeFilamentScreen.repeat_tag == 8;
197
+
198
+    #ifdef TOUCH_UI_PORTRAIT
199
+      cmd.font(font_large)
200
+    #else
201
+      cmd.font(font_small)
202
+    #endif
203
+       .tag(2) .TOG_STYLE(tog2) .button (BTN_POS(2,6), BTN_SIZE(1,1), F( STRINGIFY(LOW_TEMP)  "C (PLA)"))
204
+       .tag(3) .TOG_STYLE(tog3) .button (BTN_POS(2,5), BTN_SIZE(1,1), F( STRINGIFY(MED_TEMP)  "C (ABS)"))
205
+       .tag(4) .TOG_STYLE(tog4) .button (BTN_POS(2,4), BTN_SIZE(1,1), F( STRINGIFY(HIGH_TEMP) "C (High)"))
206
+       .colors(normal_btn)
207
+
208
+    // Add tags to color gradient
209
+    .cmd(COLOR_MASK(0,0,0,0))
210
+    .tag(2) .rectangle(BTN_POS(1,6), BTN_SIZE(1,1))
211
+    .tag(3) .rectangle(BTN_POS(1,5), BTN_SIZE(1,1))
212
+    .tag(4) .rectangle(BTN_POS(1,4), BTN_SIZE(1,1))
213
+    .cmd(COLOR_MASK(1,1,1,1))
214
+
215
+    .cmd(COLOR_RGB(t_ok ? bg_text_enabled : bg_text_disabled))
216
+    #ifdef TOUCH_UI_PORTRAIT
217
+       .font(font_large)
218
+       .tag(0)                              .text   (BTN_POS(1,8),  BTN_SIZE(1,1), F("Unload"))
219
+                                            .text   (BTN_POS(2,8),  BTN_SIZE(1,1), F("Load/Extrude"))
220
+       .tag(5)                .enabled(t_ok).button (BTN_POS(1,9),  BTN_SIZE(1,1), F("Momentary"))
221
+       .tag(6)                .enabled(t_ok).button (BTN_POS(2,9),  BTN_SIZE(1,1), F("Momentary"))
222
+       .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (BTN_POS(1,10), BTN_SIZE(1,1), F("Continuous"))
223
+       .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (BTN_POS(2,10), BTN_SIZE(1,1), F("Continuous"))
224
+       .tag(1).colors(action_btn)           .button (BTN_POS(1,11), BTN_SIZE(2,1), F("Back"));
225
+    #else
226
+       .font(font_small)
227
+       .tag(0)                              .text   (BTN_POS(3,3),  BTN_SIZE(1,1), F("Unload"))
228
+                                            .text   (BTN_POS(4,3),  BTN_SIZE(1,1), F("Load/Extrude"))
229
+       .tag(5)                .enabled(t_ok).button (BTN_POS(3,4),  BTN_SIZE(1,1), F("Momentary"))
230
+       .tag(6)                .enabled(t_ok).button (BTN_POS(4,4),  BTN_SIZE(1,1), F("Momentary"))
231
+       .tag(7).TOG_STYLE(tog7).enabled(t_ok).button (BTN_POS(3,5),  BTN_SIZE(1,1), F("Continuous"))
232
+       .tag(8).TOG_STYLE(tog8).enabled(t_ok).button (BTN_POS(4,5),  BTN_SIZE(1,1), F("Continuous"))
233
+       .font(font_medium)
234
+       .tag(1).colors(action_btn)           .button (BTN_POS(3,6),  BTN_SIZE(2,1), F("Back"));
235
+    #endif
236
+  }
237
+  #undef GRID_COLS
238
+  #undef GRID_ROWS
239
+}
240
+
241
+uint8_t ChangeFilamentScreen::getSoftenTemp() {
242
+  switch (screen_data.ChangeFilamentScreen.t_tag) {
243
+    case 2:  return LOW_TEMP;
244
+    case 3:  return MED_TEMP;
245
+    case 4:  return HIGH_TEMP;
246
+    default: return EXTRUDE_MINTEMP;
247
+  }
248
+}
249
+
250
+ExtUI::extruder_t ChangeFilamentScreen::getExtruder() {
251
+  switch (screen_data.ChangeFilamentScreen.e_tag) {
252
+    case 13: return ExtUI::E3;
253
+    case 12: return ExtUI::E2;
254
+    case 11: return ExtUI::E1;
255
+    default: return ExtUI::E0;
256
+  }
257
+}
258
+
259
+bool ChangeFilamentScreen::onTouchStart(uint8_t tag) {
260
+  // Make the Momentary and Continuous buttons slightly more responsive
261
+  switch (tag) {
262
+    case 5: case 6: case 7: case 8:
263
+      return ChangeFilamentScreen::onTouchHeld(tag);
264
+    default:
265
+      return false;
266
+  }
267
+}
268
+
269
+bool ChangeFilamentScreen::onTouchEnd(uint8_t tag) {
270
+  using namespace ExtUI;
271
+  switch (tag) {
272
+    case 1: GOTO_PREVIOUS(); break;
273
+    case 2:
274
+    case 3:
275
+    case 4:
276
+      // Change temperature
277
+      screen_data.ChangeFilamentScreen.t_tag = tag;
278
+      setTargetTemp_celsius(getSoftenTemp(), getExtruder());
279
+      break;
280
+    case 7:
281
+      screen_data.ChangeFilamentScreen.repeat_tag = (screen_data.ChangeFilamentScreen.repeat_tag == 7) ? 0 : 7;
282
+      break;
283
+    case 8:
284
+      screen_data.ChangeFilamentScreen.repeat_tag = (screen_data.ChangeFilamentScreen.repeat_tag == 8) ? 0 : 8;
285
+      break;
286
+    case 10:
287
+    case 11:
288
+      // Change extruder
289
+      screen_data.ChangeFilamentScreen.e_tag      = tag;
290
+      screen_data.ChangeFilamentScreen.t_tag      = 0;
291
+      screen_data.ChangeFilamentScreen.repeat_tag = 0;
292
+      setActiveTool(getExtruder(), true);
293
+      break;
294
+    case 15: GOTO_SCREEN(TemperatureScreen); break;
295
+  }
296
+  return true;
297
+}
298
+
299
+bool ChangeFilamentScreen::onTouchHeld(uint8_t tag) {
300
+  if (ExtUI::isMoving()) return false; // Don't allow moves to accumulate
301
+  constexpr float increment = 1;
302
+  #define UI_INCREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_INCREMENT(AxisPosition_mm, axis);
303
+  #define UI_DECREMENT_AXIS(axis) MoveAxisScreen::setManualFeedrate(axis, increment); UI_DECREMENT(AxisPosition_mm, axis);
304
+  switch (tag) {
305
+    case 5: case 7: UI_DECREMENT_AXIS(getExtruder()); break;
306
+    case 6: case 8: UI_INCREMENT_AXIS(getExtruder()); break;
307
+    default: return false;
308
+  }
309
+  #undef UI_DECREMENT_AXIS
310
+  #undef UI_INCREMENT_AXIS
311
+  return false;
312
+}
313
+
314
+void ChangeFilamentScreen::onIdle() {
315
+  if (screen_data.ChangeFilamentScreen.repeat_tag) onTouchHeld(screen_data.ChangeFilamentScreen.repeat_tag);
316
+  if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
317
+    onRefresh();
318
+    refresh_timer.start();
319
+  }
320
+  BaseScreen::onIdle();
321
+}
322
+
323
+#endif // LULZBOT_TOUCH_UI

+ 47
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_abort_print_dialog_box.cpp View File

@@ -0,0 +1,47 @@
1
+/**************************************
2
+ * confirm_abort_print_dialog_box.cpp *
3
+ **************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace ExtUI;
30
+
31
+void ConfirmAbortPrintDialogBox::onRedraw(draw_mode_t) {
32
+  drawMessage(F("Are you sure you want to cancel the print?"));
33
+  drawYesNoButtons();
34
+}
35
+
36
+bool ConfirmAbortPrintDialogBox::onTouchEnd(uint8_t tag) {
37
+  switch (tag) {
38
+    case 1:
39
+      GOTO_PREVIOUS();
40
+      stopPrint();
41
+      return true;
42
+    default:
43
+      return DialogBoxBaseClass::onTouchEnd(tag);
44
+  }
45
+}
46
+
47
+#endif // LULZBOT_TOUCH_UI

+ 48
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_auto_calibration_dialog_box.cpp View File

@@ -0,0 +1,48 @@
1
+/*******************************************
2
+ * confirm_auto_calibration_dialog_box.cpp *
3
+ *******************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(CALIBRATION_GCODE)
26
+
27
+#include "screens.h"
28
+
29
+using namespace ExtUI;
30
+using namespace Theme;
31
+
32
+void ConfirmAutoCalibrationDialogBox::onRedraw(draw_mode_t) {
33
+  drawMessage(F("For best results, unload the filament and clean the hotend prior to starting calibration. Continue?"));
34
+  drawYesNoButtons();
35
+}
36
+
37
+bool ConfirmAutoCalibrationDialogBox::onTouchEnd(uint8_t tag) {
38
+  switch (tag) {
39
+    case 1:
40
+      GOTO_SCREEN(StatusScreen);
41
+      injectCommands_P(PSTR(LULZBOT_CALIBRATION_COMMANDS));
42
+      return true;
43
+    default:
44
+      return DialogBoxBaseClass::onTouchEnd(tag);
45
+  }
46
+}
47
+
48
+#endif // LULZBOT_TOUCH_UI

+ 54
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_erase_flash_dialog_box.cpp View File

@@ -0,0 +1,54 @@
1
+/**************************************
2
+ * confirm_erase_flash_dialog_box.cpp *
3
+ **************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(DEVELOPER_SCREENS)
26
+
27
+#include "screens.h"
28
+
29
+#include "../archim2-flash/flash_storage.h"
30
+
31
+using namespace FTDI;
32
+
33
+void ConfirmEraseFlashDialogBox::onRedraw(draw_mode_t) {
34
+  drawMessage(F("Are you sure? SPI flash will be erased."));
35
+  drawYesNoButtons();
36
+}
37
+
38
+bool ConfirmEraseFlashDialogBox::onTouchEnd(uint8_t tag) {
39
+  switch (tag) {
40
+    case 1:
41
+      SpinnerDialogBox::show(F("Erasing..."));
42
+      UIFlashStorage::format_flash();
43
+      SpinnerDialogBox::hide();
44
+      AlertDialogBox::show(F("SPI flash erased"));
45
+      // Remove ConfirmEraseFlashDialogBox from the stack
46
+      // so the alert box doesn't return to me.
47
+      current_screen.forget();
48
+      return true;
49
+    default:
50
+      return DialogBoxBaseClass::onTouchEnd(tag);
51
+  }
52
+}
53
+
54
+#endif // LULZBOT_TOUCH_UI

+ 58
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/confirm_user_request_alert_box.cpp View File

@@ -0,0 +1,58 @@
1
+/**************************************
2
+ * confirm_user_request_alert_box.cpp *
3
+ **************************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+
32
+void ConfirmUserRequestAlertBox::onRedraw(draw_mode_t mode) {
33
+  AlertDialogBox::onRedraw(mode); // Required for the GOTO_SCREEN function to work
34
+}
35
+
36
+bool ConfirmUserRequestAlertBox::onTouchEnd(uint8_t tag) {
37
+  switch (tag) {
38
+    case 1:
39
+      ExtUI::setUserConfirmed();
40
+      GOTO_PREVIOUS();
41
+      return true;
42
+    case 2: GOTO_PREVIOUS(); return true;
43
+    default:                 return false;
44
+  }
45
+}
46
+
47
+void ConfirmUserRequestAlertBox::show(const char* msg) {
48
+  drawMessage(msg);
49
+  storeBackground();
50
+  screen_data.AlertDialogBox.isError = false;
51
+  GOTO_SCREEN(ConfirmUserRequestAlertBox);
52
+}
53
+
54
+void ConfirmUserRequestAlertBox::hide() {
55
+  if (AT_SCREEN(ConfirmUserRequestAlertBox))
56
+    GOTO_PREVIOUS();
57
+}
58
+#endif // LULZBOT_TOUCH_UI

+ 63
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/default_acceleration_screen.cpp View File

@@ -0,0 +1,63 @@
1
+/***********************************
2
+ * default_acceleration_screen.cpp *
3
+ ***********************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void DefaultAccelerationScreen::onRedraw(draw_mode_t what) {
34
+  widgets_t w(what);
35
+  w.precision(0);
36
+  w.units(PSTR("mm/s^2"));
37
+  w.heading(      PSTR("Default Acceleration"));
38
+  w.color(other);
39
+  w.adjuster(  2, PSTR("Printing:"),   getPrintingAcceleration_mm_s2() );
40
+  w.adjuster(  4, PSTR("Travel:"),     getTravelAcceleration_mm_s2() );
41
+  w.adjuster(  6, PSTR("Retraction:"), getRetractAcceleration_mm_s2() );
42
+  w.increments();
43
+  w.button(    8, PSTR("Set Axis Maximum"));
44
+}
45
+
46
+bool DefaultAccelerationScreen::onTouchHeld(uint8_t tag) {
47
+  const float increment = getIncrement();
48
+  switch (tag) {
49
+    case  2: UI_DECREMENT(PrintingAcceleration_mm_s2); break;
50
+    case  3: UI_INCREMENT(PrintingAcceleration_mm_s2); break;
51
+    case  4: UI_DECREMENT(TravelAcceleration_mm_s2);   break;
52
+    case  5: UI_INCREMENT(TravelAcceleration_mm_s2);   break;
53
+    case  6: UI_DECREMENT(RetractAcceleration_mm_s2);  break;
54
+    case  7: UI_INCREMENT(RetractAcceleration_mm_s2);  break;
55
+    case  8: GOTO_SCREEN(MaxAccelerationScreen);       break;
56
+    default:
57
+      return false;
58
+  }
59
+  SaveSettingsDialogBox::settingsChanged();
60
+  return true;
61
+}
62
+
63
+#endif // LULZBOT_TOUCH_UI

+ 150
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/developer_menu.cpp View File

@@ -0,0 +1,150 @@
1
+/**********************
2
+ * developer_menu.cpp *
3
+ **********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(DEVELOPER_SCREENS)
26
+
27
+#include "screens.h"
28
+
29
+#include "../archim2-flash/flash_storage.h"
30
+
31
+using namespace FTDI;
32
+using namespace Theme;
33
+
34
+void DeveloperMenu::onRedraw(draw_mode_t what) {
35
+  if (what & BACKGROUND) {
36
+    CommandProcessor cmd;
37
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
38
+       .cmd(CLEAR(true,true,true))
39
+       .font(font_medium)
40
+       .tag(0);
41
+
42
+    #ifdef SPI_FLASH_SS
43
+      constexpr bool has_flash = true;
44
+    #else
45
+      constexpr bool has_flash = false;
46
+    #endif
47
+
48
+    #if ENABLED(SDSUPPORT)
49
+      constexpr bool has_media = true;
50
+    #else
51
+      constexpr bool has_media = false;
52
+    #endif
53
+
54
+    cmd.cmd(COLOR_RGB(bg_text_enabled));
55
+    #ifdef TOUCH_UI_PORTRAIT
56
+      #define GRID_ROWS 10
57
+      #define GRID_COLS 1
58
+      cmd.font(font_large)         .text  ( BTN_POS(1,1), BTN_SIZE(1,1), F("Developer Menu"))
59
+         .colors(normal_btn)
60
+         .tag(2).font(font_medium) .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets"))
61
+         .tag(3)                   .button( BTN_POS(1,3), BTN_SIZE(1,1), F("Stress Test"))
62
+         .tag(4)                   .button( BTN_POS(1,4), BTN_SIZE(1,1), F("Show Touch Registers"))
63
+         .tag(5)                   .button( BTN_POS(1,5), BTN_SIZE(1,1), F("Play Song"))
64
+         .tag(6).enabled(has_media).button( BTN_POS(1,6), BTN_SIZE(1,1), F("Play Video from Media"))
65
+         .tag(7).enabled(has_flash).button( BTN_POS(1,7), BTN_SIZE(1,1), F("Play Video from SPI Flash"))
66
+         .tag(8).enabled(has_flash).button( BTN_POS(1,8), BTN_SIZE(1,1), F("Load Video to SPI Flash"))
67
+         .tag(9).enabled(has_flash).button( BTN_POS(1,9), BTN_SIZE(1,1), F("Erase SPI Flash"))
68
+
69
+         .tag(1).colors(action_btn)
70
+                                   .button( BTN_POS(1,10), BTN_SIZE(1,1), F("Back"));
71
+    #else
72
+      #define GRID_ROWS 6
73
+      #define GRID_COLS 2
74
+      cmd.font(font_medium)        .text  ( BTN_POS(1,1), BTN_SIZE(2,1), F("Developer Menu"))
75
+         .colors(normal_btn)
76
+         .tag(2).font(font_small)  .button( BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets"))
77
+         .tag(3)                   .button( BTN_POS(1,3), BTN_SIZE(1,1), F("Show Touch Registers"))
78
+         .tag(9)                   .button( BTN_POS(1,4), BTN_SIZE(1,1), F("Show Pin States"))
79
+         .tag(4)                   .button( BTN_POS(1,5), BTN_SIZE(1,1), F("Play Song"))
80
+         .tag(5).enabled(has_media).button( BTN_POS(2,2), BTN_SIZE(1,1), F("Play Video from Media"))
81
+         .tag(6).enabled(has_flash).button( BTN_POS(2,3), BTN_SIZE(1,1), F("Play Video from SPI Flash"))
82
+         .tag(7).enabled(has_flash).button( BTN_POS(2,4), BTN_SIZE(1,1), F("Load Video to SPI Flash"))
83
+         .tag(8).enabled(has_flash).button( BTN_POS(2,5), BTN_SIZE(1,1), F("Erase SPI Flash"))
84
+         .tag(1).colors(action_btn)
85
+                                   .button( BTN_POS(1,6), BTN_SIZE(2,1), F("Back"));
86
+    #endif
87
+  }
88
+}
89
+
90
+bool DeveloperMenu::onTouchEnd(uint8_t tag) {
91
+  using namespace Theme;
92
+  switch (tag) {
93
+    case 1: GOTO_PREVIOUS();                            break;
94
+    case 2: GOTO_SCREEN(WidgetsScreen);                 break;
95
+    case 3:
96
+      PUSH_SCREEN(StressTestScreen);
97
+      AlertDialogBox::show(F("Please do not run this test unattended as it may cause your printer to malfunction."));
98
+      current_screen.forget();
99
+      break;
100
+    case 4: GOTO_SCREEN(TouchRegistersScreen);          break;
101
+    case 5: sound.play(js_bach_joy, PLAY_ASYNCHRONOUS); break;
102
+    #if ENABLED(SDSUPPORT)
103
+    case 6:
104
+        if (!MediaPlayerScreen::playCardMedia())
105
+          AlertDialogBox::showError(F("Cannot open STARTUP.AVI"));
106
+        break;
107
+    #endif
108
+    #ifdef SPI_FLASH_SS
109
+      case 7:
110
+        if (!MediaPlayerScreen::playBootMedia())
111
+          AlertDialogBox::showError(F("No boot media available"));
112
+        break;
113
+      case 8:
114
+      {
115
+        SpinnerDialogBox::show(F("Saving..."));
116
+        UIFlashStorage::error_t res = UIFlashStorage::write_media_file(F("STARTUP.AVI"));
117
+        SpinnerDialogBox::hide();
118
+        reset_menu_timeout();
119
+        switch (res) {
120
+          case UIFlashStorage::SUCCESS:
121
+            AlertDialogBox::show(F("File copied!"));
122
+            break;
123
+
124
+          case UIFlashStorage::READ_ERROR:
125
+            AlertDialogBox::showError(F("Failed to read file"));
126
+            break;
127
+
128
+          case UIFlashStorage::VERIFY_ERROR:
129
+            AlertDialogBox::showError(F("Failed to verify file"));
130
+            break;
131
+
132
+          case UIFlashStorage::FILE_NOT_FOUND:
133
+            AlertDialogBox::showError(F("Cannot open STARTUP.AVI"));
134
+            break;
135
+
136
+          case UIFlashStorage::WOULD_OVERWRITE:
137
+            AlertDialogBox::showError(F("Cannot overwrite existing media."));
138
+            break;
139
+        }
140
+        break;
141
+      }
142
+      case 9: GOTO_SCREEN(ConfirmEraseFlashDialogBox); break;
143
+    #endif
144
+    case 10: GOTO_SCREEN(EndstopStatesScreen); break;
145
+    default: return false;
146
+  }
147
+  return true;
148
+}
149
+
150
+#endif // LULZBOT_TOUCH_UI

+ 83
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/dialog_box_base_class.cpp View File

@@ -0,0 +1,83 @@
1
+/*****************************
2
+ * dialog_box_base_class.cpp *
3
+ *****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+#define GRID_COLS 2
33
+#define GRID_ROWS 8
34
+
35
+template<typename T>
36
+void DialogBoxBaseClass::drawMessage(const T message, int16_t font) {
37
+  CommandProcessor cmd;
38
+  cmd.cmd(CMD_DLSTART)
39
+     .cmd(CLEAR_COLOR_RGB(bg_color))
40
+     .cmd(CLEAR(true,true,true))
41
+     .cmd(COLOR_RGB(bg_text_enabled))
42
+     .tag(0);
43
+  draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,3), message, OPT_CENTER, font ? font : font_large);
44
+  cmd.colors(normal_btn);
45
+}
46
+
47
+template void DialogBoxBaseClass::drawMessage(const char *, int16_t font);
48
+template void DialogBoxBaseClass::drawMessage(const progmem_str, int16_t font);
49
+
50
+void DialogBoxBaseClass::drawYesNoButtons(uint8_t default_btn) {
51
+  CommandProcessor cmd;
52
+  cmd.font(font_medium)
53
+     .colors(default_btn == 1 ? action_btn : normal_btn).tag(1).button( BTN_POS(1,8), BTN_SIZE(1,1), F("Yes"))
54
+     .colors(default_btn == 2 ? action_btn : normal_btn).tag(2).button( BTN_POS(2,8), BTN_SIZE(1,1), F("No"));
55
+}
56
+
57
+void DialogBoxBaseClass::drawOkayButton() {
58
+  CommandProcessor cmd;
59
+  cmd.font(font_medium)
60
+     .tag(1).button( BTN_POS(1,8), BTN_SIZE(2,1), F("Okay"));
61
+}
62
+
63
+void DialogBoxBaseClass::drawButton(const progmem_str label) {
64
+  CommandProcessor cmd;
65
+  cmd.font(font_medium)
66
+     .tag(1).button( BTN_POS(1,8), BTN_SIZE(2,1), label);
67
+}
68
+
69
+void DialogBoxBaseClass::drawSpinner() {
70
+  CommandProcessor cmd;
71
+  cmd.cmd(COLOR_RGB(bg_text_enabled))
72
+     .spinner(BTN_POS(1,4), BTN_SIZE(2,3)).execute();
73
+}
74
+
75
+bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) {
76
+  switch (tag) {
77
+    case 1: GOTO_PREVIOUS(); return true;
78
+    case 2: GOTO_PREVIOUS(); return true;
79
+    default:                 return false;
80
+  }
81
+}
82
+
83
+#endif // LULZBOT_TOUCH_UI

+ 61
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/display_tuning_screen.cpp View File

@@ -0,0 +1,61 @@
1
+/*****************************
2
+ * display_tuning_screen.cpp *
3
+ *****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+void DisplayTuningScreen::onRedraw(draw_mode_t what) {
33
+  widgets_t w(what);
34
+  w.precision(0, BaseNumericAdjustmentScreen::DEFAULT_LOWEST);
35
+  w.units(PSTR(""));
36
+  w.heading(     PSTR("Display Tuning"));
37
+  w.color(other);
38
+  w.adjuster( 2, PSTR("H Offset:"), CLCD::mem_read_16(CLCD::REG::HOFFSET) );
39
+  w.adjuster( 4, PSTR("V Offset:"), CLCD::mem_read_16(CLCD::REG::VOFFSET) );
40
+  w.increments();
41
+  w.heading(     PSTR("Touch Screen"));
42
+  w.button(6, PSTR("Calibrate"));
43
+}
44
+
45
+bool DisplayTuningScreen::onTouchHeld(uint8_t tag) {
46
+  #define REG_INCREMENT(a,i) CLCD::mem_write_16(CLCD::REG::a, CLCD::mem_read_16(CLCD::REG::a) + i)
47
+  const float increment = getIncrement();
48
+  switch (tag) {
49
+    case  2: REG_INCREMENT(HOFFSET, -increment);  break;
50
+    case  3: REG_INCREMENT(HOFFSET,  increment);  break;
51
+    case  4: REG_INCREMENT(VOFFSET, -increment);  break;
52
+    case  5: REG_INCREMENT(VOFFSET,  increment);  break;
53
+    case  6: GOTO_SCREEN(TouchCalibrationScreen); break;
54
+    default:
55
+      return false;
56
+  }
57
+  SaveSettingsDialogBox::settingsChanged();
58
+  return true;
59
+}
60
+
61
+#endif // LULZBOT_TOUCH_UI

+ 155
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp View File

@@ -0,0 +1,155 @@
1
+/****************************
2
+ * endstop_state_screen.cpp *
3
+ ****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+using namespace ExtUI;
32
+
33
+void EndstopStatesScreen::onEntry() {
34
+  BaseScreen::onEntry();
35
+  #ifdef LULZBOT_SET_PROBE_PINS_STATE
36
+    LULZBOT_SET_PROBE_PINS_STATE(true)
37
+  #endif
38
+}
39
+
40
+void EndstopStatesScreen::onExit() {
41
+  BaseScreen::onExit();
42
+  #ifdef LULZBOT_SET_PROBE_PINS_STATE
43
+    LULZBOT_SET_PROBE_PINS_STATE(false)
44
+  #endif
45
+}
46
+
47
+void EndstopStatesScreen::onRedraw(draw_mode_t) {
48
+  CommandProcessor cmd;
49
+  cmd.cmd(CLEAR_COLOR_RGB(bg_color))
50
+     .cmd(COLOR_RGB(bg_text_enabled))
51
+     .cmd(CLEAR(true,true,true))
52
+     .tag(0);
53
+
54
+  #define GRID_ROWS 7
55
+  #define GRID_COLS 6
56
+
57
+  #define PIN_BTN(X,Y,PIN,LABEL)          button(BTN_POS(X,Y), BTN_SIZE(2,1), F(LABEL))
58
+  #define PIN_ENABLED(LABEL,PIN,INV,X,Y)  cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL);
59
+  #define PIN_DISABLED(LABEL,PIN,INV,X,Y) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL);
60
+
61
+  #ifdef TOUCH_UI_PORTRAIT
62
+  cmd.font(font_large)
63
+  #else
64
+  cmd.font(font_medium)
65
+  #endif
66
+     .text(BTN_POS(1,1), BTN_SIZE(6,1), F("Endstop States:"))
67
+     .font(font_tiny);
68
+  #if PIN_EXISTS(X_MAX)
69
+    PIN_ENABLED ("X Max", X_MAX,X_MAX_ENDSTOP_INVERTING,1,2)
70
+  #else
71
+    PIN_DISABLED("X Max",X_MAX,X_MAX_ENDSTOP_INVERTING,1,2)
72
+  #endif
73
+  #if PIN_EXISTS(Y_MAX)
74
+    PIN_ENABLED ("Y Max",Y_MAX,Y_MAX_ENDSTOP_INVERTING,3,2)
75
+  #else
76
+    PIN_DISABLED("Y Max",Y_MAX,Y_MAX_ENDSTOP_INVERTING,3,2)
77
+  #endif
78
+  #if PIN_EXISTS(Z_MAX)
79
+    PIN_ENABLED ("Z Max",Z_MAX,Z_MAX_ENDSTOP_INVERTING,5,2)
80
+  #else
81
+    PIN_DISABLED("Z Max",Z_MAX,Z_MAX_ENDSTOP_INVERTING,5,2)
82
+  #endif
83
+  #if PIN_EXISTS(X_MIN)
84
+    PIN_ENABLED ("X Min",X_MIN,X_MIN_ENDSTOP_INVERTING,1,3)
85
+  #else
86
+    PIN_DISABLED("X Min",X_MIN,X_MIN_ENDSTOP_INVERTING,1,3)
87
+  #endif
88
+  #if PIN_EXISTS(Y_MIN)
89
+    PIN_ENABLED ("Y Min",Y_MIN,Y_MIN_ENDSTOP_INVERTING,3,3)
90
+  #else
91
+    PIN_DISABLED("Y Min",Y_MIN,Y_MIN_ENDSTOP_INVERTING,3,3)
92
+  #endif
93
+  #if PIN_EXISTS(Z_MIN)
94
+    PIN_ENABLED ("Z Min",Z_MIN,Z_MIN_ENDSTOP_INVERTING,5,3)
95
+  #else
96
+    PIN_DISABLED("Z Min",Z_MIN,Z_MIN_ENDSTOP_INVERTING,5,3)
97
+  #endif
98
+  #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT)
99
+    PIN_ENABLED ("Runout 1",FIL_RUNOUT, FIL_RUNOUT_INVERTING,1,4)
100
+  #else
101
+    PIN_DISABLED("Runout 1",FIL_RUNOUT, FIL_RUNOUT_INVERTING,1,4)
102
+  #endif
103
+  #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2)
104
+    PIN_ENABLED ("Runout 2",FIL_RUNOUT2,FIL_RUNOUT_INVERTING,3,4)
105
+  #else
106
+    PIN_DISABLED("Runout 2",FIL_RUNOUT2,FIL_RUNOUT_INVERTING,3,4)
107
+  #endif
108
+  #if PIN_EXISTS(Z_MIN_PROBE)
109
+    PIN_ENABLED ("Z Probe",Z_MIN_PROBE,Z_MIN_PROBE_ENDSTOP_INVERTING,5,4)
110
+  #else
111
+    PIN_DISABLED("Z Probe",Z_MIN_PROBE,Z_MIN_PROBE_ENDSTOP_INVERTING,5,4)
112
+  #endif
113
+
114
+  #if HAS_SOFTWARE_ENDSTOPS
115
+    #undef EDGE_R
116
+    #define EDGE_R 30
117
+    cmd.font(font_small)
118
+       .text         (BTN_POS(1,5), BTN_SIZE(3,1), F("Soft Limits:"), OPT_RIGHTX | OPT_CENTERY)
119
+       .colors(ui_toggle)
120
+       .tag(2).toggle(BTN_POS(4,5), BTN_SIZE(3,1), F("off\xFFon"), getSoftEndstopState());
121
+      #undef EDGE_R
122
+      #define EDGE_R 0
123
+  #endif
124
+
125
+  cmd.font(font_medium)
126
+     .colors(action_btn)
127
+     .tag(1).button( BTN_POS(1,7), BTN_SIZE(6,1), F("Back"));
128
+  #undef GRID_COLS
129
+  #undef GRID_ROWS
130
+}
131
+
132
+bool EndstopStatesScreen::onTouchEnd(uint8_t tag) {
133
+  switch (tag) {
134
+    case 1: GOTO_PREVIOUS(); break;
135
+    #if HAS_SOFTWARE_ENDSTOPS
136
+    case 2: setSoftEndstopState(!getSoftEndstopState());
137
+    #endif
138
+    default:
139
+      return false;
140
+  }
141
+  return true;
142
+}
143
+
144
+void EndstopStatesScreen::onIdle() {
145
+  constexpr uint32_t DIAGNOSTICS_UPDATE_INTERVAL = 100;
146
+
147
+  if (refresh_timer.elapsed(DIAGNOSTICS_UPDATE_INTERVAL)) {
148
+    onRefresh();
149
+    refresh_timer.start();
150
+    reset_menu_timeout();
151
+  }
152
+  BaseScreen::onIdle();
153
+}
154
+
155
+#endif // LULZBOT_TOUCH_UI

+ 52
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/feedrate_percent_screen.cpp View File

@@ -0,0 +1,52 @@
1
+/*******************************
2
+ * feedrate_percent_screen.cpp *
3
+ *******************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+
32
+void FeedratePercentScreen::onRedraw(draw_mode_t what) {
33
+  widgets_t w(what);
34
+  w.precision(0).units(PSTR("%"));
35
+
36
+  w.heading(PSTR("Print Speed"));
37
+  w.adjuster(4,  PSTR("Speed"), getFeedrate_percent());
38
+  w.increments();
39
+}
40
+
41
+bool FeedratePercentScreen::onTouchHeld(uint8_t tag) {
42
+  const float increment = getIncrement();
43
+  switch (tag) {
44
+    case 4: UI_DECREMENT(Feedrate_percent); break;
45
+    case 5: UI_INCREMENT(Feedrate_percent); break;
46
+    default:
47
+      return false;
48
+  }
49
+  return true;
50
+}
51
+
52
+#endif // LULZBOT_TOUCH_UI

+ 101
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/filament_menu.cpp View File

@@ -0,0 +1,101 @@
1
+/*********************
2
+ * filament_menu.cpp *
3
+ *********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ANY(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void FilamentMenu::onRedraw(draw_mode_t what) {
34
+  if (what & BACKGROUND) {
35
+    CommandProcessor cmd;
36
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
37
+       .cmd(CLEAR(true,true,true));
38
+  }
39
+
40
+  if (what & FOREGROUND) {
41
+    CommandProcessor cmd;
42
+      cmd.font(font_large)
43
+    #ifdef TOUCH_UI_PORTRAIT
44
+      #define GRID_ROWS 9
45
+      #define GRID_COLS 2
46
+         .text  ( BTN_POS(1,1),      BTN_SIZE(2,1), F("Filament Options:"))
47
+         .font(font_medium).colors(normal_btn)
48
+      #if ENABLED(FILAMENT_RUNOUT_SENSOR)
49
+        .enabled(1)
50
+      #else
51
+        .enabled(0)
52
+      #endif
53
+      .tag(2).button( BTN_POS(1,2),  BTN_SIZE(2,1), F("Runout Sensor"))
54
+      #if ENABLED(LIN_ADVANCE)
55
+        .enabled(1)
56
+      #else
57
+        .enabled(0)
58
+      #endif
59
+      .tag(3).button( BTN_POS(1,3),  BTN_SIZE(2,1), F("Linear Advance"))
60
+      .colors(action_btn)
61
+      .tag(1) .button( BTN_POS(1,9), BTN_SIZE(2,1), F("Back"));
62
+      #undef GRID_COLS
63
+      #undef GRID_ROWS
64
+    #else
65
+      #define GRID_ROWS 6
66
+      #define GRID_COLS 3
67
+         .text  ( BTN_POS(1,1),      BTN_SIZE(3,1), F("Filament Options:"))
68
+         .font(font_medium).colors(normal_btn)
69
+      #if ENABLED(FILAMENT_RUNOUT_SENSOR)
70
+        .enabled(1)
71
+      #else
72
+        .enabled(0)
73
+      #endif
74
+      .tag(2).button( BTN_POS(1,2),  BTN_SIZE(3,1), F("Filament Runout"))
75
+      #if ENABLED(LIN_ADVANCE)
76
+        .enabled(1)
77
+      #else
78
+        .enabled(0)
79
+      #endif
80
+      .tag(3).button( BTN_POS(1,3),  BTN_SIZE(3,1), F("Linear Advance"))
81
+      .colors(action_btn)
82
+      .tag(1) .button( BTN_POS(1,6), BTN_SIZE(3,1), F("Back"));
83
+    #endif
84
+  }
85
+}
86
+
87
+bool FilamentMenu::onTouchEnd(uint8_t tag) {
88
+  switch (tag) {
89
+    case 1: GOTO_PREVIOUS();                   break;
90
+    #if ENABLED(FILAMENT_RUNOUT_SENSOR)
91
+    case 2: GOTO_SCREEN(FilamentRunoutScreen); break;
92
+    #endif
93
+    #if ENABLED(LIN_ADVANCE)
94
+    case 3: GOTO_SCREEN(LinearAdvanceScreen);  break;
95
+    #endif
96
+    default: return false;
97
+  }
98
+  return true;
99
+}
100
+
101
+#endif // LULZBOT_TOUCH_UI

+ 65
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/filament_runout_screen.cpp View File

@@ -0,0 +1,65 @@
1
+/******************************
2
+ * filament_runout_screen.cpp *
3
+ ******************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(FILAMENT_RUNOUT_SENSOR)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void FilamentRunoutScreen::onRedraw(draw_mode_t what) {
34
+  widgets_t w(what);
35
+  w.heading(   PSTR("Runout Detection:"));
36
+  w.toggle( 2, PSTR("Filament Sensor:"), PSTR("off\xFFon"), getFilamentRunoutEnabled());
37
+
38
+  #ifdef FILAMENT_RUNOUT_DISTANCE_MM
39
+    w.heading(PSTR("Detection Threshold:"));
40
+    w.units(PSTR("mm"));
41
+    w.precision(0);
42
+    w.color(e_axis);
43
+    w.adjuster( 10, PSTR("Distance:"), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled());
44
+    w.increments();
45
+  #endif
46
+}
47
+
48
+bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) {
49
+  using namespace ExtUI;
50
+  const float increment = getIncrement();
51
+  switch (tag) {
52
+    case 2: setFilamentRunoutEnabled(!getFilamentRunoutEnabled()); break;
53
+    #ifdef FILAMENT_RUNOUT_DISTANCE_MM
54
+      case  10: UI_DECREMENT(FilamentRunoutDistance_mm); break;
55
+      case  11: UI_INCREMENT(FilamentRunoutDistance_mm); break;
56
+    #endif
57
+    default:
58
+      return false;
59
+  }
60
+
61
+  SaveSettingsDialogBox::settingsChanged();
62
+  return true;
63
+}
64
+
65
+#endif // LULZBOT_TOUCH_UI

+ 264
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/files_screen.cpp View File

@@ -0,0 +1,264 @@
1
+/********************
2
+ * files_screen.cpp *
3
+ ********************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+using namespace ExtUI;
32
+using namespace Theme;
33
+
34
+void FilesScreen::onEntry() {
35
+  screen_data.FilesScreen.cur_page        = 0;
36
+  screen_data.FilesScreen.selected_tag    = 0xFF;
37
+  #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
38
+    CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP);
39
+  #endif
40
+  gotoPage(0);
41
+  BaseScreen::onEntry();
42
+}
43
+
44
+const char *FilesScreen::getSelectedShortFilename() {
45
+  FileList files;
46
+  files.seek(getFileForTag(screen_data.FilesScreen.selected_tag), true);
47
+  return files.shortFilename();
48
+}
49
+
50
+const char *FilesScreen::getSelectedLongFilename() {
51
+  FileList files;
52
+  files.seek(getFileForTag(screen_data.FilesScreen.selected_tag), true);
53
+  return files.longFilename();
54
+}
55
+
56
+void FilesScreen::drawSelectedFile() {
57
+  FileList files;
58
+  files.seek(getFileForTag(screen_data.FilesScreen.selected_tag), true);
59
+  screen_data.FilesScreen.flags.is_dir = files.isDir();
60
+  drawFileButton(
61
+    files.filename(),
62
+    screen_data.FilesScreen.selected_tag,
63
+    screen_data.FilesScreen.flags.is_dir,
64
+    true
65
+  );
66
+}
67
+
68
+uint16_t FilesScreen::getFileForTag(uint8_t tag) {
69
+  return screen_data.FilesScreen.cur_page * files_per_page + tag - 2;
70
+}
71
+
72
+#ifdef TOUCH_UI_PORTRAIT
73
+  #define GRID_COLS  6
74
+  #define GRID_ROWS (files_per_page + header_h + footer_h)
75
+#else
76
+  #define GRID_COLS  6
77
+  #define GRID_ROWS (files_per_page + header_h + footer_h)
78
+#endif
79
+
80
+void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, bool is_highlighted) {
81
+  const uint8_t line = getLineForTag(tag)+1;
82
+  CommandProcessor cmd;
83
+  cmd.tag(tag);
84
+  cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color));
85
+  cmd.font(font_medium)
86
+     .rectangle( 0, BTN_Y(header_h+line), display_width, BTN_H(1));
87
+  cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled));
88
+  #if ENABLED(SCROLL_LONG_FILENAMES)
89
+    if (is_highlighted) {
90
+      cmd.cmd(SAVE_CONTEXT());
91
+      cmd.cmd(MACRO(0));
92
+    }
93
+  #endif
94
+  cmd.text  (BTN_POS(1,header_h+line), BTN_SIZE(6,1), filename, OPT_CENTERY);
95
+  if (is_dir) {
96
+    cmd.text(BTN_POS(1,header_h+line), BTN_SIZE(6,1), F("> "),  OPT_CENTERY | OPT_RIGHTX);
97
+  }
98
+  #if ENABLED(SCROLL_LONG_FILENAMES)
99
+    if (is_highlighted) {
100
+      cmd.cmd(RESTORE_CONTEXT());
101
+    }
102
+  #endif
103
+}
104
+
105
+void FilesScreen::drawFileList() {
106
+  FileList files;
107
+  screen_data.FilesScreen.num_page = max(1,(ceil)(float(files.count()) / files_per_page));
108
+  screen_data.FilesScreen.cur_page = min(screen_data.FilesScreen.cur_page, screen_data.FilesScreen.num_page-1);
109
+  screen_data.FilesScreen.flags.is_root  = files.isAtRootDir();
110
+
111
+  #undef MARGIN_T
112
+  #undef MARGIN_B
113
+  #define MARGIN_T 0
114
+  #define MARGIN_B 0
115
+  uint16_t fileIndex = screen_data.FilesScreen.cur_page * files_per_page;
116
+  for(uint8_t i = 0; i < files_per_page; i++, fileIndex++) {
117
+    if (files.seek(fileIndex)) {
118
+      drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false);
119
+    } else {
120
+      break;
121
+    }
122
+  }
123
+}
124
+
125
+void FilesScreen::drawHeader() {
126
+  const bool prev_enabled = screen_data.FilesScreen.cur_page > 0;
127
+  const bool next_enabled = screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page - 1);
128
+
129
+  #undef MARGIN_T
130
+  #undef MARGIN_B
131
+  #define MARGIN_T 0
132
+  #define MARGIN_B 2
133
+
134
+  char str[16];
135
+  sprintf_P(str, PSTR("Page %d of %d"),
136
+    screen_data.FilesScreen.cur_page + 1, screen_data.FilesScreen.num_page);
137
+
138
+
139
+  CommandProcessor cmd;
140
+  cmd.colors(normal_btn)
141
+     .font(font_small)
142
+     .tag(0).button( BTN_POS(2,1), BTN_SIZE(4,header_h), str, OPT_CENTER | OPT_FLAT)
143
+     .font(font_medium)
144
+     .colors(action_btn)
145
+     .tag(241).enabled(prev_enabled).button( BTN_POS(1,1), BTN_SIZE(1,header_h), F("<"))
146
+     .tag(242).enabled(next_enabled).button( BTN_POS(6,1), BTN_SIZE(1,header_h), F(">"));
147
+}
148
+
149
+void FilesScreen::drawFooter() {
150
+  #undef MARGIN_T
151
+  #undef MARGIN_B
152
+  #ifdef TOUCH_UI_PORTRAIT
153
+  #define MARGIN_T 15
154
+  #define MARGIN_B 5
155
+  #else
156
+  #define MARGIN_T 5
157
+  #define MARGIN_B 5
158
+  #endif
159
+  const bool    has_selection = screen_data.FilesScreen.selected_tag != 0xFF;
160
+  const uint8_t back_tag      = screen_data.FilesScreen.flags.is_root ? 240 : 245;
161
+  const uint8_t y             = GRID_ROWS - footer_h + 1;
162
+  const uint8_t h             = footer_h;
163
+
164
+  CommandProcessor cmd;
165
+  cmd.colors(normal_btn)
166
+     .font(font_medium)
167
+     .colors(has_selection ? normal_btn : action_btn)
168
+     .tag(back_tag).button( BTN_POS(4,y), BTN_SIZE(3,h), F("Back"))
169
+     .enabled(has_selection)
170
+     .colors(has_selection ? action_btn : normal_btn);
171
+  if (screen_data.FilesScreen.flags.is_dir) {
172
+    cmd.tag(244).button( BTN_POS(1, y), BTN_SIZE(3,h), F("Open"));
173
+  } else {
174
+    cmd.tag(243).button( BTN_POS(1, y), BTN_SIZE(3,h), F("Print"));
175
+  }
176
+}
177
+
178
+void FilesScreen::onRedraw(draw_mode_t what) {
179
+  if (what & FOREGROUND) {
180
+    drawHeader();
181
+    drawSelectedFile();
182
+    drawFooter();
183
+  }
184
+}
185
+
186
+void FilesScreen::gotoPage(uint8_t page) {
187
+  screen_data.FilesScreen.selected_tag = 0xFF;
188
+  screen_data.FilesScreen.cur_page     = page;
189
+  CommandProcessor cmd;
190
+  cmd.cmd(CMD_DLSTART)
191
+     .cmd(CLEAR_COLOR_RGB(bg_color))
192
+     .cmd(CLEAR(true,true,true))
193
+     .colors(normal_btn);
194
+  drawFileList();
195
+  storeBackground();
196
+}
197
+
198
+bool FilesScreen::onTouchEnd(uint8_t tag) {
199
+  switch (tag) {
200
+    case 240: GOTO_PREVIOUS();                  return true;
201
+    case 241:
202
+      if (screen_data.FilesScreen.cur_page > 0) {
203
+        gotoPage(screen_data.FilesScreen.cur_page-1);
204
+      }
205
+      break;
206
+    case 242:
207
+      if (screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page-1)) {
208
+        gotoPage(screen_data.FilesScreen.cur_page+1);
209
+      }
210
+      break;
211
+    case 243:
212
+      printFile(getSelectedShortFilename());
213
+      StatusScreen::setStatusMessage(F("Print Starting"));
214
+      GOTO_SCREEN(StatusScreen);
215
+      return true;
216
+    case 244:
217
+      {
218
+        FileList files;
219
+        files.changeDir(getSelectedShortFilename());
220
+        gotoPage(0);
221
+      }
222
+      break;
223
+    case 245:
224
+      {
225
+        FileList files;
226
+        files.upDir();
227
+        gotoPage(0);
228
+      }
229
+      break;
230
+    default:
231
+      if (tag < 240) {
232
+        screen_data.FilesScreen.selected_tag = tag;
233
+        #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
234
+          if (FTDI::ftdi_chip >= 810) {
235
+            const char *longFilename = getSelectedLongFilename();
236
+            if (longFilename[0]) {
237
+              CLCD::FontMetrics fm(font_medium);
238
+              uint16_t text_width = fm.get_text_width(longFilename);
239
+              screen_data.FilesScreen.scroll_pos = 0;
240
+              if (text_width > display_width)
241
+                screen_data.FilesScreen.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R;
242
+              else
243
+                screen_data.FilesScreen.scroll_max = 0;
244
+            }
245
+          }
246
+        #endif
247
+      }
248
+      break;
249
+  }
250
+  return true;
251
+}
252
+
253
+void FilesScreen::onIdle() {
254
+  #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
255
+    if (FTDI::ftdi_chip >= 810) {
256
+      CLCD::mem_write_32(CLCD::REG::MACRO_0,
257
+        VERTEX_TRANSLATE_X(-int32_t(screen_data.FilesScreen.scroll_pos)));
258
+      if (screen_data.FilesScreen.scroll_pos < screen_data.FilesScreen.scroll_max * 16)
259
+        screen_data.FilesScreen.scroll_pos++;
260
+    }
261
+  #endif
262
+}
263
+
264
+#endif // LULZBOT_TOUCH_UI

+ 285
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/interface_settings_screen.cpp View File

@@ -0,0 +1,285 @@
1
+/*********************************
2
+ * interface_settings_screen.cpp *
3
+ *********************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+#include "../archim2-flash/flash_storage.h"
31
+
32
+#include "../../../../../module/configuration_store.h"
33
+
34
+#if ENABLED(LULZBOT_PRINTCOUNTER)
35
+  #include "../../../../../module/printcounter.h"
36
+#endif
37
+
38
+bool restoreEEPROM();
39
+
40
+using namespace FTDI;
41
+using namespace ExtUI;
42
+using namespace Theme;
43
+
44
+constexpr bool PERSISTENT_STORE_SUCCESS = false; // persistentStore uses true for error
45
+
46
+void InterfaceSettingsScreen::onStartup() {
47
+}
48
+
49
+void InterfaceSettingsScreen::onEntry() {
50
+  screen_data.InterfaceSettingsScreen.brightness = CLCD::get_brightness();
51
+  screen_data.InterfaceSettingsScreen.volume     = SoundPlayer::get_volume();
52
+  BaseScreen::onEntry();
53
+}
54
+
55
+void InterfaceSettingsScreen::onRedraw(draw_mode_t what) {
56
+  CommandProcessor cmd;
57
+
58
+  if (what & BACKGROUND) {
59
+
60
+    #define GRID_COLS 4
61
+    #ifdef TOUCH_UI_PORTRAIT
62
+      #define GRID_ROWS 7
63
+    #else
64
+      #define GRID_ROWS 6
65
+    #endif
66
+
67
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
68
+       .cmd(CLEAR(true,true,true))
69
+       .cmd(COLOR_RGB(bg_text_enabled))
70
+       .tag(0)
71
+       .font(font_medium)
72
+       .text(BTN_POS(1,1), BTN_SIZE(4,1), F("Interface Settings"))
73
+    #undef EDGE_R
74
+    #define EDGE_R 30
75
+       .font(font_small)
76
+       .tag(0)
77
+       .text(BTN_POS(1,2), BTN_SIZE(2,1), F("LCD brightness:"), OPT_RIGHTX | OPT_CENTERY)
78
+       .text(BTN_POS(1,3), BTN_SIZE(2,1), F("Sound volume:"),   OPT_RIGHTX | OPT_CENTERY)
79
+       .text(BTN_POS(1,4), BTN_SIZE(2,1), F("Screen lock:"),    OPT_RIGHTX | OPT_CENTERY);
80
+    cmd.text(BTN_POS(1,5), BTN_SIZE(2,1), F("Boot screen:"),    OPT_RIGHTX | OPT_CENTERY);
81
+    #undef EDGE_R
82
+  }
83
+
84
+  if (what & FOREGROUND) {
85
+    #ifdef TOUCH_UI_PORTRAIT
86
+      constexpr uint8_t w = 2;
87
+    #else
88
+      constexpr uint8_t w = 1;
89
+    #endif
90
+
91
+    cmd.font(font_medium)
92
+    #define EDGE_R 30
93
+       .colors(ui_slider)
94
+       .tag(2).slider(BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettingsScreen.brightness, 128)
95
+       .tag(3).slider(BTN_POS(3,3), BTN_SIZE(2,1), screen_data.InterfaceSettingsScreen.volume,     0xFF)
96
+       .colors(ui_toggle)
97
+       .tag(4).toggle(BTN_POS(3,4), BTN_SIZE(w,1), F("off\xFFon"), LockScreen::is_enabled())
98
+       .tag(5).toggle(BTN_POS(3,5), BTN_SIZE(w,1), F("off\xFFon"), UIData::animations_enabled())
99
+    #undef EDGE_R
100
+    #define EDGE_R 0
101
+    #ifdef TOUCH_UI_PORTRAIT
102
+       .colors(normal_btn)
103
+       .tag(6).button (BTN_POS(1,6), BTN_SIZE(4,1), F("Customize Sounds"))
104
+       .colors(action_btn)
105
+       .tag(1).button (BTN_POS(1,7), BTN_SIZE(4,1), F("Back"));
106
+    #else
107
+       .tag(6).button (BTN_POS(1,6), BTN_SIZE(2,1), F("Customize Sounds"))
108
+       .colors(action_btn)
109
+       .tag(1).button (BTN_POS(3,6), BTN_SIZE(2,1), F("Back"));
110
+    #endif
111
+  }
112
+}
113
+
114
+bool InterfaceSettingsScreen::onTouchEnd(uint8_t tag) {
115
+  switch (tag) {
116
+    case 1: GOTO_PREVIOUS(); return true;
117
+    case 4:
118
+      if (!LockScreen::is_enabled())
119
+        LockScreen::enable();
120
+      else
121
+        LockScreen::disable();
122
+      break;
123
+    case 5: UIData::enable_animations(!UIData::animations_enabled());; break;
124
+    case 6: GOTO_SCREEN(InterfaceSoundsScreen); return true;
125
+    default:
126
+      return false;
127
+  }
128
+  SaveSettingsDialogBox::settingsChanged();
129
+  return true;
130
+}
131
+
132
+bool InterfaceSettingsScreen::onTouchStart(uint8_t tag) {
133
+  #undef EDGE_R
134
+  #define EDGE_R 30
135
+  CommandProcessor cmd;
136
+  switch (tag) {
137
+    case 2: cmd.track_linear(BTN_POS(3,3), BTN_SIZE(2,1), 2).execute(); break;
138
+    case 3: cmd.track_linear(BTN_POS(3,4), BTN_SIZE(2,1), 3).execute(); break;
139
+    default: break;
140
+  }
141
+  #undef EDGE_R
142
+  #define EDGE_R 0
143
+  #undef GRID_COLS
144
+  #undef GRID_ROWS
145
+  return true;
146
+}
147
+
148
+void InterfaceSettingsScreen::onIdle() {
149
+  if (refresh_timer.elapsed(TOUCH_UPDATE_INTERVAL)) {
150
+    refresh_timer.start();
151
+
152
+    uint16_t value;
153
+    CommandProcessor cmd;
154
+    switch (cmd.track_tag(value)) {
155
+      case 2:
156
+        screen_data.InterfaceSettingsScreen.brightness = float(value) * 128 / 0xFFFF;
157
+        CLCD::set_brightness(screen_data.InterfaceSettingsScreen.brightness);
158
+        SaveSettingsDialogBox::settingsChanged();
159
+        break;
160
+      case 3:
161
+        screen_data.InterfaceSettingsScreen.volume = value >> 8;
162
+        SoundPlayer::set_volume(screen_data.InterfaceSettingsScreen.volume);
163
+        SaveSettingsDialogBox::settingsChanged();
164
+        break;
165
+      default:
166
+        return;
167
+    }
168
+    onRefresh();
169
+  }
170
+  BaseScreen::onIdle();
171
+}
172
+
173
+void InterfaceSettingsScreen::failSafeSettings() {
174
+  // Reset settings that may make the printer interface
175
+  // unusable.
176
+  CLCD::mem_write_32(CLCD::REG::ROTATE, 0);
177
+  CLCD::default_touch_transform();
178
+  CLCD::default_display_orientation();
179
+  CLCD::set_brightness(255);
180
+  UIData::reset_persistent_data();
181
+  CLCD::mem_write_16(CLCD::REG::HOFFSET, FTDI::Hoffset);
182
+  CLCD::mem_write_16(CLCD::REG::VOFFSET, FTDI::Voffset);
183
+}
184
+
185
+void InterfaceSettingsScreen::defaultSettings() {
186
+  LockScreen::passcode = 0;
187
+  SoundPlayer::set_volume(255);
188
+  CLCD::set_brightness(255);
189
+  UIData::reset_persistent_data();
190
+  InterfaceSoundsScreen::defaultSettings();
191
+  CLCD::mem_write_16(CLCD::REG::HOFFSET, FTDI::Hoffset);
192
+  CLCD::mem_write_16(CLCD::REG::VOFFSET, FTDI::Voffset);
193
+}
194
+
195
+void InterfaceSettingsScreen::saveSettings(char *buff) {
196
+  static_assert(
197
+    ExtUI::eeprom_data_size >= sizeof(persistent_data_t),
198
+    "Insufficient space in EEPROM for UI parameters"
199
+  );
200
+
201
+  SERIAL_ECHOLNPGM("Writing setting to EEPROM");
202
+
203
+  persistent_data_t eeprom;
204
+
205
+  eeprom.passcode             = LockScreen::passcode;
206
+  eeprom.sound_volume         = SoundPlayer::get_volume();
207
+  eeprom.display_brightness   = CLCD::get_brightness();
208
+  eeprom.bit_flags            = UIData::get_persistent_data();
209
+  eeprom.touch_transform_a    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_A);
210
+  eeprom.touch_transform_b    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_B);
211
+  eeprom.touch_transform_c    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_C);
212
+  eeprom.touch_transform_d    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_D);
213
+  eeprom.touch_transform_e    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_E);
214
+  eeprom.touch_transform_f    = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_F);
215
+  eeprom.display_h_offset_adj = CLCD::mem_read_16(CLCD::REG::HOFFSET) - FTDI::Hoffset;
216
+  eeprom.display_v_offset_adj = CLCD::mem_read_16(CLCD::REG::VOFFSET) - FTDI::Voffset;
217
+  for(uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++)
218
+    eeprom.event_sounds[i] = InterfaceSoundsScreen::event_sounds[i];
219
+
220
+  memcpy(buff, &eeprom, sizeof(eeprom));
221
+}
222
+
223
+void InterfaceSettingsScreen::loadSettings(const char *buff) {
224
+  static_assert(
225
+    ExtUI::eeprom_data_size >= sizeof(persistent_data_t),
226
+    "Insufficient space in EEPROM for UI parameters"
227
+  );
228
+
229
+  persistent_data_t eeprom;
230
+  memcpy(&eeprom, buff, sizeof(eeprom));
231
+
232
+  SERIAL_ECHOLNPGM("Loading setting from EEPROM");
233
+
234
+  LockScreen::passcode = eeprom.passcode;
235
+  SoundPlayer::set_volume(eeprom.sound_volume);
236
+  UIData::set_persistent_data(eeprom.bit_flags);
237
+  CLCD::set_brightness(eeprom.display_brightness);
238
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_A, eeprom.touch_transform_a);
239
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_B, eeprom.touch_transform_b);
240
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_C, eeprom.touch_transform_c);
241
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_D, eeprom.touch_transform_d);
242
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_E, eeprom.touch_transform_e);
243
+  CLCD::mem_write_32(CLCD::REG::TOUCH_TRANSFORM_F, eeprom.touch_transform_f);
244
+  CLCD::mem_write_16(CLCD::REG::HOFFSET,           eeprom.display_h_offset_adj + FTDI::Hoffset);
245
+  CLCD::mem_write_16(CLCD::REG::VOFFSET,           eeprom.display_v_offset_adj + FTDI::Voffset);
246
+  for(uint8_t i = 0; i < InterfaceSoundsScreen::NUM_EVENTS; i++)
247
+    InterfaceSoundsScreen::event_sounds[i] = eeprom.event_sounds[i];
248
+
249
+  #if ENABLED(DEVELOPER_SCREENS)
250
+    StressTestScreen::startupCheck();
251
+  #endif
252
+}
253
+
254
+#ifdef LULZBOT_EEPROM_BACKUP_SIZE
255
+  #include "../../../../../HAL/shared/persistent_store_api.h"
256
+
257
+  bool restoreEEPROM() {
258
+    uint8_t data[LULZBOT_EEPROM_BACKUP_SIZE];
259
+
260
+    bool success = UIFlashStorage::read_config_data(data, LULZBOT_EEPROM_BACKUP_SIZE);
261
+
262
+    if (success)
263
+      success = persistentStore.write_data(0, data, LULZBOT_EEPROM_BACKUP_SIZE) == PERSISTENT_STORE_SUCCESS;
264
+
265
+    if (success)
266
+      StatusScreen::setStatusMessage(F("Settings restored from backup"));
267
+    else
268
+      StatusScreen::setStatusMessage(F("Settings restored to default"));
269
+
270
+    return success;
271
+  }
272
+
273
+  bool InterfaceSettingsScreen::backupEEPROM() {
274
+    uint8_t data[LULZBOT_EEPROM_BACKUP_SIZE];
275
+
276
+    if (persistentStore.read_data(0, data, LULZBOT_EEPROM_BACKUP_SIZE) != PERSISTENT_STORE_SUCCESS)
277
+      return false;
278
+
279
+    UIFlashStorage::write_config_data(data, LULZBOT_EEPROM_BACKUP_SIZE);
280
+
281
+    return true;
282
+  }
283
+#endif
284
+
285
+#endif // LULZBOT_TOUCH_UI

+ 160
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/interface_sounds_screen.cpp View File

@@ -0,0 +1,160 @@
1
+/*******************************
2
+ * interface_sounds_screen.cpp *
3
+ *******************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+using namespace Theme;
32
+using namespace ExtUI;
33
+
34
+uint8_t InterfaceSoundsScreen::event_sounds[];
35
+
36
+const char* InterfaceSoundsScreen::getSoundSelection(event_t event) {
37
+  return SoundList::name(event_sounds[event]);
38
+}
39
+
40
+void InterfaceSoundsScreen::toggleSoundSelection(event_t event) {
41
+  event_sounds[event] = (event_sounds[event]+1) % SoundList::n;
42
+  playEventSound(event);
43
+}
44
+
45
+void InterfaceSoundsScreen::setSoundSelection(event_t event, const SoundPlayer::sound_t* sound) {
46
+  for(uint8_t i = 0; i < SoundList::n; i++)
47
+    if (SoundList::data(i) == sound)
48
+      event_sounds[event] = i;
49
+}
50
+
51
+void InterfaceSoundsScreen::playEventSound(event_t event, play_mode_t mode) {
52
+  sound.play(SoundList::data(event_sounds[event]), mode);
53
+}
54
+
55
+void InterfaceSoundsScreen::defaultSettings() {
56
+  setSoundSelection(PRINTING_STARTED,  twinkle);
57
+  setSoundSelection(PRINTING_FINISHED, fanfare);
58
+  setSoundSelection(PRINTING_FAILED,   sad_trombone);
59
+}
60
+
61
+void InterfaceSoundsScreen::onRedraw(draw_mode_t what) {
62
+  CommandProcessor cmd;
63
+
64
+  if (what & BACKGROUND) {
65
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
66
+       .cmd(CLEAR(true,true,true))
67
+       .cmd(COLOR_RGB(bg_text_enabled))
68
+       .tag(0)
69
+
70
+    #define GRID_COLS 4
71
+    #define GRID_ROWS 9
72
+
73
+       .font(font_medium)
74
+       .text(BTN_POS(1,1), BTN_SIZE(4,1), F("Interface Sounds"))
75
+    #undef EDGE_R
76
+    #define EDGE_R 30
77
+       .font(font_small)
78
+       .tag(0).text      (BTN_POS(1,2), BTN_SIZE(2,1), F("Sound volume:"),   OPT_RIGHTX | OPT_CENTERY)
79
+              .text      (BTN_POS(1,3), BTN_SIZE(2,1), F("Click sounds:"),   OPT_RIGHTX | OPT_CENTERY)
80
+              .text      (BTN_POS(1,5), BTN_SIZE(2,1), F("Print starting:"), OPT_RIGHTX | OPT_CENTERY)
81
+              .text      (BTN_POS(1,6), BTN_SIZE(2,1), F("Print finished:"), OPT_RIGHTX | OPT_CENTERY)
82
+              .text      (BTN_POS(1,7), BTN_SIZE(2,1), F("Print error:"),    OPT_RIGHTX | OPT_CENTERY);
83
+    #undef EDGE_R
84
+  }
85
+
86
+  if (what & FOREGROUND) {
87
+    #ifdef TOUCH_UI_PORTRAIT
88
+      constexpr uint8_t w = 2;
89
+    #else
90
+      constexpr uint8_t w = 1;
91
+    #endif
92
+
93
+    cmd.font(font_medium)
94
+       .colors(ui_slider)
95
+    #define EDGE_R 30
96
+       .tag(2).slider    (BTN_POS(3,2), BTN_SIZE(2,1), screen_data.InterfaceSettingsScreen.volume, 0xFF)
97
+       .colors(ui_toggle)
98
+       .tag(3).toggle    (BTN_POS(3,3), BTN_SIZE(w,1), F("off\xFFon"), UIData::touch_sounds_enabled())
99
+    #undef EDGE_R
100
+       .colors(normal_btn)
101
+    #define EDGE_R 0
102
+       .tag(4).button    (BTN_POS(3,5), BTN_SIZE(2,1), getSoundSelection(PRINTING_STARTED))
103
+       .tag(5).button    (BTN_POS(3,6), BTN_SIZE(2,1), getSoundSelection(PRINTING_FINISHED))
104
+       .tag(6).button    (BTN_POS(3,7), BTN_SIZE(2,1), getSoundSelection(PRINTING_FAILED))
105
+       .colors(action_btn)
106
+       .tag(1).button    (BTN_POS(1,9), BTN_SIZE(4,1), F("Back"));
107
+  }
108
+}
109
+
110
+void InterfaceSoundsScreen::onEntry() {
111
+  screen_data.InterfaceSettingsScreen.volume = SoundPlayer::get_volume();
112
+  BaseScreen::onEntry();
113
+}
114
+
115
+bool InterfaceSoundsScreen::onTouchEnd(uint8_t tag) {
116
+  switch (tag) {
117
+    case 1: GOTO_PREVIOUS();                                              return true;
118
+    case 3: UIData::enable_touch_sounds(!UIData::touch_sounds_enabled()); break;
119
+    case 4: toggleSoundSelection(PRINTING_STARTED);                       break;
120
+    case 5: toggleSoundSelection(PRINTING_FINISHED);                      break;
121
+    case 6: toggleSoundSelection(PRINTING_FAILED);                        break;
122
+    default:
123
+      return false;
124
+  }
125
+  SaveSettingsDialogBox::settingsChanged();
126
+  return true;
127
+}
128
+
129
+bool InterfaceSoundsScreen::onTouchStart(uint8_t tag) {
130
+  CommandProcessor cmd;
131
+  #undef EDGE_R
132
+  #define EDGE_R 30
133
+  switch (tag) {
134
+    case 2: cmd.track_linear(BTN_POS(3,2), BTN_SIZE(2,1), 2).execute(); break;
135
+    default: break;
136
+  }
137
+  return true;
138
+}
139
+
140
+void InterfaceSoundsScreen::onIdle() {
141
+  if (refresh_timer.elapsed(TOUCH_UPDATE_INTERVAL)) {
142
+    refresh_timer.start();
143
+
144
+    uint16_t value;
145
+    CommandProcessor cmd;
146
+    switch (cmd.track_tag(value)) {
147
+      case 2:
148
+        screen_data.InterfaceSettingsScreen.volume = value >> 8;
149
+        SoundPlayer::set_volume(screen_data.InterfaceSettingsScreen.volume);
150
+        SaveSettingsDialogBox::settingsChanged();
151
+        break;
152
+      default:
153
+        return;
154
+    }
155
+    onRefresh();
156
+  }
157
+  BaseScreen::onIdle();
158
+}
159
+
160
+#endif // LULZBOT_TOUCH_UI

+ 65
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/jerk_screen.cpp View File

@@ -0,0 +1,65 @@
1
+/*******************
2
+ * jerk_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && DISABLED(JUNCTION_DEVIATION)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void JerkScreen::onRedraw(draw_mode_t what) {
34
+
35
+  widgets_t w(what);
36
+  w.precision(1);
37
+  w.units(PSTR("mm/s"));
38
+  w.heading(                           PSTR("Maximum Jerk"));
39
+  w.color(x_axis) .adjuster( 2, PSTR("X:"), getAxisMaxJerk_mm_s(X) );
40
+  w.color(y_axis) .adjuster( 4, PSTR("Y:"), getAxisMaxJerk_mm_s(Y) );
41
+  w.color(z_axis) .adjuster( 6, PSTR("Z:"), getAxisMaxJerk_mm_s(Z) );
42
+  w.color(e_axis) .adjuster( 8, PSTR("E:"), getAxisMaxJerk_mm_s(E0) );
43
+  w.increments();
44
+}
45
+
46
+bool JerkScreen::onTouchHeld(uint8_t tag) {
47
+  using namespace ExtUI;
48
+  const float increment = getIncrement();
49
+  switch (tag) {
50
+    case  2: UI_DECREMENT(AxisMaxJerk_mm_s, X); break;
51
+    case  3: UI_INCREMENT(AxisMaxJerk_mm_s, X); break;
52
+    case  4: UI_DECREMENT(AxisMaxJerk_mm_s, Y); break;
53
+    case  5: UI_INCREMENT(AxisMaxJerk_mm_s, Y); break;
54
+    case  6: UI_DECREMENT(AxisMaxJerk_mm_s, Z); break;
55
+    case  7: UI_INCREMENT(AxisMaxJerk_mm_s, Z); break;
56
+    case  8: UI_DECREMENT(AxisMaxJerk_mm_s, E0); break;
57
+    case  9: UI_INCREMENT(AxisMaxJerk_mm_s, E0); break;
58
+    default:
59
+      return false;
60
+  }
61
+  SaveSettingsDialogBox::settingsChanged();
62
+  return true;
63
+}
64
+
65
+#endif // LULZBOT_TOUCH_UI

+ 54
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/junction_deviation_screen.cpp View File

@@ -0,0 +1,54 @@
1
+/*******************
2
+ * boot_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(JUNCTION_DEVIATION)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void JunctionDeviationScreen::onRedraw(draw_mode_t what) {
34
+  widgets_t w(what);
35
+  w.precision(2);
36
+  w.units(PSTR("mm"));
37
+  w.heading(                          PSTR("Junction Deviation"));
38
+  w.color(other) .adjuster( 2, PSTR(""), getJunctionDeviation_mm() );
39
+  w.increments();
40
+}
41
+
42
+bool JunctionDeviationScreen::onTouchHeld(uint8_t tag) {
43
+  const float increment = getIncrement();
44
+  switch (tag) {
45
+    case  2: UI_DECREMENT(JunctionDeviation_mm); break;
46
+    case  3: UI_INCREMENT(JunctionDeviation_mm); break;
47
+    default:
48
+      return false;
49
+  }
50
+  SaveSettingsDialogBox::settingsChanged();
51
+  return true;
52
+}
53
+
54
+#endif // LULZBOT_TOUCH_UI

+ 62
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/kill_screen.cpp View File

@@ -0,0 +1,62 @@
1
+/*******************
2
+ * kill_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+
31
+// The kill screen is an oddball that happens after Marlin has killed the events
32
+// loop. So we only have a show() method rather than onRedraw(). The KillScreen
33
+// should not be used as a model for other UI screens as it is an exception.
34
+
35
+void KillScreen::show(progmem_str message) {
36
+  CommandProcessor cmd;
37
+
38
+  cmd.cmd(CMD_DLSTART)
39
+     .cmd(CLEAR_COLOR_RGB(Theme::bg_color))
40
+     .cmd(CLEAR(true,true,true))
41
+     .tag(0);
42
+
43
+  #define GRID_COLS 4
44
+  #define GRID_ROWS 8
45
+
46
+  cmd.font(Theme::font_large)
47
+     .cmd(COLOR_RGB(Theme::bg_text_enabled))
48
+     .text(BTN_POS(1,2), BTN_SIZE(4,1), message)
49
+     .text(BTN_POS(1,3), BTN_SIZE(4,1), F("PRINTER HALTED"))
50
+     .text(BTN_POS(1,6), BTN_SIZE(4,1), F("Please reset"));
51
+
52
+  #undef GRID_COLS
53
+  #undef GRID_ROWS
54
+
55
+  cmd.cmd(DL::DL_DISPLAY)
56
+     .cmd(CMD_SWAP)
57
+     .execute();
58
+
59
+  InterfaceSoundsScreen::playEventSound(InterfaceSoundsScreen::PRINTING_FAILED, PLAY_SYNCHRONOUS);
60
+}
61
+
62
+#endif // LULZBOT_TOUCH_UI

+ 77
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/linear_advance_screen.cpp View File

@@ -0,0 +1,77 @@
1
+/*****************************
2
+ * linear_advance_screen.cpp *
3
+ *****************************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && ENABLED(LIN_ADVANCE)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace ExtUI;
31
+using namespace Theme;
32
+
33
+void LinearAdvanceScreen::onRedraw(draw_mode_t what) {
34
+  widgets_t w(what);
35
+  w.precision(2, DEFAULT_LOWEST).color(e_axis);
36
+  w.heading(           PSTR("Linear Advance:"));
37
+  #if EXTRUDERS == 1
38
+    w.adjuster(     2, PSTR("K:"),    getLinearAdvance_mm_mm_s(E0) );
39
+  #else
40
+    w.adjuster(     2, PSTR("K E1:"), getLinearAdvance_mm_mm_s(E0) );
41
+    w.adjuster(     4, PSTR("K E2:"), getLinearAdvance_mm_mm_s(E1) );
42
+    #if EXTRUDERS > 2
43
+      w.adjuster(   6, PSTR("K E3:"), getLinearAdvance_mm_mm_s(E2) );
44
+      #if EXTRUDERS > 3
45
+        w.adjuster( 8, PSTR("K E4:"), getLinearAdvance_mm_mm_s(E3) );
46
+      #endif
47
+    #endif
48
+  #endif
49
+  w.increments();
50
+}
51
+
52
+bool LinearAdvanceScreen::onTouchHeld(uint8_t tag) {
53
+  using namespace ExtUI;
54
+  const float increment = getIncrement();
55
+  switch (tag) {
56
+    case  2: UI_DECREMENT(LinearAdvance_mm_mm_s, E0); break;
57
+    case  3: UI_INCREMENT(LinearAdvance_mm_mm_s, E0); break;
58
+    #if EXTRUDERS > 1
59
+      case  4: UI_DECREMENT(LinearAdvance_mm_mm_s, E1);  break;
60
+      case  5: UI_INCREMENT(LinearAdvance_mm_mm_s, E1); break;
61
+      #if EXTRUDERS > 2
62
+        case  6: UI_DECREMENT(LinearAdvance_mm_mm_s, E2);  break;
63
+        case  7: UI_INCREMENT(LinearAdvance_mm_mm_s, E2);  break;
64
+        #if EXTRUDERS > 3
65
+          case  8: UI_DECREMENT(LinearAdvance_mm_mm_s, E3);  break;
66
+          case  9: UI_INCREMENT(LinearAdvance_mm_mm_s, E3);  break;
67
+        #endif
68
+      #endif
69
+    #endif
70
+    default:
71
+      return false;
72
+  }
73
+  SaveSettingsDialogBox::settingsChanged();
74
+  return true;
75
+}
76
+
77
+#endif // LULZBOT_TOUCH_UI

+ 214
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/lock_screen.cpp View File

@@ -0,0 +1,214 @@
1
+/*******************
2
+ * lock_screen.cpp *
3
+ *******************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI)
26
+
27
+#include "screens.h"
28
+#include "screen_data.h"
29
+
30
+using namespace FTDI;
31
+using namespace Theme;
32
+
33
+uint16_t LockScreen::passcode = 0;
34
+
35
+void LockScreen::onEntry() {
36
+  const uint8_t siz = sizeof(screen_data.LockScreen.passcode);
37
+  memset(screen_data.LockScreen.passcode, '_', siz-1);
38
+  screen_data.LockScreen.passcode[siz-1] = '\0';
39
+  BaseScreen::onEntry();
40
+}
41
+
42
+void LockScreen::onRedraw(draw_mode_t what) {
43
+  CommandProcessor cmd;
44
+
45
+  if (what & BACKGROUND) {
46
+    cmd.cmd(CLEAR_COLOR_RGB(bg_color))
47
+       .cmd(CLEAR(true,true,true))
48
+       .tag(0);
49
+  }
50
+
51
+  if (what & FOREGROUND) {
52
+    #ifdef TOUCH_UI_PORTRAIT
53
+      #define GRID_COLS 1
54
+      #define GRID_ROWS 10
55
+    #else
56
+      #define GRID_COLS 1
57
+      #define GRID_ROWS 7
58
+    #endif
59
+
60
+    #undef MARGIN_T
61
+    #undef MARGIN_B
62
+    #define MARGIN_T 3
63
+    #define MARGIN_B 3
64
+
65
+    progmem_str message;
66
+    switch (message_style()) {
67
+      case 'w':
68
+        message = F("Wrong passcode!");
69
+        break;
70
+      case 'g':
71
+        message = F("Passcode accepted!");
72
+        break;
73
+      default:
74
+        if (passcode == 0) {
75
+          message = F("Select Passcode:");
76
+        } else {
77
+          message = F("Enter Passcode:");
78
+        }
79
+    }
80
+    message_style() = '\0'; // Terminate the string.
81
+
82
+    #ifdef TOUCH_UI_PORTRAIT
83
+      constexpr uint8_t l = 6;
84
+    #else
85
+      constexpr uint8_t l = 3;
86
+    #endif
87
+
88
+    const uint8_t pressed = EventLoop::get_pressed_tag();
89
+
90
+    cmd.font(font_large)
91
+       .cmd(COLOR_RGB(bg_text_enabled))
92
+       #ifdef TOUCH_UI_PORTRAIT
93
+       .text(BTN_POS(1,2), BTN_SIZE(1,1), message)
94
+       .font(font_xlarge)
95
+       .text(BTN_POS(1,4), BTN_SIZE(1,1), screen_data.LockScreen.passcode)
96
+       #else
97
+       .text(BTN_POS(1,1), BTN_SIZE(1,1), message)
98
+       .font(font_xlarge)
99
+       .text(BTN_POS(1,2), BTN_SIZE(1,1), screen_data.LockScreen.passcode)
100
+       #endif
101
+       .font(font_large)
102
+       .colors(normal_btn)
103
+       #ifdef TOUCH_UI_PASSCODE
104
+       .keys(BTN_POS(1,l+1), BTN_SIZE(1,1), F("123"),        pressed)
105
+       .keys(BTN_POS(1,l+2), BTN_SIZE(1,1), F("456"),        pressed)
106
+       .keys(BTN_POS(1,l+3), BTN_SIZE(1,1), F("789"),        pressed)
107
+       .keys(BTN_POS(1,l+4), BTN_SIZE(1,1), F("0.<"),        pressed);
108
+       #else
109
+       .keys(BTN_POS(1,l+1), BTN_SIZE(1,1), F("1234567890"), pressed)
110
+       .keys(BTN_POS(1,l+2), BTN_SIZE(1,1), F("qwertyuiop"), pressed)
111
+       .keys(BTN_POS(1,l+3), BTN_SIZE(1,1), F("asdfghjkl "), pressed)
112
+       .keys(BTN_POS(1,l+4), BTN_SIZE(1,1), F("zxcvbnm!?<"), pressed);
113
+       #endif
114
+
115
+    #undef MARGIN_T
116
+    #undef MARGIN_B
117
+    #define MARGIN_T MARGIN_DEFAULT
118
+    #define MARGIN_B MARGIN_DEFAULT
119
+
120
+    #undef GRID_COLS
121
+    #undef GRID_ROWS
122
+  }
123
+}
124
+
125
+char &LockScreen::message_style() {
126
+  // We use the last byte of the passcode string as a flag to indicate,
127
+  // which message to show.
128
+  constexpr uint8_t last_char = sizeof(screen_data.LockScreen.passcode)-1;
129
+  return screen_data.LockScreen.passcode[last_char];
130
+}
131
+
132
+void LockScreen::onPasscodeEntered() {
133
+  if (passcode == 0) {
134
+    // We are defining a passcode
135
+    message_style() = 0;
136
+    onRefresh();
137
+    sound.play(twinkle, PLAY_SYNCHRONOUS);
138
+    passcode = compute_checksum();
139
+    GOTO_PREVIOUS();
140
+  } else {
141
+    // We are verifying a passcode
142
+    if (passcode == compute_checksum()) {
143
+      message_style() = 'g';
144
+      onRefresh();
145
+      sound.play(twinkle, PLAY_SYNCHRONOUS);
146
+      GOTO_PREVIOUS();
147
+    } else {
148
+      message_style() = 'w';
149
+      onRefresh();
150
+      sound.play(sad_trombone, PLAY_SYNCHRONOUS);
151
+      current_screen.forget(); // Discard the screen the user was trying to go to.
152
+      GOTO_PREVIOUS();
153
+    }
154
+  }
155
+}
156
+
157
+bool LockScreen::onTouchEnd(uint8_t tag) {
158
+  char *c = strchr(screen_data.LockScreen.passcode,'_');
159
+  if (c) {
160
+    if (tag == '<') {
161
+      if (c != screen_data.LockScreen.passcode) {
162
+        // Backspace deletes previous entered characters.
163
+        *--c = '_';
164
+      }
165
+    } else {
166
+      // Append character to passcode
167
+      *c++ = tag;
168
+      if (*c == '\0') {
169
+        // If at last character, then process the code.
170
+        onPasscodeEntered();
171
+      }
172
+    }
173
+  }
174
+  return true;
175
+}
176
+
177
+uint16_t LockScreen::compute_checksum() {
178
+  uint16_t checksum = 0;
179
+  const char* c = screen_data.LockScreen.passcode;
180
+  while (*c) {
181
+    checksum = (checksum << 2) ^ *c++;
182
+  }
183
+  if (checksum == 0) checksum = 0xFFFF; // Prevent a zero checksum
184
+  return checksum;
185
+}
186
+
187
+// This function should be called *after* calling GOTO_SCREEN
188
+// to move to new screen. If a passcode is enabled, it will
189
+// immediately jump to the keypad screen, pushing the previous
190
+// screen onto the stack. If the code is entered correctly,
191
+// the stack will be popped, allowing the user to proceed to
192
+// the new screen. Otherwise it will be popped twice, taking
193
+// the user back to where they were before.
194
+void LockScreen::check_passcode() {
195
+  if (passcode == 0) return;
196
+  message_style() = 0;
197
+  GOTO_SCREEN(LockScreen);
198
+}
199
+
200
+bool LockScreen::is_enabled() {
201
+  return passcode != 0;
202
+}
203
+
204
+void LockScreen::disable() {
205
+  passcode = 0;
206
+}
207
+
208
+void LockScreen::enable() {
209
+  message_style() = 0;
210
+  passcode = 0;
211
+  GOTO_SCREEN(LockScreen);
212
+}
213
+
214
+#endif // LULZBOT_TOUCH_UI

+ 123
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/main_menu.cpp View File

@@ -0,0 +1,123 @@
1
+/*****************
2
+ * main_menu.cpp *
3
+ *****************/
4
+
5
+/****************************************************************************
6
+ *   Written By Mark Pelletier  2017 - Aleph Objects, Inc.                  *
7
+ *   Written By Marcio Teixeira 2018 - Aleph Objects, Inc.                  *
8
+ *                                                                          *
9
+ *   This program is free software: you can redistribute it and/or modify   *
10
+ *   it under the terms of the GNU General Public License as published by   *
11
+ *   the Free Software Foundation, either version 3 of the License, or      *
12
+ *   (at your option) any later version.                                    *
13
+ *                                                                          *
14
+ *   This program is distributed in the hope that it will be useful,        *
15
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
16
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
17
+ *   GNU General Public License for more details.                           *
18
+ *                                                                          *
19
+ *   To view a copy of the GNU General Public License, go to the following  *
20
+ *   location: <http://www.gnu.org/licenses/>.                              *
21
+ ****************************************************************************/
22
+
23
+#include "../config.h"
24
+
25
+#if ENABLED(LULZBOT_TOUCH_UI) && !defined(LULZBOT_USE_BIOPRINTER_UI)
26
+
27
+#include "screens.h"
28
+
29
+using namespace FTDI;
30
+using namespace Theme;
31
+
32
+void MainMenu::onRedraw(draw_mode_t what) {
33
+  if (what & BACKGROUND) {
34
+    CommandProcessor cmd;
35
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
36
+       .cmd(CLEAR(true,true,true));
37
+  }
38
+
39
+  if (what & FOREGROUND) {
40
+    CommandProcessor cmd;
41
+    cmd.colors(normal_btn)
42
+       .font(Theme::font_medium)
43
+    #ifdef TOUCH_UI_PORTRAIT
44
+      #define GRID_ROWS 8
45
+      #define GRID_COLS 2
46
+        .tag(2).button( BTN_POS(1,1), BTN_SIZE(1,1), F("Auto Home"))
47
+        #ifdef NOZZLE_CLEAN_FEATURE
48
+         .enabled(1)
49
+        #else
50
+         .enabled(0)
51
+        #endif
52
+        .tag(3).button( BTN_POS(2,1), BTN_SIZE(1,1), F("Clean Nozzle"))
53
+        .tag(4).button( BTN_POS(1,2), BTN_SIZE(1,1), F("Move Axis"))
54
+        .tag(5).button( BTN_POS(2,2), BTN_SIZE(1,1), F("Motors Off"))
55
+        .tag(6).button( BTN_POS(1,3), BTN_SIZE(2,1), F("Temperature"))
56
+        .tag(7).button( BTN_POS(1,4), BTN_SIZE(2,1), F("Change Filament"))
57
+        .tag(8).button( BTN_POS(1,5), BTN_SIZE(2,1), F("Advanced Settings"))
58
+        #ifdef PRINTCOUNTER
59
+         .enabled(1)
60
+        #else
61
+         .enabled(0)
62
+        #endif
63
+        .tag(9).button( BTN_POS(1,7), BTN_SIZE(2,1), F("Printer Statistics"))
64
+        .tag(10).button( BTN_POS(1,6), BTN_SIZE(2,1), F("About Printer"))
65
+        .colors(action_btn)
66
+        .tag(1).button( BTN_POS(1,8), BTN_SIZE(2,1), F("Back"));
67
+      #undef GRID_COLS
68
+      #undef GRID_ROWS
69
+    #else
70
+      #define GRID_ROWS 5
71
+      #define GRID_COLS 2
72
+        .tag(2).button( BTN_POS(1,1), BTN_SIZE(1,1), F("Auto Home"))
73
+        #if ENABLED(NOZZLE_CLEAN_FEATURE)
74
+         .enabled(1)
75
+        #else
76
+         .enabled(0)
77
+        #endif
78
+        .tag(3).button( BTN_POS(2,1), BTN_SIZE(1,1), F("Clean Nozzle"))
79
+        .tag(4).button( BTN_POS(1,2), BTN_SIZE(1,1), F("Move Axis"))
80
+        .tag(5).button( BTN_POS(2,2), BTN_SIZE(1,1), F("Motors Off"))
81
+        .tag(6).button( BTN_POS(1,3), BTN_SIZE(1,1), F("Temperature"))
82
+        .tag(7).button( BTN_POS(2,3), BTN_SIZE(1,1), F("Change Filament"))
83
+        .tag(8).button( BTN_POS(1,4), BTN_SIZE(1,1), F("Advanced Settings"))
84
+        #ifdef PRINTCOUNTER
85
+         .enabled(1)
86
+        #else
87
+         .enabled(0)
88
+        #endif
89
+        .tag(9).button( BTN_POS(2,4), BTN_SIZE(1,1), F("Printer Statistics"))
90
+        .tag(10).button( BTN_POS(1,5), BTN_SIZE(1,1), F("About Printer"))
91
+        .colors(action_btn)
92
+        .tag(1).button( BTN_POS(2,5), BTN_SIZE(1,1), F("Back"));
93
+      #undef GRID_COLS
94
+      #undef GRID_ROWS
95
+    #endif
96
+  }
97
+}
98
+
99
+bool MainMenu::onTouchEnd(uint8_t tag) {
100
+  using namespace ExtUI;
101
+
102
+  switch (tag) {
103
+    case 1:  GOTO_PREVIOUS();                                         break;
104
+    case 2:  SpinnerDialogBox::enqueueAndWait_P(F("G28"));            break;
105
+    #if ENABLED(NOZZLE_CLEAN_FEATURE)
106
+    case 3:  injectCommands_P(PSTR("G12")); GOTO_SCREEN(StatusScreen); break;
107
+    #endif
108
+    case 4:  GOTO_SCREEN(MoveAxisScreen);                             break;
109
+    case 5:  injectCommands_P(PSTR("M84"));                           break;
110
+    case 6:  GOTO_SCREEN(TemperatureScreen);                          break;
111
+    case 7:  GOTO_SCREEN(ChangeFilamentScreen);                       break;
112
+    case 8:  GOTO_SCREEN(AdvancedSettingsMenu);                       break;
113
+#if ENABLED(PRINTCOUNTER)
114
+    case 9:  GOTO_SCREEN(StatisticsScreen);                           break;
115
+#endif
116
+    case 10: GOTO_SCREEN(AboutScreen);                                break;
117
+    default:
118
+      return false;
119
+  }
120
+  return true;
121
+}
122
+
123
+#endif // LULZBOT_TOUCH_UI

+ 0
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/max_acceleration_screen.cpp View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save