Skip to content

Conversation

MaxineMuster
Copy link
Contributor

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 and others added 12 commits July 26, 2025 21:31
…c/rolesNchannels.h".

This will be imported by all files using pin-roles and its attributes (i.e. number of channels)
while "old" information is commented out.

The input file also includes information on use of channels ("T" for temperature, "H" for humidity ...).

If you set
it will include this information to pin config page.

Size of resulting image is slightly smaller due to som optimizations in JS code.

If you include the additional information, it will be approx 350bytes larger
…arning (or even errors with -Werror)

Simulators not working, need to figure out how to invoke awk-script there ...
for testing: Enable extended channels on W800
…n new header file src/rolesNchannels.h

Add some descriptions for LED drivers and display
….c to avoid duplicate commands

Qick and dirty fix for getcommands.js modifying code - by disabling writes adding "&& false" as condition
@MaxineMuster MaxineMuster changed the title rework or pin config page rework of pin config page Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant