[nextion] Add basic functions to Intelligent series (#6791)

This commit is contained in:
Edward Firmo 2024-05-23 23:11:34 +02:00 committed by GitHub
parent c2d67659f3
commit 9d03f47233
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 86 additions and 1 deletions

View file

@ -952,6 +952,73 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
*/
bool set_protocol_reparse_mode(bool active_mode);
// ======== Nextion Intelligent Series ========
/**
* Set the video id of a component.
* @param component The component name.
* @param vid_id The video ID.
*
* Example:
* ```cpp
* it.set_component_vid("textview", 1);
* ```
*
* This will change the video id of the component `textview`.
*
* Note: Requires Nextion Intelligent series display.
*/
void set_component_vid(const char *component, uint8_t vid_id);
/**
* Set the drag availability of a component.
* @param component The component name.
* @param drag False: Drag not available, True: Drag available.
*
* Example:
* ```cpp
* it.set_component_drag("textview", true);
* ```
*
* This will enable drag to the component `textview`.
*
* Note: Requires Nextion Intelligent series display.
*/
void set_component_drag(const char *component, bool drag);
/**
* Set the opaqueness (fading) of a component.
* @param component The component name.
* @param aph An integer between 0 and 127 related to the opaqueness/fading level.
*
* Example:
* ```cpp
* it.set_component_aph("textview", 64);
* ```
*
* This will set the opaqueness level of the component `textview` to 64.
*
* Note: Requires Nextion Intelligent series display.
*/
void set_component_aph(const char *component, uint8_t aph);
/**
* Set the position of a component.
* @param component The component name.
* @param x The new X (horizontal) coordinate for the component.
* @param y The new Y (vertical) coordinate for the component.
*
* Example:
* ```cpp
* it.set_component_aph("textview", 64, 35);
* ```
*
* This will move the component `textview` to the column 64 of row 35 of the display.
*
* Note: Requires Nextion Intelligent series display.
*/
void set_component_position(const char *component, uint32_t x, uint32_t y);
// ========== INTERNAL METHODS ==========
// (In most use cases you won't need these)
void register_touch_component(NextionComponentBase *obj) { this->touch_.push_back(obj); }

View file

@ -148,7 +148,25 @@ void Nextion::set_component_pic(const char *component, uint8_t pic_id) {
}
void Nextion::set_component_picc(const char *component, uint8_t pic_id) {
this->add_no_result_to_queue_with_printf_("set_component_pic", "%s.picc=%" PRIu8, component, pic_id);
this->add_no_result_to_queue_with_printf_("set_component_picc", "%s.picc=%" PRIu8, component, pic_id);
}
// Set video
void Nextion::set_component_vid(const char *component, uint8_t vid_id) {
this->add_no_result_to_queue_with_printf_("set_component_vid", "%s.vid=%" PRIu8, component, vid_id);
}
void Nextion::set_component_drag(const char *component, bool drag) {
this->add_no_result_to_queue_with_printf_("set_component_drag", "%s.drag=%i", component, drag ? 1 : 0);
}
void Nextion::set_component_aph(const char *component, uint8_t aph) {
this->add_no_result_to_queue_with_printf_("set_component_aph", "%s.aph=%" PRIu8, component, aph);
}
void Nextion::set_component_position(const char *component, uint32_t x, uint32_t y) {
this->add_no_result_to_queue_with_printf_("set_component_position_x", "%s.x=%" PRIu32, component, x);
this->add_no_result_to_queue_with_printf_("set_component_position_y", "%s.y=%" PRIu32, component, y);
}
void Nextion::set_component_text_printf(const char *component, const char *format, ...) {