Skip to content

Issues overloading set() function on custom ValueConsumer for a display #790

Answered by mairas
caballero03 asked this question in Q&A
Discussion options

You must be logged in to vote

Having a single class inheriting from multiple consumer types was a pattern used in previous SensESP versions, but I removed support for it during the version 3 development. I believe some technical reasons (that I fail to remember) were the breaking point, but I also didn't like the pattern much. It wasn't possible to create multiple consumers of the same type, and the usage of such multi-consumers could be confusing.

However, there's a better pattern available. In MyDisplay, define public LambdaConsumer members for the inputs you need. For example, for brightness, you would have:

...
 public:
  LambdaConsumer<int> brightness_{[this](int value) {
   this->set_backlight(value);   
  }};

F…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@caballero03
Comment options

@mairas
Comment options

@caballero03
Comment options

Answer selected by caballero03
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #789 on November 16, 2024 11:15.