소스 검색

Pretty up EEPROM port args

Scott Lahteine 7 년 전
부모
커밋
4aebe3d82e
2개의 변경된 파일40개의 추가작업 그리고 94개의 파일을 삭제
  1. 23
    64
      Marlin/src/module/configuration_store.cpp
  2. 17
    30
      Marlin/src/module/configuration_store.h

+ 23
- 64
Marlin/src/module/configuration_store.cpp 파일 보기

45
 //#define DEBUG_EEPROM_READWRITE
45
 //#define DEBUG_EEPROM_READWRITE
46
 
46
 
47
 #include "configuration_store.h"
47
 #include "configuration_store.h"
48
+
49
+#if ADD_PORT_ARG
50
+  #define PORTARG_SOLO     const int8_t port
51
+  #define PORTARG_AFTER   ,const int8_t port
52
+  #define PORTVAR_SOLO     port
53
+#else
54
+  #define PORTARG_SOLO
55
+  #define PORTARG_AFTER
56
+  #define PORTVAR_SOLO
57
+#endif
58
+
48
 #include "endstops.h"
59
 #include "endstops.h"
49
 #include "planner.h"
60
 #include "planner.h"
50
 #include "stepper.h"
61
 #include "stepper.h"
345
 
356
 
346
   bool MarlinSettings::eeprom_error, MarlinSettings::validating;
357
   bool MarlinSettings::eeprom_error, MarlinSettings::validating;
347
 
358
 
348
-  bool MarlinSettings::size_error(const uint16_t size
349
-    #if ADD_PORT_ARG
350
-      , const int8_t port/*=-1*/
351
-    #endif
352
-  ) {
359
+  bool MarlinSettings::size_error(const uint16_t size PORTARG_AFTER) {
353
     if (size != datasize()) {
360
     if (size != datasize()) {
354
       #if ENABLED(EEPROM_CHITCHAT)
361
       #if ENABLED(EEPROM_CHITCHAT)
355
         SERIAL_ERROR_START_P(port);
362
         SERIAL_ERROR_START_P(port);
363
   /**
370
   /**
364
    * M500 - Store Configuration
371
    * M500 - Store Configuration
365
    */
372
    */
366
-  bool MarlinSettings::save(
367
-    #if ADD_PORT_ARG
368
-      const int8_t port/*=-1*/
369
-    #endif
370
-  ) {
373
+  bool MarlinSettings::save(PORTARG_SOLO) {
371
     float dummy = 0.0f;
374
     float dummy = 0.0f;
372
     char ver[4] = "ERR";
375
     char ver[4] = "ERR";
373
 
376
 
853
   /**
856
   /**
854
    * M501 - Retrieve Configuration
857
    * M501 - Retrieve Configuration
855
    */
858
    */
856
-  bool MarlinSettings::_load(
857
-    #if ADD_PORT_ARG
858
-      const int8_t port/*=-1*/
859
-    #endif
860
-  ) {
859
+  bool MarlinSettings::_load(PORTARG_SOLO) {
861
     uint16_t working_crc = 0;
860
     uint16_t working_crc = 0;
862
 
861
 
863
     EEPROM_START();
862
     EEPROM_START();
1431
     }
1430
     }
1432
 
1431
 
1433
     #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
1432
     #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503)
1434
-      if (!validating) report(
1435
-        #if ADD_PORT_ARG
1436
-          port
1437
-        #endif
1438
-      );
1433
+      if (!validating) report(PORTVAR_SOLO);
1439
     #endif
1434
     #endif
1440
     EEPROM_FINISH();
1435
     EEPROM_FINISH();
1441
 
1436
 
1442
     return !eeprom_error;
1437
     return !eeprom_error;
1443
   }
1438
   }
1444
 
1439
 
1445
-  bool MarlinSettings::validate(
1446
-    #if ADD_PORT_ARG
1447
-      const int8_t port/*=-1*/
1448
-    #endif
1449
-  ) {
1440
+  bool MarlinSettings::validate(PORTARG_SOLO) {
1450
     validating = true;
1441
     validating = true;
1451
-    const bool success = _load(
1452
-      #if ADD_PORT_ARG
1453
-        port
1454
-      #endif
1455
-    );
1442
+    const bool success = _load(PORTVAR_SOLO);
1456
     validating = false;
1443
     validating = false;
1457
     return success;
1444
     return success;
1458
   }
1445
   }
1459
 
1446
 
1460
-  bool MarlinSettings::load(
1461
-    #if ADD_PORT_ARG
1462
-      const int8_t port/*=-1*/
1463
-    #endif
1464
-  ) {
1465
-    if (validate(
1466
-      #if ADD_PORT_ARG
1467
-        port
1468
-      #endif
1469
-    )) return _load(
1470
-      #if ADD_PORT_ARG
1471
-        port
1472
-      #endif
1473
-    );
1447
+  bool MarlinSettings::load(PORTARG_SOLO) {
1448
+    if (validate(PORTVAR_SOLO)) return _load(PORTVAR_SOLO);
1474
     reset();
1449
     reset();
1475
     return true;
1450
     return true;
1476
   }
1451
   }
1581
 
1556
 
1582
 #else // !EEPROM_SETTINGS
1557
 #else // !EEPROM_SETTINGS
1583
 
1558
 
1584
-  bool MarlinSettings::save(
1585
-    #if ADD_PORT_ARG
1586
-      const int8_t port/*=-1*/
1587
-    #endif
1588
-  ) {
1559
+  bool MarlinSettings::save(PORTARG_SOLO) {
1589
     #if ENABLED(EEPROM_CHITCHAT)
1560
     #if ENABLED(EEPROM_CHITCHAT)
1590
       SERIAL_ERROR_START_P(port);
1561
       SERIAL_ERROR_START_P(port);
1591
       SERIAL_ERRORLNPGM_P(port, "EEPROM disabled");
1562
       SERIAL_ERRORLNPGM_P(port, "EEPROM disabled");
1598
 /**
1569
 /**
1599
  * M502 - Reset Configuration
1570
  * M502 - Reset Configuration
1600
  */
1571
  */
1601
-void MarlinSettings::reset(
1602
-  #if ADD_PORT_ARG
1603
-    const int8_t port/*=-1*/
1604
-  #endif
1605
-) {
1572
+void MarlinSettings::reset(PORTARG_SOLO) {
1606
   static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
1573
   static const float tmp1[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT, tmp2[] PROGMEM = DEFAULT_MAX_FEEDRATE;
1607
   static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
1574
   static const uint32_t tmp3[] PROGMEM = DEFAULT_MAX_ACCELERATION;
1608
   LOOP_XYZE_N(i) {
1575
   LOOP_XYZE_N(i) {
1860
 
1827
 
1861
 #if DISABLED(DISABLE_M503)
1828
 #if DISABLED(DISABLE_M503)
1862
 
1829
 
1863
-  #if ADD_PORT_ARG
1864
-    #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
1865
-  #else
1866
-    #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START(); }while(0)
1867
-  #endif
1830
+  #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(PORTVAR_SOLO); }while(0)
1868
 
1831
 
1869
   /**
1832
   /**
1870
    * M503 - Report current settings in RAM
1833
    * M503 - Report current settings in RAM
2129
           SERIAL_ECHOLNPGM_P(port, " meshes.\n");
2092
           SERIAL_ECHOLNPGM_P(port, " meshes.\n");
2130
         }
2093
         }
2131
 
2094
 
2132
-        ubl.report_current_mesh(
2133
-          #if ADD_PORT_ARG
2134
-            port
2135
-          #endif
2136
-        );
2095
+        ubl.report_current_mesh(PORTVAR_SOLO);
2137
 
2096
 
2138
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
2097
       #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
2139
 
2098
 

+ 17
- 30
Marlin/src/module/configuration_store.h 파일 보기

27
 
27
 
28
 #define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
28
 #define ADD_PORT_ARG ENABLED(EEPROM_CHITCHAT) && NUM_SERIAL > 1
29
 
29
 
30
+#if ADD_PORT_ARG
31
+  #define PORTINIT_SOLO    const int8_t port=-1
32
+  #define PORTINIT_AFTER  ,const int8_t port=-1
33
+#else
34
+  #define PORTINIT_SOLO
35
+  #define PORTINIT_AFTER
36
+#endif
37
+
30
 class MarlinSettings {
38
 class MarlinSettings {
31
   public:
39
   public:
32
     MarlinSettings() { }
40
     MarlinSettings() { }
33
 
41
 
34
     static uint16_t datasize();
42
     static uint16_t datasize();
35
 
43
 
36
-    static void reset(
37
-      #if ADD_PORT_ARG
38
-        const int8_t port=-1
39
-      #endif
40
-    );
41
-    static bool save(
42
-      #if ADD_PORT_ARG
43
-        const int8_t port=-1
44
-      #endif
45
-    );   // Return 'true' if data was saved
44
+    static void reset(PORTINIT_SOLO);
45
+    static bool save(PORTINIT_SOLO);    // Return 'true' if data was saved
46
 
46
 
47
     FORCE_INLINE static bool init_eeprom() {
47
     FORCE_INLINE static bool init_eeprom() {
48
       bool success = true;
48
       bool success = true;
57
     }
57
     }
58
 
58
 
59
     #if ENABLED(EEPROM_SETTINGS)
59
     #if ENABLED(EEPROM_SETTINGS)
60
-      static bool load(
61
-        #if ADD_PORT_ARG
62
-          const int8_t port=-1
63
-        #endif
64
-      );     // Return 'true' if data was loaded ok
65
-      static bool validate(
66
-        #if ADD_PORT_ARG
67
-          const int8_t port=-1
68
-        #endif
69
-      ); // Return 'true' if EEPROM data is ok
60
+      static bool load(PORTINIT_SOLO);      // Return 'true' if data was loaded ok
61
+      static bool validate(PORTINIT_SOLO);  // Return 'true' if EEPROM data is ok
70
 
62
 
71
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
63
       #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
72
                                          // That can store is enabled
64
                                          // That can store is enabled
110
 
102
 
111
       #endif
103
       #endif
112
 
104
 
113
-      static bool _load(
114
-        #if ADD_PORT_ARG
115
-          const int8_t port=-1
116
-        #endif
117
-      );
118
-      static bool size_error(const uint16_t size
119
-        #if ADD_PORT_ARG
120
-          , const int8_t port=-1
121
-        #endif
122
-      );
105
+      static bool _load(PORTINIT_SOLO);
106
+      static bool size_error(const uint16_t size PORTINIT_AFTER);
123
     #endif
107
     #endif
124
 };
108
 };
125
 
109
 
126
 extern MarlinSettings settings;
110
 extern MarlinSettings settings;
127
 
111
 
112
+#undef PORTINIT_SOLO
113
+#undef PORTINIT_AFTER
114
+
128
 #endif // CONFIGURATION_STORE_H
115
 #endif // CONFIGURATION_STORE_H

Loading…
취소
저장