Perspective

The perspective is a hexagonal prism-like widget that uses six tabs as column faces. Once the perspective widget is created, it automatically rotates to display different tabs. During the rotation, you can also click on different tabs to quickly jump to the desired tab.

Usage

Create Perspective Widget

gui_perspective_create() is used to create a perspective widget. The img_file is a structure that contains image resources for the six tabs. When creating the perspective widget, the image resources for the six tabs can be specified using either memory addresses or file paths. The src_mode field in gui_perspective_imgfile_t (refer to the following structure) indicates whether the image resource originates from a memory address or a file path. For instance, when src_mode is set to IMG_SRC_MEMADDR, it means the image resource comes from a memory address.

typedef struct
{
    IMG_SOURCE_MODE_TYPE src_mode[6];                    //!< flag: indicate file src
    union
    {
        char *img_path[6];               //!< images file path
        void *data_addr[6];              //!< images memory address
    };
} gui_perspective_imgfile_t;

Set Image for Perspective

The images of cube can be configured by calling gui_perspective_set_img().

Set Image Blending Mode

By default, the image blending mode is set to IMG_SRC_OVER_MODE, you can change the image blending mode by calling gui_perspective_set_mode(). The BLEND_MODE_TYPE enumeration for the blending modes is as follows:

typedef enum
{
    IMG_BYPASS_MODE = 0,
    IMG_FILTER_BLACK,
    IMG_SRC_OVER_MODE, //S * Sa + (1 - Sa) * D
    IMG_COVER_MODE,
    IMG_RECT,
} BLEND_MODE_TYPE;

Example



API

Defines

RAD(d)

angle to rad

Functions

void gui_perspective_set_mode(gui_perspective_t *perspective, uint8_t img_index, BLEND_MODE_TYPE mode)

set the perspective image’s blend mode

Parameters:
  • perspective – the perspective widget pointer

  • img_index – the perspective image’s index

  • mode – the enumeration value of the mode is BLEND_MODE_TYPE

void gui_perspective_set_img(gui_perspective_t *perspective, gui_perspective_imgfile_t *img_file)

set perspective image

Parameters:
  • perspective – the perspective widget pointer

  • img_file – the image file data, set flg_fs true when using filesystem

gui_perspective_t *gui_perspective_create(void *parent, const char *name, gui_perspective_imgfile_t *img_file, int16_t x, int16_t y)

create 3D perspective, images can be loaded from filesystem or memory address

Example usage

void perspctive_example(void *parent)
{
    gui_perspective_imgfile_t imgfile =
    {
        .flg_fs = true,
        .img_path[0] = "Clockn.bin",
        .img_path[1] = "Weather.bin",
        .img_path[2] = "Music.bin",
        .img_path[3] = "QuickCard.bin",
        .img_path[4] = "HeartRate.bin",
        .img_path[5] = "Activity.bin"
    };
    img_test = gui_perspective_create(canvas, "test", &imgfile, 0, 0);
}

Parameters:
  • parent – parent widget

  • name – widget name

  • img_file – the image file data, set flg_fs true when using filesystem

  • x – left

  • y – top

Returns:

gui_perspective_t* widget pointer

struct gui_perspective_imgfile_t

Public Members

IMG_SOURCE_MODE_TYPE src_mode[6]

flag: indicate file src

char *img_path[6]

images file path

void *data_addr[6]

images memory address

union gui_perspective_imgfile_t
struct gui_perspective_t

Public Members

gui_obj_t base

base structure

draw_img_t img[6]
int ry[6]
int temp[6]
void *file_path[6]
void *ftl[6]
union gui_perspective_t
void *data[6]
uint8_t src_mode[6]
int16_t release_x
uint8_t checksum