Fix Nextion set_component_picture call (#6378)

This fixes the call to the Nextion display to change the pic id from a component.
It was previously changing the attribute `val`, which is related to something else.
In addition, I've changed the parameter for picture_id to be uint_8, as Nextion requires an integer from 0 to 255 on this attribute.
This commit is contained in:
Edward Firmo 2024-03-16 06:19:25 +01:00 committed by GitHub
parent 4f59b14ab0
commit e753ac3a97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -82,16 +82,16 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
/** /**
* Set the picture of an image component. * Set the picture of an image component.
* @param component The component name. * @param component The component name.
* @param value The picture name. * @param value The picture id.
* *
* Example: * Example:
* ```cpp * ```cpp
* it.set_component_picture("pic", "4"); * it.set_component_picture("pic", 4);
* ``` * ```
* *
* This will change the image of the component `pic` to the image with ID `4`. * This will change the image of the component `pic` to the image with ID `4`.
*/ */
void set_component_picture(const char *component, const char *picture); void set_component_picture(const char *component, uint8_t picture_id);
/** /**
* Set the background color of a component. * Set the background color of a component.
* @param component The component name. * @param component The component name.

View file

@ -197,8 +197,8 @@ void Nextion::disable_component_touch(const char *component) {
this->add_no_result_to_queue_with_printf_("disable_component_touch", "tsw %s,0", component); this->add_no_result_to_queue_with_printf_("disable_component_touch", "tsw %s,0", component);
} }
void Nextion::set_component_picture(const char *component, const char *picture) { void Nextion::set_component_picture(const char *component, uint8_t picture_id) {
this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.val=%s", component, picture); this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.pic=%d", component, picture_id);
} }
void Nextion::set_component_text(const char *component, const char *text) { void Nextion::set_component_text(const char *component, const char *text) {