OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

rework of pin config page

Open MaxineMuster opened this issue 4 months ago • 0 comments

Use a single text file to combine all information about roles and channels.

Actually we have information in this files:

new_pins.h

typedef enum ioRole_e {
	//iodetail:{"name":"None",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"Default pin role; this pin does nothing.",
	//iodetail:"enum":"IOR_None",
	//iodetail:"file":"new_pins.h",
	//iodetail:"driver":""}
	IOR_None,
	//iodetail:{"name":"Relay",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"an active-high relay. This relay is closed when a logical 1 value is on linked channel",
	//iodetail:"enum":"IOR_Relay",
	//iodetail:"file":"new_pins.h",
	//iodetail:"driver":""}
	IOR_Relay,
....
	IOR_Total_Options
} ioRole_t;

new_pins.c

int PIN_IOR_NofChan(int test){
	if( ( test == IOR_None ) || ( ( test >= IOR_LED_WIFI )&&( test <= IOR_Button_ToggleAll_n ) ) || ( ( test >= IOR_BL0937_SEL )&&( test <= IOR_BL0937_CF1 ) )
		 || ( ( test >= IOR_SM2135_DAT )&&( test <= IOR_BP1658CJ_CLK ) ) || ( ( test >= IOR_IRRecv )&&( test <= IOR_Button_ScriptOnly_n ) )
		 || ( test == IOR_CHT83XX_CLK ) || ( test == IOR_SHT3X_CLK ) || ( test == IOR_BL0937_SEL_n ) || ( test == IOR_SGP_CLK ) ){
		return 0;
	}
...
};

new_http.c


const char* htmlPinRoleNames[] = {
	" " ,
	"Rel" ,
..
};

... and maybe in http_fns.c if we want to add some information about channel usage.

This approach will put all in a file with this entries


// START marker for "getcommands.js" script
//START_OF_IODETAILS
	//iodetail:{"name":"None",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"Default pin role; this pin does nothing.",
	//iodetail:"enum":"IOR_None",
	//iodetail:"file":"pins_and_roles.h",
	//iodetail:"driver":""}
	IOR_None," ",0
	//iodetail:{"name":"Relay",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"an active-high relay. This relay is closed when a logical 1 value is on linked channel",
	//iodetail:"enum":"IOR_Relay",
	//iodetail:"file":"pins_and_roles.h",
	//iodetail:"driver":""}
	IOR_Relay,"Rel",1,"C"
...

So, here's some kind of documentation:

// This file is the source for pin roles and their features:
// It will be used to automatically generate the needed input 
//  - the "enum ioRole_e" (used in new_pins.h)
//  - the "htmlPinRoleNames" (used in new_http.c)
//  - the number of channels per role (used in new_pins.c)
//  - will provide optional descriptions of the use of channels - for future use
// 
// every entry is of the form 
//  	<enum id>,"<PinRoleName>",<# of channels>,"<description of channel 1>","<description of channel 2>",
//        ^                ^                ^                ^                       ^
//        |                |                |                |                       | 
//        |                |                |                |                       |-- optional description of the use of channel 1, else ""
//        |                |                |                | 
//        |                |                |                |---------------- optional description of the use of channel 2, else ""
//        |                |                | 
//        |                |                |---------------- number of channels per role (used in new_pins.c)
//        |                | 
//        |                |---------------- htmlPinRoleNames" (used in new_http.c)
//        | 
//        |---------------- "enum ioRole_e" (used in new_pins.h)
//
//
//
//	as "description" for channels: if none, use ""
//	to keep input small, use these 
//		T	Temperature
//		H	Humidity
//		C	Connector		to be discussed I would propose this for relay, buttons and LED "connected" to this pin 
//		I	Input
//		X	Toggle
//	
//	-- and as before in new_pins.h, the comment for documentation will prepend the row

Changed also

Combining the two "IR" driver lines in one in "drv_main.c" (else getcommands.js will complain about duplicate descriptions - alternative the second command could simply be without comment)

A "quick and dirty" solution for getcommands.js removing needed lines in code - simply not allowing to write to this files.


diff --git a/scripts/getcommands.js b/scripts/getcommands.js
index db0efaabe0..4d1d5878ad 100644
--- a/scripts/getcommands.js
+++ b/scripts/getcommands.js
@@ -629,7 +629,7 @@ function getFolder(name, cb) {
 
 					newlines.push(lines[i]);
 				}
-				if (modified) {
+				if (modified && false) {
 					let newdata = newlines.join('\n');
 					try {
 						fs.writeFileSync(file, newdata);

MaxineMuster avatar Aug 24 '25 18:08 MaxineMuster