Add status codes for scan
This commit is contained in:
@@ -8,7 +8,14 @@
|
|||||||
|
|
||||||
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
enum response_type {
|
||||||
|
RESPONSE_CHECK,
|
||||||
|
RESPONSE_CHECK_ID,
|
||||||
|
RESPONSE_CROSS,
|
||||||
|
RESPONSE_TRIANGLE
|
||||||
|
};
|
||||||
|
|
||||||
void screen_create(lv_obj_t *screen);
|
void screen_create(lv_obj_t *screen);
|
||||||
void screen_response(char *big, char *small, uint8_t id_req, uint32_t time);
|
void screen_response(char *big, char *small, uint8_t status, uint32_t time);
|
||||||
|
|
||||||
#endif /* end of include guard: SCREEN_H_CGT5FQUY */
|
#endif /* end of include guard: SCREEN_H_CGT5FQUY */
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
||||||
|
#include "miniaudio/miniaudio.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
@@ -6,6 +7,9 @@
|
|||||||
lv_display_t *display;
|
lv_display_t *display;
|
||||||
uint32_t idle_time;
|
uint32_t idle_time;
|
||||||
|
|
||||||
|
ma_result result;
|
||||||
|
ma_engine engine;
|
||||||
|
|
||||||
void key_pressed(lv_event_t *event)
|
void key_pressed(lv_event_t *event)
|
||||||
{
|
{
|
||||||
lv_key_t key = lv_indev_get_key(lv_indev_active());
|
lv_key_t key = lv_indev_get_key(lv_indev_active());
|
||||||
@@ -15,6 +19,13 @@ void key_pressed(lv_event_t *event)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
result = ma_engine_init(NULL, &engine);
|
||||||
|
if (result != MA_SUCCESS) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ma_engine_play_sound(&engine, "assets/hop_adult.wav", NULL);
|
||||||
|
|
||||||
lv_init();
|
lv_init();
|
||||||
#ifdef LV_TARGET_FB
|
#ifdef LV_TARGET_FB
|
||||||
display = lv_linux_fbdev_create();
|
display = lv_linux_fbdev_create();
|
||||||
|
|||||||
17
src/screen.c
17
src/screen.c
@@ -3,8 +3,8 @@
|
|||||||
*
|
*
|
||||||
* Description: Helper for screen
|
* Description: Helper for screen
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#include "screen.h"
|
||||||
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
#include "lvgl/lvgl.h" // IWYU pragma: keep
|
||||||
#include "lvgl/src/tick/lv_tick.h"
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -67,11 +67,11 @@ void set_opa(void *var, int32_t value)
|
|||||||
lv_obj_set_style_image_opa(obj, value, 0);
|
lv_obj_set_style_image_opa(obj, value, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_response(char *big, char *small, uint8_t id_req, uint32_t time)
|
void screen_response(char *big, char *small, uint8_t status, uint32_t time)
|
||||||
{
|
{
|
||||||
lv_label_set_text(label_reply_big, big);
|
lv_label_set_text(label_reply_big, big);
|
||||||
lv_label_set_text(label_reply_small, small);
|
lv_label_set_text(label_reply_small, small);
|
||||||
id_required = id_req;
|
id_required = status == RESPONSE_CHECK_ID;
|
||||||
response_timer = lv_tick_get() + time;
|
response_timer = lv_tick_get() + time;
|
||||||
update_response();
|
update_response();
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,8 @@ void screen_idle_update(lv_timer_t *data)
|
|||||||
update_response();
|
update_response();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_response() {
|
void update_response()
|
||||||
|
{
|
||||||
if (response_timer < lv_tick_get()) {
|
if (response_timer < lv_tick_get()) {
|
||||||
lv_obj_add_flag(img_check, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(img_check, LV_OBJ_FLAG_HIDDEN);
|
||||||
lv_obj_add_flag(img_id_required, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(img_id_required, LV_OBJ_FLAG_HIDDEN);
|
||||||
@@ -131,18 +132,22 @@ void update_response() {
|
|||||||
lv_obj_add_flag(img_logo, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(img_logo, LV_OBJ_FLAG_HIDDEN);
|
||||||
lv_obj_add_flag(label_contactless, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(label_contactless, LV_OBJ_FLAG_HIDDEN);
|
||||||
lv_obj_add_flag(label_tap, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(label_tap, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
if (id_required)
|
||||||
|
lv_obj_remove_flag(img_id_required, LV_OBJ_FLAG_HIDDEN);
|
||||||
|
else
|
||||||
|
lv_obj_add_flag(img_id_required, LV_OBJ_FLAG_HIDDEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void screen_create(lv_obj_t *screen)
|
void screen_create(lv_obj_t *screen)
|
||||||
{
|
{
|
||||||
/*Change the active screen's background color*/
|
// background color
|
||||||
lv_obj_set_style_bg_color(screen, lv_color_hex(0), LV_PART_MAIN);
|
lv_obj_set_style_bg_color(screen, lv_color_hex(0), LV_PART_MAIN);
|
||||||
|
|
||||||
// hop logo
|
// hop logo
|
||||||
img_logo = lv_img_create(screen);
|
img_logo = lv_img_create(screen);
|
||||||
lv_img_set_src(img_logo, &hop_logo);
|
lv_img_set_src(img_logo, &hop_logo);
|
||||||
lv_obj_align(img_logo, LV_ALIGN_CENTER, 0, -100);
|
lv_obj_align(img_logo, LV_ALIGN_CENTER, 0, -103);
|
||||||
|
|
||||||
// flickering arrow
|
// flickering arrow
|
||||||
img_arrow = lv_img_create(screen);
|
img_arrow = lv_img_create(screen);
|
||||||
|
|||||||
Reference in New Issue
Block a user