@@ -184,7 +184,7 @@ var groups=[
184184 [ 'TODO: //LCDs' ] ,
185185]
186186var type = i => i . value == undefined ?'BOOL' :'string'
187- var type1 = i => i . value && ( i . select ?'select' :/ \" .* \" / . test ( i . value ) ?'string' :/ f a l s e | t r u e / . test ( i . value ) ?'boolean' :'numeric' ) || undefined //"
187+ var type1 = i => i . value && ( i . select ?'select' :/ \" .* \" / . test ( i . value ) ?'string' :/ ^ f a l s e | t r u e $ / . test ( i . value ) ?'boolean' :'numeric' ) || undefined //"
188188var section0 = i => i . name + ' ' + type ( i ) + ( i . condition . length && ( ' == ' + i . condition . join ( ' AND ' ) ) || '' )
189189var section = i => ( { name :i . name , type :type ( i ) , condition :i . condition . length && i . condition || undefined , value :i . value || ! i . disabled } )
190190var section1 = ( p , i ) => ( p [ i . name ] = { changed :i . changed , type :type1 ( i ) , condition :i . condition . length && i . condition || undefined , value :i . value , disabled :i . disabled , line :i . line , select :i . select } , p )
@@ -312,13 +312,33 @@ module.exports.makeHfile=(root,name,dir)=>conf=>{
312312 . catch ( a => ( console . log ( 'fail update h file: ' , file , a ) , a ) )
313313}
314314
315- exports . getBoards = ( file ) => {
316- return Promise . resolve ( file )
315+ exports . getBoards = file => Promise . resolve ( file )
317316 . then ( inFile )
317+ . catch ( a => '' )
318318 . then ( text2array )
319319 . then ( a => a . map ( i => i . replace ( / ( .* # d e f i n e \s + B O A R D _ .+ ?) ( \/ \/ .* ) / , "$1" ) ) )
320320 . then ( a => a . map ( i => i . match ( / .* # d e f i n e \s + ( \w + ) \s + ( \d + ) \s * / ) ) )
321321 . then ( a => a . filter ( i => i ) )
322- . then ( a => ( { list : a . map ( i => i [ 1 ] ) , objs : a . map ( i => ( { name : i [ 1 ] , value : i [ 2 ] } ) ) } ) )
323- // .then(JSON.stringify)
322+ . then ( a => ( {
323+ list : a . map ( i => i [ 1 ] ) ,
324+ objs : a . map ( i => ( { name : i [ 1 ] , value : i [ 2 ] } ) ) ,
325+ select : a . reduce ( ( p , i ) => ( p [ i [ 1 ] ] = i [ 1 ] + ' (' + i [ 2 ] + ')' , p ) , { } )
326+ } ) )
327+
328+ const thermistors = / T H E R M I S T O R _ I D \s + = = \s + ( - ? \d * ) .* \n .* T H E R M I S T O R _ N A M E \s + " ( [ ^ " ] + ) / g;
329+ const splitter = ( regex , str ) => {
330+ var list = [ ] , m ;
331+ while ( ( m = regex . exec ( str ) ) !== null ) {
332+ if ( m . index === regex . lastIndex ) regex . lastIndex ++ ;
333+ list . push ( m ) ;
334+ }
335+ return list ;
324336}
337+ exports . getThermistors = file => Promise . resolve ( file )
338+ . then ( inFile )
339+ . catch ( a => '' )
340+ . then ( text => splitter ( thermistors , text ) )
341+ . then ( a => ( {
342+ list : a . map ( i => i [ 2 ] ) ,
343+ select : a . reduce ( ( p , i ) => ( p [ i [ 1 ] ] = i [ 2 ] + ' (' + i [ 1 ] + ')' , p ) , { '0' : 'Not used' } )
344+ } ) )
0 commit comments