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

...
	IOR_BL0937_CF,
	//iodetail:{"name":"BL0937_CF1",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"CF1 pin for BL0937 energy measuring devices. Set all BL0937 pins to autostart BL0937 driver. Don't forget to calibrate it later.",
	//iodetail:"channels used":"0",
	//iodetail:"channel 1 usage":"",
	//iodetail:"channel 2 usage":"",
	//iodetail:"htmlPinRoleName":"BL0937CF1",
	//iodetail:"enum":"IOR_BL0937_CF1",
	//iodetail:"file":"pins_and_roles.h",
	//iodetail:"define":"ENABLE_DRIVER_BL0937",
	//iodetail:"driver":"src/driver/drv_bl0937.c"}
	IOR_BL0937_CF1,
	//iodetail:{"name":"ADC",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"Analog to Digital converter converts voltage to channel value which is later published by MQTT and also can be used to trigger scriptable events",
	//iodetail:"channels used":"1",
	//iodetail:"channel 1 usage":"Input",
	//iodetail:"channel 2 usage":"",
	//iodetail:"htmlPinRoleName":"ADC",
	//iodetail:"enum":"IOR_ADC",
	//iodetail:"file":"pins_and_roles.h",
	//iodetail:"define":"",
	//iodetail:"driver":""}
	IOR_ADC,
	//iodetail:{"name":"SM2135_DAT",
	//iodetail:"title":"TODO",
	//iodetail:"descr":"SM2135 DAT pin for SM2135 modified-I2C twowire LED driver, used in RGBCW lights. Set both required SM2135 pins to autostart the related driver. Don't forget to Map the colors order later, so colors are not mixed.",
	//iodetail:"channels used":"0",
	//iodetail:"channel 1 usage":"",
	//iodetail:"channel 2 usage":"",
	//iodetail:"htmlPinRoleName":"SM2135DAT",
	//iodetail:"enum":"IOR_SM2135_DAT",
	//iodetail:"file":"pins_and_roles.h",
	//iodetail:"define":"ENABLE_DRIVER_LED",
	//iodetail:"driver":"src/driver/drv_sm2135.c"}
	IOR_SM2135_DAT,
...

You can see, I added some more "//iodetails"-fields containing all information we might need:
- the number of channels an ioRole needs
- descriptions, what channels are used for
- a "define" so we can see, which #define will enable the driver for this role

This gives
one place to hold (and extend) all information
some additional information which allows us
to add information about channel usage
to "hide" all roles, which can't be used in the FW because the driver is not present

I think it will be clearer if I can e.g. select the role SHTX only, if the driver is present.
As a side effect, I can squeeze the image a bit - missing roles don't need a description text!

Since we already use python in Makefile, I changed the original used "awk-script" ( #1773 ) to a python one.

This is the release W800 page (you see, not all IORoles will fit the page, there are quite some more missing of all 87 roles)
W800_rel

The same page with this PR

  • all (available) roles fit the page
  • IORole 17 configured before with a role for not present BL0937 driver is shown accordingly:
    W800_PR

If you set
#define ENABLE_USE_PINROLE_CHAN_DESC 1

You can see some ideas what else is possible:

  • only showing used PINS
  • showing some descriptions on what channels are used for:
    W800_PR_2

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