From 1cf37a5fbbc5ef845d6886d9ff57c659b1f637d4 Mon Sep 17 00:00:00 2001 From: Nicolas Roggeman Date: Thu, 12 Sep 2024 14:13:20 +0200 Subject: [PATCH] Use different touch contexts for App & UX --- include/nbgl_stubs.h | 102 +++++++++++++------------- include/syscalls.h | 1 - lib_nbgl/include/nbgl_obj.h | 1 + lib_nbgl/include/nbgl_touch.h | 11 +-- lib_nbgl/src/nbgl_fonts.c | 5 +- lib_nbgl/src/nbgl_obj.c | 29 +++++++- lib_nbgl/src/nbgl_screen.c | 2 +- lib_nbgl/src/nbgl_touch.c | 109 +++++++++++++++++----------- lib_ux_nbgl/ux.c | 11 ++- src/pic.c | 4 +- target/flex/script.ld | 2 +- target/stax/script.ld | 2 +- unit-tests/lib_nbgl/nbgl_stubs.c | 30 -------- unit-tests/lib_nbgl/test_nbgl_obj.c | 3 +- 14 files changed, 170 insertions(+), 142 deletions(-) diff --git a/include/nbgl_stubs.h b/include/nbgl_stubs.h index 79238a25c..accf9ef8a 100644 --- a/include/nbgl_stubs.h +++ b/include/nbgl_stubs.h @@ -1,54 +1,54 @@ #pragma once // auto-generated by shared_export.py -#define _NR_nbgl_refresh 0x90 -#define _NR_nbgl_refreshSpecial 0x91 -#define _NR_nbgl_refreshSpecialWithPostRefresh 0x92 -#define _NR_nbgl_refreshIsNeeded 0x93 -#define _NR_nbgl_refreshReset 0x94 -#define _NR_nbgl_objInit 0x95 -#define _NR_nbgl_objDraw 0x96 -#define _NR_nbgl_objAllowDrawing 0x97 -#define _NR_nbgl_objGetRAMBuffer 0x98 -#define _NR_nbgl_screenContainsObjType 0x99 -#define _NR_nbgl_screenSet 0x9a -#define _NR_nbgl_screenPush 0x9b -#define _NR_nbgl_screenRedraw 0x9c -#define _NR_nbgl_screenPop 0x9d -#define _NR_nbgl_screenGetElements 0x9e -#define _NR_nbgl_screenGetCurrentStackSize 0x9f -#define _NR_nbgl_screenGetUxStackSize 0xa0 -#define _NR_nbgl_screenGetAt 0xa1 -#define _NR_nbgl_screenGetTop 0xa2 -#define _NR_nbgl_screenUpdateTicker 0xa3 -#define _NR_nbgl_screenUpdateBackgroundColor 0xa4 -#define _NR_nbgl_screenReset 0xa5 -#define _NR_nbgl_screenHandler 0xa6 -#define _NR_nbgl_objPoolGet 0xa7 -#define _NR_nbgl_objPoolGetArray 0xa8 -#define _NR_nbgl_containerPoolGet 0xa9 -#define _NR_nbgl_getCharWidth 0xaa -#define _NR_nbgl_getFont 0xab -#define _NR_nbgl_getFontHeight 0xac -#define _NR_nbgl_getFontLineHeight 0xad -#define _NR_nbgl_getSingleLineTextWidth 0xae -#define _NR_nbgl_getSingleLineTextWidthInLen 0xaf -#define _NR_nbgl_getTextHeight 0xb0 -#define _NR_nbgl_getTextHeightInWidth 0xb1 -#define _NR_nbgl_getTextNbLinesInWidth 0xb2 -#define _NR_nbgl_getTextNbPagesInWidth 0xb3 -#define _NR_nbgl_getTextWidth 0xb4 -#define _NR_nbgl_getTextMaxLenInNbLines 0xb5 -#define _NR_nbgl_textReduceOnNbLines 0xb6 -#define _NR_nbgl_textWrapOnNbLines 0xb7 -#define _NR_nbgl_refreshUnicodeFont 0xb8 -#define _NR_nbgl_touchHandler 0xb9 -#define _NR_nbgl_touchGetTouchDuration 0xba -#define _NR_nbgl_touchGetTouchedPosition 0xbb -#define _NR_nbgl_buttonsHandler 0xbc -#define _NR_nbgl_buttonsReset 0xbd -#define _NR_nbgl_keyboardCallback 0xbe -#define _NR_nbgl_keypadCallback 0xbf -#define _NR_nbgl_drawText 0xc0 -#define _NR_pic_shared 0xc1 -#define _NR_pic_init 0xc2 +#define _NR_nbgl_refresh 0x91 +#define _NR_nbgl_refreshSpecial 0x92 +#define _NR_nbgl_refreshSpecialWithPostRefresh 0x93 +#define _NR_nbgl_refreshIsNeeded 0x94 +#define _NR_nbgl_refreshReset 0x95 +#define _NR_nbgl_objInit 0x96 +#define _NR_nbgl_objDraw 0x97 +#define _NR_nbgl_objAllowDrawing 0x98 +#define _NR_nbgl_objGetRAMBuffer 0x99 +#define _NR_nbgl_screenContainsObjType 0x9a +#define _NR_nbgl_screenSet 0x9b +#define _NR_nbgl_screenPush 0x9c +#define _NR_nbgl_screenRedraw 0x9d +#define _NR_nbgl_screenPop 0x9e +#define _NR_nbgl_screenGetElements 0x9f +#define _NR_nbgl_screenGetCurrentStackSize 0xa0 +#define _NR_nbgl_screenGetUxStackSize 0xa1 +#define _NR_nbgl_screenGetAt 0xa2 +#define _NR_nbgl_screenGetTop 0xa3 +#define _NR_nbgl_screenUpdateTicker 0xa4 +#define _NR_nbgl_screenUpdateBackgroundColor 0xa5 +#define _NR_nbgl_screenReset 0xa6 +#define _NR_nbgl_screenHandler 0xa7 +#define _NR_nbgl_objPoolGet 0xa8 +#define _NR_nbgl_objPoolGetArray 0xa9 +#define _NR_nbgl_containerPoolGet 0xaa +#define _NR_nbgl_getCharWidth 0xab +#define _NR_nbgl_getFont 0xac +#define _NR_nbgl_getFontHeight 0xad +#define _NR_nbgl_getFontLineHeight 0xae +#define _NR_nbgl_getSingleLineTextWidth 0xaf +#define _NR_nbgl_getSingleLineTextWidthInLen 0xb0 +#define _NR_nbgl_getTextHeight 0xb1 +#define _NR_nbgl_getTextHeightInWidth 0xb2 +#define _NR_nbgl_getTextNbLinesInWidth 0xb3 +#define _NR_nbgl_getTextNbPagesInWidth 0xb4 +#define _NR_nbgl_getTextWidth 0xb5 +#define _NR_nbgl_getTextMaxLenInNbLines 0xb6 +#define _NR_nbgl_textReduceOnNbLines 0xb7 +#define _NR_nbgl_textWrapOnNbLines 0xb8 +#define _NR_nbgl_refreshUnicodeFont 0xb9 +#define _NR_nbgl_touchHandler 0xba +#define _NR_nbgl_touchGetTouchDuration 0xbb +#define _NR_nbgl_touchGetTouchedPosition 0xbc +#define _NR_nbgl_buttonsHandler 0xbd +#define _NR_nbgl_buttonsReset 0xbe +#define _NR_nbgl_keyboardCallback 0xbf +#define _NR_nbgl_keypadCallback 0xc0 +#define _NR_nbgl_drawText 0xc1 +#define _NR_pic_shared 0xc2 +#define _NR_pic_init 0xc3 diff --git a/include/syscalls.h b/include/syscalls.h index 40ae1347a..117e4fab5 100644 --- a/include/syscalls.h +++ b/include/syscalls.h @@ -303,7 +303,6 @@ #define SYSCALL_nbgl_side_draw_horizontal_line_ID 0x03fa0006 #define SYSCALL_nbgl_side_draw_img_ID 0x04fa0007 #define SYSCALL_nbgl_side_refresh_area_ID 0x02fa0008 -#define SYSCALL_nbgl_get_font_ID 0x01fa000c #define SYSCALL_nbgl_screen_reinit_ID 0x00fa000d #define SYSCALL_nbgl_front_draw_img_rle_ID 0x05fa0010 #define SYSCALL_nbgl_front_control_area_masking_ID 0x03fa0012 diff --git a/lib_nbgl/include/nbgl_obj.h b/lib_nbgl/include/nbgl_obj.h index 89b37ef3e..f678c1a70 100644 --- a/lib_nbgl/include/nbgl_obj.h +++ b/lib_nbgl/include/nbgl_obj.h @@ -578,6 +578,7 @@ void nbgl_objInit(void); void nbgl_objDraw(nbgl_obj_t *obj); void nbgl_objAllowDrawing(bool enable); uint8_t *nbgl_objGetRAMBuffer(void); +bool nbgl_objIsUx(nbgl_obj_t *obj); void nbgl_objPoolRelease(uint8_t layer); nbgl_obj_t *nbgl_objPoolGet(nbgl_obj_type_t type, uint8_t layer); diff --git a/lib_nbgl/include/nbgl_touch.h b/lib_nbgl/include/nbgl_touch.h index 03e95df84..341dbb8a2 100644 --- a/lib_nbgl/include/nbgl_touch.h +++ b/lib_nbgl/include/nbgl_touch.h @@ -23,7 +23,7 @@ extern "C" { // duration of a short touch on touch panel (in ms) #define SHORT_TOUCH_DURATION 0 // duration of a long touch on touch panel (in ms) -#define LONG_TOUCH_DURATION 1500 +#define LONG_TOUCH_DURATION 3000 /********************** * TYPEDEFS **********************/ @@ -31,10 +31,11 @@ extern "C" { /********************** * GLOBAL PROTOTYPES **********************/ -void nbgl_touchHandler(nbgl_touchStatePosition_t *touchEvent, uint32_t currentTimeMs); -bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, - nbgl_touchStatePosition_t **firstPos, - nbgl_touchStatePosition_t **lastPos); +void nbgl_touchInit(bool fromUx); +void nbgl_touchHandler(bool fromUx, nbgl_touchStatePosition_t *touchEvent, uint32_t currentTimeMs); +bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, + nbgl_touchStatePosition_t **firstPos, + nbgl_touchStatePosition_t **lastPos); uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj); nbgl_obj_t *nbgl_touchGetObjectFromId(nbgl_obj_t *obj, uint8_t id); diff --git a/lib_nbgl/src/nbgl_fonts.c b/lib_nbgl/src/nbgl_fonts.c index c354118b6..d265428ca 100644 --- a/lib_nbgl/src/nbgl_fonts.c +++ b/lib_nbgl/src/nbgl_fonts.c @@ -66,12 +66,13 @@ static const LANGUAGE_PACK *language_pack; #include "nbgl_font_open_sans_light_16.inc" #endif // SCREEN_SIZE_WALLET -const nbgl_font_t *const C_nbgl_fonts[] = { +__attribute__((section("._nbgl_fonts_"))) const nbgl_font_t *const C_nbgl_fonts[] = { #include "nbgl_font_rom_struct.inc" }; -const unsigned int C_nbgl_fonts_count = sizeof(C_nbgl_fonts) / sizeof(C_nbgl_fonts[0]); +__attribute__((section("._nbgl_fonts_"))) const unsigned int C_nbgl_fonts_count + = sizeof(C_nbgl_fonts) / sizeof(C_nbgl_fonts[0]); #if (defined(HAVE_BOLOS) && !defined(BOLOS_OS_UPGRADER_APP)) #if !defined(HAVE_LANGUAGE_PACK) diff --git a/lib_nbgl/src/nbgl_obj.c b/lib_nbgl/src/nbgl_obj.c index 717ccda2c..318aac79d 100644 --- a/lib_nbgl/src/nbgl_obj.c +++ b/lib_nbgl/src/nbgl_obj.c @@ -14,6 +14,7 @@ #include "nbgl_front.h" #include "nbgl_debug.h" #include "nbgl_screen.h" +#include "nbgl_touch.h" #include "os_print.h" #include "os_helpers.h" #include "os_pic.h" @@ -1629,12 +1630,17 @@ void nbgl_refreshReset(void) /** * @brief This functions inits all internal of nbgl objects layer + * @note it is supposed to be called only from App * */ void nbgl_objInit(void) { // init area to the smallest size nbgl_refreshReset(); + objDrawingDisabled = false; +#ifdef HAVE_SE_TOUCH + nbgl_touchInit(false); +#endif } /** @@ -1650,9 +1656,30 @@ void nbgl_objAllowDrawing(bool enable) /** * @brief This function is used to get the all purpose RAM buffer * - * @param enable if true, enables drawing/refresh, otherwise disables + * @return a pointer to the all purpose RAM buffer */ uint8_t *nbgl_objGetRAMBuffer(void) { return ramBuffer; } + +/** + * @brief This function returns true if the object belongs to a UxScreen + * + * @return true if the object belongs to a UxScreen + */ +bool nbgl_objIsUx(nbgl_obj_t *obj) +{ + nbgl_obj_t *parent = obj; + // search screen in parenthood + while (parent->parent != NULL) { + parent = parent->parent; + } + if (parent->type == SCREEN) { + return (((nbgl_screen_t *) parent)->isUxScreen); + } + else { + // should never happen + return true; + } +} diff --git a/lib_nbgl/src/nbgl_screen.c b/lib_nbgl/src/nbgl_screen.c index ba07911b4..ce6fb4f87 100644 --- a/lib_nbgl/src/nbgl_screen.c +++ b/lib_nbgl/src/nbgl_screen.c @@ -368,7 +368,7 @@ int nbgl_screenPush(nbgl_obj_t ***elements, nbgl_touchStatePosition_t touchStatePosition = {.state = RELEASED, .x = 0, .y = 0}; // make a fake touch release for the current top-of-stack to avoid issue // (for example in long-touch press) - nbgl_touchHandler(&touchStatePosition, 0); + nbgl_touchHandler(topOfStack->isUxScreen, &touchStatePosition, 0); #endif // HAVE_SE_TOUCH // new top of stack topOfStack = &screenStack[screenIndex]; diff --git a/lib_nbgl/src/nbgl_touch.c b/lib_nbgl/src/nbgl_touch.c index 1e6881f8d..b2f2c25a1 100644 --- a/lib_nbgl/src/nbgl_touch.c +++ b/lib_nbgl/src/nbgl_touch.c @@ -20,10 +20,23 @@ /********************* * DEFINES *********************/ +enum { + UX_CTX = 0, + APP_CTX, + NB_CTXS +}; /********************** * TYPEDEFS **********************/ +typedef struct nbgl_touchCtx_s { + nbgl_touchState_t lastState; + uint32_t lastPressedTime; + uint32_t lastCurrentTime; + nbgl_obj_t *lastPressedObj; + nbgl_touchStatePosition_t firstTouchedPosition; + nbgl_touchStatePosition_t lastTouchedPosition; +} nbgl_touchCtx_t; /********************** * STATIC PROTOTYPES @@ -32,10 +45,7 @@ /********************** * STATIC VARIABLES **********************/ -static uint32_t lastPressedTime = 0; -static uint32_t lastCurrentTime = 0; -static nbgl_obj_t *lastPressedObj = NULL; -static nbgl_touchStatePosition_t firstTouchedPosition, lastTouchedPosition; +static nbgl_touchCtx_t touchCtxs[NB_CTXS]; /********************** * VARIABLES @@ -255,29 +265,41 @@ static nbgl_touchType_t nbgl_detectSwipe(nbgl_touchStatePosition_t *last, /********************** * GLOBAL FUNCTIONS **********************/ +/** + * @brief Function to initialize the touch context + * @param fromUx if true, means to initialize the UX context, otherwise App one + */ +void nbgl_touchInit(bool fromUx) +{ + nbgl_touchCtx_t *ctx = fromUx ? &touchCtxs[UX_CTX] : &touchCtxs[APP_CTX]; + memset(ctx, 0, sizeof(nbgl_touchCtx_t)); +} /** * @brief Function to be called periodically to check touchscreen state * and coordinates + * @param fromUx if true, means this is called from the UX, not the App * @param touchStatePosition state and position read from touch screen * @param currentTime current time in ms */ -void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t currentTime) +void nbgl_touchHandler(bool fromUx, + nbgl_touchStatePosition_t *touchStatePosition, + uint32_t currentTime) { - static nbgl_touchState_t lastState = RELEASED; - nbgl_obj_t *foundObj; + nbgl_obj_t *foundObj; + nbgl_touchCtx_t *ctx = fromUx ? &touchCtxs[UX_CTX] : &touchCtxs[APP_CTX]; // save last received currentTime - lastCurrentTime = currentTime; + ctx->lastCurrentTime = currentTime; - if (lastState == RELEASED) { + if (ctx->lastState == RELEASED) { // filter out not realistic cases (successive RELEASE events) if (RELEASED == touchStatePosition->state) { - lastState = touchStatePosition->state; + ctx->lastState = touchStatePosition->state; return; } // memorize first touched position - memcpy(&firstTouchedPosition, touchStatePosition, sizeof(nbgl_touchStatePosition_t)); + memcpy(&ctx->firstTouchedPosition, touchStatePosition, sizeof(nbgl_touchStatePosition_t)); } // LOG_DEBUG(TOUCH_LOGGER,"state = %s, x = %d, y=%d\n",(touchStatePosition->state == // RELEASED)?"RELEASED":"PRESSED",touchStatePosition->x,touchStatePosition->y); @@ -289,86 +311,88 @@ void nbgl_touchHandler(nbgl_touchStatePosition_t *touchStatePosition, uint32_t c // foundObj->type); if (foundObj == NULL) { LOG_DEBUG(TOUCH_LOGGER, "nbgl_touchHandler: no found obj\n"); - if ((touchStatePosition->state == PRESSED) && (lastState == PRESSED) - && (lastPressedObj != NULL)) { + if ((touchStatePosition->state == PRESSED) && (ctx->lastState == PRESSED) + && (ctx->lastPressedObj != NULL)) { // finger has moved out of an object // make sure lastPressedObj still belongs to current screen before warning it - if (nbgl_screenContainsObj(lastPressedObj)) { - applytouchStatePosition(lastPressedObj, OUT_OF_TOUCH); + if (nbgl_screenContainsObj(ctx->lastPressedObj)) { + applytouchStatePosition(ctx->lastPressedObj, OUT_OF_TOUCH); } } // Released event has been handled, forget lastPressedObj - lastPressedObj = NULL; + ctx->lastPressedObj = NULL; } // memorize last touched position - memcpy(&lastTouchedPosition, touchStatePosition, sizeof(nbgl_touchStatePosition_t)); + memcpy(&ctx->lastTouchedPosition, touchStatePosition, sizeof(nbgl_touchStatePosition_t)); if (touchStatePosition->state == RELEASED) { - nbgl_touchType_t swipe = nbgl_detectSwipe(touchStatePosition, &firstTouchedPosition); + nbgl_touchType_t swipe = nbgl_detectSwipe(touchStatePosition, &ctx->firstTouchedPosition); bool consumed = false; if (swipe != NB_TOUCH_TYPES) { // Swipe detected nbgl_obj_t *swipedObj = getSwipableObject( - nbgl_screenGetTop(), &firstTouchedPosition, &lastTouchedPosition, swipe); + nbgl_screenGetTop(), &ctx->firstTouchedPosition, &ctx->lastTouchedPosition, swipe); // if a swipable object has been found if (swipedObj) { applytouchStatePosition(swipedObj, swipe); consumed = true; } } - if (!consumed && (lastPressedObj != NULL) - && ((foundObj == lastPressedObj) || (nbgl_screenContainsObj(lastPressedObj)))) { + if (!consumed && (ctx->lastPressedObj != NULL) + && ((foundObj == ctx->lastPressedObj) + || (nbgl_screenContainsObj(ctx->lastPressedObj)))) { // very strange if lastPressedObj != foundObj, let's consider that it's a normal release // on lastPressedObj make sure lastPressedObj still belongs to current screen before // "releasing" it - applytouchStatePosition(lastPressedObj, TOUCH_RELEASED); - if (currentTime >= (lastPressedTime + LONG_TOUCH_DURATION)) { - applytouchStatePosition(lastPressedObj, LONG_TOUCHED); + applytouchStatePosition(ctx->lastPressedObj, TOUCH_RELEASED); + if (currentTime >= (ctx->lastPressedTime + LONG_TOUCH_DURATION)) { + applytouchStatePosition(ctx->lastPressedObj, LONG_TOUCHED); } - else if (currentTime >= (lastPressedTime + SHORT_TOUCH_DURATION)) { - applytouchStatePosition(lastPressedObj, TOUCHED); + else if (currentTime >= (ctx->lastPressedTime + SHORT_TOUCH_DURATION)) { + applytouchStatePosition(ctx->lastPressedObj, TOUCHED); } } // Released event has been handled, forget lastPressedObj - lastPressedObj = NULL; + ctx->lastPressedObj = NULL; } else { // PRESSED - if ((lastState == PRESSED) && (lastPressedObj != NULL)) { - if (foundObj != lastPressedObj) { + if ((ctx->lastState == PRESSED) && (ctx->lastPressedObj != NULL)) { + if (foundObj != ctx->lastPressedObj) { // finger has moved out of an object // make sure lastPressedObj still belongs to current screen before warning it - if (nbgl_screenContainsObj(lastPressedObj)) { - applytouchStatePosition(lastPressedObj, OUT_OF_TOUCH); + if (nbgl_screenContainsObj(ctx->lastPressedObj)) { + applytouchStatePosition(ctx->lastPressedObj, OUT_OF_TOUCH); } - lastPressedObj = NULL; + ctx->lastPressedObj = NULL; } else { // warn the concerned object that it is still touched applytouchStatePosition(foundObj, TOUCHING); } } - else if (lastState == RELEASED) { + else if (ctx->lastState == RELEASED) { // newly touched object - lastPressedObj = foundObj; - lastPressedTime = currentTime; + ctx->lastPressedObj = foundObj; + ctx->lastPressedTime = currentTime; applytouchStatePosition(foundObj, TOUCH_PRESSED); applytouchStatePosition(foundObj, TOUCHING); } } - lastState = touchStatePosition->state; + ctx->lastState = touchStatePosition->state; } bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, nbgl_touchStatePosition_t **firstPos, nbgl_touchStatePosition_t **lastPos) { - LOG_DEBUG(TOUCH_LOGGER, "nbgl_touchGetTouchedPosition: %p %p\n", obj, lastPressedObj); - if (obj == lastPressedObj) { - *firstPos = &firstTouchedPosition; - *lastPos = &lastTouchedPosition; + nbgl_touchCtx_t *ctx = nbgl_objIsUx(obj) ? &touchCtxs[UX_CTX] : &touchCtxs[APP_CTX]; + LOG_DEBUG(TOUCH_LOGGER, "nbgl_touchGetTouchedPosition: %p %p\n", obj, ctx->lastPressedObj); + if (obj == ctx->lastPressedObj) { + *firstPos = &ctx->firstTouchedPosition; + *lastPos = &ctx->lastTouchedPosition; return true; } return false; @@ -376,8 +400,9 @@ bool nbgl_touchGetTouchedPosition(nbgl_obj_t *obj, uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj) { - if (obj == lastPressedObj) { - return (lastCurrentTime - lastPressedTime); + nbgl_touchCtx_t *ctx = nbgl_objIsUx(obj) ? &touchCtxs[UX_CTX] : &touchCtxs[APP_CTX]; + if (obj == ctx->lastPressedObj) { + return (ctx->lastCurrentTime - ctx->lastPressedTime); } return 0; } diff --git a/lib_ux_nbgl/ux.c b/lib_ux_nbgl/ux.c index d7a807e3c..985705fc4 100644 --- a/lib_ux_nbgl/ux.c +++ b/lib_ux_nbgl/ux.c @@ -75,7 +75,7 @@ void ux_process_finger_event(uint8_t seph_packet[]) #ifdef HAVE_HW_TOUCH_SWIPE pos.swipe = seph_packet[10]; #endif // HAVE_HW_TOUCH_SWIPE - nbgl_touchHandler(&pos, nbTicks * 100); + nbgl_touchHandler(false, &pos, nbTicks * 100); nbgl_refresh(); } } @@ -115,13 +115,16 @@ void ux_process_ticker_event(void) // enable/disable drawing according to UX decision nbgl_objAllowDrawing(displayEnabled); - // update ticker in NBGL - nbgl_screenHandler(100); + // do not do any action on screens if display is disabled, because + // UX has the hand if (!displayEnabled) { return; } + // update ticker in NBGL + nbgl_screenHandler(100); + #ifdef HAVE_SE_TOUCH // handle touch only if detected as pressed in last touch message if (pos.state == PRESSED) { @@ -131,7 +134,7 @@ void ux_process_ticker_event(void) pos.x = touch_info.x; pos.y = touch_info.y; // Send current touch position to nbgl - nbgl_touchHandler(&pos, nbTicks * 100); + nbgl_touchHandler(false, &pos, nbTicks * 100); } #endif // HAVE_SE_TOUCH nbgl_refresh(); diff --git a/src/pic.c b/src/pic.c index 0592cad41..3bced6d10 100644 --- a/src/pic.c +++ b/src/pic.c @@ -93,12 +93,12 @@ static void *ram_real_addr; void *pic_shared(const void *link_address) { // check if in the LINKED TEXT zone - if ((link_address > APP_FLASH_RELOC_ADDR) && (link_address <= APP_FLASH_RELOC_END)) { + if ((link_address >= APP_FLASH_RELOC_ADDR) && (link_address < APP_FLASH_RELOC_END)) { link_address = link_address - APP_FLASH_RELOC_ADDR + flash_real_addr; } // check if in the LINKED RAM zone - if ((link_address >= APP_DATA_RELOC_ADDR) && (link_address <= APP_DATA_RELOC_END)) { + if ((link_address >= APP_DATA_RELOC_ADDR) && (link_address < APP_DATA_RELOC_END)) { link_address = link_address - APP_DATA_RELOC_ADDR + ram_real_addr; } diff --git a/target/flex/script.ld b/target/flex/script.ld index 4114636c8..100201cb5 100644 --- a/target/flex/script.ld +++ b/target/flex/script.ld @@ -26,7 +26,7 @@ MEMORY FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 40K } PAGE_SIZE = 512; diff --git a/target/stax/script.ld b/target/stax/script.ld index 4114636c8..100201cb5 100644 --- a/target/stax/script.ld +++ b/target/stax/script.ld @@ -26,7 +26,7 @@ MEMORY FLASH (rx) : ORIGIN = 0xc0de0000, LENGTH = 400K DATA (r) : ORIGIN = 0xc0de0000, LENGTH = 400K - SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 44K + SRAM (rwx) : ORIGIN = 0xda7a0000, LENGTH = 40K } PAGE_SIZE = 512; diff --git a/unit-tests/lib_nbgl/nbgl_stubs.c b/unit-tests/lib_nbgl/nbgl_stubs.c index c9913caf8..bdd133690 100644 --- a/unit-tests/lib_nbgl/nbgl_stubs.c +++ b/unit-tests/lib_nbgl/nbgl_stubs.c @@ -59,33 +59,3 @@ void fetch_language_packs(void) nbgl_refreshUnicodeFont(language_pack); } } - -#include "nbgl_fonts.h" -#include "nbgl_font_inter_regular_24.inc" -#include "nbgl_font_inter_semibold_24.inc" -#include "nbgl_font_inter_medium_32.inc" -#include "nbgl_font_inter_regular_24_1bpp.inc" -#include "nbgl_font_inter_semibold_24_1bpp.inc" -#include "nbgl_font_inter_medium_32_1bpp.inc" -#include "nbgl_font_open_sans_extrabold_11.inc" -#include "nbgl_font_open_sans_regular_11.inc" -#include "nbgl_font_open_sans_light_16.inc" - -static const nbgl_font_t *const C_nbgl_fonts[] = { -#include "nbgl_font_rom_struct.inc" -}; -static const unsigned int C_nbgl_fonts_count = sizeof(C_nbgl_fonts) / sizeof(C_nbgl_fonts[0]); - -const nbgl_font_t *nbgl_font_getFont(unsigned int fontId) -{ - unsigned int i = C_nbgl_fonts_count; - while (i--) { - // font id match this entry (non indexed array) - if (C_nbgl_fonts[i]->font_id == fontId) { - return C_nbgl_fonts[i]; - } - } - - // id not found - return NULL; -} diff --git a/unit-tests/lib_nbgl/test_nbgl_obj.c b/unit-tests/lib_nbgl/test_nbgl_obj.c index 54e856dc7..aeb106f9b 100644 --- a/unit-tests/lib_nbgl/test_nbgl_obj.c +++ b/unit-tests/lib_nbgl/test_nbgl_obj.c @@ -188,8 +188,9 @@ void nbgl_screen_reinit(void) { return; } - #ifdef HAVE_SE_TOUCH +void nbgl_touchInit(void) {} + static void test_draw_obj(void **state __attribute__((unused))) { nbgl_image_t *image;