Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stax - Use IDs for touchable objects to ease tests #422

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ typedef void (*nbgl_touchCallback_t)(void *obj, nbgl_touchType_t eventType);
typedef struct PACKED__ nbgl_obj_s {
nbgl_area_t area; ///< absolute position, backGround color and size of the object. DO NOT MOVE
///< THIS FIELD
nbgl_obj_type_t type; ///< type of the graphical object, must be explicitly set
int16_t
rel_x0; ///< horizontal position of top-left corner relative to parent's top-left corner
int16_t rel_y0; ///< vertical position of top-left corner relative to parent's top-left corner,
Expand All @@ -202,7 +201,10 @@ typedef struct PACKED__ nbgl_obj_s {
nbgl_aligment_t alignment; ///< type of alignment
int16_t alignmentMarginX; ///< horizontal margin when aligning
int16_t alignmentMarginY; ///< vertical margin when aligning
nbgl_obj_type_t type; ///< type of the graphical object, must be explicitly set
uint8_t touchMask; ///< bit mask to tell engine which touch events are handled by this object
uint8_t touchId; ///< a unique identifier (by screen) to be used by external test environment
///< (TTYT or Screenshots)
} nbgl_obj_t;

/**
Expand Down Expand Up @@ -457,6 +459,27 @@ typedef struct PACKED__ nbgl_keypad_s {
keyboardCallback_t callback; ///< function called when an active key is pressed
} nbgl_keypad_t;

/**
* @brief ids of touchable objects, for external stimulus (by Testing environment)
*
*/
enum {
BOTTOM_BUTTON_ID = 1,
LEFT_BUTTON_ID,
RIGHT_BUTTON_ID,
WHOLE_SCREEN_ID,
TOP_RIGHT_BUTTON_ID,
BACK_BUTTON_ID,
SINGLE_BUTTON_ID,
CHOICE_1_ID,
CHOICE_2_ID,
KEYPAD_ID,
KEYBOARD_ID,
ENTERED_TEXT_ID,
CONTROLS_ID, // when multiple controls in the same pages (buttons, switches, radios)
NB_CONTROL_IDS
};

/**********************
* GLOBAL PROTOTYPES
**********************/
Expand Down Expand Up @@ -491,16 +514,16 @@ bool nbgl_navigationCallback(nbgl_obj_t *obj,
nbgl_touchType_t eventType,
uint8_t nbPages,
uint8_t *activePage);
nbgl_container_t *nbgl_bottomButtonPopulate(const nbgl_icon_details_t *icon,
bool separationLine,
uint8_t layer);

// for internal use
void nbgl_objDrawKeyboard(nbgl_keyboard_t *kbd);
void nbgl_objDrawKeypad(nbgl_keypad_t *kbd);
void nbgl_keyboardTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType);
void nbgl_keypadTouchCallback(nbgl_obj_t *obj, nbgl_touchType_t eventType);

bool nbgl_keyboardGetPosition(nbgl_keyboard_t *kbd, char index, uint16_t *x, uint16_t *y);
bool nbgl_keypadGetPosition(nbgl_keypad_t *kbd, char index, uint16_t *x, uint16_t *y);

/**********************
* MACROS
**********************/
Expand Down
11 changes: 6 additions & 5 deletions lib_nbgl/include/nbgl_touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ 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);
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj);
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);
uint32_t nbgl_touchGetTouchDuration(nbgl_obj_t *obj);
nbgl_obj_t *nbgl_touchGetObjectFromId(nbgl_obj_t *obj, uint8_t id);

/**********************
* MACROS
Expand Down
96 changes: 0 additions & 96 deletions lib_nbgl/src/nbgl_bottom_button.c

This file was deleted.

Loading
Loading