🧑💻 Update pins formatter script (#26450)
This commit is contained in:
parent
12881d5576
commit
20445b8e83
10
Makefile
10
Makefile
|
@ -5,6 +5,7 @@ CONTAINER_IMAGE := marlin-dev
|
|||
|
||||
help:
|
||||
@echo "Tasks for local development:"
|
||||
@echo "* format-pins: Reformat all pins files
|
||||
@echo "* tests-single-ci: Run a single test from inside the CI"
|
||||
@echo "* tests-single-local: Run a single test locally"
|
||||
@echo "* tests-single-local-docker: Run a single test locally, using docker"
|
||||
|
@ -57,3 +58,12 @@ tests-all-local-docker:
|
|||
setup-local-docker:
|
||||
$(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
|
||||
.PHONY: setup-local-docker
|
||||
|
||||
PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
|
||||
|
||||
.PHONY: $(PINS)
|
||||
|
||||
$(PINS): %:
|
||||
@echo "Formatting $@" && node buildroot/share/scripts/pinsformat.js $@
|
||||
|
||||
format-pins: $(PINS)
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
//
|
||||
// SPI
|
||||
//
|
||||
#define SPI_DEVICE -1 // Maple
|
||||
#define SPI_DEVICE -1 // Maple
|
||||
#define SCK_PIN -1
|
||||
#define MISO_PIN -1
|
||||
#define MOSI_PIN -1
|
||||
|
|
|
@ -202,7 +202,7 @@
|
|||
#undef E1_ENABLE_PIN
|
||||
#endif
|
||||
|
||||
#else // !SOFTWARE_DRIVER_ENABLE
|
||||
#else // !SOFTWARE_DRIVER_ENABLE
|
||||
|
||||
// A chip-select pin is needed for each driver.
|
||||
|
||||
|
|
|
@ -372,7 +372,7 @@
|
|||
#define TFT_BACKLIGHT_PIN EXP1_03_PIN
|
||||
|
||||
#define TOUCH_BUTTONS_HW_SPI
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
|
||||
//#define TFT_RST_PIN EXP2_07_PIN
|
||||
#define TFT_SCK_PIN EXP2_02_PIN
|
||||
|
|
|
@ -464,7 +464,7 @@
|
|||
#define NEOPIXEL_PIN EXP1_06_PIN
|
||||
#endif
|
||||
|
||||
#else // !FYSETC_MINI_12864
|
||||
#else // !FYSETC_MINI_12864
|
||||
|
||||
#if ENABLED(MKS_MINI_12864)
|
||||
#define DOGLCD_CS EXP1_06_PIN
|
||||
|
|
|
@ -350,7 +350,7 @@
|
|||
#define LCD_PINS_D7 EXP1_08_PIN
|
||||
#define KILL_PIN -1 // NC
|
||||
|
||||
#else // !MKS_12864OLED_SSD1306
|
||||
#else // !MKS_12864OLED_SSD1306
|
||||
|
||||
#define LCD_PINS_RS EXP1_04_PIN
|
||||
|
||||
|
@ -385,7 +385,7 @@
|
|||
#define NEOPIXEL_PIN EXP1_06_PIN
|
||||
#endif
|
||||
|
||||
#else // !FYSETC_MINI_12864
|
||||
#else // !FYSETC_MINI_12864
|
||||
|
||||
#if ENABLED(MKS_MINI_12864)
|
||||
#define DOGLCD_CS EXP1_06_PIN
|
||||
|
|
|
@ -368,7 +368,7 @@
|
|||
#define TFT_QUEUE_SIZE 6144
|
||||
#endif
|
||||
|
||||
#else // !MKS_12864OLED_SSD1306
|
||||
#else // !MKS_12864OLED_SSD1306
|
||||
|
||||
#define LCD_PINS_RS EXP1_04_PIN
|
||||
|
||||
|
@ -403,7 +403,7 @@
|
|||
#define NEOPIXEL_PIN EXP1_06_PIN
|
||||
#endif
|
||||
|
||||
#else // !FYSETC_MINI_12864
|
||||
#else // !FYSETC_MINI_12864
|
||||
|
||||
#if ENABLED(MKS_MINI_12864)
|
||||
#define DOGLCD_CS EXP1_06_PIN
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
// Power monitoring pins - set to 0 for main VIN, 1 for dedicated bed supply rail.
|
||||
// Don't forget to enable POWER_MONITOR_VOLTAGE in Configuration_adv.h
|
||||
// and set POWER_MONITOR_VOLTS_PER_VOLT to 0.090909.
|
||||
#define POWER_MONITOR_VOLTAGE_PIN 0
|
||||
#define POWER_MONITOR_VOLTAGE_PIN 0
|
||||
|
||||
/** LCD SDCARD
|
||||
* ------ ------
|
||||
|
@ -181,7 +181,7 @@
|
|||
#define BTN_ENC EXP1_02_PIN
|
||||
#define SD_DETECT_PIN EXP2_07_PIN
|
||||
|
||||
#else // !IS_NEWPANEL
|
||||
#else // !IS_NEWPANEL
|
||||
|
||||
#define SHIFT_CLK_PIN EXP2_07_PIN
|
||||
#define SHIFT_LD_PIN EXP2_03_PIN
|
||||
|
|
|
@ -30,6 +30,6 @@
|
|||
|
||||
#define BOARD_INFO_NAME "GT2560 Rev.A+"
|
||||
|
||||
#define SERVO0_PIN 11
|
||||
#define SERVO0_PIN 11
|
||||
|
||||
#include "pins_GT2560_REV_A.h"
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
// Origin: https://github.com/mjrice/PICA/blob/97ab9e7771a8e5eef97788f3adcc17a9fa9de9b9/pica_schematic.pdf
|
||||
// ATmega2560
|
||||
|
||||
#define HEATER_0_PIN 9 // E0
|
||||
#define HEATER_1_PIN 10 // E1
|
||||
#define FAN0_PIN 11
|
||||
#define FAN2_PIN 12
|
||||
#define HEATER_0_PIN 9 // E0
|
||||
#define HEATER_1_PIN 10 // E1
|
||||
#define FAN0_PIN 11
|
||||
#define FAN2_PIN 12
|
||||
|
||||
#include "pins_PICA.h"
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
|
||||
#define SD_DETECT_PIN 72
|
||||
|
||||
#else // !MINIRAMBO_10A
|
||||
#else // !MINIRAMBO_10A
|
||||
|
||||
// AUX-4
|
||||
#define BEEPER_PIN 84
|
||||
|
|
|
@ -232,7 +232,7 @@
|
|||
|
||||
#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
|
||||
|
||||
#else // !VIKI2 && !miniVIKI
|
||||
#else // !VIKI2 && !miniVIKI
|
||||
|
||||
#define BEEPER_PIN 79 // AUX-4
|
||||
|
||||
|
@ -253,7 +253,7 @@
|
|||
#define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder
|
||||
#endif
|
||||
|
||||
#else // !IS_NEWPANEL - old style panel with shift register
|
||||
#else // !IS_NEWPANEL - old style panel with shift register
|
||||
|
||||
// No Beeper added
|
||||
#define BEEPER_PIN 33
|
||||
|
|
|
@ -35,23 +35,23 @@
|
|||
//
|
||||
// Heaters / Fans
|
||||
//
|
||||
#define MOSFET_D_PIN 7
|
||||
#define MOSFET_D_PIN 7
|
||||
|
||||
#include "pins_RAMPS.h"
|
||||
|
||||
//
|
||||
// Misc. Functions
|
||||
//
|
||||
#define SDPOWER_PIN 1
|
||||
#define SDPOWER_PIN 1
|
||||
|
||||
#define PS_ON_PIN 12
|
||||
#define PS_ON_PIN 12
|
||||
|
||||
//
|
||||
// LCD / Controller
|
||||
//
|
||||
#if HAS_WIRED_LCD && IS_NEWPANEL
|
||||
|
||||
#define SD_DETECT_PIN 6
|
||||
#define SD_DETECT_PIN 6
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@
|
|||
//
|
||||
#define SDSS 53
|
||||
#ifndef LED_PIN
|
||||
#define LED_PIN 13 // The Formbot v 1 board has almost no unassigned pins on it. The Board's LED
|
||||
#endif // is a good place to get a signal to control the Max7219 LED Matrix.
|
||||
#define LED_PIN 13 // The Formbot v 1 board has almost no unassigned pins.
|
||||
#endif // The Board's LED is a good place to connect the Max7219 Matrix.
|
||||
|
||||
// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector
|
||||
#define FILWIDTH_PIN 5 // Analog Input
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
//
|
||||
// Only 3 Limit Switch plugs on Micromake C1
|
||||
//
|
||||
#define X_STOP_PIN 2
|
||||
#define Y_STOP_PIN 15
|
||||
#define Z_STOP_PIN 19
|
||||
#define X_STOP_PIN 2
|
||||
#define Y_STOP_PIN 15
|
||||
#define Z_STOP_PIN 19
|
||||
|
||||
#include "pins_RAMPS.h"
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
#ifndef FAN0_PIN
|
||||
#define FAN0_PIN 11
|
||||
#endif
|
||||
#else // RAMPS_V_1_1 or RAMPS_V_1_2
|
||||
#else // RAMPS_V_1_1 or RAMPS_V_1_2
|
||||
#define HEATER_0_PIN 10
|
||||
#define HEATER_BED_PIN 8
|
||||
#ifndef FAN0_PIN
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#define DEFAULT_MACHINE_NAME "Raise3D N Series"
|
||||
|
||||
// Raise3D uses thermocouples on the standard input pins
|
||||
#define TEMP_0_PIN 15 // Analog Input
|
||||
#define TEMP_1_PIN 14 // Analog Input
|
||||
#define TEMP_0_PIN 15 // Analog Input
|
||||
#define TEMP_1_PIN 14 // Analog Input
|
||||
|
||||
#include "pins_RUMBA.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
//
|
||||
// Servos
|
||||
//
|
||||
#define SERVO1_PIN 12 // 2560 PIN 25/PB6
|
||||
#define SERVO1_PIN 12 // 2560 PIN 25/PB6
|
||||
|
||||
//
|
||||
// Import RAMPS 1.4 pins
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
|
||||
#define SD_DETECT_PIN 38
|
||||
|
||||
#else // !IS_NEWPANEL - Old style panel with shift register
|
||||
#else // !IS_NEWPANEL - Old style panel with shift register
|
||||
|
||||
// Buttons attached to a shift register
|
||||
#define SHIFT_CLK_PIN 38
|
||||
|
|
|
@ -195,7 +195,7 @@
|
|||
|
||||
#define SD_DETECT_PIN 38
|
||||
|
||||
#else // !IS_NEWPANEL - Old style panel with shift register
|
||||
#else // !IS_NEWPANEL - Old style panel with shift register
|
||||
|
||||
// Buttons attached to a shift register
|
||||
#define SHIFT_CLK_PIN 38
|
||||
|
|
|
@ -374,7 +374,7 @@
|
|||
#define KILL_PIN -1
|
||||
#if ANY(OLED_HW_IIC, OLED_HW_SPI)
|
||||
#error "Oops! You must choose SW SPI for ZRIB V53 board and connect the OLED screen to EXP1 connector."
|
||||
#else // SW_SPI
|
||||
#else // SW_SPI
|
||||
#define DOGLCD_A0 LCD_PINS_DC
|
||||
#define DOGLCD_MOSI 35 // SDA
|
||||
#define DOGLCD_SCK 37 // SCK
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
//
|
||||
// Temperature Sensors
|
||||
//
|
||||
#define TEMP_0_PIN 9 // Analog Input
|
||||
#define TEMP_1_PIN -1 // Analog Input
|
||||
#define TEMP_BED_PIN 10 // Analog Input
|
||||
#define TEMP_0_PIN 9 // Analog Input
|
||||
#define TEMP_1_PIN -1 // Analog Input
|
||||
#define TEMP_BED_PIN 10 // Analog Input
|
||||
|
||||
#include "../ramps/pins_RAMPS.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define BOARD_INFO_NAME "RAMPS-FD v2"
|
||||
|
||||
#ifndef E0_CS_PIN
|
||||
#define E0_CS_PIN 69 // moved from A13 to A15 on v2.2, if not earlier
|
||||
#define E0_CS_PIN 69 // moved from A13 to A15 on v2.2, if not earlier
|
||||
#endif
|
||||
|
||||
#include "pins_RAMPS_FD_V1.h"
|
||||
|
@ -44,9 +44,9 @@
|
|||
#define MARLIN_EEPROM_SIZE 0x10000 // 64K in a 24C512
|
||||
|
||||
#ifndef PS_ON_PIN
|
||||
#define PS_ON_PIN 12
|
||||
#define PS_ON_PIN 12
|
||||
#endif
|
||||
|
||||
#ifndef FILWIDTH_PIN
|
||||
#define FILWIDTH_PIN 5 // Analog Input on AUX2
|
||||
#define FILWIDTH_PIN 5 // Analog Input on AUX2
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,6 @@
|
|||
|
||||
#define BOARD_INFO_NAME "Azteeg X1"
|
||||
|
||||
#define FAN0_PIN 4
|
||||
#define FAN0_PIN 4
|
||||
|
||||
#include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11
|
||||
|
|
|
@ -173,7 +173,7 @@
|
|||
// Marlin so this can be used for BEEPER_PIN. You can use this pin
|
||||
// with M42 instead of BEEPER_PIN.
|
||||
#define BEEPER_PIN 27
|
||||
#else // Sanguinololu >=1.3
|
||||
#else // Sanguinololu >=1.3
|
||||
#define LCD_PINS_RS 4
|
||||
#define LCD_PINS_EN 17
|
||||
#define LCD_PINS_D4 30
|
||||
|
@ -197,7 +197,7 @@
|
|||
#define BEEPER_PIN 27
|
||||
#define DOGLCD_CS 28
|
||||
|
||||
#else // !MAKRPANEL
|
||||
#else // !MAKRPANEL
|
||||
|
||||
#define DOGLCD_CS 29
|
||||
|
||||
|
@ -250,7 +250,7 @@
|
|||
#define BTN_ENC 30
|
||||
#endif
|
||||
|
||||
#else // !LCD_FOR_MELZI && !ZONESTAR_LCD && !LCD_I2C_PANELOLU2
|
||||
#else // !LCD_FOR_MELZI && !ZONESTAR_LCD && !LCD_I2C_PANELOLU2
|
||||
|
||||
#define BTN_ENC 16
|
||||
#ifndef LCD_SDSS
|
||||
|
|
|
@ -235,7 +235,7 @@
|
|||
// #define NEOPIXEL_PIN EXP1_06_PIN
|
||||
//#endif
|
||||
|
||||
#else // !FYSETC_MINI_12864
|
||||
#else // !FYSETC_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -242,7 +242,7 @@
|
|||
// #define NEOPIXEL_PIN EXP1_05_PIN
|
||||
//#endif
|
||||
|
||||
#else // !FYSETC_MINI_12864
|
||||
#else // !FYSETC_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP1_06_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -356,7 +356,7 @@
|
|||
#endif
|
||||
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -34,6 +34,6 @@
|
|||
#define Z_STEP_PIN PC14
|
||||
#define Z_DIR_PIN PC15
|
||||
|
||||
#define BTN_ENC_EN -1
|
||||
#define BTN_ENC_EN -1
|
||||
|
||||
#include "pins_MKS_ROBIN_E3_common.h"
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
#define DOGLCD_SCK PB13
|
||||
#define DOGLCD_MOSI PB15
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP3_06_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
#define TFTGLCD_CS PB11
|
||||
#endif
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 PA6
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -356,7 +356,7 @@
|
|||
#endif
|
||||
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 PE14
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -279,7 +279,7 @@
|
|||
#define DOGLCD_SCK PB13
|
||||
#define DOGLCD_MOSI PB15
|
||||
|
||||
#else // !MKS_MINI_12864 && !ENDER2_STOCKDISPLAY
|
||||
#else // !MKS_MINI_12864 && !ENDER2_STOCKDISPLAY
|
||||
|
||||
#define LCD_PINS_D4 PF14
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -494,7 +494,7 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
#endif // HAS_WIRED_LCD
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
// Alter timing for graphical display
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
|
|
@ -523,10 +523,10 @@
|
|||
#define BTN_EN2 EXP2_05_PIN
|
||||
|
||||
#ifndef TFT_WIDTH
|
||||
#define TFT_WIDTH 480
|
||||
#define TFT_WIDTH 480
|
||||
#endif
|
||||
#ifndef TFT_HEIGHT
|
||||
#define TFT_HEIGHT 320
|
||||
#define TFT_HEIGHT 320
|
||||
#endif
|
||||
|
||||
#if ENABLED(BTT_TFT35_SPI_V1_0)
|
||||
|
@ -592,7 +592,7 @@
|
|||
#define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN
|
||||
|
||||
#define TOUCH_BUTTONS_HW_SPI
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
|
||||
#define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
|
||||
#define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
|
||||
|
|
|
@ -359,7 +359,7 @@
|
|||
#endif
|
||||
//#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -360,7 +360,7 @@
|
|||
// Required for MKS_MINI_12864 with this board
|
||||
//#define MKS_LCD12864B
|
||||
|
||||
#else // !MKS_MINI_12864
|
||||
#else // !MKS_MINI_12864
|
||||
|
||||
#define LCD_PINS_D4 EXP1_05_PIN
|
||||
#if IS_ULTIPANEL
|
||||
|
|
|
@ -336,7 +336,7 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
#endif // HAS_WIRED_LCD
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
// Alter timing for graphical display
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
|
|
@ -506,7 +506,7 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
#endif // HAS_WIRED_LCD
|
||||
#endif // HAS_WIRED_LCD
|
||||
|
||||
// Alter timing for graphical display
|
||||
#if IS_U8GLIB_ST7920
|
||||
|
|
|
@ -536,7 +536,7 @@
|
|||
#define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN
|
||||
|
||||
#define TOUCH_BUTTONS_HW_SPI
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
|
||||
|
||||
#define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS
|
||||
#define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
#define KILL_PIN EXT_AUX_A2_IO
|
||||
#define HOME_PIN EXT_AUX_A4_IO
|
||||
|
||||
#else // Use the expansion header for spindle control
|
||||
#else // Use the expansion header for spindle control
|
||||
|
||||
//
|
||||
// M3/M4/M5 - Spindle/Laser Control
|
||||
|
|
|
@ -27,6 +27,15 @@ String.prototype.rpad = function(len, chr) {
|
|||
return s;
|
||||
};
|
||||
|
||||
// Concatenate a string, adding a space if necessary
|
||||
// to avoid merging two words
|
||||
String.prototype.concat_with_space = function(str) {
|
||||
const c = this.substr(-1), d = str.charAt(0);
|
||||
if (c !== ' ' && c !== '' && d !== ' ' && d !== '')
|
||||
str = ' ' + str;
|
||||
return this + str;
|
||||
};
|
||||
|
||||
const mpatt = [ '-?\\d{1,3}', 'P[A-I]\\d+', 'P\\d_\\d+', 'Pin[A-Z]\\d\\b' ],
|
||||
definePatt = new RegExp(`^\\s*(//)?#define\\s+[A-Z_][A-Z0-9_]+\\s+(${mpatt[0]}|${mpatt[1]}|${mpatt[2]}|${mpatt[3]})\\s*(//.*)?$`, 'gm'),
|
||||
ppad = [ 3, 4, 5, 5 ],
|
||||
|
@ -56,6 +65,7 @@ else
|
|||
// Find the pin pattern so non-pin defines can be skipped
|
||||
function get_pin_pattern(txt) {
|
||||
var r, m = 0, match_count = [ 0, 0, 0, 0 ];
|
||||
var max_match_count = 0, max_match_index = -1;
|
||||
definePatt.lastIndex = 0;
|
||||
while ((r = definePatt.exec(txt)) !== null) {
|
||||
let ind = -1;
|
||||
|
@ -65,12 +75,15 @@ function get_pin_pattern(txt) {
|
|||
return r[2].match(p);
|
||||
}) ) {
|
||||
const m = ++match_count[ind];
|
||||
if (m >= 5) {
|
||||
return { match: mpatt[ind], pad:ppad[ind] };
|
||||
if (m > max_match_count) {
|
||||
max_match_count = m;
|
||||
max_match_index = ind;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
if (max_match_index === -1) return null;
|
||||
|
||||
return { match:mpatt[max_match_index], pad:ppad[max_match_index] };
|
||||
}
|
||||
|
||||
function process_text(txt) {
|
||||
|
@ -79,13 +92,14 @@ function process_text(txt) {
|
|||
if (!patt) return txt;
|
||||
const pindefPatt = new RegExp(`^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(${patt.match})\\s*(//.*)?$`),
|
||||
noPinPatt = new RegExp(`^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(-1)\\s*(//.*)?$`),
|
||||
skipPatt1 = new RegExp('^(\\s*(//)?#define)\\s+(AT90USB|USBCON|(BOARD|DAC|FLASH|HAS|IS|USE)_.+|.+_(ADDRESS|AVAILABLE|BAUDRATE|CLOCK|CONNECTION|DEFAULT|FREQ|ITEM|MODULE|NAME|ONLY|PERIOD|RANGE|RATE|SERIAL|SIZE|SPI|STATE|STEP|TIMER))\\s+(.+)\\s*(//.*)?$'),
|
||||
skipPatt1 = new RegExp('^(\\s*(//)?#define)\\s+(AT90USB|USBCON|(BOARD|DAC|FLASH|HAS|IS|USE)_.+|.+_(ADDRESS|AVAILABLE|BAUDRATE|CLOCK|CONNECTION|DEFAULT|ERROR|EXTRUDERS|FREQ|ITEM|MKS_BASE_VERSION|MODULE|NAME|ONLY|ORIENTATION|PERIOD|RANGE|RATE|READ_RETRIES|SERIAL|SIZE|SPI|STATE|STEP|TIMER|VERSION))\\s+(.+)\\s*(//.*)?$'),
|
||||
skipPatt2 = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(0x[0-9A-Fa-f]+|\d+|.+[a-z].+)\\s*(//.*)?$'),
|
||||
skipPatt3 = /^\s*#e(lse|ndif)\b.*$/,
|
||||
aliasPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+([A-Z_][A-Z0-9_()]+)\\s*(//.*)?$'),
|
||||
switchPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'),
|
||||
undefPatt = new RegExp('^(\\s*(//)?#undef)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'),
|
||||
defPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+([-_\\w]+)\\s*(//.*)?$'),
|
||||
condPatt = new RegExp('^(\\s*(//)?#(if|ifn?def|else|elif)(\\s+\\S+)*)\\s+(//.*)$'),
|
||||
condPatt = new RegExp('^(\\s*(//)?#(if|ifn?def|elif)(\\s+\\S+)*)\\s+(//.*)$'),
|
||||
commPatt = new RegExp('^\\s{20,}(//.*)?$');
|
||||
const col_value_lj = col_comment - patt.pad - 2;
|
||||
var r, out = '', check_comment_next = false;
|
||||
|
@ -110,8 +124,8 @@ function process_text(txt) {
|
|||
if (do_log) console.log("pin:", line);
|
||||
const pinnum = r[4].charAt(0) == 'P' ? r[4] : r[4].lpad(patt.pad);
|
||||
line = r[1] + ' ' + r[3];
|
||||
line = line.rpad(col_value_lj) + pinnum;
|
||||
if (r[5]) line = line.rpad(col_comment) + r[5];
|
||||
line = line.rpad(col_value_lj).concat_with_space(pinnum);
|
||||
if (r[5]) line = line.rpad(col_comment).concat_with_space(r[5]);
|
||||
}
|
||||
else if ((r = noPinPatt.exec(line)) !== null) {
|
||||
//
|
||||
|
@ -119,10 +133,10 @@ function process_text(txt) {
|
|||
//
|
||||
if (do_log) console.log("pin -1:", line);
|
||||
line = r[1] + ' ' + r[3];
|
||||
line = line.rpad(col_value_lj) + '-1';
|
||||
if (r[5]) line = line.rpad(col_comment) + r[5];
|
||||
line = line.rpad(col_value_lj).concat_with_space('-1');
|
||||
if (r[5]) line = line.rpad(col_comment).concat_with_space(r[5]);
|
||||
}
|
||||
else if (skipPatt2.exec(line) !== null) {
|
||||
else if (skipPatt2.exec(line) !== null || skipPatt3.exec(line) !== null) {
|
||||
//
|
||||
// #define SKIP_ME
|
||||
//
|
||||
|
@ -134,8 +148,8 @@ function process_text(txt) {
|
|||
//
|
||||
if (do_log) console.log("alias:", line);
|
||||
line = r[1] + ' ' + r[3];
|
||||
line += r[4].lpad(col_value_rj + 1 - line.length);
|
||||
if (r[5]) line = line.rpad(col_comment) + r[5];
|
||||
line = line.concat_with_space(r[4].lpad(col_value_rj + 1 - line.length));
|
||||
if (r[5]) line = line.rpad(col_comment).concat_with_space(r[5]);
|
||||
}
|
||||
else if ((r = switchPatt.exec(line)) !== null) {
|
||||
//
|
||||
|
@ -143,7 +157,7 @@ function process_text(txt) {
|
|||
//
|
||||
if (do_log) console.log("switch:", line);
|
||||
line = r[1] + ' ' + r[3];
|
||||
if (r[4]) line = line.rpad(col_comment) + r[4];
|
||||
if (r[4]) line = line.rpad(col_comment).concat_with_space(r[4]);
|
||||
check_comment_next = true;
|
||||
}
|
||||
else if ((r = defPatt.exec(line)) !== null) {
|
||||
|
@ -152,7 +166,7 @@ function process_text(txt) {
|
|||
//
|
||||
if (do_log) console.log("def:", line);
|
||||
line = r[1] + ' ' + r[3] + ' ';
|
||||
line += r[4].lpad(col_value_rj + 1 - line.length);
|
||||
line = line.concat_with_space(r[4].lpad(col_value_rj + 1 - line.length));
|
||||
if (r[5]) line = line.rpad(col_comment - 1) + ' ' + r[5];
|
||||
}
|
||||
else if ((r = undefPatt.exec(line)) !== null) {
|
||||
|
@ -161,14 +175,14 @@ function process_text(txt) {
|
|||
//
|
||||
if (do_log) console.log("undef:", line);
|
||||
line = r[1] + ' ' + r[3];
|
||||
if (r[4]) line = line.rpad(col_comment) + r[4];
|
||||
if (r[4]) line = line.rpad(col_comment).concat_with_space(r[4]);
|
||||
}
|
||||
else if ((r = condPatt.exec(line)) !== null) {
|
||||
//
|
||||
// #if ...
|
||||
// #if, #ifdef, #ifndef, #elif ...
|
||||
//
|
||||
if (do_log) console.log("cond:", line);
|
||||
line = r[1].rpad(col_comment) + r[5];
|
||||
line = r[1].rpad(col_comment).concat_with_space(r[5]);
|
||||
check_comment_next = true;
|
||||
}
|
||||
out += line + '\n';
|
||||
|
|
Loading…
Reference in a new issue