screenConnection.hpp (1322B)
1 #ifndef SCREEN_CONNECTION_H 2 #define SCREEN_CONNECTION_H 3 4 #include "global.hpp" 5 #include "screen.hpp" 6 #include <cstring> 7 #include <src/core/lv_obj_pos.h> 8 #include <src/libs/qrcode/lv_qrcode.h> 9 #include <src/misc/lv_color.h> 10 #include <src/misc/lv_types.h> 11 12 class ScreenConnection : public Screen{ 13 private: 14 lv_obj_t *abortButton; 15 lv_obj_t *qrCode; 16 17 static void callbackEventAbort(lv_event_t *e){ 18 event(EVENT_BUTTON_ABORT); 19 } 20 21 protected: 22 public: 23 ScreenConnection(){ 24 //Set the "instruction 25 lv_label_set_text(instructionLabel, "Scan the QR-Code with your Taler Wallet App"); 26 27 //Add button "Abort" 28 abortButton = lv_button_create(buttonsContainer); 29 lv_obj_add_style(abortButton, &buttonDefaultStyle, 0); 30 lv_obj_t *label = lv_label_create(abortButton); 31 lv_label_set_text(label, "Abort"); 32 lv_obj_add_style(label, &buttonLabelDefaultStyle, 0); 33 lv_obj_add_event_cb(abortButton, callbackEventAbort, LV_EVENT_CLICKED, NULL); 34 35 //Add QR-Code 36 qrCode = lv_qrcode_create(mainContentContainer); 37 lv_qrcode_set_size(qrCode, 150); 38 lv_qrcode_set_dark_color(qrCode, lv_color_black()); 39 lv_qrcode_set_light_color(qrCode, lv_color_white()); 40 } 41 42 void generateQR(const char* uri){ 43 lv_qrcode_update(qrCode, uri, strlen(uri)); 44 lv_obj_center(qrCode); 45 } 46 }; 47 48 #endif