Skip to content

Simplify leaf adding with one-line commands #36

@adamoferro

Description

@adamoferro

When you want to add a leaf you need to use several commands which could probably be summarized in simple one-line ones.

Example.
To add a moisture capacity sensor this is the way now:

//creates the moisture sensor
	moist = gn_leaf_create(node, "moist", gn_capacitive_moisture_sensor_config,
			4096);
	//set the channel 4
	gn_leaf_param_init_double(moist, GN_CMS_PARAM_ADC_CHANNEL, 4); //GPIO12
	//set update time
	gn_leaf_param_init_double(moist, GN_CMS_PARAM_UPDATE_TIME_SEC, 5);
	//set initial status to active (on)
	gn_leaf_param_init_bool(moist, GN_CMS_PARAM_ACTIVE, true);

It could be summarized with something like:

	moist = gn_cms_fastcreate(node, "moist", 4, 5)

where implicitly "under the hood" all the other parameters are set. E.g., probably nobody would change that "4096" and a standard user when creates a leaf wants it active.

It could be:

  1. a function defined in each leaf (like in the example above), or
  2. if possible, a general function taking in input also the leaf type... but different leaves have different parameters, so it may be not straightforward

In case 1, leaf should have a standard and common "name" to use in every function/parameter definition/file names, in order to make it easy to know the name of the "fastcreate" function.
For example capacity moisture sensors have file names and config called "capacity_moisture_sensor" but parameters called "CMS". This may generate confusion.
Temperature ds18b20 sensors, instead, maintain the same name everywhere.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions