Skip to content

Commit

Permalink
Merge pull request #43 from hb020/0.7.0
Browse files Browse the repository at this point in the history
added custom_state_subtopic
  • Loading branch information
fvanroie authored Oct 10, 2024
2 parents fc3e7c5 + 659ed3e commit a29c981
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/firmware/compiling/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void custom_every_5seconds();
bool custom_pin_in_use(uint8_t pin);
void custom_get_sensors(JsonDocument& doc);
void custom_topic_payload(const char* topic, const char* payload, uint8_t source);
void custom_state_subtopic(const char* subtopic, const char* payload);

#endif // HASP_USE_CUSTOM
#endif // HASP_CUSTOM_H
Expand All @@ -36,16 +37,22 @@ Otherwise it will have an impact on the UI responsiveness and/or other time-sens
`custom_every_second()` and `custom_every_5seconds()` functions are called every second and every 5 seconds respectively.
You can use these to execute non-time-critical code.

The function `custom_pin_in_use()` is used to indicate that a pin is in use. Return `true` if the pin used by your custom code.
The function `custom_pin_in_use(pin)` is used to indicate that a pin is in use. Return `true` if the pin used by your custom code.

Use `custom_get_sensors()` to add a sensor key and value to the periodic `sensor` MQTT messages.
Use `custom_get_sensors(doc)` to add a sensor key and value to the periodic `sensor` MQTT messages.
The function is called every 30 seconds by default, but the teleperiod interval can be changed by the user.
The `doc` variable is passed so you can add your JSON object too it. *(see below)*

With `custom_topic_payload()` you can receive custom topic & payload messages.
With `custom_topic_payload(topic, payload, source)` you can receive custom topic & payload messages.
You can use the value of the topic and payload variables to set LVGL attributes or perform custom actions.</br>
`source` indicates the module from wich the command is received. (`TAG_MQTT`, `TAG_CONS`, `TAG_TELN`, `TAG_HTTP`, ...)

With `custom_state_subtopic(subtopic, payload)` you get a copy of all status messages sent out.</br>
Examples:

* going to page 1: `subtopic` = `"page"` and `payload` = `"1"`
* click on a control: `subtopic` = "p2b15" and `payload` = `{"event":"up","val":0}`

## Customize functions

In `src/my_custom.cpp` you add the code to execute for each of the functions declared above.
Expand Down

0 comments on commit a29c981

Please sign in to comment.