Skip to content

Commit

Permalink
Fix Nextion set_component_picture call (esphome#6378)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edwardtfn committed Mar 16, 2024
1 parent 4f59b14 commit e753ac3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions esphome/components/nextion/nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
/**
* Set the picture of an image component.
* @param component The component name.
* @param value The picture name.
* @param value The picture id.
*
* Example:
* ```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`.
*/
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.
* @param component The component name.
Expand Down
4 changes: 2 additions & 2 deletions esphome/components/nextion/nextion_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

void Nextion::set_component_picture(const char *component, const char *picture) {
this->add_no_result_to_queue_with_printf_("set_component_picture", "%s.val=%s", component, 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.pic=%d", component, picture_id);
}

void Nextion::set_component_text(const char *component, const char *text) {
Expand Down

0 comments on commit e753ac3

Please sign in to comment.