Sfoglia il codice sorgente

Add Linear Advance values to EEPROM and enable configuration of K via LCD

Thomas Moore 7 anni fa
parent
commit
f8e77d6545

+ 52
- 3
Marlin/configuration_store.cpp Vedi File

@@ -36,7 +36,7 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V34"
39
+#define EEPROM_VERSION "V35"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
@@ -149,8 +149,12 @@
149 149
  *  572  M906 E3   stepperE3 current                (uint16_t)
150 150
  *  576  M906 E4   stepperE4 current                (uint16_t)
151 151
  *
152
- *  580                                Minimum end-point
153
- * 1901 (580 + 36 + 9 + 288 + 988)     Maximum end-point
152
+ * LIN_ADVANCE:                                     8 bytes
153
+ *  580  M905 K    extruder_advance_k               (float)
154
+ *  584  M905 WHD  advance_ed_ratio                 (float)
155
+ *
156
+ *  588                                Minimum end-point
157
+ * 1909 (588 + 36 + 9 + 288 + 988)     Maximum end-point
154 158
  */
155 159
 #include "configuration_store.h"
156 160
 
@@ -570,6 +574,20 @@ void MarlinSettings::postprocess() {
570 574
       for (uint8_t q = 0; q < 11; ++q) EEPROM_WRITE(val);
571 575
     #endif
572 576
 
577
+    //
578
+    // Linear Advance
579
+    //
580
+
581
+    float extruder_advance_k = 0.0f, advance_ed_ratio = 0.0f;
582
+
583
+    #if ENABLED(LIN_ADVANCE)
584
+      extruder_advance_k = planner.get_extruder_advance_k();
585
+      advance_ed_ratio = planner.get_advance_ed_ratio();
586
+    #endif
587
+
588
+    EEPROM_WRITE(extruder_advance_k);
589
+    EEPROM_WRITE(advance_ed_ratio);
590
+
573 591
     if (!eeprom_write_error) {
574 592
 
575 593
       const uint16_t final_checksum = eeprom_checksum,
@@ -900,6 +918,19 @@ void MarlinSettings::postprocess() {
900 918
         for (uint8_t q = 0; q < 11; q++) EEPROM_READ(val);
901 919
       #endif
902 920
 
921
+      //
922
+      // Linear Advance
923
+      //
924
+
925
+      float extruder_advance_k, advance_ed_ratio;
926
+      EEPROM_READ(extruder_advance_k);
927
+      EEPROM_READ(advance_ed_ratio);
928
+
929
+      #if ENABLED(LIN_ADVANCE)
930
+        planner.set_extruder_advance_k(extruder_advance_k);
931
+        planner.set_advance_ed_ratio(advance_ed_ratio);
932
+      #endif
933
+
903 934
       if (eeprom_checksum == stored_checksum) {
904 935
         if (eeprom_read_error)
905 936
           reset();
@@ -1155,6 +1186,11 @@ void MarlinSettings::reset() {
1155 1186
     #endif
1156 1187
   #endif
1157 1188
 
1189
+  #if ENABLED(LIN_ADVANCE)
1190
+    planner.set_extruder_advance_k(LIN_ADVANCE_K);
1191
+    planner.set_advance_ed_ratio(LIN_ADVANCE_E_D_RATIO);
1192
+  #endif
1193
+
1158 1194
   postprocess();
1159 1195
 
1160 1196
   SERIAL_ECHO_START;
@@ -1619,6 +1655,19 @@ void MarlinSettings::reset() {
1619 1655
       #endif
1620 1656
       SERIAL_EOL;
1621 1657
     #endif
1658
+
1659
+    /**
1660
+     * Linear Advance
1661
+     */
1662
+    #if ENABLED(LIN_ADVANCE)
1663
+      if (!forReplay) {
1664
+        CONFIG_ECHO_START;
1665
+        SERIAL_ECHOLNPGM("Linear Advance:");
1666
+      }
1667
+      CONFIG_ECHO_START;
1668
+      SERIAL_ECHOPAIR("  M905 K", planner.get_extruder_advance_k());
1669
+      SERIAL_ECHOLNPAIR(" R", planner.get_advance_ed_ratio());
1670
+    #endif
1622 1671
   }
1623 1672
 
1624 1673
 #endif // !DISABLE_M503

+ 3
- 2
Marlin/planner.h Vedi File

@@ -267,9 +267,10 @@ class Planner {
267 267
     #endif
268 268
 
269 269
     #if ENABLED(LIN_ADVANCE)
270
-      static void set_extruder_advance_k(const float &k) { extruder_advance_k = k; };
270
+      static void set_extruder_advance_k(float k) { extruder_advance_k = k; };
271 271
       static float get_extruder_advance_k() { return extruder_advance_k; };
272
-      static void set_advance_ed_ratio(const float &ratio) { advance_ed_ratio = ratio; };
272
+      static void set_advance_ed_ratio(float ratio) { advance_ed_ratio = ratio; };
273
+      static float get_advance_ed_ratio() { return advance_ed_ratio; };
273 274
     #endif
274 275
 
275 276
     /**

+ 67
- 23
Marlin/ultralcd.cpp Vedi File

@@ -143,7 +143,7 @@ uint16_t max_display_update_time = 0;
143 143
   void lcd_control_temperature_preheat_material1_settings_menu();
144 144
   void lcd_control_temperature_preheat_material2_settings_menu();
145 145
   void lcd_control_motion_menu();
146
-  void lcd_control_volumetric_menu();
146
+  void lcd_control_filament_menu();
147 147
 
148 148
   #if ENABLED(DAC_STEPPER_CURRENT)
149 149
     void dac_driver_commit();
@@ -198,26 +198,31 @@ uint16_t max_display_update_time = 0;
198 198
   void menu_action_submenu(screenFunc_t data);
199 199
   void menu_action_gcode(const char* pgcode);
200 200
   void menu_action_function(screenFunc_t data);
201
+
202
+  #define DECLARE_MENU_EDIT_TYPE(_type, _name) \
203
+    bool _menu_edit_ ## _name(); \
204
+    void menu_edit_ ## _name(); \
205
+    void menu_edit_callback_ ## _name(); \
206
+    void _menu_action_setting_edit_ ## _name(const char * const pstr, _type* const ptr, const _type minValue, const _type maxValue); \
207
+    void menu_action_setting_edit_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue); \
208
+    void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback); \
209
+    void _menu_action_setting_edit_accessor_ ## _name(const char * const pstr, _type (*pget)(), void (*pset)(_type), const _type minValue, const _type maxValue); \
210
+    void menu_action_setting_edit_accessor_ ## _name(const char * const pstr, _type (*pget)(), void (*pset)(_type), const _type minValue, const _type maxValue); \
211
+    typedef void _name##_void
212
+
213
+  DECLARE_MENU_EDIT_TYPE(int, int3);
214
+  DECLARE_MENU_EDIT_TYPE(float, float3);
215
+  DECLARE_MENU_EDIT_TYPE(float, float32);
216
+  DECLARE_MENU_EDIT_TYPE(float, float43);
217
+  DECLARE_MENU_EDIT_TYPE(float, float5);
218
+  DECLARE_MENU_EDIT_TYPE(float, float51);
219
+  DECLARE_MENU_EDIT_TYPE(float, float52);
220
+  DECLARE_MENU_EDIT_TYPE(float, float62);
221
+  DECLARE_MENU_EDIT_TYPE(unsigned long, long5);
222
+  
201 223
   void menu_action_setting_edit_bool(const char* pstr, bool* ptr);
202
-  void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
203
-  void menu_action_setting_edit_float3(const char* pstr, float* ptr, float minValue, float maxValue);
204
-  void menu_action_setting_edit_float32(const char* pstr, float* ptr, float minValue, float maxValue);
205
-  void menu_action_setting_edit_float43(const char* pstr, float* ptr, float minValue, float maxValue);
206
-  void menu_action_setting_edit_float5(const char* pstr, float* ptr, float minValue, float maxValue);
207
-  void menu_action_setting_edit_float51(const char* pstr, float* ptr, float minValue, float maxValue);
208
-  void menu_action_setting_edit_float52(const char* pstr, float* ptr, float minValue, float maxValue);
209
-  void menu_action_setting_edit_float62(const char* pstr, float* ptr, float minValue, float maxValue);
210
-  void menu_action_setting_edit_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue);
211 224
   void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, screenFunc_t callbackFunc);
212
-  void menu_action_setting_edit_callback_int3(const char* pstr, int* ptr, int minValue, int maxValue, screenFunc_t callbackFunc);
213
-  void menu_action_setting_edit_callback_float3(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
214
-  void menu_action_setting_edit_callback_float32(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
215
-  void menu_action_setting_edit_callback_float43(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
216
-  void menu_action_setting_edit_callback_float5(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
217
-  void menu_action_setting_edit_callback_float51(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
218
-  void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
219
-  void menu_action_setting_edit_callback_float62(const char* pstr, float* ptr, float minValue, float maxValue, screenFunc_t callbackFunc);
220
-  void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, screenFunc_t callbackFunc);
225
+  void menu_action_setting_edit_accessor_bool(const char* pstr, bool (*pget)(), void (*pset)(bool));
221 226
 
222 227
   #if ENABLED(SDSUPPORT)
223 228
     void lcd_sdcard_menu();
@@ -375,12 +380,15 @@ uint16_t max_display_update_time = 0;
375 380
   #define MENU_ITEM_DUMMY() do { _thisItemNr++; } while(0)
376 381
   #define MENU_ITEM_EDIT(type, label, ...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
377 382
   #define MENU_ITEM_EDIT_CALLBACK(type, label, ...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
383
+  #define MENU_ITEM_EDIT_ACCESSOR(type, label, ...) MENU_ITEM(setting_edit_accessor_ ## type, label, PSTR(label), ## __VA_ARGS__)
378 384
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
379 385
     #define MENU_MULTIPLIER_ITEM_EDIT(type, label, ...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
380 386
     #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, ...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
387
+    #define MENU_MULTIPLIER_ITEM_EDIT_ACCESSOR(type, label, ...) MENU_MULTIPLIER_ITEM(setting_edit_accessor_ ## type, label, PSTR(label), ## __VA_ARGS__)
381 388
   #else //!ENCODER_RATE_MULTIPLIER
382 389
     #define MENU_MULTIPLIER_ITEM_EDIT(type, label, ...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## __VA_ARGS__)
383 390
     #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, ...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## __VA_ARGS__)
391
+    #define MENU_MULTIPLIER_ITEM_EDIT_ACCESSOR(type, label, ...) MENU_ITEM(setting_edit_accessor_ ## type, label, PSTR(label), ## __VA_ARGS__)
384 392
   #endif //!ENCODER_RATE_MULTIPLIER
385 393
 
386 394
   /** Used variables to keep track of the menu */
@@ -417,6 +425,7 @@ uint16_t max_display_update_time = 0;
417 425
   // Variables used when editing values.
418 426
   const char* editLabel;
419 427
   void* editValue;
428
+  void* editSetter;
420 429
   int32_t minEditValue, maxEditValue;
421 430
   screenFunc_t callbackFunc;              // call this after editing
422 431
 
@@ -2105,7 +2114,7 @@ void kill_screen(const char* lcd_msg) {
2105 2114
     MENU_BACK(MSG_MAIN);
2106 2115
     MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
2107 2116
     MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
2108
-    MENU_ITEM(submenu, MSG_VOLUMETRIC, lcd_control_volumetric_menu);
2117
+    MENU_ITEM(submenu, MSG_VOLUMETRIC, lcd_control_filament_menu);
2109 2118
 
2110 2119
     #if HAS_LCD_CONTRAST
2111 2120
       //MENU_ITEM_EDIT(int3, MSG_CONTRAST, &lcd_contrast, 0, 63);
@@ -2543,10 +2552,14 @@ void kill_screen(const char* lcd_msg) {
2543 2552
    * "Control" > "Filament" submenu
2544 2553
    *
2545 2554
    */
2546
-  void lcd_control_volumetric_menu() {
2555
+  void lcd_control_filament_menu() {
2547 2556
     START_MENU();
2548 2557
     MENU_BACK(MSG_CONTROL);
2549 2558
 
2559
+    #if ENABLED(LIN_ADVANCE)
2560
+      MENU_ITEM_EDIT_ACCESSOR(float3, MSG_ADVANCE_K, planner.get_extruder_advance_k, planner.set_extruder_advance_k, 0, 999);
2561
+    #endif
2562
+
2550 2563
     MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
2551 2564
 
2552 2565
     if (volumetric_enabled) {
@@ -3101,6 +3114,8 @@ void kill_screen(const char* lcd_msg) {
3101 3114
    *   void _menu_action_setting_edit_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue);
3102 3115
    *   void menu_action_setting_edit_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue);
3103 3116
    *   void menu_action_setting_edit_callback_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue, const screenFunc_t callback); // edit int with callback
3117
+   *   void _menu_action_setting_edit_accessor_int3(const char * const pstr, int (*pget)(), void (*pset)(int), const int minValue, const int maxValue);
3118
+   *   void menu_action_setting_edit_accessor_int3(const char * const pstr, int (*pget)(), void (*pset)(int), const int minValue, const int maxValue); // edit int via pget and pset accessor functions
3104 3119
    *
3105 3120
    * You can then use one of the menu macros to present the edit interface:
3106 3121
    *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
@@ -3112,6 +3127,9 @@ void kill_screen(const char* lcd_msg) {
3112 3127
    * Also: MENU_MULTIPLIER_ITEM_EDIT, MENU_ITEM_EDIT_CALLBACK, and MENU_MULTIPLIER_ITEM_EDIT_CALLBACK
3113 3128
    *
3114 3129
    *       menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
3130
+   *
3131
+   * Values that are get/set via functions (As opposed to global variables) can use the accessor form:
3132
+   *   MENU_ITEM_EDIT_ACCESSOR(int3, MSG_SPEED, get_feedrate_percentage, set_feedrate_percentage, 10, 999)
3115 3133
    */
3116 3134
   #define menu_edit_type(_type, _name, _strFunc, _scale) \
3117 3135
     bool _menu_edit_ ## _name () { \
@@ -3121,7 +3139,11 @@ void kill_screen(const char* lcd_msg) {
3121 3139
       if (lcdDrawUpdate) \
3122 3140
         lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale))); \
3123 3141
       if (lcd_clicked) { \
3124
-        *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
3142
+        _type value = ((_type)((int32_t)encoderPosition + minEditValue)) * (1.0 / _scale); \
3143
+        if (editValue != NULL) \
3144
+          *((_type*)editValue) = value; \
3145
+        else if (editSetter != NULL) \
3146
+          ((void (*)(_type))editSetter)(value); \
3125 3147
         lcd_goto_previous_menu(); \
3126 3148
       } \
3127 3149
       return lcd_clicked; \
@@ -3135,6 +3157,7 @@ void kill_screen(const char* lcd_msg) {
3135 3157
       \
3136 3158
       editLabel = pstr; \
3137 3159
       editValue = ptr; \
3160
+      editSetter = NULL; \
3138 3161
       minEditValue = minValue * _scale; \
3139 3162
       maxEditValue = maxValue * _scale - minEditValue; \
3140 3163
       encoderPosition = (*ptr) * _scale - minEditValue; \
@@ -3142,12 +3165,28 @@ void kill_screen(const char* lcd_msg) {
3142 3165
     void menu_action_setting_edit_ ## _name (const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue) { \
3143 3166
       _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
3144 3167
       currentScreen = menu_edit_ ## _name; \
3145
-    }\
3168
+    } \
3146 3169
     void menu_action_setting_edit_callback_ ## _name (const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback) { \
3147 3170
       _menu_action_setting_edit_ ## _name(pstr, ptr, minValue, maxValue); \
3148 3171
       currentScreen = menu_edit_callback_ ## _name; \
3149 3172
       callbackFunc = callback; \
3150 3173
     } \
3174
+    void _menu_action_setting_edit_accessor_ ## _name (const char * const pstr, _type (*pget)(), void (*pset)(_type), const _type minValue, const _type maxValue) { \
3175
+      lcd_save_previous_screen(); \
3176
+      \
3177
+      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; \
3178
+      \
3179
+      editLabel = pstr; \
3180
+      editValue = NULL; \
3181
+      editSetter = pset; \
3182
+      minEditValue = minValue * _scale; \
3183
+      maxEditValue = maxValue * _scale - minEditValue; \
3184
+      encoderPosition = pget() * _scale - minEditValue; \
3185
+    } \
3186
+    void menu_action_setting_edit_accessor_ ## _name (const char * const pstr, _type (*pget)(), void (*pset)(_type), const _type minValue, const _type maxValue) { \
3187
+      _menu_action_setting_edit_accessor_ ## _name(pstr, pget, pset, minValue, maxValue); \
3188
+      currentScreen = menu_edit_ ## _name; \
3189
+    } \
3151 3190
     typedef void _name
3152 3191
 
3153 3192
   menu_edit_type(int, int3, itostr3, 1);
@@ -3252,6 +3291,11 @@ void kill_screen(const char* lcd_msg) {
3252 3291
     menu_action_setting_edit_bool(pstr, ptr);
3253 3292
     (*callback)();
3254 3293
   }
3294
+  void menu_action_setting_edit_accessor_bool(const char* pstr, bool (*pget)(), void (*pset)(bool)) {
3295
+    UNUSED(pstr);
3296
+    pset(!pget());
3297
+    lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
3298
+  }
3255 3299
 
3256 3300
 #endif // ULTIPANEL
3257 3301
 

+ 23
- 19
Marlin/ultralcd_impl_DOGM.h Vedi File

@@ -767,27 +767,31 @@ static void lcd_implementation_status_screen() {
767 767
   #define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
768 768
   #define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
769 769
 
770
-  #define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
771
-  #define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
772
-  #define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
773
-  #define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
774
-  #define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
775
-  #define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
776
-  #define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
777
-  #define lcd_implementation_drawmenu_setting_edit_float62(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr62rj(*(data)))
778
-  #define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
779
-  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
770
+  #define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(_type, _name, _strFunc) \
771
+    inline void lcd_implementation_drawmenu_setting_edit_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \
772
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(*(data))); \
773
+    } \
774
+    inline void lcd_implementation_drawmenu_setting_edit_callback_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \
775
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(*(data))); \
776
+    } \
777
+    inline void lcd_implementation_drawmenu_setting_edit_accessor_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type (*pget)(), void (*pset)(_type), ...) { \
778
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, _strFunc(pget())); \
779
+    } \
780
+    typedef void _name##_void
781
+
782
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
783
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
784
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
785
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);
786
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float5, ftostr5rj);
787
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float51, ftostr51sign);
788
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float52, ftostr52sign);
789
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float62, ftostr62rj);
790
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long, long5, ftostr5rj);
780 791
 
781
-  #define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
782
-  #define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
783
-  #define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
784
-  #define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43sign(*(data)))
785
-  #define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
786
-  #define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52sign(*(data)))
787
-  #define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51sign(*(data)))
788
-  #define lcd_implementation_drawmenu_setting_edit_callback_float62(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr62rj(*(data)))
789
-  #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5rj(*(data)))
792
+  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
790 793
   #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
794
+  #define lcd_implementation_drawmenu_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
791 795
 
792 796
   void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL) {
793 797
     const uint8_t labellen = lcd_strlen_P(pstr),

+ 23
- 20
Marlin/ultralcd_impl_HD44780.h Vedi File

@@ -874,28 +874,31 @@ static void lcd_implementation_status_screen() {
874 874
     lcd_printPGM(data);
875 875
   }
876 876
 
877
-  #define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
878
-  #define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
879
-  #define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
880
-  #define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
881
-  #define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
882
-  #define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
883
-  #define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
884
-  #define lcd_implementation_drawmenu_setting_edit_float62(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr62rj(*(data)))
885
-  #define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
886
-  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
877
+  #define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(_type, _name, _strFunc) \
878
+    inline void lcd_implementation_drawmenu_setting_edit_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \
879
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', _strFunc(*(data))); \
880
+    } \
881
+    inline void lcd_implementation_drawmenu_setting_edit_callback_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type * const data, ...) { \
882
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', _strFunc(*(data))); \
883
+    } \
884
+    inline void lcd_implementation_drawmenu_setting_edit_accessor_ ## _name (const bool sel, const uint8_t row, const char* pstr, const char* pstr2, _type (*pget)(), void (*pset)(_type), ...) { \
885
+      lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', _strFunc(pget())); \
886
+    } \
887
+    typedef void _name##_void
888
+
889
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
890
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
891
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
892
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);
893
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float5, ftostr5rj);
894
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float51, ftostr51sign);
895
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float52, ftostr52sign);
896
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float62, ftostr62rj);
897
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long, long5, ftostr5rj);
887 898
 
888
-  //Add version for callback functions
889
-  #define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
890
-  #define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
891
-  #define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
892
-  #define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr43sign(*(data)))
893
-  #define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
894
-  #define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr52sign(*(data)))
895
-  #define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr51sign(*(data)))
896
-  #define lcd_implementation_drawmenu_setting_edit_callback_float62(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr62rj(*(data)))
897
-  #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr5rj(*(data)))
899
+  #define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
898 900
   #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
901
+  #define lcd_implementation_drawmenu_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
899 902
 
900 903
   void lcd_implementation_drawedit(const char* pstr, const char* const value=NULL) {
901 904
     lcd.setCursor(1, 1);

Loading…
Annulla
Salva