release v5.0.0
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
**/*.o
|
||||
111
docs/README.md
111
docs/README.md
@@ -1,83 +1,64 @@
|
||||
# LittleV Graphics Libraray
|
||||
# Littlev Graphics Libraray
|
||||
|
||||

|
||||
|
||||
LittlevGL is a graphics library to create Graphical User Interfaces (GUI) on TFT, LCD or monochrome displays for microcontroller based embedded systems.
|
||||
|
||||
Transparency, anti-aliassing and smooth animations can be used with no double buffering so typically no external memories are required. Layouts, scrolling, word-wrapping, layers and other features make your job easier.
|
||||
|
||||
The graphics library is written in C and it is completely hardware independent. You can even run it in a PC simulator without any embedded hardware.
|
||||
Littlev Graphics Library provides everything you need to add graphical user interface (GUI) to your embedded system. LittlevGL is designed to be an all-in-one solution for microcontroller based embedded GUIs where high level graphics feature, easy-to-use graphical elements and low memory footprint are required.
|
||||
|
||||
Homepage: http://gl.littlev.hu
|
||||
|
||||
### Table Of Content
|
||||
* [Key features](#key-features)
|
||||
* [Porting](#porting)
|
||||
* [Project set-up](#project-set-up)
|
||||
* [PC simulator](#pc-simulator)
|
||||
* [Contributing](#contributing)
|
||||
* [Donate](#donate)
|
||||
|
||||
## Key features
|
||||
* Hardware independent, support any modern microcontroller
|
||||
* High resolution TFTs, monochrome or any type of display supported (24/16/8/1 bit color depth)
|
||||
* External RAM, FPU or GPU not required just optional
|
||||
* Build GUI from simple graphical objects
|
||||
* Buttons, Labels, Images
|
||||
* Charts, Lists, Bars, Sliders, Text areas etc.
|
||||
* Create or delete graphical object dynamically in run time
|
||||
* High level graphical features without double buffering
|
||||
* Antialiassing (font or full screen)
|
||||
* Animations
|
||||
* Transparency
|
||||
* Gradient colors
|
||||
* Smooth dragging and scrolling
|
||||
* Built-in features
|
||||
* Layouts (to auto-arrange items)
|
||||
* Scrolling
|
||||
* Auto-size (aligned to the content)
|
||||
* Word wrapping
|
||||
* Layers
|
||||
* Customizable appearance with styles
|
||||
* Applications for complex tasks
|
||||
* Can run in a PC simulator
|
||||
* Modular and well-structured source code
|
||||
* Actively developed
|
||||
- Powerful building blocks buttons, charts, lists, sliders, images etc
|
||||
- Advanced graphics with animations, anti-aliasing, opacity, smooth scrolling
|
||||
- Various input devices touch pad, mouse, keyboard and external buttons
|
||||
- Multi language support with UTF-8 support
|
||||
- Fully customizable graphical elements
|
||||
|
||||
- Hardware independent to use with any MCU or display
|
||||
- Scalable to operate with few memory (80 kB Flash, 10 kB RAM)
|
||||
- OS, External memory and GPU supported but not required
|
||||
- Single frame buffer operation even with advances graphical effects
|
||||
|
||||
- Written in C for maximal compatibility
|
||||
- PC simulator to develop without embedded hardware
|
||||
- Tutorials, examples, themes for rapid development
|
||||
- Advanced support and professional GUI development service
|
||||
- Documentation and API references online
|
||||
- Free and open source under MIT licence
|
||||
|
||||
## Porting
|
||||
The following functions has to be provided
|
||||
* hal/disp `disp_fill(x1, y1, x2, y2, color)` to fill area with a color
|
||||
* hal/disp `disp_map(x1, y1, x2, y2, &color_array)` copy a color map to an area
|
||||
* hal/disp `disp_color_cpy(dest, src, length, opa)` copy pixel, optional for GPU
|
||||
* hal/indev `indev_get(id, &x, &y)` get the *x* and *y* coordinates from an input device (e.g. touch pad)
|
||||
* hal/systick `systick_get()` get a system tick with 1 ms resolution
|
||||
* hal/systick `systick_elapse(prev_time)` get the elapsed milliseconds sience *prev_time*
|
||||
|
||||
See the [example HAL](https://github.com/littlevgl/hal) repository!
|
||||
|
||||
## Requirements
|
||||
* [Misc. library](https://github.com/littlevgl/misc) is used by the graphics library
|
||||
In the most sime case you need 4 things:
|
||||
1. Call `lv_tick_inc(1)` in every millisecods in a Timer or Task
|
||||
2. Register a function which can copy a pixel array to an area of the screen
|
||||
3. Register a function which can read an input device. (E.g. touch pad)
|
||||
4. Call `lv_task_handler()` periodically in every few milliseconds ()
|
||||
|
||||
For more information visit http://gl.littlev.hu/porting
|
||||
|
||||
## Project set-up
|
||||
1. Clone or download the following repositories:
|
||||
* lvgl:`git clone https://github.com/littlevgl/lvgl.git`
|
||||
* misc: `git clone https://github.com/littlevgl/misc.git`
|
||||
* hal: `git clone https://github.com/littlevgl/hal.git`
|
||||
2. Create project with your prefered IDE and add the **lvgl**, **misc** and **hal** folders
|
||||
3. Add your projects **root directory as include path**
|
||||
4. Write your display, touch pad and system tick **drivers in hal**
|
||||
5. Copy *lvgl/lv_conf_templ.h* as **lv_conf.h** and *misc/misc_conf_templ.h* as **misc_conf.h** to the projects root folder
|
||||
6. In the *_conf.h files delete the first `#if 0` and its `#endif`. Let the default configurations at first.
|
||||
7. In your *main.c* include:
|
||||
* #include "misc/misc.h"
|
||||
* #include "misc/os/ptask.h"
|
||||
* #include "lvgl/lvgl.h"
|
||||
8. In your *main.c* intialize:
|
||||
* **misc_init()**;
|
||||
* your_systick_init();
|
||||
* your_disp_init();
|
||||
* your_indev_init();
|
||||
* **lv_init()**;
|
||||
10. To **test** create a label: `lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);`
|
||||
11. In the main *while(1)* call `ptask_handler();` and make a few milliseconds delay (e.g. `your_delay_ms(5);`)
|
||||
12. Compile the code and load it to your embedded hardware
|
||||
1. Clone or download the lvgl repository: `git clone https://github.com/littlevgl/lvgl.git`
|
||||
2. Create project with your prefered IDE and add the *lvgl* folder
|
||||
3. Copy *lvgl/lv_conf_templ.h* as *lv_conf.h* next to the lvgl folder
|
||||
4. In the *_conf.h files delete the first `#if 0` and its `#endif`. Let the default configurations at first.
|
||||
5. In your *main.c*: #include "lvgl/lvgl.h"
|
||||
6. In your *main function*:
|
||||
* lvgl_init();
|
||||
* tick, display and input device initialization (see above)
|
||||
7. To **test** create a label: `lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);`
|
||||
8. In the main *while(1)* call `lv_task_handler();` and make a few milliseconds delay (e.g. `my_delay_ms(5);`)
|
||||
9. Compile the code and load it to your embedded hardware
|
||||
|
||||
## PC Simulator
|
||||
If you don't have got an embedded hardware you can test the graphics library in a PC simulator. The simulator uses [SDL2](https://www.libsdl.org/) to emulate a display on your monitor and a touch pad with your mouse.
|
||||
|
||||
There is a pre-configured PC project for **Eclipse CDT** in this repository: https://github.com/littlevgl/proj_pc
|
||||
There is a pre-configured PC project for **Eclipse CDT** in this repository: https://github.com/littlevgl/pc_simulator
|
||||
|
||||
## Contributing
|
||||
See [CONTRIBUTING.md](https://github.com/littlevgl/lvgl/blob/master/docs/CONTRIBUTING.md)
|
||||
|
||||
@@ -19,3 +19,4 @@ Please create an issue to introduce a bug instead of adding pull request to this
|
||||
## v4.2 (released at: 17.08.2017)
|
||||
- [x] lv_slider: don't let indicator or bar to disappear because of hpad/vpad
|
||||
- [x] lv_ta: memory leak if deleted in password mode
|
||||
- [x] lv_list: work without *lv_img* by ignore the image file name parameter of *lv_list_add()*
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* @file img_conf.h
|
||||
*
|
||||
*/
|
||||
|
||||
#if 0 /*Remove this to enable the content (Delete the last #endif too!)*/
|
||||
|
||||
#ifndef IMG_CONF_H
|
||||
#define IMG_CONF_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/* Enable here the used images
|
||||
* For example:
|
||||
* #define USE_IMG_EXAMPLE 1
|
||||
*
|
||||
* This is compatible with the images
|
||||
* generated by the image converter utility
|
||||
* For more information see: www.littlev.hu */
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#endif /*Remove this to enable the content*/
|
||||
1136
lv_app/lv_app.c
1136
lv_app/lv_app.c
File diff suppressed because it is too large
Load Diff
270
lv_app/lv_app.h
270
lv_app/lv_app.h
@@ -1,270 +0,0 @@
|
||||
/**
|
||||
* @file lv_app.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_H
|
||||
#define LV_APP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Check dependencies*/
|
||||
#if LV_OBJ_FREE_P == 0
|
||||
#error "lv_app: Free pointer is required for application. Enable it lv_conf.h: LV_OBJ_FREE_P 1"
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_NUM == 0
|
||||
#error "lv_app: Free number is required for application. Enable it lv_conf.h: LV_OBJ_FREE_NUM 1"
|
||||
#endif
|
||||
|
||||
#if DM_CUSTOM == 0 && DM_MEM_SIZE < (2 * 1024)
|
||||
#error "lv_app: not enough dynamic memory. Increase it in misc_conf.h: DM_MEM_SIZE"
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_MODE_NONE = 0x0000,
|
||||
LV_APP_MODE_NOT_LIST = 0x0001, /*Do not list the application*/
|
||||
LV_APP_MODE_NO_SC_TITLE = 0x0002, /*No short cut title*/
|
||||
}lv_app_mode_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_COM_TYPE_CHAR, /*Stream of characters. Not '\0' terminated*/
|
||||
LV_APP_COM_TYPE_INT, /*Stream of 'int32_t' numbers*/
|
||||
LV_APP_COM_TYPE_LOG, /*String about an event to log*/
|
||||
LV_APP_COM_TYPE_TRIG, /*A trigger to do some specific action (data is ignored)*/
|
||||
LV_APP_COM_TYPE_INV, /*Invalid type*/
|
||||
LV_APP_COM_TYPE_NUM, /*Indicates the number of com. types*/
|
||||
}lv_app_com_type_t;
|
||||
|
||||
struct __LV_APP_DSC_T;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const struct __LV_APP_DSC_T * dsc;
|
||||
char * name;
|
||||
lv_obj_t * sc;
|
||||
lv_obj_t * sc_title;
|
||||
lv_obj_t * win;
|
||||
lv_obj_t * conf_win;
|
||||
void * app_data;
|
||||
void * sc_data;
|
||||
void * win_data;
|
||||
}lv_app_inst_t;
|
||||
|
||||
typedef struct __LV_APP_DSC_T
|
||||
{
|
||||
const char * name;
|
||||
lv_app_mode_t mode;
|
||||
void (*app_run)(lv_app_inst_t *, void *);
|
||||
void (*app_close) (lv_app_inst_t *);
|
||||
void (*com_rec) (lv_app_inst_t *, lv_app_inst_t *, lv_app_com_type_t, const void *, uint32_t);
|
||||
void (*sc_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
void (*sc_close) (lv_app_inst_t *);
|
||||
void (*win_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
void (*win_close) (lv_app_inst_t *);
|
||||
void (*conf_open) (lv_app_inst_t *, lv_obj_t * );
|
||||
uint16_t app_data_size;
|
||||
uint16_t sc_data_size;
|
||||
uint16_t win_data_size;
|
||||
}lv_app_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_style_t menu;
|
||||
lv_style_t menu_btn_rel;
|
||||
lv_style_t menu_btn_pr;
|
||||
lv_style_t sc_rel;
|
||||
lv_style_t sc_pr;
|
||||
lv_style_t sc_send_rel;
|
||||
lv_style_t sc_send_pr;
|
||||
lv_style_t sc_rec_rel;
|
||||
lv_style_t sc_rec_pr;
|
||||
lv_style_t sc_title;
|
||||
lv_style_t win_header;
|
||||
lv_style_t win_scrl;
|
||||
lv_style_t win_cbtn_rel;
|
||||
lv_style_t win_cbtn_pr;
|
||||
}lv_app_style_t;
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application system
|
||||
*/
|
||||
void lv_app_init(void);
|
||||
|
||||
/**
|
||||
* Get screen of the applications
|
||||
*/
|
||||
lv_obj_t * lv_scr_app(void);
|
||||
|
||||
/**
|
||||
* Allocate a new application descriptor
|
||||
* @return pointer to an lv_app_dsc_t pointer. Save here a pointer to an app. dsc.
|
||||
* E.g. *dsc = &my_app_dsc;
|
||||
*/
|
||||
lv_app_dsc_t ** lv_app_add_dsc(void);
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to an application specific configuration structure or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, void * conf);
|
||||
|
||||
/**
|
||||
* Close a running application. Close the Window and the Shortcut too if opened.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_sc_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_sc_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @return pointer to the shortcut
|
||||
*/
|
||||
lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
void lv_app_win_close(lv_app_inst_t * app);
|
||||
|
||||
/**
|
||||
* Send data to other applications
|
||||
* @param app_send pointer to the application which is sending the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
* @return number application which were received the message
|
||||
*/
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**
|
||||
* Test an application communication connection
|
||||
* @param sender pointer to an application which sends data
|
||||
* @param receiver pointer to an application which receives data
|
||||
* @return false: no connection, true: there is connection
|
||||
*/
|
||||
bool lv_app_con_check(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Create a new connection between two applications
|
||||
* @param sender pointer to a data sender application
|
||||
* @param receiver pointer to a data receiver application
|
||||
*/
|
||||
void lv_app_con_set(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Delete a communication connection
|
||||
* @param sender pointer to a data sender application or NULL to be true for all sender
|
||||
* @param receiver pointer to a data receiver application or NULL to be true for all receiver
|
||||
*/
|
||||
void lv_app_con_del(lv_app_inst_t * sender, lv_app_inst_t * receiver);
|
||||
|
||||
/**
|
||||
* Get the application descriptor from its name
|
||||
* @param name name of the app. dsc.
|
||||
* @return pointer to the app. dsc.
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_dsc_get(const char * name);
|
||||
|
||||
/**
|
||||
* Rename an application
|
||||
* @param app pointer to an application
|
||||
* @param name a string with the new name
|
||||
*/
|
||||
void lv_app_rename(lv_app_inst_t * app, const char * name);
|
||||
|
||||
/**
|
||||
* Get the window object from an object located on the window
|
||||
* @param obj pointer to an object on the window
|
||||
* @return pointer to the window of 'obj'
|
||||
*/
|
||||
lv_obj_t * lv_app_win_get_from_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Read the list of the running applications. (Get he next element)
|
||||
* @param prev the previous application (at the first call give NULL to get the first application)
|
||||
* @param dsc pointer to an application descriptor to filer the applications (NULL to do not filter)
|
||||
* @return pointer to the next running application or NULL if no more
|
||||
*/
|
||||
lv_app_inst_t * lv_app_get_next(lv_app_inst_t * prev, lv_app_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Read the list of applications descriptors. (Get he next element)
|
||||
* @param prev the previous application descriptors(at the first call give NULL to get the first)
|
||||
* @return pointer to the next application descriptors or NULL if no more
|
||||
*/
|
||||
lv_app_dsc_t ** lv_app_dsc_get_next(lv_app_dsc_t ** prev);
|
||||
|
||||
|
||||
/**
|
||||
* Get a pointer to the application style structure. If modified then 'lv_app_refr_style' should be called
|
||||
* @return pointer to the application style structure
|
||||
*/
|
||||
lv_app_style_t * lv_app_style_get(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* POST-INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_fsel.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_notice.h"
|
||||
|
||||
#include "lvgl/lv_appx/lv_app_example.h"
|
||||
#include "lvgl/lv_appx/lv_app_phantom.h"
|
||||
#include "lvgl/lv_appx/lv_app_sysmon.h"
|
||||
#include "lvgl/lv_appx/lv_app_terminal.h"
|
||||
#include "lvgl/lv_appx/lv_app_files.h"
|
||||
#include "lvgl/lv_appx/lv_app_wifi.h"
|
||||
#include "lvgl/lv_appx/lv_app_gsm.h"
|
||||
#include "lvgl/lv_appx/lv_app_ethernet.h"
|
||||
#include "lvgl/lv_appx/lv_app_benchmark.h"
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_H*/
|
||||
@@ -1,381 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_fsel.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_fsel.h"
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lv_app_notice.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void fsel_refr(void);
|
||||
static lv_action_res_t fsel_close_action(lv_obj_t * close, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_up_action(lv_obj_t * up, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_next_action(lv_obj_t * next, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_prev_action(lv_obj_t * prev, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t fsel_file_action(lv_obj_t * file, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static const char * fsel_filter;
|
||||
static char fsel_path[LV_APP_FSEL_PATH_MAX_LEN];
|
||||
static uint16_t fsel_file_cnt;
|
||||
static lv_obj_t * fsel_win;
|
||||
static lv_obj_t * fsel_list;
|
||||
static void * fsel_param;
|
||||
static void (*fsel_ok_action)(void *, const char *);
|
||||
static lv_style_t style_btn_symbol;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File selector utility
|
||||
*/
|
||||
void lv_app_fsel_init(void)
|
||||
{
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol);
|
||||
style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the File selector
|
||||
* @param path start path
|
||||
* @param filter show only files with a specific extension, e.g. "wav".
|
||||
* "/" means filter to folders.
|
||||
* @param param a free parameter which will be added to 'ok_action'
|
||||
* @param ok_action an action to call when a file or folder is chosen
|
||||
*/
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param, void (*ok_action)(void *, const char *))
|
||||
{
|
||||
/*Save the parameters*/
|
||||
strcpy(fsel_path, path);
|
||||
fsel_filter = filter;
|
||||
fsel_file_cnt = 0;
|
||||
fsel_param = param;
|
||||
fsel_ok_action = ok_action;
|
||||
|
||||
/*Trim the extra '\' or '/' from the end of path*/
|
||||
uint16_t i;
|
||||
for(i = strlen(fsel_path) -1 ; fsel_path[i] == '/' || fsel_path[i] == '\\'; i--) {
|
||||
fsel_path[i] = '\0';
|
||||
}
|
||||
|
||||
/*Check filter: NULL and "" mean no filtering*/
|
||||
if(fsel_filter == NULL) fsel_filter = "";
|
||||
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
/*Create a window for the File selector*/
|
||||
fsel_win = lv_win_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(fsel_win, LV_HOR_RES, LV_VER_RES);
|
||||
lv_win_set_styles_cbtn(fsel_win, &app_style->win_cbtn_rel, &app_style->win_cbtn_pr);
|
||||
lv_obj_set_style(lv_win_get_header(fsel_win), &app_style->menu);
|
||||
|
||||
lv_win_add_cbtn(fsel_win, SYMBOL_CLOSE, fsel_close_action);
|
||||
|
||||
fsel_refr(); /*Refresh the list*/
|
||||
|
||||
/*Show instruction when first open with folder filter*/
|
||||
static bool first_folder_call = false;
|
||||
if(first_folder_call == false && fsel_filter[0] == '/') {
|
||||
lv_app_notice_add("Press a folder long\nto choose it!");
|
||||
first_folder_call = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the File selector
|
||||
*/
|
||||
void lv_app_fsel_close(void)
|
||||
{
|
||||
if(fsel_win != NULL) {
|
||||
lv_obj_del(fsel_win);
|
||||
}
|
||||
|
||||
fsel_win = NULL;
|
||||
fsel_list = NULL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Refresh the file list according to the current path and filter
|
||||
*/
|
||||
static void fsel_refr(void)
|
||||
{
|
||||
/*Delete the previous list*/
|
||||
if(fsel_list != NULL) {
|
||||
lv_obj_del(fsel_list);
|
||||
}
|
||||
|
||||
lv_win_set_title(fsel_win, fsel_path);
|
||||
|
||||
/*Create a new list*/
|
||||
fsel_list = lv_list_create(fsel_win, NULL);
|
||||
lv_obj_set_width(fsel_list, lv_win_get_width(fsel_win));
|
||||
lv_list_set_style_img(fsel_list, &style_btn_symbol);
|
||||
lv_obj_set_style(lv_page_get_scrl(fsel_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_drag_parent(fsel_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(fsel_list), true);
|
||||
lv_cont_set_fit(fsel_list, false, true);
|
||||
|
||||
fs_res_t res = FS_RES_OK;
|
||||
lv_obj_t * liste;
|
||||
|
||||
/*At empty path show the drivers */
|
||||
if(fsel_path[0] == '\0') {
|
||||
char drv[16];
|
||||
char buf[2];
|
||||
fs_get_letters(drv);
|
||||
uint8_t i;
|
||||
for(i = 0; drv[i] != '\0'; i++) {
|
||||
buf[0] = drv[i];
|
||||
buf[1] = '\0';
|
||||
liste = lv_list_add(fsel_list, SYMBOL_DRIVE, buf, fsel_drv_action);
|
||||
/*Add long press action to choose the driver as a folder*/
|
||||
if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_drv_lpr_action);
|
||||
}
|
||||
}
|
||||
/*List the files/folders with fs interface*/
|
||||
else {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_UP, "Up", fsel_up_action);
|
||||
|
||||
fs_readdir_t rd;
|
||||
res = fs_readdir_init(&rd, fsel_path);
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
return;
|
||||
}
|
||||
|
||||
/*At not first page add prev. page button */
|
||||
if(fsel_file_cnt != 0) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_LEFT, "Previous page", fsel_prev_action);
|
||||
}
|
||||
|
||||
char fn[LV_APP_FSEL_FN_MAX_LEN];
|
||||
|
||||
/*Read the files from the previous pages*/
|
||||
uint16_t file_cnt = 0;
|
||||
while(file_cnt <= fsel_file_cnt) {
|
||||
res = fs_readdir(&rd, fn);
|
||||
if(res != FS_RES_OK){
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
return;
|
||||
}
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Add list elements from the files and folders*/
|
||||
while(res == FS_RES_OK && fn[0] != '\0') {
|
||||
if(fn[0] == '/') { /*Add a folder*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(fsel_list, SYMBOL_FOLDER, &fn[1], fsel_folder_action);
|
||||
/*Add long press action to choose a folder*/
|
||||
if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_folder_lpr_action);
|
||||
|
||||
fsel_file_cnt ++;
|
||||
file_cnt ++;
|
||||
}
|
||||
/*Add a file if it is not filtered*/
|
||||
else if(fsel_filter[0] == '\0' || /*No filtering or ...*/
|
||||
(strcmp(fs_get_ext(fn), fsel_filter) == 0 && /*.. the filter matches*/
|
||||
fsel_filter[0] != '/')) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_FILE, fn, fsel_file_action);
|
||||
fsel_file_cnt ++;
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Get the next element*/
|
||||
res = fs_readdir(&rd, fn);
|
||||
|
||||
/*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/
|
||||
if(fsel_file_cnt != 0 && fsel_file_cnt % LV_APP_FSEL_PAGE_SIZE == 0) {
|
||||
liste = lv_list_add(fsel_list, SYMBOL_RIGHT, "Next page", fsel_next_action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Close the read directory*/
|
||||
fs_readdir_close(&rd);
|
||||
}
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the path\nin File selector");
|
||||
}
|
||||
|
||||
/*Focus to the top of the list*/
|
||||
lv_obj_set_y(lv_page_get_scrl(fsel_list), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the File selector window close button is released
|
||||
* @param close pointer to the close button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the window is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_close_action(lv_obj_t * close, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_fsel_close();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Up list element is released to step one level
|
||||
* @param up pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_up_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
fs_up(fsel_path);
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Next list element is released to go to the next page
|
||||
* @param next pointer to the Next button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_next_action(lv_obj_t * next, lv_dispi_t * dispi)
|
||||
{
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Prev list element is released to previous page
|
||||
* @param prev pointer to the Prev button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_prev_action(lv_obj_t * prev, lv_dispi_t * dispi)
|
||||
{
|
||||
if(fsel_file_cnt <= 2 * LV_APP_FSEL_PAGE_SIZE) fsel_file_cnt = 0;
|
||||
else if(fsel_file_cnt % LV_APP_FSEL_PAGE_SIZE == 0) {
|
||||
fsel_file_cnt -= 2 * LV_APP_FSEL_PAGE_SIZE;
|
||||
} else {
|
||||
fsel_file_cnt = ((fsel_file_cnt / LV_APP_FSEL_PAGE_SIZE) - 1) * LV_APP_FSEL_PAGE_SIZE;
|
||||
}
|
||||
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is released to step into a driver
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s:", lv_list_get_element_text(drv));
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is long pressed to choose it
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s:", lv_list_get_element_text(drv));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a folder list element is released to enter into it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder));
|
||||
fsel_file_cnt = 0;
|
||||
fsel_refr();
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a folder list element is long pressed to choose it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a file list element is released to choose it
|
||||
* @param file pointer to a file button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t fsel_file_action(lv_obj_t * file, lv_dispi_t * dispi)
|
||||
{
|
||||
sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(file));
|
||||
|
||||
if(fsel_ok_action != NULL) {
|
||||
fsel_ok_action(fsel_param, fsel_path);
|
||||
}
|
||||
|
||||
lv_app_fsel_close();
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_fsel.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_FSEL_H
|
||||
#define LV_APP_FSEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Add the required configurations*/
|
||||
#ifndef LV_APP_FSEL_FN_MAX_LEN
|
||||
#define LV_APP_FSEL_FN_MAX_LEN 128
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_FSEL_PATH_MAX_LEN
|
||||
#define LV_APP_FSEL_PATH_MAX_LEN 256
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_FSEL_PAGE_SIZE
|
||||
#define LV_APP_FSEL_PAGE_SIZE 8
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File selector utility
|
||||
*/
|
||||
void lv_app_fsel_init(void);
|
||||
|
||||
/**
|
||||
* Open the File selector
|
||||
* @param path start path
|
||||
* @param filter show only files with a specific extension, e.g. "wav".
|
||||
* "/" means filter to folders.
|
||||
* @param param a free parameter which will be added to 'ok_action'
|
||||
* @param ok_action an action to call when a file or folder is chosen (give 'param' and the path as parameters)
|
||||
*/
|
||||
void lv_app_fsel_open(const char * path, const char * filter, void * param,
|
||||
void (*ok_action)(void *, const char *));
|
||||
|
||||
/**
|
||||
* Close the File selector
|
||||
*/
|
||||
void lv_app_fsel_close(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_FSEL_H*/
|
||||
@@ -1,278 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_kb.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_kb.h"
|
||||
#if USE_LV_APP_KB != 0
|
||||
|
||||
#include "lvgl/lv_objx/lv_btnm.h"
|
||||
#include "lvgl/lv_objx/lv_ta.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_APP_KB_ANIM_TIME
|
||||
#define LV_APP_KB_ANIM_TIME 300 /*ms*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * kb_btnm;
|
||||
static lv_obj_t * kb_win;
|
||||
static lv_obj_t * kb_ta;
|
||||
static const char * kb_map_lc[] = {
|
||||
"\0051#", "\004q", "\004w", "\004e", "\004r", "\004t", "\004y", "\004u", "\004i", "\004o", "\004p", "\007Del", "\n",
|
||||
"\006ABC", "\003a", "\003s", "\003d", "\003f", "\003g", "\003h", "\003j", "\003k", "\003l", "\010Enter", "\n",
|
||||
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_uc[] = {
|
||||
"\0051#", "\004Q", "\004W", "\004E", "\004R", "\004T", "\004Y", "\004U", "\004I", "\004O", "\004P", "\007Del", "\n",
|
||||
"\006abc", "\003A", "\003S", "\003D", "\003F", "\003G", "\003H", "\003J", "\003K", "\003L", "\010Enter", "\n",
|
||||
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_spec[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\002Del", "\n",
|
||||
"\002abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
|
||||
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
|
||||
"\003Hide", "\003Left", "\006 ", "\003Right", "\003Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_num[] = {
|
||||
"1", "2", "3", "\002Hide","\n",
|
||||
"4", "5", "6", "\002Ok", "\n",
|
||||
"7", "8", "9", "\002Del", "\n",
|
||||
"+/-", "0", ".", "Left", "Right", ""
|
||||
};
|
||||
|
||||
static cord_t kb_ta_ori_size;
|
||||
static uint8_t kb_mode;
|
||||
static void (*kb_close_action)(lv_obj_t *);
|
||||
static void (*kb_ok_action)(lv_obj_t *);
|
||||
static lv_style_t style_bg;
|
||||
static lv_style_t style_btn_rel;
|
||||
static lv_style_t style_btn_pr;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void)
|
||||
{
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
|
||||
memcpy(&style_bg, &app_style->menu, sizeof(lv_style_t));
|
||||
style_bg.opa = OPA_COVER;
|
||||
style_bg.hpad = 0;
|
||||
style_bg.vpad = 0;
|
||||
style_bg.opad = 0;
|
||||
|
||||
memcpy(&style_btn_rel, &app_style->menu_btn_rel, sizeof(lv_style_t));
|
||||
style_btn_rel.radius = 0;
|
||||
style_btn_rel.bwidth = 1;
|
||||
|
||||
memcpy(&style_btn_pr, &app_style->menu_btn_pr, sizeof(lv_style_t));
|
||||
style_btn_pr.radius = 0;
|
||||
style_btn_pr.bwidth = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a keyboard for a text area object
|
||||
* @param ta pointer to a text area object
|
||||
* @param mode 'OR'd values of 'lv_app_kb_mode_t' enum
|
||||
* @param close a function to call when the keyboard is closed
|
||||
* @param ok a function to called when the "Ok" button is pressed
|
||||
* @return the created button matrix objects
|
||||
*/
|
||||
lv_obj_t * lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *))
|
||||
{
|
||||
/*Close the previous keyboard*/
|
||||
if(kb_btnm != NULL) {
|
||||
lv_app_kb_close(false);
|
||||
}
|
||||
|
||||
/*Save some parameters*/
|
||||
kb_ta = ta;
|
||||
kb_mode = mode;
|
||||
kb_close_action = close;
|
||||
kb_ok_action = ok;
|
||||
|
||||
/*Create a button matrix for the keyboard */
|
||||
kb_btnm = lv_btnm_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(kb_btnm, &style_bg);
|
||||
lv_obj_set_size(kb_btnm, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_align(kb_btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_btnm_set_action(kb_btnm, lv_app_kb_action);
|
||||
if(mode & LV_APP_KB_MODE_TXT) {
|
||||
style_btn_rel.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
style_btn_pr.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
lv_btnm_set_map(kb_btnm, kb_map_lc);
|
||||
}
|
||||
else if(mode & LV_APP_KB_MODE_NUM) {
|
||||
style_btn_rel.font = font_get(LV_APP_FONT_LARGE);
|
||||
style_btn_pr.font = font_get(LV_APP_FONT_LARGE);
|
||||
lv_btnm_set_map(kb_btnm, kb_map_num);
|
||||
}
|
||||
lv_btnm_set_styles_btn(kb_btnm, &style_btn_rel, &style_btn_pr);
|
||||
|
||||
kb_win = NULL;
|
||||
kb_ta_ori_size = 0;
|
||||
if(mode & LV_APP_KB_MODE_WIN_RESIZE) {
|
||||
/*Reduce the size of the window and align it to the top*/
|
||||
kb_win = lv_app_win_get_from_obj(kb_ta);
|
||||
lv_obj_set_height(kb_win, LV_VER_RES / 2);
|
||||
lv_obj_set_y(kb_win, 0);
|
||||
|
||||
/*If the text area is higher then the new size of the window reduce its size too*/
|
||||
cord_t cont_h = lv_obj_get_height(kb_win) - lv_obj_get_height(lv_win_get_header(kb_win));
|
||||
kb_ta_ori_size = lv_obj_get_height(kb_ta);
|
||||
if(lv_obj_get_height(kb_ta) > cont_h - LV_DPI / 10) {
|
||||
lv_obj_set_height(kb_ta, cont_h - LV_DPI / 10);
|
||||
}
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
}
|
||||
|
||||
lv_ta_set_cursor_pos(kb_ta, LV_TA_CUR_LAST);
|
||||
if(kb_mode & LV_APP_KB_MODE_CUR_MANAGE) {
|
||||
lv_ta_set_cursor_show(kb_ta, true);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_ANIM_IN) {
|
||||
lv_obj_anim(kb_btnm, LV_ANIM_FLOAT_BOTTOM | ANIM_IN, LV_APP_KB_ANIM_TIME, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
return kb_btnm;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the keyboard
|
||||
* @param ok true: call the ok function, false: call the close function
|
||||
*/
|
||||
void lv_app_kb_close(bool ok)
|
||||
{
|
||||
if(kb_btnm == NULL) return;
|
||||
|
||||
if(ok == false) {
|
||||
if(kb_close_action != NULL) kb_close_action(kb_ta);
|
||||
} else {
|
||||
if(kb_ok_action != NULL) kb_ok_action(kb_ta);
|
||||
}
|
||||
|
||||
/*Reset the modified sizes*/
|
||||
if((kb_mode & LV_APP_KB_MODE_WIN_RESIZE) && kb_win != NULL) {
|
||||
lv_obj_set_height(kb_ta, kb_ta_ori_size);
|
||||
lv_obj_set_size(kb_win, LV_HOR_RES, LV_VER_RES);
|
||||
kb_win = NULL;
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_CUR_MANAGE) {
|
||||
lv_ta_set_cursor_show(kb_ta, false);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_ANIM_OUT) {
|
||||
lv_obj_anim(kb_btnm, LV_ANIM_FLOAT_BOTTOM | ANIM_OUT, LV_APP_KB_ANIM_TIME, 0, lv_obj_del);
|
||||
} else {
|
||||
lv_obj_del(kb_btnm);
|
||||
}
|
||||
|
||||
kb_btnm = NULL;
|
||||
kb_ta = NULL;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called when a button of 'kb_btnm' is released
|
||||
* @param btnm pointer to 'kb_btnm'
|
||||
* @param i the index of the released button from the current btnm map
|
||||
* @return LV_ACTION_RES_INV if the btnm is deleted else LV_ACTION_RES_OK
|
||||
*/
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
|
||||
{
|
||||
const char ** map = lv_btnm_get_map(btnm);
|
||||
const char * txt = map[i];
|
||||
|
||||
/*Ignore the unit size number of the text*/
|
||||
if(txt[0] <= '\011') txt++;
|
||||
|
||||
/*Do the corresponding action according to the text of the button*/
|
||||
if(strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_lc);
|
||||
} else if(strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_uc);
|
||||
} else if(strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_spec);
|
||||
} else if(strcmp(txt, "Enter") == 0) {
|
||||
lv_ta_add_char(kb_ta, '\n');
|
||||
} else if(strcmp(txt, "Left") == 0) {
|
||||
lv_ta_cursor_left(kb_ta);
|
||||
} else if(strcmp(txt, "Right") == 0) {
|
||||
lv_ta_cursor_right(kb_ta);
|
||||
} else if(strcmp(txt, "Del") == 0) {
|
||||
lv_ta_del(kb_ta);
|
||||
} else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(kb_ta);
|
||||
const char * ta_txt = lv_ta_get_txt(kb_ta);
|
||||
if(ta_txt[0] == '-') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '+');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else if(ta_txt[0] == '+') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else {
|
||||
lv_ta_set_cursor_pos(kb_ta, 0);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur + 1);
|
||||
}
|
||||
} else if(strcmp(txt, "Hide") == 0) {
|
||||
lv_app_kb_close(false);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else if(strcmp(txt, "Ok") == 0) {
|
||||
lv_app_kb_close(true);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else {
|
||||
lv_ta_add_text(kb_ta, txt);
|
||||
}
|
||||
|
||||
if(kb_mode & LV_APP_KB_MODE_WIN_RESIZE) {
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_page(kb_win), kb_ta, 0);
|
||||
#endif
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_kb.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_KB_H
|
||||
#define LV_APP_KB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#if USE_LV_APP_KB != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_KB_MODE_TXT = 0x0001,
|
||||
LV_APP_KB_MODE_NUM = 0x0002,
|
||||
LV_APP_KB_MODE_WIN_RESIZE = 0x0004,
|
||||
LV_APP_KB_MODE_CUR_MANAGE = 0x0008,
|
||||
LV_APP_KB_MODE_ANIM_IN = 0x0010,
|
||||
LV_APP_KB_MODE_ANIM_OUT = 0x0020,
|
||||
}lv_app_kb_mode_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application keyboard
|
||||
*/
|
||||
void lv_app_kb_init(void);
|
||||
|
||||
/**
|
||||
* Open a keyboard for a text area object
|
||||
* @param ta pointer to a text area object
|
||||
* @param mode 'OR'd values of 'lv_app_kb_mode_t' enum
|
||||
* @param close a function to call when the keyboard is closed
|
||||
* @param ok a function to called when the "Ok" button is pressed
|
||||
* @return the created button matrix objects
|
||||
*/
|
||||
lv_obj_t * lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t *), void (*ok)(lv_obj_t *));
|
||||
|
||||
/**
|
||||
* Close the keyboard
|
||||
* @param ok true: call the ok function, false: call the close function
|
||||
*/
|
||||
void lv_app_kb_close(bool ok);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_KB_H*/
|
||||
@@ -1,95 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_notice.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_notice.h"
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include "lvgl/lv_objx/lv_label.h"
|
||||
|
||||
#include "misc/gfx/anim.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * notice_h;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
/**
|
||||
* Initialize the Notifications
|
||||
*/
|
||||
void lv_app_notice_init(void)
|
||||
{
|
||||
notice_h = lv_cont_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - LV_DPI / 8);
|
||||
lv_obj_set_y(notice_h, LV_DPI / 8);
|
||||
lv_obj_set_click(notice_h, false);
|
||||
lv_obj_set_style(notice_h, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
lv_cont_set_layout(notice_h, LV_CONT_LAYOUT_COL_R);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...)
|
||||
{
|
||||
char txt[LV_APP_NOTICE_MAX_LEN];
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
vsprintf(txt,format, va);
|
||||
va_end(va);
|
||||
|
||||
lv_obj_t * mbox;
|
||||
mbox = lv_mbox_create(notice_h, NULL);
|
||||
lv_mbox_set_text(mbox, txt);
|
||||
lv_mbox_set_anim_close_time(mbox, LV_APP_NOTICE_CLOSE_ANIM_TIME);
|
||||
|
||||
#if LV_APP_NOTICE_SHOW_TIME != 0
|
||||
lv_mbox_start_auto_close(mbox, LV_APP_NOTICE_SHOW_TIME);
|
||||
#endif
|
||||
|
||||
/*Delete the last children if there are too many*/
|
||||
uint32_t child_num = lv_obj_get_child_num(notice_h);
|
||||
if(child_num > LV_APP_NOTICE_MAX_NUM) {
|
||||
lv_obj_t * last_child = ll_get_tail(¬ice_h->child_ll);
|
||||
lv_obj_del(last_child);
|
||||
}
|
||||
|
||||
/*make sure the notices are on the top*/
|
||||
lv_obj_set_parent(notice_h, lv_scr_act());
|
||||
|
||||
return mbox;
|
||||
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_notice.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_NOTICE_H
|
||||
#define LV_APP_NOTICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_app.h"
|
||||
#include <stdarg.h>
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Add the required configurations*/
|
||||
#ifndef LV_APP_NOTICE_SHOW_TIME
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_CLOSE_ANIM_TIME
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_MAX_NUM
|
||||
#define LV_APP_NOTICE_MAX_NUM 6
|
||||
#endif
|
||||
|
||||
#ifndef LV_APP_NOTICE_MAX_LEN
|
||||
#define LV_APP_NOTICE_MAX_LEN 256
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Notifications
|
||||
*/
|
||||
void lv_app_notice_init(void);
|
||||
|
||||
/**
|
||||
* Add a notification with a given text
|
||||
* @param format pritntf-like format string
|
||||
* @return pointer the notice which is a message box (lv_mbox) object
|
||||
*/
|
||||
lv_obj_t * lv_app_notice_add(const char * format, ...);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_APP_NOTICE_H*/
|
||||
|
||||
@@ -1,698 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_benchmark.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_benchmark.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "lvgl/lv_obj/lv_refr.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SHADOW_WIDTH (LV_DPI / 8)
|
||||
#define IMG_RECOLOR OPA_30
|
||||
#define OPACITY OPA_60
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t wp :1;
|
||||
uint8_t recolor :1;
|
||||
uint8_t upscalse :1;
|
||||
uint8_t shdw :1;
|
||||
uint8_t opa :1;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * wp;
|
||||
lv_obj_t * value_l;
|
||||
lv_style_t style_wp;
|
||||
lv_style_t style_value_l;
|
||||
lv_style_t style_btn_rel;
|
||||
lv_style_t style_btn_pr;
|
||||
lv_style_t style_btn_trel;
|
||||
lv_style_t style_btn_tpr;
|
||||
lv_style_t style_btn_ina;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void refr_monitor(uint32_t time_ms, uint32_t px_num);
|
||||
static lv_action_res_t run_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t wp_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t recolor_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t upscale_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t shadow_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t opa_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Benchmark",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_style_t style_win_scrl;
|
||||
static lv_style_t style_sc_btn_rel;
|
||||
static lv_style_t style_sc_btn_pr;
|
||||
|
||||
static bool caputre_next;
|
||||
|
||||
static const color_int_t img_benchmark_bg[];
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_benchmark_init(void)
|
||||
{
|
||||
lv_refr_set_monitor_cb(refr_monitor);
|
||||
|
||||
lv_img_create_file("app_bm_wp", img_benchmark_bg);
|
||||
|
||||
lv_style_get(LV_STYLE_TRANSP, &style_win_scrl);
|
||||
style_win_scrl.opad = 2 * SHADOW_WIDTH + SHADOW_WIDTH / 8 ;
|
||||
style_win_scrl.hpad = SHADOW_WIDTH;
|
||||
style_win_scrl.vpad = SHADOW_WIDTH;
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_sc_btn_rel);
|
||||
style_sc_btn_rel.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_PR, &style_sc_btn_pr);
|
||||
style_sc_btn_pr.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_benchmark_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * ad = app->app_data;
|
||||
ad->opa = 0;
|
||||
ad->recolor = 0;
|
||||
ad->shdw = 0;
|
||||
ad->upscalse = 0;
|
||||
ad->wp = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
my_sc_data_t * sc_data = app_rec->sc_data;
|
||||
if (sc_data->label != NULL) {
|
||||
lv_label_set_text_array(sc_data->label, data, size);
|
||||
lv_obj_align(sc_data->label , NULL,LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
lv_cont_set_layout(sc, LV_CONT_LAYOUT_CENTER);
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "N/A ms");
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(sc, NULL);
|
||||
lv_btn_set_rel_action(btn, run_rel_action);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
lv_btn_set_styles(btn, &style_sc_btn_rel, &style_sc_btn_pr, NULL, NULL, NULL);
|
||||
|
||||
lv_obj_t * btn_l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(btn_l, SYMBOL_PLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_INA, &wdata->style_value_l);
|
||||
wdata->style_value_l.ccolor = COLOR_BLACK;
|
||||
lv_style_get(LV_STYLE_BTN_REL, &wdata->style_btn_rel);
|
||||
lv_style_get(LV_STYLE_BTN_PR, &wdata->style_btn_pr);
|
||||
lv_style_get(LV_STYLE_BTN_TREL, &wdata->style_btn_trel);
|
||||
lv_style_get(LV_STYLE_BTN_TPR, &wdata->style_btn_tpr);
|
||||
lv_style_get(LV_STYLE_BTN_INA, &wdata->style_btn_ina);
|
||||
lv_style_get(LV_STYLE_PLAIN, &wdata->style_wp);
|
||||
wdata->style_wp.ccolor = COLOR_RED;//MAKE(0x10, 0x20, 0x30);
|
||||
|
||||
if(adata->opa == 0) {
|
||||
wdata->style_btn_rel.opa = OPA_COVER;
|
||||
wdata->style_btn_pr.opa = OPA_COVER;
|
||||
wdata->style_btn_trel.opa =OPA_COVER;
|
||||
wdata->style_btn_tpr.opa = OPA_COVER;
|
||||
wdata->style_btn_ina.opa = OPA_COVER;
|
||||
} else {
|
||||
wdata->style_btn_rel.opa = OPACITY;
|
||||
wdata->style_btn_pr.opa = OPACITY;
|
||||
wdata->style_btn_trel.opa =OPACITY;
|
||||
wdata->style_btn_tpr.opa = OPACITY;
|
||||
wdata->style_btn_ina.opa = OPACITY;
|
||||
}
|
||||
|
||||
if(adata->shdw == 0) {
|
||||
wdata->style_btn_rel.swidth = 0;
|
||||
wdata->style_btn_pr.swidth = 0;
|
||||
wdata->style_btn_trel.swidth = 0;
|
||||
wdata->style_btn_tpr.swidth = 0;
|
||||
wdata->style_btn_ina.swidth = 0;
|
||||
} else {
|
||||
wdata->style_btn_rel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_pr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_trel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_tpr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_ina.swidth = SHADOW_WIDTH;
|
||||
}
|
||||
|
||||
if(adata->recolor == 0) {
|
||||
wdata->style_wp.img_recolor = OPA_TRANSP;
|
||||
} else {
|
||||
wdata->style_wp.img_recolor = IMG_RECOLOR;
|
||||
}
|
||||
|
||||
lv_obj_set_style(lv_page_get_scrl(lv_win_get_page(win)), &style_win_scrl);
|
||||
|
||||
wdata->wp = lv_img_create(win, NULL);
|
||||
lv_obj_set_protect(wdata->wp, LV_PROTECT_PARENT);
|
||||
lv_obj_set_parent(wdata->wp, lv_win_get_page(win));
|
||||
lv_img_set_file(wdata->wp, "U:/app_bm_wp");
|
||||
lv_obj_set_size(wdata->wp, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(lv_win_get_header(win)));
|
||||
lv_obj_set_pos(wdata->wp, 0, 0);
|
||||
lv_obj_set_style(wdata->wp, &wdata->style_wp);
|
||||
lv_img_set_auto_size(wdata->wp, false);
|
||||
if(adata->wp == 0) lv_obj_set_hidden(wdata->wp, true);
|
||||
if(adata->upscalse != 0) lv_img_set_upscale(wdata->wp, true);
|
||||
|
||||
/* The order is changed because the wallpaper's parent change
|
||||
* Therefore add the scrollable again */
|
||||
lv_obj_set_parent(lv_page_get_scrl(lv_win_get_page(win)), lv_win_get_page(win));
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
lv_obj_t * holder;
|
||||
|
||||
holder = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(holder, true, true);
|
||||
lv_obj_set_style(holder, &wdata->style_btn_ina);
|
||||
lv_page_glue_obj(holder, true);
|
||||
|
||||
wdata->value_l = lv_label_create(holder, NULL);
|
||||
lv_obj_set_style(wdata->value_l, &wdata->style_value_l);
|
||||
lv_label_set_text(wdata->value_l, "Screen load: N/A ms\nN/A px/ms");
|
||||
|
||||
lv_obj_t * btn;
|
||||
btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(btn, app);
|
||||
lv_page_glue_obj(btn, true);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
lv_btn_set_styles(btn, &wdata->style_btn_rel, &wdata->style_btn_pr, &wdata->style_btn_trel, &wdata->style_btn_tpr, NULL);
|
||||
lv_btn_set_rel_action(btn, run_rel_action);
|
||||
|
||||
lv_obj_t * btn_l;
|
||||
btn_l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(btn_l, "Run\ntest!");
|
||||
lv_obj_set_protect(btn, LV_PROTECT_FOLLOW);
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
lv_btn_set_tgl(btn, true);
|
||||
lv_obj_clr_protect(btn, LV_PROTECT_FOLLOW);
|
||||
if(adata->wp != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, wp_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wallpaper");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->recolor != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, recolor_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wp. recolor!");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->upscalse != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, upscale_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Wp. upscalse!");
|
||||
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->shdw != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, shadow_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Shadow");
|
||||
|
||||
btn = lv_btn_create(win, btn);
|
||||
if(adata->opa != 0) lv_btn_set_state(btn, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
lv_btn_set_rel_action(btn, opa_rel_action);
|
||||
btn_l = lv_label_create(btn, btn_l);
|
||||
lv_label_set_text(btn_l, "Opacity");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void refr_monitor(uint32_t time_ms, uint32_t px_num)
|
||||
{
|
||||
if(caputre_next != false) {
|
||||
lv_app_inst_t * app = NULL;
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
|
||||
char w_buf[256];
|
||||
if(time_ms != 0) sprintf(w_buf, "Screen load: %d ms\n%d px/ms", time_ms, px_num/time_ms);
|
||||
else sprintf(w_buf, "Screen load: %d ms\nN/A px/ms", time_ms);
|
||||
|
||||
char s_buf[16];
|
||||
sprintf(s_buf, "%d ms", time_ms);
|
||||
|
||||
while(app != NULL) {
|
||||
if(app->win_data != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_label_set_text(wdata->value_l, w_buf);
|
||||
}
|
||||
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sdata = app->sc_data;
|
||||
lv_label_set_text(sdata->label, s_buf);
|
||||
}
|
||||
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
|
||||
|
||||
caputre_next = false;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_action_res_t run_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_obj_inv(lv_scr_act());
|
||||
caputre_next = true;
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t wp_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->wp = 1;
|
||||
lv_obj_set_hidden(wdata->wp, false);
|
||||
} else {
|
||||
adata->wp = 0;
|
||||
lv_obj_set_hidden(wdata->wp, true);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t recolor_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->recolor = 1;
|
||||
wdata->style_wp.img_recolor = IMG_RECOLOR;
|
||||
} else {
|
||||
adata->recolor = 0;
|
||||
wdata->style_wp.img_recolor = OPA_TRANSP;
|
||||
}
|
||||
|
||||
lv_obj_refr_style(wdata->wp);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t upscale_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->upscalse = 1;
|
||||
lv_img_set_upscale(wdata->wp, true);
|
||||
} else {
|
||||
adata->upscalse = 0;
|
||||
lv_img_set_upscale(wdata->wp, false);
|
||||
}
|
||||
|
||||
lv_obj_set_size(wdata->wp, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(lv_win_get_header(app->win)));
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t shadow_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->shdw = 1;
|
||||
wdata->style_btn_rel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_pr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_trel.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_tpr.swidth = SHADOW_WIDTH;
|
||||
wdata->style_btn_ina.swidth = SHADOW_WIDTH;
|
||||
} else {
|
||||
adata->shdw = 0;
|
||||
wdata->style_btn_rel.swidth = 0;
|
||||
wdata->style_btn_pr.swidth = 0;
|
||||
wdata->style_btn_trel.swidth =0;
|
||||
wdata->style_btn_tpr.swidth = 0;
|
||||
wdata->style_btn_ina.swidth = 0;
|
||||
}
|
||||
|
||||
lv_style_refr_objs(&wdata->style_btn_rel);
|
||||
lv_style_refr_objs(&wdata->style_btn_pr);
|
||||
lv_style_refr_objs(&wdata->style_btn_trel);
|
||||
lv_style_refr_objs(&wdata->style_btn_tpr);
|
||||
lv_style_refr_objs(&wdata->style_btn_ina);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t opa_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_TREL) {
|
||||
adata->opa = 1;
|
||||
wdata->style_btn_rel.opa = OPACITY;
|
||||
wdata->style_btn_pr.opa = OPACITY;
|
||||
wdata->style_btn_trel.opa =OPACITY;
|
||||
wdata->style_btn_tpr.opa = OPACITY;
|
||||
wdata->style_btn_ina.opa = OPACITY;
|
||||
} else {
|
||||
adata->opa = 0;
|
||||
wdata->style_btn_rel.opa = OPA_COVER;
|
||||
wdata->style_btn_pr.opa = OPA_COVER;
|
||||
wdata->style_btn_trel.opa =OPA_COVER;
|
||||
wdata->style_btn_tpr.opa = OPA_COVER;
|
||||
wdata->style_btn_ina.opa = OPA_COVER;
|
||||
}
|
||||
|
||||
lv_style_refr_objs(&wdata->style_btn_rel);
|
||||
lv_style_refr_objs(&wdata->style_btn_pr);
|
||||
lv_style_refr_objs(&wdata->style_btn_trel);
|
||||
lv_style_refr_objs(&wdata->style_btn_tpr);
|
||||
lv_style_refr_objs(&wdata->style_btn_ina);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/*Exceptionally store the data because the big array would be bothering*/
|
||||
|
||||
#if COLOR_DEPTH == 8
|
||||
static const color_int_t img_benchmark_bg[] = {
|
||||
/*HEADER
|
||||
Width = 40
|
||||
Height = 40
|
||||
Transp: 0
|
||||
Color depth: 8*/
|
||||
40, 128, 2, 2,
|
||||
|
||||
/*IMAGE DATA*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 5, 0, 5, 5, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 5, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 0, 0, 0, 5, 5, 5, 0, 5, 5, 5, 5, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 0, 5, 5, 5, 0, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 5, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 5, 5, 5, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
#endif /*COLOR_DEPTH*/
|
||||
|
||||
#if COLOR_DEPTH == 16
|
||||
static const color_int_t img_benchmark_bg[] = {
|
||||
/*HEADER
|
||||
Width = 40
|
||||
Height = 40
|
||||
Transp: 0
|
||||
Color depth: 16*/
|
||||
32808, 1026,
|
||||
|
||||
/*IMAGE DATA*/
|
||||
32, 32, 32, 2113, 2113, 4258, 6339, 4258, 4258, 4226, 4226, 2145, 4226, 2113, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 2145, 2145, 4226, 4226, 4226, 4226, 4226, 2145, 32, 32, 32, 32,
|
||||
0, 32, 2113, 32, 6339, 10565, 8452, 4258, 4226, 4226, 2145, 4226, 6339, 4226, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 2145, 4226, 2145, 2145, 4226, 4226, 4226, 6371, 6339, 4226, 32, 32, 32,
|
||||
32, 32, 2113, 4226, 8484, 8484, 8452, 6371, 4226, 2145, 4226, 4258, 4258, 4258, 2145, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 2145, 4226, 4226, 4226, 4226, 2145, 2145, 4226, 6339, 4258, 4258, 4226, 32, 32,
|
||||
32, 32, 4258, 6371, 8452, 6371, 6371, 6339, 4226, 2145, 4226, 4226, 2145, 4226, 4226, 2113, 32, 0, 0, 0, 0, 32, 0, 0, 32, 2113, 2145, 2145, 2145, 4226, 4226, 4226, 2145, 4226, 6339, 4226, 6371, 6339, 2145, 32,
|
||||
2113, 2145, 6371, 6339, 4226, 4226, 4226, 4226, 4258, 4258, 4226, 2145, 4226, 2145, 2145, 4226, 4258, 32, 0, 0, 0, 0, 0, 2113, 6339, 4226, 2113, 2145, 2145, 2145, 4226, 4226, 4258, 4226, 4258, 4258, 4258, 6339, 6339, 2145,
|
||||
4226, 4258, 6339, 4226, 4226, 2145, 2145, 2145, 4226, 4226, 4226, 2145, 2145, 2145, 4226, 6339, 8452, 6339, 32, 0, 0, 0, 2113, 6339, 6371, 6339, 2145, 2113, 2145, 2145, 4226, 4226, 4226, 4226, 4226, 4226, 4226, 4258, 4258, 4226,
|
||||
4226, 4226, 2145, 4226, 2145, 2145, 4226, 4226, 2145, 4226, 4226, 4226, 2145, 4226, 6371, 6371, 6371, 8452, 4258, 32, 0, 2113, 6371, 6371, 6371, 6339, 6339, 2145, 2145, 4226, 2145, 2145, 2145, 4226, 4258, 4226, 4226, 4226, 2145, 4226,
|
||||
4226, 2145, 4226, 2145, 2145, 4226, 4226, 4226, 4226, 4226, 2145, 2145, 4258, 6371, 8452, 6371, 6371, 6371, 8452, 6339, 2145, 6339, 8452, 6371, 6339, 6371, 6371, 6339, 4226, 2145, 2145, 2145, 2145, 2145, 4258, 4258, 2145, 2145, 2145, 2145,
|
||||
4226, 2145, 4226, 2113, 2145, 4226, 4258, 4226, 2145, 2145, 2145, 4258, 6371, 8452, 6371, 6339, 6371, 6371, 8452, 8452, 6339, 8452, 8452, 8452, 6371, 6371, 8452, 8452, 6339, 4226, 2145, 2145, 2145, 2145, 4226, 4258, 2145, 2113, 2145, 2145,
|
||||
2145, 2145, 2113, 2145, 4226, 4226, 4226, 2145, 2145, 2113, 4226, 6339, 6371, 6371, 6371, 6371, 6371, 8452, 6371, 8452, 8452, 6371, 8452, 8452, 6339, 6371, 8452, 8452, 8452, 6371, 4226, 2145, 4226, 4226, 4226, 4226, 4226, 4226, 2145, 4226,
|
||||
4226, 4226, 2145, 4226, 4226, 2145, 4226, 2145, 2113, 2145, 6339, 6371, 6371, 8452, 8452, 8452, 8484, 8452, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 8452, 8452, 6339, 2145, 2145, 4226, 4226, 2145, 4226, 4226, 2145, 4226,
|
||||
2145, 4226, 4258, 2145, 2145, 2145, 2113, 2145, 4226, 6339, 6371, 6371, 6371, 8452, 8484, 8484, 8452, 6371, 6371, 6371, 6371, 6371, 6371, 8452, 6371, 6339, 6371, 6371, 6371, 8452, 8452, 6339, 4226, 2145, 2145, 4226, 4226, 2145, 4226, 2145,
|
||||
32, 2113, 4226, 4226, 2145, 2145, 2113, 2145, 8452, 8452, 6371, 6371, 6339, 8484, 8484, 8484, 8484, 8452, 6371, 6339, 6371, 6371, 6371, 6371, 6371, 6371, 6339, 6339, 6339, 6339, 8452, 8484, 6371, 2145, 2145, 4226, 2145, 4226, 4226, 2113,
|
||||
0, 0, 2145, 4226, 4226, 4226, 4258, 6371, 6371, 8452, 6371, 6339, 6339, 8452, 8484, 8452, 8452, 8452, 6371, 6371, 8452, 8452, 8452, 6371, 6371, 6339, 6371, 6339, 6371, 6371, 8452, 8452, 8484, 8452, 4226, 4226, 4258, 4258, 2113, 32,
|
||||
0, 0, 32, 2113, 2145, 6339, 8452, 8452, 6339, 6339, 8452, 6371, 6339, 6371, 10565, 8484, 8452, 8484, 8452, 6371, 6339, 8452, 8452, 6371, 6371, 6339, 6371, 6371, 6371, 8452, 8452, 8452, 8484, 10565, 6371, 4258, 4226, 2145, 32, 0,
|
||||
0, 0, 0, 0, 2113, 6339, 8452, 6371, 6371, 6339, 6371, 8452, 6371, 6371, 8452, 8484, 8452, 8452, 8484, 8452, 4258, 8452, 8452, 6339, 6339, 6339, 6339, 6371, 6371, 6371, 6371, 8452, 8452, 8452, 8484, 8452, 2113, 0, 0, 32,
|
||||
0, 0, 0, 0, 0, 4258, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 6371, 8452, 8452, 8452, 8484, 8452, 2145, 32, 4226, 6371, 6371, 6371, 6339, 6371, 6371, 6371, 6371, 6371, 6371, 8452, 8452, 8452, 4226, 32, 0, 0, 32,
|
||||
0, 0, 0, 0, 0, 0, 4226, 8452, 6371, 6371, 6371, 6339, 6371, 8452, 8452, 8452, 8484, 8452, 2145, 0, 0, 0, 4226, 8452, 6371, 6371, 6371, 6339, 6339, 6371, 6371, 6371, 8452, 8484, 4258, 0, 32, 32, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 32, 4258, 6371, 6371, 6371, 6371, 6371, 8452, 8452, 8452, 8452, 2145, 0, 0, 32, 0, 0, 4226, 6371, 6371, 6339, 6339, 6371, 6371, 6371, 6371, 6371, 2145, 0, 0, 32, 32, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 32, 6339, 6371, 6371, 6371, 6371, 8452, 8484, 8452, 4226, 32, 0, 0, 0, 0, 0, 0, 4226, 6339, 6339, 6339, 6371, 6371, 6371, 6371, 4226, 0, 32, 32, 32, 32, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 2113, 6339, 6371, 6371, 6371, 6371, 8452, 8484, 8484, 4258, 32, 0, 0, 0, 0, 0, 32, 4258, 6339, 6339, 6371, 6371, 6371, 8452, 8452, 4258, 32, 32, 32, 32, 32, 0, 32,
|
||||
0, 0, 0, 32, 0, 0, 2113, 6339, 8484, 8452, 6371, 6371, 8452, 8484, 8484, 8484, 8452, 4226, 0, 0, 0, 0, 32, 6339, 8452, 6371, 6371, 6371, 6371, 6371, 8452, 8452, 8484, 6371, 2113, 32, 32, 32, 32, 32,
|
||||
0, 0, 0, 0, 0, 2113, 6339, 8452, 8484, 8484, 8452, 6371, 8452, 10597, 8452, 8452, 8452, 6371, 4226, 0, 0, 32, 4258, 8452, 8452, 8452, 8452, 6371, 6339, 6371, 6371, 6371, 8484, 8484, 6339, 2113, 0, 32, 32, 32,
|
||||
0, 0, 0, 0, 2113, 6371, 8452, 8452, 8452, 8452, 8452, 8452, 8484, 10597, 8452, 8452, 6371, 8452, 8452, 4258, 2113, 6339, 8452, 8452, 8452, 6371, 8452, 8452, 8452, 8452, 6371, 6371, 8452, 8484, 8484, 6371, 2113, 32, 32, 32,
|
||||
0, 0, 0, 32, 2145, 6339, 8484, 8452, 8452, 8452, 8452, 8452, 8484, 8484, 8452, 8452, 6371, 8452, 8452, 10565, 8484, 8452, 8484, 8452, 8452, 6371, 8452, 8484, 8452, 8484, 8452, 6371, 8484, 8484, 10597, 6371, 6339, 2145, 0, 32,
|
||||
0, 0, 0, 2145, 4226, 2145, 6339, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8452, 8484, 8452, 8452, 8452, 8452, 8452, 6371, 8452, 8452, 8452, 8484, 8484, 8484, 8484, 12678, 6371, 4226, 6371, 4258, 32, 0,
|
||||
0, 32, 2145, 4226, 4226, 2145, 2145, 6339, 8484, 10565, 8452, 8452, 8452, 8452, 8484, 8484, 8452, 8452, 6371, 6371, 6371, 6339, 8452, 8452, 8452, 8452, 6371, 8452, 8484, 8484, 8452, 8484, 10565, 8484, 4258, 4226, 6339, 6339, 2145, 32,
|
||||
2113, 4226, 4258, 4226, 4226, 4226, 2145, 2145, 8452, 8484, 8452, 6371, 8452, 8452, 8484, 8452, 8452, 6371, 6339, 6339, 6339, 6371, 6371, 8452, 8452, 8452, 6371, 6371, 6339, 8452, 8484, 8484, 6371, 4226, 4258, 6339, 4226, 4258, 6339, 4226,
|
||||
2145, 2145, 4226, 4226, 4226, 4226, 2145, 2145, 2145, 10565, 8452, 8452, 8452, 6371, 8452, 8452, 8452, 6371, 8452, 6371, 6339, 6371, 6371, 6371, 8452, 6371, 6371, 6339, 6339, 6371, 6371, 6339, 4226, 4258, 4226, 6339, 6339, 4258, 6339, 4226,
|
||||
2145, 2145, 2113, 4226, 4226, 4226, 4226, 4226, 2145, 4226, 6339, 6371, 6371, 8452, 8452, 8452, 8452, 8452, 6371, 6371, 6371, 6339, 8452, 8452, 8452, 8452, 8452, 8452, 6371, 6371, 4258, 2145, 4226, 4258, 6339, 4258, 4258, 4226, 4226, 4258,
|
||||
2145, 2145, 2145, 2145, 2145, 4226, 4226, 4226, 4226, 2145, 2145, 6371, 8484, 8452, 8452, 8452, 8452, 8452, 8452, 6371, 6371, 6371, 8452, 8484, 8452, 8452, 8452, 8484, 8484, 6339, 2145, 2145, 4226, 4226, 4258, 6339, 4226, 2145, 4226, 4226,
|
||||
2145, 2145, 4226, 4226, 4226, 4258, 4226, 4258, 4258, 4226, 2145, 4226, 6371, 8452, 8452, 6371, 8452, 8452, 8452, 8452, 6339, 8452, 8452, 8452, 8484, 10565, 8452, 8484, 6371, 4226, 4226, 4258, 6339, 6339, 6339, 6339, 4226, 2145, 2145, 4226,
|
||||
2145, 2145, 2145, 4226, 4226, 6339, 6339, 6339, 4226, 4226, 4226, 2145, 4258, 6339, 8452, 8452, 8452, 8452, 8484, 4258, 2113, 6339, 8452, 8452, 8452, 8484, 8452, 6339, 4258, 4226, 6339, 6339, 6339, 6339, 6339, 6339, 4226, 2145, 2145, 4258,
|
||||
2145, 4226, 4226, 4226, 4258, 4226, 6371, 6339, 4226, 4226, 4226, 4226, 2145, 4226, 6339, 8452, 8452, 8452, 4258, 32, 0, 2113, 6339, 8484, 10565, 8484, 6339, 4226, 4258, 6339, 6339, 6339, 6339, 4258, 4226, 2145, 4258, 4226, 4226, 4258,
|
||||
2145, 4226, 4258, 4258, 4226, 4226, 4226, 4258, 6339, 4258, 4226, 2145, 2145, 2145, 4226, 6371, 8452, 4226, 32, 0, 0, 0, 32, 6371, 10565, 8452, 4226, 4226, 4258, 4258, 6339, 6339, 6371, 4226, 2145, 4226, 4226, 4226, 4258, 4226,
|
||||
32, 2113, 6339, 4258, 4258, 4226, 4226, 4226, 4258, 4258, 4226, 4226, 4226, 4226, 4226, 4226, 4226, 32, 0, 0, 0, 0, 0, 2113, 8452, 6339, 4258, 4226, 4226, 4226, 4258, 6339, 4258, 4258, 4226, 4258, 6339, 4258, 4226, 2113,
|
||||
0, 0, 2113, 4258, 4258, 4258, 4258, 4226, 2145, 2145, 4226, 4226, 4226, 4258, 4258, 2113, 32, 32, 32, 32, 32, 0, 32, 2113, 2145, 4258, 6371, 6339, 4258, 6339, 4258, 4226, 4258, 8484, 6371, 8452, 8484, 6339, 2113, 0,
|
||||
0, 0, 0, 2113, 6339, 6339, 4258, 4226, 2145, 2145, 2145, 4226, 6339, 4258, 2145, 32, 32, 32, 32, 32, 0, 0, 32, 32, 2113, 2145, 6339, 8452, 8452, 4258, 4226, 4258, 6339, 8484, 10565, 10597, 8452, 2145, 32, 0,
|
||||
0, 0, 0, 0, 4258, 6371, 6339, 4226, 4226, 2145, 2145, 4226, 4258, 4226, 32, 0, 32, 32, 32, 32, 0, 32, 0, 32, 32, 32, 2145, 8452, 8452, 4258, 4226, 4226, 4258, 8484, 8452, 8484, 4226, 0, 0, 0,
|
||||
0, 0, 0, 0, 32, 4226, 4258, 6339, 4226, 4226, 4226, 4226, 2145, 32, 32, 0, 0, 32, 32, 32, 0, 0, 0, 0, 32, 2113, 2113, 2145, 4226, 4226, 4226, 4226, 6339, 6371, 4226, 2145, 32, 0, 0, 0,
|
||||
};
|
||||
#endif /*COLOR_DEPTH == 16*/
|
||||
|
||||
#if COLOR_DEPTH == 24
|
||||
static const color_int_t img_benchmark_bg[] = {
|
||||
/*HEADER
|
||||
Width = 40
|
||||
Height = 40
|
||||
Transp: 0
|
||||
Color depth: 24*/
|
||||
100827176,
|
||||
|
||||
/*IMAGE DATA*/
|
||||
|
||||
263172, 460551, 460551, 526344, 723723, 1447446, 1644825, 1447446, 1447446, 1052688, 1052688, 921102, 1052688, 723723, 263172, 197379, 131586, 65793, 65793, 0, 65793, 0, 65793, 65793, 65793, 65793, 65793, 328965, 789516, 855309, 1250067, 1052688, 1052688, 1184274, 1184274, 986895, 394758, 394758, 394758, 328965,
|
||||
131586, 460551, 526344, 394758, 1776411, 2631720, 2105376, 1447446, 1250067, 1052688, 855309, 1052688, 1579032, 1250067, 460551, 65793, 65793, 65793, 65793, 65793, 0, 65793, 65793, 0, 0, 0, 328965, 986895, 1184274, 789516, 921102, 1250067, 1052688, 1052688, 1842204, 1644825, 1052688, 328965, 263172, 328965,
|
||||
394758, 460551, 526344, 1052688, 2434341, 2434341, 2236962, 1907997, 1052688, 855309, 1052688, 1315860, 1381653, 1447446, 855309, 263172, 0, 0, 131586, 131586, 131586, 131586, 131586, 65793, 0, 263172, 855309, 1052688, 1052688, 1052688, 1118481, 921102, 986895, 1052688, 1579032, 1513239, 1513239, 1118481, 394758, 328965,
|
||||
263172, 460551, 1447446, 1842204, 2171169, 1973790, 1973790, 1776411, 1052688, 986895, 1184274, 1250067, 921102, 1118481, 1118481, 723723, 263172, 0, 65793, 131586, 197379, 263172, 131586, 131586, 328965, 657930, 921102, 855309, 921102, 1052688, 1052688, 1052688, 855309, 1250067, 1579032, 1250067, 1842204, 1710618, 986895, 263172,
|
||||
657930, 921102, 1842204, 1776411, 1250067, 1118481, 1052688, 1118481, 1315860, 1381653, 1052688, 855309, 1052688, 855309, 921102, 1184274, 1381653, 394758, 65793, 131586, 131586, 131586, 65793, 526344, 1579032, 1052688, 723723, 789516, 855309, 921102, 1052688, 1184274, 1315860, 1052688, 1315860, 1447446, 1513239, 1710618, 1644825, 855309,
|
||||
1052688, 1315860, 1710618, 1250067, 1052688, 986895, 921102, 921102, 1052688, 1052688, 1184274, 855309, 855309, 921102, 1052688, 1776411, 2302755, 1644825, 394758, 0, 131586, 131586, 657930, 1776411, 1907997, 1710618, 855309, 723723, 855309, 986895, 1052688, 1052688, 1184274, 1184274, 1052688, 1184274, 1250067, 1513239, 1447446, 1184274,
|
||||
1184274, 1052688, 986895, 1052688, 921102, 986895, 1184274, 1052688, 921102, 1052688, 1052688, 1052688, 986895, 1118481, 1907997, 1907997, 1973790, 2171169, 1513239, 394758, 65793, 657930, 1973790, 1973790, 1842204, 1776411, 1579032, 855309, 789516, 1052688, 986895, 986895, 986895, 1250067, 1315860, 1118481, 1250067, 1118481, 986895, 1118481,
|
||||
1250067, 986895, 1052688, 855309, 986895, 1250067, 1184274, 1052688, 1052688, 1052688, 986895, 921102, 1315860, 1973790, 2105376, 1842204, 1842204, 1973790, 2171169, 1579032, 789516, 1710618, 2105376, 1973790, 1776411, 1907997, 1973790, 1710618, 1118481, 855309, 855309, 855309, 921102, 986895, 1315860, 1381653, 986895, 855309, 789516, 986895,
|
||||
1250067, 855309, 1052688, 657930, 986895, 1118481, 1315860, 1118481, 986895, 986895, 855309, 1381653, 1907997, 2105376, 1842204, 1776411, 1842204, 1907997, 2105376, 2171169, 1776411, 2105376, 2236962, 2105376, 1842204, 1973790, 2171169, 2236962, 1776411, 1052688, 855309, 986895, 921102, 921102, 1118481, 1513239, 921102, 657930, 921102, 855309,
|
||||
986895, 855309, 657930, 855309, 1052688, 1118481, 1118481, 986895, 855309, 657930, 1052688, 1776411, 1907997, 1907997, 1973790, 1907997, 1907997, 2171169, 1973790, 2236962, 2171169, 1973790, 2105376, 2105376, 1776411, 1973790, 2236962, 2236962, 2302755, 1842204, 1118481, 855309, 1052688, 1052688, 1052688, 1184274, 1118481, 1052688, 921102, 1052688,
|
||||
1250067, 1250067, 855309, 1052688, 1052688, 986895, 1052688, 855309, 657930, 855309, 1710618, 1907997, 1907997, 2105376, 2171169, 2302755, 2368548, 2105376, 1973790, 1907997, 1842204, 1842204, 1907997, 1907997, 1842204, 1907997, 1973790, 1973790, 2171169, 2302755, 1776411, 855309, 855309, 1052688, 1052688, 986895, 1184274, 1184274, 855309, 1052688,
|
||||
986895, 1052688, 1315860, 855309, 855309, 855309, 723723, 789516, 1052688, 1710618, 1973790, 1842204, 1973790, 2302755, 2434341, 2434341, 2302755, 1973790, 1842204, 1842204, 1842204, 1973790, 1907997, 2236962, 1907997, 1776411, 1907997, 1907997, 1973790, 2105376, 2236962, 1776411, 1052688, 855309, 855309, 1184274, 1052688, 986895, 1184274, 986895,
|
||||
328965, 657930, 1052688, 1052688, 855309, 855309, 723723, 921102, 2105376, 2236962, 1907997, 1973790, 1710618, 2368548, 2434341, 2434341, 2368548, 2236962, 1842204, 1710618, 1842204, 1842204, 1907997, 1973790, 1907997, 1842204, 1776411, 1710618, 1776411, 1776411, 2171169, 2368548, 1907997, 855309, 986895, 1052688, 986895, 1118481, 1052688, 723723,
|
||||
131586, 131586, 855309, 1118481, 1052688, 1118481, 1447446, 1907997, 1842204, 2105376, 1907997, 1776411, 1776411, 2171169, 2500134, 2171169, 2171169, 2236962, 1907997, 1907997, 2105376, 2105376, 2171169, 1973790, 1842204, 1776411, 1842204, 1776411, 1842204, 1842204, 2171169, 2105376, 2434341, 2105376, 1118481, 1052688, 1381653, 1315860, 657930, 328965,
|
||||
65793, 131586, 263172, 657930, 855309, 1579032, 2236962, 2171169, 1776411, 1776411, 2105376, 1842204, 1776411, 1973790, 2631720, 2434341, 2302755, 2368548, 2105376, 1842204, 1776411, 2236962, 2171169, 1842204, 1842204, 1776411, 1842204, 1842204, 1842204, 2105376, 2105376, 2105376, 2500134, 2631720, 1907997, 1381653, 1052688, 789516, 263172, 197379,
|
||||
65793, 131586, 131586, 131586, 526344, 1644825, 2105376, 1842204, 1907997, 1776411, 1907997, 2105376, 1842204, 1973790, 2105376, 2368548, 2236962, 2302755, 2368548, 2171169, 1513239, 2105376, 2171169, 1776411, 1644825, 1710618, 1644825, 1842204, 1973790, 1973790, 1842204, 2105376, 2236962, 2236962, 2565927, 2105376, 657930, 131586, 131586, 328965,
|
||||
65793, 131586, 197379, 131586, 197379, 1315860, 1973790, 1973790, 1907997, 1907997, 1907997, 1842204, 1842204, 1973790, 2171169, 2236962, 2302755, 2434341, 2302755, 855309, 263172, 1184274, 1842204, 1973790, 1842204, 1710618, 1907997, 1842204, 1842204, 1973790, 1973790, 1842204, 2105376, 2302755, 2105376, 1184274, 328965, 197379, 131586, 263172,
|
||||
65793, 131586, 131586, 65793, 0, 197379, 1250067, 2105376, 1973790, 1907997, 1973790, 1776411, 1842204, 2236962, 2171169, 2105376, 2500134, 2171169, 789516, 131586, 197379, 197379, 1184274, 2171169, 1907997, 1907997, 1842204, 1710618, 1710618, 1842204, 1907997, 1842204, 2171169, 2368548, 1315860, 65793, 263172, 394758, 263172, 197379,
|
||||
65793, 131586, 131586, 131586, 65793, 0, 263172, 1315860, 1907997, 1907997, 1842204, 1907997, 1973790, 2302755, 2302755, 2236962, 2171169, 855309, 131586, 131586, 263172, 131586, 197379, 1052688, 1973790, 1907997, 1710618, 1710618, 1907997, 1842204, 1907997, 1973790, 1973790, 986895, 131586, 197379, 394758, 394758, 263172, 131586,
|
||||
65793, 197379, 65793, 131586, 131586, 131586, 65793, 394758, 1579032, 1907997, 1907997, 1907997, 1973790, 2171169, 2565927, 2171169, 1118481, 263172, 131586, 197379, 197379, 131586, 131586, 197379, 1118481, 1776411, 1776411, 1776411, 1842204, 1907997, 1973790, 1973790, 1052688, 131586, 263172, 328965, 394758, 328965, 197379, 197379,
|
||||
131586, 131586, 131586, 197379, 131586, 131586, 131586, 592137, 1644825, 1973790, 1842204, 1973790, 1973790, 2236962, 2500134, 2368548, 1447446, 263172, 65793, 197379, 197379, 131586, 131586, 394758, 1447446, 1776411, 1776411, 1842204, 1907997, 1973790, 2105376, 2171169, 1513239, 394758, 328965, 460551, 460551, 328965, 197379, 263172,
|
||||
197379, 197379, 197379, 328965, 197379, 131586, 592137, 1710618, 2368548, 2302755, 1907997, 1907997, 2236962, 2434341, 2368548, 2434341, 2236962, 1052688, 131586, 65793, 197379, 131586, 328965, 1579032, 2302755, 1973790, 1842204, 1842204, 1842204, 1907997, 2105376, 2302755, 2500134, 1907997, 657930, 394758, 394758, 394758, 394758, 328965,
|
||||
131586, 131586, 131586, 197379, 131586, 526344, 1776411, 2302755, 2434341, 2368548, 2171169, 1842204, 2302755, 2894892, 2302755, 2236962, 2171169, 1907997, 1118481, 197379, 131586, 394758, 1513239, 2236962, 2171169, 2105376, 2105376, 1842204, 1710618, 1842204, 1907997, 1907997, 2368548, 2565927, 1644825, 592137, 197379, 394758, 328965, 328965,
|
||||
65793, 131586, 131586, 65793, 526344, 1842204, 2302755, 2236962, 2302755, 2302755, 2105376, 2105376, 2434341, 2894892, 2302755, 2105376, 1973790, 2105376, 2105376, 1381653, 592137, 1644825, 2236962, 2302755, 2105376, 1973790, 2171169, 2171169, 2105376, 2105376, 1973790, 1973790, 2171169, 2565927, 2565927, 1973790, 657930, 460551, 460551, 263172,
|
||||
0, 65793, 65793, 263172, 855309, 1776411, 2434341, 2105376, 2236962, 2105376, 2302755, 2302755, 2368548, 2368548, 2105376, 2105376, 1973790, 2171169, 2302755, 2829099, 2565927, 2302755, 2500134, 2105376, 2105376, 1842204, 2171169, 2368548, 2302755, 2368548, 2171169, 1907997, 2368548, 2500134, 2894892, 1842204, 1579032, 789516, 197379, 263172,
|
||||
0, 0, 197379, 789516, 1052688, 921102, 1710618, 2302755, 2105376, 2171169, 2302755, 2236962, 2105376, 2105376, 2302755, 2171169, 2171169, 2302755, 2105376, 2434341, 2302755, 2171169, 2302755, 2105376, 2105376, 1973790, 2105376, 2302755, 2302755, 2368548, 2434341, 2368548, 2500134, 3158064, 1973790, 1118481, 1907997, 1315860, 328965, 131586,
|
||||
65793, 263172, 986895, 1184274, 1052688, 855309, 921102, 1644825, 2368548, 2631720, 2302755, 2236962, 2171169, 2302755, 2565927, 2368548, 2105376, 2105376, 1907997, 1907997, 1973790, 1776411, 2105376, 2171169, 2171169, 2105376, 1907997, 2302755, 2500134, 2434341, 2236962, 2434341, 2829099, 2434341, 1513239, 1184274, 1644825, 1776411, 921102, 394758,
|
||||
657930, 1052688, 1381653, 1184274, 1052688, 1052688, 855309, 855309, 2105376, 2368548, 2105376, 1973790, 2171169, 2302755, 2565927, 2302755, 2171169, 1907997, 1776411, 1710618, 1776411, 1973790, 1842204, 2105376, 2236962, 2105376, 1907997, 1842204, 1776411, 2236962, 2368548, 2500134, 1973790, 1184274, 1513239, 1710618, 1250067, 1381653, 1776411, 1118481,
|
||||
855309, 921102, 1118481, 1118481, 1184274, 1052688, 986895, 855309, 855309, 2631720, 2105376, 2105376, 2105376, 1973790, 2236962, 2302755, 2105376, 1907997, 2171169, 1907997, 1710618, 1842204, 1842204, 1842204, 2236962, 1842204, 1842204, 1710618, 1776411, 1842204, 1842204, 1579032, 1118481, 1513239, 1250067, 1579032, 1579032, 1513239, 1644825, 1052688,
|
||||
986895, 855309, 723723, 1052688, 1052688, 1052688, 1250067, 1052688, 986895, 1052688, 1644825, 1907997, 1973790, 2302755, 2236962, 2236962, 2236962, 2236962, 1973790, 1907997, 1907997, 1710618, 2105376, 2302755, 2105376, 2105376, 2105376, 2105376, 1973790, 1973790, 1315860, 789516, 1118481, 1513239, 1579032, 1381653, 1513239, 1118481, 1052688, 1315860,
|
||||
855309, 855309, 855309, 855309, 986895, 1184274, 1052688, 1118481, 1052688, 921102, 855309, 1842204, 2368548, 2302755, 2236962, 2105376, 2105376, 2236962, 2171169, 1973790, 1907997, 1842204, 2105376, 2434341, 2236962, 2171169, 2302755, 2434341, 2500134, 1776411, 986895, 855309, 1118481, 1250067, 1513239, 1776411, 1184274, 855309, 1052688, 1118481,
|
||||
855309, 789516, 1052688, 1052688, 1052688, 1381653, 1250067, 1315860, 1447446, 1052688, 855309, 1052688, 1973790, 2302755, 2105376, 1973790, 2105376, 2171169, 2302755, 2171169, 1710618, 2105376, 2171169, 2171169, 2500134, 2631720, 2105376, 2434341, 1907997, 1052688, 1118481, 1513239, 1579032, 1579032, 1776411, 1776411, 1184274, 789516, 986895, 1184274,
|
||||
986895, 855309, 789516, 1052688, 1250067, 1644825, 1776411, 1579032, 1184274, 1052688, 1052688, 986895, 1315860, 1776411, 2171169, 2171169, 2105376, 2302755, 2368548, 1315860, 592137, 1710618, 2236962, 2236962, 2171169, 2500134, 2171169, 1710618, 1315860, 1184274, 1644825, 1776411, 1776411, 1776411, 1644825, 1579032, 1184274, 921102, 855309, 1315860,
|
||||
921102, 1052688, 1052688, 1184274, 1315860, 1250067, 1842204, 1776411, 1250067, 1184274, 1118481, 1052688, 986895, 1052688, 1710618, 2302755, 2302755, 2302755, 1315860, 263172, 65793, 526344, 1644825, 2368548, 2631720, 2434341, 1644825, 1052688, 1315860, 1644825, 1579032, 1710618, 1579032, 1447446, 1052688, 921102, 1315860, 1118481, 1118481, 1315860,
|
||||
855309, 1184274, 1513239, 1315860, 1052688, 1118481, 1184274, 1513239, 1579032, 1381653, 1118481, 986895, 986895, 986895, 1052688, 1907997, 2302755, 1184274, 263172, 131586, 131586, 131586, 460551, 1973790, 2829099, 2171169, 1052688, 1184274, 1315860, 1381653, 1644825, 1644825, 1842204, 1250067, 986895, 1184274, 1052688, 1250067, 1513239, 1250067,
|
||||
394758, 657930, 1644825, 1381653, 1315860, 1184274, 1184274, 1184274, 1315860, 1381653, 1052688, 1052688, 1052688, 1184274, 1118481, 1118481, 1052688, 328965, 131586, 197379, 131586, 131586, 197379, 592137, 2105376, 1710618, 1447446, 1184274, 1052688, 1250067, 1447446, 1579032, 1513239, 1513239, 1250067, 1513239, 1579032, 1513239, 1118481, 592137,
|
||||
197379, 197379, 657930, 1381653, 1513239, 1315860, 1315860, 1250067, 789516, 855309, 1250067, 1250067, 1052688, 1513239, 1315860, 657930, 328965, 328965, 328965, 263172, 263172, 197379, 328965, 526344, 855309, 1513239, 1973790, 1710618, 1315860, 1579032, 1381653, 1184274, 1447446, 2368548, 1907997, 2105376, 2500134, 1644825, 657930, 131586,
|
||||
197379, 131586, 131586, 657930, 1710618, 1776411, 1447446, 1052688, 855309, 855309, 921102, 1118481, 1579032, 1447446, 855309, 328965, 328965, 394758, 328965, 263172, 131586, 197379, 263172, 460551, 657930, 789516, 1710618, 2236962, 2105376, 1447446, 1250067, 1381653, 1776411, 2368548, 2631720, 3026478, 2236962, 789516, 263172, 131586,
|
||||
197379, 197379, 131586, 197379, 1381653, 1973790, 1579032, 1184274, 1052688, 921102, 855309, 1052688, 1447446, 1052688, 328965, 131586, 328965, 460551, 460551, 328965, 131586, 263172, 197379, 328965, 460551, 460551, 921102, 2236962, 2105376, 1447446, 1118481, 1250067, 1513239, 2434341, 2302755, 2565927, 1052688, 131586, 131586, 131586,
|
||||
197379, 131586, 131586, 131586, 328965, 1052688, 1447446, 1644825, 1250067, 1052688, 1184274, 1052688, 855309, 394758, 263172, 197379, 131586, 263172, 328965, 263172, 197379, 131586, 197379, 197379, 263172, 592137, 657930, 921102, 1118481, 1250067, 1118481, 1118481, 1710618, 1973790, 1250067, 855309, 263172, 131586, 197379, 131586,
|
||||
};
|
||||
#endif /*COLOR_DEPTH == 24*/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_benchmark.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_BENCHMARK_H
|
||||
#define LV_APP_BENCHMARK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_benchmark_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_benchmark_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_BENCHMARK != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_BENCHMARK_H */
|
||||
@@ -1,227 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_ethernet.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_ethernet.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_ETHERNET != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "hal/eth/eth.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ETH_MONITOR_PERIOD 1000 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t * last_msg_dp;
|
||||
uint16_t last_msg_size;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void eth_state_monitor_task(void * param);
|
||||
static void tcp_transf_cb(eth_state_t state, const char * txt);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Ethernet",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_app_inst_t * app_act_com = NULL;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_ethernet_init(void)
|
||||
{
|
||||
ptask_create(eth_state_monitor_task, ETH_MONITOR_PERIOD, PTASK_PRIO_LOW, NULL);
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_ethernet_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
eth_tcp_transf(data, size, tcp_transf_cb);
|
||||
app_act_com = app_rec;
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
if(adata->last_msg_dp != NULL) dm_free(adata->last_msg_dp);
|
||||
|
||||
adata->last_msg_dp = dm_alloc(size);
|
||||
memcpy(adata->last_msg_dp, data, size);
|
||||
adata->last_msg_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void eth_state_monitor_task(void * param)
|
||||
{
|
||||
/* The eth. should be busy if there is sg. to send.
|
||||
* It means fail during last send. Try again*/
|
||||
if(app_act_com != NULL && eth_busy() == false) {
|
||||
/*Try to send the message again*/
|
||||
lv_app_notice_add("Resend Ethernet message");
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
eth_tcp_transf(adata->last_msg_dp, adata->last_msg_size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_transf_cb(eth_state_t state, const char * txt)
|
||||
{
|
||||
if(state == ETH_STATE_OK) {
|
||||
uint16_t size = txt[0] + ((txt[1] << 8) & 0xFF00);
|
||||
char buf[256];
|
||||
memcpy(buf, &txt[2], size);
|
||||
buf[size] = '\0';
|
||||
lv_app_com_send(app_act_com, LV_APP_COM_TYPE_CHAR, &txt[2], size);
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
dm_free(adata->last_msg_dp);
|
||||
adata->last_msg_dp = NULL;
|
||||
adata->last_msg_size = 0;
|
||||
app_act_com = NULL;
|
||||
}else if(state == ETH_STATE_ERROR) {
|
||||
lv_app_notice_add("Ethernet TCP transfer error\n%s", txt);
|
||||
}
|
||||
|
||||
}
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_ETHERNET != 0*/
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_ethernet.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_ETHERNET_H
|
||||
#define LV_APP_ETHERNET_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_ETHERNET != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_ethernet_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_ethernet_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_ETHERNET != 0*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_ETHERNET_H */
|
||||
@@ -1,216 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_example.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static void kb_ok_action(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Example",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_example_init(void)
|
||||
{
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
my_sc_data_t * sc_data = app_rec->sc_data;
|
||||
if (sc_data->label != NULL) {
|
||||
lv_label_set_text_array(sc_data->label, data, size);
|
||||
lv_obj_align(sc_data->label , NULL,LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
lv_obj_t * ta;
|
||||
ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size_us(ta, 200, 100);
|
||||
lv_obj_set_pos_us(ta, 0, 0);
|
||||
lv_obj_set_free_p(ta, app);
|
||||
lv_page_set_rel_action(ta, ta_rel_action);
|
||||
lv_ta_set_text(ta, "Write a text to send to the other applications");
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called when the text area on the window is released to open the app. keyboard
|
||||
* @param ta pointer to the text area on the window
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the text area is not deleted
|
||||
*/
|
||||
static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_ta_set_text(ta, ""); /*Clear the ta*/
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, kb_ok_action);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the "Ok" button is pressed on the app. keyboard
|
||||
* @param ta pointer to the text area assigned to the app. kexboard
|
||||
*/
|
||||
static void kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
const char * txt = lv_ta_get_txt(ta);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, txt, strlen(txt));
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_EXAMPLE_H
|
||||
#define LV_APP_EXAMPLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_example_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_example_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
@@ -1,897 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_files.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "misc/os/ptask.h"
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "../lv_app/lv_app_util/lv_app_notice.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_APP_FILES_CHUNK_MIN_SIZE 32
|
||||
#define LV_APP_FILES_CHUNK_MIN_TIME 10
|
||||
#define LV_APP_FILES_CHUNK_MAX_TIME 10000
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char path[LV_APP_FILES_PATH_MAX_LEN];
|
||||
char fn[LV_APP_FILES_FN_MAX_LEN];
|
||||
fs_file_t file;
|
||||
uint8_t file_cnt;
|
||||
uint16_t chunk_delay;
|
||||
uint16_t chunk_size;
|
||||
uint8_t send_fn :1;
|
||||
uint8_t send_size :1;
|
||||
uint8_t send_crc :1;
|
||||
uint8_t send_in_prog :1;
|
||||
ptask_t * send_task;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * file_list;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SEND_SETTINGS_FN,
|
||||
SEND_SETTINGS_SIZE,
|
||||
SEND_SETTINGS_CRC,
|
||||
SEND_SETTINGS_CHUNK_SIZE,
|
||||
SEND_SETTINGS_CHUNK_DELAY,
|
||||
}send_settings_id_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win);
|
||||
|
||||
static void win_load_file_list(lv_app_inst_t * app);
|
||||
static void win_create_list(lv_app_inst_t * app);
|
||||
static lv_action_res_t win_up_action(lv_obj_t * up, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_next_action(lv_obj_t * next, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_prev_action(lv_obj_t * prev, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_drv_action(lv_obj_t * drv, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_folder_action(lv_obj_t * folder, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_file_action(lv_obj_t * file, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_send_rel_action(lv_obj_t * send, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_send_settings_element_rel_action(lv_obj_t * element, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_back_action(lv_obj_t * back, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_del_rel_action(lv_obj_t * del, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_del_lpr_action(lv_obj_t * del, lv_dispi_t * dispi);
|
||||
static void send_settings_kb_close_action(lv_obj_t * ta);
|
||||
static void send_settings_kb_ok_action(lv_obj_t * ta);
|
||||
static void start_send(lv_app_inst_t * app, const char * path);
|
||||
static void send_task(void * param);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Files",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.conf_open = my_conf_open,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_style_t style_sc_label;
|
||||
static lv_style_t style_btn_symbol;
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_files_init(void)
|
||||
{
|
||||
lv_app_style_t * app_style = lv_app_style_get();
|
||||
memcpy(&style_sc_label, &app_style->sc_rec_rel, sizeof(lv_style_t));
|
||||
style_sc_label.font = font_get(LV_APP_FONT_LARGE);
|
||||
|
||||
lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol);
|
||||
style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
app_data->file_cnt = 0;
|
||||
app_data->path[0] = '\0';
|
||||
app_data->fn[0] = '\0';
|
||||
app_data->send_fn = 0;
|
||||
app_data->send_size = 0;
|
||||
app_data->send_crc = 0;
|
||||
app_data->chunk_size = LV_APP_FILES_CHUNK_DEF_SIZE;
|
||||
app_data->chunk_delay = LV_APP_FILES_CHUNK_DEF_TIME;
|
||||
app_data->send_in_prog = 0;
|
||||
|
||||
app_data->send_task = ptask_create(send_task, LV_APP_FILES_CHUNK_DEF_TIME, PTASK_PRIO_OFF, app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
ptask_del(app_data->send_task);
|
||||
if(app_data->send_in_prog != 0) fs_close(&app_data->file);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) {
|
||||
/*Check for file query. E.g. "U:/file.txt?"*/
|
||||
const char * path = data;
|
||||
if(path[size - 1] == '?') {
|
||||
if(size > LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN) {
|
||||
lv_app_notice_add("Can not send file:\ntoo long path");
|
||||
}
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
memcpy(path_fn, data, size - 1); /*-1 to ignore the '?' at the end*/
|
||||
path_fn[size - 1] = '\0';
|
||||
start_send(app_rec, path_fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_obj_set_style(sc_data->label, &style_sc_label);
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->file_cnt = 0;
|
||||
win_data->file_list = NULL;
|
||||
|
||||
lv_win_set_title(win, app_data->path);
|
||||
|
||||
win_load_file_list(app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create objects to configure the applications
|
||||
* @param app pointer to an application which settings should be created
|
||||
* @param conf_win pointer to a window where the objects can be created
|
||||
* (the window has the proper layout)
|
||||
*/
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Create check boxes*/
|
||||
lv_obj_t * cb;
|
||||
|
||||
/*Send file name check box*/
|
||||
cb = lv_cb_create(conf_win, NULL);
|
||||
lv_cb_set_text(cb, "Send file name");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_FN);
|
||||
lv_obj_set_free_p(cb, app);
|
||||
lv_btn_set_rel_action(cb, win_send_settings_element_rel_action);
|
||||
if(app_data->send_fn != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Send size check box*/
|
||||
cb = lv_cb_create(conf_win, cb);
|
||||
lv_cb_set_text(cb, "Send size");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_SIZE);
|
||||
if(app_data->send_size != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Send CRC check box*/
|
||||
cb = lv_cb_create(conf_win, cb);
|
||||
lv_cb_set_text(cb, "Send CRC");
|
||||
lv_obj_set_free_num(cb, SEND_SETTINGS_CRC);
|
||||
if(app_data->send_crc != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
|
||||
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
|
||||
|
||||
/*Create a text area to type chunk size*/
|
||||
lv_obj_t * val_set_h;
|
||||
val_set_h = lv_cont_create(conf_win, NULL);
|
||||
lv_obj_set_style(val_set_h, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
|
||||
lv_obj_set_click(val_set_h, false);
|
||||
lv_cont_set_fit(val_set_h, true, true);
|
||||
lv_cont_set_layout(val_set_h, LV_CONT_LAYOUT_ROW_M);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
lv_label_set_text(label, "Chunk size");
|
||||
|
||||
lv_obj_t * ta;
|
||||
char buf[32];
|
||||
ta = lv_ta_create(val_set_h, NULL);
|
||||
lv_cont_set_fit(ta, false, true);
|
||||
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_SIZE);
|
||||
lv_obj_set_free_p(ta, app);
|
||||
lv_page_set_rel_action(ta, win_send_settings_element_rel_action);
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
lv_ta_set_text(ta, buf);
|
||||
|
||||
/*Create a text area to type the chunk delay*/
|
||||
val_set_h = lv_cont_create(conf_win, val_set_h);
|
||||
|
||||
label = lv_label_create(val_set_h, NULL);
|
||||
lv_label_set_text(label, "Inter-chunk delay");
|
||||
|
||||
ta = lv_ta_create(val_set_h, ta);
|
||||
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_DELAY);
|
||||
sprintf(buf, "%d", app_data->chunk_delay);
|
||||
lv_ta_set_text(ta, buf);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
/**
|
||||
* Create an mpty list on the window. 'win_load_file_list' will fill it.
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void win_create_list(lv_app_inst_t * app)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Delete the previous list*/
|
||||
if(win_data->file_list != NULL) {
|
||||
lv_obj_del(win_data->file_list);
|
||||
}
|
||||
|
||||
/*Create a new list*/
|
||||
win_data->file_list = lv_list_create(app->win, NULL);
|
||||
lv_obj_set_width(win_data->file_list, lv_win_get_width(app->win));
|
||||
lv_list_set_style_img(win_data->file_list, &style_btn_symbol);
|
||||
lv_obj_set_style(lv_page_get_scrl(win_data->file_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_drag_parent(win_data->file_list, true);
|
||||
lv_obj_set_drag_parent(lv_page_get_scrl(win_data->file_list), true);
|
||||
lv_cont_set_fit(win_data->file_list, false, true);
|
||||
lv_cont_set_layout(lv_page_get_scrl(win_data->file_list), LV_CONT_LAYOUT_COL_L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the file list from the current path on the window
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void win_load_file_list(lv_app_inst_t * app)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Create a new list*/
|
||||
win_create_list(app);
|
||||
|
||||
fs_res_t res = FS_RES_OK;
|
||||
|
||||
/*At empty path show the drivers */
|
||||
lv_obj_t * liste;
|
||||
if(app_data->path[0] == '\0') {
|
||||
char drv[16];
|
||||
char buf[2];
|
||||
fs_get_letters(drv);
|
||||
uint8_t i;
|
||||
for(i = 0; drv[i] != '\0'; i++) {
|
||||
buf[0] = drv[i];
|
||||
buf[1] = '\0';
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_DRIVE, buf, win_drv_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
}
|
||||
}
|
||||
/*List the files/folders with fs interface*/
|
||||
else {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_UP, "Up", win_up_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
fs_readdir_t rd;
|
||||
res = fs_readdir_init(&rd, app_data->path);
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read the\npath in Files");
|
||||
return;
|
||||
}
|
||||
|
||||
/*At not first page add prev. page button */
|
||||
if(app_data->file_cnt != 0) {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_LEFT, "Previous page", win_prev_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
}
|
||||
|
||||
char fn[LV_APP_FILES_FN_MAX_LEN];
|
||||
|
||||
/*Read the files from the previous pages*/
|
||||
uint16_t file_cnt = 0;
|
||||
while(file_cnt <= app_data->file_cnt) {
|
||||
res = fs_readdir(&rd, fn);
|
||||
if(res != FS_RES_OK ){
|
||||
lv_app_notice_add("Can not read\nthe path in Files");
|
||||
return;
|
||||
}
|
||||
file_cnt ++;
|
||||
}
|
||||
|
||||
/*Add list elements from the files and folders*/
|
||||
while(res == FS_RES_OK && fn[0] != '\0') {
|
||||
if(fn[0] == '/') { /*Add a folder*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_FOLDER, &fn[1], win_folder_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
app_data->file_cnt ++;
|
||||
}
|
||||
/*Add a file*/
|
||||
else {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_FILE, fn, win_file_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
app_data->file_cnt ++;
|
||||
}
|
||||
|
||||
/*Get the next element*/
|
||||
res = fs_readdir(&rd, fn);
|
||||
|
||||
/*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/
|
||||
if(app_data->file_cnt != 0 && app_data->file_cnt % LV_APP_FILES_PAGE_SIZE == 0) {
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_RIGHT, "Next page", win_next_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*Close the read directory*/
|
||||
fs_readdir_close(&rd);
|
||||
}
|
||||
|
||||
if(res != FS_RES_OK) {
|
||||
lv_app_notice_add("Can not read\nthe path in Files");
|
||||
}
|
||||
|
||||
/*Focus to the top of the list*/
|
||||
lv_obj_set_y(lv_page_get_scrl(win_data->file_list), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Up list element is released to step one level
|
||||
* @param up pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_up_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(up);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
fs_up(app_data->path);
|
||||
app_data->file_cnt = 0;
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Next list element is released to go to the next page
|
||||
* @param next pointer to the Next button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_next_action(lv_obj_t * next, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(next);
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Prev list element is released to previous page
|
||||
* @param prev pointer to the Prev button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_prev_action(lv_obj_t * prev, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(prev);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
if(app_data->file_cnt <= 2 * LV_APP_FILES_PAGE_SIZE) app_data->file_cnt = 0;
|
||||
else if(app_data->file_cnt % LV_APP_FILES_PAGE_SIZE == 0) {
|
||||
app_data->file_cnt -= 2 * LV_APP_FILES_PAGE_SIZE;
|
||||
} else {
|
||||
app_data->file_cnt = ((app_data->file_cnt / LV_APP_FILES_PAGE_SIZE) - 1) * LV_APP_FILES_PAGE_SIZE;
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Driver list element is released to step into a driver
|
||||
* @param drv pointer to the Driver button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_drv_action(lv_obj_t * drv, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(drv);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
sprintf(app_data->path, "%s:", lv_list_get_element_text(drv));
|
||||
app_data->file_cnt = 0;
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a folder list element is released to enter into it
|
||||
* @param folder pointer to a folder button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_folder_action(lv_obj_t * folder, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(folder);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
sprintf(app_data->path, "%s/%s", app_data->path, lv_list_get_element_text(folder));
|
||||
app_data->file_cnt = 0;
|
||||
|
||||
lv_win_set_title(app->win, app_data->path);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a file list element is released to show the list of operation on it
|
||||
* @param file pointer to a file button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_file_action(lv_obj_t * file, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(file);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
sprintf(app_data->fn, "%s", lv_list_get_element_text(file));
|
||||
|
||||
win_create_list(app);
|
||||
|
||||
/*Create the list of operations*/
|
||||
lv_obj_t * liste;
|
||||
liste = lv_list_add(win_data->file_list, SYMBOL_LEFT, "Back", win_back_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
/*Send button*/
|
||||
liste = lv_list_add(win_data->file_list, NULL, "Send", win_send_rel_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
/*Delete button*/
|
||||
liste = lv_list_add(win_data->file_list, NULL, "Delete", win_del_rel_action);
|
||||
lv_btn_set_lpr_action(liste, win_del_lpr_action);
|
||||
lv_obj_set_free_p(liste, app);
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Back list element is released to when a file chosen to
|
||||
* go back to the file list from file operation
|
||||
* @param back pointer to the back button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_INV because the list is deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_back_action(lv_obj_t * up, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(up);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->file_cnt = 0;
|
||||
win_load_file_list(app);
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Send list element is released to send the file
|
||||
* @param sed pointer to the Up button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_send_rel_action(lv_obj_t * send, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(send);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(app_data->send_in_prog != 0) {
|
||||
lv_app_notice_add("File sending\nin progress");
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
sprintf(path_fn, "%s/%s", app_data->path, app_data->fn);
|
||||
start_send(app, path_fn);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send settings element is released
|
||||
* @param element pointer to a chekbox or text area
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_send_settings_element_rel_action(lv_obj_t * element, lv_dispi_t * dispi)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(element);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(element);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(id == SEND_SETTINGS_FN) {
|
||||
app_data->send_fn = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
} else if(id == SEND_SETTINGS_SIZE) {
|
||||
app_data->send_size = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
} else if(id == SEND_SETTINGS_CRC) {
|
||||
app_data->send_crc = lv_btn_get_state(element) == LV_BTN_STATE_REL ? 0 : 1;
|
||||
|
||||
/*TODO CRC sending is not supported yet*/
|
||||
if(app_data->send_crc != 0) {
|
||||
lv_app_notice_add("CRC sending is\nnot supported yet");
|
||||
}
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action);
|
||||
} else if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Delete list element is released.
|
||||
* It will show a notification to long press the Delete button to remove the file
|
||||
* @param del pointer to the back button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_del_rel_action(lv_obj_t * del, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_notice_add("Press long the Delete button\n"
|
||||
"to remove the file");
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
/**
|
||||
* Called when the Delete list element is long pressed to remove a file
|
||||
* @param del pointer to the Delete button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is NOT deleted in the function
|
||||
*/
|
||||
static lv_action_res_t win_del_lpr_action(lv_obj_t * del, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(del);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
|
||||
sprintf(path_fn, "%s/%s", app_data->path, app_data->fn);
|
||||
|
||||
fs_res_t res = fs_remove(path_fn);
|
||||
if(res == FS_RES_OK) lv_app_notice_add("%s deleted", app_data->fn);
|
||||
else lv_app_notice_add("Can not delete\n%s", app_data->fn);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send setting is typed and 'Close' pressed on the App. keyboard.
|
||||
* The function reverts the original value in the text area.
|
||||
* @param ta pointer to a text area
|
||||
*/
|
||||
static void send_settings_kb_close_action(lv_obj_t * ta)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(ta);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
char buf[32];
|
||||
buf[0] = '\0';
|
||||
|
||||
if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
sprintf(buf, "%d", app_data->chunk_size);
|
||||
}
|
||||
lv_ta_set_text(ta, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a send setting is typed and 'Ok' pressed on the App. keyboard.
|
||||
* The function saves teh new value.
|
||||
* @param ta pointer to a text area
|
||||
*/
|
||||
static void send_settings_kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
send_settings_id_t id = lv_obj_get_free_num(ta);
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
int num;
|
||||
sscanf(lv_ta_get_txt(ta), "%d", &num);
|
||||
|
||||
if(id == SEND_SETTINGS_CHUNK_DELAY) {
|
||||
if(num > LV_APP_FILES_CHUNK_MAX_TIME) num = LV_APP_FILES_CHUNK_MAX_TIME;
|
||||
if(num < LV_APP_FILES_CHUNK_MIN_TIME) num = LV_APP_FILES_CHUNK_MIN_TIME;
|
||||
app_data->chunk_delay = (uint16_t) num;
|
||||
} else if(id == SEND_SETTINGS_CHUNK_SIZE) {
|
||||
if(num > LV_APP_FILES_CHUNK_MAX_SIZE) num = LV_APP_FILES_CHUNK_MAX_SIZE;
|
||||
if(num < LV_APP_FILES_CHUNK_MIN_SIZE) num = LV_APP_FILES_CHUNK_MIN_SIZE;
|
||||
app_data->chunk_size= (uint16_t) num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the sending of a file
|
||||
* @param app pointer to a Files application
|
||||
* @param path path of the file to send
|
||||
*/
|
||||
static void start_send(lv_app_inst_t * app, const char * path)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Open the file*/
|
||||
fs_res_t res = fs_open(&app_data->file, path, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
app_data->send_in_prog = 1;
|
||||
|
||||
/*Send the header*/
|
||||
if(app_data->send_fn != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, app_data->path, strlen(app_data->path));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "/", 1);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, app_data->fn, strlen(app_data->fn));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
|
||||
if(app_data->send_size != 0) {
|
||||
char buf[64];
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
sprintf(buf,"%d", (int) size);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, buf, strlen(buf));
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
if(app_data->send_crc != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "0x0000", 6);
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
|
||||
/*Add an extra \n to separate the header from the file data*/
|
||||
if(app_data->send_fn != 0 || app_data->send_size != 0 || app_data->send_crc != 0) {
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*If an error occurred close the file*/
|
||||
if(res != FS_RES_OK) {
|
||||
fs_close(&app_data->file);
|
||||
ptask_set_prio(app_data->send_task, PTASK_PRIO_OFF);
|
||||
app_data->send_in_prog = 0;
|
||||
lv_app_notice_add("Can not send\nthe file in Files");
|
||||
}
|
||||
/*If no error show notification, start the sender task and refresh the shortcut*/
|
||||
else {
|
||||
/*Start the sender task*/
|
||||
ptask_set_period(app_data->send_task, app_data->chunk_delay);
|
||||
ptask_reset(app_data->send_task);
|
||||
ptask_set_prio(app_data->send_task, PTASK_PRIO_HIGH);
|
||||
lv_app_notice_add("Sending\n%s", fs_get_last(path));
|
||||
|
||||
/*Refresh the shortcut with the percentage of the sending*/
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
uint32_t pos;
|
||||
fs_tell(&app_data->file, &pos);
|
||||
|
||||
int pct = (uint32_t) (pos * 100) / size;
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "Sending\n%d%%", pct);
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Periodically send the next chunk of the file
|
||||
* @param app pointer to a Files application
|
||||
*/
|
||||
static void send_task(void * param)
|
||||
{
|
||||
lv_app_inst_t * app = param;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(app_data->send_in_prog == 0) return;
|
||||
|
||||
/*Read a chunk*/
|
||||
uint32_t rn;
|
||||
char rd_buf[LV_APP_FILES_CHUNK_MAX_SIZE];
|
||||
fs_res_t res = fs_read(&app_data->file, rd_buf, app_data->chunk_size, &rn);
|
||||
if(res == FS_RES_OK) {
|
||||
app_data->send_in_prog = 1;
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, rd_buf, rn);
|
||||
}
|
||||
|
||||
/*If the read failed close the file and show an error*/
|
||||
if(res != FS_RES_OK) {
|
||||
fs_close(&app_data->file);
|
||||
app_data->send_in_prog = 0;
|
||||
lv_app_notice_add("Can not send\nthe file in Files");
|
||||
}
|
||||
/*If the read was successful*/
|
||||
else {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
/*If the file is read close it a show a notification*/
|
||||
if(rn < app_data->chunk_size) {
|
||||
lv_app_notice_add("File sent");
|
||||
fs_close(&app_data->file);
|
||||
app_data->send_in_prog = 0;
|
||||
|
||||
/*Refresh the shortut*/
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
/*If the file is not sent yet refresh the shortcut with percentage of sending*/
|
||||
else {
|
||||
if(sc_data != NULL) {
|
||||
uint32_t size;
|
||||
fs_size(&app_data->file, &size);
|
||||
uint32_t pos;
|
||||
fs_tell(&app_data->file, &pos);
|
||||
|
||||
uint8_t pct = (uint32_t) (pos * 100) / size;
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "Sending\n%d%%", pct);
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_files.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_FILES_H
|
||||
#define LV_APP_FILES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_files_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_files_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_FILES != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
@@ -1,477 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_gsm.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_gsm.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_GSM != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "hal/gsm/gsm.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "misc/comm/gsmmng.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define GSM_MONITOR_PERIOD 1000 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char set_apn[128];
|
||||
char set_ip[32];
|
||||
char set_port[16];
|
||||
uint8_t * last_msg_dp;
|
||||
uint16_t last_msg_size;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * netw_apn_ta;
|
||||
lv_obj_t * tcp_ip_ta;
|
||||
lv_obj_t * tcp_port_ta;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void gsm_state_monitor_task(void * param);
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t netw_apn_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
|
||||
static void netw_apn_kb_ok(lv_obj_t * ta);
|
||||
static void netw_apn_kb_close(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta);
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_port_kb_close(lv_obj_t * ta);
|
||||
|
||||
static void tcp_transf_cb(gsm_state_t state, const char * txt);
|
||||
|
||||
static void win_title_refr(void);
|
||||
|
||||
static void save_conf(lv_app_inst_t * app);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "GSM",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static lv_app_inst_t * app_act_com;
|
||||
|
||||
static char def_apn[128];
|
||||
static char def_ip[32];
|
||||
static char def_port[16];
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_gsm_init(void)
|
||||
{
|
||||
#ifdef LV_APP_GSM_CONF_PATH
|
||||
fs_file_t f;
|
||||
fs_res_t res;
|
||||
|
||||
res = fs_open(&f, LV_APP_GSM_CONF_PATH, FS_MODE_RD);
|
||||
if(res == FS_RES_NOT_EX) {
|
||||
res = fs_open(&f, LV_APP_GSM_CONF_PATH, FS_MODE_WR | FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
const char * def_conf = "apn\n100.101.102.103\n1234";
|
||||
fs_write(&f, def_conf, strlen(def_conf) + 1, NULL);
|
||||
fs_seek(&f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(res == FS_RES_OK) {
|
||||
volatile char buf[256];
|
||||
volatile uint32_t rn;
|
||||
fs_read(&f, (char *)buf, sizeof(buf) - 1, (uint32_t *)&rn);
|
||||
|
||||
volatile uint16_t i;
|
||||
volatile uint16_t j = 0;
|
||||
volatile uint8_t line_cnt = 0;
|
||||
for(i = 0; i < rn; i++) {
|
||||
if(buf[i] != '\n') {
|
||||
if(line_cnt == 0) def_apn[j] = buf[i];
|
||||
if(line_cnt == 1) def_ip[j] = buf[i];
|
||||
if(line_cnt == 2) def_port[j] = buf[i];
|
||||
j++;
|
||||
} else {
|
||||
if(line_cnt == 0) def_apn[j] = '\0';
|
||||
if(line_cnt == 1) def_ip[j] = '\0';
|
||||
if(line_cnt == 2) def_port[j] = '\0';
|
||||
j = 0;
|
||||
line_cnt ++;
|
||||
}
|
||||
}
|
||||
|
||||
fs_close(&f);
|
||||
|
||||
} else {
|
||||
lv_app_notice_add("SD card error");
|
||||
}
|
||||
#else
|
||||
strcpy(def_apn, LV_APP_GSM_APN_DEF);
|
||||
strcpy(def_ip, LV_APP_GSM_IP_DEF);
|
||||
strcpy(def_port, LV_APP_GSM_PORT_DEF);
|
||||
#endif
|
||||
|
||||
#if LV_APP_GSM_AUTO_CONNECT != 0
|
||||
gsmmng_set_last_apn(def_apn);
|
||||
gsmmng_set_last_tcp(def_ip, def_port);
|
||||
#endif
|
||||
ptask_create(gsm_state_monitor_task, GSM_MONITOR_PERIOD, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_apn, def_apn);
|
||||
strcpy(adata->set_ip, def_ip);
|
||||
strcpy(adata->set_port, def_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
app_act_com = app_rec;
|
||||
gsm_tcp_transf(data, size, tcp_transf_cb);
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
if(adata->last_msg_dp != NULL) dm_free(adata->last_msg_dp);
|
||||
|
||||
adata->last_msg_dp = dm_alloc(size);
|
||||
memcpy(adata->last_msg_dp, data, size);
|
||||
adata->last_msg_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_app_data_t * adata = app->app_data;
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
wdata->title = lv_label_create(win, NULL);
|
||||
|
||||
lv_obj_t * ta_cont = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(ta_cont, true, true);
|
||||
lv_cont_set_layout(ta_cont, LV_CONT_LAYOUT_COL_L);
|
||||
lv_obj_set_style(ta_cont, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
|
||||
wdata->netw_apn_ta = lv_ta_create(ta_cont, NULL);
|
||||
lv_cont_set_fit(wdata->netw_apn_ta, false, true);
|
||||
lv_obj_set_free_p(wdata->netw_apn_ta, app);
|
||||
lv_obj_set_width(wdata->netw_apn_ta, LV_DPI * 3);
|
||||
lv_page_set_rel_action(wdata->netw_apn_ta, netw_apn_rel_action);
|
||||
lv_ta_set_text(wdata->netw_apn_ta, adata->set_apn);
|
||||
lv_ta_set_cursor_show(wdata->netw_apn_ta, false);
|
||||
|
||||
wdata->tcp_ip_ta = lv_ta_create(ta_cont, wdata->netw_apn_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_ip_ta, tcp_ip_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_ip_ta, adata->set_ip);
|
||||
|
||||
wdata->tcp_port_ta = lv_ta_create(ta_cont, wdata->netw_apn_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_port_ta, tcp_port_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_port_ta, adata->set_port);
|
||||
|
||||
lv_obj_t * con_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(con_btn, app);
|
||||
lv_btn_set_rel_action(con_btn, netw_con_rel_action);
|
||||
lv_obj_t * label = lv_label_create(con_btn, NULL);
|
||||
lv_label_set_text(label, "Connect");
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void gsm_state_monitor_task(void * param)
|
||||
{
|
||||
static gsmmng_state_t state_prev = GSMMNG_STATE_WAIT;
|
||||
gsmmng_state_t state_act = gsmmng_get_state();
|
||||
|
||||
if(state_prev != state_act && state_act == GSMMNG_STATE_READY) {
|
||||
lv_app_notice_add("GSM connected to:\n%s\n%s:%s",
|
||||
gsmmng_get_last_apn(), gsmmng_get_last_ip(), gsmmng_get_last_port());
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
/* The GSM should be busy if there is sg. to send.
|
||||
* It means fail during last send. Try again*/
|
||||
if(app_act_com != NULL) {
|
||||
if(gsm_busy() == false && state_act == GSMMNG_STATE_READY) {
|
||||
/*Try to send the message again*/
|
||||
lv_app_notice_add("Resend GSM message");
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
gsm_tcp_transf(adata->last_msg_dp, adata->last_msg_size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
|
||||
state_prev = state_act;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
gsmmng_set_last_apn(adata->set_apn);
|
||||
gsmmng_set_last_tcp(adata->set_ip, adata->set_port);
|
||||
gsmmng_reconnect();
|
||||
save_conf(app);
|
||||
lv_app_notice_add("Connecting to GSM network\n%s\n %s:%s",
|
||||
adata->set_apn, adata->set_ip, adata->set_port);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_apn_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_apn_kb_close ,netw_apn_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_ip_kb_close ,tcp_ip_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_port_kb_close ,tcp_port_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static void netw_apn_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_apn, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_apn_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_apn);
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ip, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ip);
|
||||
}
|
||||
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_port, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_port_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_port);
|
||||
}
|
||||
|
||||
static void tcp_transf_cb(gsm_state_t state, const char * txt)
|
||||
{
|
||||
if(state == GSM_STATE_OK) {
|
||||
uint16_t size = txt[0] + ((txt[1] << 8) & 0xFF00);
|
||||
char buf[256];
|
||||
memcpy(buf, &txt[2], size);
|
||||
buf[size] = '\0';
|
||||
lv_app_com_send(app_act_com, LV_APP_COM_TYPE_CHAR, &txt[2], size);
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
dm_free(adata->last_msg_dp);
|
||||
adata->last_msg_dp = NULL;
|
||||
adata->last_msg_size = 0;
|
||||
app_act_com = NULL;
|
||||
}else if(state == GSM_STATE_ERROR) {
|
||||
lv_app_notice_add("GSM TCP transfer error\n%s", txt);
|
||||
lv_app_notice_add("Reconnecting to GSM...");
|
||||
gsmmng_reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void win_title_refr(void)
|
||||
{
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
if(gsmmng_get_state() == GSMMNG_STATE_IDLE) {
|
||||
lv_label_set_text(wdata->title, "Not connected");
|
||||
} else if(gsmmng_get_state() == GSMMNG_STATE_READY) {
|
||||
lv_label_set_text(wdata->title, "Connecting ...");
|
||||
} else {
|
||||
char buf[256];
|
||||
sprintf(buf, "%s - %s:%s", gsmmng_get_last_apn(), gsmmng_get_last_ip(), gsmmng_get_last_port());
|
||||
lv_label_set_text(wdata->title, buf);
|
||||
}
|
||||
lv_obj_set_width(wdata->title, lv_win_get_width(app->win));
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
static void save_conf(lv_app_inst_t * app)
|
||||
{
|
||||
#ifdef LV_APP_GSM_CONF_PATH
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
fs_file_t f;
|
||||
fs_res_t res;
|
||||
res = fs_open(&f, LV_APP_GSM_CONF_PATH, FS_MODE_WR);
|
||||
if(res == FS_RES_OK) {
|
||||
char buf[256];
|
||||
sprintf(buf,"%s\n%s\n%s", adata->set_apn, adata->set_ip, adata->set_port);
|
||||
fs_write(&f, buf, strlen(buf) + 1, NULL);
|
||||
fs_close(&f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_gsm.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_GSM_H
|
||||
#define LV_APP_GSM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_GSM != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_gsm_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_gsm_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_phantom.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
void (*com_listen)(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Phantom",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = NULL,
|
||||
.win_close = NULL,
|
||||
.sc_open = NULL,
|
||||
.sc_close = NULL,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_phantom_init(void)
|
||||
{
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_phantom_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
app_data->com_listen = NULL;
|
||||
|
||||
if(conf != NULL) {
|
||||
lv_app_phantom_conf_t * my_conf = conf;
|
||||
app_data->com_listen = my_conf->com_listen;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
|
||||
my_app_data_t * app_data = app_rec->app_data;
|
||||
|
||||
if(app_data->com_listen != NULL) {
|
||||
app_data->com_listen(app_send, app_rec, type, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_phantom.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_PHANTOM_H
|
||||
#define LV_APP_PHANTOM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
void (*com_listen)(lv_app_inst_t * app_send,
|
||||
lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type ,
|
||||
const void * data, uint32_t size);
|
||||
}lv_app_phantom_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_phantom_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_PHANTOM_H */
|
||||
@@ -1,399 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_sysmon.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_sysmon.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0
|
||||
|
||||
#include <stdio.h>
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/os/idle.h"
|
||||
#include "lvgl/lv_objx/lv_chart.h"
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_notice.h"
|
||||
#include "hal/systick/systick.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CPU_LABEL_COLOR "FF0000"
|
||||
#define MEM_LABEL_COLOR "0000FF"
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * chart;
|
||||
lv_chart_dl_t * cpu_dl;
|
||||
lv_chart_dl_t * mem_dl;
|
||||
lv_obj_t * label;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * bar_cpu;
|
||||
lv_obj_t * bar_mem;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void sysmon_task(void * param);
|
||||
static void lv_app_sysmon_refr(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Sys. monitor",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static uint8_t mem_pct[LV_APP_SYSMON_PNUM];
|
||||
static uint8_t cpu_pct[LV_APP_SYSMON_PNUM];
|
||||
static lv_style_t cpu_bar_bg;
|
||||
static lv_style_t mem_bar_bg;
|
||||
static lv_style_t cpu_bar_indic;
|
||||
static lv_style_t mem_bar_indic;
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
static dm_mon_t mem_mon;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_sysmon_init(void)
|
||||
{
|
||||
ptask_create(sysmon_task, LV_APP_SYSMON_REFR_TIME, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
memset(mem_pct, 0, sizeof(mem_pct));
|
||||
memset(cpu_pct, 0, sizeof(cpu_pct));
|
||||
|
||||
/*Create bar styles for the shortcut*/
|
||||
lv_style_get(LV_STYLE_PRETTY, &cpu_bar_bg);
|
||||
cpu_bar_bg.ccolor = COLOR_MAKE(0x40, 0x00, 0x00);
|
||||
cpu_bar_bg.font = font_get(LV_APP_FONT_MEDIUM);
|
||||
cpu_bar_bg.line_space = 0;
|
||||
cpu_bar_bg.txt_align = 1;
|
||||
cpu_bar_bg.hpad = 0;
|
||||
cpu_bar_bg.vpad = 0;
|
||||
|
||||
memcpy(&mem_bar_bg, &cpu_bar_bg, sizeof(lv_style_t));
|
||||
mem_bar_bg.ccolor = COLOR_MAKE(0x00, 0x40, 0x00);
|
||||
|
||||
lv_style_get(LV_STYLE_PRETTY_COLOR, &cpu_bar_indic);
|
||||
cpu_bar_indic.gcolor = COLOR_MARRON;
|
||||
cpu_bar_indic.mcolor = COLOR_RED;
|
||||
cpu_bar_indic.bcolor = COLOR_BLACK;
|
||||
//cpu_bar_indic.bwidth = 1 * LV_DOWNSCALE;
|
||||
cpu_bar_indic.bopa = OPA_50;
|
||||
cpu_bar_indic.hpad = 0 * LV_DOWNSCALE;
|
||||
cpu_bar_indic.vpad = 0 * LV_DOWNSCALE;
|
||||
|
||||
|
||||
memcpy(&mem_bar_indic, &cpu_bar_indic, sizeof(lv_style_t));
|
||||
mem_bar_indic.gcolor = COLOR_GREEN;
|
||||
mem_bar_indic.mcolor = COLOR_LIME;
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_sysmon_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
cord_t w = lv_obj_get_width(sc) / 5;
|
||||
|
||||
/*Create 2 bars for the CPU and the Memory*/
|
||||
sc_data->bar_cpu = lv_bar_create(sc, NULL);
|
||||
lv_obj_set_size(sc_data->bar_cpu, w, 5 * lv_obj_get_height(sc) / 8);
|
||||
lv_obj_align(sc_data->bar_cpu, NULL, LV_ALIGN_IN_BOTTOM_LEFT, w, - lv_obj_get_height(sc) / 8);
|
||||
lv_obj_set_style(sc_data->bar_cpu, &cpu_bar_bg);
|
||||
lv_bar_set_style_indic(sc_data->bar_cpu, &cpu_bar_indic);
|
||||
lv_obj_set_click(sc_data->bar_cpu, false);
|
||||
lv_bar_set_range(sc_data->bar_cpu, 0, 100);
|
||||
lv_obj_t * label = lv_label_create(sc_data->bar_cpu, NULL);
|
||||
lv_label_set_text(label, "C\nP\nU");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
sc_data->bar_mem = lv_bar_create(sc, sc_data->bar_cpu);
|
||||
lv_obj_align(sc_data->bar_mem, sc_data->bar_cpu, LV_ALIGN_OUT_RIGHT_MID, w, 0);
|
||||
lv_obj_set_style(sc_data->bar_mem, &mem_bar_bg);
|
||||
lv_bar_set_style_indic(sc_data->bar_mem, &mem_bar_indic);
|
||||
label = lv_label_create(sc_data->bar_mem, NULL);
|
||||
lv_label_set_text(label, "M\nE\nM");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_app_sysmon_refr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
|
||||
/*Make the window content responsive*/
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
/*Create a chart with two data lines*/
|
||||
win_data->chart = lv_chart_create(win, NULL);
|
||||
lv_obj_set_size(win_data->chart, LV_HOR_RES / 2, LV_VER_RES / 2);
|
||||
lv_obj_set_pos(win_data->chart, LV_DPI / 10, LV_DPI / 10);
|
||||
lv_chart_set_pnum(win_data->chart, LV_APP_SYSMON_PNUM);
|
||||
lv_chart_set_range(win_data->chart, 0, 100);
|
||||
lv_chart_set_type(win_data->chart, LV_CHART_LINE);
|
||||
lv_chart_set_dl_width(win_data->chart, 2 * LV_DOWNSCALE);
|
||||
win_data->cpu_dl = lv_chart_add_data_line(win_data->chart, COLOR_RED);
|
||||
win_data->mem_dl = lv_chart_add_data_line(win_data->chart, COLOR_BLUE);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < LV_APP_SYSMON_PNUM; i ++) {
|
||||
win_data->cpu_dl->points[i] = cpu_pct[i];
|
||||
win_data->mem_dl->points[i] = mem_pct[i];
|
||||
}
|
||||
|
||||
/*Create a label for the details of Memory and CPU usage*/
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_recolor(win_data->label, true);
|
||||
lv_obj_align(win_data->label, win_data->chart, LV_ALIGN_OUT_RIGHT_TOP, LV_DPI / 4, 0);
|
||||
|
||||
|
||||
lv_app_sysmon_refr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called periodically to monitor the CPU and memory usage.
|
||||
* It refreshes the shortcuts and windows and also add notifications if there is any problem.
|
||||
* @param param unused
|
||||
*/
|
||||
static void sysmon_task(void * param)
|
||||
{
|
||||
/*Shift out the oldest data*/
|
||||
uint16_t i;
|
||||
for(i = 1; i < LV_APP_SYSMON_PNUM; i++) {
|
||||
mem_pct[i - 1] = mem_pct[i];
|
||||
cpu_pct[i - 1] = cpu_pct[i];
|
||||
}
|
||||
|
||||
/*Get CPU and memory information */
|
||||
uint8_t cpu_busy = 0;
|
||||
#if USE_IDLE != 0 /*Use the more precise idle module if enabled*/
|
||||
cpu_busy = 100 - idle_get();
|
||||
#else
|
||||
cpu_busy = 100 - ptask_get_idle();
|
||||
#endif
|
||||
|
||||
uint8_t mem_used_pct = 0;
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
dm_monitor(&mem_mon);
|
||||
mem_used_pct = mem_mon.pct_used;
|
||||
#endif
|
||||
|
||||
/*Add the CPU and memory data*/
|
||||
cpu_pct[LV_APP_SYSMON_PNUM - 1] = cpu_busy;
|
||||
mem_pct[LV_APP_SYSMON_PNUM - 1] = mem_used_pct;
|
||||
|
||||
/*Refresh the shortcuts and windows*/
|
||||
lv_app_sysmon_refr();
|
||||
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
|
||||
/*Handle periodic defrag. if enabled*/
|
||||
#if LV_APP_SYSMON_DEFRAG_PERIOD != 0
|
||||
static uint32_t last_defrag = 0;
|
||||
|
||||
if(systick_elaps(last_defrag) > LV_APP_SYSMON_DEFRAG_PERIOD) {
|
||||
dm_defrag();
|
||||
last_defrag = systick_get();
|
||||
}
|
||||
#endif
|
||||
/*Add notifications if something is critical*/
|
||||
static bool mem_warn_report = false;
|
||||
if(mem_mon.size_free < LV_APP_SYSMON_MEM_WARN && mem_warn_report == false) {
|
||||
mem_warn_report = true;
|
||||
lv_app_notice_add("Critically low memory");
|
||||
}
|
||||
|
||||
if(mem_mon.size_free > LV_APP_SYSMON_MEM_WARN) mem_warn_report = false;
|
||||
|
||||
static bool frag_warn_report = false;
|
||||
if(mem_mon.pct_frag > LV_APP_SYSMON_FRAG_WARN) {
|
||||
if(frag_warn_report == false) {
|
||||
frag_warn_report = true;
|
||||
lv_app_notice_add("Critical memory\nfragmentation");
|
||||
|
||||
dm_defrag(); /*Defrag. if the fragmentation is critical*/
|
||||
}
|
||||
}
|
||||
|
||||
if(mem_mon.pct_frag < LV_APP_SYSMON_FRAG_WARN) frag_warn_report = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the shortcuts and windows.
|
||||
*/
|
||||
static void lv_app_sysmon_refr(void)
|
||||
{
|
||||
|
||||
char buf_long[256];
|
||||
char buf_short[128];
|
||||
sprintf(buf_long, "%c%s CPU: %d %%%c\n\n",TXT_RECOLOR_CMD, CPU_LABEL_COLOR, cpu_pct[LV_APP_SYSMON_PNUM - 1], TXT_RECOLOR_CMD);
|
||||
sprintf(buf_short, "CPU: %d %%\n", cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
|
||||
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
|
||||
sprintf(buf_long, "%s%c%s MEMORY: %d %%%c\nTotal: %d bytes\nUsed: %d bytes\nFree: %d bytes\nFrag: %d %%",
|
||||
buf_long,
|
||||
TXT_RECOLOR_CMD,
|
||||
MEM_LABEL_COLOR,
|
||||
mem_pct[LV_APP_SYSMON_PNUM - 1],
|
||||
TXT_RECOLOR_CMD,
|
||||
(int)mem_mon.size_total,
|
||||
(int)mem_mon.size_total - mem_mon.size_free, mem_mon.size_free, mem_mon.pct_frag);
|
||||
|
||||
sprintf(buf_short, "%sMem: %d %%\nFrag: %d %%\n",
|
||||
buf_short, mem_pct[LV_APP_SYSMON_PNUM - 1], mem_mon.pct_frag);
|
||||
#else
|
||||
sprintf(buf_long, "%s%c%s MEMORY: N/A%c", buf_long, TXT_RECOLOR_CMD, MEM_LABEL_COLOR, TXT_RECOLOR_CMD);
|
||||
sprintf(buf_short, "%sMem: N/A\nFrag: N/A", buf_short);
|
||||
#endif
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
/*Refresh the windows*/
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text(win_data->label, buf_long);
|
||||
|
||||
lv_chart_set_next(win_data->chart, win_data->mem_dl, mem_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
lv_chart_set_next(win_data->chart, win_data->cpu_dl, cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
|
||||
}
|
||||
/*Refresh the shortcut*/
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
if(sc_data != NULL) {
|
||||
lv_bar_set_value(sc_data->bar_cpu, cpu_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
lv_bar_set_value(sc_data->bar_mem, mem_pct[LV_APP_SYSMON_PNUM - 1]);
|
||||
}
|
||||
|
||||
lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, buf_short, strlen(buf_short));
|
||||
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_SYSMON_H
|
||||
#define LV_APP_SYSMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_sysmon_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_sysmon_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_SYSMON != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_SYSMON_H */
|
||||
@@ -1,498 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_terminal.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include <lv_conf.h>
|
||||
#include <misc/gfx/area.h>
|
||||
#include <lvgl/lv_obj/lv_dispi.h>
|
||||
#include <lvgl/lv_obj/lv_obj.h>
|
||||
#include <lvgl/lv_objx/lv_btn.h>
|
||||
#include <lvgl/lv_objx/lv_cont.h>
|
||||
#include <lvgl/lv_objx/lv_ddlist.h>
|
||||
#include <lvgl/lv_objx/lv_label.h>
|
||||
#include <lvgl/lv_objx/lv_page.h>
|
||||
#include <lvgl/lv_objx/lv_ta.h>
|
||||
#include <misc/gfx/color.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "lv_app_terminal.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0
|
||||
|
||||
#include "lvgl/lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define OBJ_PAD (LV_DPI / 12)
|
||||
#define AUTO_CONNECT_TCP_DELAY 5000 /*Wait before TCS server connect when the WiFi connect is ready*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char txt[LV_APP_TERMINAL_LENGTH + 1];
|
||||
lv_app_com_type_t com_type;
|
||||
lv_app_terminal_format_t format;
|
||||
lv_app_inst_t * last_sender;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
lv_obj_t * ta;
|
||||
lv_obj_t * clear_btn;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win);
|
||||
|
||||
static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len);
|
||||
static lv_action_res_t win_ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_comtype_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_format_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
static lv_action_res_t win_clear_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static void win_ta_kb_ok_action(lv_obj_t * ta);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "Terminal",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.conf_open = my_conf_open,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static const char * com_type_list_txt[] = {"Character", "Integer", "Log", "None", ""};
|
||||
static lv_app_com_type_t com_type_list[] = {LV_APP_COM_TYPE_CHAR, LV_APP_COM_TYPE_INT, LV_APP_COM_TYPE_LOG, LV_APP_COM_TYPE_INV};
|
||||
static const char * txt_format_list_txt[] = {"ASCII", "Hexadecimal", ""};
|
||||
static lv_style_t style_sc_term;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_terminal_init(void)
|
||||
{
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_sc_term);
|
||||
style_sc_term.line_space = 0;
|
||||
style_sc_term.letter_space = 0;
|
||||
style_sc_term.txt_align = 0;
|
||||
style_sc_term.ccolor = COLOR_WHITE;
|
||||
style_sc_term.mcolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
style_sc_term.gcolor = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
if(conf != NULL) {
|
||||
app_data->com_type = ((lv_app_terminal_conf_t * ) conf)->com_type;
|
||||
app_data->format = ((lv_app_terminal_conf_t * ) conf)->format;
|
||||
} else {
|
||||
app_data->com_type = LV_APP_COM_TYPE_CHAR;
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_ASCII;
|
||||
}
|
||||
|
||||
app_data->last_sender = NULL;
|
||||
|
||||
memset(app_data->txt, 0, sizeof(app_data->txt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this applicationstring
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
my_app_data_t * app_data = app_rec->app_data;
|
||||
|
||||
/*Add the received data if the type is matches*/
|
||||
if(type == app_data->com_type) {
|
||||
|
||||
/*Insert the name of the sender application if it is not the last*/
|
||||
if(app_data->last_sender != app_send) {
|
||||
add_data(app_rec, "\n@", 2);
|
||||
add_data(app_rec, app_send->name, strlen(app_send->name));
|
||||
add_data(app_rec, "\n", 1);
|
||||
}
|
||||
|
||||
if(app_data->format == LV_APP_TERMINAL_FORMAT_HEX) {
|
||||
char hex_buf[8];
|
||||
const char * data_buf = data;
|
||||
uint32_t i;
|
||||
for(i = 0; i < size; i++) {
|
||||
sprintf(hex_buf, "%02x", data_buf[i]);
|
||||
add_data(app_rec, hex_buf, 2);
|
||||
}
|
||||
} else {
|
||||
add_data(app_rec, data, size);
|
||||
}
|
||||
}
|
||||
|
||||
app_data->last_sender = app_send;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Create a dark background*/
|
||||
lv_obj_t * txt_bg = lv_obj_create(sc, NULL);
|
||||
lv_obj_set_size(txt_bg, 7 * LV_APP_SC_WIDTH / 8 , app->sc->cords.y2 - app->sc_title->cords.y2 - 10 * LV_DOWNSCALE);
|
||||
lv_obj_set_style(txt_bg, &style_sc_term);
|
||||
lv_obj_align(txt_bg, app->sc_title, LV_ALIGN_OUT_BOTTOM_MID, 0, 3 * LV_DOWNSCALE);
|
||||
lv_obj_set_click(txt_bg, false);
|
||||
|
||||
/*Add a text with the text of the terminal*/
|
||||
sc_data->label = lv_label_create(txt_bg, NULL);
|
||||
lv_label_set_long_mode(sc_data->label, LV_LABEL_LONG_BREAK);
|
||||
lv_obj_set_width(sc_data->label, lv_obj_get_width(txt_bg) - LV_APP_SC_WIDTH / 8);
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, txt_bg, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
/*Make the window content responsive*/
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
/*Create a label for the text of the terminal*/
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_long_mode(win_data->label, LV_LABEL_LONG_BREAK);
|
||||
lv_obj_set_width(win_data->label, lv_win_get_width(win));
|
||||
lv_label_set_text_static(win_data->label, app_data->txt); /*Use the app. data text directly*/
|
||||
|
||||
/*Create a text area. Text can be added to the terminal from here by app. keyboard.*/
|
||||
win_data->ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size(win_data->ta, 3 * LV_HOR_RES / 5, LV_VER_RES / 4);
|
||||
lv_obj_set_free_p(win_data->ta, app);
|
||||
lv_page_set_rel_action(win_data->ta, win_ta_rel_action);
|
||||
lv_page_glue_obj(win_data->ta, true);
|
||||
lv_ta_set_text(win_data->ta, "");
|
||||
|
||||
/*Create a clear button*/
|
||||
win_data->clear_btn = lv_btn_create(win, NULL);
|
||||
lv_cont_set_fit(win_data->clear_btn, true, true);
|
||||
lv_obj_set_free_p(win_data->clear_btn, app);
|
||||
lv_page_glue_obj(win_data->ta, true);
|
||||
lv_btn_set_rel_action(win_data->clear_btn, win_clear_rel_action);
|
||||
lv_obj_t * btn_label = lv_label_create(win_data->clear_btn, NULL);
|
||||
lv_label_set_text(btn_label, "Clear");
|
||||
|
||||
/*Align the window to see the text area on the bottom*/
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create objects to configure the applications
|
||||
* @param app pointer to an application which settings should be created
|
||||
* @param conf_win pointer to a window where the objects can be created
|
||||
* (the window has the proper layout)
|
||||
*/
|
||||
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(conf_win, NULL);
|
||||
lv_label_set_text(label, "Communication type");
|
||||
|
||||
lv_obj_t * ddl;
|
||||
ddl = lv_ddlist_create(conf_win, NULL);
|
||||
lv_obj_set_free_p(ddl, app);
|
||||
lv_ddlist_set_options(ddl, com_type_list_txt);
|
||||
lv_ddlist_set_action(ddl, win_comtype_action);
|
||||
lv_ddlist_set_selected(ddl, app_data->com_type);
|
||||
|
||||
label = lv_label_create(conf_win, label);
|
||||
lv_label_set_text(label, "\nText format"); /*First '\n' keeps space from the list above*/
|
||||
ddl = lv_ddlist_create(conf_win, ddl);
|
||||
lv_ddlist_set_options(ddl, txt_format_list_txt);
|
||||
lv_ddlist_set_selected(ddl, app_data->format);
|
||||
lv_ddlist_set_action(ddl, win_format_action);
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
/**
|
||||
* Called when the Text area is released to open the app. keybard
|
||||
* @param ta pointer to the text area
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the text area is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, win_ta_kb_ok_action);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an option is chosen in the communication type drop down list on the configuration window
|
||||
* @param ddl pointer to the drop down list
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_comtype_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
|
||||
app_data->com_type = com_type_list[lv_ddlist_get_selected(ddlist)];
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an option is chosen in the format drop down list on the configuration window
|
||||
* @param ddl pointer to the drop down list
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the list is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_format_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
uint16_t opt = lv_ddlist_get_selected(ddlist);
|
||||
if(strcmp(txt_format_list_txt[opt], "Hexadecimal") == 0) {
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_HEX;
|
||||
} else if (strcmp(txt_format_list_txt[opt], "ASCII") == 0) {
|
||||
app_data->format = LV_APP_TERMINAL_FORMAT_ASCII;
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the Clear button is released to clear the text of the terminal
|
||||
* @param btn pointer to the clear button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t win_clear_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
app_data->txt[0] = '\0';
|
||||
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text_static(win_data->label, app_data->txt);
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the 'Ok' button of the keyboard in the window
|
||||
* is pressed to write to the Terminal
|
||||
* @param ta pointer to the Text area in the window
|
||||
*/
|
||||
static void win_ta_kb_ok_action(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
const char * ta_txt = lv_ta_get_txt(ta);
|
||||
uint32_t ta_txt_len = strlen(ta_txt);
|
||||
if(app_data->txt[0] != '\0') add_data(app, "\n", 1);
|
||||
add_data(app, ">", 1);
|
||||
add_data(app, ta_txt, ta_txt_len);
|
||||
|
||||
lv_app_com_send(app, app_data->com_type, ta_txt, ta_txt_len);
|
||||
|
||||
lv_ta_set_text(ta, "");
|
||||
app_data->last_sender = NULL; /*Now the least data in the terminal is from this app*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add data to the terminal
|
||||
* @param app pointer to a Terminal application
|
||||
* @param data pointer to the data
|
||||
* @param data_len length of 'data' in bytes
|
||||
*/
|
||||
static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len)
|
||||
{
|
||||
my_app_data_t * app_data = app->app_data;
|
||||
uint16_t old_len = strlen(app_data->txt);
|
||||
const char * txt = data;
|
||||
|
||||
/*IF the data is longer then the terminal ax size show the last part of data*/
|
||||
if(data_len > LV_APP_TERMINAL_LENGTH) {
|
||||
txt += (data_len - LV_APP_TERMINAL_LENGTH);
|
||||
data_len = LV_APP_TERMINAL_LENGTH;
|
||||
old_len = 0;
|
||||
}
|
||||
/*If the text become too long 'forget' the oldest lines*/
|
||||
else if(old_len + data_len > LV_APP_TERMINAL_LENGTH) {
|
||||
uint16_t new_start;
|
||||
for(new_start = 0; new_start < old_len; new_start++) {
|
||||
if(app_data->txt[new_start] == '\n') {
|
||||
/*If there is enough space break*/
|
||||
if(new_start >= data_len) {
|
||||
/*Ignore line breaks*/
|
||||
while(app_data->txt[new_start] == '\n' || app_data->txt[new_start] == '\r') new_start++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If it wasn't able to make enough space on line breaks
|
||||
* simply forget the oldest characters*/
|
||||
if(new_start == old_len) {
|
||||
new_start = old_len - (LV_APP_TERMINAL_LENGTH - data_len);
|
||||
}
|
||||
/*Move the remaining text to the beginning*/
|
||||
uint16_t j;
|
||||
for(j = new_start; j < old_len; j++) {
|
||||
app_data->txt[j - new_start] = app_data->txt[j];
|
||||
}
|
||||
old_len = old_len - new_start;
|
||||
app_data->txt[old_len] = '\0';
|
||||
|
||||
}
|
||||
|
||||
memcpy(&app_data->txt[old_len], txt, data_len);
|
||||
app_data->txt[old_len + data_len] = '\0';
|
||||
|
||||
my_win_data_t * win_data = app->win_data;
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
if(win_data != NULL) {
|
||||
lv_label_set_text_static(win_data->label, app_data->txt);
|
||||
lv_obj_t * page = lv_win_get_page(app->win);
|
||||
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
|
||||
}
|
||||
|
||||
/*Set the last line on the shortcut*/
|
||||
if(sc_data != NULL) {
|
||||
lv_label_set_text_static(sc_data->label, app_data->txt);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0*/
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_terminal.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_TERMINAL_H
|
||||
#define LV_APP_TERMINAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_TERMINAL_FORMAT_ASCII,
|
||||
LV_APP_TERMINAL_FORMAT_HEX,
|
||||
}lv_app_terminal_format_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_app_terminal_format_t format; /*Data display format*/
|
||||
lv_app_com_type_t com_type; /*The listened communication type (channel) */
|
||||
}lv_app_terminal_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_terminal_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_TERMINAL != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_TERMINAL_H */
|
||||
@@ -1,593 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_wifi.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app_wifi.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_WIFI != 0
|
||||
|
||||
#include "../lv_app/lv_app_util/lv_app_kb.h"
|
||||
#include "hal/wifi/wifi.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "misc/comm/wifimng.h"
|
||||
#include "misc/fs/fat32/integer.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SSID_LIST_MAX_LENGTH 512
|
||||
#define WIFI_MONITOR_PERIOD 1000 /*ms*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Application specific data for an instance of this application*/
|
||||
typedef struct
|
||||
{
|
||||
char set_ssid[64];
|
||||
char set_pwd[64];
|
||||
char set_ip[32];
|
||||
char set_port[16];
|
||||
uint8_t * last_msg_dp;
|
||||
uint16_t last_msg_size;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * list;
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * netw_ssid_ta;
|
||||
lv_obj_t * netw_pwd_ta;
|
||||
lv_obj_t * tcp_ip_ta;
|
||||
lv_obj_t * tcp_port_ta;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, lv_app_com_type_t type , const void * data, uint32_t size);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void wifi_state_monitor_task(void * param);
|
||||
|
||||
static lv_action_res_t netw_list_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi);
|
||||
static lv_action_res_t netw_ssid_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t netw_pwd_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi);
|
||||
static lv_action_res_t wifi_ap_select_action( lv_obj_t * ddlist, lv_dispi_t* dispi);
|
||||
|
||||
static void netw_ssid_kb_ok(lv_obj_t * ta);
|
||||
static void netw_ssid_kb_close(lv_obj_t * ta);
|
||||
static void netw_pwd_kb_ok(lv_obj_t * ta);
|
||||
static void netw_pwd_kb_close(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta);
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta);
|
||||
static void tcp_port_kb_close(lv_obj_t * ta);
|
||||
|
||||
static void list_cb(wifi_state_t state, const char * txt);
|
||||
static void tcp_transf_cb(wifi_state_t state, const char * txt);
|
||||
|
||||
static void win_title_refr(void);
|
||||
|
||||
static void save_conf(lv_app_inst_t * app);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_app_dsc_t my_app_dsc =
|
||||
{
|
||||
.name = "WiFi",
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
static char def_ssid[64];
|
||||
static char def_pwd[64];
|
||||
static char def_ip[32];
|
||||
static char def_port[16];
|
||||
|
||||
static char ssid_list[SSID_LIST_MAX_LENGTH];
|
||||
static lv_app_inst_t * app_act_com;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the application
|
||||
* @return pointer to the application descriptor of this application
|
||||
*/
|
||||
const lv_app_dsc_t * lv_app_wifi_init(void)
|
||||
{
|
||||
strcpy(ssid_list, "");
|
||||
#ifdef LV_APP_WIFI_CONF_PATH
|
||||
fs_file_t f;
|
||||
fs_res_t res;
|
||||
|
||||
res = fs_open(&f, LV_APP_WIFI_CONF_PATH, FS_MODE_RD);
|
||||
if(res == FS_RES_NOT_EX) {
|
||||
res = fs_open(&f, LV_APP_WIFI_CONF_PATH, FS_MODE_WR | FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
const char * def_conf = "ssid\npwd\n100.101.102.103\n1234";
|
||||
fs_write(&f, def_conf, strlen(def_conf) + 1, NULL);
|
||||
fs_seek(&f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(res == FS_RES_OK) {
|
||||
volatile char buf[256];
|
||||
volatile uint32_t rn;
|
||||
fs_read(&f, (char *)buf, sizeof(buf) - 1, (uint32_t *)&rn);
|
||||
|
||||
volatile uint16_t i;
|
||||
volatile uint16_t j = 0;
|
||||
volatile uint8_t line_cnt = 0;
|
||||
for(i = 0; i < rn; i++) {
|
||||
if(buf[i] != '\n') {
|
||||
if(line_cnt == 0) def_ssid[j] = buf[i];
|
||||
if(line_cnt == 1) def_pwd[j] = buf[i];
|
||||
if(line_cnt == 2) def_ip[j] = buf[i];
|
||||
if(line_cnt == 3) def_port[j] = buf[i];
|
||||
j++;
|
||||
} else {
|
||||
if(line_cnt == 0) def_ssid[j] = '\0';
|
||||
if(line_cnt == 1) def_pwd[j] = '\0';
|
||||
if(line_cnt == 2) def_ip[j] = '\0';
|
||||
if(line_cnt == 3) def_port[j] = '\0';
|
||||
j = 0;
|
||||
line_cnt ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fs_close(&f);
|
||||
|
||||
} else {
|
||||
lv_app_notice_add("SD card error");
|
||||
}
|
||||
#else
|
||||
strcpy(def_ssid, LV_APP_WIFI_SSID_DEF);
|
||||
strcpy(def_pwd, LV_APP_WIFI_PWD_DEF);
|
||||
strcpy(def_ip, LV_APP_WIFI_IP_DEF);
|
||||
strcpy(def_port, LV_APP_WIFI_PORT_DEF);
|
||||
#endif
|
||||
|
||||
#if LV_APP_WIFI_AUTO_CONNECT != 0
|
||||
wifimng_set_last_netw(def_ssid, def_pwd);
|
||||
wifimng_set_last_tcp(def_ip, def_port);
|
||||
#endif
|
||||
|
||||
ptask_create(wifi_state_monitor_task, WIFI_MONITOR_PERIOD, PTASK_PRIO_LOW, NULL);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Run an application according to 'app_dsc'
|
||||
* @param app_dsc pointer to an application descriptor
|
||||
* @param conf pointer to a lv_app_example_conf_t structure with configuration data or NULL if unused
|
||||
* @return pointer to the opened application or NULL if any error occurred
|
||||
*/
|
||||
static void my_app_run(lv_app_inst_t * app, void * conf)
|
||||
{
|
||||
/*Initialize the application*/
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ssid, def_ssid);
|
||||
strcpy(adata->set_pwd, def_pwd);
|
||||
strcpy(adata->set_ip, def_ip);
|
||||
strcpy(adata->set_port, def_port);
|
||||
adata->last_msg_dp = NULL;
|
||||
adata->last_msg_size = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a running application.
|
||||
* Close the Window and the Shortcut too if opened.
|
||||
* Free all the allocated memory by this application.
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_app_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_app_data'*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data have been sent to this application
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param size length of 'data' in bytes
|
||||
*/
|
||||
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
|
||||
lv_app_com_type_t type , const void * data, uint32_t size)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_CHAR) { /*data: string*/
|
||||
app_act_com = app_rec;
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
if(adata->last_msg_dp != NULL) dm_free(adata->last_msg_dp);
|
||||
|
||||
adata->last_msg_dp = dm_alloc(size);
|
||||
memcpy(adata->last_msg_dp, data, size);
|
||||
adata->last_msg_size = size;
|
||||
|
||||
wifi_tcp_transf(data, size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a shortcut for an application
|
||||
* @param app pointer to an application
|
||||
* @param sc pointer to an object where the application
|
||||
* can create content of the shortcut
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, "Empty");
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the shortcut of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_sc_close(lv_app_inst_t * app)
|
||||
{
|
||||
/*No dynamically allocated data in 'my_sc_data'*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the application in a window
|
||||
* @param app pointer to an application
|
||||
* @param win pointer to a window object where
|
||||
* the application can create content
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_app_data_t * adata = app->app_data;
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
wdata->title = lv_label_create(win, NULL);
|
||||
|
||||
wdata->list = lv_ddlist_create(win, NULL);
|
||||
lv_obj_set_free_p(wdata->list, app);
|
||||
lv_ddlist_set_options_str(wdata->list, ssid_list);
|
||||
lv_ddlist_set_action(wdata->list, wifi_ap_select_action);
|
||||
|
||||
lv_obj_t * list_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(list_btn, app);
|
||||
lv_btn_set_rel_action(list_btn, netw_list_rel_action);
|
||||
lv_obj_t * label = lv_label_create(list_btn, NULL);
|
||||
lv_label_set_text(label, "List\nrefresh");
|
||||
|
||||
lv_obj_t * ta_cont = lv_cont_create(win, NULL);
|
||||
lv_cont_set_fit(ta_cont, true, true);
|
||||
lv_cont_set_layout(ta_cont, LV_CONT_LAYOUT_COL_L);
|
||||
lv_obj_set_style(ta_cont, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
|
||||
wdata->netw_ssid_ta = lv_ta_create(ta_cont, NULL);
|
||||
lv_cont_set_fit(wdata->netw_ssid_ta, false, true);
|
||||
lv_obj_set_free_p(wdata->netw_ssid_ta, app);
|
||||
lv_page_set_rel_action(wdata->netw_ssid_ta, netw_ssid_rel_action);
|
||||
lv_ta_set_text(wdata->netw_ssid_ta, adata->set_ssid);
|
||||
lv_ta_set_cursor_show(wdata->netw_ssid_ta, false);
|
||||
|
||||
wdata->netw_pwd_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->netw_pwd_ta, netw_pwd_rel_action);
|
||||
lv_ta_set_text(wdata->netw_pwd_ta, adata->set_pwd);
|
||||
|
||||
wdata->tcp_ip_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_ip_ta, tcp_ip_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_ip_ta, adata->set_ip);
|
||||
|
||||
wdata->tcp_port_ta = lv_ta_create(ta_cont, wdata->netw_ssid_ta);
|
||||
lv_page_set_rel_action(wdata->tcp_port_ta, tcp_port_rel_action);
|
||||
lv_ta_set_text(wdata->tcp_port_ta, adata->set_port);
|
||||
|
||||
|
||||
lv_obj_t * con_btn = lv_btn_create(win, NULL);
|
||||
lv_obj_set_free_p(con_btn, app);
|
||||
lv_btn_set_rel_action(con_btn, netw_con_rel_action);
|
||||
label = lv_label_create(con_btn, NULL);
|
||||
lv_label_set_text(label, "Connect");
|
||||
|
||||
|
||||
lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY);
|
||||
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the window of an application
|
||||
* @param app pointer to an application
|
||||
*/
|
||||
static void my_win_close(lv_app_inst_t * app)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*--------------------
|
||||
* OTHER FUNCTIONS
|
||||
---------------------*/
|
||||
|
||||
static void wifi_state_monitor_task(void * param)
|
||||
{
|
||||
static wifimng_state_t state_prev = WIFIMNG_STATE_WAIT;
|
||||
wifimng_state_t state_act = wifimng_get_state();
|
||||
|
||||
if(state_prev != state_act && state_act == WIFIMNG_STATE_READY) {
|
||||
lv_app_notice_add("WiFi connected to:\n%s\n%s:%s",
|
||||
wifimng_get_last_ssid(), wifimng_get_last_ip(), wifimng_get_last_port());
|
||||
win_title_refr();
|
||||
}
|
||||
|
||||
/* The wifi should be busy if there is sg. to send.
|
||||
* It means fail during last send. Try again*/
|
||||
if(app_act_com != NULL) {
|
||||
if(wifi_busy() == false && state_act == WIFIMNG_STATE_READY) {
|
||||
/*Try to send the message again*/
|
||||
lv_app_notice_add("Resend WiFi message");
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
wifi_tcp_transf(adata->last_msg_dp, adata->last_msg_size, tcp_transf_cb);
|
||||
}
|
||||
}
|
||||
state_prev = state_act;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_list_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
wifi_state_t ret;
|
||||
ret = wifi_netw_list(list_cb);
|
||||
|
||||
if(ret == WIFI_STATE_OK) {
|
||||
lv_app_notice_add("Listing WiFi networks");
|
||||
} else {
|
||||
lv_app_notice_add("Cannot list networks\nWiFi was busy. Try again");
|
||||
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_con_rel_action(lv_obj_t * btn, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(btn);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
wifimng_set_last_netw(adata->set_ssid, adata->set_pwd);
|
||||
wifimng_set_last_tcp(adata->set_ip, adata->set_port);
|
||||
wifimng_reconnect();
|
||||
save_conf(app);
|
||||
lv_app_notice_add("Connecting to WiFi network\n%s, %s:%s",
|
||||
adata->set_ssid, adata->set_ip, adata->set_port);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_ssid_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_ssid_kb_close ,netw_ssid_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t netw_pwd_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, netw_pwd_kb_close ,netw_pwd_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_ip_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_ip_kb_close ,tcp_ip_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t tcp_port_rel_action( lv_obj_t * ta, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE | LV_APP_KB_MODE_CUR_MANAGE, tcp_port_kb_close ,tcp_port_kb_ok);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static lv_action_res_t wifi_ap_select_action( lv_obj_t * ddlist, lv_dispi_t* dispi)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ddlist);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
char ssid[256];
|
||||
lv_ddlist_get_selected_str(ddlist, ssid);
|
||||
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_ta_set_text(wdata->netw_ssid_ta, ssid);
|
||||
strcpy(adata->set_ssid, ssid);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
static void netw_ssid_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ssid, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_ssid_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ssid);
|
||||
}
|
||||
|
||||
static void netw_pwd_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_pwd, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void netw_pwd_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_pwd);
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_ip, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_ip_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_ip);
|
||||
}
|
||||
|
||||
static void tcp_port_kb_ok(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
strcpy(adata->set_port, lv_ta_get_txt(ta));
|
||||
}
|
||||
|
||||
static void tcp_port_kb_close(lv_obj_t * ta)
|
||||
{
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(ta);
|
||||
my_app_data_t * adata = app->app_data;
|
||||
lv_ta_set_text(ta, adata->set_port);
|
||||
}
|
||||
|
||||
static void list_cb(wifi_state_t state, const char * txt)
|
||||
{
|
||||
if(state == WIFI_STATE_OK) {
|
||||
if(txt[0] == '\0') {
|
||||
lv_app_notice_add("WiFi network list ready");
|
||||
return;
|
||||
}
|
||||
if(strlen(ssid_list) + strlen(txt) + 4 < sizeof(ssid_list)) {
|
||||
sprintf(ssid_list, "%s\n%s", ssid_list, txt);
|
||||
}
|
||||
|
||||
lv_app_inst_t * app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win_data != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
lv_ddlist_set_options_str(wdata->list, ssid_list);
|
||||
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
} else if(state == WIFI_STATE_ERROR) {
|
||||
lv_app_notice_add("WiFi network list error\n%s", txt);
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_transf_cb(wifi_state_t state, const char * txt)
|
||||
{
|
||||
if(state == WIFI_STATE_OK) {
|
||||
uint16_t size = txt[0] + ((txt[1] << 8) & 0xFF00);
|
||||
char buf[256];
|
||||
memcpy(buf, &txt[2], size);
|
||||
buf[size] = '\0';
|
||||
lv_app_com_send(app_act_com, LV_APP_COM_TYPE_CHAR, &txt[2], size);
|
||||
my_app_data_t * adata = app_act_com->app_data;
|
||||
dm_free(adata->last_msg_dp);
|
||||
adata->last_msg_dp = NULL;
|
||||
adata->last_msg_size = 0;
|
||||
app_act_com = NULL;
|
||||
}else if(state == WIFI_STATE_ERROR) {
|
||||
lv_app_notice_add("WiFi TCP transfer error\n%s", txt);
|
||||
lv_app_notice_add("Reconnecting to WiFi...");
|
||||
wifimng_reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void win_title_refr(void)
|
||||
{
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next(NULL, &my_app_dsc);
|
||||
while(app != NULL) {
|
||||
if(app->win != NULL) {
|
||||
my_win_data_t * wdata = app->win_data;
|
||||
|
||||
if(wifimng_get_state() == WIFIMNG_STATE_IDLE) {
|
||||
lv_label_set_text(wdata->title, "Not connected");
|
||||
}
|
||||
else if(wifimng_get_state() == WIFIMNG_STATE_READY) {
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, "%s - %s:%s", wifimng_get_last_ssid(), wifimng_get_last_ip(), wifimng_get_last_port());
|
||||
lv_label_set_text(wdata->title, buf);
|
||||
}
|
||||
else {
|
||||
lv_label_set_text(wdata->title, "Connecting ...");
|
||||
}
|
||||
|
||||
lv_obj_set_width(wdata->title, lv_win_get_width(app->win));
|
||||
}
|
||||
app = lv_app_get_next(app, &my_app_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
static void save_conf(lv_app_inst_t * app)
|
||||
{
|
||||
#ifdef LV_APP_WIFI_CONF_PATH
|
||||
my_app_data_t * adata = app->app_data;
|
||||
|
||||
fs_file_t f;
|
||||
fs_res_t res;
|
||||
res = fs_open(&f, LV_APP_WIFI_CONF_PATH, FS_MODE_WR);
|
||||
if(res == FS_RES_OK) {
|
||||
char buf[256];
|
||||
sprintf(buf,"%s\n%s\n%s\n%s", adata->set_ssid, adata->set_pwd, adata->set_ip, adata->set_port);
|
||||
fs_write(&f, buf, strlen(buf) + 1, NULL);
|
||||
fs_close(&f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* @file lv_app_example.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_APP_WIFI_H
|
||||
#define LV_APP_WIFI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_WIFI != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_wifi_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
const lv_app_dsc_t * lv_app_wifi_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* LV_APP_EXAMPLE_H */
|
||||
360
lv_conf_templ.h
360
lv_conf_templ.h
@@ -8,55 +8,157 @@
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
/*----------------
|
||||
* Dynamic memory
|
||||
*----------------*/
|
||||
#define LV_MEM_CUSTOM 0 /*1: use custom malloc/free, 0: use the built-in lv_mem_alloc/lv_mem_free*/
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
#define LV_MEM_SIZE (32U * 1024U) /*Size memory used by mem_alloc (in bytes)*/
|
||||
#define LV_MEM_ATTR /*Complier prefix for big array declaration*/
|
||||
#define LV_MEM_AUTO_DEFRAG 1 /*Automatically defrag on free*/
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||
#define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
|
||||
#define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/*===================
|
||||
Graphical settings
|
||||
*=====================*/
|
||||
|
||||
/* Horizontal and vertical resolution of the library.
|
||||
* Screen resolution multiplied by LV_DOWN_SCALE*/
|
||||
#define LV_HOR_RES (320 * LV_DOWNSCALE)
|
||||
#define LV_VER_RES (240 * LV_DOWNSCALE)
|
||||
#define LV_DPI (80 * LV_DOWNSCALE)
|
||||
/* Enable anti-aliasing
|
||||
* If enabled everything will half-sized
|
||||
* Use LV_DOWNSCALE to compensate he down scaling effect of anti-aliasing*/
|
||||
#define LV_ANTIALIAS 1
|
||||
#define LV_DOWNSCALE (1 << LV_ANTIALIAS) /*Set the downscaling value*/
|
||||
/* Horizontal and vertical resolution of the library.*/
|
||||
#define LV_HOR_RES (480)
|
||||
#define LV_VER_RES (320)
|
||||
#define LV_DPI 100
|
||||
|
||||
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
|
||||
#define LV_VDB_SIZE (LV_HOR_RES * LV_VER_RES / 20)
|
||||
#if LV_VDB_SIZE
|
||||
/* Double virtual buffering
|
||||
* One for rendering another to transfer former rendered image to frame buffer in the background*/
|
||||
/* Buffered rendering: >= LV_DOWNSCALE * lv_disp_hor_res() or 0 to disable buffering*/
|
||||
#define LV_VDB_SIZE (20 * 1024)
|
||||
#define LV_VDB_ADR 0 /*Place VDB to a specific address (e.g. in external RAM) (0: allocate into RAM)*/
|
||||
|
||||
/* Use two Virtual Display buffers (VDB) parallelize rendering and flushing
|
||||
* The flushing should use DMA to write the frame buffer in the background*/
|
||||
#define LV_VDB_DOUBLE 0
|
||||
#endif
|
||||
#define LV_VDB2_ADR 0 /*Place VDB2 to a specific address (e.g. in external RAM) (0: allocate into RAM)*/
|
||||
|
||||
#define LV_REFR_PERIOD 40 /*Screen refresh period in milliseconds*/
|
||||
#define LV_INV_FIFO_SIZE 32 /*The average number of objects on a screen */
|
||||
/* Enable anti aliasing
|
||||
* If enabled everything will be rendered in double size and filtered to normal size */
|
||||
#define LV_ANTIALIAS 1
|
||||
|
||||
/* Enable anti aliasing only for fonts (texts)
|
||||
* It half the size of the letters so you should use double sized fonts
|
||||
* Much faster then normal anti aliasing */
|
||||
#define LV_FONT_ANTIALIAS 0
|
||||
|
||||
/*Screen refresh settings*/
|
||||
#define LV_REFR_PERIOD 50 /*Screen refresh period in milliseconds*/
|
||||
#define LV_INV_FIFO_SIZE 32 /*The average count of objects on a screen */
|
||||
|
||||
/*=================
|
||||
Misc. setting
|
||||
*=================*/
|
||||
/*Display Input settings*/
|
||||
#define LV_DISPI_READ_PERIOD 50 /*Input device read period milliseconds*/
|
||||
#define LV_DISPI_TP_MARKER 0 /*Mark the pressed points (Value means marker point size)*/
|
||||
#define LV_DISPI_DRAG_LIMIT (10 * LV_DOWNSCALE) /*Drag threshold in pixels */
|
||||
#define LV_DISPI_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_DISPI_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_DISPI_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
|
||||
/*lv_obj (base object) settings*/
|
||||
#define LV_OBJ_FREE_NUM 1 /*Enable the free number attribute*/
|
||||
#define LV_OBJ_FREE_P 1 /*Enable the free pointer attribute*/
|
||||
#define LV_OBJ_GROUP 1 /*Enable object groups*/
|
||||
/*Input device settings*/
|
||||
#define LV_INDEV_READ_PERIOD 50 /*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_POINT_MARKER 0 /*Mark the pressed points*/
|
||||
#define LV_INDEV_DRAG_LIMIT 10 /*Drag threshold in pixels */
|
||||
#define LV_INDEV_DRAG_THROW 20 /*Drag throw slow-down in [%]. Greater value means faster slow-down */
|
||||
#define LV_INDEV_LONG_PRESS_TIME 400 /*Long press time in milliseconds*/
|
||||
#define LV_INDEV_LONG_PRESS_REP_TIME 100 /*Repeated trigger period in long press [ms] */
|
||||
|
||||
/*Others*/
|
||||
#define LV_COLOR_TRANSP COLOR_LIME /*This could mean transparent pixel*/
|
||||
#define USE_LV_EXAMPLE 1 /*Enable examples (lvgl/lv_examples/). Disable to save memory*/
|
||||
/*Color settings*/
|
||||
#define LV_COLOR_DEPTH 16
|
||||
#define LV_COLOR_TRANSP LV_COLOR_LIME /*Images pixels with this color will not be drawn (chroma keying)*/
|
||||
|
||||
/*Text settings*/
|
||||
#define LV_TXT_UTF8 1
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_" /*Can break texts on these chars*/
|
||||
|
||||
/*Graphics feature usage*/
|
||||
#define USE_LV_ANIMATION 1 /*1: disable all animations*/
|
||||
#define USE_LV_SHADOW 1 /*1: disable shadows*/
|
||||
#define USE_LV_GROUP 1 /*1: Enable object groups (for keyboards)*/
|
||||
#define USE_LV_GPU 0 /*1: Enable GPU interface*/
|
||||
#define USE_LV_FILESYSTEM 1 /*1: Enable file system (required by images aka. lv_img)*/
|
||||
|
||||
/*================
|
||||
* THEME USAGE
|
||||
*================*/
|
||||
#define USE_LV_THEME_TEMPL 0 /*Just for test*/
|
||||
#define USE_LV_THEME_DEFAULT 1 /*Built mainly from the built-in styles. Consumes very few RAM*/
|
||||
#define USE_LV_THEME_ALIEN 1 /*Dark futuristic theme*/
|
||||
#define USE_LV_THEME_NIGHT 1 /*Dark elegant theme*/
|
||||
#define USE_LV_THEME_MONO 1 /*Mono color theme for monochrome displays*/
|
||||
#define USE_LV_THEME_MATERIAL 1 /*Flat theme with bold colors and light shadows*/
|
||||
#define USE_LV_THEME_ZEN 1 /*Peaceful, mainly light theme */
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
*===================*/
|
||||
#define LV_FONT_DEFAULT &lv_font_dejavu_40 /*Always set a default font from the built-in fonts*/
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_10 0
|
||||
#define USE_LV_FONT_DEJAVU_10_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_EXT_A 0
|
||||
#define USE_LV_FONT_DEJAVU_10_LATIN_EXT_B 0
|
||||
#define USE_LV_FONT_DEJAVU_10_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_10_BASIC 0
|
||||
#define USE_LV_FONT_SYMBOL_10_FILE 0
|
||||
#define USE_LV_FONT_SYMBOL_10_FEEDBACK 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_20 0
|
||||
#define USE_LV_FONT_DEJAVU_20_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_20_LATIN_EXT_A 0
|
||||
#define USE_LV_FONT_DEJAVU_20_LATIN_EXT_B 0
|
||||
#define USE_LV_FONT_DEJAVU_20_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_20_BASIC 0
|
||||
#define USE_LV_FONT_SYMBOL_20_FILE 0
|
||||
#define USE_LV_FONT_SYMBOL_20_FEEDBACK 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_30 0
|
||||
#define USE_LV_FONT_DEJAVU_30_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_EXT_A 0
|
||||
#define USE_LV_FONT_DEJAVU_30_LATIN_EXT_B 0
|
||||
#define USE_LV_FONT_DEJAVU_30_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_30_BASIC 0
|
||||
#define USE_LV_FONT_SYMBOL_30_FILE 0
|
||||
#define USE_LV_FONT_SYMBOL_30_FEEDBACK 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_40 1
|
||||
#define USE_LV_FONT_DEJAVU_40_SUP 1
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_EXT_A 1
|
||||
#define USE_LV_FONT_DEJAVU_40_LATIN_EXT_B 1
|
||||
#define USE_LV_FONT_DEJAVU_40_CYRILLIC 1
|
||||
#define USE_LV_FONT_SYMBOL_40_BASIC 1
|
||||
#define USE_LV_FONT_SYMBOL_40_FILE 1
|
||||
#define USE_LV_FONT_SYMBOL_40_FEEDBACK 1
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_60 0
|
||||
#define USE_LV_FONT_DEJAVU_60_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_60_LATIN_EXT_A 0
|
||||
#define USE_LV_FONT_DEJAVU_60_LATIN_EXT_B 0
|
||||
#define USE_LV_FONT_DEJAVU_60_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_60_BASIC 0
|
||||
#define USE_LV_FONT_SYMBOL_60_FILE 0
|
||||
#define USE_LV_FONT_SYMBOL_60_FEEDBACK 0
|
||||
|
||||
#define USE_LV_FONT_DEJAVU_80 0
|
||||
#define USE_LV_FONT_DEJAVU_80_SUP 0
|
||||
#define USE_LV_FONT_DEJAVU_80_LATIN_EXT_A 0
|
||||
#define USE_LV_FONT_DEJAVU_80_LATIN_EXT_B 0
|
||||
#define USE_LV_FONT_DEJAVU_80_CYRILLIC 0
|
||||
#define USE_LV_FONT_SYMBOL_80_BASIC 0
|
||||
#define USE_LV_FONT_SYMBOL_80_FILE 0
|
||||
#define USE_LV_FONT_SYMBOL_80_FEEDBACK 0
|
||||
|
||||
/*===================
|
||||
* LV_OBJ SETTINGS
|
||||
*==================*/
|
||||
#define LV_OBJ_FREE_NUM_TYPE uint32_t /*Type of free number attribute (comment out disable free number)*/
|
||||
#define LV_OBJ_FREE_PTR 1 /*Enable the free pointer attribute*/
|
||||
|
||||
/*==================
|
||||
* LV OBJ X USAGE
|
||||
* ================*/
|
||||
*================*/
|
||||
|
||||
/*****************
|
||||
* Simple object
|
||||
@@ -65,30 +167,17 @@
|
||||
/*Label (dependencies: -*/
|
||||
#define USE_LV_LABEL 1
|
||||
#if USE_LV_LABEL != 0
|
||||
#define LV_LABEL_SCROLL_SPEED (25 * LV_DOWNSCALE) /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL' mode*/
|
||||
#define LV_LABEL_SCROLL_SPEED_VER (10 * LV_DOWNSCALE) /*Ver. scroll speed if hor. scroll is applied too*/
|
||||
#define LV_LABEL_SCROLL_PLAYBACK_PAUSE 500 /*Wait before the scroll turns back in ms*/
|
||||
#define LV_LABEL_SCROLL_REPEAT_PAUSE 500 /*Wait before the scroll begins again in ms*/
|
||||
#define LV_LABEL_SCROLL_SPEED 25 /*Hor, or ver. scroll speed (px/sec) in 'LV_LABEL_LONG_SCROLL/ROLL' mode*/
|
||||
#endif
|
||||
|
||||
/*Image (dependencies: lv_label (if symbols are enabled) from misc: FSINT, UFS)*/
|
||||
#define USE_LV_IMG 1
|
||||
#if USE_LV_IMG != 0
|
||||
//#define LV_IMG_DEF_WALLPAPER img_square_x1 /*Comment this line to NOT use wallpaper*/
|
||||
/* 1: enables to interpret the file names as symbol name
|
||||
* from symbol_def.h if they begin with a lower case letter.
|
||||
* (driver letters are always upper case)*/
|
||||
#define LV_IMG_ENABLE_SYMBOLS 1
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#define LV_IMG_DEF_SYMBOL_FONT FONT_SYMBOL_30
|
||||
#endif /*LV_IMG_ENABLE_SYMBOLS*/
|
||||
#endif /*USE_LV_IMG*/
|
||||
|
||||
/*Line (dependencies: -*/
|
||||
#define USE_LV_LINE 1
|
||||
|
||||
/*******************
|
||||
* Container object
|
||||
* Container objects
|
||||
*******************/
|
||||
|
||||
/*Container (dependencies: -*/
|
||||
@@ -100,21 +189,24 @@
|
||||
/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/
|
||||
#define USE_LV_WIN 1
|
||||
|
||||
/*Tab (dependencies: lv_page, lv_btnm)*/
|
||||
#define USE_LV_TABVIEW 1
|
||||
#if USE_LV_TABVIEW != 0
|
||||
#define LV_TABVIEW_ANIM_TIME 300 /*Time of slide animation [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
* Data visualizer object
|
||||
* Data visualizer objects
|
||||
*************************/
|
||||
|
||||
/*Bar (dependencies: -)*/
|
||||
#define USE_LV_BAR 1
|
||||
#define USE_LV_BAR 1
|
||||
|
||||
/*Line meter (dependencies: bar; misc: trigo)*/
|
||||
/*Line meter (dependencies: *;)*/
|
||||
#define USE_LV_LMETER 1
|
||||
|
||||
/*Gauge (dependencies:bar, lmeter; misc: trigo)*/
|
||||
/*Gauge (dependencies:bar, lmeter)*/
|
||||
#define USE_LV_GAUGE 1
|
||||
#if USE_LV_GAUGE != 0
|
||||
#define LV_GAUGE_MAX_NEEDLE 4 /*Max number of needles. Used in the style.*/
|
||||
#endif
|
||||
|
||||
/*Chart (dependencies: -)*/
|
||||
#define USE_LV_CHART 1
|
||||
@@ -122,19 +214,18 @@
|
||||
/*LED (dependencies: -)*/
|
||||
#define USE_LV_LED 1
|
||||
|
||||
/*Message box (dependencies: lv_rect, lv_btn, lv_label)*/
|
||||
/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/
|
||||
#define USE_LV_MBOX 1
|
||||
|
||||
/*Text area (dependencies: lv_label, lv_page)*/
|
||||
#define USE_LV_TA 1
|
||||
#if USE_LV_TA != 0
|
||||
#define LV_TA_MAX_LENGTH 256
|
||||
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
|
||||
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#define LV_TA_CURSOR_BLINK_TIME 400 /*ms*/
|
||||
#define LV_TA_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
* User input object
|
||||
* User input objects
|
||||
*************************/
|
||||
|
||||
/*Button (dependencies: lv_cont*/
|
||||
@@ -143,154 +234,37 @@
|
||||
/*Button matrix (dependencies: -)*/
|
||||
#define USE_LV_BTNM 1
|
||||
|
||||
/*Keyboard (dependencies: lv_btnm)*/
|
||||
#define USE_LV_KB 1
|
||||
|
||||
/*Check box (dependencies: lv_btn, lv_label)*/
|
||||
#define USE_LV_CB 1
|
||||
|
||||
/*List (dependencies: lv_page, lv_btn, lv_label, lv_img)*/
|
||||
/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/
|
||||
#define USE_LV_LIST 1
|
||||
#if USE_LV_LIST != 0
|
||||
#define LV_LIST_FOCUS_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
|
||||
#define LV_LIST_FOCUS_TIME 100 /*Default animation time of focusing to a list element [ms] (0: no animation) */
|
||||
#endif
|
||||
|
||||
/*Drop down list (dependencies: lv_page, lv_label)*/
|
||||
#define USE_LV_DDLIST 1
|
||||
#if USE_LV_DDLIST != 0
|
||||
#define LV_DDLIST_ANIM_TIME 200 /*Open and close default animation time [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*Roller (dependencies: lv_ddlist)*/
|
||||
#define USE_LV_ROLLER 1
|
||||
#if USE_LV_ROLLER != 0
|
||||
#define LV_ROLLER_ANIM_TIME 200 /*Focus animation time [ms] (0: no animation)*/
|
||||
#endif
|
||||
|
||||
/*Slider (dependencies: lv_bar)*/
|
||||
#define USE_LV_SLIDER 1
|
||||
|
||||
/*==================
|
||||
* LV APP SETTINGS
|
||||
* =================*/
|
||||
|
||||
/*Enable the application system*/
|
||||
#define LV_APP_ENABLE 0
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/****************************
|
||||
* Basic application settings
|
||||
*****************************/
|
||||
#define LV_APP_DESKTOP 1 /*Create a desktop-like environment*/
|
||||
|
||||
#define LV_APP_SC_WIDTH (LV_DPI * 2) /*Shortcut width*/
|
||||
#define LV_APP_SC_HEIGHT (3 * LV_DPI / 2) /*Shortcut height*/
|
||||
#define LV_APP_FONT_SMALL FONT_DEJAVU_20 /*A small font*/
|
||||
#define LV_APP_FONT_MEDIUM FONT_DEFAULT /*A medium font*/
|
||||
#define LV_APP_FONT_LARGE FONT_DEJAVU_40 /*A large font*/
|
||||
|
||||
/***********************
|
||||
* Animation settings
|
||||
***********************/
|
||||
#define LV_APP_ANIM_WIN 200 /*Animation time of windows [ms] (0: turn off animations)*/
|
||||
#define LV_APP_ANIM_DESKTOP 200 /*Animation time the desktop [ms] (0: turn off animations)*/
|
||||
|
||||
/************************
|
||||
* App. utility settings
|
||||
************************/
|
||||
|
||||
/*Notice*/
|
||||
#define USE_LV_APP_NOTICE 1
|
||||
#if USE_LV_APP_NOTICE != 0
|
||||
#define LV_APP_NOTICE_SHOW_TIME 4000 /*Notices will be shown for this time [ms]*/
|
||||
#define LV_APP_NOTICE_CLOSE_ANIM_TIME 300 /*Notice close animation time. [ms] 0: no animation */
|
||||
#define LV_APP_NOTICE_MAX_NUM 6 /*Max. number of notices*/
|
||||
#define LV_APP_NOTICE_MAX_LEN 256 /*Max. number of characters on a notice*/
|
||||
#endif
|
||||
|
||||
/*File selector*/
|
||||
#define USE_LV_APP_FSEL 1
|
||||
#if USE_LV_APP_FSEL != 0
|
||||
#define LV_APP_FSEL_PAGE_SIZE 8 /*Max. number of files/folder on a page*/
|
||||
#define LV_APP_FSEL_FN_MAX_LEN 32 /*Max file name length*/
|
||||
#define LV_APP_FSEL_PATH_MAX_LEN 256 /*Max path length*/
|
||||
#endif
|
||||
|
||||
/*Keyboard*/
|
||||
#define USE_LV_APP_KB 1
|
||||
#if USE_LV_APP_KB != 0
|
||||
#define LV_APP_KB_ANIM_TIME 300 /*ms*/
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* LV APP X USAGE
|
||||
* ================*/
|
||||
|
||||
/*Example application*/
|
||||
#define USE_LV_APP_EXAMPLE 1
|
||||
|
||||
/*Phantom application*/
|
||||
#define USE_LV_APP_PHANTOM 1
|
||||
#if USE_LV_APP_PHANTOM != 0
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*System monitor*/
|
||||
#define USE_LV_APP_SYSMON 1
|
||||
#if USE_LV_APP_SYSMON != 0
|
||||
#define LV_APP_SYSMON_REFR_TIME 500 /*Mem. and CPU usage read period [ms]*/
|
||||
#define LV_APP_SYSMON_PNUM 64 /*Number of point on the window's chart*/
|
||||
#define LV_APP_SYSMON_MEM_WARN (2 * 1024) /*Make a notice less then this remaining memory [bytes]*/
|
||||
#define LV_APP_SYSMON_FRAG_WARN (70) /*Make a notice above this fragmentation level [%]*/
|
||||
#define LV_APP_SYSMON_DEFRAG_PERIOD (5000) /*Auto-defrag period [ms]*/
|
||||
#endif /*USE_LV_APP_SYSMON != 0*/
|
||||
|
||||
/*Terminal*/
|
||||
#define USE_LV_APP_TERMINAL 1
|
||||
#if USE_LV_APP_TERMINAL != 0
|
||||
#define LV_APP_TERMINAL_LENGTH 512 /*Memory of the terminal [character number]*/
|
||||
#endif /*USE_LV_APP_TERMINAL != 0*/
|
||||
|
||||
/*Files*/
|
||||
#define USE_LV_APP_FILES 1
|
||||
#if USE_LV_APP_FILES != 0
|
||||
#define LV_APP_FILES_PAGE_SIZE 8 /*Max. number of files/folder on a page*/
|
||||
#define LV_APP_FILES_FN_MAX_LEN 32 /*Max file name length*/
|
||||
#define LV_APP_FILES_PATH_MAX_LEN 256 /*Max path length*/
|
||||
#define LV_APP_FILES_CHUNK_DEF_SIZE 256 /*Chunk size when sending a file*/
|
||||
#define LV_APP_FILES_CHUNK_DEF_TIME 100 /*Delay between sent chunks*/
|
||||
#define LV_APP_FILES_CHUNK_MAX_SIZE 1024 /*Max chunk size when the user sets it*/
|
||||
#endif /*USE_LV_APP_FILES != 0*/
|
||||
|
||||
/*Benchmark*/
|
||||
#define USE_LV_APP_BENCHMARK 1
|
||||
#if USE_LV_APP_BENCHMARK != 0
|
||||
/*No settings*/
|
||||
#endif
|
||||
|
||||
/*WiFi*/
|
||||
#define USE_LV_APP_WIFI 0
|
||||
#if USE_LV_APP_WIFI != 0
|
||||
#define LV_APP_WIFI_CONF_PATH "S:/wifi_conf.txt" /*Save config. here. Comment to use def. value*/
|
||||
#ifndef LV_APP_WIFI_CONF_PATH
|
||||
#define LV_APP_WIFI_SSID_DEF "ssid"
|
||||
#define LV_APP_WIFI_PWD_DEF "pwd"
|
||||
#define LV_APP_WIFI_IP_DEF "100.101.102.103"
|
||||
#define LV_APP_WIFI_PORT_DEF "1234"
|
||||
#endif /*LV_APP_WIFI_CONF_PATH*/
|
||||
#define LV_APP_WIFI_AUTO_CONNECT 1 /*Try to connect at start up to the deafult SSID and IP:PORT*/
|
||||
#endif /*USE_LV_APP_WIFI != 0*/
|
||||
|
||||
/*GSM*/
|
||||
#define USE_LV_APP_GSM 0
|
||||
#if USE_LV_APP_GSM != 0
|
||||
#define LV_APP_GSM_CONF_PATH "S:/gsm_conf.txt" /*Save config. here. Comment to use def. value*/
|
||||
#ifndef LV_APP_GSM_CONF_PATH
|
||||
#define LV_APP_GSM_APN_DEF "apn"
|
||||
#define LV_APP_GSM_IP_DEF "101.102.103.104"
|
||||
#define LV_APP_GSM_PORT_DEF "1234"
|
||||
#endif /*LV_APP_GSM_CONF_PATH*/
|
||||
#define LV_APP_GSM_AUTO_CONNECT 1 /*Try to connect at start up with the deafult APN and IP:PORT*/
|
||||
#endif /*USE_LV_APP_GSM != 0*/
|
||||
|
||||
/*Ethernet*/
|
||||
#define USE_LV_APP_ETHERNET 0
|
||||
#if USE_LV_APP_ETHERNET != 0
|
||||
/*No settings*/
|
||||
#endif /*USE_LV_APP_ETHERNET != 0*/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
/*Switch (dependencies: lv_slider)*/
|
||||
#define USE_LV_SW 1
|
||||
|
||||
#endif /*LV_CONF_H*/
|
||||
|
||||
|
||||
#endif /*Remove this to enable the content*/
|
||||
|
||||
|
||||
11
lv_core/lv_core.mk
Normal file
11
lv_core/lv_core.mk
Normal file
@@ -0,0 +1,11 @@
|
||||
CSRCS += lv_group.c
|
||||
CSRCS += lv_indev.c
|
||||
CSRCS += lv_obj.c
|
||||
CSRCS += lv_refr.c
|
||||
CSRCS += lv_style.c
|
||||
CSRCS += lv_vdb.c
|
||||
|
||||
DEPPATH += --dep-path lvgl/lv_core
|
||||
VPATH += :lvgl/lv_core
|
||||
|
||||
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_core"
|
||||
@@ -7,7 +7,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_group.h"
|
||||
#if LV_OBJ_GROUP != 0
|
||||
#if USE_LV_GROUP != 0
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
@@ -41,8 +41,8 @@ static void style_mod_def(lv_style_t * style);
|
||||
*/
|
||||
lv_group_t * lv_group_create(void)
|
||||
{
|
||||
lv_group_t * group = dm_alloc(sizeof(lv_group_t));
|
||||
ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
lv_group_t * group = lv_mem_alloc(sizeof(lv_group_t));
|
||||
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
||||
|
||||
group->style_mod = style_mod_def;
|
||||
group->obj_focus = NULL;
|
||||
@@ -59,29 +59,31 @@ lv_group_t * lv_group_create(void)
|
||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
||||
{
|
||||
obj->group_p = group;
|
||||
lv_obj_t ** next = ll_ins_tail(&group->obj_ll);
|
||||
lv_obj_t ** next = lv_ll_ins_tail(&group->obj_ll);
|
||||
*next = obj;
|
||||
|
||||
/* If the head and the tail is equal then there is only one object in the linked list.
|
||||
* In this case automatically activate it*/
|
||||
if(ll_get_head(&group->obj_ll) == next) {
|
||||
if(lv_ll_get_head(&group->obj_ll) == next) {
|
||||
lv_group_focus_next(group);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an object from its group
|
||||
* @param obj pointer to an objectto remove
|
||||
* @param obj pointer to an object to remove
|
||||
*/
|
||||
void lv_group_rem_obj(lv_obj_t * obj)
|
||||
void lv_group_remove_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_group_t * g = obj->group_p;
|
||||
if(g == NULL) return;
|
||||
lv_obj_t ** i;
|
||||
|
||||
/*Search the object and remove it from its group */
|
||||
lv_obj_t ** i;
|
||||
LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
ll_rem(&g->obj_ll, i);
|
||||
lv_ll_rem(&g->obj_ll, i);
|
||||
obj->group_p = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +94,6 @@ void lv_group_rem_obj(lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Focus on an object (defocus the current)
|
||||
* @param obj pointer to an object to focus on
|
||||
@@ -109,15 +110,15 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
LL_READ(g->obj_ll, i) {
|
||||
if(*i == obj) {
|
||||
if(g->obj_focus != NULL) {
|
||||
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*g->obj_focus);
|
||||
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
|
||||
g->obj_focus = i;
|
||||
|
||||
if(g->obj_focus != NULL){
|
||||
(*g->obj_focus)->signal_f(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*g->obj_focus);
|
||||
(*g->obj_focus)->signal_func(*g->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*g->obj_focus);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -130,23 +131,23 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
||||
*/
|
||||
void lv_group_focus_next(lv_group_t * group)
|
||||
{
|
||||
if(group->frozen != 0) return;
|
||||
if(group->frozen) return;
|
||||
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = ll_get_head(&group->obj_ll);
|
||||
else obj_next = ll_get_next(&group->obj_ll, group->obj_focus);
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_next(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) obj_next = ll_get_head(&group->obj_ll);
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_head(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
if(group->obj_focus){
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,23 +157,23 @@ void lv_group_focus_next(lv_group_t * group)
|
||||
*/
|
||||
void lv_group_focus_prev(lv_group_t * group)
|
||||
{
|
||||
if(group->frozen != 0) return;
|
||||
if(group->frozen) return;
|
||||
|
||||
if(group->obj_focus != NULL) {
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
if(group->obj_focus) {
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
lv_obj_t ** obj_next;
|
||||
if(group->obj_focus == NULL) obj_next = ll_get_tail(&group->obj_ll);
|
||||
else obj_next = ll_get_prev(&group->obj_ll, group->obj_focus);
|
||||
if(group->obj_focus == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
else obj_next = lv_ll_get_prev(&group->obj_ll, group->obj_focus);
|
||||
|
||||
if(obj_next == NULL) obj_next = ll_get_tail(&group->obj_ll);
|
||||
if(obj_next == NULL) obj_next = lv_ll_get_tail(&group->obj_ll);
|
||||
group->obj_focus = obj_next;
|
||||
|
||||
if(group->obj_focus != NULL){
|
||||
(*group->obj_focus)->signal_f(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_inv(*group->obj_focus);
|
||||
(*group->obj_focus)->signal_func(*group->obj_focus, LV_SIGNAL_FOCUS, NULL);
|
||||
lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -191,14 +192,14 @@ void lv_group_focus_freeze(lv_group_t * group, bool en)
|
||||
/**
|
||||
* Send a control character to the focuses object of a group
|
||||
* @param group pointer to a group
|
||||
* @param c a control character (use LV_GROUP_KEY_.. to navigate)
|
||||
* @param c a character (use LV_GROUP_KEY_.. to navigate)
|
||||
*/
|
||||
void lv_group_send(lv_group_t * group, char c)
|
||||
void lv_group_send_data(lv_group_t * group, uint32_t c)
|
||||
{
|
||||
lv_obj_t * act = lv_group_get_focused(group);
|
||||
if(act == NULL) return;
|
||||
|
||||
act->signal_f(act, LV_SIGNAL_CONTROLL, &c);
|
||||
act->signal_func(act, LV_SIGNAL_CONTROLL, &c);
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +211,7 @@ void lv_group_send(lv_group_t * group, char c)
|
||||
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style))
|
||||
{
|
||||
group->style_mod = style_cb;
|
||||
if(group->obj_focus != NULL) lv_obj_inv(*group->obj_focus);
|
||||
if(group->obj_focus != NULL) lv_obj_invalidate(*group->obj_focus);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +222,7 @@ void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t *
|
||||
*/
|
||||
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style)
|
||||
{
|
||||
lv_style_cpy(&group->style_tmp, style);
|
||||
lv_style_copy(&group->style_tmp, style);
|
||||
|
||||
if(group->style_mod != NULL) group->style_mod(&group->style_tmp);
|
||||
else style_mod_def(&group->style_tmp);
|
||||
@@ -248,17 +249,22 @@ lv_obj_t * lv_group_get_focused(lv_group_t * group)
|
||||
|
||||
/**
|
||||
* Default style modifier function
|
||||
* @param style pointer to a style to modify. (Typically &group->style_tmp) It will be OVERWRITTEN.
|
||||
* @param style pointer to a style to modify. (Typically group.style_tmp) It will be OVERWRITTEN.
|
||||
*/
|
||||
static void style_mod_def(lv_style_t * style)
|
||||
{
|
||||
/*Make the style a little bit orange*/
|
||||
style->bcolor = COLOR_ORANGE;
|
||||
style->bopa = OPA_COVER;
|
||||
if(style->bwidth == 0 && style->empty == 0) style->bwidth = 2 * LV_DOWNSCALE; /*Add border to not transparent styles*/
|
||||
else style->bwidth = style->bwidth * 2; /*Make the border thicker*/
|
||||
style->mcolor = color_mix(style->mcolor, COLOR_ORANGE, OPA_80);
|
||||
style->gcolor = color_mix(style->gcolor, COLOR_ORANGE, OPA_80);
|
||||
/*Make the style to be a little bit orange*/
|
||||
style->body.border.opa = LV_OPA_COVER;
|
||||
style->body.border.color = LV_COLOR_ORANGE;
|
||||
|
||||
/*If not empty or has border then emphasis the border*/
|
||||
if(style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20;
|
||||
|
||||
style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
style->body.shadow.color = lv_color_mix(style->body.shadow.color, LV_COLOR_ORANGE, LV_OPA_60);
|
||||
|
||||
style->text.color = lv_color_mix(style->text.color, LV_COLOR_ORANGE, LV_OPA_70);
|
||||
}
|
||||
|
||||
#endif /*LV_OBJ_GROUP != 0*/
|
||||
#endif /*USE_LV_GROUP != 0*/
|
||||
134
lv_core/lv_group.h
Normal file
134
lv_core/lv_group.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file lv_group.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_GROUP_H
|
||||
#define LV_GROUP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/*Predefined keys to control the focused object via lv_group_send(group, c)*/
|
||||
/*For compatibility in signal function define the keys regardless to LV_GROUP*/
|
||||
#define LV_GROUP_KEY_UP 17 /*0x11*/
|
||||
#define LV_GROUP_KEY_DOWN 18 /*0x12*/
|
||||
#define LV_GROUP_KEY_RIGHT 19 /*0x13*/
|
||||
#define LV_GROUP_KEY_LEFT 20 /*0x14*/
|
||||
#define LV_GROUP_KEY_ESC 33 /*0x1B*/
|
||||
#define LV_GROUP_KEY_ENTER 10 /*0x0A, '\n'*/
|
||||
#define LV_GROUP_KEY_NEXT 9 /*0x09, '\t'*/
|
||||
#define LV_GROUP_KEY_PREV 11 /*0x0B, '*/
|
||||
|
||||
#if USE_LV_GROUP != 0
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct _lv_group_t
|
||||
{
|
||||
lv_ll_t obj_ll;
|
||||
lv_obj_t ** obj_focus;
|
||||
void (*style_mod)(lv_style_t * style);
|
||||
lv_style_t style_tmp;
|
||||
uint8_t frozen:1;
|
||||
}lv_group_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a new object group
|
||||
* @return pointer to the new object group
|
||||
*/
|
||||
lv_group_t * lv_group_create(void);
|
||||
|
||||
/**
|
||||
* Add an object to a group
|
||||
* @param group pointer to a group
|
||||
* @param obj pointer to an object to add
|
||||
*/
|
||||
void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Remove an object from its group
|
||||
* @param obj pointer to an object to remove
|
||||
*/
|
||||
void lv_group_remove_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Focus on an object (defocus the current)
|
||||
* @param obj pointer to an object to focus on
|
||||
*/
|
||||
void lv_group_focus_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Focus the next object in a group (defocus the current)
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_focus_next(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Focus the previous object in a group (defocus the current)
|
||||
* @param group pointer to a group
|
||||
*/
|
||||
void lv_group_focus_prev(lv_group_t * group);
|
||||
|
||||
/**
|
||||
* Do not let to change the focus from the current object
|
||||
* @param group pointer to a group
|
||||
* @param en true: freeze, false: release freezing (normal mode)
|
||||
*/
|
||||
void lv_group_focus_freeze(lv_group_t * group, bool en);
|
||||
|
||||
/**
|
||||
* Send a control character to the focuses object of a group
|
||||
* @param group pointer to a group
|
||||
* @param c a character (use LV_GROUP_KEY_.. to navigate)
|
||||
*/
|
||||
void lv_group_send_data(lv_group_t * group, uint32_t c);
|
||||
|
||||
|
||||
/**
|
||||
* Set a function for a group which will modify the object's style if it is in focus
|
||||
* @param group pointer to a group
|
||||
* @param style_cb the style modifier function pointer
|
||||
*/
|
||||
void lv_group_set_style_mod_cb(lv_group_t * group, void (*style_cb)(lv_style_t * style));
|
||||
|
||||
/**
|
||||
* Modify a style with the set 'style_mod' function. The input style remains unchanged.
|
||||
* @param group pointer to group
|
||||
* @param style pointer to a style to modify
|
||||
* @return a copy of the input style but modified with the 'style_mod' function
|
||||
*/
|
||||
lv_style_t * lv_group_mod_style(lv_group_t * group, const lv_style_t * style);
|
||||
|
||||
/**
|
||||
* Get the focused object or NULL if there isn't one
|
||||
* @param group pointer to a group
|
||||
* @return pointer to the focused object
|
||||
*/
|
||||
lv_obj_t * lv_group_get_focused(lv_group_t * group);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_GROUP != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_GROUP_H*/
|
||||
624
lv_core/lv_indev.c
Normal file
624
lv_core/lv_indev.c
Normal file
@@ -0,0 +1,624 @@
|
||||
/**
|
||||
* @file lv_indev_proc.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
********************/
|
||||
#include "lv_indev.h"
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void indev_proc_task(void * param);
|
||||
static void indev_proc_point(lv_indev_proc_t * indev);
|
||||
static void indev_proc_press(lv_indev_proc_t * info);
|
||||
static void indev_proc_release(lv_indev_proc_t * state);
|
||||
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj);
|
||||
static void indev_drag(lv_indev_proc_t * state);
|
||||
static void indev_drag_throw(lv_indev_proc_t * state);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_task_t *indev_proc_task_p;
|
||||
static lv_indev_t *indev_act;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the display input device subsystem
|
||||
*/
|
||||
void lv_indev_init(void)
|
||||
{
|
||||
#if LV_INDEV_READ_PERIOD != 0
|
||||
indev_proc_task_p = lv_task_create(indev_proc_task, LV_INDEV_READ_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
#else
|
||||
indev_proc_task_p = lv_task_create(indev_proc_task, 1, LV_TASK_PRIO_OFF); /*Not use lv_indev_proc*/
|
||||
#endif
|
||||
|
||||
lv_indev_reset(NULL); /*Reset all input devices*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently processed input device. Can be used in action functions too.
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing right now
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_act(void)
|
||||
{
|
||||
return indev_act;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset one or all input devices
|
||||
* @param indev pointer to an input device to reset or NULL to reset all of them
|
||||
*/
|
||||
void lv_indev_reset(lv_indev_t * indev)
|
||||
{
|
||||
if(indev) indev->proc.reset_query = 1;
|
||||
else {
|
||||
lv_indev_t * i = lv_indev_next(NULL);
|
||||
while(i) {
|
||||
i->proc.reset_query = 1;
|
||||
i = lv_indev_next(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the long press state of an input device
|
||||
* @param indev pointer to an input device
|
||||
*/
|
||||
void lv_indev_reset_lpr(lv_indev_t * indev)
|
||||
{
|
||||
indev->proc.long_pr_sent = 0;
|
||||
indev->proc.longpr_rep_timestamp = lv_tick_get();
|
||||
indev->proc.pr_timestamp = lv_tick_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable input devices device by type
|
||||
* @param type Input device type
|
||||
* @param enable true: enable this type; false: disable this type
|
||||
*/
|
||||
void lv_indev_enable(lv_hal_indev_type_t type, bool enable)
|
||||
{
|
||||
lv_indev_t *i = lv_indev_next(NULL);
|
||||
|
||||
while (i) {
|
||||
if (i->driver.type == type) i->proc.disabled = enable == false ? 1 : 0;
|
||||
i = lv_indev_next(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cursor for a pointer input device
|
||||
* @param indev pointer to an input device (type: 'LV_INDEV_TYPE_POINTER')
|
||||
* @param cur_obj pointer to an object to be used as cursor
|
||||
*/
|
||||
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj)
|
||||
{
|
||||
if(indev->driver.type != LV_INDEV_TYPE_POINTER) return;
|
||||
|
||||
indev->cursor = cur_obj;
|
||||
lv_obj_set_parent(indev->cursor, lv_layer_sys());
|
||||
lv_obj_set_pos(indev->cursor, indev->proc.act_point.x, indev->proc.act_point.y);
|
||||
}
|
||||
|
||||
#if USE_LV_GROUP
|
||||
/**
|
||||
* Set a destination group for a keypad input device
|
||||
* @param indev pointer to an input device (type: 'LV_INDEV_TYPE_KEYPAD')
|
||||
* @param group point to a group
|
||||
*/
|
||||
void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group)
|
||||
{
|
||||
indev->group = group;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the last point of an input device
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_indev_get_point(lv_indev_t * indev, lv_point_t * point)
|
||||
{
|
||||
point->x = indev->proc.act_point.x;
|
||||
point->y = indev->proc.act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is dragging with an input device or not
|
||||
* @param indev pointer to an input device
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_indev_is_dragging(lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return false;
|
||||
return indev->proc.drag_in_prog == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vector of dragging of an input device
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_indev_get_vect(lv_indev_t * indev, lv_point_t * point)
|
||||
{
|
||||
point->x = indev->proc.vect.x;
|
||||
point->y = indev->proc.vect.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elapsed time since last press
|
||||
* @param indev pointer to an input device (NULL to get the overall smallest inactivity)
|
||||
* @return Elapsed ticks (milliseconds) since last press
|
||||
*/
|
||||
uint32_t lv_indev_get_inactive_time(lv_indev_t * indev)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
if(indev) return t = lv_tick_elaps(indev->last_activity_time);
|
||||
|
||||
lv_indev_t *i;
|
||||
t = UINT16_MAX;
|
||||
i = lv_indev_next(NULL);
|
||||
while(i) {
|
||||
t = LV_MATH_MIN(t, lv_tick_elaps(i->last_activity_time));
|
||||
i = lv_indev_next(i);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param indev pointer to an input device
|
||||
*/
|
||||
void lv_indev_wait_release(lv_indev_t * indev)
|
||||
{
|
||||
indev->proc.wait_unil_release = 1;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called periodically to handle the input devices
|
||||
* @param param unused
|
||||
*/
|
||||
static void indev_proc_task(void * param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
lv_indev_data_t data;
|
||||
lv_indev_t * i;
|
||||
i = lv_indev_next(NULL);
|
||||
|
||||
/*Read and process all indevs*/
|
||||
while(i) {
|
||||
indev_act = i;
|
||||
|
||||
/*Handle reset query before processing the point*/
|
||||
if(i->proc.reset_query) {
|
||||
i->proc.act_obj = NULL;
|
||||
i->proc.last_obj = NULL;
|
||||
i->proc.drag_range_out = 0;
|
||||
i->proc.drag_in_prog = 0;
|
||||
i->proc.long_pr_sent = 0;
|
||||
i->proc.pr_timestamp = 0;
|
||||
i->proc.longpr_rep_timestamp = 0;
|
||||
i->proc.drag_sum.x = 0;
|
||||
i->proc.drag_sum.y = 0;
|
||||
i->proc.reset_query = 0;
|
||||
}
|
||||
|
||||
if(i->proc.disabled == 0) {
|
||||
/*Read the data*/
|
||||
lv_indev_read(i, &data);
|
||||
i->proc.state = data.state;
|
||||
|
||||
if(i->proc.state == LV_INDEV_STATE_PR) {
|
||||
i->last_activity_time = lv_tick_get();
|
||||
}
|
||||
|
||||
/*Move the cursor if set and moved*/
|
||||
if(i->driver.type == LV_INDEV_TYPE_POINTER &&
|
||||
i->cursor != NULL &&
|
||||
(i->proc.last_point.x != data.point.x ||
|
||||
i->proc.last_point.y != data.point.y))
|
||||
{
|
||||
lv_obj_set_pos(i->cursor, data.point.x, data.point.y);
|
||||
}
|
||||
|
||||
if(i->driver.type == LV_INDEV_TYPE_POINTER)
|
||||
{
|
||||
i->proc.act_point.x = data.point.x;
|
||||
i->proc.act_point.y = data.point.y;;
|
||||
|
||||
/*Process the current point*/
|
||||
indev_proc_point(&i->proc);
|
||||
}
|
||||
else if (i->driver.type == LV_INDEV_TYPE_KEYPAD) {
|
||||
#if USE_LV_GROUP
|
||||
if(i->group != NULL && data.key != 0 &&
|
||||
data.state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_REL)
|
||||
{
|
||||
if(data.key == LV_GROUP_KEY_NEXT) {
|
||||
lv_group_focus_next(i->group);
|
||||
}
|
||||
else if(data.key == LV_GROUP_KEY_PREV) {
|
||||
lv_group_focus_prev(i->group);
|
||||
}
|
||||
else {
|
||||
lv_group_send_data(i->group, data.key);
|
||||
}
|
||||
}
|
||||
i->proc.last_state = data.state;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*Handle reset query if it happened in during processing*/
|
||||
if(i->proc.reset_query) {
|
||||
i->proc.act_obj = NULL;
|
||||
i->proc.last_obj = NULL;
|
||||
i->proc.drag_range_out = 0;
|
||||
i->proc.drag_in_prog = 0;
|
||||
i->proc.long_pr_sent = 0;
|
||||
i->proc.pr_timestamp = 0;
|
||||
i->proc.longpr_rep_timestamp = 0;
|
||||
i->proc.drag_sum.x = 0;
|
||||
i->proc.drag_sum.y = 0;
|
||||
i->proc.reset_query = 0;
|
||||
}
|
||||
|
||||
i = lv_indev_next(i); /*Go to the next indev*/
|
||||
}
|
||||
|
||||
indev_act = NULL; /*End of indev processing, so no act indev*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Process new points from a input device. indev->state.pressed has to be set
|
||||
* @param indev pointer to an input device state
|
||||
* @param x x coordinate of the next point
|
||||
* @param y y coordinate of the next point
|
||||
*/
|
||||
static void indev_proc_point(lv_indev_proc_t * indev)
|
||||
{
|
||||
if(indev->state == LV_INDEV_STATE_PR){
|
||||
#if LV_INDEV_POINT_MARKER != 0
|
||||
lv_area_t area;
|
||||
area.x1 = indev->act_point.x - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.y1 = indev->act_point.y - (LV_INDEV_POINT_MARKER >> 1);
|
||||
area.x2 = indev->act_point.x + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
area.y2 = indev->act_point.y + ((LV_INDEV_POINT_MARKER >> 1) | 0x1);
|
||||
lv_rfill(&area, NULL, LV_COLOR_MAKE(0xFF, 0, 0), LV_OPA_COVER);
|
||||
#endif
|
||||
indev_proc_press(indev);
|
||||
} else {
|
||||
indev_proc_release(indev);
|
||||
}
|
||||
|
||||
indev->last_point.x = indev->act_point.x;
|
||||
indev->last_point.y = indev->act_point.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the pressed state
|
||||
* @param indev pointer to an input device state
|
||||
*/
|
||||
static void indev_proc_press(lv_indev_proc_t * info)
|
||||
{
|
||||
lv_obj_t * pr_obj = info->act_obj;
|
||||
|
||||
if(info->wait_unil_release != 0) return;
|
||||
|
||||
/*If there is no last object then search*/
|
||||
if(info->act_obj == NULL) {
|
||||
pr_obj = indev_search_obj(info, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
|
||||
}
|
||||
/*If there is last object but it is not dragged also search*/
|
||||
else if(info->drag_in_prog == 0) {/*Now act_obj != NULL*/
|
||||
pr_obj = indev_search_obj(info, lv_layer_top());
|
||||
if(pr_obj == NULL) pr_obj = indev_search_obj(info, lv_scr_act());
|
||||
}
|
||||
/*If a dragable object was the last then keep it*/
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
/*If a new object was found reset some variables and send a pressed signal*/
|
||||
if(pr_obj != info->act_obj) {
|
||||
|
||||
info->last_point.x = info->act_point.x;
|
||||
info->last_point.y = info->act_point.y;
|
||||
|
||||
/*If a new object found the previous was lost, so send a signal*/
|
||||
if(info->act_obj != NULL) {
|
||||
info->act_obj->signal_func(info->act_obj, LV_SIGNAL_PRESS_LOST, indev_act);
|
||||
if(info->reset_query != 0) return;
|
||||
}
|
||||
|
||||
if(pr_obj != NULL) {
|
||||
/* Save the time when the obj pressed.
|
||||
* It is necessary to count the long press time.*/
|
||||
info->pr_timestamp = lv_tick_get();
|
||||
info->long_pr_sent = 0;
|
||||
info->drag_range_out = 0;
|
||||
info->drag_in_prog = 0;
|
||||
info->drag_sum.x = 0;
|
||||
info->drag_sum.y = 0;
|
||||
|
||||
/*Search for 'top' attribute*/
|
||||
lv_obj_t * i = pr_obj;
|
||||
lv_obj_t * last_top = NULL;
|
||||
while(i != NULL){
|
||||
if(i->top != 0) last_top = i;
|
||||
i = lv_obj_get_parent(i);
|
||||
}
|
||||
|
||||
if(last_top != NULL) {
|
||||
/*Move the last_top object to the foreground*/
|
||||
lv_obj_t * par = lv_obj_get_parent(last_top);
|
||||
/*After list change it will be the new head*/
|
||||
lv_ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
||||
lv_obj_invalidate(last_top);
|
||||
}
|
||||
|
||||
/*Send a signal about the press*/
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_PRESSED, indev_act);
|
||||
if(info->reset_query != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
info->act_obj = pr_obj; /*Save the pressed object*/
|
||||
info->last_obj = info->act_obj; /*Refresh the last_obj*/
|
||||
|
||||
/*Calculate the vector*/
|
||||
info->vect.x = info->act_point.x - info->last_point.x;
|
||||
info->vect.y = info->act_point.y - info->last_point.y;
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(info->act_obj != NULL) {
|
||||
info->act_obj->signal_func(info->act_obj, LV_SIGNAL_PRESSING, indev_act);
|
||||
if(info->reset_query != 0) return;
|
||||
|
||||
indev_drag(info);
|
||||
if(info->reset_query != 0) return;
|
||||
|
||||
/*If there is no drag then check for long press time*/
|
||||
if(info->drag_in_prog == 0 && info->long_pr_sent == 0) {
|
||||
/*Send a signal about the long press if enough time elapsed*/
|
||||
if(lv_tick_elaps(info->pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) {
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS, indev_act);
|
||||
if(info->reset_query != 0) return;
|
||||
|
||||
/*Mark the signal sending to do not send it again*/
|
||||
info->long_pr_sent = 1;
|
||||
|
||||
/*Save the long press time stamp for the long press repeat handler*/
|
||||
info->longpr_rep_timestamp = lv_tick_get();
|
||||
}
|
||||
}
|
||||
/*Send long press repeated signal*/
|
||||
if(info->drag_in_prog == 0 && info->long_pr_sent == 1) {
|
||||
/*Send a signal about the long press repeate if enough time elapsed*/
|
||||
if(lv_tick_elaps(info->longpr_rep_timestamp) > LV_INDEV_LONG_PRESS_REP_TIME) {
|
||||
pr_obj->signal_func(pr_obj, LV_SIGNAL_LONG_PRESS_REP, indev_act);
|
||||
if(info->reset_query != 0) return;
|
||||
info->longpr_rep_timestamp = lv_tick_get();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the released state
|
||||
* @param indev_proc_p pointer to an input device state
|
||||
*/
|
||||
static void indev_proc_release(lv_indev_proc_t * state)
|
||||
{
|
||||
if(state->wait_unil_release != 0) {
|
||||
state->act_obj = NULL;
|
||||
state->last_obj = NULL;
|
||||
state->pr_timestamp = 0;
|
||||
state->longpr_rep_timestamp = 0;
|
||||
state->wait_unil_release = 0;
|
||||
}
|
||||
|
||||
/*Forgot the act obj and send a released signal */
|
||||
if(state->act_obj != NULL) {
|
||||
state->act_obj->signal_func(state->act_obj, LV_SIGNAL_RELEASED, indev_act);
|
||||
if(state->reset_query != 0) return;
|
||||
state->act_obj = NULL;
|
||||
state->pr_timestamp = 0;
|
||||
state->longpr_rep_timestamp = 0;
|
||||
}
|
||||
|
||||
/*The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(state->last_obj != NULL && state->reset_query == 0) {
|
||||
indev_drag_throw(state);
|
||||
if(state->reset_query != 0) return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the most top, clickable object on the last point of an input device
|
||||
* @param indev pointer to an input device
|
||||
* @param obj pointer to a start object, typically the screen
|
||||
* @return pointer to the found object or NULL if there was no suitable object
|
||||
*/
|
||||
static lv_obj_t * indev_search_obj(const lv_indev_proc_t * indev, lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If the point is on this object*/
|
||||
/*Check its children too*/
|
||||
if(lv_area_is_point_on(&obj->coords, &indev->act_point)) {
|
||||
lv_obj_t * i;
|
||||
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = indev_search_obj(indev, i);
|
||||
|
||||
/*If a child was found then break*/
|
||||
if(found_p != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*If then the children was not ok, and this obj is clickable
|
||||
* and it or its parent is not hidden then save this object*/
|
||||
if(found_p == NULL && lv_obj_get_click(obj) != false) {
|
||||
lv_obj_t * hidden_i = obj;
|
||||
while(hidden_i != NULL) {
|
||||
if(lv_obj_get_hidden(hidden_i) == true) break;
|
||||
hidden_i = lv_obj_get_parent(hidden_i);
|
||||
}
|
||||
/*No parent found with hidden == true*/
|
||||
if(hidden_i == NULL) found_p = obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return found_p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dragging of indev_proc_p->act_obj
|
||||
* @param indev pointer to a input device state
|
||||
*/
|
||||
static void indev_drag(lv_indev_proc_t * state)
|
||||
{
|
||||
lv_obj_t * drag_obj = state->act_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
if(lv_obj_get_drag(drag_obj) == false) return;
|
||||
|
||||
/*If still there is no drag then count the movement*/
|
||||
if(state->drag_range_out == 0) {
|
||||
state->drag_sum.x += state->vect.x;
|
||||
state->drag_sum.y += state->vect.y;
|
||||
|
||||
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
||||
if(LV_MATH_ABS(state->drag_sum.x) >= LV_INDEV_DRAG_LIMIT ||
|
||||
LV_MATH_ABS(state->drag_sum.y) >= LV_INDEV_DRAG_LIMIT)
|
||||
{
|
||||
state->drag_range_out = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*If the drag limit is stepped over then handle the dragging*/
|
||||
if(state->drag_range_out != 0) {
|
||||
/*Set new position if the vector is not zero*/
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0) {
|
||||
/*Get the coordinates of the object end modify them*/
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj);
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj);
|
||||
|
||||
lv_obj_set_pos(drag_obj, act_x + state->vect.x, act_y + state->vect.y);
|
||||
|
||||
/*Set the drag in progress flag if the object is really moved*/
|
||||
if(lv_obj_get_x(drag_obj) != act_x || lv_obj_get_y(drag_obj) != act_y) {
|
||||
if(state->drag_range_out != 0) { /*Send the drag begin signal on first move*/
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
|
||||
if(state->reset_query != 0) return;
|
||||
}
|
||||
state->drag_in_prog = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle throwing by drag if the drag is ended
|
||||
* @param indev pointer to an input device state
|
||||
*/
|
||||
static void indev_drag_throw(lv_indev_proc_t * state)
|
||||
{
|
||||
if(state->drag_in_prog == 0) return;
|
||||
|
||||
/*Set new position if the vector is not zero*/
|
||||
lv_obj_t * drag_obj = state->last_obj;
|
||||
|
||||
/*If drag parent is active check recursively the drag_parent attribute*/
|
||||
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
||||
drag_obj != NULL) {
|
||||
drag_obj = lv_obj_get_parent(drag_obj);
|
||||
}
|
||||
|
||||
if(drag_obj == NULL) return;
|
||||
|
||||
/*Return if the drag throw is not enabled*/
|
||||
if(lv_obj_get_drag_throw(drag_obj) == false ){
|
||||
state->drag_in_prog = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
return;
|
||||
}
|
||||
|
||||
/*Reduce the vectors*/
|
||||
state->vect.x = state->vect.x * (100 -LV_INDEV_DRAG_THROW) / 100;
|
||||
state->vect.y = state->vect.y * (100 -LV_INDEV_DRAG_THROW) / 100;
|
||||
|
||||
if(state->vect.x != 0 ||
|
||||
state->vect.y != 0)
|
||||
{
|
||||
/*Get the coordinates and modify them*/
|
||||
lv_coord_t act_x = lv_obj_get_x(drag_obj) + state->vect.x;
|
||||
lv_coord_t act_y = lv_obj_get_y(drag_obj) + state->vect.y;
|
||||
lv_obj_set_pos(drag_obj, act_x, act_y);
|
||||
|
||||
/*If non of the coordinates are changed then do not continue throwing*/
|
||||
if((lv_obj_get_x(drag_obj) != act_x || state->vect.x == 0) &&
|
||||
(lv_obj_get_y(drag_obj) != act_y || state->vect.y == 0)) {
|
||||
state->drag_in_prog = 0;
|
||||
state->vect.x = 0;
|
||||
state->vect.y = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
|
||||
}
|
||||
}
|
||||
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
|
||||
else {
|
||||
state->drag_in_prog = 0;
|
||||
drag_obj->signal_func(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
|
||||
}
|
||||
}
|
||||
119
lv_core/lv_indev.h
Normal file
119
lv_core/lv_indev.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* @file lv_indev_proc.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_INDEV_H
|
||||
#define LV_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_obj.h"
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "../lv_core/lv_group.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the display input device subsystem
|
||||
*/
|
||||
void lv_indev_init(void);
|
||||
|
||||
/**
|
||||
* Get the currently processed input device. Can be used in action functions too.
|
||||
* @return pointer to the currently processed input device or NULL if no input device processing right now
|
||||
*/
|
||||
lv_indev_t * lv_indev_get_act(void);
|
||||
|
||||
/**
|
||||
* Reset one or all input devices
|
||||
* @param indev pointer to an input device to reset or NULL to reset all of them
|
||||
*/
|
||||
void lv_indev_reset(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Reset the long press state of an input device
|
||||
* @param indev_proc pointer to an input device
|
||||
*/
|
||||
void lv_indev_reset_lpr(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Enable input devices device by type
|
||||
* @param type Input device type
|
||||
* @param enable true: enable this type; false: disable this type
|
||||
*/
|
||||
void lv_indev_enable(lv_hal_indev_type_t type, bool enable);
|
||||
|
||||
/**
|
||||
* Set a cursor for a pointer input device
|
||||
* @param indev pointer to an input device (type: 'LV_INDEV_TYPE_POINTER')
|
||||
* @param cur_obj pointer to an object to be used as cursor
|
||||
*/
|
||||
void lv_indev_set_cursor(lv_indev_t *indev, lv_obj_t *cur_obj);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
/**
|
||||
* Set a destination group for a keypad input device
|
||||
* @param indev pointer to an input device (type: 'LV_INDEV_TYPE_KEYPAD')
|
||||
* @param group point to a group
|
||||
*/
|
||||
void lv_indev_set_group(lv_indev_t *indev, lv_group_t *group);
|
||||
#endif
|
||||
/**
|
||||
* Get the last point of an input device
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the result
|
||||
*/
|
||||
void lv_indev_get_point(lv_indev_t * indev, lv_point_t * point);
|
||||
/**
|
||||
* Check if there is dragging with an input device or not
|
||||
* @param indev pointer to an input device
|
||||
* @return true: drag is in progress
|
||||
*/
|
||||
bool lv_indev_is_dragging(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Get the vector of dragging of an input device
|
||||
* @param indev pointer to an input device
|
||||
* @param point pointer to a point to store the vector
|
||||
*/
|
||||
void lv_indev_get_vect(lv_indev_t * indev, lv_point_t * point);
|
||||
|
||||
/**
|
||||
* Get elapsed time since last press
|
||||
* @param indev pointer to an input device (NULL to get the overall smallest inactivity)
|
||||
* @return Elapsed ticks (milliseconds) since last press
|
||||
*/
|
||||
uint32_t lv_indev_get_inactive_time(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Do nothing until the next release
|
||||
* @param indev pointer to an input device
|
||||
*/
|
||||
void lv_indev_wait_release(lv_indev_t * indev);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_INDEV_H*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,14 +13,14 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include <misc/gfx/area.h>
|
||||
#include "../../lv_conf.h"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lv_style.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_misc/lv_ll.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -31,8 +31,8 @@ extern "C" {
|
||||
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
|
||||
#endif
|
||||
|
||||
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2
|
||||
#error "LV: LV_DOWNSCALE can be only 1 or 2"
|
||||
#if LV_ANTIALIAS != 0 && LV_ANTIALIAS != 1
|
||||
#error "LV: LV_ATIALIAS can be only 0 or 1"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && LV_ANTIALIAS != 0
|
||||
@@ -47,19 +47,15 @@ extern "C" {
|
||||
#error "LV: Small Virtual Display Buffer (lv_conf.h: LV_VDB_SIZE >= (2 * LV_HOR_RES))"
|
||||
#endif
|
||||
|
||||
/*New defines*/
|
||||
#define LV_OBJ_DEF_WIDTH (80 * LV_DOWNSCALE)
|
||||
#define LV_OBJ_DEF_HEIGHT (60 * LV_DOWNSCALE)
|
||||
|
||||
#define ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/
|
||||
#define LV_ANIM_IN 0x00 /*Animation to show an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define LV_ANIM_OUT 0x80 /*Animation to hide an object. 'OR' it with lv_anim_builtin_t*/
|
||||
#define LV_ANIM_DIR_MASK 0x80 /*ANIM_IN/ANIM_OUT mask*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct __LV_OBJ_T;
|
||||
struct _lv_obj_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -68,7 +64,13 @@ typedef enum
|
||||
LV_DESIGN_COVER_CHK,
|
||||
}lv_design_mode_t;
|
||||
|
||||
typedef bool (* lv_design_f_t) (struct __LV_OBJ_T * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
typedef bool (* lv_design_func_t) (struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action function*/
|
||||
LV_RES_OK, /*The object is valid (no deleted) after the action*/
|
||||
}lv_res_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -79,7 +81,7 @@ typedef enum
|
||||
LV_SIGNAL_STYLE_CHG,
|
||||
LV_SIGNAL_REFR_EXT_SIZE,
|
||||
|
||||
/*Display input related*/
|
||||
/*Input device related*/
|
||||
LV_SIGNAL_PRESSED,
|
||||
LV_SIGNAL_PRESSING,
|
||||
LV_SIGNAL_PRESS_LOST,
|
||||
@@ -95,45 +97,47 @@ typedef enum
|
||||
LV_SIGNAL_CONTROLL,
|
||||
}lv_signal_t;
|
||||
|
||||
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T * obj, lv_signal_t sign, void * param);
|
||||
typedef lv_res_t (* lv_signal_func_t) (struct _lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
|
||||
typedef struct __LV_OBJ_T
|
||||
typedef struct _lv_obj_t
|
||||
{
|
||||
struct __LV_OBJ_T * par; /*Pointer to the parent object*/
|
||||
ll_dsc_t child_ll; /*Linked list to store the children objects*/
|
||||
struct _lv_obj_t * par; /*Pointer to the parent object*/
|
||||
lv_ll_t child_ll; /*Linked list to store the children objects*/
|
||||
|
||||
area_t cords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
lv_area_t coords; /*Coordinates of the object (x1, y1, x2, y2)*/
|
||||
|
||||
lv_signal_f_t signal_f; /*Object type specific signal function*/
|
||||
lv_design_f_t design_f; /*Object type specific design function*/
|
||||
lv_signal_func_t signal_func; /*Object type specific signal function*/
|
||||
lv_design_func_t design_func; /*Object type specific design function*/
|
||||
|
||||
void * ext; /*Object type specific extended data*/
|
||||
void * ext_attr; /*Object type specific extended data*/
|
||||
lv_style_t * style_p; /*Pointer to the object's style*/
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
void * free_p; /*Application specific pointer (set it freely)*/
|
||||
#if LV_OBJ_FREE_PTR != 0
|
||||
void * free_ptr; /*Application specific pointer (set it freely)*/
|
||||
#endif
|
||||
|
||||
void * group_p; /*Pointer to the group of the object*/
|
||||
|
||||
/*Attributes and states*/
|
||||
uint8_t click_en :1; /*1: Can be pressed by a display input device*/
|
||||
uint8_t drag_en :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw_en:1; /*1: Enable throwing with drag*/
|
||||
uint8_t click :1; /*1: Can be pressed by an input device*/
|
||||
uint8_t drag :1; /*1: Enable the dragging*/
|
||||
uint8_t drag_throw:1; /*1: Enable throwing with drag*/
|
||||
uint8_t drag_parent :1; /*1: Parent will be dragged instead*/
|
||||
uint8_t hidden :1; /*1: Object is hidden*/
|
||||
uint8_t top_en :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t top :1; /*1: If the object or its children is clicked it goes to the foreground*/
|
||||
uint8_t reserved :1;
|
||||
|
||||
uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from lv_obj_prot_t*/
|
||||
|
||||
cord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
lv_coord_t ext_size; /*EXTtend the size of the object in every direction. E.g. for shadow drawing*/
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
uint8_t free_num; /*Application specific identifier (set it freely)*/
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
LV_OBJ_FREE_NUM_TYPE free_num; /*Application specific identifier (set it freely)*/
|
||||
#endif
|
||||
}lv_obj_t;
|
||||
|
||||
typedef lv_res_t (*lv_action_t) (struct _lv_obj_t * obj);
|
||||
|
||||
/*Protect some attributes (max. 8 bit)*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -189,6 +193,10 @@ typedef enum
|
||||
*/
|
||||
void lv_init(void);
|
||||
|
||||
/*--------------------
|
||||
* Create and delete
|
||||
*-------------------*/
|
||||
|
||||
/**
|
||||
* Create a basic object
|
||||
* @param parent pointer to a parent object.
|
||||
@@ -201,23 +209,30 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, lv_obj_t * copy);
|
||||
/**
|
||||
* Delete 'obj' and all of its children
|
||||
* @param obj pointer to an object to delete
|
||||
* @return LV_RES_INV because the object is deleted
|
||||
*/
|
||||
void lv_obj_del(lv_obj_t * obj);
|
||||
lv_res_t lv_obj_del(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Signal function of the basic object
|
||||
* Delete all children of an object
|
||||
* @param obj pointer to an object
|
||||
* @param sign signal type
|
||||
* @param param parameter for the signal (depends on signal type)
|
||||
* @return false: the object become invalid (e.g. deleted)
|
||||
*/
|
||||
bool lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param);
|
||||
void lv_obj_clean(lv_obj_t *obj);
|
||||
|
||||
/**
|
||||
* Mark the object as invalid therefore its current position will be redrawn by 'lv_refr_task'
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj);
|
||||
void lv_obj_invalidate(lv_obj_t * obj);
|
||||
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/*--------------
|
||||
* Screen set
|
||||
*--------------*/
|
||||
|
||||
/**
|
||||
* Load a new screen
|
||||
@@ -225,6 +240,10 @@ void lv_obj_inv(lv_obj_t * obj);
|
||||
*/
|
||||
void lv_scr_load(lv_obj_t * scr);
|
||||
|
||||
/*--------------------
|
||||
* Parent/children set
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Set a new parent for an object. Its relative position will be the same.
|
||||
* @param obj pointer to an object
|
||||
@@ -232,52 +251,31 @@ void lv_scr_load(lv_obj_t * scr);
|
||||
*/
|
||||
void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent);
|
||||
|
||||
/*--------------------
|
||||
* Coordinate set
|
||||
* ------------------*/
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent)
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_pos(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Set relative the position of an object (relative to the parent).
|
||||
* The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_pos_us(lv_obj_t * obj, cord_t x, cord_t y);
|
||||
void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent
|
||||
*/
|
||||
void lv_obj_set_x(lv_obj_t * obj, cord_t x);
|
||||
|
||||
/**
|
||||
* Set the x coordinate of a object.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param x new distance from the left side from the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_x_us(lv_obj_t * obj, cord_t x);
|
||||
void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent
|
||||
*/
|
||||
void lv_obj_set_y(lv_obj_t * obj, cord_t y);
|
||||
|
||||
/**
|
||||
* Set the y coordinate of a object.
|
||||
* The coordinate will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param y new distance from the top of the parent. (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Set the size of an object
|
||||
@@ -285,43 +283,21 @@ void lv_obj_set_y_us(lv_obj_t * obj, cord_t y);
|
||||
* @param w new width
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_size(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the size of an object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_size_us(lv_obj_t * obj, cord_t w, cord_t h);
|
||||
void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h);
|
||||
|
||||
/**
|
||||
* Set the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @param w new width
|
||||
*/
|
||||
void lv_obj_set_width(lv_obj_t * obj, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the width of an object. The width will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param w new width (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_width_us(lv_obj_t * obj, cord_t w);
|
||||
void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @param h new height
|
||||
*/
|
||||
void lv_obj_set_height(lv_obj_t * obj, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the height of an object. The height will be upscaled with LV_DOWNSCALE
|
||||
* @param obj pointer to an object
|
||||
* @param h new height (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h);
|
||||
|
||||
/**
|
||||
* Align an object to an other object.
|
||||
@@ -331,24 +307,12 @@ void lv_obj_set_height_us(lv_obj_t * obj, cord_t h);
|
||||
* @param x_mod x coordinate shift after alignment
|
||||
* @param y_mod y coordinate shift after alignment
|
||||
*/
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
void lv_obj_align(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
|
||||
|
||||
/**
|
||||
* Align an object to an other object. The coordinates will be upscaled with LV_DOWNSCALE.
|
||||
* @param obj pointer to an object to align
|
||||
* @param base pointer to an object (if NULL the parent is used). 'obj' will be aligned to it.
|
||||
* @param align type of alignment (see 'lv_align_t' enum)
|
||||
* @param x_mod x coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
* @param y_mod y coordinate shift after alignment (will be multiplied with LV_DOWNSCALE)
|
||||
*/
|
||||
void lv_obj_align_us(lv_obj_t * obj,lv_obj_t * base, lv_align_t align, cord_t x_mod, cord_t y_mod);
|
||||
|
||||
/**
|
||||
* Set the extended size of an object
|
||||
* @param obj pointer to an object
|
||||
* @param ext_size the extended size
|
||||
*/
|
||||
void lv_obj_set_ext_size(lv_obj_t * obj, cord_t ext_size);
|
||||
/*---------------------
|
||||
* Appearance set
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Set a new style for an object
|
||||
@@ -361,14 +325,18 @@ void lv_obj_set_style(lv_obj_t * obj, lv_style_t * style);
|
||||
* Notify an object about its style is modified
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_style(lv_obj_t * obj);
|
||||
void lv_obj_refresh_style(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Notify all object if a style is modified
|
||||
* @param style pointer to a style. Only the objects with this style will be notified
|
||||
* (NULL to notify all objects)
|
||||
*/
|
||||
void lv_style_refr_objs(void * style);
|
||||
void lv_obj_report_style_mod(lv_style_t * style);
|
||||
|
||||
/*-----------------
|
||||
* Attribute set
|
||||
*----------------*/
|
||||
|
||||
/**
|
||||
* Hide an object. It won't be visible and clickable.
|
||||
@@ -426,7 +394,7 @@ void lv_obj_set_protect(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @param prot 'OR'-ed values from lv_obj_prot_t
|
||||
*/
|
||||
void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
void lv_obj_clear_protect(lv_obj_t * obj, uint8_t prot);
|
||||
|
||||
/**
|
||||
* Set the signal function of an object.
|
||||
@@ -434,14 +402,18 @@ void lv_obj_clr_protect(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new signal function
|
||||
*/
|
||||
void lv_obj_set_signal_f(lv_obj_t * obj, lv_signal_f_t fp);
|
||||
void lv_obj_set_signal_func(lv_obj_t * obj, lv_signal_func_t fp);
|
||||
|
||||
/**
|
||||
* Set a new design function for an object
|
||||
* @param obj pointer to an object
|
||||
* @param fp the new design function
|
||||
*/
|
||||
void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
void lv_obj_set_design_func(lv_obj_t * obj, lv_design_func_t fp);
|
||||
|
||||
/*----------------
|
||||
* Other set
|
||||
*--------------*/
|
||||
|
||||
/**
|
||||
* Allocate a new ext. data for an object
|
||||
@@ -449,34 +421,35 @@ void lv_obj_set_design_f(lv_obj_t * obj, lv_design_f_t fp);
|
||||
* @param ext_size the size of the new ext. data
|
||||
* @return Normal pointer to the allocated ext
|
||||
*/
|
||||
void * lv_obj_alloc_ext(lv_obj_t * obj, uint16_t ext_size);
|
||||
void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size);
|
||||
|
||||
/**
|
||||
* Send a 'LV_SIGNAL_REFR_EXT_SIZE' signal to the object
|
||||
* @param obj pointer to an object
|
||||
*/
|
||||
void lv_obj_refr_ext_size(lv_obj_t * obj);
|
||||
void lv_obj_refresh_ext_size(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
/**
|
||||
* Set an application specific number for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_num the new free number
|
||||
*/
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, uint8_t free_num);
|
||||
void lv_obj_set_free_num(lv_obj_t * obj, LV_OBJ_FREE_NUM_TYPE free_num);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
#if LV_OBJ_FREE_PTR != 0
|
||||
/**
|
||||
* Set an application specific pointer for an object.
|
||||
* It can help to identify objects in the application.
|
||||
* @param obj pointer to an object
|
||||
* @param free_p the new free pinter
|
||||
*/
|
||||
void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
void lv_obj_set_free_ptr(lv_obj_t * obj, void * free_p);
|
||||
#endif
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
/**
|
||||
* Animate an object
|
||||
* @param obj pointer to an object to animate
|
||||
@@ -485,20 +458,46 @@ void lv_obj_set_free_p(lv_obj_t * obj, void * free_p);
|
||||
* @param delay delay before the animation in milliseconds
|
||||
* @param cb a function to call when the animation is ready
|
||||
*/
|
||||
void lv_obj_anim(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *));
|
||||
void lv_obj_animate(lv_obj_t * obj, lv_anim_builtin_t type, uint16_t time, uint16_t delay, void (*cb) (lv_obj_t *));
|
||||
#endif
|
||||
|
||||
/*=======================
|
||||
* Getter functions
|
||||
*======================*/
|
||||
|
||||
/*------------------
|
||||
* Screen get
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Return with the actual screen
|
||||
* @return pointer to to the actual screen object
|
||||
* Return with a pointer to the active screen
|
||||
* @return pointer to the active screen object (loaded by 'lv_scr_load()')
|
||||
*/
|
||||
lv_obj_t * lv_scr_act(void);
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_top(void);
|
||||
|
||||
/**
|
||||
* Return with the system layer. (Same on every screen and it is above the all other layers)
|
||||
* It is used for example by the cursor
|
||||
* @return pointer to the system layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_layer_sys(void);
|
||||
|
||||
/**
|
||||
* Return with the screen of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to a screen
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
|
||||
lv_obj_t * lv_obj_get_screen(lv_obj_t * obj);
|
||||
|
||||
/*---------------------
|
||||
* Parent/children get
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Returns with the parent of an object
|
||||
@@ -508,7 +507,7 @@ lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
|
||||
lv_obj_t * lv_obj_get_parent(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Iterate through the children of an object
|
||||
* Iterate through the children of an object (start from the "youngest, lastly created")
|
||||
* @param obj pointer to an object
|
||||
* @param child NULL at first call to get the next children
|
||||
* and the previous return value later
|
||||
@@ -516,54 +515,71 @@ lv_obj_t * lv_obj_get_parent(lv_obj_t * obj);
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child(lv_obj_t * obj, lv_obj_t * child);
|
||||
|
||||
/**
|
||||
* Iterate through the children of an object (start from the "oldest", firstly created)
|
||||
* @param obj pointer to an object
|
||||
* @param child NULL at first call to get the next children
|
||||
* and the previous return value later
|
||||
* @return the child after 'act_child' or NULL if no more child
|
||||
*/
|
||||
lv_obj_t * lv_obj_get_child_back(lv_obj_t * obj, lv_obj_t * child);
|
||||
|
||||
/**
|
||||
* Count the children of an object (only children directly on 'obj')
|
||||
* @param obj pointer to an object
|
||||
* @return children number of 'obj'
|
||||
*/
|
||||
uint16_t lv_obj_get_child_num(lv_obj_t * obj);
|
||||
uint16_t lv_obj_count_children(lv_obj_t * obj);
|
||||
|
||||
/*---------------------
|
||||
* Coordinate get
|
||||
*--------------------*/
|
||||
|
||||
/**
|
||||
* Copy the coordinates of an object to an area
|
||||
* @param obj pointer to an object
|
||||
* @param cords_p pointer to an area to store the coordinates
|
||||
*/
|
||||
void lv_obj_get_cords(lv_obj_t * obj, area_t * cords_p);
|
||||
void lv_obj_get_coords(lv_obj_t * obj, lv_area_t * cords_p);
|
||||
|
||||
/**
|
||||
* Get the x coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the left side of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_x(lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_x(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the y coordinate of object
|
||||
* @param obj pointer to an object
|
||||
* @return distance of 'obj' from the top of its parent
|
||||
*/
|
||||
cord_t lv_obj_get_y(lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_y(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the width
|
||||
*/
|
||||
cord_t lv_obj_get_width(lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_width(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the height
|
||||
*/
|
||||
cord_t lv_obj_get_height(lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_height(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the extended size attribute of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the extended size attribute
|
||||
*/
|
||||
cord_t lv_obj_get_ext_size(lv_obj_t * obj);
|
||||
lv_coord_t lv_obj_get_ext_size(lv_obj_t * obj);
|
||||
|
||||
/*-----------------
|
||||
* Appearance get
|
||||
*---------------*/
|
||||
|
||||
/**
|
||||
* Get the style pointer of an object (if NULL get style of the parent)
|
||||
@@ -572,6 +588,10 @@ cord_t lv_obj_get_ext_size(lv_obj_t * obj);
|
||||
*/
|
||||
lv_style_t * lv_obj_get_style(lv_obj_t * obj);
|
||||
|
||||
/*-----------------
|
||||
* Attribute get
|
||||
*----------------*/
|
||||
|
||||
/**
|
||||
* Get the hidden attribute of an object
|
||||
* @param obj pointer to an object
|
||||
@@ -634,14 +654,18 @@ bool lv_obj_is_protected(lv_obj_t * obj, uint8_t prot);
|
||||
* @param obj pointer to an object
|
||||
* @return the signal function
|
||||
*/
|
||||
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t * obj);
|
||||
lv_signal_func_t lv_obj_get_signal_func(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the design function of an object
|
||||
* @param obj pointer to an object
|
||||
* @return the design function
|
||||
*/
|
||||
lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
lv_design_func_t lv_obj_get_design_func(lv_obj_t * obj);
|
||||
|
||||
/*------------------
|
||||
* Other get
|
||||
*-----------------*/
|
||||
|
||||
/**
|
||||
* Get the ext pointer
|
||||
@@ -649,27 +673,27 @@ lv_design_f_t lv_obj_get_design_f(lv_obj_t * obj);
|
||||
* @return the ext pointer but not the dynamic version
|
||||
* Use it as ext->data1, and NOT da(ext)->data1
|
||||
*/
|
||||
void * lv_obj_get_ext(lv_obj_t * obj);
|
||||
void * lv_obj_get_ext_attr(lv_obj_t * obj);
|
||||
|
||||
#if LV_OBJ_FREE_NUM != 0
|
||||
#ifdef LV_OBJ_FREE_NUM_TYPE
|
||||
/**
|
||||
* Get the free number
|
||||
* @param obj pointer to an object
|
||||
* @return the free number
|
||||
*/
|
||||
uint8_t lv_obj_get_free_num(lv_obj_t * obj);
|
||||
LV_OBJ_FREE_NUM_TYPE lv_obj_get_free_num(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_FREE_P != 0
|
||||
#if LV_OBJ_FREE_PTR != 0
|
||||
/**
|
||||
* Get the free pointer
|
||||
* @param obj pointer to an object
|
||||
* @return the free pointer
|
||||
*/
|
||||
void * lv_obj_get_free_p(lv_obj_t * obj);
|
||||
void * lv_obj_get_free_ptr(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
#if LV_OBJ_GROUP != 0
|
||||
#if USE_LV_GROUP
|
||||
/**
|
||||
* Get the group of the object
|
||||
* @param obj pointer to an object
|
||||
@@ -677,9 +701,12 @@ void * lv_obj_get_free_p(lv_obj_t * obj);
|
||||
*/
|
||||
void * lv_obj_get_group(lv_obj_t * obj);
|
||||
#endif
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define LV_SCALE(x) (x << LV_ANTIALIAS)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -6,13 +6,13 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
#include <stddef.h>
|
||||
#include "lv_conf.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/mem/fifo.h"
|
||||
#include "lv_refr.h"
|
||||
#include "lv_vdb.h"
|
||||
#include "hal/systick/systick.h"
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_misc/lv_task.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -23,7 +23,7 @@
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
area_t area;
|
||||
lv_area_t area;
|
||||
uint8_t joined;
|
||||
}lv_join_t;
|
||||
|
||||
@@ -34,14 +34,14 @@ static void lv_refr_task(void * param);
|
||||
static void lv_refr_join_area(void);
|
||||
static void lv_refr_areas(void);
|
||||
#if LV_VDB_SIZE == 0
|
||||
static void lv_refr_area_no_vdb(const area_t * area_p);
|
||||
static void lv_refr_area_no_vdb(const lv_area_t * area_p);
|
||||
#else
|
||||
static void lv_refr_area_with_vdb(const area_t * area_p);
|
||||
static void lv_refr_area_part_vdb(const area_t * area_p);
|
||||
static void lv_refr_area_with_vdb(const lv_area_t * area_p);
|
||||
static void lv_refr_area_part_vdb(const lv_area_t * area_p);
|
||||
#endif
|
||||
static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj);
|
||||
static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p);
|
||||
static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p);
|
||||
static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj);
|
||||
static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p);
|
||||
static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -67,16 +67,16 @@ void lv_refr_init(void)
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
ptask_t* task;
|
||||
task = ptask_create(lv_refr_task, LV_REFR_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
dm_assert(task);
|
||||
lv_task_t* task;
|
||||
task = lv_task_create(lv_refr_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
lv_mem_assert(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p)
|
||||
void lv_inv_area(const lv_area_t * area_p)
|
||||
{
|
||||
/*Clear the invalidate buffer if the parameter is NULL*/
|
||||
if(area_p == NULL) {
|
||||
@@ -84,21 +84,21 @@ void lv_inv_area(const area_t * area_p)
|
||||
return;
|
||||
}
|
||||
|
||||
area_t scr_area;
|
||||
lv_area_t scr_area;
|
||||
scr_area.x1 = 0;
|
||||
scr_area.y1 = 0;
|
||||
scr_area.x2 = LV_HOR_RES - 1;
|
||||
scr_area.y2 = LV_VER_RES - 1;
|
||||
|
||||
area_t com_area;
|
||||
lv_area_t com_area;
|
||||
bool suc;
|
||||
|
||||
suc = area_union(&com_area, area_p, &scr_area);
|
||||
suc = lv_area_union(&com_area, area_p, &scr_area);
|
||||
|
||||
/*The area is truncated to the screen*/
|
||||
if(suc != false)
|
||||
{
|
||||
#if LV_DOWNSCALE == 2
|
||||
#if LV_ANTIALIAS == 1
|
||||
/*Rounding*/
|
||||
com_area.x1 = com_area.x1 & (~0x1);
|
||||
com_area.y1 = com_area.y1 & (~0x1);
|
||||
@@ -109,16 +109,16 @@ void lv_inv_area(const area_t * area_p)
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
if(lv_area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
}
|
||||
|
||||
|
||||
/*Save the area*/
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&com_area);
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area,&com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&scr_area);
|
||||
lv_area_copy(&inv_buf[inv_buf_p].area,&scr_area);
|
||||
}
|
||||
inv_buf_p ++;
|
||||
}
|
||||
@@ -146,8 +146,9 @@ void lv_refr_set_monitor_cb(void (*cb)(uint32_t, uint32_t))
|
||||
*/
|
||||
static void lv_refr_task(void * param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
uint32_t start = systick_get();
|
||||
uint32_t start = lv_tick_get();
|
||||
|
||||
lv_refr_join_area();
|
||||
|
||||
@@ -162,7 +163,7 @@ static void lv_refr_task(void * param)
|
||||
* therefore be sure the inv_buf is cleared prior to it*/
|
||||
if(refr_done != false) {
|
||||
if(monitor_cb != NULL) {
|
||||
monitor_cb(systick_elaps(start), px_num);
|
||||
monitor_cb(lv_tick_elaps(start), px_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +176,7 @@ static void lv_refr_join_area(void)
|
||||
{
|
||||
uint32_t join_from;
|
||||
uint32_t join_in;
|
||||
area_t joined_area;
|
||||
lv_area_t joined_area;
|
||||
for(join_in = 0; join_in < inv_buf_p; join_in++) {
|
||||
if(inv_buf[join_in].joined != 0) continue;
|
||||
|
||||
@@ -187,19 +188,19 @@ static void lv_refr_join_area(void)
|
||||
}
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(area_is_on(&inv_buf[join_in].area,
|
||||
if(lv_area_is_on(&inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
area_join(&joined_area, &inv_buf[join_in].area,
|
||||
lv_area_join(&joined_area, &inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area);
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(area_get_size(&joined_area) <
|
||||
(area_get_size(&inv_buf[join_in].area) + area_get_size(&inv_buf[join_from].area))) {
|
||||
area_cpy(&inv_buf[join_in].area, &joined_area);
|
||||
if(lv_area_get_size(&joined_area) <
|
||||
(lv_area_get_size(&inv_buf[join_in].area) + lv_area_get_size(&inv_buf[join_from].area))) {
|
||||
lv_area_copy(&inv_buf[join_in].area, &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
inv_buf[join_from].joined = 1;
|
||||
@@ -226,7 +227,7 @@ static void lv_refr_areas(void)
|
||||
/*If VDB is used...*/
|
||||
lv_refr_area_with_vdb(&inv_buf[i].area);
|
||||
#endif
|
||||
if(monitor_cb != NULL) px_num += area_get_size(&inv_buf[i].area);
|
||||
if(monitor_cb != NULL) px_num += lv_area_get_size(&inv_buf[i].area);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ static void lv_refr_areas(void)
|
||||
* Refresh an area if there is no Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_no_vdb(const area_t * area_p)
|
||||
static void lv_refr_area_no_vdb(const lv_area_t * area_p)
|
||||
{
|
||||
lv_obj_t * top_p;
|
||||
|
||||
@@ -245,7 +246,7 @@ static void lv_refr_area_no_vdb(const area_t * area_p)
|
||||
top_p = lv_refr_get_top_obj(area_p, lv_scr_act());
|
||||
|
||||
/*Do the refreshing*/
|
||||
lv_refr_make(top_p, area_p);
|
||||
lv_refr_obj_and_children(top_p, area_p);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -254,21 +255,22 @@ static void lv_refr_area_no_vdb(const area_t * area_p)
|
||||
* Refresh an area if there is Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
static void lv_refr_area_with_vdb(const lv_area_t * area_p)
|
||||
{
|
||||
/*Calculate the max row num*/
|
||||
uint32_t max_row = (uint32_t) LV_VDB_SIZE / (area_get_width(area_p));
|
||||
if(max_row > area_get_height(area_p)) max_row = area_get_height(area_p);
|
||||
|
||||
/*Round the row number with downscale*/
|
||||
#if LV_DOWNSCALE == 2
|
||||
max_row &= (~0x1);
|
||||
#endif
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
lv_coord_t y2 = area_p->y2 >= LV_VER_RES ? y2 = LV_VER_RES - 1 : area_p->y2;
|
||||
|
||||
uint32_t max_row = (uint32_t) LV_VDB_SIZE / (w << LV_AA);
|
||||
if(max_row > (h << LV_AA)) max_row = (h << LV_AA);
|
||||
|
||||
max_row = max_row >> LV_AA ;
|
||||
|
||||
/*Always use the full row*/
|
||||
cord_t row;
|
||||
cord_t row_last = 0;
|
||||
for(row = area_p->y1; row + max_row - 1 <= area_p->y2; row += max_row) {
|
||||
uint32_t row;
|
||||
lv_coord_t row_last = 0;
|
||||
for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
@@ -276,19 +278,20 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = row + max_row - 1;
|
||||
row_last = row + max_row - 1;
|
||||
if(vdb_p->area.y2 > y2) vdb_p->area.y2 = y2;
|
||||
row_last = vdb_p->area.y2;
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
}
|
||||
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(area_p->y2 != row_last) {
|
||||
if(y2 != row_last) {
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Calc. the next y coordinates of VDB*/
|
||||
vdb_p->area.x1 = area_p->x1;
|
||||
vdb_p->area.x2 = area_p->x2;
|
||||
vdb_p->area.y1 = row;
|
||||
vdb_p->area.y2 = area_p->y2;
|
||||
vdb_p->area.y2 = y2;
|
||||
|
||||
/*Refresh this part too*/
|
||||
lv_refr_area_part_vdb(area_p);
|
||||
@@ -299,21 +302,32 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
* Refresh a part of an area which is on the actual Virtual Display Buffer
|
||||
* @param area_p pointer to an area to refresh
|
||||
*/
|
||||
static void lv_refr_area_part_vdb(const area_t * area_p)
|
||||
static void lv_refr_area_part_vdb(const lv_area_t * area_p)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
lv_obj_t * top_p;
|
||||
|
||||
/*Get the new mask from the original area and the act. VDB
|
||||
It will be a part of 'area_p'*/
|
||||
area_t start_mask;
|
||||
area_union(&start_mask, area_p, &vdb_p->area);
|
||||
lv_area_t start_mask;
|
||||
lv_area_union(&start_mask, area_p, &vdb_p->area);
|
||||
|
||||
#if LV_ANTIALIAS
|
||||
vdb_p->area.x1 = vdb_p->area.x1 << LV_AA;
|
||||
vdb_p->area.x2 = (vdb_p->area.x2 << LV_AA) + 1;
|
||||
vdb_p->area.y1 = (vdb_p->area.y1 << LV_AA);
|
||||
vdb_p->area.y2 = (vdb_p->area.y2 << LV_AA) + 1;
|
||||
#endif
|
||||
|
||||
/*Get the most top object which is not covered by others*/
|
||||
top_p = lv_refr_get_top_obj(&start_mask, lv_scr_act());
|
||||
|
||||
/*Do the refreshing from the top object*/
|
||||
lv_refr_make(top_p, &start_mask);
|
||||
lv_refr_obj_and_children(top_p, &start_mask);
|
||||
|
||||
/*Also refresh top and sys layer unconditionally*/
|
||||
lv_refr_obj_and_children(lv_layer_top(), &start_mask);
|
||||
lv_refr_obj_and_children(lv_layer_sys(), &start_mask);
|
||||
|
||||
/*Flush the content of the VDB*/
|
||||
lv_vdb_flush();
|
||||
@@ -327,13 +341,13 @@ static void lv_refr_area_part_vdb(const area_t * area_p)
|
||||
* @param obj the first object to start the searching (typically a screen)
|
||||
* @return
|
||||
*/
|
||||
static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(area_is_in(area_p, &obj->cords) && obj->hidden == 0)
|
||||
if(lv_area_is_in(area_p, &obj->coords) && obj->hidden == 0)
|
||||
{
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
@@ -347,8 +361,8 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
/*If no better children check this object*/
|
||||
if(found_p == NULL) {
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa == OPA_COVER &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
if(style->body.opa == LV_OPA_COVER &&
|
||||
obj->design_func(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
@@ -362,7 +376,7 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
* @param top_p pointer to an objects. Start the drawing from it.
|
||||
* @param mask_p pointer to an area, the objects will be drawn only here
|
||||
*/
|
||||
static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
|
||||
{
|
||||
/* Normally always will be a top_obj (at least the screen)
|
||||
* but in special cases (e.g. if the screen has alpha) it won't.
|
||||
@@ -382,12 +396,12 @@ static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
/*Do until not reach the screen*/
|
||||
while(par != NULL) {
|
||||
/*object before border_p has to be redrawn*/
|
||||
i = ll_get_prev(&(par->child_ll), border_p);
|
||||
i = lv_ll_get_prev(&(par->child_ll), border_p);
|
||||
|
||||
while(i != NULL) {
|
||||
/*Refresh the objects*/
|
||||
lv_refr_obj(i, mask_p);
|
||||
i = ll_get_prev(&(par->child_ll), i);
|
||||
i = lv_ll_get_prev(&(par->child_ll), i);
|
||||
}
|
||||
|
||||
/*The new border will be there last parents,
|
||||
@@ -400,7 +414,7 @@ static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
/*Call the post draw design function of the parents of the to object*/
|
||||
par = lv_obj_get_parent(top_p);
|
||||
while(par != NULL) {
|
||||
par->design_f(par, mask_p, LV_DESIGN_DRAW_POST);
|
||||
par->design_func(par, mask_p, LV_DESIGN_DRAW_POST);
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
}
|
||||
@@ -410,7 +424,7 @@ static void lv_refr_make(lv_obj_t * top_p, const area_t * mask_p)
|
||||
* @param obj pointer to an object to refresh
|
||||
* @param mask_ori_p pointer to an area, the objects will be drawn only here
|
||||
*/
|
||||
static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
||||
{
|
||||
/*Do not refresh hidden objects*/
|
||||
if(obj->hidden != 0) return;
|
||||
@@ -418,37 +432,37 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
bool union_ok; /* Store the return value of area_union */
|
||||
/* Truncate the original mask to the coordinates of the parent
|
||||
* because the parent and its children are visible only here */
|
||||
area_t obj_mask;
|
||||
area_t obj_ext_mask;
|
||||
area_t obj_area;
|
||||
cord_t ext_size = obj->ext_size;
|
||||
lv_obj_get_cords(obj, &obj_area);
|
||||
lv_area_t obj_mask;
|
||||
lv_area_t obj_ext_mask;
|
||||
lv_area_t obj_area;
|
||||
lv_coord_t ext_size = obj->ext_size;
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
obj_area.x1 -= ext_size;
|
||||
obj_area.y1 -= ext_size;
|
||||
obj_area.x2 += ext_size;
|
||||
obj_area.y2 += ext_size;
|
||||
union_ok = area_union(&obj_ext_mask, mask_ori_p, &obj_area);
|
||||
union_ok = lv_area_union(&obj_ext_mask, mask_ori_p, &obj_area);
|
||||
|
||||
/*Draw the parent and its children only if they ore on 'mask_parent'*/
|
||||
if(union_ok != false) {
|
||||
|
||||
/* Redraw the object */
|
||||
lv_style_t * style = lv_obj_get_style(obj);
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
if(style->body.opa != LV_OPA_TRANSP) {
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
//tick_wait_ms(100); /*DEBUG: Wait after every object draw to see the order of drawing*/
|
||||
}
|
||||
|
||||
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
|
||||
lv_obj_get_cords(obj, &obj_area);
|
||||
union_ok = area_union(&obj_mask, mask_ori_p, &obj_area);
|
||||
lv_obj_get_coords(obj, &obj_area);
|
||||
union_ok = lv_area_union(&obj_mask, mask_ori_p, &obj_area);
|
||||
if(union_ok != false) {
|
||||
area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_obj_t * child_p;
|
||||
area_t child_area;
|
||||
lv_area_t child_area;
|
||||
LL_READ_BACK(obj->child_ll, child_p)
|
||||
{
|
||||
lv_obj_get_cords(child_p, &child_area);
|
||||
lv_obj_get_coords(child_p, &child_area);
|
||||
ext_size = child_p->ext_size;
|
||||
child_area.x1 -= ext_size;
|
||||
child_area.y1 -= ext_size;
|
||||
@@ -456,7 +470,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
child_area.y2 += ext_size;
|
||||
/* Get the union (common parts) of original mask (from obj)
|
||||
* and its child */
|
||||
union_ok = area_union(&mask_child, &obj_mask, &child_area);
|
||||
union_ok = lv_area_union(&mask_child, &obj_mask, &child_area);
|
||||
|
||||
/*If the parent and the child has common area then refresh the child */
|
||||
if(union_ok) {
|
||||
@@ -467,8 +481,8 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
}
|
||||
|
||||
/* If all the children are redrawn make 'post draw' design */
|
||||
if(style->opa != OPA_TRANSP) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
if(style->body.opa != LV_OPA_TRANSP) {
|
||||
obj->design_func(obj, &obj_ext_mask, LV_DESIGN_DRAW_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void lv_refr_init(void);
|
||||
* Invalidate an area
|
||||
* @param area_p pointer to area which should be invalidated
|
||||
*/
|
||||
void lv_inv_area(const area_t * area_p);
|
||||
void lv_inv_area(const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Set a function to call after every refresh to announce the refresh time and the number of refreshed pixels
|
||||
319
lv_core/lv_style.c
Normal file
319
lv_core/lv_style.c
Normal file
@@ -0,0 +1,319 @@
|
||||
/**
|
||||
* @file lv_style.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
#include "lv_style.h"
|
||||
#include "lv_obj.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#if USE_LV_ANIMATION
|
||||
#define LV_STYLE_ANIM_RES 256
|
||||
#define LV_STYLE_ANIM_SHIFT 8 /*log2(LV_STYLE_ANIM_RES)*/
|
||||
|
||||
#define VAL_PROP(v1, v2, r) v1 + (((v2-v1) * r) >> LV_STYLE_ANIM_SHIFT)
|
||||
#define STYLE_ATTR_ANIM(attr, r) if(start->attr != end->attr) act->attr = VAL_PROP(start->attr, end->attr, r)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
#if USE_LV_ANIMATION
|
||||
typedef struct {
|
||||
lv_style_t style_start; /*Save not only pointers because can be same as 'style_anim' then it will be modified too*/
|
||||
lv_style_t style_end;
|
||||
lv_style_t *style_anim;
|
||||
void (*end_cb)(void *);
|
||||
}lv_style_anim_dsc_t;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if USE_LV_ANIMATION
|
||||
static void style_animator(lv_style_anim_dsc_t * dsc, int32_t val);
|
||||
static void style_animation_common_end_cb(void *ptr);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
lv_style_t lv_style_scr;
|
||||
lv_style_t lv_style_transp;
|
||||
lv_style_t lv_style_transp_fit;
|
||||
lv_style_t lv_style_transp_tight;
|
||||
lv_style_t lv_style_plain;
|
||||
lv_style_t lv_style_plain_color;
|
||||
lv_style_t lv_style_pretty;
|
||||
lv_style_t lv_style_pretty_color;
|
||||
lv_style_t lv_style_btn_rel;
|
||||
lv_style_t lv_style_btn_pr;
|
||||
lv_style_t lv_style_btn_tgl_rel;
|
||||
lv_style_t lv_style_btn_tgl_pr;
|
||||
lv_style_t lv_style_btn_ina;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void)
|
||||
{
|
||||
/* Not White/Black/Gray colors are created by HSV model with
|
||||
* HUE = 210*/
|
||||
|
||||
/*Screen style*/
|
||||
lv_style_scr.glass = 0;
|
||||
lv_style_scr.body.opa = LV_OPA_COVER;
|
||||
lv_style_scr.body.main_color = LV_COLOR_WHITE;
|
||||
lv_style_scr.body.grad_color = LV_COLOR_WHITE;
|
||||
lv_style_scr.body.radius = 0;
|
||||
lv_style_scr.body.padding.ver = LV_DPI / 12;
|
||||
lv_style_scr.body.padding.hor = LV_DPI / 12;
|
||||
lv_style_scr.body.padding.inner = LV_DPI / 12;
|
||||
|
||||
lv_style_scr.body.border.color = LV_COLOR_BLACK;
|
||||
lv_style_scr.body.border.opa = LV_OPA_COVER;
|
||||
lv_style_scr.body.border.width = 0;
|
||||
lv_style_scr.body.border.part = LV_BORDER_FULL;
|
||||
|
||||
lv_style_scr.body.shadow.color = LV_COLOR_GRAY;
|
||||
lv_style_scr.body.shadow.type = LV_SHADOW_FULL;
|
||||
lv_style_scr.body.shadow.width = 0;
|
||||
|
||||
lv_style_scr.text.opa = LV_OPA_COVER;
|
||||
lv_style_scr.text.color = LV_COLOR_MAKE(0x30, 0x30, 0x30);
|
||||
lv_style_scr.text.font = LV_FONT_DEFAULT;
|
||||
lv_style_scr.text.letter_space = 2;
|
||||
lv_style_scr.text.line_space = 2;
|
||||
|
||||
lv_style_scr.image.opa = LV_OPA_COVER;
|
||||
lv_style_scr.image.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.image.intense = LV_OPA_TRANSP;
|
||||
|
||||
lv_style_scr.line.opa = LV_OPA_COVER;
|
||||
lv_style_scr.line.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_scr.line.width = 1;
|
||||
|
||||
/*Plain style (by default near the same as the screen style)*/
|
||||
memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t));
|
||||
|
||||
/*Plain color style*/
|
||||
memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_plain_color.text.color = LV_COLOR_MAKE(0xf0, 0xf0, 0xf0);
|
||||
lv_style_plain_color.image.color = LV_COLOR_MAKE(0xf0, 0xf0, 0xf0);
|
||||
lv_style_plain_color.line.color = LV_COLOR_MAKE(0xf0, 0xf0, 0xf0);
|
||||
lv_style_plain_color.body.main_color = LV_COLOR_MAKE(0x55, 0x96, 0xd8);
|
||||
lv_style_plain_color.body.grad_color = lv_style_plain_color.body.main_color;
|
||||
|
||||
/*Pretty style */
|
||||
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_pretty.text.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_pretty.image.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_pretty.line.color = LV_COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_style_pretty.body.main_color = LV_COLOR_WHITE;
|
||||
lv_style_pretty.body.grad_color = LV_COLOR_SILVER;
|
||||
lv_style_pretty.body.radius = LV_DPI / 15;
|
||||
lv_style_pretty.body.border.color = LV_COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_style_pretty.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_pretty.body.border.opa = LV_OPA_30;
|
||||
|
||||
/*Pretty color style*/
|
||||
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));
|
||||
lv_style_pretty_color.text.color = LV_COLOR_MAKE(0xe0, 0xe0, 0xe0);
|
||||
lv_style_pretty_color.image.color = LV_COLOR_MAKE(0xe0, 0xe0, 0xe0);
|
||||
lv_style_pretty_color.line.color = LV_COLOR_MAKE(0xc0, 0xc0, 0xc0);
|
||||
lv_style_pretty_color.body.main_color = LV_COLOR_MAKE(0x6b, 0x9a, 0xc7);
|
||||
lv_style_pretty_color.body.grad_color = LV_COLOR_MAKE(0x2b, 0x59, 0x8b);
|
||||
lv_style_pretty_color.body.border.color = LV_COLOR_MAKE(0x15, 0x2c, 0x42);
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_style_transp, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_transp.body.empty = 1;
|
||||
lv_style_transp.glass = 1;
|
||||
lv_style_transp.body.border.width = 0;
|
||||
|
||||
/*Transparent tight style*/
|
||||
memcpy(&lv_style_transp_fit, &lv_style_transp, sizeof(lv_style_t));
|
||||
lv_style_transp_fit.body.padding.hor = 0;
|
||||
lv_style_transp_fit.body.padding.ver = 0;
|
||||
|
||||
/*Transparent fitting size*/
|
||||
memcpy(&lv_style_transp_tight, &lv_style_transp_fit, sizeof(lv_style_t));
|
||||
lv_style_transp_tight.body.padding.inner = 0;
|
||||
|
||||
/*Button released style*/
|
||||
memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t));
|
||||
lv_style_btn_rel.body.main_color = LV_COLOR_MAKE(0x76, 0xa2, 0xd0);
|
||||
lv_style_btn_rel.body.grad_color = LV_COLOR_MAKE(0x19, 0x3a, 0x5d);
|
||||
lv_style_btn_rel.body.radius = LV_DPI / 15;
|
||||
lv_style_btn_rel.body.padding.hor = LV_DPI / 4;
|
||||
lv_style_btn_rel.body.padding.ver = LV_DPI / 6;
|
||||
lv_style_btn_rel.body.padding.inner = LV_DPI / 10;
|
||||
lv_style_btn_rel.body.border.color = LV_COLOR_MAKE(0x0b, 0x19, 0x28);
|
||||
lv_style_btn_rel.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
|
||||
lv_style_btn_rel.body.border.opa = LV_OPA_70;
|
||||
lv_style_btn_rel.text.color = LV_COLOR_MAKE(0xff, 0xff, 0xff);
|
||||
lv_style_btn_rel.body.shadow.color = LV_COLOR_GRAY;
|
||||
lv_style_btn_rel.body.shadow.width = 0;
|
||||
|
||||
/*Button pressed style*/
|
||||
memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_pr.body.main_color = LV_COLOR_MAKE(0x33, 0x62, 0x94);
|
||||
lv_style_btn_pr.body.grad_color = LV_COLOR_MAKE(0x10, 0x26, 0x3c);
|
||||
lv_style_btn_pr.text.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
lv_style_btn_pr.image.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
lv_style_btn_pr.line.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button toggle released style*/
|
||||
memcpy(&lv_style_btn_tgl_rel, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_tgl_rel.body.main_color = LV_COLOR_MAKE(0x0a, 0x11, 0x22);
|
||||
lv_style_btn_tgl_rel.body.grad_color = LV_COLOR_MAKE(0x37, 0x62, 0x90);
|
||||
lv_style_btn_tgl_rel.body.border.color = LV_COLOR_MAKE(0x01, 0x07, 0x0d);
|
||||
lv_style_btn_tgl_rel.text.color = LV_COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
lv_style_btn_tgl_rel.image.color = LV_COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
lv_style_btn_tgl_rel.line.color = LV_COLOR_MAKE(0xc8, 0xdd, 0xf4);
|
||||
|
||||
/*Button toggle pressed style*/
|
||||
memcpy(&lv_style_btn_tgl_pr, &lv_style_btn_tgl_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_tgl_pr.body.main_color = LV_COLOR_MAKE(0x02, 0x14, 0x27);
|
||||
lv_style_btn_tgl_pr.body.grad_color = LV_COLOR_MAKE(0x2b, 0x4c, 0x70);
|
||||
lv_style_btn_tgl_pr.text.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
lv_style_btn_tgl_pr.image.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
lv_style_btn_tgl_pr.line.color = LV_COLOR_MAKE(0xa4, 0xb5, 0xc6);
|
||||
|
||||
/*Button inactive style*/
|
||||
memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t));
|
||||
lv_style_btn_ina.body.main_color = LV_COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.body.grad_color = LV_COLOR_MAKE(0xd8, 0xd8, 0xd8);
|
||||
lv_style_btn_ina.body.border.color = LV_COLOR_MAKE(0x90, 0x90, 0x90);
|
||||
lv_style_btn_ina.text.color = LV_COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
lv_style_btn_ina.image.color = LV_COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
lv_style_btn_ina.line.color = LV_COLOR_MAKE(0x70, 0x70, 0x70);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
* @param dest pointer to the destination style
|
||||
* @param src pointer to the source style
|
||||
*/
|
||||
void lv_style_copy(lv_style_t * dest, const lv_style_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(lv_style_t));
|
||||
}
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
/**
|
||||
* Create an animation from a pre-configured 'lv_style_anim_t' variable
|
||||
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
|
||||
*/
|
||||
void lv_style_anim_create(lv_style_anim_t * anim)
|
||||
{
|
||||
lv_style_anim_dsc_t * dsc;
|
||||
dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t));
|
||||
dsc->style_anim = anim->style_anim;
|
||||
memcpy(&dsc->style_start, anim->style_start, sizeof(lv_style_t));
|
||||
memcpy(&dsc->style_end, anim->style_end, sizeof(lv_style_t));
|
||||
dsc->end_cb = anim->end_cb;
|
||||
|
||||
|
||||
lv_anim_t a;
|
||||
a.var = (void*)dsc;
|
||||
a.start = 0;
|
||||
a.end = LV_STYLE_ANIM_RES;
|
||||
a.fp = (lv_anim_fp_t)style_animator;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.end_cb = style_animation_common_end_cb;
|
||||
a.act_time = anim->act_time;
|
||||
a.time = anim->time;
|
||||
a.playback = anim->playback;
|
||||
a.playback_pause = anim->playback_pause;
|
||||
a.repeat = anim->repeat;
|
||||
a.repeat_pause = anim->repeat_pause;
|
||||
|
||||
lv_anim_create(&a);
|
||||
}
|
||||
#endif
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
#if USE_LV_ANIMATION
|
||||
/**
|
||||
* Used by the style animations to set the values of a style according to start and end style.
|
||||
* @param dsc the 'animated variable' set by lv_style_anim_create()
|
||||
* @param val the current state of the animation between 0 and LV_STYLE_ANIM_RES
|
||||
*/
|
||||
static void style_animator(lv_style_anim_dsc_t * dsc, int32_t val)
|
||||
{
|
||||
const lv_style_t * start = &dsc->style_start;
|
||||
const lv_style_t * end = &dsc->style_end;
|
||||
lv_style_t * act = dsc->style_anim;
|
||||
|
||||
STYLE_ATTR_ANIM(body.opa, val);
|
||||
STYLE_ATTR_ANIM(body.radius, val);
|
||||
STYLE_ATTR_ANIM(body.border.width, val);
|
||||
STYLE_ATTR_ANIM(body.shadow.width, val);
|
||||
STYLE_ATTR_ANIM(body.padding.hor, val);
|
||||
STYLE_ATTR_ANIM(body.padding.ver, val);
|
||||
STYLE_ATTR_ANIM(body.padding.inner, val);
|
||||
STYLE_ATTR_ANIM(text.line_space, val);
|
||||
STYLE_ATTR_ANIM(text.letter_space, val);
|
||||
STYLE_ATTR_ANIM(line.width, val);
|
||||
STYLE_ATTR_ANIM(image.intense, val);
|
||||
|
||||
lv_opa_t opa = val == LV_STYLE_ANIM_RES ? LV_OPA_COVER : val;
|
||||
|
||||
act->body.main_color = lv_color_mix(end->body.main_color, start->body.main_color, opa);
|
||||
act->body.grad_color = lv_color_mix(end->body.grad_color, start->body.grad_color, opa);
|
||||
act->body.border.color = lv_color_mix(end->body.border.color, start->body.border.color, opa);
|
||||
act->body.shadow.color = lv_color_mix(end->body.shadow.color, start->body.shadow.color, opa);
|
||||
act->text.color = lv_color_mix(end->text.color, start->text.color, opa);
|
||||
act->image.color = lv_color_mix(end->image.color, start->image.color, opa);
|
||||
act->line.color = lv_color_mix(end->line.color, start->line.color, opa);
|
||||
|
||||
if(val == 0) {
|
||||
act->body.empty = start->body.empty;
|
||||
act->glass = start->glass;
|
||||
act->text.font = start->text.font;
|
||||
act->body.shadow.type = start->body.shadow.type;
|
||||
}
|
||||
|
||||
if(val == LV_STYLE_ANIM_RES) {
|
||||
act->body.empty = end->body.empty;
|
||||
act->glass = end->glass;
|
||||
act->text.font = end->text.font;
|
||||
act->body.shadow.type = end->body.shadow.type;
|
||||
}
|
||||
|
||||
lv_obj_report_style_mod(dsc->style_anim);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a style animation is ready
|
||||
* It called the user defined call back and free the allocated memories
|
||||
* @param ptr the 'animated variable' set by lv_style_anim_create()
|
||||
*/
|
||||
static void style_animation_common_end_cb(void *ptr)
|
||||
{
|
||||
lv_style_anim_dsc_t *dsc = ptr; /*To avoid casting*/
|
||||
|
||||
if(dsc->end_cb) dsc->end_cb(dsc);
|
||||
|
||||
lv_mem_free(dsc);
|
||||
}
|
||||
|
||||
#endif
|
||||
184
lv_core/lv_style.h
Normal file
184
lv_core/lv_style.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* @file lv_style.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_STYLE_H
|
||||
#define LV_STYLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
#include "../lv_misc/lv_anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_RADIUS_CIRCLE (LV_COORD_MAX) /*A very big radius to always draw as circle*/
|
||||
#define LV_AA LV_ANTIALIAS /*Just a shorter form of LV_ANTIALIAS*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Border types (Use 'OR'ed values)*/
|
||||
typedef enum
|
||||
{
|
||||
LV_BORDER_NONE = 0x00,
|
||||
LV_BORDER_BOTTOM = 0x01,
|
||||
LV_BORDER_TOP = 0x02,
|
||||
LV_BORDER_LEFT = 0x04,
|
||||
LV_BORDER_RIGHT = 0x08,
|
||||
LV_BORDER_FULL = 0x0F,
|
||||
}lv_border_part_t;
|
||||
|
||||
/*Shadow types*/
|
||||
typedef enum
|
||||
{
|
||||
LV_SHADOW_BOTTOM = 0,
|
||||
LV_SHADOW_FULL,
|
||||
}lv_shadow_type_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t glass :1; /*1: Do not inherit this style*/
|
||||
|
||||
struct {
|
||||
lv_color_t main_color;
|
||||
lv_color_t grad_color;
|
||||
lv_coord_t radius;
|
||||
lv_opa_t opa;
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
lv_border_part_t part;
|
||||
lv_opa_t opa;
|
||||
}border;
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
uint8_t type;
|
||||
}shadow;
|
||||
|
||||
struct {
|
||||
lv_coord_t ver;
|
||||
lv_coord_t hor;
|
||||
lv_coord_t inner;
|
||||
}padding;
|
||||
|
||||
uint8_t empty :1; /*Transparent background (border still drawn)*/
|
||||
}body;
|
||||
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
const lv_font_t * font;
|
||||
lv_coord_t letter_space;
|
||||
lv_coord_t line_space;
|
||||
lv_opa_t opa;
|
||||
}text;
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
lv_opa_t intense;
|
||||
lv_opa_t opa;
|
||||
}image;
|
||||
|
||||
struct {
|
||||
lv_color_t color;
|
||||
lv_coord_t width;
|
||||
lv_opa_t opa;
|
||||
}line;
|
||||
}lv_style_t;
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
typedef struct {
|
||||
const lv_style_t * style_start; /*Pointer to the starting style*/
|
||||
const lv_style_t * style_end; /*Pointer to the destination style*/
|
||||
lv_style_t * style_anim; /*Pointer to a style to animate*/
|
||||
lv_anim_cb_t end_cb; /*Call it when the animation is ready (NULL if unused)*/
|
||||
int16_t time; /*Animation time in ms*/
|
||||
int16_t act_time; /*Current time in animation. Set to negative to make delay.*/
|
||||
uint16_t playback_pause; /*Wait before play back*/
|
||||
uint16_t repeat_pause; /*Wait before repeat*/
|
||||
uint8_t playback :1; /*When the animation is ready play it back*/
|
||||
uint8_t repeat :1; /*Repeat the animation infinitely*/
|
||||
}lv_style_anim_t;
|
||||
|
||||
/* Example initialization
|
||||
lv_style_anim_t a;
|
||||
a.style_anim = &style_to_anim;
|
||||
a.style_start = &style_1;
|
||||
a.style_end = &style_2;
|
||||
a.act_time = 0;
|
||||
a.time = 1000;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
a.end_cb = NULL;
|
||||
lv_style_anim_create(&a);
|
||||
*/
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init the basic styles
|
||||
*/
|
||||
void lv_style_init (void);
|
||||
|
||||
/**
|
||||
* Copy a style to an other
|
||||
* @param dest pointer to the destination style
|
||||
* @param src pointer to the source style
|
||||
*/
|
||||
void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
/**
|
||||
* Create an animation from a pre-configured 'lv_style_anim_t' variable
|
||||
* @param anim pointer to a pre-configured 'lv_style_anim_t' variable (will be copied)
|
||||
*/
|
||||
void lv_style_anim_create(lv_style_anim_t * anim);
|
||||
#endif
|
||||
|
||||
/*************************
|
||||
* GLOBAL VARIABLES
|
||||
*************************/
|
||||
extern lv_style_t lv_style_scr;
|
||||
extern lv_style_t lv_style_transp;
|
||||
extern lv_style_t lv_style_transp_fit;
|
||||
extern lv_style_t lv_style_transp_tight;
|
||||
extern lv_style_t lv_style_plain;
|
||||
extern lv_style_t lv_style_plain_color;
|
||||
extern lv_style_t lv_style_pretty;
|
||||
extern lv_style_t lv_style_pretty_color;
|
||||
extern lv_style_t lv_style_btn_rel;
|
||||
extern lv_style_t lv_style_btn_pr;
|
||||
extern lv_style_t lv_style_btn_tgl_rel;
|
||||
extern lv_style_t lv_style_btn_tgl_pr;;
|
||||
extern lv_style_t lv_style_btn_ina;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_STYLE_H*/
|
||||
@@ -2,10 +2,10 @@
|
||||
* @file lv_vdb.c
|
||||
*
|
||||
*/
|
||||
#include "lv_conf.h"
|
||||
#include "../../lv_conf.h"
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "hal/disp/disp.h"
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include <stddef.h>
|
||||
#include "lv_vdb.h"
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
#if LV_VDB_DOUBLE != 0
|
||||
typedef enum {
|
||||
LV_VDB_STATE_FREE = 0,
|
||||
LV_VDB_STATE_ACTIVE,
|
||||
LV_VDB_STATE_FLUSH,
|
||||
} lv_vdb_state_t;
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
@@ -34,11 +33,31 @@ typedef enum {
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
static lv_vdb_t vdb;
|
||||
/*Simple VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state = LV_VDB_STATE_ACTIVE;
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb = {.buf = vdb_buf};
|
||||
# else
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb = {.buf = (lv_color_t *)LV_VDB_ADR};
|
||||
# endif
|
||||
#else
|
||||
static lv_vdb_t vdb[2];
|
||||
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
|
||||
/*Double VDB*/
|
||||
static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_FREE};
|
||||
# if LV_VDB_ADR == 0
|
||||
/*If the buffer address is not specified simply allocate it*/
|
||||
static lv_color_t vdb_buf1[LV_VDB_SIZE];
|
||||
static lv_color_t vdb_buf2[LV_VDB_SIZE];
|
||||
static lv_vdb_t vdb[2] = {{.buf = vdb_buf1}, {.buf = vdb_buf2}};
|
||||
# else
|
||||
/*If the buffer address is specified use that address*/
|
||||
static lv_vdb_t vdb[2] = {{.buf = (lv_color_t *)LV_VDB_ADR}, {.buf = (lv_color_t *)LV_VDB2_ADR}};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
@@ -51,11 +70,14 @@ static volatile lv_vdb_state_t vdb_state[2] = {LV_VDB_STATE_FREE, LV_VDB_STATE_F
|
||||
|
||||
/**
|
||||
* Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode
|
||||
* @return pointer to the 'vdb' variable
|
||||
* @return pointer to a 'vdb' variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void)
|
||||
{
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
/* Wait until VDB become ACTIVE from FLUSH by the
|
||||
* user call of 'lv_flush_ready()' in display drivers's flush function*/
|
||||
while(vdb_state != LV_VDB_STATE_ACTIVE);
|
||||
return &vdb;
|
||||
#else
|
||||
/*If already there is an active do nothing*/
|
||||
@@ -85,9 +107,11 @@ void lv_vdb_flush(void)
|
||||
lv_vdb_t * vdb_act = lv_vdb_get();
|
||||
if(vdb_act == NULL) return;
|
||||
|
||||
#if LV_VDB_DOUBLE != 0
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
vdb_state = LV_VDB_STATE_FLUSH; /*User call to 'lv_flush_ready()' will set to ACTIVE 'disp_flush'*/
|
||||
#else
|
||||
/* Wait the pending flush before starting this one
|
||||
* (Don't forget: 'lv_vdb_flush_ready' has to be called when flushing is ready)*/
|
||||
* (Don't forget: 'lv_flush_ready()' has to be called when flushing is ready)*/
|
||||
while(vdb_state[0] == LV_VDB_STATE_FLUSH || vdb_state[1] == LV_VDB_STATE_FLUSH);
|
||||
|
||||
/*Turn the active VDB to flushing*/
|
||||
@@ -96,7 +120,7 @@ void lv_vdb_flush(void)
|
||||
#endif
|
||||
|
||||
#if LV_ANTIALIAS == 0
|
||||
disp_map(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
|
||||
lv_disp_flush(vdb_act->area.x1, vdb_act->area.y1, vdb_act->area.x2, vdb_act->area.y2, vdb_act->buf);
|
||||
#else
|
||||
/* Get the average of 2x2 pixels and put the result back to the VDB
|
||||
* The reading goes much faster then the write back
|
||||
@@ -105,16 +129,16 @@ void lv_vdb_flush(void)
|
||||
* -----------------------------
|
||||
* in1_buf |2,2|6,8| 3,7
|
||||
* in2_buf |4,4|7,7| 1,2
|
||||
* --------- ==>
|
||||
* --------- ==>
|
||||
* in1_buf |1,1|1,3|
|
||||
* in2_buf |1,1|1,3|
|
||||
* */
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
cord_t w = area_get_width(&vdb_act->area);
|
||||
color_t * in1_buf = vdb_act->buf; /*Pointer to the first row*/
|
||||
color_t * in2_buf = vdb_act->buf + w; /*Pointer to the second row*/
|
||||
color_t * out_buf = vdb_act->buf; /*Store the result here*/
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
lv_coord_t w = lv_area_get_width(&vdb_act->area);
|
||||
lv_color_t * in1_buf = vdb_act->buf; /*Pointer to the first row*/
|
||||
lv_color_t * in2_buf = vdb_act->buf + w; /*Pointer to the second row*/
|
||||
lv_color_t * out_buf = vdb_act->buf; /*Store the result here*/
|
||||
for(y = vdb_act->area.y1; y < vdb_act->area.y2; y += 2) {
|
||||
for(x = vdb_act->area.x1; x < vdb_act->area.x2; x += 2) {
|
||||
|
||||
@@ -146,17 +170,18 @@ void lv_vdb_flush(void)
|
||||
|
||||
/* Now the full the VDB is filtered and the result is stored in the first quarter of it
|
||||
* Write out the filtered map to the display*/
|
||||
disp_map(vdb_act->area.x1 >> 1, vdb_act->area.y1 >> 1, vdb_act->area.x2 >> 1, vdb_act->area.y2 >> 1, vdb_act->buf);
|
||||
lv_disp_flush(vdb_act->area.x1 >> 1, vdb_act->area.y1 >> 1, vdb_act->area.x2 >> 1, vdb_act->area.y2 >> 1, vdb_act->buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* In 'LV_VDB_DOUBLE' mode has to be called when the 'disp_map'
|
||||
* is ready with copying the map to a frame buffer.
|
||||
* Call in the display driver's 'disp_flush' function when the flushing is finished
|
||||
*/
|
||||
void lv_vdb_flush_ready(void)
|
||||
void lv_flush_ready(void)
|
||||
{
|
||||
#if LV_VDB_DOUBLE != 0
|
||||
#if LV_VDB_DOUBLE == 0
|
||||
vdb_state = LV_VDB_STATE_ACTIVE;
|
||||
#else
|
||||
if(vdb_state[0] == LV_VDB_STATE_FLUSH) vdb_state[0] = LV_VDB_STATE_FREE;
|
||||
if(vdb_state[1] == LV_VDB_STATE_FLUSH) vdb_state[1] = LV_VDB_STATE_FREE;
|
||||
#endif
|
||||
@@ -166,4 +191,13 @@ void lv_vdb_flush_ready(void)
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Just for compatibility
|
||||
*/
|
||||
void lv_flush_ready(void)
|
||||
{
|
||||
/*Do nothing. It is used only for VDB*/
|
||||
}
|
||||
#endif
|
||||
@@ -13,12 +13,12 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -30,8 +30,8 @@ extern "C" {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
area_t area;
|
||||
color_t buf[LV_VDB_SIZE];
|
||||
lv_area_t area;
|
||||
lv_color_t *buf;
|
||||
}lv_vdb_t;
|
||||
|
||||
/**********************
|
||||
@@ -40,7 +40,7 @@ typedef struct
|
||||
|
||||
/**
|
||||
* Get the 'vdb' variable or allocate one in LV_VDB_DOUBLE mode
|
||||
* @return pointer to the 'vdb' variable
|
||||
* @return pointer to a 'vdb' variable
|
||||
*/
|
||||
lv_vdb_t * lv_vdb_get(void);
|
||||
|
||||
@@ -54,13 +54,17 @@ void lv_vdb_flush(void);
|
||||
* In 'LV_VDB_DOUBLE' mode has to be called when 'disp_map()'
|
||||
* is ready with copying the map to a frame buffer.
|
||||
*/
|
||||
void lv_vdb_flush_ready(void);
|
||||
void lv_flush_ready(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_VDB_SIZE != 0*/
|
||||
#else /*LV_VDB_SIZE != 0*/
|
||||
|
||||
/*Just for compatibility*/
|
||||
void lv_flush_ready(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
1357
lv_draw/lv_draw.c
1357
lv_draw/lv_draw.c
File diff suppressed because it is too large
Load Diff
@@ -13,9 +13,8 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "../lv_obj/lv_style.h"
|
||||
#include "../lv_core/lv_style.h"
|
||||
#include "../lv_misc/lv_txt.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -25,6 +24,17 @@ extern "C" {
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Image header it is compatible with
|
||||
* the result image converter utility*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t w:12; /*Width of the image map*/
|
||||
uint32_t h:12; /*Height of the image map*/
|
||||
uint32_t transp:1; /*1: The image contains transparent pixels with LV_COLOR_TRANSP color*/
|
||||
uint32_t cd:3; /*Color depth (0: reserved, 1: 8 bit, 2: 16 bit or 3: 24 bit, 4-7: reserved)*/
|
||||
uint32_t res :4; /*Reserved*/
|
||||
}lv_img_raw_header_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
@@ -35,7 +45,7 @@ extern "C" {
|
||||
* @param mask_p the rectangle will be drawn only in this mask
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_t * style_p);
|
||||
void lv_draw_rect(const lv_area_t * cords_p, const lv_area_t * mask_p, const lv_style_t * style_p);
|
||||
|
||||
|
||||
/*Experimental use for 3D modeling*/
|
||||
@@ -47,7 +57,7 @@ void lv_draw_rect(const area_t * cords_p, const area_t * mask_p, const lv_style_
|
||||
* @param mask_p the triangle will be drawn only in this mask
|
||||
* @param color color of the triangle
|
||||
*/
|
||||
void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t color);
|
||||
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask_p, lv_color_t color);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -59,17 +69,19 @@ void lv_draw_triangle(const point_t * points, const area_t * mask_p, color_t col
|
||||
* @param flags settings for the text from 'txt_flag_t' enum
|
||||
* @param offset text offset in x and y direction (NULL if unused)
|
||||
*/
|
||||
void lv_draw_label(const area_t * cords_p,const area_t * mask_p, const lv_style_t * style_p,
|
||||
const char * txt, txt_flag_t flag, point_t * offset);
|
||||
void lv_draw_label(const lv_area_t * cords_p,const lv_area_t * mask_p, const lv_style_t * style_p,
|
||||
const char * txt, lv_txt_flag_t flag, lv_point_t * offset);
|
||||
|
||||
#if USE_LV_IMG
|
||||
/**
|
||||
* Draw an image
|
||||
* @param cords_p the coordinates of the image
|
||||
* @param mask_p the image will be drawn only in this area
|
||||
* @param map_p pointer to a color_t array which contains the pixels of the image
|
||||
* @param map_p pointer to a lv_color_t array which contains the pixels of the image
|
||||
*/
|
||||
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
void lv_draw_img(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const lv_style_t * style_p, const char * fn);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
@@ -78,7 +90,7 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param mask_pthe line will be drawn only on this area
|
||||
* @param style_p pointer to a style
|
||||
*/
|
||||
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
|
||||
void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t * mask_p,
|
||||
const lv_style_t * style_p);
|
||||
|
||||
/**********************
|
||||
|
||||
8
lv_draw/lv_draw.mk
Normal file
8
lv_draw/lv_draw.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
CSRCS += lv_draw_vbasic.c
|
||||
CSRCS += lv_draw.c
|
||||
CSRCS += lv_draw_rbasic.c
|
||||
|
||||
DEPPATH += --dep-path lvgl/lv_draw
|
||||
VPATH += :lvgl/lv_draw
|
||||
|
||||
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_draw"
|
||||
@@ -6,10 +6,10 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_conf.h"
|
||||
#include "hal/disp/disp.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "../../lv_conf.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -43,15 +43,17 @@
|
||||
* @param color color of the pixel
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vpx)
|
||||
*/
|
||||
void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
area_t area;
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vpx*/
|
||||
|
||||
lv_area_t area;
|
||||
area.x1 = x;
|
||||
area.y1 = y;
|
||||
area.x2 = x;
|
||||
area.y2 = y;
|
||||
|
||||
lv_rfill(&area, mask_p, color, OPA_COVER);
|
||||
lv_rfill(&area, mask_p, color, LV_OPA_COVER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,23 +63,25 @@ void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
area_t masked_area;
|
||||
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vfill*/
|
||||
|
||||
lv_area_t masked_area;
|
||||
bool union_ok = true;
|
||||
|
||||
if(mask_p != NULL) {
|
||||
union_ok = area_union(&masked_area, cords_p, mask_p);
|
||||
union_ok = lv_area_union(&masked_area, cords_p, mask_p);
|
||||
} else {
|
||||
area_t scr_area;
|
||||
area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_VER_RES - 1);
|
||||
union_ok = area_union(&masked_area, cords_p, &scr_area);
|
||||
lv_area_t scr_area;
|
||||
lv_area_set(&scr_area, 0, 0, LV_HOR_RES - 1, LV_HOR_RES - 1);
|
||||
union_ok = lv_area_union(&masked_area, cords_p, &scr_area);
|
||||
}
|
||||
|
||||
|
||||
if(union_ok != false){
|
||||
disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
lv_disp_fill(masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,15 +94,22 @@ void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa)
|
||||
void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
uint8_t w = font_get_width(font_p, letter);
|
||||
const uint8_t * bitmap_p = font_get_bitmap(font_p, letter);
|
||||
(void)opa; /*Opa is used only for compatibility with lv_vletter*/
|
||||
|
||||
uint8_t w = lv_font_get_width(font_p, letter);
|
||||
|
||||
if(letter == 'C') {
|
||||
letter = 'C';
|
||||
}
|
||||
|
||||
const uint8_t * bitmap_p = lv_font_get_bitmap(font_p, letter);
|
||||
|
||||
uint8_t col, col_sub, row;
|
||||
#if FONT_ANTIALIAS == 0
|
||||
#if LV_FONT_ANTIALIAS == 0
|
||||
for(row = 0; row < font_p->height_row; row ++) {
|
||||
for(col = 0, col_sub = 7; col < w; col ++, col_sub--) {
|
||||
if(*bitmap_p & (1 << col_sub)) {
|
||||
@@ -110,15 +121,14 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
col_sub = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/*Correction if the letter is short*/
|
||||
bitmap_p += font_p->width_byte - ((w >> 3) + 1);
|
||||
/*Go to the next row*/
|
||||
bitmap_p ++;
|
||||
if(col_sub != 7) bitmap_p ++; /*Go to the next byte if it not done in the last step*/
|
||||
}
|
||||
#else
|
||||
uint8_t width_byte = w >> 3; /*Width in bytes (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(w & 0x7) width_byte++;
|
||||
const uint8_t * map1_p = bitmap_p;
|
||||
const uint8_t * map2_p = bitmap_p + font_p->width_byte;
|
||||
const uint8_t * map2_p = bitmap_p + width_byte;
|
||||
uint8_t px_cnt;
|
||||
uint8_t col_byte_cnt;
|
||||
for(row = 0; row < (font_p->height_row >> 1); row ++) {
|
||||
@@ -148,14 +158,14 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
|
||||
|
||||
if(px_cnt != 0) {
|
||||
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, color_mix(color, COLOR_SILVER, 63 * px_cnt), OPA_COVER);
|
||||
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, lv_color_mix(color, LV_COLOR_SILVER, 63 * px_cnt), LV_OPA_COVER);
|
||||
}
|
||||
}
|
||||
|
||||
map1_p += font_p->width_byte;
|
||||
map2_p += font_p->width_byte;
|
||||
map1_p += font_p->width_byte - col_byte_cnt;
|
||||
map2_p += font_p->width_byte - col_byte_cnt;
|
||||
map1_p += width_byte;
|
||||
map2_p += width_byte;
|
||||
map1_p += width_byte - col_byte_cnt;
|
||||
map2_p += width_byte - col_byte_cnt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -164,44 +174,49 @@ void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param transp true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const lv_color_t * map_p, lv_opa_t opa, bool transp, bool upscale,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
(void)opa; /*opa is used only for compatibility with lv_vmap*/
|
||||
(void)recolor_opa; /*recolor_opa is used only for compatibility with lv_vmap*/
|
||||
(void)recolor; /*recolor is used only for compatibility with lv_vmap*/
|
||||
(void)upscale; /*upscale is used only for compatibility with lv_vmap*/
|
||||
|
||||
lv_area_t masked_a;
|
||||
bool union_ok;
|
||||
|
||||
union_ok = area_union(&masked_a, cords_p, mask_p);
|
||||
union_ok = lv_area_union(&masked_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the mask and map then draw the map*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
/*Go to the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p);
|
||||
lv_coord_t map_width = lv_area_get_width(cords_p);
|
||||
map_p+= (masked_a.y1 - cords_p->y1) * map_width;
|
||||
map_p += masked_a.x1 - cords_p->x1;
|
||||
|
||||
if(transp == false) {
|
||||
cord_t row;
|
||||
cord_t mask_w = area_get_width(&masked_a) - 1;
|
||||
for(row = 0; row < area_get_height(&masked_a); row++) {
|
||||
disp_map(masked_a.x1, masked_a.y1 + row, masked_a.x1 + mask_w, masked_a.y1 + row, map_p);
|
||||
lv_coord_t row;
|
||||
lv_coord_t mask_w = lv_area_get_width(&masked_a) - 1;
|
||||
for(row = 0; row < lv_area_get_height(&masked_a); row++) {
|
||||
lv_disp_map(masked_a.x1, masked_a.y1 + row, masked_a.x1 + mask_w, masked_a.y1 + row, map_p);
|
||||
|
||||
map_p += map_width;
|
||||
}
|
||||
}else {
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
cord_t row;
|
||||
for(row = 0; row < area_get_height(&masked_a); row++) {
|
||||
cord_t col;
|
||||
for(col = 0; col < area_get_width(&masked_a); col ++) {
|
||||
lv_color_t transp_color = LV_COLOR_TRANSP;
|
||||
lv_coord_t row;
|
||||
for(row = 0; row < lv_area_get_height(&masked_a); row++) {
|
||||
lv_coord_t col;
|
||||
for(col = 0; col < lv_area_get_width(&masked_a); col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
lv_rpx(masked_a.x1 + col, masked_a.y1 + row, mask_p, map_p[col], opa);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa);
|
||||
void lv_rpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Fill an area on the display
|
||||
@@ -38,8 +38,8 @@ void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
* @param color fill color
|
||||
* @param opa opacity (ignored, only for compatibility with lv_vfill)
|
||||
*/
|
||||
void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
void lv_rfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter to the display
|
||||
@@ -50,24 +50,24 @@ void lv_rfill(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (ignored, only for compatibility with lv_vletter)
|
||||
*/
|
||||
void lv_rletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param transp true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size (not supported)
|
||||
* @param recolor mix the pixels with this color (not supported)
|
||||
* @param recolor_opa the intense of recoloring (not supported)
|
||||
*/
|
||||
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
void lv_rmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const lv_color_t * map_p, lv_opa_t opa, bool transp, bool upscale,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
* @file lv_vdraw.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lv_conf.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "hal/disp/disp.h"
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lvgl/lv_obj/lv_vdb.h"
|
||||
#include "../lv_core/lv_vdb.h"
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
@@ -24,6 +26,7 @@
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define VFILL_HW_ACC_SIZE_LIMIT 50 /*Always fill < 50 px with 'sw_color_fill' because of the hw. init overhead*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
@@ -32,8 +35,8 @@
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void sw_color_cpy(color_t * dest, const color_t * src, uint32_t length, opa_t opa);
|
||||
static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_area, color_t color, opa_t opa);
|
||||
static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -47,7 +50,6 @@ static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Put a pixel in the Virtual Display Buffer
|
||||
* @param x pixel x coordinate
|
||||
@@ -56,7 +58,7 @@ static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_
|
||||
* @param color pixel color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
@@ -66,17 +68,17 @@ void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t vdb_width = area_get_width(&vdb_p->area);
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
|
||||
/*Make the coordinates relative to VDB*/
|
||||
x-=vdb_p->area.x1;
|
||||
y-=vdb_p->area.y1;
|
||||
color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
|
||||
if(opa == OPA_COVER) {
|
||||
lv_color_t * vdb_px_p = vdb_p->buf + y * vdb_width + x;
|
||||
if(opa == LV_OPA_COVER) {
|
||||
*vdb_px_p = color;
|
||||
}
|
||||
else {
|
||||
*vdb_px_p = color_mix(color,*vdb_px_p, opa);
|
||||
*vdb_px_p = lv_color_mix(color,*vdb_px_p, opa);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,53 +91,104 @@ void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
area_t res_a;
|
||||
lv_area_t res_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Get the union of cord and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
union_ok = area_union(&res_a, cords_p, mask_p);
|
||||
union_ok = lv_area_union(&res_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
|
||||
lv_area_t vdb_rel_a; /*Stores relative coordinates on vdb*/
|
||||
vdb_rel_a.x1 = res_a.x1 - vdb_p->area.x1;
|
||||
vdb_rel_a.y1 = res_a.y1 - vdb_p->area.y1;
|
||||
vdb_rel_a.x2 = res_a.x2 - vdb_p->area.x1;
|
||||
vdb_rel_a.y2 = res_a.y2 - vdb_p->area.y1;
|
||||
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
uint32_t vdb_width = area_get_width(&vdb_p->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
uint32_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
/*Move the vdb_tmp to the first row*/
|
||||
vdb_buf_tmp += vdb_width * vdb_rel_a.y1;
|
||||
|
||||
#if DISP_HW_ACC == 0
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
#else
|
||||
static color_t color_map[LV_HOR_RES];
|
||||
static cord_t last_width = 0;
|
||||
cord_t map_width = area_get_width(&vdb_rel_a);
|
||||
if(color_map[0].full != color.full || last_width != map_width) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < map_width; i++) {
|
||||
color_map[i].full = color.full;
|
||||
}
|
||||
|
||||
last_width = map_width;
|
||||
}
|
||||
cord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
disp_color_cpy(&vdb_buf_tmp[vdb_rel_a.x1], color_map, map_width, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
#if USE_LV_GPU
|
||||
static lv_color_t color_array_tmp[LV_HOR_RES << LV_ANTIALIAS]; /*Used by 'sw_color_fill'*/
|
||||
static lv_coord_t last_width = -1;
|
||||
|
||||
lv_coord_t w = lv_area_get_width(&vdb_rel_a);
|
||||
/*Don't use hw. acc. for every small fill (because of the init overhead)*/
|
||||
if(w < VFILL_HW_ACC_SIZE_LIMIT) {
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
}
|
||||
#endif
|
||||
/*Not opaque fill*/
|
||||
else if(opa == LV_OPA_COVER) {
|
||||
/*Use hw fill if present*/
|
||||
if(lv_disp_is_mem_fill_supported()) {
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_fill(&vdb_buf_tmp[vdb_rel_a.x1], w, color);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
}
|
||||
/*Use hw blend if present and the area is not too small*/
|
||||
else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT &&
|
||||
lv_disp_is_mem_blend_supported())
|
||||
{
|
||||
if(color_array_tmp[0].full != color.full || last_width != w) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < w; i++) {
|
||||
color_array_tmp[i].full = color.full;
|
||||
}
|
||||
last_width = w;
|
||||
}
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
|
||||
}
|
||||
/*Else use sw fill if no better option*/
|
||||
else {
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
/*Fill with opacity*/
|
||||
else {
|
||||
/*Use hw blend if present*/
|
||||
if(lv_disp_is_mem_blend_supported()) {
|
||||
if(color_array_tmp[0].full != color.full || last_width != w) {
|
||||
uint16_t i;
|
||||
for(i = 0; i < w; i++) {
|
||||
color_array_tmp[i].full = color.full;
|
||||
}
|
||||
|
||||
last_width = w;
|
||||
}
|
||||
lv_coord_t row;
|
||||
for(row = vdb_rel_a.y1;row <= vdb_rel_a.y2; row++) {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[vdb_rel_a.x1], color_array_tmp, w, opa);
|
||||
vdb_buf_tmp += vdb_width;
|
||||
}
|
||||
|
||||
}
|
||||
/*Use sw fill with opa if no better option*/
|
||||
else {
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
sw_color_fill(&vdb_p->area, vdb_buf_tmp, &vdb_rel_a, color, opa);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,16 +200,16 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa)
|
||||
void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t letter_w = font_get_width(font_p, letter);
|
||||
uint8_t letter_h = font_get_height(font_p);
|
||||
uint8_t letter_w = lv_font_get_width(font_p, letter);
|
||||
uint8_t letter_h = lv_font_get_height(font_p);
|
||||
|
||||
const uint8_t * map_p = font_get_bitmap(font_p, letter);
|
||||
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
|
||||
|
||||
if(map_p == NULL) return;
|
||||
|
||||
@@ -165,18 +218,20 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
cord_t vdb_width = area_get_width(&vdb_p->area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
cord_t col, row;
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
lv_coord_t col, row;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
uint8_t width_byte = letter_w >> 3; /*Width in bytes (e.g. w = 11 -> 2 bytes wide)*/
|
||||
if(letter_w & 0x7) width_byte++;
|
||||
|
||||
/* Calculate the col/row start/end on the map
|
||||
* If font anti alaiassing is enabled use the reduced letter sizes*/
|
||||
cord_t col_start = pos_p->x > mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
cord_t col_end = pos_p->x + (letter_w >> FONT_ANTIALIAS) < mask_p->x2 ? (letter_w >> FONT_ANTIALIAS) : mask_p->x2 - pos_p->x + 1;
|
||||
cord_t row_start = pos_p->y > mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
cord_t row_end = pos_p->y + (letter_h >> FONT_ANTIALIAS) < mask_p->y2 ? (letter_h >> FONT_ANTIALIAS) : mask_p->y2 - pos_p->y + 1;
|
||||
lv_coord_t col_start = pos_p->x > mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
lv_coord_t col_end = pos_p->x + (letter_w >> LV_FONT_ANTIALIAS) < mask_p->x2 ? (letter_w >> LV_FONT_ANTIALIAS) : mask_p->x2 - pos_p->x + 1;
|
||||
lv_coord_t row_start = pos_p->y > mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
lv_coord_t row_end = pos_p->y + (letter_h >> LV_FONT_ANTIALIAS) < mask_p->y2 ? (letter_h >> LV_FONT_ANTIALIAS) : mask_p->y2 - pos_p->y + 1;
|
||||
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_p->y - vdb_p->area.y1) * vdb_width)
|
||||
@@ -186,17 +241,17 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
|
||||
/*Move on the map too*/
|
||||
map_p += ((row_start << FONT_ANTIALIAS) * font_p->width_byte) + ((col_start << FONT_ANTIALIAS) >> 3);
|
||||
map_p += ((row_start << LV_FONT_ANTIALIAS) * width_byte) + ((col_start << LV_FONT_ANTIALIAS) >> 3);
|
||||
|
||||
#if FONT_ANTIALIAS != 0
|
||||
opa_t opa_tmp = opa;
|
||||
if(opa_tmp != OPA_COVER) opa_tmp = opa_tmp >> 2; /*Opacity per pixel (used when sum the pixels)*/
|
||||
#if LV_FONT_ANTIALIAS != 0
|
||||
lv_opa_t opa_tmp = opa;
|
||||
if(opa_tmp != LV_OPA_COVER) opa_tmp = opa_tmp >> 2; /*Opacity per pixel (used when sum the pixels)*/
|
||||
const uint8_t * map1_p = map_p;
|
||||
const uint8_t * map2_p = map_p + font_p->width_byte;
|
||||
const uint8_t * map2_p = map_p + width_byte;
|
||||
uint8_t px_cnt;
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - ((col_start << FONT_ANTIALIAS) % 8);
|
||||
col_bit = 7 - ((col_start << LV_FONT_ANTIALIAS) % 8);
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
px_cnt = 0;
|
||||
@@ -219,19 +274,18 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
map2_p ++;
|
||||
}
|
||||
|
||||
|
||||
if(px_cnt != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, 63*px_cnt);
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa_tmp * px_cnt);
|
||||
if(opa == LV_OPA_COVER) *vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, 63*px_cnt);
|
||||
else *vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, opa_tmp * px_cnt);
|
||||
}
|
||||
|
||||
vdb_buf_tmp++;
|
||||
}
|
||||
|
||||
map1_p += font_p->width_byte;
|
||||
map2_p += font_p->width_byte;
|
||||
map1_p += font_p->width_byte - col_byte_cnt;
|
||||
map2_p += font_p->width_byte - col_byte_cnt;
|
||||
map1_p += width_byte;
|
||||
map2_p += width_byte;
|
||||
map1_p += width_byte - col_byte_cnt;
|
||||
map2_p += width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - ((col_end) - (col_start)); /*Next row in VDB*/
|
||||
}
|
||||
#else
|
||||
@@ -241,8 +295,8 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
if((*map_p & (1 << col_bit)) != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
if(opa == LV_OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
|
||||
vdb_buf_tmp++;
|
||||
@@ -255,7 +309,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
}
|
||||
}
|
||||
|
||||
map_p += font_p->width_byte - col_byte_cnt;
|
||||
map_p += width_byte - col_byte_cnt;
|
||||
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
|
||||
}
|
||||
#endif
|
||||
@@ -265,25 +319,25 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area (truncated to VDB area)
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param transp true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa)
|
||||
void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const lv_color_t * map_p, lv_opa_t opa, bool transp, bool upscale,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa)
|
||||
{
|
||||
area_t masked_a;
|
||||
lv_area_t masked_a;
|
||||
bool union_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*Get the union of map size and mask*/
|
||||
/* The mask is already truncated to the vdb size
|
||||
* in 'lv_refr_area_with_vdb' function */
|
||||
union_ok = area_union(&masked_a, cords_p, mask_p);
|
||||
union_ok = lv_area_union(&masked_a, cords_p, mask_p);
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
@@ -292,7 +346,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
if(upscale != false) ds_shift = 1;
|
||||
|
||||
/*If the map starts OUT of the masked area then calc. the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p) >> ds_shift;
|
||||
lv_coord_t map_width = lv_area_get_width(cords_p) >> ds_shift;
|
||||
if(cords_p->y1 < masked_a.y1) {
|
||||
map_p += (uint32_t) map_width * ((masked_a.y1 - cords_p->y1) >> ds_shift);
|
||||
}
|
||||
@@ -306,8 +360,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
masked_a.x2 = masked_a.x2 - vdb_p->area.x1;
|
||||
masked_a.y2 = masked_a.y2 - vdb_p->area.y1;
|
||||
|
||||
cord_t vdb_width = area_get_width(&vdb_p->area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
lv_coord_t vdb_width = lv_area_get_width(&vdb_p->area);
|
||||
lv_color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/
|
||||
|
||||
map_p -= (masked_a.x1 >> ds_shift); /*Move back. It will be easier to index 'map_p' later*/
|
||||
@@ -315,29 +369,33 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
/*No upscalse*/
|
||||
if(upscale == false) {
|
||||
if(transp == false) { /*Simply copy the pixels to the VDB*/
|
||||
cord_t row;
|
||||
cord_t map_useful_w = area_get_width(&masked_a);
|
||||
lv_coord_t row;
|
||||
lv_coord_t map_useful_w = lv_area_get_width(&masked_a);
|
||||
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
#if DISP_HW_ACC == 0
|
||||
sw_color_cpy(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
#if USE_LV_GPU
|
||||
if(lv_disp_is_mem_blend_supported() == false) {
|
||||
sw_mem_blend(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
} else {
|
||||
lv_disp_mem_blend(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
}
|
||||
#else
|
||||
disp_color_cpy(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
sw_mem_blend(&vdb_buf_tmp[masked_a.x1], &map_p[masked_a.x1], map_useful_w, opa);
|
||||
#endif
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
/*To recolor draw simply a rectangle above the image*/
|
||||
if(recolor_opa != OPA_TRANSP) {
|
||||
if(recolor_opa != LV_OPA_TRANSP) {
|
||||
lv_vfill(cords_p, mask_p, recolor, recolor_opa);
|
||||
}
|
||||
} else { /*transp == true: Check all pixels */
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
lv_coord_t row;
|
||||
lv_coord_t col;
|
||||
lv_color_t transp_color = LV_COLOR_TRANSP;
|
||||
|
||||
if(recolor_opa == OPA_TRANSP) {/*No recolor*/
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
if(recolor_opa == LV_OPA_TRANSP) {/*No recolor*/
|
||||
if(opa == LV_OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
@@ -352,7 +410,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
vdb_buf_tmp[col] = lv_color_mix( map_p[col], vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,13 +419,13 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
}
|
||||
}
|
||||
} else { /*Recolor needed*/
|
||||
color_t color_tmp;
|
||||
if(opa == OPA_COVER) { /*no opa */
|
||||
lv_color_t lv_color_tmp;
|
||||
if(opa == LV_OPA_COVER) { /*no opa */
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
lv_color_tmp = lv_color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = lv_color_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,8 +436,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
color_tmp = color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = color_mix(color_tmp, vdb_buf_tmp[col], opa);
|
||||
lv_color_tmp = lv_color_mix(recolor, map_p[col], recolor_opa);
|
||||
vdb_buf_tmp[col] = lv_color_mix(lv_color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,31 +450,34 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
}
|
||||
/*Upscalse*/
|
||||
else {
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
color_t color_tmp;
|
||||
color_t prev_color = COLOR_BLACK;
|
||||
cord_t map_col;
|
||||
lv_coord_t row;
|
||||
lv_coord_t col;
|
||||
lv_color_t transp_color = LV_COLOR_TRANSP;
|
||||
lv_color_t lv_color_tmp;
|
||||
lv_color_t prev_color = LV_COLOR_BLACK;
|
||||
lv_coord_t map_col;
|
||||
|
||||
/*The most simple case (but upscale): 0 opacity, no recolor, no transp. pixels*/
|
||||
if(transp == false && opa == OPA_COVER && recolor_opa == OPA_TRANSP) {
|
||||
cord_t map_col_start = masked_a.x1 >> 1;
|
||||
cord_t map_col_end = masked_a.x2 >> 1;
|
||||
cord_t vdb_col; /*Col. in this row*/
|
||||
cord_t vdb_col2; /*Col. in next row*/
|
||||
if(transp == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) {
|
||||
lv_coord_t map_col_start = masked_a.x1 >> 1;
|
||||
lv_coord_t map_col_end = masked_a.x2 >> 1;
|
||||
lv_coord_t vdb_col; /*Col. in this row*/
|
||||
lv_coord_t vdb_col2; /*Col. in next row*/
|
||||
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row += 2) {
|
||||
map_col_start = masked_a.x1 >> 1;
|
||||
map_col_end = masked_a.x2 >> 1;
|
||||
vdb_col = masked_a.x1;
|
||||
vdb_col2 = masked_a.x1 + vdb_width;
|
||||
for(map_col = map_col_start; map_col <= map_col_end; map_col ++, vdb_col += 2, vdb_col2 += 2) {
|
||||
|
||||
vdb_buf_tmp[vdb_col].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col + 1].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col2].full = map_p[map_col].full;
|
||||
vdb_buf_tmp[vdb_col2 + 1].full = map_p[map_col].full;
|
||||
}
|
||||
|
||||
|
||||
map_p += map_width;
|
||||
vdb_buf_tmp += 2 * vdb_width ; /*+ 2 row on the VDB (2 rows are filled because of the upscale)*/
|
||||
|
||||
@@ -424,27 +485,27 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
}
|
||||
/*Handle other cases*/
|
||||
else {
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
lv_color_tmp = lv_color_mix(recolor, prev_color, recolor_opa);
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
map_col = col >> 1;
|
||||
|
||||
/*Handle recoloring*/
|
||||
if(recolor_opa == OPA_TRANSP) {
|
||||
color_tmp.full = map_p[map_col].full;
|
||||
if(recolor_opa == LV_OPA_TRANSP) {
|
||||
lv_color_tmp.full = map_p[map_col].full;
|
||||
} else {
|
||||
if(map_p[map_col].full != prev_color.full) {
|
||||
prev_color.full = map_p[map_col].full;
|
||||
color_tmp = color_mix(recolor, prev_color, recolor_opa);
|
||||
lv_color_tmp = lv_color_mix(recolor, prev_color, recolor_opa);
|
||||
}
|
||||
}
|
||||
/*Put the NOT transparent pixels*/
|
||||
if(transp == false || map_p[map_col].full != transp_color.full) {
|
||||
/*Handle opacity*/
|
||||
if(opa == OPA_COVER) {
|
||||
vdb_buf_tmp[col] = color_tmp;
|
||||
if(opa == LV_OPA_COVER) {
|
||||
vdb_buf_tmp[col] = lv_color_tmp;
|
||||
} else {
|
||||
vdb_buf_tmp[col] = color_mix( color_tmp, vdb_buf_tmp[col], opa);
|
||||
vdb_buf_tmp[col] = lv_color_mix( lv_color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,23 +520,21 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if DISP_HW_ACC == 0
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity
|
||||
* Blend pixels to destination memory using opacity
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
static void sw_color_cpy(color_t * dest, const color_t * src, uint32_t length, opa_t opa)
|
||||
static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
|
||||
{
|
||||
if(opa == OPA_COVER) {
|
||||
memcpy(dest, src, length * sizeof(color_t));
|
||||
if(opa == LV_OPA_COVER) {
|
||||
memcpy(dest, src, length * sizeof(lv_color_t));
|
||||
} else {
|
||||
cord_t col;
|
||||
uint32_t col;
|
||||
for(col = 0; col < length; col++) {
|
||||
dest[col] = color_mix(src[col], dest[col], opa);
|
||||
dest[col] = lv_color_mix(src[col], dest[col], opa);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,27 +542,29 @@ static void sw_color_cpy(color_t * dest, const color_t * src, uint32_t length, o
|
||||
/**
|
||||
*
|
||||
* @param mem_area coordinates of 'mem' memory area
|
||||
* @param mem a memory address. Considered to a rectangual window according to 'mem_area'
|
||||
* @param mem a memory address. Considered to a rectangular window according to 'mem_area'
|
||||
* @param fill_area coordinates of an area to fill. Relative to 'mem_area'.
|
||||
* @param color fill color
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_area, color_t color, opa_t opa)
|
||||
static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, lv_opa_t opa)
|
||||
{
|
||||
|
||||
/*Set all row in vdb to the given color*/
|
||||
cord_t row;
|
||||
uint32_t col;
|
||||
cord_t mem_width = area_get_width(mem_area);
|
||||
lv_coord_t row;
|
||||
lv_coord_t col;
|
||||
lv_coord_t mem_width = lv_area_get_width(mem_area);
|
||||
|
||||
/*Run simpler function without opacity*/
|
||||
if(opa == OPA_COVER) {
|
||||
if(opa == LV_OPA_COVER) {
|
||||
/*Fill the first row with 'color'*/
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
mem[col] = color;
|
||||
}
|
||||
|
||||
/*Copy the first row to all other rows*/
|
||||
color_t * mem_first = &mem[fill_area->x1];
|
||||
cord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(color_t);
|
||||
lv_color_t * mem_first = &mem[fill_area->x1];
|
||||
lv_coord_t copy_size = (fill_area->x2 - fill_area->x1 + 1) * sizeof(lv_color_t);
|
||||
mem += mem_width;
|
||||
|
||||
for(row = fill_area->y1 + 1; row <= fill_area->y2; row++) {
|
||||
@@ -513,14 +574,14 @@ static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_
|
||||
}
|
||||
/*Calculate with alpha too*/
|
||||
else {
|
||||
color_t bg_tmp = COLOR_BLACK;
|
||||
color_t opa_tmp = color_mix(color, bg_tmp, opa);
|
||||
lv_color_t bg_tmp = LV_COLOR_BLACK;
|
||||
lv_color_t opa_tmp = lv_color_mix(color, bg_tmp, opa);
|
||||
for(row = fill_area->y1; row <= fill_area->y2; row++) {
|
||||
for(col = fill_area->x1; col <= fill_area->x2; col++) {
|
||||
/*If the bg color changed recalculate the result color*/
|
||||
if(mem[col].full != bg_tmp.full) {
|
||||
bg_tmp = mem[col];
|
||||
opa_tmp = color_mix(color, bg_tmp, opa);
|
||||
opa_tmp = lv_color_mix(color, bg_tmp, opa);
|
||||
}
|
||||
mem[col] = opa_tmp;
|
||||
}
|
||||
@@ -528,6 +589,5 @@ static void sw_color_fill(area_t * mem_area, color_t * mem, const area_t * fill_
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*DISP_HW_ACC == 0*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,13 +13,13 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
#include "../lv_misc/lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -33,7 +33,7 @@ extern "C" {
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa);
|
||||
void lv_vpx(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa);
|
||||
/**
|
||||
* Fill an area in the Virtual Display Buffer
|
||||
* @param cords_p coordinates of the area to fill
|
||||
@@ -41,8 +41,8 @@ void lv_vpx(cord_t x, cord_t y, const area_t * mask_p, color_t color, opa_t opa)
|
||||
* @param color fill color
|
||||
* @param opa opacity of the area (0..255)
|
||||
*/
|
||||
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa);
|
||||
void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a letter in the Virtual Display Buffer
|
||||
@@ -53,26 +53,30 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p,
|
||||
* @param color color of letter
|
||||
* @param opa opacity of letter (0..255)
|
||||
*/
|
||||
void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
const font_t * font_p, uint8_t letter,
|
||||
color_t color, opa_t opa);
|
||||
void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
|
||||
const lv_font_t * font_p, uint32_t letter,
|
||||
lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Draw a color map to the display
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area
|
||||
* @param map_p pointer to a color_t array
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param opa opacity of the map (ignored, only for compatibility with lv_vmap)
|
||||
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
|
||||
* @param transp true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param upscale true: upscale to double size
|
||||
* @param recolor mix the pixels with this color
|
||||
* @param recolor_opa the intense of recoloring
|
||||
*/
|
||||
void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
const color_t * map_p, opa_t opa, bool transp, bool upscale,
|
||||
color_t recolor, opa_t recolor_opa);
|
||||
void lv_vmap(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
||||
const lv_color_t * map_p, lv_opa_t opa, bool transp, bool upscale,
|
||||
lv_color_t recolor, lv_opa_t recolor_opa);
|
||||
|
||||
|
||||
/**
|
||||
* Reallocate 'color_map_tmp' to the new hor. res. size. It is used in 'sw_fill'
|
||||
*/
|
||||
void lv_vdraw_refresh_temp_arrays(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* @file lv_ex_hello_world.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Greetings,
|
||||
* this is the first example in the tutorial hence this is the most simple one.
|
||||
* It only creates a Label, set its text, and align to the middle.
|
||||
*
|
||||
* Be sure in lv_conf.h LV_APP_ENEBLE is 0 (just for simplicity)
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_ex_hello_world.h"
|
||||
#if USE_LV_EXAMPLE != 0
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a simple 'Hello world!' label
|
||||
*/
|
||||
void lv_ex_hello_world(void)
|
||||
{
|
||||
/*Create a Label on the current screen*/
|
||||
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
|
||||
|
||||
/*Modify the Label's text*/
|
||||
lv_label_set_text(label1, "Hello world!");
|
||||
|
||||
/* Align the Label to the center
|
||||
* NULL means align on parent (which is the screen now)
|
||||
* 0, 0 at the and means an x, y offset after alignment*/
|
||||
lv_obj_align_us(label1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_EXAMPLE != 0*/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,218 +0,0 @@
|
||||
/**
|
||||
* @file lv_hello_world.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The basic building blocks (components or widgets) in LittlevGL are the graphical objects.
|
||||
* For example:
|
||||
* - Buttons
|
||||
* - Labels
|
||||
* - Charts
|
||||
* - Sliders etc
|
||||
*
|
||||
* In this part you can learn the basics of the objects like creating, positioning, sizing etc.
|
||||
* You will also meet some different object types and their attributes.
|
||||
*
|
||||
* Regardless to the object type the 'lv_obj_t' variable type is used stores the objects
|
||||
* and you can refer to an object with an lv_obj_t pointer (lv_obj_t *)
|
||||
*
|
||||
* INHERITANCE
|
||||
* -------------
|
||||
* Similarly to object oriented languages some kind of inheritance is used
|
||||
* among the object types.
|
||||
*
|
||||
* Every object is derived from the 'Basic object'. (lv_obj)
|
||||
*
|
||||
* The types are backward compatible which means a type can use all the ancestor
|
||||
* attributes/functions too.
|
||||
*
|
||||
* For example a 'Button' is derived from 'Container' which is derived from 'Basic objects'.
|
||||
* Therefore a button can use container attributes like automatically fit size to the content.
|
||||
*
|
||||
* PARENT-CHILD
|
||||
* -------------
|
||||
* A parent can be considered as the container of its children.
|
||||
* Every object has exactly one parent object (except screens).
|
||||
* A parent can have unlimited number of children.
|
||||
* There is no limitation for the type of the parent.
|
||||
*
|
||||
* The children are visible only on their parent. The parts outside will be cropped (not displayed)
|
||||
*
|
||||
* If the parent is moved the children will be moved with it.
|
||||
*
|
||||
* The earlier created object (and its children) will drawn earlier.
|
||||
* Using this layers can be built.
|
||||
*
|
||||
* LEARN MORE
|
||||
* -------------
|
||||
* - General overview: http://www.gl.littlev.hu/objects
|
||||
* - Detailed description of types: http://www.gl.littlev.hu/object-types
|
||||
*
|
||||
* NOTES
|
||||
* -------------
|
||||
* - Be sure 'LV_OBJ_FREE_P' is enabled in 'lv_conf.h'
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_ex_objects.h"
|
||||
#if USE_LV_EXAMPLE != 0
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_action_res_t btn_rel_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t ddlist_action(lv_obj_t * ddlist, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the Object usage example
|
||||
*/
|
||||
void lv_ex_objects(void)
|
||||
{
|
||||
|
||||
/********************
|
||||
* CREATE A SCREEN
|
||||
*******************/
|
||||
|
||||
/* Create a new screen and load it
|
||||
* Screen can be created from any type object
|
||||
* Now a Page is used which is an objects with scrollable content*/
|
||||
lv_obj_t * scr = lv_page_create(NULL, NULL);
|
||||
lv_scr_load(scr);
|
||||
|
||||
|
||||
/****************
|
||||
* ADD A TITLE
|
||||
****************/
|
||||
lv_obj_t * label = lv_label_create(scr, NULL); /*First parameters (scr) is the parent*/
|
||||
lv_label_set_text(label, "Object usage demo"); /*Set the text*/
|
||||
lv_obj_set_x(label, 50); /*Labels are inherited from Basic object so 'lv_obj_...' functions can be used*/
|
||||
|
||||
|
||||
/********************
|
||||
* CREATE TWO BUTTONS
|
||||
********************/
|
||||
|
||||
/*Create a button*/
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL); /*Create a button on the currently loaded screen*/
|
||||
lv_btn_set_rel_action(btn1, btn_rel_action); /*Set function to call when the button is released*/
|
||||
lv_obj_align(btn1, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20); /*Align below the label*/
|
||||
label = lv_label_create(btn1, NULL); /*Create a label on the button (the 'label' variable can be reused)*/
|
||||
lv_label_set_text(label, "Button 1");
|
||||
|
||||
/*Copy the previous button*/
|
||||
lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), btn1); /*Second parameter is an object to copy*/
|
||||
lv_obj_align(btn2, btn1, LV_ALIGN_OUT_RIGHT_MID, 50, 0);/*Align next to the prev. button.*/
|
||||
label = lv_label_create(btn2, NULL); /*Create a label on the button*/
|
||||
lv_label_set_text(label, "Button 2");
|
||||
|
||||
|
||||
/****************
|
||||
* ADD A SLIDER
|
||||
****************/
|
||||
|
||||
/*Add a slider (inheritance: lv_obj -> lv_bar -> lv_slider)*/
|
||||
lv_obj_t * slider = lv_slider_create(scr, NULL); /*Create a slider*/
|
||||
lv_obj_set_size(slider, lv_obj_get_width(lv_scr_act()) / 3, LV_DPI / 3); /*Set the size*/
|
||||
lv_obj_align(slider, btn1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20); /*Align below the first button*/
|
||||
lv_bar_set_value(slider, 30); /*Slider is a 'bar' so set its value like a 'bar'*/
|
||||
|
||||
|
||||
/***********************
|
||||
* ADD A DROP DOWN LIST
|
||||
************************/
|
||||
|
||||
lv_obj_t * ddlist = lv_ddlist_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(ddlist, slider, LV_ALIGN_OUT_RIGHT_TOP, 20, 0); /*Align next to the slider*/
|
||||
lv_obj_set_free_p(ddlist, slider); /*Save the pointer of the slider in the ddlist (used in 'ddlist_action()')*/
|
||||
lv_ddlist_set_options_str(ddlist, "None\nLittle\nHalf\nA lot\nAll"); /*Set the options*/
|
||||
lv_ddlist_set_action(ddlist, ddlist_action); /*Set function to call on new option choose*/
|
||||
lv_obj_set_top(ddlist, true); /*Enable the drop down list always be on the top*/
|
||||
|
||||
|
||||
/****************
|
||||
* CREATE A CHART
|
||||
****************/
|
||||
lv_obj_t * chart = lv_chart_create(lv_scr_act(), NULL); /*Craete the chart*/
|
||||
lv_obj_set_size(chart, lv_obj_get_width(scr) / 2, lv_obj_get_width(scr) / 4); /*Set the size*/
|
||||
lv_obj_align(chart, slider, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 20); /*Align below the slider*/
|
||||
lv_chart_set_dl_width(chart, 3 * LV_DOWNSCALE); /*Set the line width (LV_DOWNSCALE compensates anti-aliasing if enabled)*/
|
||||
|
||||
/*Add a RED data line and set some points*/
|
||||
lv_chart_dl_t * dl1 = lv_chart_add_data_line(chart, COLOR_RED);
|
||||
lv_chart_set_next(chart, dl1, 10);
|
||||
lv_chart_set_next(chart, dl1, 25);
|
||||
lv_chart_set_next(chart, dl1, 45);
|
||||
lv_chart_set_next(chart, dl1, 80);
|
||||
|
||||
/*Add a BLUE data line and set some points*/
|
||||
lv_chart_dl_t * dl2 = lv_chart_add_data_line(chart, COLOR_MAKE(0x40, 0x70, 0xC0));
|
||||
lv_chart_set_next(chart, dl2, 10);
|
||||
lv_chart_set_next(chart, dl2, 25);
|
||||
lv_chart_set_next(chart, dl2, 45);
|
||||
lv_chart_set_next(chart, dl2, 80);
|
||||
lv_chart_set_next(chart, dl2, 75);
|
||||
lv_chart_set_next(chart, dl2, 505);
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called when a button is released
|
||||
* @param btn pointer to the released button
|
||||
* @param dispi pointer to caller display input (e.g. touchpad)
|
||||
* @return LV_ACTION_RES_OK because the object is not deleted in this function
|
||||
*/
|
||||
static lv_action_res_t btn_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/*Increase the button width*/
|
||||
cord_t width = lv_obj_get_width(btn);
|
||||
lv_obj_set_width(btn, width + 20);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new option is chosen in the drop down list
|
||||
* @param ddlist pointer to the drop down list
|
||||
* @param dispi pointer to caller display input (e.g. touchpad)
|
||||
* @return LV_ACTION_RES_OK because the object is not deleted in this function
|
||||
*/
|
||||
static lv_action_res_t ddlist_action(lv_obj_t * ddlist, lv_dispi_t * dispi)
|
||||
{
|
||||
uint16_t opt = lv_ddlist_get_selected(ddlist); /*Get the id of selected option*/
|
||||
|
||||
lv_obj_t * slider = lv_obj_get_free_p(ddlist); /*Get the saved slider*/
|
||||
lv_bar_set_value(slider, (opt * 100) / 4); /*Modify the slider value according to the selection*/
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*USE_LV_EXAMPLE != 0*/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
@@ -1,161 +0,0 @@
|
||||
/**
|
||||
* @file lv_ex_styles.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* You can modify the appearance of the graphical objects with styles.
|
||||
* A style is simple 'lv_style_t' variable.
|
||||
* Objects save the address of this variable so it has to be 'static or 'global'.
|
||||
*
|
||||
* A style contains various attributes to describe rectangle, image or text like
|
||||
* objects at same time. To know which attribute is used by an object see:
|
||||
* http://www.gl.littlev.hu/object-types
|
||||
*
|
||||
* To set a new style for an object use: 'lv_obj_set_style(obj, &style);
|
||||
* If NULL is set as style then the object will inherit the parents style.
|
||||
* For example is you create a style for button the label appearance can be defined there as well.
|
||||
*
|
||||
* You can use built-in styles. 'lv_style_get(LV_STYLE_... , ©)' will give you a pointer to built in style
|
||||
* and copy it to variable (second parameter) if it is not NULL.
|
||||
* By default the objects use the built-in styles.
|
||||
* The built-in styles can be modified in run time to give a new default skin to your GUI.
|
||||
*
|
||||
* Learn more here: http://www.gl.littlev.hu/objects#style
|
||||
* */
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_ex_styles.h"
|
||||
|
||||
#if USE_LV_EXAMPLE != 0
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a simple 'Hello world!' label
|
||||
*/
|
||||
void lv_ex_styles(void)
|
||||
{
|
||||
|
||||
/****************************************
|
||||
* BASE OBJECT + LABEL WITH DEFAULT STYLE
|
||||
****************************************/
|
||||
|
||||
lv_obj_t * obj1;
|
||||
obj1 = lv_obj_create(lv_scr_act(), NULL); /*Create a simple objects*/
|
||||
lv_obj_set_pos(obj1, 10, 10);
|
||||
lv_obj_t * label = lv_label_create(obj1, NULL);
|
||||
|
||||
/*Add a label to the object*/
|
||||
lv_label_set_text(label, "Default");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/****************************************
|
||||
* BASE OBJECT WITH PRETTY COLOR STYLE
|
||||
****************************************/
|
||||
|
||||
lv_obj_t * obj2;
|
||||
obj2 = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(obj2, obj1, LV_ALIGN_OUT_RIGHT_MID, 20, 0); /*Align next to the previous object*/
|
||||
lv_obj_set_style(obj2, lv_style_get(LV_STYLE_PRETTY_COLOR, NULL)); /*Set built in style*/
|
||||
label = lv_label_create(obj2, NULL);
|
||||
|
||||
/* Add a label to the object.
|
||||
* Labels by default inherit the parent's style */
|
||||
lv_label_set_text(label, "Pretty\ncolor");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*****************************
|
||||
* BASE OBJECT WITH NEW STYLE
|
||||
*****************************/
|
||||
|
||||
/* Create a new style */
|
||||
static lv_style_t style_new; /*Styles can't be local variables*/
|
||||
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_new); /*Copy a built-in style as a starting point*/
|
||||
style_new.radius = LV_RADIUS_CIRCLE; /*Fully round corners*/
|
||||
style_new.swidth = 8; /*8 px shadow*/
|
||||
style_new.bwidth = 2; /*2 px border width*/
|
||||
style_new.mcolor = COLOR_WHITE; /*White main color*/
|
||||
style_new.gcolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_40); /*light blue gradient color*/
|
||||
style_new.scolor = COLOR_MAKE(0xa0, 0xa0, 0xa0); /*Light gray shadow color*/
|
||||
style_new.ccolor = color_mix(COLOR_BLUE, COLOR_WHITE, OPA_90); /*Blue content color (text color)*/
|
||||
style_new.letter_space = 10; /*10 px letter space*/
|
||||
style_new.txt_align = LV_TXT_ALIGN_MID; /*Middel text align*/
|
||||
|
||||
/*Create a base object and apply the new style*/
|
||||
lv_obj_t * obj3;
|
||||
obj3 = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(obj3, obj2, LV_ALIGN_OUT_RIGHT_MID, 20, 0);
|
||||
lv_obj_set_style(obj3, &style_new);
|
||||
|
||||
/* Add a label to the object.
|
||||
* Labels by default inherit the parent's style */
|
||||
label = lv_label_create(obj3, NULL);
|
||||
lv_label_set_text(label, "New\nstyle");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
|
||||
/************************
|
||||
* CREATE A STYLED LED
|
||||
***********************/
|
||||
|
||||
/*Create a style for the LED*/
|
||||
static lv_style_t style_led;
|
||||
lv_style_get(LV_STYLE_PRETTY_COLOR, &style_led);
|
||||
style_led.swidth = 15;
|
||||
style_led.radius = LV_RADIUS_CIRCLE;
|
||||
style_led.bwidth = 3;
|
||||
style_led.bopa = OPA_30;
|
||||
style_led.mcolor = COLOR_MAKE(0xb5, 0x0f, 0x04);
|
||||
style_led.gcolor = COLOR_MAKE(0x50, 0x07, 0x02);
|
||||
style_led.bcolor = COLOR_MAKE(0xfa, 0x0f, 0x00);
|
||||
style_led.scolor = COLOR_MAKE(0xb5, 0x0f, 0x04);
|
||||
|
||||
/*Create a LED and switch it ON*/
|
||||
lv_obj_t * led1 = lv_led_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_style(led1, &style_led);
|
||||
lv_obj_align_us(led1, obj1, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
|
||||
lv_led_on(led1);
|
||||
|
||||
/*Copy the previous LED and set a brightness*/
|
||||
lv_obj_t * led2 = lv_led_create(lv_scr_act(), led1);
|
||||
lv_obj_align_us(led2, obj2, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
|
||||
lv_led_set_bright(led2, 190);
|
||||
|
||||
/*Copy the previous LED and switch it OFF*/
|
||||
lv_obj_t * led3 = lv_led_create(lv_scr_act(), led1);
|
||||
lv_obj_align_us(led3, obj3, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
|
||||
lv_led_off(led3);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_EXAMPLE != 0*/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
/**
|
||||
* @file lv_ex_encoder_ctrl.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create a simple GUI to demonstrate how to control it with an encoder
|
||||
* using 'lv_group'.
|
||||
*
|
||||
* Be sure in lv_conf.h:
|
||||
* - LV_OBJ_GROUP 1 to enable groups
|
||||
* - LV_APP_ENABLE 0 to disable applications because they might bother now
|
||||
*
|
||||
* lv_group:
|
||||
* - you can create groups and add object to them
|
||||
* - it can be a focused object within a group
|
||||
* - the style of the focused object will be automatically modified
|
||||
* - different style modifier functions can be applied in each groups
|
||||
* - you can focus on the next or previous object (lv_group_focus_next/prev)
|
||||
* - letters can be sent to the focused object to do something (lv_group_send):
|
||||
* - LV_GROUP_KEY_RIGHT/UP: increment action in the object
|
||||
* - LV_GROUP_KEY_LEFT/DOWN: decrement action in the object
|
||||
* - LV_GROUP_KEY_ENTER: ok or select action in the object
|
||||
* - LV_GROUP_KEY_ESC: close or back action action in the object
|
||||
* - or any character for example to a text area
|
||||
*
|
||||
* The encoder is replaced by 4 button on the screen:
|
||||
* - [>] Next (lv_group_focus_next): focus on the next object in the group (simulates encoder press)
|
||||
* - [+] IncrementNext (LV_GROUP_KEY_RIGHT): increment signal to the object (simulates rotate right)
|
||||
* - [-] DecrementNext (LV_GROUP_KEY_LEFT): increment signal to the object (simulates rotate left)
|
||||
* - [!] SelectNext (LV_GROUP_KEY_ENTER): Select something (simulates encoder long press or an 'Select' button)
|
||||
*/
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_ex_encoder_ctrl.h"
|
||||
#if USE_LV_EXAMPLE != 0
|
||||
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void gui_create(void);
|
||||
static void enc_create(void);
|
||||
static lv_action_res_t mbox_yes_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t mbox_no_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t enable_action(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t enc_next(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t enc_inc(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t enc_dec(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
static lv_action_res_t enc_sel(lv_obj_t * btn, lv_dispi_t * dispi);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_obj_t * scr; /*The screen for the demo*/
|
||||
static lv_obj_t * btn_enable; /*An enable button*/
|
||||
static lv_style_t style_mbox_bg; /*Black bg. style with opacity*/
|
||||
static lv_group_t * g; /*An Object Group*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a simple GUI to demonstrate encoder control capability
|
||||
*/
|
||||
void lv_ex_encoder_ctrl(void)
|
||||
{
|
||||
/* Create a Page screen (to make it scrollable)
|
||||
* and use Pretty layout to make the content responsive.
|
||||
* See the 'responsive' example for more information */
|
||||
scr = lv_page_create(NULL, NULL);
|
||||
lv_cont_set_layout(lv_page_get_scrl(scr), LV_CONT_LAYOUT_PRETTY);
|
||||
lv_page_set_sb_mode(scr, LV_PAGE_SB_MODE_AUTO);
|
||||
lv_scr_load(scr);
|
||||
|
||||
/*Create an object group for objects to focus*/
|
||||
g = lv_group_create();
|
||||
|
||||
/* Create a dark plain style for a message box's background*/
|
||||
lv_style_get(LV_STYLE_PLAIN, &style_mbox_bg);
|
||||
style_mbox_bg.mcolor = COLOR_BLACK;
|
||||
style_mbox_bg.gcolor = COLOR_BLACK;
|
||||
style_mbox_bg.opa = OPA_50;
|
||||
|
||||
/*Create a demo GUI*/
|
||||
gui_create();
|
||||
|
||||
/*Create virtual encoder*/
|
||||
enc_create();
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a demo GUI
|
||||
*/
|
||||
static void gui_create(void)
|
||||
{
|
||||
/*Create a title*/
|
||||
lv_obj_t * title = lv_label_create(scr, NULL);
|
||||
lv_label_set_text(title, "Encoder control");
|
||||
lv_obj_set_protect(title, LV_PROTECT_FOLLOW); /*Make a line break in the layout*/
|
||||
|
||||
/*Create a drop down list*/
|
||||
lv_obj_t * ddlist = lv_ddlist_create(scr, NULL);
|
||||
lv_ddlist_set_options_str(ddlist, "Low\nMedium\nHigh");
|
||||
lv_group_add_obj(g, ddlist); /*Add the object to the group*/
|
||||
|
||||
/*Create a holder an check boxes on it*/
|
||||
lv_obj_t * holder = lv_cont_create(scr, NULL); /*Create a transparent holder*/
|
||||
lv_cont_set_fit(holder, true, true);
|
||||
lv_cont_set_layout(holder, LV_CONT_LAYOUT_COL_L);
|
||||
lv_obj_set_style(holder, lv_style_get(LV_STYLE_TRANSP, NULL));
|
||||
|
||||
lv_obj_t * cb = lv_cb_create(holder, NULL); /*First check box*/
|
||||
lv_cb_set_text(cb, "Red");
|
||||
lv_group_add_obj(g, cb); /*Add to the group*/
|
||||
|
||||
cb = lv_cb_create(holder, cb); /*Copy the first check box. Automatically added to the same group*/
|
||||
lv_cb_set_text(cb, "Green");
|
||||
|
||||
cb = lv_cb_create(holder, cb); /*Copy the second check box. Automatically added to the same group*/
|
||||
lv_cb_set_text(cb, "Blue");
|
||||
|
||||
/*Create a sliders*/
|
||||
lv_obj_t * slider = lv_slider_create(scr, NULL);
|
||||
lv_obj_set_size_us(slider, 180, 30);
|
||||
lv_bar_set_range(slider, 0, 20);
|
||||
lv_group_add_obj(g, slider); /*Add to the group*/
|
||||
|
||||
/*Create a button*/
|
||||
btn_enable = lv_btn_create(scr, NULL);
|
||||
lv_btn_set_rel_action(btn_enable, enable_action);
|
||||
lv_cont_set_fit(btn_enable, true, true);
|
||||
lv_group_add_obj(g, btn_enable); /*Add to the group*/
|
||||
lv_obj_t * l = lv_label_create(btn_enable, NULL);
|
||||
lv_label_set_text(l, "Enable");
|
||||
lv_obj_set_protect(btn_enable, LV_PROTECT_FOLLOW); /*Make a line break in the layout*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Create virtual encoder using 4 buttons:
|
||||
* - [>] Next: focus on the next object in the group (simulates encoder press)
|
||||
* - [+] Increment: increment signal to the object (simulates rotate right)
|
||||
* - [-] Decrement: increment signal to the object (simulates rotate left)
|
||||
* - [!] Select: Select something (simulates encoder long press or an 'Select' button)
|
||||
*/
|
||||
static void enc_create(void)
|
||||
{
|
||||
/*Next button*/
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_btn_set_rel_action(btn, enc_next);
|
||||
lv_cont_set_fit(btn, true, true);
|
||||
lv_obj_t * l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(l, ">");
|
||||
|
||||
/*Increment button*/
|
||||
btn = lv_btn_create(lv_scr_act(), btn);
|
||||
lv_btn_set_rel_action(btn, enc_dec);
|
||||
l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(l, "-");
|
||||
|
||||
/*Decrement button*/
|
||||
btn = lv_btn_create(lv_scr_act(), btn);
|
||||
lv_btn_set_rel_action(btn, enc_inc);
|
||||
l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(l, "+");
|
||||
|
||||
/*Select button*/
|
||||
btn = lv_btn_create(lv_scr_act(), btn);
|
||||
lv_btn_set_rel_action(btn, enc_sel);
|
||||
l = lv_label_create(btn, NULL);
|
||||
lv_label_set_text(l, "!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Enable button is released. Show a message box to really enable or not?
|
||||
* @param btn pointer to the Enable button
|
||||
* @param dispi pointer to the caller display input or NULL if the encoder used
|
||||
* @return LV_ACTION_RES_OK: because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t enable_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/*If the butto nsi released the show message box to be sure about the Enable*/
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_REL) {
|
||||
/* Create a dark screen sized bg. with opacity to show
|
||||
* the other objects are not available now*/
|
||||
lv_obj_t * bg = lv_obj_create(scr, NULL);
|
||||
lv_obj_set_protect(bg, LV_PROTECT_PARENT); /*The page screen move it to scrollable area*/
|
||||
lv_obj_set_parent(bg, scr); /*So movi it back ater protected*/
|
||||
lv_obj_set_style(bg, &style_mbox_bg);
|
||||
lv_obj_set_size(bg, LV_HOR_RES, LV_VER_RES);
|
||||
lv_obj_set_pos(bg, 0, 0);
|
||||
lv_obj_set_click(bg, false); /*For test disable click there fore buttons under it remain clickable*/
|
||||
|
||||
/*Create a message box*/
|
||||
lv_obj_t * mbox = lv_mbox_create(bg, NULL);
|
||||
lv_mbox_set_text(mbox, "Really Enable the outputs?");
|
||||
lv_group_add_obj(g, mbox); /*Add to he group*/
|
||||
|
||||
/*Add two buttons*/
|
||||
lv_mbox_add_btn(mbox, "Yes", mbox_yes_action);
|
||||
lv_mbox_add_btn(mbox, "No", mbox_no_action);
|
||||
|
||||
lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, - LV_DPI / 2);
|
||||
|
||||
/*Focus on the new message box, can freeze focus on it*/
|
||||
lv_group_focus_obj(mbox);
|
||||
lv_group_focus_freeze(g, true);
|
||||
}
|
||||
/*Disable is not dangerous so just change the button state*/
|
||||
else {
|
||||
lv_btn_set_state(btn_enable, LV_BTN_STATE_REL);
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the message box's 'Yes' button is released
|
||||
* @param btn pointer to the 'Yes' button
|
||||
* @param dispi pointer to the caller display input or NULL if the encoder used
|
||||
* @return LV_ACTION_RES_INV: because the button along with the message box will be deleted
|
||||
*/
|
||||
static lv_action_res_t mbox_yes_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_group_focus_freeze(g, false); /*Release the freeze*/
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
lv_obj_del(lv_obj_get_parent(mbox)); /*Delete the black background. (it will delete the mbox too)*/
|
||||
|
||||
/*Mark the enabled state by toggling the button*/
|
||||
lv_btn_set_state(btn_enable, LV_BTN_STATE_TREL);
|
||||
|
||||
/* In a real case you can add some specific actions here
|
||||
* to really enable something */
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the message box's 'No' button is released
|
||||
* @param btn pointer to the 'No' button
|
||||
* @param dispi pointer to the caller display input or NULL if the encoder used
|
||||
* @return LV_ACTION_RES_INV: because the button along with the message box will be deleted
|
||||
*/
|
||||
static lv_action_res_t mbox_no_action(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_group_focus_freeze(g, false); /*Release the freeze*/
|
||||
lv_obj_t * mbox = lv_mbox_get_from_btn(btn);
|
||||
lv_obj_del(lv_obj_get_parent(mbox)); /*Delete the black background. (it will delete the mbox too)*/
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Encoder emulator's Next button is released
|
||||
* @param btn pointer to the button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK: because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t enc_next(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/*Focus on the next object in the group*/
|
||||
lv_group_focus_next(g);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Encoder emulator's Increment button is released
|
||||
* @param btn pointer to the button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK: because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t enc_inc(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/* Send RIGHT key when rotate to right.
|
||||
* It will trigger an increment like action in the object */
|
||||
lv_group_send(g, LV_GROUP_KEY_RIGHT);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Encoder emulator's Increment button is released
|
||||
* @param btn pointer to the button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK: because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t enc_dec(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/* Send LEFT key when rotate to left.
|
||||
* It will trigger a decrement like action in the object */
|
||||
lv_group_send(g, LV_GROUP_KEY_LEFT);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
/**
|
||||
* Called when the Encoder emulator's Send button is released
|
||||
* @param btn pointer to the button
|
||||
* @param dispi pointer to the caller display input
|
||||
* @return LV_ACTION_RES_OK: because the button is not deleted
|
||||
*/
|
||||
static lv_action_res_t enc_sel(lv_obj_t * btn, lv_dispi_t * dispi)
|
||||
{
|
||||
/* Send ENTER key.
|
||||
* It will trigger an 'OK' or 'Select' action in the object */
|
||||
lv_group_send(g, LV_GROUP_KEY_ENTER);
|
||||
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*USE_LV_EXAMPLE != 0*/
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
@@ -1,41 +0,0 @@
|
||||
# EXAMPLES FOR LITTLEV GRAPHICS LIBRARY
|
||||
|
||||
## Introduction
|
||||
In the folders you will find simple hardware independent examples to know the key features of Littlev Graphics Library.
|
||||
The examples are organized in consistent way and can be used as a **Tutorial**.
|
||||
|
||||
Every example consist of least an *example_name.c* and *example_name.h* files. You can load an example in your *main* function with **example_name_init()**. The header file has to be included too.
|
||||
|
||||
You will find **detailed explanation** in the *c* and *h* files.
|
||||
|
||||
The examples can be enabled/disabled in *lv_conf.h* with **USE_LV_EXAMPLES**.
|
||||
|
||||
## 1_x Getting started
|
||||
With examples in this section you can learn the basics from a simple *Hello world* label to a complex full featured GUI with animations and other effects. You will learn about
|
||||
- creating, deleting graphical objects
|
||||
- modify their attributes
|
||||
- change their style
|
||||
- and even creating a new object type
|
||||
|
||||
## 2_x GUI control without Touchpad
|
||||
You can control your GUI not only with Touchpad. The most simple way to put real buttons next to the graphical ones and simulate *touch pad-like press* on the display. An other way is to organize the objects in groups and *focus* on one of objects. Then you can control the object-in-focus with simple character instructions. Or using a cursor and mouse is also possible. So an external control device can be
|
||||
- push buttons
|
||||
- encoders
|
||||
- keyboard
|
||||
- or a mouse
|
||||
|
||||
In this section you will find examples for them!
|
||||
|
||||
## 3_x Applications
|
||||
The applications are high level components to do complex thing with a nice user interface. An application can be for example
|
||||
- WiFi network manager
|
||||
- File system browser
|
||||
- System monitor
|
||||
- Terminal etc.
|
||||
|
||||
Here you will find examples how to run application, and communicate with them.
|
||||
|
||||
## Final words
|
||||
If you also have codes which could be useful for others, please share it via *Pull requests* on *GitHub*!
|
||||
Thank you in advance!
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file style_usage.h
|
||||
* @file hal.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STYLE_USAGE_H
|
||||
#define STYLE_USAGE_H
|
||||
#ifndef HAL_H
|
||||
#define HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -13,8 +13,9 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_EXAMPLE != 0
|
||||
#include "lv_hal_disp.h"
|
||||
#include "lv_hal_indev.h"
|
||||
#include "lv_hal_tick.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -27,16 +28,13 @@ extern "C" {
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_ex_styles(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_LV_EXAMPLE != 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_HELLO_WORLD_H*/
|
||||
#endif
|
||||
8
lv_hal/lv_hal.mk
Normal file
8
lv_hal/lv_hal.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
CSRCS += lv_hal_disp.c
|
||||
CSRCS += lv_hal_indev.c
|
||||
CSRCS += lv_hal_tick.c
|
||||
|
||||
DEPPATH += --dep-path lvgl/lv_hal
|
||||
VPATH += :lvgl/lv_hal
|
||||
|
||||
CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_hal"
|
||||
221
lv_hal/lv_hal_disp.c
Normal file
221
lv_hal/lv_hal_disp.c
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
/**
|
||||
* @file hal_disp.c
|
||||
*
|
||||
* @description HAL layer for display driver
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
#include "../lv_core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_disp_t *disp_list = NULL;
|
||||
static lv_disp_t *active;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a display driver with default values.
|
||||
* It is used to surly have known values in the fields ant not memory junk.
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t *driver)
|
||||
{
|
||||
driver->disp_fill = NULL;
|
||||
driver->disp_map = NULL;
|
||||
driver->disp_flush = NULL;
|
||||
|
||||
#if USE_LV_GPU
|
||||
driver->mem_blend = NULL;
|
||||
driver->mem_fill = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
* Automatically set the first display as active.
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver)
|
||||
{
|
||||
lv_disp_t *node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_disp_t));
|
||||
if (!node) return NULL;
|
||||
|
||||
memcpy(&node->driver,driver, sizeof(lv_disp_drv_t));
|
||||
node->next = NULL;
|
||||
|
||||
/* Set first display as active by default */
|
||||
if (disp_list == NULL) {
|
||||
disp_list = node;
|
||||
active = node;
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
} else {
|
||||
node->next = disp_list;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the active display
|
||||
* @param disp pointer to a display (return value of 'lv_disp_register')
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp)
|
||||
{
|
||||
active = disp;
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the active display
|
||||
* @return pointer to the active display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void)
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_next(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) {
|
||||
return disp_list;
|
||||
} else {
|
||||
if(disp_list->next == NULL) return NULL;
|
||||
else return disp_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the content of the internal buffer (VDB) to the display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p fill color
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_fill != NULL) active->driver.disp_fill(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_flush != NULL) active->driver.disp_flush(x1, y1, x2, y2, color_p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_map pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.disp_map != NULL) active->driver.disp_map(x1, y1, x2, y2, color_map);
|
||||
}
|
||||
|
||||
#if USE_LV_GPU
|
||||
|
||||
/**
|
||||
* Blend pixels to a destination memory from a source memory
|
||||
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Blend 'src' here.
|
||||
* @param src pointer to pixel map. Blend it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.mem_blend != NULL) active->driver.mem_blend(dest, src, length, opa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a memory with a color (GPUs may support it)
|
||||
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color)
|
||||
{
|
||||
if(active == NULL) return;
|
||||
if(active->driver.mem_fill != NULL) active->driver.mem_fill(dest, length, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows if memory blending (by GPU) is supported or not
|
||||
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_blend_supported(void)
|
||||
{
|
||||
if(active->driver.mem_blend) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows if memory fill (by GPU) is supported or not
|
||||
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_fill_supported(void)
|
||||
{
|
||||
if(active->driver.mem_fill) return true;
|
||||
else return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
168
lv_hal/lv_hal_disp.h
Normal file
168
lv_hal/lv_hal_disp.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* @file hal_disp.h
|
||||
*
|
||||
* @description Display Driver HAL interface header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_DISP_H
|
||||
#define HAL_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Display Driver structure to be registered by HAL
|
||||
*/
|
||||
typedef struct _disp_drv_t {
|
||||
/*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/
|
||||
void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
|
||||
/*Fill an area with a color on the display*/
|
||||
void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
|
||||
|
||||
/*Write pixel map (e.g. image) to the display*/
|
||||
void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
|
||||
|
||||
#if USE_LV_GPU
|
||||
/*Blend two memories using opacity (GPU only)*/
|
||||
void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
|
||||
/*Fill a memory with a color (GPU only)*/
|
||||
void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
#endif
|
||||
|
||||
} lv_disp_drv_t;
|
||||
|
||||
typedef struct _disp_t {
|
||||
lv_disp_drv_t driver;
|
||||
struct _disp_t *next;
|
||||
} lv_disp_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a display driver with default values.
|
||||
* It is used to surly have known values in the fields ant not memory junk.
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_disp_drv_init(lv_disp_drv_t *driver);
|
||||
|
||||
/**
|
||||
* Register an initialized display driver.
|
||||
* Automatically set the first display as active.
|
||||
* @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new display or NULL on error
|
||||
*/
|
||||
lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver);
|
||||
|
||||
/**
|
||||
* Set the active display
|
||||
* @param disp pointer to a display (return value of 'lv_disp_register')
|
||||
*/
|
||||
void lv_disp_set_active(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Get a pointer to the active display
|
||||
* @return pointer to the active display
|
||||
*/
|
||||
lv_disp_t * lv_disp_get_active(void);
|
||||
|
||||
/**
|
||||
* Get the next display.
|
||||
* @param disp pointer to the current display. NULL to initialize.
|
||||
* @return the next display or NULL if no more. Give the first display when the parameter is NULL
|
||||
*/
|
||||
lv_disp_t * lv_disp_next(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_p pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);
|
||||
|
||||
/**
|
||||
* Fill a rectangular area with a color on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color fill color
|
||||
*/
|
||||
void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Put a color map to a rectangular area on the active display
|
||||
* @param x1 left coordinate of the rectangle
|
||||
* @param x2 right coordinate of the rectangle
|
||||
* @param y1 top coordinate of the rectangle
|
||||
* @param y2 bottom coordinate of the rectangle
|
||||
* @param color_map pointer to an array of colors
|
||||
*/
|
||||
void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);
|
||||
|
||||
#if USE_LV_GPU
|
||||
/**
|
||||
* Blend pixels to a destination memory from a source memory
|
||||
* In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Blend 'src' here.
|
||||
* @param src pointer to pixel map. Blend it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Fill a memory with a color (GPUs may support it)
|
||||
* In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
|
||||
*/
|
||||
void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
|
||||
/**
|
||||
* Shows if memory blending (by GPU) is supported or not
|
||||
* @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_blend_supported(void);
|
||||
|
||||
/**
|
||||
* Shows if memory fill (by GPU) is supported or not
|
||||
* @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
|
||||
*/
|
||||
bool lv_disp_is_mem_fill_supported(void);
|
||||
#endif
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
120
lv_hal/lv_hal_indev.c
Normal file
120
lv_hal/lv_hal_indev.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file hal_indev.c
|
||||
*
|
||||
* @description Input device HAL interface
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "../lv_misc/lv_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_indev_t *indev_list = NULL;
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an input device driver with default values.
|
||||
* It is used to surly have known values in the fields ant not memory junk.
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_indev_drv_init(lv_indev_drv_t *driver)
|
||||
{
|
||||
driver->read = NULL;
|
||||
driver->type = LV_INDEV_TYPE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an initialized input device driver.
|
||||
* @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new input device or NULL on error
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver)
|
||||
{
|
||||
lv_indev_t *node;
|
||||
|
||||
node = lv_mem_alloc(sizeof(lv_indev_t));
|
||||
if (!node) return NULL;
|
||||
|
||||
memcpy(&node->driver, driver, sizeof(lv_indev_drv_t));
|
||||
|
||||
node->next = NULL;
|
||||
node->proc.reset_query = 1;
|
||||
node->cursor = NULL;
|
||||
node->group = NULL;
|
||||
|
||||
if (indev_list == NULL) {
|
||||
indev_list = node;
|
||||
} else {
|
||||
lv_indev_t *last = indev_list;
|
||||
while (last->next)
|
||||
last = last->next;
|
||||
|
||||
last->next = node;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Give the first input device when the parameter is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev)
|
||||
{
|
||||
|
||||
if(indev == NULL) {
|
||||
return indev_list;
|
||||
} else {
|
||||
if(indev->next == NULL) return NULL;
|
||||
else return indev->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an input device.
|
||||
* @param indev pointer to an input device
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t *data)
|
||||
{
|
||||
bool cont = false;
|
||||
|
||||
if(indev->driver.read) {
|
||||
cont = indev->driver.read(data);
|
||||
} else {
|
||||
memset(data, 0, sizeof(lv_indev_data_t));
|
||||
}
|
||||
|
||||
return cont;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
148
lv_hal/lv_hal_indev.h
Normal file
148
lv_hal/lv_hal_indev.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* @file hal_indev.h
|
||||
*
|
||||
* @description Input Device HAL interface layer header file
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HAL_INDEV_H
|
||||
#define HAL_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "lv_hal.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/*Possible input device types*/
|
||||
typedef enum {
|
||||
LV_INDEV_TYPE_NONE, /*Show uninitialized state*/
|
||||
LV_INDEV_TYPE_POINTER, /*Touch pad, mouse, external button*/
|
||||
LV_INDEV_TYPE_KEYPAD, /*Keypad or keyboard*/
|
||||
} lv_hal_indev_type_t;
|
||||
|
||||
/*States for input devices*/
|
||||
typedef enum {
|
||||
LV_INDEV_STATE_REL,
|
||||
LV_INDEV_STATE_PR
|
||||
}lv_indev_state_t;
|
||||
|
||||
/*Data type when an input device is read */
|
||||
typedef struct {
|
||||
union {
|
||||
lv_point_t point; /*For INDEV_TYPE_POINTER*/
|
||||
uint32_t key; /*For INDEV_TYPE_KEYPAD*/
|
||||
};
|
||||
lv_indev_state_t state; /*LV_INDEV_EVENT_REL or LV_INDEV_EVENT_PR*/
|
||||
}lv_indev_data_t;
|
||||
|
||||
/*Initialized by the user and registered by 'lv_indev_add()'*/
|
||||
typedef struct {
|
||||
lv_hal_indev_type_t type; /*Input device type*/
|
||||
bool (*read)(lv_indev_data_t *data); /*Function pointer to read data. Return 'true' if there is still data to be read (buffered)*/
|
||||
}lv_indev_drv_t;
|
||||
|
||||
struct _lv_obj_t;
|
||||
|
||||
typedef struct _lv_indev_state_t {
|
||||
lv_indev_state_t state;
|
||||
union {
|
||||
struct { /*Pointer data*/
|
||||
lv_point_t act_point;
|
||||
lv_point_t last_point;
|
||||
lv_point_t vect;
|
||||
lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DRAG_LIMIT*/
|
||||
struct _lv_obj_t * act_obj;
|
||||
struct _lv_obj_t * last_obj;
|
||||
|
||||
/*Flags*/
|
||||
uint8_t drag_range_out :1;
|
||||
uint8_t drag_in_prog :1;
|
||||
uint8_t wait_unil_release :1;
|
||||
};
|
||||
struct { /*Keypad data*/
|
||||
lv_indev_state_t last_state;
|
||||
};
|
||||
};
|
||||
|
||||
uint32_t pr_timestamp; /*Pressed time stamp*/
|
||||
uint32_t longpr_rep_timestamp; /*Long press repeat time stamp*/
|
||||
|
||||
/*Flags*/
|
||||
uint8_t long_pr_sent :1;
|
||||
uint8_t reset_query :1;
|
||||
uint8_t disabled :1;
|
||||
}lv_indev_proc_t;
|
||||
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _lv_group_t;
|
||||
|
||||
typedef struct _lv_indev_t {
|
||||
lv_indev_drv_t driver;
|
||||
lv_indev_proc_t proc;
|
||||
uint32_t last_activity_time;
|
||||
union {
|
||||
struct _lv_obj_t *cursor;
|
||||
struct _lv_group_t *group; /*Keypad destination group*/
|
||||
};
|
||||
struct _lv_indev_t *next;
|
||||
} lv_indev_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an input device driver with default values.
|
||||
* It is used to surly have known values in the fields ant not memory junk.
|
||||
* After it you can set the fields.
|
||||
* @param driver pointer to driver variable to initialize
|
||||
*/
|
||||
void lv_indev_drv_init(lv_indev_drv_t *driver);
|
||||
|
||||
/**
|
||||
* Register an initialized input device driver.
|
||||
* @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)
|
||||
* @return pointer to the new input device or NULL on error
|
||||
*/
|
||||
lv_indev_t * lv_indev_drv_register(lv_indev_drv_t *driver);
|
||||
|
||||
/**
|
||||
* Get the next input device.
|
||||
* @param indev pointer to the current input device. NULL to initialize.
|
||||
* @return the next input devise or NULL if no more. Gives the first input device when the parameter is NULL
|
||||
*/
|
||||
lv_indev_t * lv_indev_next(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Read data from an input device.
|
||||
* @param indev pointer to an input device
|
||||
* @param data input device will write its data here
|
||||
* @return false: no more data; true: there more data to read (buffered)
|
||||
*/
|
||||
bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t *data);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
86
lv_hal/lv_hal_tick.c
Normal file
86
lv_hal/lv_hal_tick.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @file systick.c
|
||||
* Provide access to the system tick with 1 millisecond resolution
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_hal_tick.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static uint32_t sys_time = 0;
|
||||
static volatile uint8_t tick_irq_flag;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* You have to call this function periodically
|
||||
* @param tick_period the call period of this function in milliseconds
|
||||
*/
|
||||
void lv_tick_inc(uint32_t tick_period)
|
||||
{
|
||||
tick_irq_flag = 0;
|
||||
sys_time += tick_period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t lv_tick_get(void)
|
||||
{
|
||||
uint32_t result;
|
||||
do {
|
||||
tick_irq_flag = 1;
|
||||
result = sys_time;
|
||||
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. Continue until make a non interrupted cycle */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds science a previous time stamp
|
||||
* @param prev_tick a previous time stamp (return value of systick_get() )
|
||||
* @return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick)
|
||||
{
|
||||
uint32_t act_time = lv_tick_get();
|
||||
|
||||
/*If there is no overflow in sys_time simple subtract*/
|
||||
if(act_time >= prev_tick) {
|
||||
prev_tick = act_time - prev_tick;
|
||||
} else {
|
||||
prev_tick = UINT32_MAX - prev_tick + 1;
|
||||
prev_tick += act_time;
|
||||
}
|
||||
|
||||
return prev_tick;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
58
lv_hal/lv_hal_tick.h
Normal file
58
lv_hal/lv_hal_tick.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @file lv_hal_tick.h
|
||||
* Provide access to the system tick with 1 millisecond resolution
|
||||
*/
|
||||
|
||||
#ifndef LV_HAL_TICK_H
|
||||
#define LV_HAL_TICK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* You have to call this function periodically
|
||||
* @param tick_period the call period of this function in milliseconds
|
||||
*/
|
||||
void lv_tick_inc(uint32_t tick_period);
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t lv_tick_get(void);
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds science a previous time stamp
|
||||
* @param prev_tick a previous time stamp (return value of systick_get() )
|
||||
* @return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_HAL_TICK_H*/
|
||||
259
lv_misc/lv_anim.c
Normal file
259
lv_misc/lv_anim.c
Normal file
@@ -0,0 +1,259 @@
|
||||
/**
|
||||
* @file anim.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_anim.h"
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "lv_task.h"
|
||||
#include "lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_ANIM_RESOLUTION 1024
|
||||
#define LV_ANIM_RES_SHIFT 10
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void anim_task (void * param);
|
||||
static bool anim_ready_handler(lv_anim_t * a);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_ll_t anim_ll;
|
||||
static uint32_t last_task_run;
|
||||
static bool anim_del_global_flag = false;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void lv_anim_init(void)
|
||||
{
|
||||
lv_ll_init(&anim_ll, sizeof(lv_anim_t));
|
||||
last_task_run = lv_tick_get();
|
||||
lv_task_create(anim_task, LV_REFR_PERIOD, LV_TASK_PRIO_MID, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void lv_anim_create(lv_anim_t * anim_p)
|
||||
{
|
||||
/* Do not let two animations for the same 'var' with the same 'fp'*/
|
||||
if(anim_p->fp != NULL) lv_anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
|
||||
|
||||
/*Add the new animation to the animation linked list*/
|
||||
lv_anim_t * new_anim = lv_ll_ins_head(&anim_ll);
|
||||
lv_mem_assert(new_anim);
|
||||
|
||||
/*Initialize the animation descriptor*/
|
||||
anim_p->playback_now = 0;
|
||||
memcpy(new_anim, anim_p, sizeof(lv_anim_t));
|
||||
|
||||
/*Set the start value*/
|
||||
if(new_anim->fp != NULL) new_anim->fp(new_anim->var, new_anim->start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animator function
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to delete all animations of 'var'
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool lv_anim_del(void * var, lv_anim_fp_t fp)
|
||||
{
|
||||
bool del = false;
|
||||
lv_anim_t * a;
|
||||
lv_anim_t * a_next;
|
||||
a = lv_ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = lv_ll_get_next(&anim_ll, a);
|
||||
|
||||
if(a->var == var && (a->fp == fp || fp == NULL)) {
|
||||
lv_ll_rem(&anim_ll, a);
|
||||
lv_mem_free(a);
|
||||
del = true;
|
||||
anim_del_global_flag = true;
|
||||
}
|
||||
|
||||
a = a_next;
|
||||
}
|
||||
|
||||
return del;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
|
||||
{
|
||||
int32_t d = LV_MATH_ABS((int32_t) start - end);
|
||||
uint16_t time = (int32_t)((int32_t)(d * 1000) / speed);
|
||||
|
||||
if(time == 0) {
|
||||
time++;
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying linear characteristic
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_linear(const lv_anim_t *a)
|
||||
{
|
||||
/*Calculate the current step*/
|
||||
|
||||
uint16_t step;
|
||||
if(a->time == a->act_time) step = LV_ANIM_RESOLUTION; /*Use the last value id the time fully elapsed*/
|
||||
else step = (a->act_time * LV_ANIM_RESOLUTION) / a->time;
|
||||
|
||||
|
||||
/* Get the new value which will be proportional to the current element of 'path_p'
|
||||
* and the 'start' and 'end' values*/
|
||||
int32_t new_value;
|
||||
new_value = (int32_t) step * (a->end - a->start);
|
||||
new_value = new_value >> LV_ANIM_RES_SHIFT;
|
||||
new_value += a->start;
|
||||
|
||||
return new_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying step characteristic.
|
||||
* (Set end value on the end of the animation)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_step(const lv_anim_t *a)
|
||||
{
|
||||
if(a->act_time >= a->time) return a->end;
|
||||
else return a->start;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Periodically handle the animations.
|
||||
* @param param unused
|
||||
*/
|
||||
static void anim_task (void * param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
volatile uint32_t elaps;
|
||||
elaps = lv_tick_elaps(last_task_run);
|
||||
|
||||
lv_anim_t * a;
|
||||
lv_anim_t * a_next;
|
||||
a = lv_ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = lv_ll_get_next(&anim_ll, a);
|
||||
|
||||
a->act_time += elaps;
|
||||
if(a->act_time >= 0) {
|
||||
if(a->act_time > a->time) a->act_time = a->time;
|
||||
|
||||
int32_t new_value;
|
||||
new_value = a->path(a);
|
||||
|
||||
if(a->fp != NULL) a->fp(a->var, new_value); /*Apply the calculated value*/
|
||||
|
||||
/*If the time is elapsed the animation is ready*/
|
||||
if(a->act_time >= a->time) {
|
||||
bool invalid;
|
||||
invalid = anim_ready_handler(a);
|
||||
if(invalid != false) {
|
||||
a_next = lv_ll_get_head(&anim_ll); /*a_next might be invalid if animation delete occurred*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a = a_next;
|
||||
}
|
||||
|
||||
last_task_run = lv_tick_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an animation is ready to do the necessary thinks
|
||||
* e.g. repeat, play back, delete etc.
|
||||
* @param a pointer to an animation descriptor
|
||||
* @return true: animation delete occurred
|
||||
* */
|
||||
static bool anim_ready_handler(lv_anim_t * a)
|
||||
{
|
||||
bool invalid = false;
|
||||
|
||||
/*Delete the animation if
|
||||
* - no repeat and no play back (simple one shot animation)
|
||||
* - no repeat, play back is enabled and play back is ready */
|
||||
if((a->repeat == 0 && a->playback == 0) ||
|
||||
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
|
||||
void (*cb) (void *) = a->end_cb;
|
||||
void * p = a->var;
|
||||
lv_ll_rem(&anim_ll, a);
|
||||
lv_mem_free(a);
|
||||
|
||||
/*Call the callback function at the end*/
|
||||
/* Check if an animation is deleted in the cb function
|
||||
* if yes then the caller function has to know this*/
|
||||
anim_del_global_flag = false;
|
||||
if(cb != NULL) cb(p);
|
||||
invalid = anim_del_global_flag;
|
||||
}
|
||||
/*If the animation is not deleted then restart it*/
|
||||
else {
|
||||
a->act_time = - a->repeat_pause; /*Restart the animation*/
|
||||
/*Swap the start and end values in play back mode*/
|
||||
if(a->playback != 0) {
|
||||
/*If now turning back use the 'playback_pause*/
|
||||
if(a->playback_now == 0) a->act_time = - a->playback_pause;
|
||||
|
||||
/*Toggle the play back state*/
|
||||
a->playback_now = a->playback_now == 0 ? 1: 0;
|
||||
/*Swap the start and end values*/
|
||||
int32_t tmp;
|
||||
tmp = a->start;
|
||||
a->start = a->end;
|
||||
a->end = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return invalid;
|
||||
}
|
||||
#endif
|
||||
129
lv_misc/lv_anim.h
Normal file
129
lv_misc/lv_anim.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @file anim.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ANIM_H
|
||||
#define ANIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
#if USE_LV_ANIMATION
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _lv_anim_t;
|
||||
|
||||
typedef int32_t(*lv_anim_path_t)(const struct _lv_anim_t*);
|
||||
|
||||
typedef void (*lv_anim_fp_t)(void *, int32_t);
|
||||
typedef void (*lv_anim_cb_t)(void *);
|
||||
|
||||
typedef struct _lv_anim_t
|
||||
{
|
||||
void * var; /*Variable to animate*/
|
||||
lv_anim_fp_t fp; /*Animator function*/
|
||||
lv_anim_cb_t end_cb; /*Call it when the animation is ready*/
|
||||
lv_anim_path_t path; /*An array with the steps of animations*/
|
||||
int32_t start; /*Start value*/
|
||||
int32_t end; /*End value*/
|
||||
int16_t time; /*Animation time in ms*/
|
||||
int16_t act_time; /*Current time in animation. Set to negative to make delay.*/
|
||||
uint16_t playback_pause; /*Wait before play back*/
|
||||
uint16_t repeat_pause; /*Wait before repeat*/
|
||||
uint8_t playback :1; /*When the animation is ready play it back*/
|
||||
uint8_t repeat :1; /*Repeat the animation infinitely*/
|
||||
/*Animation system use these - user shouldn't set*/
|
||||
uint8_t playback_now :1; /*Play back is in progress*/
|
||||
}lv_anim_t;
|
||||
|
||||
/*Example initialization
|
||||
lv_anim_t a;
|
||||
a.var = obj;
|
||||
a.start = lv_obj_get_height(obj);
|
||||
a.end = new_height;
|
||||
a.fp = (lv_anim_fp_t)lv_obj_set_height;
|
||||
a.path = lv_anim_path_linear;
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = 200;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
*/
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void lv_anim_init(void);
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void lv_anim_create(lv_anim_t * anim_p);
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animatior function
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all animation with 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool lv_anim_del(void * var, lv_anim_fp_t fp);
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t lv_anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying linear characteristic
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_linear(const lv_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying step characteristic.
|
||||
* (Set end value on the end of the animation)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t lv_anim_path_step(const lv_anim_t *a);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_NO_ANIM == 0*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_ANIM_H*/
|
||||
|
||||
233
lv_misc/lv_area.c
Normal file
233
lv_misc/lv_area.c
Normal file
@@ -0,0 +1,233 @@
|
||||
/**
|
||||
* @file lv_area.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_area.h"
|
||||
#include "lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2)
|
||||
{
|
||||
area_p->x1 = x1;
|
||||
area_p->y1 = y1;
|
||||
area_p->x2 = x2;
|
||||
area_p->y2 = y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void lv_area_set_width(lv_area_t * area_p, lv_coord_t w)
|
||||
{
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void lv_area_set_height(lv_area_t * area_p, lv_coord_t h)
|
||||
{
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
area_p->x1 = x;
|
||||
area_p->y1 = y;
|
||||
lv_area_set_width(area_p, w);
|
||||
lv_area_set_height(area_p, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t lv_area_get_size(const lv_area_t * area_p)
|
||||
{
|
||||
uint32_t size;
|
||||
|
||||
size = (uint32_t)(area_p->x2 - area_p->x1 + 1) *
|
||||
(area_p->y2 - area_p->y1 + 1);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool lv_area_union(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
/* Get the smaller area from 'a1_p' and 'a2_p' */
|
||||
res_p->x1 = LV_MATH_MAX(a1_p->x1, a2_p->x1);
|
||||
res_p->y1 = LV_MATH_MAX(a1_p->y1, a2_p->y1);
|
||||
res_p->x2 = LV_MATH_MIN(a1_p->x2, a2_p->x2);
|
||||
res_p->y2 = LV_MATH_MIN(a1_p->y2, a2_p->y2);
|
||||
|
||||
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
|
||||
bool union_ok = true;
|
||||
if((res_p->x1 > res_p->x2) ||
|
||||
(res_p->y1 > res_p->y2))
|
||||
{
|
||||
union_ok = false;
|
||||
}
|
||||
|
||||
return union_ok;
|
||||
}
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
a_res_p->x1 = LV_MATH_MIN(a1_p->x1, a2_p->x1);
|
||||
a_res_p->y1 = LV_MATH_MIN(a1_p->y1, a2_p->y1);
|
||||
a_res_p->x2 = LV_MATH_MAX(a1_p->x2, a2_p->x2);
|
||||
a_res_p->y2 = LV_MATH_MAX(a1_p->y2, a2_p->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p)
|
||||
{
|
||||
bool is_on = false;
|
||||
|
||||
if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) &&
|
||||
((p_p->y >= a_p->y1 && p_p->y <= a_p->y2)))
|
||||
{
|
||||
is_on = true;
|
||||
}
|
||||
|
||||
return is_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
/*Two area are on each other if... */
|
||||
|
||||
lv_point_t p;
|
||||
/*a2 left-top corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y1;
|
||||
if(lv_area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 right-top corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y1;
|
||||
if(lv_area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 left-bottom corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y2;
|
||||
if(lv_area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 right-bottom corner is on a1*/
|
||||
p.x = a2_p->x2;
|
||||
p.y = a2_p->y2;
|
||||
if(lv_area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 is horizontally bigger then a1 and covers it*/
|
||||
if((a2_p->x1 <= a1_p->x1 && a2_p->x2 >= a1_p->x2) && /*a2 hor. cover a1?*/
|
||||
((a2_p->y1 <= a1_p->y1 && a2_p->y1 >= a1_p->y2) || /*upper edge is on a1?*/
|
||||
(a2_p->y2 <= a1_p->y1 && a2_p->y2 >= a1_p->y2) ||/* or lower edge is on a1?*/
|
||||
(a2_p->y1 <= a1_p->y1 && a2_p->y2 >= a1_p->y2))) /*or a2 vert bigger then a1*/
|
||||
return true;
|
||||
|
||||
/*a2 is vertically bigger then a1 and covers it*/
|
||||
if((a2_p->y1 <= a1_p->y1 && a2_p->y2 >= a1_p->y2) && /*a2 vert. cover a1?*/
|
||||
((a2_p->x1 <= a1_p->x1 && a2_p->x1 >= a1_p->x2) || /*left edge is on a1?*/
|
||||
(a2_p->x2 <= a1_p->x1 && a2_p->x2 >= a1_p->x2) ||/* or right edge is on a1?*/
|
||||
(a2_p->x1 <= a1_p->x1 && a2_p->x2 >= a1_p->x2))) /*or a2 hor. bigger then a1*/
|
||||
return true;
|
||||
|
||||
/*Else no cover*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be in 'aholder_p'
|
||||
* @param aholder pointer to an area which could involve 'ain_p'
|
||||
* @return
|
||||
*/
|
||||
bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p)
|
||||
{
|
||||
bool is_in = false;
|
||||
|
||||
if(ain_p->x1 >= aholder_p->x1 &&
|
||||
ain_p->y1 >= aholder_p->y1 &&
|
||||
ain_p->x2 <= aholder_p->x2 &&
|
||||
ain_p->y2 <= aholder_p->y2)
|
||||
{
|
||||
is_in = true;
|
||||
}
|
||||
|
||||
return is_in;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
169
lv_misc/lv_area.h
Normal file
169
lv_misc/lv_area.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* @file lv_area.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_AREA_H
|
||||
#define LV_AREA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_COORD_MAX (16383) /*To avoid overflow don't let the max [-32,32k] range */
|
||||
#define LV_COORD_MIN (-16384)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef int16_t lv_coord_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
}lv_point_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
lv_coord_t x1;
|
||||
lv_coord_t y1;
|
||||
lv_coord_t x2;
|
||||
lv_coord_t y2;
|
||||
}lv_area_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2);
|
||||
|
||||
/**
|
||||
* Copy an area
|
||||
* @param dest pointer to the destination area
|
||||
* @param src pointer to the source area
|
||||
*/
|
||||
inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(lv_area_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the width of the area (if x1 == x2 -> width = 1)
|
||||
*/
|
||||
static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p)
|
||||
{
|
||||
return area_p->x2 - area_p->x1 + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the height of the area (if y1 == y2 -> height = 1)
|
||||
*/
|
||||
static inline lv_coord_t lv_area_get_height(const lv_area_t * area_p)
|
||||
{
|
||||
return area_p->y2 - area_p->y1 + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void lv_area_set_width(lv_area_t * area_p, lv_coord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void lv_area_set_height(lv_area_t * area_p, lv_coord_t h);
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y);
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t lv_area_get_size(const lv_area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool lv_area_union(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p);
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be on aholder_p
|
||||
* @param aholder pointer to an area which could involve ain_p
|
||||
* @return
|
||||
*/
|
||||
bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
79
lv_misc/lv_circ.c
Normal file
79
lv_misc/lv_circ.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file lv_circ.c
|
||||
* Circle drawing algorithm (with Bresenham)
|
||||
* Only a 1/8 circle is calculated. Use CIRC_OCT1_X, CIRC_OCT1_Y macros to get
|
||||
* the other octets.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius)
|
||||
{
|
||||
c->x = radius;
|
||||
c->y = 0;
|
||||
*tmp = 1 - radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
bool lv_circ_cont(lv_point_t * c)
|
||||
{
|
||||
return c->y <= c->x ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
void lv_circ_next(lv_point_t * c, lv_coord_t * tmp)
|
||||
{
|
||||
c->y++;
|
||||
|
||||
if (*tmp <= 0) {
|
||||
(*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1
|
||||
} else {
|
||||
c->x--;
|
||||
(*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
79
lv_misc/lv_circ.h
Normal file
79
lv_misc/lv_circ.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @file lv_circ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_CIRC_H
|
||||
#define LV_CIRC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stddef.h>
|
||||
#include "lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_CIRC_OCT1_X(p) (p.x)
|
||||
#define LV_CIRC_OCT1_Y(p) (p.y)
|
||||
#define LV_CIRC_OCT2_X(p) (p.y)
|
||||
#define LV_CIRC_OCT2_Y(p) (p.x)
|
||||
#define LV_CIRC_OCT3_X(p) (-p.y)
|
||||
#define LV_CIRC_OCT3_Y(p) (p.x)
|
||||
#define LV_CIRC_OCT4_X(p) (-p.x)
|
||||
#define LV_CIRC_OCT4_Y(p) (p.y)
|
||||
#define LV_CIRC_OCT5_X(p) (-p.x)
|
||||
#define LV_CIRC_OCT5_Y(p) (-p.y)
|
||||
#define LV_CIRC_OCT6_X(p) (-p.y)
|
||||
#define LV_CIRC_OCT6_Y(p) (-p.x)
|
||||
#define LV_CIRC_OCT7_X(p) (p.y)
|
||||
#define LV_CIRC_OCT7_Y(p) (-p.x)
|
||||
#define LV_CIRC_OCT8_X(p) (p.x)
|
||||
#define LV_CIRC_OCT8_Y(p) (-p.y)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius);
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
bool lv_circ_cont(lv_point_t * c);
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
void lv_circ_next(lv_point_t * c, lv_coord_t * tmp);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
135
lv_misc/lv_color.c
Normal file
135
lv_misc/lv_color.c
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @file lv_color.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with LV_COLOR_DEPTH depth)
|
||||
*/
|
||||
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
{
|
||||
h = (uint32_t)((uint32_t)h * 255) / 360;
|
||||
s = (uint16_t)((uint16_t)s * 255) / 100;
|
||||
v = (uint16_t)((uint16_t)v * 255) / 100;
|
||||
|
||||
uint8_t r, g, b;
|
||||
|
||||
uint8_t region, remainder, p, q, t;
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
r = v;
|
||||
g = v;
|
||||
b = v;
|
||||
return LV_COLOR_MAKE(v, v, v);
|
||||
}
|
||||
|
||||
region = h / 43;
|
||||
remainder = (h - (region * 43)) * 6;
|
||||
|
||||
p = (v * (255 - s)) >> 8;
|
||||
q = (v * (255 - ((s * remainder) >> 8))) >> 8;
|
||||
t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case 0:
|
||||
r = v; g = t; b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q; g = v; b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p; g = v; b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p; g = q; b = v;
|
||||
break;
|
||||
case 4:
|
||||
r = t; g = p; b = v;
|
||||
break;
|
||||
default:
|
||||
r = v; g = p; b = q;
|
||||
break;
|
||||
}
|
||||
|
||||
lv_color_t result = LV_COLOR_MAKE(r, g, b);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an RGB color to HSV
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @return the given RGB color n HSV
|
||||
*/
|
||||
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
lv_color_hsv_t hsv;
|
||||
uint8_t rgbMin, rgbMax;
|
||||
|
||||
rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b);
|
||||
rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||
|
||||
hsv.v = rgbMax;
|
||||
if (hsv.v == 0)
|
||||
{
|
||||
hsv.h = 0;
|
||||
hsv.s = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
hsv.s = 255 * (long)(rgbMax - rgbMin) / hsv.v;
|
||||
if (hsv.s == 0)
|
||||
{
|
||||
hsv.h = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
if (rgbMax == r)
|
||||
hsv.h = 0 + 43 * (g - b) / (rgbMax - rgbMin);
|
||||
else if (rgbMax == g)
|
||||
hsv.h = 85 + 43 * (b - r) / (rgbMax - rgbMin);
|
||||
else
|
||||
hsv.h = 171 + 43 * (r - g) / (rgbMax - rgbMin);
|
||||
|
||||
return hsv;
|
||||
}
|
||||
311
lv_misc/lv_color.h
Normal file
311
lv_misc/lv_color.h
Normal file
@@ -0,0 +1,311 @@
|
||||
/**
|
||||
* @file lv_color.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_COLOR_H
|
||||
#define LV_COLOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_COLOR_BLACK LV_COLOR_MAKE(0x00,0x00,0x00)
|
||||
#define LV_COLOR_WHITE LV_COLOR_MAKE(0xFF,0xFF,0xFF)
|
||||
#define LV_COLOR_RED LV_COLOR_MAKE(0xFF,0x00,0x00)
|
||||
#define LV_COLOR_LIME LV_COLOR_MAKE(0x00,0xFF,0x00)
|
||||
#define LV_COLOR_BLUE LV_COLOR_MAKE(0x00,0x00,0xFF)
|
||||
#define LV_COLOR_YELLOW LV_COLOR_MAKE(0xFF,0xFF,0x00)
|
||||
#define LV_COLOR_CYAN LV_COLOR_MAKE(0x00,0xFF,0xFF)
|
||||
#define LV_COLOR_AQUA LV_COLOR_CYAN
|
||||
#define LV_COLOR_MAGENTA LV_COLOR_MAKE(0xFF,0x00,0xFF)
|
||||
#define LV_COLOR_SILVER LV_COLOR_MAKE(0xC0,0xC0,0xC0)
|
||||
#define LV_COLOR_GRAY LV_COLOR_MAKE(0x80,0x80,0x80)
|
||||
#define LV_COLOR_MARRON LV_COLOR_MAKE(0x80,0x00,0x00)
|
||||
#define LV_COLOR_OLIVE LV_COLOR_MAKE(0x80,0x80,0x00)
|
||||
#define LV_COLOR_GREEN LV_COLOR_MAKE(0x00,0x80,0x00)
|
||||
#define LV_COLOR_PURPLE LV_COLOR_MAKE(0x80,0x00,0x80)
|
||||
#define LV_COLOR_TEAL LV_COLOR_MAKE(0x00,0x80,0x80)
|
||||
#define LV_COLOR_NAVY LV_COLOR_MAKE(0x00,0x00,0x80)
|
||||
#define LV_COLOR_ORANGE LV_COLOR_MAKE(0xFF,0xA5,0x00)
|
||||
|
||||
#define LV_OPA_TRANSP 0
|
||||
#define LV_OPA_0 0
|
||||
#define LV_OPA_10 25
|
||||
#define LV_OPA_20 51
|
||||
#define LV_OPA_30 76
|
||||
#define LV_OPA_40 102
|
||||
#define LV_OPA_50 127
|
||||
#define LV_OPA_60 153
|
||||
#define LV_OPA_70 178
|
||||
#define LV_OPA_80 204
|
||||
#define LV_OPA_90 229
|
||||
#define LV_OPA_100 255
|
||||
#define LV_OPA_COVER 255
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t blue :1;
|
||||
uint8_t green :1;
|
||||
uint8_t red :1;
|
||||
uint8_t full :1;
|
||||
}lv_color1_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t blue :2;
|
||||
uint8_t green :3;
|
||||
uint8_t red :3;
|
||||
};
|
||||
uint8_t full;
|
||||
}lv_color8_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t blue :5;
|
||||
uint16_t green :6;
|
||||
uint16_t red :5;
|
||||
};
|
||||
uint16_t full;
|
||||
}lv_color16_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t blue;
|
||||
uint8_t green;
|
||||
uint8_t red;
|
||||
};
|
||||
uint32_t full;
|
||||
}lv_color24_t;
|
||||
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
typedef uint8_t lv_color_int_t;
|
||||
typedef lv_color1_t lv_color_t;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
typedef uint8_t lv_color_int_t;
|
||||
typedef lv_color8_t lv_color_t;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
typedef uint16_t lv_color_int_t;
|
||||
typedef lv_color16_t lv_color_t;
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
typedef uint32_t lv_color_int_t;
|
||||
typedef lv_color24_t lv_color_t;
|
||||
#else
|
||||
#error "Invalid LV_COLOR_DEPTH in misc_conf.h! Set it to 1, 8, 16 or 24!"
|
||||
#endif
|
||||
|
||||
typedef uint8_t lv_opa_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t h;
|
||||
uint8_t s;
|
||||
uint8_t v;
|
||||
} lv_color_hsv_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*In color conversations:
|
||||
* - When converting to bigger color type the LSB weight of 1 LSB is calculated
|
||||
* E.g. 16 bit Red has 5 bits
|
||||
* 8 bit Red has 2 bits
|
||||
* ----------------------
|
||||
* 8 bit red LSB = (2^5 - 1) / (2^2 - 1) = 31 / 3 = 10
|
||||
*
|
||||
* - When calculating to smaller color type simply shift out the LSBs
|
||||
* E.g. 8 bit Red has 2 bits
|
||||
* 16 bit Red has 5 bits
|
||||
* ----------------------
|
||||
* Shift right with 5 - 3 = 2
|
||||
*/
|
||||
|
||||
static inline uint8_t lv_color_to1(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
return color.full;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
if((color.red & 0b100) ||
|
||||
(color.green & 0b100) ||
|
||||
(color.blue & 0b10)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
if((color.red & 0b10000) ||
|
||||
(color.green & 0b100000) ||
|
||||
(color.blue & 0b10000)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
if((color.red & 0x80) ||
|
||||
(color.green & 0x80) ||
|
||||
(color.blue & 0x80)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint8_t lv_color_to8(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
return color.full;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
lv_color8_t ret;
|
||||
ret.red = color.red >> 2; /* 5 - 3 = 2*/
|
||||
ret.green = color.green >> 3; /* 6 - 3 = 3*/
|
||||
ret.blue = color.blue >> 3; /* 5 - 2 = 3*/
|
||||
return ret.full;
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
lv_color8_t ret;
|
||||
ret.red = color.red >> 5; /* 8 - 3 = 5*/
|
||||
ret.green = color.green >> 5; /* 8 - 3 = 5*/
|
||||
ret.blue = color.blue >> 6; /* 8 - 2 = 6*/
|
||||
return ret.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t lv_color_to16(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
lv_color16_t ret;
|
||||
ret.red = color.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/
|
||||
ret.green = color.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
||||
ret.blue = color.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/
|
||||
return ret.full;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
return color.full;
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
lv_color16_t ret;
|
||||
ret.red = color.red >> 3; /* 8 - 5 = 3*/
|
||||
ret.green = color.green >> 2; /* 8 - 6 = 2*/
|
||||
ret.blue = color.blue >> 3; /* 8 - 5 = 3*/
|
||||
return ret.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t lv_color_to24(lv_color_t color)
|
||||
{
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFFFF;
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
lv_color24_t ret;
|
||||
ret.red = color.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||
ret.green = color.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||
ret.blue = color.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/
|
||||
return ret.full;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
lv_color24_t ret;
|
||||
ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
ret.green = color.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
|
||||
ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
return ret.full;
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
return color.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix)
|
||||
{
|
||||
lv_color_t ret;
|
||||
ret.red = (uint16_t)((uint16_t) c1.red * mix + (c2.red * (255 - mix))) >> 8;
|
||||
ret.green = (uint16_t)((uint16_t) c1.green * mix + (c2.green * (255 - mix))) >> 8;
|
||||
ret.blue = (uint16_t)((uint16_t) c1.blue * mix + (c2.blue * (255 - mix))) >> 8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the brightness of a color
|
||||
* @param color a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
static inline uint8_t lv_color_brightness(lv_color_t color)
|
||||
{
|
||||
lv_color24_t c24;
|
||||
c24.full = lv_color_to24(color);
|
||||
uint16_t bright = 3 * c24.red + c24.blue + 4 * c24.green;
|
||||
return (uint16_t) bright >> 3;
|
||||
}
|
||||
|
||||
#if LV_COLOR_DEPTH == 1
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){(b8 >> 7 | g8 >> 7 | r8 >> 7)})
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 6, g8 >> 5, r8 >> 5}})
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8 >> 3, g8 >> 2, r8 >> 3}})
|
||||
#elif LV_COLOR_DEPTH == 24
|
||||
#define LV_COLOR_MAKE(r8, g8, b8) ((lv_color_t){{b8, g8, r8}})
|
||||
#endif
|
||||
|
||||
#define LV_COLOR_HEX(c) LV_COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \
|
||||
((uint32_t)((uint32_t)c >> 8) & 0xFF), \
|
||||
((uint32_t) c & 0xFF))
|
||||
|
||||
/*Usage LV_COLOR_HEX3(0x16C) which means LV_COLOR_HEX(0x1166CC)*/
|
||||
#define LV_COLOR_HEX3(c) LV_COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
|
||||
((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
||||
((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
||||
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with LV_COLOR_DEPTH depth)
|
||||
*/
|
||||
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v);
|
||||
|
||||
/**
|
||||
* Convert an RGB color to HSV
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @return the given RGB color n HSV
|
||||
*/
|
||||
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*USE_COLOR*/
|
||||
482
lv_misc/lv_font.c
Normal file
482
lv_misc/lv_font.c
Normal file
@@ -0,0 +1,482 @@
|
||||
/**
|
||||
* @file lv_font.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lv_font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the built-in fonts
|
||||
*/
|
||||
void lv_font_init(void)
|
||||
{
|
||||
|
||||
/*DEJAVU 10*/
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_dejavu_10, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_dejavu_10_sup, &lv_font_dejavu_10);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_10_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_dejavu_10_latin_ext_a, &lv_font_dejavu_10);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_10_latine_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_dejavu_10_latin_ext_b, &lv_font_dejavu_10);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_10_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_10_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_dejavu_10_cyrillic, &lv_font_dejavu_10);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_10_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 10*/
|
||||
#if USE_LV_FONT_SYMBOL_10_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_10 != 0
|
||||
lv_font_add(&lv_font_symbol_10_basic, &lv_font_dejavu_10);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_10_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_10_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_10_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_10_file, &lv_font_symbol_10_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_10_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_10_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_10_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_10_feedback, &lv_font_symbol_10_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_10_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*DEJAVU 20*/
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_dejavu_20, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_dejavu_20_sup, &lv_font_dejavu_20);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_20_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_dejavu_20_latin_ext_a, &lv_font_dejavu_20);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_20_latin_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_dejavu_20_latin_ext_b, &lv_font_dejavu_20);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_20_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_20_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_dejavu_20_cyrillic, &lv_font_dejavu_20);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_20_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 20*/
|
||||
#if USE_LV_FONT_SYMBOL_20_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_20 != 0
|
||||
lv_font_add(&lv_font_symbol_20_basic, &lv_font_dejavu_20);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_20_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_20_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_20_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_20_file, &lv_font_symbol_20_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_20_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_20_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_20_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_20_feedback, &lv_font_symbol_20_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_20_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*DEJAVU 30*/
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_dejavu_30, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_dejavu_30_sup, &lv_font_dejavu_30);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_30_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_dejavu_30_latin_ext_a, &lv_font_dejavu_30);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_30_latin_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_dejavu_30_latin_ext_b, &lv_font_dejavu_30);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_30_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_30_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_dejavu_30_cyrillic, &lv_font_dejavu_30);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_30_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 30*/
|
||||
#if USE_LV_FONT_SYMBOL_30_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_30 != 0
|
||||
lv_font_add(&lv_font_symbol_30_basic, &lv_font_dejavu_30);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_30_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_30_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_30_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_30_file, &lv_font_symbol_30_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_30_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_30_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_30_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_30_feedback, &lv_font_symbol_30_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_30_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*DEJAVU 40*/
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_dejavu_40, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_dejavu_40_sup, &lv_font_dejavu_40);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_40_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_dejavu_40_latin_ext_a, &lv_font_dejavu_40);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_40_latin_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_dejavu_40_latin_ext_b, &lv_font_dejavu_40);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_40_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_40_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_dejavu_40_cyrillic, &lv_font_dejavu_40);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_40_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 40*/
|
||||
#if USE_LV_FONT_SYMBOL_40_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_40 != 0
|
||||
lv_font_add(&lv_font_symbol_40_basic, &lv_font_dejavu_40);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_40_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_40_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_40_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_40_file, &lv_font_symbol_40_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_40_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_40_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_40_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_40_feedback, &lv_font_symbol_40_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_40_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*DEJAVU 60*/
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_dejavu_60, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_60_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_dejavu_60_sup, &lv_font_dejavu_60);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_60_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_60_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_dejavu_60_latin_ext_a, &lv_font_dejavu_60);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_60_latin_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_60_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_dejavu_60_latin_ext_b, &lv_font_dejavu_60);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_60_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_60_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_dejavu_60_cyrillic, &lv_font_dejavu_60);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_60_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 60*/
|
||||
#if USE_LV_FONT_SYMBOL_60_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_60 != 0
|
||||
lv_font_add(&lv_font_symbol_60_basic, &lv_font_dejavu_60);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_60_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_60_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_60_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_60_file, &lv_font_symbol_60_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_60_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_60_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_60_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_60_feedback, &lv_font_symbol_60_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_60_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*DEJAVU 80*/
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_dejavu_80, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_80_SUP != 0
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_dejavu_80_sup, &lv_font_dejavu_80);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_80_sup, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_80_LATIN_EXT_A != 0
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_dejavu_80_latin_ext_a, &lv_font_dejavu_80);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_80_latin_ext_a, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_80_LATIN_EXT_B != 0
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_dejavu_80_latin_ext_b, &lv_font_dejavu_80);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_80_latin_ext_b, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_DEJAVU_80_CYRILLIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_dejavu_80_cyrillic, &lv_font_dejavu_80);
|
||||
#else
|
||||
lv_font_add(&lv_font_dejavu_80_cyrillic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*SYMBOL 80*/
|
||||
#if USE_LV_FONT_SYMBOL_80_BASIC != 0
|
||||
#if USE_LV_FONT_DEJAVU_80 != 0
|
||||
lv_font_add(&lv_font_symbol_80_basic, &lv_font_dejavu_80);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_80_basic, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_80_FILE != 0
|
||||
#if USE_LV_FONT_SYMBOL_80_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_80_file, &lv_font_symbol_80_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_80_file, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_LV_FONT_SYMBOL_80_FEEDBACK != 0
|
||||
#if USE_LV_FONT_SYMBOL_80_BASIC != 0
|
||||
lv_font_add(&lv_font_symbol_80_feedback, &lv_font_symbol_80_basic);
|
||||
#else
|
||||
lv_font_add(&lv_font_symbol_80_feedback, NULL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param name name of the font
|
||||
* @param dsc_get_fp the font descriptor get function
|
||||
* @param parent add this font as charter set extension of 'parent'
|
||||
*/
|
||||
void lv_font_add(lv_font_t *child, lv_font_t *parent)
|
||||
{
|
||||
if(parent == NULL) return;
|
||||
|
||||
while(parent->next_page != NULL) {
|
||||
parent = parent->next_page; /*Got to the last page and add the new font there*/
|
||||
}
|
||||
|
||||
parent->next_page = child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter)
|
||||
{
|
||||
const lv_font_t * font_i = font_p;
|
||||
while(font_i != NULL) {
|
||||
if(letter >= font_i->first_ascii && letter <= font_i->last_ascii) {
|
||||
uint32_t index = (letter - font_i->first_ascii);
|
||||
return &font_i->bitmap[font_i->map[index]];
|
||||
}
|
||||
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter)
|
||||
{
|
||||
const lv_font_t * font_i = font_p;
|
||||
while(font_i != NULL) {
|
||||
if(letter >= font_i->first_ascii && letter <= font_i->last_ascii) {
|
||||
uint32_t index = (letter - font_i->first_ascii);
|
||||
return font_i->width[index];
|
||||
}
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
175
lv_misc/lv_font.h
Normal file
175
lv_misc/lv_font.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* @file lv_font.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FONT_H
|
||||
#define LV_FONT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lv_conf.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lv_fonts/lv_symbol_def.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct _lv_font_struct
|
||||
{
|
||||
uint32_t first_ascii;
|
||||
uint32_t last_ascii;
|
||||
uint8_t height_row;
|
||||
const uint8_t * bitmap;
|
||||
const uint32_t * map;
|
||||
const uint8_t * width;
|
||||
struct _lv_font_struct * next_page; /*Pointer to a font extension*/
|
||||
}lv_font_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the built-in fonts
|
||||
*/
|
||||
void lv_font_init(void);
|
||||
|
||||
/**
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param child pointer to a font to join to the 'parent'
|
||||
* @param parent pointer to a font. 'child' will be joined here
|
||||
*/
|
||||
void lv_font_add(lv_font_t *child, lv_font_t *parent);
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);
|
||||
|
||||
/**
|
||||
* Get the height of a font
|
||||
* @param font_p pointer to a font
|
||||
* @return the height of a font
|
||||
*/
|
||||
static inline uint8_t lv_font_get_height(const lv_font_t * font_p)
|
||||
{
|
||||
return font_p->height_row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of a font. Give the real size on the screen (half size if LV_FONT_ANTIALIAS is enabled)
|
||||
* @param font_p pointer to a font
|
||||
* @return the height of a font
|
||||
*/
|
||||
static inline uint8_t lv_font_get_height_scale(const lv_font_t * font_p)
|
||||
{
|
||||
return (font_p->height_row >> LV_FONT_ANTIALIAS) >> LV_ANTIALIAS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font )Give the real size on the screen (half size if LV_FONT_ANTIALIAS is enabled)
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
static inline uint8_t lv_font_get_width_scale(const lv_font_t * font_p, uint32_t letter)
|
||||
{
|
||||
return (lv_font_get_width(font_p, letter) >> LV_FONT_ANTIALIAS) >> LV_ANTIALIAS;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/***********************
|
||||
* POST INCLUDES
|
||||
***********************/
|
||||
/*Add built-in fonts*/
|
||||
|
||||
#include "lv_fonts/dejavu_10.h"
|
||||
#include "lv_fonts/dejavu_10_sup.h"
|
||||
#include "lv_fonts/dejavu_10_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_10_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_10_cyrillic.h"
|
||||
#include "lv_fonts/symbol_10_basic.h"
|
||||
#include "lv_fonts/symbol_10_file.h"
|
||||
#include "lv_fonts/symbol_10_feedback.h"
|
||||
|
||||
#include "lv_fonts/dejavu_20.h"
|
||||
#include "lv_fonts/dejavu_20_sup.h"
|
||||
#include "lv_fonts/dejavu_20_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_20_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_20_cyrillic.h"
|
||||
#include "lv_fonts/symbol_20_basic.h"
|
||||
#include "lv_fonts/symbol_20_file.h"
|
||||
#include "lv_fonts/symbol_20_feedback.h"
|
||||
|
||||
#include "lv_fonts/dejavu_30.h"
|
||||
#include "lv_fonts/dejavu_30_sup.h"
|
||||
#include "lv_fonts/dejavu_30_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_30_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_30_cyrillic.h"
|
||||
#include "lv_fonts/symbol_30_basic.h"
|
||||
#include "lv_fonts/symbol_30_file.h"
|
||||
#include "lv_fonts/symbol_30_feedback.h"
|
||||
|
||||
#include "lv_fonts/dejavu_40.h"
|
||||
#include "lv_fonts/dejavu_40_sup.h"
|
||||
#include "lv_fonts/dejavu_40_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_40_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_40_cyrillic.h"
|
||||
#include "lv_fonts/symbol_40_basic.h"
|
||||
#include "lv_fonts/symbol_40_file.h"
|
||||
#include "lv_fonts/symbol_40_feedback.h"
|
||||
|
||||
#include "lv_fonts/dejavu_60.h"
|
||||
#include "lv_fonts/dejavu_60_sup.h"
|
||||
#include "lv_fonts/dejavu_60_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_60_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_60_cyrillic.h"
|
||||
#include "lv_fonts/symbol_60_basic.h"
|
||||
#include "lv_fonts/symbol_60_file.h"
|
||||
#include "lv_fonts/symbol_60_feedback.h"
|
||||
|
||||
#include "lv_fonts/dejavu_80.h"
|
||||
#include "lv_fonts/dejavu_80_sup.h"
|
||||
#include "lv_fonts/dejavu_80_latin_ext_a.h"
|
||||
#include "lv_fonts/dejavu_80_latin_ext_b.h"
|
||||
#include "lv_fonts/dejavu_80_cyrillic.h"
|
||||
#include "lv_fonts/symbol_80_basic.h"
|
||||
#include "lv_fonts/symbol_80_file.h"
|
||||
#include "lv_fonts/symbol_80_feedback.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*USE_FONT*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user