Skip to content

Commit

Permalink
demo/high_res: add compatibility for board with no button configured
Browse files Browse the repository at this point in the history
If button configuration is not detected, then screen should not block
input on sliding Lock on HMI.

Signed-off-by: Divyansh Mittal <[email protected]>
  • Loading branch information
Divyansh Mittal committed Jan 27, 2025
1 parent f526522 commit 98f0151
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions demos/high_res/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <sys/mman.h>
#include "lv_demo_high_res_private.h"

int button_configured = 0;

const char *ev_type[EV_CNT] = {
[EV_SYN] = "EV_SYN",
Expand Down Expand Up @@ -57,6 +58,7 @@ void *button_init(lv_demo_high_res_api_t * api)
int len_dev = strlen(dev);
int len_buffer = strlen(buffer);
dev[len_dev - 1] = buffer[len_buffer - 2];
button_configured = 1;
}
else{
printf("Button not Configured\n");
Expand Down
3 changes: 2 additions & 1 deletion demos/high_res/lv_demo_high_res_api_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int delay_millis = 1000;
pthread_mutex_t delay_lock;
pthread_mutex_t playing_now_lock;
int playing_now=0;
extern int button_configured;

/**********************
* GLOBAL FUNCTIONS
Expand Down Expand Up @@ -135,7 +136,7 @@ static void output_subject_observer_cb(lv_observer_t * observer, lv_subject_t *
delay_millis = (int)(20.0+(1-fraction_delay)*230.0);
pthread_mutex_unlock(&delay_lock);
}
else if(strcmp(subject_name, "locked") == 0){
else if(button_configured && strcmp(subject_name, "locked") == 0){
lv_lock();
int lock_status = lv_subject_get_int(subject);
lv_indev_enable(NULL, !lock_status);
Expand Down

0 comments on commit 98f0151

Please sign in to comment.