Browse Source

Config sections, multi-field values, toggles, etc

- Auto-detect “switchable” items where possible
- Handle switchable multi-value fields
- Add standard sections to config form
- Add section markers to configurations
- Add value options to configurations
- Remove and re-add fields for loaded configs
- Preserve sections across configs
- Preserve non-added fields
- Style added fields wider & newline by default
Scott Lahteine 10 years ago
parent
commit
83cb702e72

+ 48
- 0
Marlin/configurator/config/Configuration.h View File

35
 // example_configurations/SCARA directory.
35
 // example_configurations/SCARA directory.
36
 //
36
 //
37
 
37
 
38
+// @section info
39
+
38
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
40
 // User-specified version info of this build to display in [Pronterface, etc] terminal window during
39
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
41
 // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
40
 // build by the user have been successfully uploaded into firmware.
42
 // build by the user have been successfully uploaded into firmware.
45
 #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1
47
 #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1
46
 //#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2
48
 //#define STRING_SPLASH_LINE2 STRING_VERSION_CONFIG_H // will be shown during bootup in line2
47
 
49
 
50
+// @section machine
51
+
48
 // SERIAL_PORT selects which serial port should be used for communication with the host.
52
 // SERIAL_PORT selects which serial port should be used for communication with the host.
49
 // This allows the connection of wireless adapters (for instance) to non-default port pins.
53
 // This allows the connection of wireless adapters (for instance) to non-default port pins.
50
 // Serial port 0 is still used by the Arduino bootloader regardless of this setting.
54
 // Serial port 0 is still used by the Arduino bootloader regardless of this setting.
84
 // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it.
88
 // Define this to have the electronics keep the power supply off on startup. If you don't know what this is leave it.
85
 // #define PS_DEFAULT_OFF
89
 // #define PS_DEFAULT_OFF
86
 
90
 
91
+// @section temperature
92
+
87
 //===========================================================================
93
 //===========================================================================
88
 //============================= Thermal Settings ============================
94
 //============================= Thermal Settings ============================
89
 //===========================================================================
95
 //===========================================================================
237
 // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
243
 // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
238
 #endif // PIDTEMPBED
244
 #endif // PIDTEMPBED
239
 
245
 
246
+// @section extruder
240
 
247
 
241
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
248
 //this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
242
 //can be software-disabled for whatever purposes by
249
 //can be software-disabled for whatever purposes by
291
 //============================= Mechanical Settings =========================
298
 //============================= Mechanical Settings =========================
292
 //===========================================================================
299
 //===========================================================================
293
 
300
 
301
+// @section machine
302
+
294
 // Uncomment the following line to enable CoreXY kinematics
303
 // Uncomment the following line to enable CoreXY kinematics
295
 // #define COREXY
304
 // #define COREXY
296
 
305
 
306
+// @section homing
307
+
297
 // coarse Endstop Settings
308
 // coarse Endstop Settings
298
 #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
309
 #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
299
 
310
 
326
 //#define DISABLE_MAX_ENDSTOPS
337
 //#define DISABLE_MAX_ENDSTOPS
327
 //#define DISABLE_MIN_ENDSTOPS
338
 //#define DISABLE_MIN_ENDSTOPS
328
 
339
 
340
+// @section hidden
341
+
329
 // Disable max endstops for compatibility with endstop checking routine
342
 // Disable max endstops for compatibility with endstop checking routine
330
 #if defined(COREXY) && !defined(DISABLE_MAX_ENDSTOPS)
343
 #if defined(COREXY) && !defined(DISABLE_MAX_ENDSTOPS)
331
   #define DISABLE_MAX_ENDSTOPS
344
   #define DISABLE_MAX_ENDSTOPS
332
 #endif
345
 #endif
333
 
346
 
347
+// @section homing
348
+
334
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
349
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
350
+// :[0,1]
335
 #define X_ENABLE_ON 0
351
 #define X_ENABLE_ON 0
336
 #define Y_ENABLE_ON 0
352
 #define Y_ENABLE_ON 0
337
 #define Z_ENABLE_ON 0
353
 #define Z_ENABLE_ON 0
338
 #define E_ENABLE_ON 0 // For all extruders
354
 #define E_ENABLE_ON 0 // For all extruders
339
 
355
 
356
+// @section machine
357
+
340
 // Disables axis when it's not being used.
358
 // Disables axis when it's not being used.
341
 #define DISABLE_X false
359
 #define DISABLE_X false
342
 #define DISABLE_Y false
360
 #define DISABLE_Y false
343
 #define DISABLE_Z false
361
 #define DISABLE_Z false
362
+
363
+// @section extruder
364
+
344
 #define DISABLE_E false // For all extruders
365
 #define DISABLE_E false // For all extruders
345
 #define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
366
 #define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
346
 
367
 
368
+// @section machine
369
+
347
 #define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
370
 #define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
348
 #define INVERT_Y_DIR false    // for Mendel set to true, for Orca set to false
371
 #define INVERT_Y_DIR false    // for Mendel set to true, for Orca set to false
349
 #define INVERT_Z_DIR true     // for Mendel set to false, for Orca set to true
372
 #define INVERT_Z_DIR true     // for Mendel set to false, for Orca set to true
373
+
374
+// @section extruder
375
+
350
 #define INVERT_E0_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
376
 #define INVERT_E0_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
351
 #define INVERT_E1_DIR false    // for direct drive extruder v9 set to true, for geared extruder set to false
377
 #define INVERT_E1_DIR false    // for direct drive extruder v9 set to true, for geared extruder set to false
352
 #define INVERT_E2_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
378
 #define INVERT_E2_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
353
 
379
 
380
+// @section homing
381
+
354
 // ENDSTOP SETTINGS:
382
 // ENDSTOP SETTINGS:
355
 // Sets direction of endstops when homing; 1=MAX, -1=MIN
383
 // Sets direction of endstops when homing; 1=MAX, -1=MIN
384
+// :[-1,1]
356
 #define X_HOME_DIR -1
385
 #define X_HOME_DIR -1
357
 #define Y_HOME_DIR -1
386
 #define Y_HOME_DIR -1
358
 #define Z_HOME_DIR -1
387
 #define Z_HOME_DIR -1
360
 #define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
389
 #define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
361
 #define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.
390
 #define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.
362
 
391
 
392
+// @section machine
393
+
363
 // Travel limits after homing (units are in mm)
394
 // Travel limits after homing (units are in mm)
364
 #define X_MAX_POS 205
395
 #define X_MAX_POS 205
365
 #define X_MIN_POS 0
396
 #define X_MIN_POS 0
368
 #define Z_MAX_POS 200
399
 #define Z_MAX_POS 200
369
 #define Z_MIN_POS 0
400
 #define Z_MIN_POS 0
370
 
401
 
402
+// @section hidden
403
+
371
 #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
404
 #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
372
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
405
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
373
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
406
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
377
 //============================= Bed Auto Leveling ===========================
410
 //============================= Bed Auto Leveling ===========================
378
 //===========================================================================
411
 //===========================================================================
379
 
412
 
413
+// @section bedlevel
414
+
380
 //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
415
 //#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (remove // at the start of the line)
381
 #define Z_PROBE_REPEATABILITY_TEST  // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
416
 #define Z_PROBE_REPEATABILITY_TEST  // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
382
 
417
 
493
 #endif // ENABLE_AUTO_BED_LEVELING
528
 #endif // ENABLE_AUTO_BED_LEVELING
494
 
529
 
495
 
530
 
531
+// @section homing
532
+
496
 // The position of the homing switches
533
 // The position of the homing switches
497
 //#define MANUAL_HOME_POSITIONS  // If defined, MANUAL_*_HOME_POS below will be used
534
 //#define MANUAL_HOME_POSITIONS  // If defined, MANUAL_*_HOME_POS below will be used
498
 //#define BED_CENTER_AT_0_0  // If defined, the center of the bed is at (X=0, Y=0)
535
 //#define BED_CENTER_AT_0_0  // If defined, the center of the bed is at (X=0, Y=0)
504
 #define MANUAL_Z_HOME_POS 0
541
 #define MANUAL_Z_HOME_POS 0
505
 //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
542
 //#define MANUAL_Z_HOME_POS 402 // For delta: Distance between nozzle and print surface after homing.
506
 
543
 
544
+// @section movement
545
+
507
 //// MOVEMENT SETTINGS
546
 //// MOVEMENT SETTINGS
508
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
547
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
509
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
548
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
533
 //============================= Additional Features ===========================
572
 //============================= Additional Features ===========================
534
 //=============================================================================
573
 //=============================================================================
535
 
574
 
575
+// @section more
576
+
536
 // Custom M code points
577
 // Custom M code points
537
 #define CUSTOM_M_CODES
578
 #define CUSTOM_M_CODES
538
 #ifdef CUSTOM_M_CODES
579
 #ifdef CUSTOM_M_CODES
541
   #define Z_PROBE_OFFSET_RANGE_MAX -5
582
   #define Z_PROBE_OFFSET_RANGE_MAX -5
542
 #endif
583
 #endif
543
 
584
 
585
+// @section extras
544
 
586
 
545
 // EEPROM
587
 // EEPROM
546
 // The microcontroller can store settings in the EEPROM, e.g. max velocity...
588
 // The microcontroller can store settings in the EEPROM, e.g. max velocity...
553
 // please keep turned on if you can.
595
 // please keep turned on if you can.
554
 //#define EEPROM_CHITCHAT
596
 //#define EEPROM_CHITCHAT
555
 
597
 
598
+// @section temperature
599
+
556
 // Preheat Constants
600
 // Preheat Constants
557
 #define PLA_PREHEAT_HOTEND_TEMP 180
601
 #define PLA_PREHEAT_HOTEND_TEMP 180
558
 #define PLA_PREHEAT_HPB_TEMP 70
602
 #define PLA_PREHEAT_HPB_TEMP 70
562
 #define ABS_PREHEAT_HPB_TEMP 100
606
 #define ABS_PREHEAT_HPB_TEMP 100
563
 #define ABS_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
607
 #define ABS_PREHEAT_FAN_SPEED 255   // Insert Value between 0 and 255
564
 
608
 
609
+// @section lcd
610
+
565
 //LCD and SD support
611
 //LCD and SD support
566
 
612
 
567
 // Character based displays can have different extended charsets.
613
 // Character based displays can have different extended charsets.
738
 # endif
784
 # endif
739
 #endif
785
 #endif
740
 
786
 
787
+// @section extras
788
+
741
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
789
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
742
 //#define FAST_PWM_FAN
790
 //#define FAST_PWM_FAN
743
 
791
 

+ 35
- 1
Marlin/configurator/config/Configuration_adv.h View File

1
 #ifndef CONFIGURATION_ADV_H
1
 #ifndef CONFIGURATION_ADV_H
2
 #define CONFIGURATION_ADV_H
2
 #define CONFIGURATION_ADV_H
3
 
3
 
4
+// @section temperature
5
+
4
 //===========================================================================
6
 //===========================================================================
5
 //=============================Thermal Settings  ============================
7
 //=============================Thermal Settings  ============================
6
 //===========================================================================
8
 //===========================================================================
44
 //The M105 command return, besides traditional information, the ADC value read from temperature sensors.
46
 //The M105 command return, besides traditional information, the ADC value read from temperature sensors.
45
 //#define SHOW_TEMP_ADC_VALUES
47
 //#define SHOW_TEMP_ADC_VALUES
46
 
48
 
49
+// @section extruder
50
+
47
 //  extruder run-out prevention.
51
 //  extruder run-out prevention.
48
 //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
52
 //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
49
 //#define EXTRUDER_RUNOUT_PREVENT
53
 //#define EXTRUDER_RUNOUT_PREVENT
53
 #define EXTRUDER_RUNOUT_SPEED 1500.  //extrusion speed
57
 #define EXTRUDER_RUNOUT_SPEED 1500.  //extrusion speed
54
 #define EXTRUDER_RUNOUT_EXTRUDE 100
58
 #define EXTRUDER_RUNOUT_EXTRUDE 100
55
 
59
 
60
+// @section temperature
61
+
56
 //These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
62
 //These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
57
 //The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
63
 //The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
58
 #define TEMP_SENSOR_AD595_OFFSET 0.0
64
 #define TEMP_SENSOR_AD595_OFFSET 0.0
70
 // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
76
 // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
71
 //#define FAN_KICKSTART_TIME 100
77
 //#define FAN_KICKSTART_TIME 100
72
 
78
 
79
+// @section extruder
80
+
73
 // Extruder cooling fans
81
 // Extruder cooling fans
74
 // Configure fan pin outputs to automatically turn on/off when the associated
82
 // Configure fan pin outputs to automatically turn on/off when the associated
75
 // extruder temperature is above/below EXTRUDER_AUTO_FAN_TEMPERATURE.
83
 // extruder temperature is above/below EXTRUDER_AUTO_FAN_TEMPERATURE.
87
 //=============================Mechanical Settings===========================
95
 //=============================Mechanical Settings===========================
88
 //===========================================================================
96
 //===========================================================================
89
 
97
 
98
+// @section machine
99
+
90
 #define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
100
 #define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
91
 
101
 
92
 
102
 
210
 
220
 
211
 #endif //DUAL_X_CARRIAGE
221
 #endif //DUAL_X_CARRIAGE
212
 
222
 
223
+// @section homing
224
+
213
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
225
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
214
 #define X_HOME_RETRACT_MM 5
226
 #define X_HOME_RETRACT_MM 5
215
 #define Y_HOME_RETRACT_MM 5
227
 #define Y_HOME_RETRACT_MM 5
216
 #define Z_HOME_RETRACT_MM 2
228
 #define Z_HOME_RETRACT_MM 2
217
 //#define QUICK_HOME  //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
229
 //#define QUICK_HOME  //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
218
 
230
 
231
+// @section machine
232
+
219
 #define AXIS_RELATIVE_MODES {false, false, false, false}
233
 #define AXIS_RELATIVE_MODES {false, false, false, false}
220
 #ifdef CONFIG_STEPPERS_TOSHIBA
234
 #ifdef CONFIG_STEPPERS_TOSHIBA
221
 #define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
235
 #define MAX_STEP_FREQUENCY 10000 // Max step frequency for Toshiba Stepper Controllers
228
 #define INVERT_Z_STEP_PIN false
242
 #define INVERT_Z_STEP_PIN false
229
 #define INVERT_E_STEP_PIN false
243
 #define INVERT_E_STEP_PIN false
230
 
244
 
231
-//default stepper release if idle
245
+//default stepper release if idle. Set to 0 to deactivate.
232
 #define DEFAULT_STEPPER_DEACTIVE_TIME 60
246
 #define DEFAULT_STEPPER_DEACTIVE_TIME 60
233
 
247
 
234
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
248
 #define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
235
 #define DEFAULT_MINTRAVELFEEDRATE     0.0
249
 #define DEFAULT_MINTRAVELFEEDRATE     0.0
236
 
250
 
251
+// @section lcd
252
+
237
 // Feedrates for manual moves along X, Y, Z, E from panel
253
 // Feedrates for manual moves along X, Y, Z, E from panel
238
 #ifdef ULTIPANEL
254
 #ifdef ULTIPANEL
239
 #define MANUAL_FEEDRATE {50*60, 50*60, 4*60, 60}  // set the speeds for manual moves (mm/min)
255
 #define MANUAL_FEEDRATE {50*60, 50*60, 4*60, 60}  // set the speeds for manual moves (mm/min)
244
     #define ULTIPANEL_FEEDMULTIPLY
260
     #define ULTIPANEL_FEEDMULTIPLY
245
 #endif
261
 #endif
246
 
262
 
263
+// @section extras
264
+
247
 // minimum time in microseconds that a movement needs to take if the buffer is emptied.
265
 // minimum time in microseconds that a movement needs to take if the buffer is emptied.
248
 #define DEFAULT_MINSEGMENTTIME        20000
266
 #define DEFAULT_MINSEGMENTTIME        20000
249
 
267
 
287
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
305
 //#define CHDK 4        //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
288
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
306
 #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
289
 
307
 
308
+// @section lcd
309
+
290
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
310
 #define SD_FINISHED_STEPPERRELEASE true  //if sd support and the file is finished: disable steppers?
291
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
311
 #define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
292
 
312
 
315
   #endif
335
   #endif
316
 #endif
336
 #endif
317
 
337
 
338
+// @section more
339
+
318
 // The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
340
 // The hardware watchdog should reset the microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
319
 //#define USE_WATCHDOG
341
 //#define USE_WATCHDOG
320
 
342
 
373
 
395
 
374
 const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
396
 const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
375
 
397
 
398
+// @section lcd
399
+
376
 // If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
400
 // If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
377
 // You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT
401
 // You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT
378
 // in the pins.h file.  When using a push button pulling the pin to ground this will need inverted.  This setting should
402
 // in the pins.h file.  When using a push button pulling the pin to ground this will need inverted.  This setting should
379
 // be commented out otherwise
403
 // be commented out otherwise
380
 #define SDCARDDETECTINVERTED
404
 #define SDCARDDETECTINVERTED
381
 
405
 
406
+// @section hidden
407
+
382
 #ifdef ULTIPANEL
408
 #ifdef ULTIPANEL
383
  #undef SDCARDDETECTINVERTED
409
  #undef SDCARDDETECTINVERTED
384
 #endif
410
 #endif
399
   #define PS_ON_ASLEEP LOW
425
   #define PS_ON_ASLEEP LOW
400
 #endif
426
 #endif
401
 
427
 
428
+// @section temperature
429
+
402
 // Control heater 0 and heater 1 in parallel.
430
 // Control heater 0 and heater 1 in parallel.
403
 //#define HEATERS_PARALLEL
431
 //#define HEATERS_PARALLEL
404
 
432
 
406
 //=============================Buffers           ============================
434
 //=============================Buffers           ============================
407
 //===========================================================================
435
 //===========================================================================
408
 
436
 
437
+// @section hidden
438
+
409
 // The number of linear motions that can be in the plan at any give time.
439
 // The number of linear motions that can be in the plan at any give time.
410
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
440
 // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ring-buffering.
411
 #if defined SDSUPPORT
441
 #if defined SDSUPPORT
414
   #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
444
   #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
415
 #endif
445
 #endif
416
 
446
 
447
+// @section more
417
 
448
 
418
 //The ASCII buffer for receiving from the serial:
449
 //The ASCII buffer for receiving from the serial:
419
 #define MAX_CMD_SIZE 96
450
 #define MAX_CMD_SIZE 96
420
 #define BUFSIZE 4
451
 #define BUFSIZE 4
421
 
452
 
453
+// @section extras
422
 
454
 
423
 // Firmware based and LCD controlled retract
455
 // Firmware based and LCD controlled retract
424
 // M207 and M208 can be used to define parameters for the retraction.
456
 // M207 and M208 can be used to define parameters for the retraction.
460
 //=============================  Define Defines  ============================
492
 //=============================  Define Defines  ============================
461
 //===========================================================================
493
 //===========================================================================
462
 
494
 
495
+// @section hidden
496
+
463
 #if defined (ENABLE_AUTO_BED_LEVELING) && defined (DELTA)
497
 #if defined (ENABLE_AUTO_BED_LEVELING) && defined (DELTA)
464
   #error "Bed Auto Leveling is still not compatible with Delta Kinematics."
498
   #error "Bed Auto Leveling is still not compatible with Delta Kinematics."
465
 #endif
499
 #endif

+ 23
- 9
Marlin/configurator/css/configurator.css View File

45
 #message p.message { color: #080; background: #CFC; }
45
 #message p.message { color: #080; background: #CFC; }
46
 #message p.error { color: #F00; background: #FF4; }
46
 #message p.error { color: #F00; background: #FF4; }
47
 #message p.warning { color: #FF0; background: #BA4; }
47
 #message p.warning { color: #FF0; background: #BA4; }
48
-#message p.message span {
48
+#message p.message span,
49
+#message p.error span,
50
+#message p.warning span {
49
 	color: #A00;
51
 	color: #A00;
50
 	background: rgba(255, 255, 255, 1);
52
 	background: rgba(255, 255, 255, 1);
51
 	border: 1px solid rgba(0,0,0,0.5);
53
 	border: 1px solid rgba(0,0,0,0.5);
89
 	}
91
 	}
90
 input[type="text"], select { margin: 0.75em 0 0; }
92
 input[type="text"], select { margin: 0.75em 0 0; }
91
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
93
 input[type="checkbox"], input[type="radio"], input[type="file"] { margin: 1em 0 0; }
92
-input[type="checkbox"], input[type="radio"].enabler { margin-left: 1em; }
94
+input[type="checkbox"].enabler, input[type="radio"].enabler { margin-left: 1em; }
93
 
95
 
94
 input:disabled { color: #BBB; }
96
 input:disabled { color: #BBB; }
95
 
97
 
96
-#more input[type="text"] { width: 20em; }
98
+#config_form input[type="text"].subitem { width: 4em; }
99
+#config_form input[type="text"].subitem+.subitem { margin-left: 4px; }
97
 
100
 
98
-#more label {
99
-	width: 240px; /* label area */
101
+input[type="text"].added { width: 20em; }
102
+label.added {
103
+	width: 275px; /* label area */
100
 	height: 1em;
104
 	height: 1em;
101
 	padding: 10px 360px 10px 1em;
105
 	padding: 10px 360px 10px 1em;
102
 	margin-right: -350px;
106
 	margin-right: -350px;
103
 	text-align: right;
107
 	text-align: right;
104
 	}
108
 	}
105
 
109
 
106
-
107
 ul.tabs { padding: 0; list-style: none; }
110
 ul.tabs { padding: 0; list-style: none; }
108
 ul.tabs li { display: inline; }
111
 ul.tabs li { display: inline; }
109
 ul.tabs li a,
112
 ul.tabs li a,
192
 
195
 
193
 /* Tooltips Checkbox */
196
 /* Tooltips Checkbox */
194
 
197
 
195
-#tipson { float: right; font-weight: bold; font-size: 100%; font-family: helvetica; }
196
-#tipson input { float: none; display: inline; }
198
+#tipson {
199
+	width: auto;
200
+	height: auto;
201
+	padding: 0;
202
+	margin-right: 0;
203
+	float: right;
204
+	font-weight: bold;
205
+	font-size: 100%;
206
+	font-family: helvetica;
207
+	text-align: left;
208
+	cursor: pointer;
209
+	}
210
+#tipson input { float: none; display: inline; cursor: pointer; }
197
 
211
 
198
 /* Config Text */
212
 /* Config Text */
199
 
213
 
206
 	clear: both;
220
 	clear: both;
207
 	background-color: #FFF;
221
 	background-color: #FFF;
208
 	color: #000;
222
 	color: #000;
209
-	font-family: "Fira Mono";
223
+	font-family: "Fira Mono", monospace;
210
 	font-size: small;
224
 	font-size: small;
211
 	}
225
 	}
212
 
226
 

+ 19
- 7
Marlin/configurator/index.html View File

25
         <div id="tooltip"></div>
25
         <div id="tooltip"></div>
26
 
26
 
27
         <label>Drop Files Here:</label><input type="file" id="file-upload" />
27
         <label>Drop Files Here:</label><input type="file" id="file-upload" />
28
-        <div id="tipson"><input type="checkbox" checked /> ?</div>
28
+        <label id="tipson"><input type="checkbox" checked /> ?</label>
29
         <br class="clear" />
29
         <br class="clear" />
30
 
30
 
31
         <fieldset id="machine">
31
         <fieldset id="machine">
40
 
40
 
41
           <label class="newline">Motherboard:</label><select name="MOTHERBOARD"></select>
41
           <label class="newline">Motherboard:</label><select name="MOTHERBOARD"></select>
42
 
42
 
43
-          <label class="newline">Custom Name:</label><input name="CUSTOM_MENDEL_NAME" class="switchable" type="text" size="14" maxlength="12" value="" />
43
+          <label class="newline">Custom Name:</label><input name="CUSTOM_MENDEL_NAME" type="text" size="14" maxlength="12" value="" />
44
 
44
 
45
-          <label class="newline">Machine UUID:</label><input name="MACHINE_UUID" class="switchable" type="text" size="38" maxlength="36" value="" />
45
+          <label class="newline">Machine UUID:</label><input name="MACHINE_UUID" type="text" size="38" maxlength="36" value="" />
46
 
46
 
47
           <label class="newline">Extruders:</label><select name="EXTRUDERS"></select>
47
           <label class="newline">Extruders:</label><select name="EXTRUDERS"></select>
48
 
48
 
52
             <input name="PS_DEFAULT_OFF" type="checkbox" value="1" checked />
52
             <input name="PS_DEFAULT_OFF" type="checkbox" value="1" checked />
53
         </fieldset>
53
         </fieldset>
54
 
54
 
55
+        <fieldset id="homing">
56
+          <legend>Homing</legend>
57
+        </fieldset>
58
+
55
         <fieldset id="temperature">
59
         <fieldset id="temperature">
56
           <legend>Temperature</legend>
60
           <legend>Temperature</legend>
57
           <label class="newline">Temp Sensor 0:</label><select name="TEMP_SENSOR_0"></select>
61
           <label class="newline">Temp Sensor 0:</label><select name="TEMP_SENSOR_0"></select>
69
             <input name="TEMP_RESIDENCY_TIME" type="text" size="3" maxlength="2" />
73
             <input name="TEMP_RESIDENCY_TIME" type="text" size="3" maxlength="2" />
70
         </fieldset>
74
         </fieldset>
71
 
75
 
72
-        <fieldset id="hotends">
73
-          <legend>Hot Ends</legend>
76
+        <fieldset id="extruder">
77
+          <legend>Extruder</legend>
78
+        </fieldset>
79
+
80
+        <fieldset id="lcd">
81
+          <legend>LCD / SD</legend>
82
+        </fieldset>
83
+
84
+        <fieldset id="bedlevel">
85
+          <legend>Bed Leveling</legend>
74
         </fieldset>
86
         </fieldset>
75
 
87
 
76
-        <fieldset id="heatbed">
77
-          <legend>Heated Bed</legend>
88
+        <fieldset id="extras">
89
+          <legend>Extras</legend>
78
         </fieldset>
90
         </fieldset>
79
 
91
 
80
         <fieldset id="more">
92
         <fieldset id="more">

+ 177
- 76
Marlin/configurator/js/configurator.js View File

143
       $config = $('#config_text pre'),
143
       $config = $('#config_text pre'),
144
       $config_adv = $('#config_adv_text pre'),
144
       $config_adv = $('#config_adv_text pre'),
145
       define_list = [[],[]],
145
       define_list = [[],[]],
146
+      define_section = {},
146
       boards_list = {},
147
       boards_list = {},
147
       therms_list = {},
148
       therms_list = {},
148
       total_config_lines,
149
       total_config_lines,
308
     /**
309
     /**
309
      * Get all the unique define names
310
      * Get all the unique define names
310
      */
311
      */
311
-    getDefinesFromText: function(txt) {
312
-      var leave_out_defines = ['CONFIGURATION_H', 'CONFIGURATION_ADV_H', 'STRING_VERSION', 'STRING_URL', 'STRING_VERSION_CONFIG_H', 'STRING_CONFIG_H_AUTHOR', 'STRING_SPLASH_LINE1', 'STRING_SPLASH_LINE2'];
313
-      // Get all the unique #define's and save them in an array
314
-      var r, define_obj = {}, findDef = new RegExp('#define[ \\t]+(\\w+)', 'gm');
312
+    updateDefinesFromText: function(index, txt) {
313
+      var section = 'machine',
314
+          leave_out_defines = ['CONFIGURATION_H', 'CONFIGURATION_ADV_H', 'STRING_VERSION', 'STRING_URL', 'STRING_VERSION_CONFIG_H', 'STRING_CONFIG_H_AUTHOR', 'STRING_SPLASH_LINE1', 'STRING_SPLASH_LINE2'],
315
+          define_sect = {},
316
+          r, findDef = new RegExp('(@section|#define)[ \\t]+(\\w+)', 'gm');
315
       while((r = findDef.exec(txt)) !== null) {
317
       while((r = findDef.exec(txt)) !== null) {
316
-        if ($.inArray(r[1], leave_out_defines) < 0 && !(r[1] in define_obj))
317
-          define_obj[r[1]] = null;
318
+        var name = r[2];
319
+        if (r[1] == '@section')
320
+          section = name;
321
+        else if ($.inArray(name, leave_out_defines) < 0 && !(name in define_sect))
322
+          define_sect[name] = section;
318
       }
323
       }
319
-      this.log(Object.keys(define_obj), 2);
320
-      return Object.keys(define_obj);
324
+      define_list[index] = Object.keys(define_sect);
325
+      $.extend(define_section, define_sect);
326
+      this.log(define_list[index], 2);
321
     },
327
     },
322
 
328
 
323
     /**
329
     /**
327
       var e = adv ? 1 : 0, n = 0;
333
       var e = adv ? 1 : 0, n = 0;
328
       var fail_list = [];
334
       var fail_list = [];
329
       $.each(define_list[e], function(i,name) {
335
       $.each(define_list[e], function(i,name) {
330
-        if (!$('#'+name).length) {
331
-          var $ff = $('#more'),
332
-              inf = self.getDefineInfo(name, adv);
336
+        var section = define_section[name];
337
+        if (section != 'hidden' && !$('#'+name).length) {
338
+          var inf = self.getDefineInfo(name, adv);
339
+
333
           if (inf) {
340
           if (inf) {
334
-            var $newlabel = $('<label>',{for:name}).text(name.toLabel());
341
+
342
+            var $ff = $('#'+section), $newfield,
343
+                $newlabel = $('<label>',{for:name,class:'added'}).text(name.toLabel());
344
+
335
             // if (!(++n % 3))
345
             // if (!(++n % 3))
336
               $newlabel.addClass('newline');
346
               $newlabel.addClass('newline');
337
 
347
 
338
-            var $newfield;
339
-            if (inf.options !== undefined) {
340
-              $newfield = $('<select>'); //.addOptions(inf.options);
348
+            $ff.append($newlabel);
349
+
350
+            // Multiple fields?
351
+            if (inf.type == 'list') {
352
+              for (var i=0; i<inf.size; i++) {
353
+                var fieldname = i > 0 ? name+'-'+i : name;
354
+                $newfield = $('<input>',{type:'text',size:6,maxlength:10,id:fieldname,name:fieldname,class:'subitem added'}).prop({defineInfo:inf});
355
+                $ff.append($newfield);
356
+              }
341
             }
357
             }
342
             else {
358
             else {
343
-              $newfield = inf.type == 'switch' ? $('<input>',{type:'checkbox'}) : $('<input>',{type:'text',size:10,maxlength:40});
359
+              // Items with options, either toggle or select
360
+              // TODO: Radio buttons for other values
361
+              if (inf.options !== undefined) {
362
+                if (inf.type == 'toggle') {
363
+                  $newfield = $('<input>',{type:'checkbox'});
364
+                }
365
+                else {
366
+                  // Otherwise selectable
367
+                  $newfield = $('<select>');
368
+                }
369
+                // ...Options added when field initialized
370
+              }
371
+              else {
372
+                $newfield = inf.type == 'switch' ? $('<input>',{type:'checkbox'}) : $('<input>',{type:'text',size:10,maxlength:40});
373
+              }
374
+              $newfield.attr({id:name,name:name,class:'added'}).prop({defineInfo:inf});
375
+              // Add the new field to the form
376
+              $ff.append($newfield);
344
             }
377
             }
345
-            $newfield.attr({id:name,name:name}).prop({defineInfo:inf});
346
-            // Add the new field to the form
347
-            $ff.append($newlabel, $newfield);
348
           }
378
           }
349
           else
379
           else
350
             fail_list.push(name);
380
             fail_list.push(name);
410
       // When a config file loads defines might change
440
       // When a config file loads defines might change
411
       if (init_index != null) {
441
       if (init_index != null) {
412
         var adv = init_index == 1;
442
         var adv = init_index == 1;
413
-        define_list[init_index] = this.getDefinesFromText(txt);
414
-        this.log(define_list[init_index], 2);
415
-        this.purgeDefineInfo(adv);
416
-        this.createFieldsForDefines(init_index);
443
+        this.purgeAddedFields(init_index);
444
+        this.updateDefinesFromText(init_index, txt);
445
+        this.createFieldsForDefines(adv);
417
         this.refreshConfigForm(init_index);
446
         this.refreshConfigForm(init_index);
418
         this.activateDownloadLink(adv);
447
         this.activateDownloadLink(adv);
419
       }
448
       }
446
       });
475
       });
447
 
476
 
448
       // Get all 'switchable' class items and add a checkbox
477
       // Get all 'switchable' class items and add a checkbox
449
-      $form.find('.switchable').each(function(){
450
-        $(this).after(
451
-          $('<input>',{type:'checkbox',value:'1',class:'enabler'}).prop('checked',true)
452
-            .attr('id',this.id + '-switch')
453
-            .change(self.handleSwitch)
454
-        );
455
-      });
478
+      // $form.find('.switchable').each(function(){
479
+      //   $(this).after(
480
+      //     $('<input>',{type:'checkbox',value:'1',class:'enabler added'})
481
+      //       .prop('checked',true)
482
+      //       .attr('id',this.id + '-switch')
483
+      //       .change(self.handleSwitch)
484
+      //   );
485
+      // });
456
 
486
 
457
       // Add options to the popup menus
487
       // Add options to the popup menus
458
       // $('#SERIAL_PORT').addOptions([0,1,2,3,4,5,6,7]);
488
       // $('#SERIAL_PORT').addOptions([0,1,2,3,4,5,6,7]);
516
       /**
546
       /**
517
        * Any manually-created form elements will remain
547
        * Any manually-created form elements will remain
518
        * where they are. Unknown defines (currently most)
548
        * where they are. Unknown defines (currently most)
519
-       * are added to the "More..." tab for now.
549
+       * are added to tabs based on section
520
        *
550
        *
521
        * Specific exceptions can be managed by applying
551
        * Specific exceptions can be managed by applying
522
        * classes to the associated form fields.
552
        * classes to the associated form fields.
550
       if (inf == null)
580
       if (inf == null)
551
         inf = elm.defineInfo = this.getDefineInfo(name, adv);
581
         inf = elm.defineInfo = this.getDefineInfo(name, adv);
552
 
582
 
553
-      // Set options on the field if there are any
554
-      if (inf.options !== undefined)
555
-        $elm.html('').addOptions(inf.options);
556
-
557
-      // Create a tooltip if there is one
583
+      // Create a tooltip on the label if there is one
558
       if (inf.tooltip) {
584
       if (inf.tooltip) {
559
         var $tipme = $elm.prev('label');
585
         var $tipme = $elm.prev('label');
560
         if ($tipme.length) {
586
         if ($tipme.length) {
583
         }
609
         }
584
       }
610
       }
585
 
611
 
586
-      $elm.unbind('input change');
587
-      $elm.on($elm.attr('type') == 'text' ? 'input' : 'change', this.handleChange);
612
+      // Make the element(s) respond to events
613
+      if (inf.type == 'list') {
614
+        // Multiple fields need to respond
615
+        for (var i=0; i<inf.size; i++) {
616
+          if (i > 0) $elm = $('#'+name+'-'+i);
617
+          $elm.unbind('input');
618
+          $elm.on('input', this.handleChange);
619
+        }
620
+      }
621
+      else {
622
+        var elmtype = $elm.attr('type');
623
+        // Set options on single fields if there are any
624
+        if (inf.options !== undefined && elmtype === undefined)
625
+          $elm.html('').addOptions(inf.options);
626
+        $elm.unbind('input change');
627
+        $elm.on(elmtype == 'text' ? 'input' : 'change', this.handleChange);
628
+      }
629
+
630
+      // Add an enabler checkbox if it needs one
631
+      if (inf.switchable && $('#'+name+'-switch').length == 0) {
632
+        // $elm = the last element added
633
+        $elm.after(
634
+          $('<input>',{type:'checkbox',value:'1',class:'enabler added'})
635
+            .prop('checked',self.defineIsEnabled(name))
636
+            .attr({id: name+'-switch'})
637
+            .change(self.handleSwitch)
638
+        );
639
+      }
588
 
640
 
589
       // Set the field's initial value from the define
641
       // Set the field's initial value from the define
590
       this.setFieldFromDefine(name);
642
       this.setFieldFromDefine(name);
592
 
644
 
593
     /**
645
     /**
594
      * Handle any value field being changed
646
      * Handle any value field being changed
647
+     * this = the field
595
      */
648
      */
596
     handleChange: function() { self.updateDefineFromField(this.id); },
649
     handleChange: function() { self.updateDefineFromField(this.id); },
597
 
650
 
598
     /**
651
     /**
599
      * Handle a switch checkbox being changed
652
      * Handle a switch checkbox being changed
653
+     * this = the switch checkbox
600
      */
654
      */
601
     handleSwitch: function() {
655
     handleSwitch: function() {
602
-      var $elm = $(this), $prev = $elm.prev();
603
-      var on = $elm.prop('checked') || false;
604
-      $prev.attr('disabled', !on);
605
-      self.setDefineEnabled($prev[0].id, on);
656
+      var $elm = $(this),
657
+          name = $elm[0].id.replace(/-.+/,''),
658
+          inf = $('#'+name)[0].defineInfo,
659
+          on = $elm.prop('checked') || false;
660
+
661
+      self.setDefineEnabled(name, on);
662
+
663
+      if (inf.type == 'list') {
664
+        // Multiple fields?
665
+        for (var i=0; i<inf.size; i++) {
666
+          $('#'+name+(i?'-'+i:'')).attr('disabled', !on);
667
+        }
668
+      }
669
+      else {
670
+        $elm.prev().attr('disabled', !on);
671
+      }
606
     },
672
     },
607
 
673
 
608
     /**
674
     /**
656
      */
722
      */
657
     updateDefineFromField: function(name) {
723
     updateDefineFromField: function(name) {
658
       this.log('updateDefineFromField:'+name,4);
724
       this.log('updateDefineFromField:'+name,4);
725
+
726
+      // Drop the suffix on sub-fields
727
+      name = name.replace(/-\d+$/, '');
728
+
659
       var $elm = $('#'+name), inf = $elm[0].defineInfo;
729
       var $elm = $('#'+name), inf = $elm[0].defineInfo;
660
       if (inf == null) return;
730
       if (inf == null) return;
661
 
731
 
662
       var isCheck = $elm.attr('type') == 'checkbox',
732
       var isCheck = $elm.attr('type') == 'checkbox',
663
-          val = isCheck ? $elm.prop('checked') : $elm.val();
733
+          val = isCheck ? $elm.prop('checked') : $elm.val().trim();
664
 
734
 
665
       var newline;
735
       var newline;
666
       switch(inf.type) {
736
       switch(inf.type) {
668
           var slash = val ? '' : '//';
738
           var slash = val ? '' : '//';
669
           newline = inf.line.replace(inf.repl, '$1'+slash+'$3');
739
           newline = inf.line.replace(inf.repl, '$1'+slash+'$3');
670
           break;
740
           break;
741
+        case 'list':
671
         case 'quoted':
742
         case 'quoted':
672
         case 'plain':
743
         case 'plain':
673
-          if (isCheck)
674
-            this.setMessage(name + ' should not be a checkbox!', 'error');
675
-          else
676
-            newline = inf.line.replace(inf.repl, '$1'+val.replace('$','\\$')+'$3');
744
+          if (isCheck) this.setMessage(name + ' should not be a checkbox!', 'error');
745
+        case 'toggle':
746
+          if (isCheck) {
747
+            val = val ? inf.options[1] : inf.options[0];
748
+          }
749
+          else {
750
+            if (inf.type == 'list')
751
+              for (var i=1; i<inf.size; i++) val += ', ' + $('#'+name+'-'+i).val().trim();
752
+          }
753
+          newline = inf.line.replace(inf.repl, '$1'+(''+val).replace('$','\\$')+'$3');
677
           break;
754
           break;
678
       }
755
       }
679
       this.setDefineLine(name, newline);
756
       this.setDefineLine(name, newline);
725
      * Set a form field to the current #define value in the config text
802
      * Set a form field to the current #define value in the config text
726
      */
803
      */
727
     setFieldFromDefine: function(name) {
804
     setFieldFromDefine: function(name) {
728
-      var $elm = $('#'+name), val = this.defineValue(name);
805
+      var $elm = $('#'+name), inf = $elm[0].defineInfo,
806
+          val = this.defineValue(name);
729
 
807
 
730
       this.log('setFieldFromDefine:' + name + ' to ' + val, 2);
808
       this.log('setFieldFromDefine:' + name + ' to ' + val, 2);
731
 
809
 
732
-      // Set the field value
733
-      $elm.attr('type') == 'checkbox' ? $elm.prop('checked', val) : $elm.val(''+val);
734
-
735
       // If the item has a checkbox then set enabled state too
810
       // If the item has a checkbox then set enabled state too
736
-      var $cb = $('#'+name+'-switch');
811
+      var $cb = $('#'+name+'-switch'), on = true;
737
       if ($cb.length) {
812
       if ($cb.length) {
738
-        var on = self.defineIsEnabled(name);
813
+        on = self.defineIsEnabled(name);
814
+        $cb.prop('checked', on);
815
+      }
816
+
817
+      if (inf.type == 'list') {
818
+        $.each(val.split(','),function(i,v){
819
+          var $e = i > 0 ? $('#'+name+'-'+i) : $elm;
820
+          $e.val(v.trim());
821
+          $e.attr('disabled', !on);
822
+        });
823
+      }
824
+      else {
825
+        if (inf.type == 'toggle') val = val == inf.options[1];
826
+        $elm.attr('type') == 'checkbox' ? $elm.prop('checked', val) : $elm.val(''+val);
739
         $elm.attr('disabled', !on); // enable/disable the form field (could also dim it)
827
         $elm.attr('disabled', !on); // enable/disable the form field (could also dim it)
740
-        $cb.prop('checked', on);    // check/uncheck the checkbox
741
       }
828
       }
742
     },
829
     },
743
 
830
 
744
     /**
831
     /**
745
-     * Purge #define information for one of the config files
832
+     * Purge added fields and all their define info
746
      */
833
      */
747
-    purgeDefineInfo: function(adv) {
748
-      if (adv === undefined) adv = false;
749
-      $('[name]').each(function() {
750
-        var inf = this.defineInfo;
751
-        if (inf && adv === inf.adv) $(this).removeProp('defineInfo');
834
+    purgeAddedFields: function(index) {
835
+      $.each(define_list[index], function(){
836
+        $('#'+this + ",[id^='"+this+"-'],label[for='"+this+"']").filter('.added').remove();
752
       });
837
       });
838
+      define_list[index] = [];
753
     },
839
     },
754
 
840
 
755
     /**
841
     /**
805
             line:   result[0],
891
             line:   result[0],
806
             pre:    result[1] === undefined ? '' : result[1].replace('//',''),
892
             pre:    result[1] === undefined ? '' : result[1].replace('//',''),
807
             define: result[2],
893
             define: result[2],
894
+            size:   result[3].split(',').length,
808
             post:   result[4] === undefined ? '' : result[4]
895
             post:   result[4] === undefined ? '' : result[4]
809
           });
896
           });
810
           info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '\{([^\}]*)\}' + info.post.regEsc(), 'm');
897
           info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '\{([^\}]*)\}' + info.post.regEsc(), 'm');
837
                 define: result[2],
924
                 define: result[2],
838
                 post:   result[4] === undefined ? '' : result[4]
925
                 post:   result[4] === undefined ? '' : result[4]
839
               });
926
               });
927
+              if (result[3].match(/false|true/)) {
928
+                info.type = 'toggle';
929
+                info.options = ['false','true'];
930
+              }
840
               info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '(\\S*)' + info.post.regEsc(), 'm');
931
               info.regex = new RegExp('([ \\t]*//)?[ \\t]*' + info.define.regEsc() + '(\\S*)' + info.post.regEsc(), 'm');
841
               info.repl  = new RegExp('(([ \\t]*//)?[ \\t]*' + info.define.regEsc() + ')\\S*(' + info.post.regEsc() + ')', 'm');
932
               info.repl  = new RegExp('(([ \\t]*//)?[ \\t]*' + info.define.regEsc() + ')\\S*(' + info.post.regEsc() + ')', 'm');
842
             }
933
             }
854
 
945
 
855
         // Get all the comments immediately before the item
946
         // Get all the comments immediately before the item
856
         var r, s;
947
         var r, s;
857
-        findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line.regEsc(), 'g');
948
+        findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n)?' + info.line.regEsc(), 'g');
858
         if (r = findDef.exec(txt)) {
949
         if (r = findDef.exec(txt)) {
950
+          // Get the text of the found comments
859
           findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
951
           findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
860
           while((s = findDef.exec(r[1])) !== null) {
952
           while((s = findDef.exec(r[1])) !== null) {
861
-            if (s[1].match(/^#define[ \\t]/) != null) {
862
-              tooltip = '';
863
-              break;
864
-            }
865
-            // JSON data? Save as select options
866
-            if (s[1].match(/:[\[{]/) != null) {
867
-              // TODO
868
-              // :[1-6] = value limits
869
-              eval('info.options = ' + s[1].substr(1));
870
-            }
871
-            else {
872
-              // Other lines added to the tooltip
873
-              tooltip += ' ' + s[1] + '\n';
953
+            var tip = s[1].replace(/[ \\t]*(={5,}|@section[ \\t]+\w+)[ \\t]*/g, '');
954
+            if (tip.length) {
955
+              if (tip.match(/^#define[ \\t]/) != null) {
956
+                tooltip = '';
957
+                break;
958
+              }
959
+              // JSON data? Save as select options
960
+              if (!info.options && tip.match(/:[\[{]/) != null) {
961
+                // TODO
962
+                // :[1-6] = value limits
963
+                var o; eval('o=' + tip.substr(1));
964
+                info.options = o;
965
+                if (Object.prototype.toString.call(o) == "[object Array]" && o.length == 2 && !eval(''+o[0]))
966
+                  info.type = 'toggle';
967
+              }
968
+              else {
969
+                // Other lines added to the tooltip
970
+                tooltip += ' ' + tip + '\n';
971
+              }
874
             }
972
             }
875
           }
973
           }
876
         }
974
         }
877
 
975
 
878
-        findDef = new RegExp('^'+name); // To strip the name from the start
976
+
977
+        // Add .tooltip and .lineNum properties to the info
978
+        findDef = new RegExp('^'+name); // Strip the name from the tooltip
879
         $.extend(info, {
979
         $.extend(info, {
880
           tooltip: '<strong>'+name+'</strong> '+tooltip.trim().replace(findDef,'').toHTML(),
980
           tooltip: '<strong>'+name+'</strong> '+tooltip.trim().replace(findDef,'').toHTML(),
881
-          lineNum: this.getLineNumberOfText(info.line, txt)
981
+          lineNum: this.getLineNumberOfText(info.line, txt),
982
+          switchable: (info.type != 'switch' && info.line.match(/^[ \t]*\/\//)) || false // Disabled? Mark as "switchable"
882
         });
983
         });
883
       }
984
       }
884
       else
985
       else

Loading…
Cancel
Save