commit 2e8d55a7b6e1491bb2c0e6697aefc0f2e3e3afd5
parent e3934bc1fdf172fc72f39ad577bb398b76a2355c
Author: Manuel Geissbühler <manuel@debian>
Date: Sat, 28 Dec 2024 13:43:18 +0100
testing
Diffstat:
11 files changed, 177 insertions(+), 23 deletions(-)
diff --git a/src/cash2ecash.cpp b/src/cash2ecash.cpp
@@ -22,7 +22,7 @@ enum state_e state = INIT;
char test;
char *string;
Gui gui;
-ScreenWelcome welcome(800, 480, &startButtonCb);
+ScreenWelcome welcome(&startButtonCb);
void guiDriver();
int main(int argc, char *argv[]){
diff --git a/src/gui/#screenWelcomme.hpp# b/src/gui/#screenWelcomme.hpp#
@@ -0,0 +1,38 @@
+#ifndef SCREEN_WELCOME_H
+#define SCREEN_WELCOME_H
+#include "screen.hpp"
+#include <cstdint>
+#include <src/core/lv_obj_event.h>
+#include <src/core/lv_obj_pos.h>
+#include <src/core/lv_obj_style.h>
+#include <src/misc/lv_area.h>
+#include <src/misc/lv_event.h>
+#include <src/misc/lv_types.h>
+#include <src/widgets/button/lv_button.h>
+#include <src/widgets/label/lv_label.h>
+
+class ScreenWelcome : public Screen {
+private:
+ lv_obj_t *startButton;
+
+
+
+
+ protected:
+ public:
+ ScreenWelcome(void (*startCallback)(lv_event_t *e)){
+ //Set set the "instruction"
+ lv_label_set_text(instructionLabel, "Press Start to begin...");
+
+
+ //Add button "Start"
+ startButton = lv_button_create(buttonsContainer);
+ lv_obj_add_style(startButton, &buttonDefaultStyle, 0);
+ lv_obj_t *label = lv_label_create(startButton);
+ lv_label_set_text(label, "Start");
+ lv_obj_add_style(label, &buttonLabelDefaultStyle, 0);
+ lv_obj_add_event_cb(startButton, startCallback, LV_EVENT_CLICKED, NULL);
+ }
+
+};
+#endif
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
@@ -5,15 +5,15 @@ endforeach()
if (LV_USE_LINUX_DRM)
- add_library(gui gui.cpp screen.cpp screenWelcome.cpp)
+ add_library(gui gui.cpp screen.cpp screenWelcome.cpp screenIdentification.cpp screenConnection.cpp screenAcceptCash.cpp)
target_link_libraries(gui lvgl lvgl::examples lvgl::demos lvgl::thorvg ${LIBDRM_LIBRARIES} m pthread)
elseif (LV_USE_SDL)
- add_library(gui gui.cpp screen.cpp screenWelcome.cpp)
+ add_library(gui gui.cpp screen.cpp screenWelcome.cpp screenIdentification.cpp screenConnection.cpp screenAcceptCash.cpp)
target_link_libraries(gui lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} m pthread)
elseif (LV_USE_WAYLAND)
- add_library(gui gui.cpp screen.cpp screenWelcome.cpp ${WAYLAND_PROTOCOLS_SRC} backends/wayland.c)
+ add_library(gui gui.cpp screen.cpp screenWelcome.cpp screenIdentification.cpp screenConnection.cpp screenAcceptCash.cpp ${WAYLAND_PROTOCOLS_SRC} backends/wayland.c)
target_compile_definitions(gui PRIVATE LV_CONF_INCLUDE_SIMPLE)
target_link_libraries(gui lvgl lvgl::examples lvgl::demos lvgl::thorvg m
wayland-client wayland-cursor xkbcommon)
@@ -21,7 +21,7 @@ elseif (LV_USE_WAYLAND)
else()
# No specific build steps required for FBDEV
- add_library(gui gui.cpp screen.cpp screenWelcome.cpp)
+ add_library(gui gui.cpp screen.cpp screenWelcome.cpp screenIdentification.cpp screenConnection.cpp screenAcceptCash.cpp)
target_link_libraries(gui lvgl lvgl::examples lvgl::demos lvgl::thorvg m pthread)
target_include_directories(gui PUBLIC "../extern/lvgl")
endif()
diff --git a/src/gui/screen.hpp b/src/gui/screen.hpp
@@ -42,7 +42,6 @@ class Screen {
lv_style_t buttonsContainerStyle;
-
protected:
uint16_t width, height;
lv_obj_t *screenPointer;
@@ -51,12 +50,29 @@ class Screen {
lv_obj_t *buttonsContainer;
lv_obj_t *mainContentContainer;
+ lv_obj_t *instructionLabel;
+
lv_style_t buttonDefaultStyle;
+ lv_style_t buttonLabelDefaultStyle;
lv_style_t instructionDefaultStyle;
public:
- Screen(uint16_t width, uint16_t height) : width(width), height(height)
+ Screen()
{
+ //create default style for buttons
+ lv_style_init(&buttonDefaultStyle);
+ lv_style_set_size(&buttonDefaultStyle, LV_PCT(100), 72);
+
+ //create default style for button labels
+ lv_style_init(&buttonLabelDefaultStyle);
+ lv_style_set_align(&buttonLabelDefaultStyle, LV_ALIGN_CENTER);
+ lv_style_set_text_font(&buttonLabelDefaultStyle, &lv_font_montserrat_16);
+
+ //create default style for the instructions Text
+ lv_style_init(&instructionDefaultStyle);
+ lv_style_set_text_font(&instructionDefaultStyle, &lv_font_montserrat_24);
+
+
screenPointer = lv_obj_create(NULL);
//lv_obj_set_size(screenPointer, 800, 480);
@@ -86,6 +102,11 @@ class Screen {
color.red = 0;
lv_obj_set_style_bg_color(mainContentContainer, color, 0);
+ //Add "instructions" label and set style
+ instructionLabel = lv_label_create(instructionsContainer);
+ lv_label_set_text(instructionLabel, "dummytext");
+ lv_obj_add_style(instructionLabel, &instructionDefaultStyle, 0);
+
//set style & flow of buttons container
lv_style_init(&buttonsContainerStyle);
lv_style_set_flex_flow(&buttonsContainerStyle, LV_FLEX_FLOW_COLUMN_REVERSE);
@@ -97,13 +118,7 @@ class Screen {
lv_obj_add_style(buttonsContainer, &buttonsContainerStyle, 0);
- //create default style for buttons
- lv_style_init(&buttonDefaultStyle);
- lv_style_set_size(&buttonDefaultStyle, LV_PCT(100), 72);
-
- //create default style for the instructions Text
- lv_style_init(&instructionDefaultStyle);
- lv_style_set_text_font(&instructionDefaultStyle, &lv_font_montserrat_24);
+
}
diff --git a/src/gui/screenAcceptCash.cpp b/src/gui/screenAcceptCash.cpp
@@ -0,0 +1 @@
+#include "screenAcceptCash.hpp"
diff --git a/src/gui/screenAcceptCash.hpp b/src/gui/screenAcceptCash.hpp
@@ -0,0 +1,34 @@
+#ifndef SCREEN_ACCEPTCASH_H
+#define SCREEN_ACCEPTCASH_H
+
+#include "screen.hpp"
+#include "lvgl.h"
+#include <src/core/lv_obj_pos.h>
+#include <src/widgets/label/lv_label.h>
+
+class ScreenAcceptCash : public Screen{
+ private:
+ lv_obj_t *finishButton;
+ lv_obj_t *amountLabel;
+ protected:
+ public:
+ ScreenAcceptCash(char* amountString, void (*finishCallback)(lv_event_t *e)){
+ //Set set the "instruction"
+ lv_label_set_text(instructionLabel, "Insert Cash and press Finish if you're done");
+
+ //Add button "Finish"
+ finishButton = lv_button_create(buttonsContainer);
+ lv_obj_add_style(finishButton, &buttonDefaultStyle, 0);
+ lv_obj_t *label = lv_label_create(finishButton);
+ lv_label_set_text(label, "Finish");
+ lv_obj_add_style(label, &buttonLabelDefaultStyle, 0);
+ lv_obj_add_event_cb(finishButton, finishCallback, LV_EVENT_CLICKED, NULL);
+
+ //Add field, displaying amount
+ amountLabel = lv_label_create(mainContentContainer);
+ lv_label_set_text_static(amountLabel, amountString);
+ lv_obj_center(amountLabel);
+ }
+};
+
+#endif
diff --git a/src/gui/screenConnection.cpp b/src/gui/screenConnection.cpp
@@ -0,0 +1 @@
+#include "screenConnection.hpp"
diff --git a/src/gui/screenConnection.hpp b/src/gui/screenConnection.hpp
@@ -0,0 +1,40 @@
+#ifndef SCREEN_CONNECTION_H
+#define SCREEN_CONNECTION_H
+
+#include "screen.hpp"
+#include <cstring>
+#include <src/core/lv_obj_pos.h>
+#include <src/libs/qrcode/lv_qrcode.h>
+#include <src/misc/lv_color.h>
+#include <src/misc/lv_types.h>
+
+class ScreenConnection : public Screen{
+ private:
+ lv_obj_t *abortButton;
+ lv_obj_t *qrCode;
+ protected:
+ public:
+ ScreenConnection(char *uri, void (*abortCallback)(lv_event_t *e)){
+ //Set the "instruction
+ lv_label_set_text(instructionLabel, "Scan the QR-Code with your Taler Wallet App");
+
+ //Add button "Abort"
+ abortButton = lv_button_create(buttonsContainer);
+ lv_obj_add_style(abortButton, &buttonDefaultStyle, 0);
+ lv_obj_t *label = lv_label_create(abortButton);
+ lv_label_set_text(label, "Abort");
+ lv_obj_add_style(label, &buttonLabelDefaultStyle, 0);
+ lv_obj_add_event_cb(abortButton, abortCallback, LV_EVENT_CLICKED, NULL);
+
+ //Add QR-Code
+ qrCode = lv_qrcode_create(mainContentContainer);
+ lv_qrcode_set_size(qrCode, LV_PCT(80));
+ lv_qrcode_set_dark_color(qrCode, lv_color_black());
+ lv_qrcode_set_light_color(qrCode, lv_color_white());
+
+ lv_qrcode_update(qrCode, uri, strlen(uri));
+ lv_obj_center(qrCode);
+ }
+};
+
+#endif
diff --git a/src/gui/screenIdentification.cpp b/src/gui/screenIdentification.cpp
@@ -0,0 +1 @@
+#include "screenIdentification.hpp"
diff --git a/src/gui/screenIdentification.hpp b/src/gui/screenIdentification.hpp
@@ -0,0 +1,30 @@
+#ifndef SCREEN_IDENTIFICATION_H
+#define SCREEN_IDENTIFICATION_H
+
+#include "screen.hpp"
+#include <src/misc/lv_types.h>
+#include <src/widgets/label/lv_label.h>
+
+
+
+class ScreenIdentification : public Screen {
+ private:
+ lv_obj_t *abortButton;
+
+ protected:
+ public:
+ ScreenIdentification(void (*abortCallback)(lv_event_t *e)){
+ //Set the instruction
+ lv_label_set_text(instructionLabel, "Identificate presenting a NFC-Tag to the NFC-Reader.");
+
+
+ //Add button "Abort"
+ abortButton = lv_button_create(buttonsContainer);
+ lv_obj_add_style(abortButton, &buttonDefaultStyle, 0);
+ lv_obj_t *label = lv_label_create(abortButton);
+ lv_label_set_text(label, "Abort");
+ lv_obj_add_style(label, &buttonLabelDefaultStyle, 0);
+ lv_obj_add_event_cb(abortButton, abortCallback, LV_EVENT_CLICKED, NULL);
+ }
+};
+#endif
diff --git a/src/gui/screenWelcomme.hpp b/src/gui/screenWelcomme.hpp
@@ -3,6 +3,7 @@
#include "screen.hpp"
#include <cstdint>
#include <src/core/lv_obj_event.h>
+#include <src/core/lv_obj_pos.h>
#include <src/core/lv_obj_style.h>
#include <src/misc/lv_area.h>
#include <src/misc/lv_event.h>
@@ -12,28 +13,21 @@
class ScreenWelcome : public Screen {
private:
- lv_obj_t *instructionLabel;
lv_obj_t *startButton;
-
-
-
protected:
public:
- ScreenWelcome(uint16_t width, uint16_t height, void (*startCallback)(lv_event_t *e)) : Screen(width, height){
+ ScreenWelcome(void (*startCallback)(lv_event_t *e)){
//Set set the "instruction"
- instructionLabel = lv_label_create(instructionsContainer);
lv_label_set_text(instructionLabel, "Press Start to begin...");
- lv_obj_add_style(instructionLabel, &instructionDefaultStyle, 0);
-
//Add button "Start"
startButton = lv_button_create(buttonsContainer);
lv_obj_add_style(startButton, &buttonDefaultStyle, 0);
lv_obj_t *label = lv_label_create(startButton);
lv_label_set_text(label, "Start");
+ lv_obj_add_style(label, &buttonLabelDefaultStyle, 0);
lv_obj_add_event_cb(startButton, startCallback, LV_EVENT_CLICKED, NULL);
}
-
};
#endif