Skip to content

Commit

Permalink
WIP mask area syscall
Browse files Browse the repository at this point in the history
  • Loading branch information
abonnaudet-ledger committed Jun 25, 2024
1 parent 1a27b34 commit 979634f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
#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

#ifdef HAVE_SE_EINK_DISPLAY
#define SYSCALL_nbgl_wait_pipeline_ID 0x00fa0011
Expand Down
5 changes: 5 additions & 0 deletions lib_nbgl/include/nbgl_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ typedef struct PACKED__ nbgl_text_entry_s {
const char *text; ///< text to display (up to nbChars chars).
} nbgl_text_entry_t;

typedef struct PACKED__ nbgl_mask_control_s {
nbgl_obj_t obj; ///< common part
bool enableMasking; ///< true: Enable masking of area / false: Disable masking of area
} nbgl_mask_control_t;

/**
* @brief struct to represent a "spinner", represented by the Ledger corners, in gray, with one of
* the corners in black (@ref SPINNER type)
Expand Down
3 changes: 2 additions & 1 deletion lib_nbgl/include/nbgl_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ typedef enum {
KEYPAD, ///< Keypad
SPINNER, ///< Spinner
IMAGE_FILE, ///< Image file (with Ledger compression)
TEXT_ENTRY ///< area for entered text, only for Nanos
TEXT_ENTRY, ///< area for entered text, only for Nanos
MASK_CONTROL,
} nbgl_obj_type_t;

/**
Expand Down
21 changes: 21 additions & 0 deletions lib_nbgl/src/nbgl_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,24 @@ static void draw_image_file(nbgl_image_file_t *obj, nbgl_obj_t *prevObj, bool co
nbgl_frontDrawImageFile((nbgl_area_t *) obj, obj->buffer, BLACK, ramBuffer);
}

static void draw_mask_control(nbgl_mask_control_t *obj, nbgl_obj_t *prevObj, bool computePosition)
{
if (computePosition) {
compute_position((nbgl_obj_t *) obj, prevObj);
}

if (objDrawingDisabled) {
return;
}

if (obj->enableMasking) {
nbgl_frontControlAreaMasking(0, &obj->obj.area);
}
else {
nbgl_frontControlAreaMasking(0, NULL);
}
}

/**
* @brief internal function used to draw an object of any type
*
Expand Down Expand Up @@ -1442,6 +1460,9 @@ draw_object(nbgl_obj_t *obj, nbgl_obj_t *prevObj, bool computePosition)
draw_textEntry((nbgl_text_entry_t *) obj, prevObj, computePosition);
break;
#endif // HAVE_SE_TOUCH
case MASK_CONTROL:
draw_mask_control((nbgl_mask_control_t *) obj, prevObj, computePosition);
break;
default:
LOG_DEBUG(OBJ_LOGGER, "Not existing object type\n");
break;
Expand Down
9 changes: 9 additions & 0 deletions src/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ void nbgl_frontDrawImageRle(nbgl_area_t *area,
return;
}

void nbgl_frontControlAreaMasking(uint8_t mask_index, nbgl_area_t *masked_area_or_null)
{
unsigned int parameters[2];
parameters[0] = (unsigned int) mask_index;
parameters[1] = (unsigned int) masked_area_or_null;
SVC_Call(SYSCALL_nbgl_front_control_area_masking_ID, parameters);
return;
}

void nbgl_frontDrawImageFile(nbgl_area_t *area,
uint8_t *buffer,
nbgl_color_map_t colorMap,
Expand Down

0 comments on commit 979634f

Please sign in to comment.