Skip to content

Commit c2c1ff8

Browse files
committed
πŸ§‘β€πŸ’» Update pinsformat.js
1 parent e240874 commit c2c1ff8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

β€Žbuildroot/share/scripts/pinsformat.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ String.prototype.rpad = function(len, chr) {
2727
return s;
2828
};
2929

30-
const mpatt = [ '-?\\d+', 'P[A-I]\\d+', 'P\\d_\\d+' ],
31-
definePatt = new RegExp(`^\\s*(//)?#define\\s+[A-Z_][A-Z0-9_]+\\s+(${mpatt[0]}|${mpatt[1]}|${mpatt[2]})\\s*(//.*)?$`, 'gm'),
32-
ppad = [ 3, 4, 5 ],
30+
const mpatt = [ '-?\\d{1,3}', 'P[A-I]\\d+', 'P\\d_\\d+', 'Pin[A-Z]\\d\\b' ],
31+
definePatt = new RegExp(`^\\s*(//)?#define\\s+[A-Z_][A-Z0-9_]+\\s+(${mpatt[0]}|${mpatt[1]}|${mpatt[2]}|${mpatt[3]})\\s*(//.*)?$`, 'gm'),
32+
ppad = [ 3, 4, 5, 5 ],
3333
col_comment = 50,
3434
col_value_rj = col_comment - 3;
3535

@@ -55,7 +55,7 @@ else
5555

5656
// Find the pin pattern so non-pin defines can be skipped
5757
function get_pin_pattern(txt) {
58-
var r, m = 0, match_count = [ 0, 0, 0 ];
58+
var r, m = 0, match_count = [ 0, 0, 0, 0 ];
5959
definePatt.lastIndex = 0;
6060
while ((r = definePatt.exec(txt)) !== null) {
6161
let ind = -1;
@@ -65,7 +65,7 @@ function get_pin_pattern(txt) {
6565
return r[2].match(p);
6666
}) ) {
6767
const m = ++match_count[ind];
68-
if (m >= 10) {
68+
if (m >= 5) {
6969
return { match: mpatt[ind], pad:ppad[ind] };
7070
}
7171
}
@@ -79,7 +79,8 @@ function process_text(txt) {
7979
if (!patt) return txt;
8080
const pindefPatt = new RegExp(`^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(${patt.match})\\s*(//.*)?$`),
8181
noPinPatt = new RegExp(`^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(-1)\\s*(//.*)?$`),
82-
skipPatt = new RegExp('^(\\s*(//)?#define)\\s+(AT90USB|USBCON|BOARD_.+|.+_MACHINE_NAME|.+_SERIAL)\\s+(.+)\\s*(//.*)?$'),
82+
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*(//.*)?$'),
83+
skipPatt2 = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+(0x[0-9A-Fa-f]+|\d+|.+[a-z].+)\\s*(//.*)?$'),
8384
aliasPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s+([A-Z_][A-Z0-9_()]+)\\s*(//.*)?$'),
8485
switchPatt = new RegExp('^(\\s*(//)?#define)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'),
8586
undefPatt = new RegExp('^(\\s*(//)?#undef)\\s+([A-Z_][A-Z0-9_]+)\\s*(//.*)?$'),
@@ -96,6 +97,12 @@ function process_text(txt) {
9697
// Comments in column 45
9798
line = ''.rpad(col_comment) + r[1];
9899

100+
else if (skipPatt1.exec(line) !== null) {
101+
//
102+
// #define SKIP_ME
103+
//
104+
if (do_log) console.log("skip:", line);
105+
}
99106
else if ((r = pindefPatt.exec(line)) !== null) {
100107
//
101108
// #define MY_PIN [pin]
@@ -115,7 +122,7 @@ function process_text(txt) {
115122
line = line.rpad(col_value_lj) + '-1';
116123
if (r[5]) line = line.rpad(col_comment) + r[5];
117124
}
118-
else if ((r = skipPatt.exec(line)) !== null) {
125+
else if (skipPatt2.exec(line) !== null) {
119126
//
120127
// #define SKIP_ME
121128
//

0 commit comments

Comments
Β (0)