1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

Merge branch 'dev' into feat/new-scroll

This commit is contained in:
Gabor Kiss-Vamosi 2020-07-02 09:27:04 +02:00
commit e7648f1c00
42 changed files with 466 additions and 75 deletions

17
.github/workflows/merge-to-dev.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Merge master branch to dev
on:
push:
branches:
- 'master'
jobs:
merge-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Merge to dev branch
uses: devmasx/merge-branch@v1.1.0
with:
type: now
target_branch: 'dev'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@ -31,11 +31,16 @@ Available in the `dev` branch
- In `lv_init` test if the the strings are UTF-8 encoded. - In `lv_init` test if the the strings are UTF-8 encoded.
- Add `user_data` to themes - Add `user_data` to themes
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems. - Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
- Add inline function lv_checkbox_get_state(const lv_obj_t * cb) to extend the checkbox functionality.
- Add inline function lv_checkbox_set_state(const lv_obj_t * cb, lv_btn_state_t state ) to extend the checkbox functionality.
### Bugfixes ### Bugfixes
- `lv_img` fix invalidation area when angle or zoom changes - `lv_img` fix invalidation area when angle or zoom changes
- Update the style handling to support Big endian MCUs - Update the style handling to support Big endian MCUs
- Change some methods to support big endian hardware. - Change some methods to support big endian hardware.
- remove use of c++ keyword 'new' in parameter of function lv_theme_set_base().
- Add LV_BIG_ENDIAN_SYSTEM flag to lv_conf.h in order to fix displaying images on big endian systems.
- Fix inserting chars in text area in big endian hardware.
## v7.0.2 (16.06.2020) ## v7.0.2 (16.06.2020)

View File

@ -0,0 +1,119 @@
#include <lvgl.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
static lv_disp_buf_t disp_buf;
static lv_color_t buf[LV_HOR_RES_MAX * 10];
#if USE_LV_LOG != 0
/* Serial debugging */
void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc)
{
Serial.printf("%s@%d->%s\r\n", file, line, dsc);
Serial.flush();
}
#endif
/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);
tft.startWrite();
tft.setAddrWindow(area->x1, area->y1, w, h);
tft.pushColors(&color_p->full, w * h, true);
tft.endWrite();
lv_disp_flush_ready(disp);
}
/*Read the touchpad*/
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{
uint16_t touchX, touchY;
bool touched = tft.getTouch(&touchX, &touchY, 600);
if(!touched)
{
data->state = LV_INDEV_STATE_REL;
return false;
}
else
{
data->state = LV_INDEV_STATE_PR;
}
if(touchX>screenWidth || touchY > screenHeight)
{
Serial.println("Y or y outside of expected parameters..");
Serial.print("y:");
Serial.print(touchX);
Serial.print(" x:");
Serial.print(touchY);
}
else
{
/*Set the coordinates*/
data->point.x = touchX;
data->point.y = touchY;
Serial.print("Data x");
Serial.println(touchX);
Serial.print("Data y");
Serial.println(touchY);
}
return false; /*Return `false` because we are not buffering and no more data to read*/
}
void setup()
{
Serial.begin(115200); /* prepare for possible serial debug */
lv_init();
#if USE_LV_LOG != 0
lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif
tft.begin(); /* TFT init */
tft.setRotation(1); /* Landscape orientation */
uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
tft.setTouch(calData);
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10);
/*Initialize the display*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = 320;
disp_drv.ver_res = 240;
disp_drv.flush_cb = my_disp_flush;
disp_drv.buffer = &disp_buf;
lv_disp_drv_register(&disp_drv);
/*Initialize the (dummy) input device driver*/
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register(&indev_drv);
/* Try an example from the lv_examples repository
* https://github.com/lvgl/lv_examples*/
lv_ex_btn_1();
}
void loop()
{
lv_task_handler(); /* let the GUI do its work */
delay(5);
}

View File

@ -0,0 +1,44 @@
# Example for lv_arduino using a slider
This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file:
```C
int screenWidth = 480;
int screenHeight = 320;
```
## Backlight
Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve:
```C
ledcSetup(10, 5000/*freq*/, 10 /*resolution*/);
ledcAttachPin(32, 10);
analogReadResolution(10);
ledcWrite(10,768);
```
## Theme selection
Change the following to change the theme:
```C
lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme
lv_theme_set_current(th);
```
## Calibration
This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values:
```C
uint16_t calData[5] = { 275, 3620, 264, 3532, 1 };
```
## Screen rotation
Check the following if you need to alter your screen rotation:
```C
tft.setRotation(3);
```

View File

@ -0,0 +1,37 @@
# LVGL Arduino examples
LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library.
It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL.
## Example
There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing.
To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder.
LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it:
1. Go to directory of the installed Arduno libraries
2. Go to `lvgl` and copy `lv_conf_template.h` as `lvgl.h` next to the `lvgl` folder.
3. Open `lv_conf.h` and change the first `#if 0` to `#if 1`
4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX`
5. Set the color depth of you display in `LV_COLOR_DEPTH`
6. Set `LV_TICK_CUSTOM 1`
## Debugging
In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`:
```c
/*Log settings*/
#define USE_LV_LOG 1 /*Enable/disable the log module*/
#if LV_USE_LOG
/* How important log should be added:
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
* LV_LOG_LEVEL_INFO Log important events
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
* LV_LOG_LEVEL_NONE Do not log anything
*/
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
```
After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd.

View File

@ -268,8 +268,8 @@ typedef void * lv_img_decoder_user_data_t;
* It removes the need to manually update the tick with `lv_tick_inc`) */ * It removes the need to manually update the tick with `lv_tick_inc`) */
#define LV_TICK_CUSTOM 0 #define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM == 1 #if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif /*LV_TICK_CUSTOM*/ #endif /*LV_TICK_CUSTOM*/
typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/
@ -428,8 +428,8 @@ typedef void * lv_font_user_data_t;
#define LV_THEME_DEFAULT_INCLUDE <stdint.h> /*Include a header for the init. function*/ #define LV_THEME_DEFAULT_INCLUDE <stdint.h> /*Include a header for the init. function*/
#define LV_THEME_DEFAULT_INIT lv_theme_material_init #define LV_THEME_DEFAULT_INIT lv_theme_material_init
#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED #define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1)
#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE #define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6)
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
#define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16 #define LV_THEME_DEFAULT_FONT_SMALL &lv_font_montserrat_16
#define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16 #define LV_THEME_DEFAULT_FONT_NORMAL &lv_font_montserrat_16

View File

@ -394,10 +394,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#endif #endif
#if LV_TICK_CUSTOM == 1 #if LV_TICK_CUSTOM == 1
#ifndef LV_TICK_CUSTOM_INCLUDE #ifndef LV_TICK_CUSTOM_INCLUDE
#define LV_TICK_CUSTOM_INCLUDE "something.h" /*Header for the sys time function*/ #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#endif #endif
#ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/ #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif #endif
#endif /*LV_TICK_CUSTOM*/ #endif /*LV_TICK_CUSTOM*/
@ -641,10 +641,10 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#define LV_THEME_DEFAULT_INIT lv_theme_material_init #define LV_THEME_DEFAULT_INIT lv_theme_material_init
#endif #endif
#ifndef LV_THEME_DEFAULT_COLOR_PRIMARY #ifndef LV_THEME_DEFAULT_COLOR_PRIMARY
#define LV_THEME_DEFAULT_COLOR_PRIMARY LV_COLOR_RED #define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0x01a2b1)
#endif #endif
#ifndef LV_THEME_DEFAULT_COLOR_SECONDARY #ifndef LV_THEME_DEFAULT_COLOR_SECONDARY
#define LV_THEME_DEFAULT_COLOR_SECONDARY LV_COLOR_BLUE #define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0x44d1b6)
#endif #endif
#ifndef LV_THEME_DEFAULT_FLAG #ifndef LV_THEME_DEFAULT_FLAG
#define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT #define LV_THEME_DEFAULT_FLAG LV_THEME_MATERIAL_FLAG_LIGHT
@ -705,7 +705,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
/* Support bidirectional texts. /* Support bidirectional texts.
* Allows mixing Left-to-Right and Right-to-Left texts. * Allows mixing Left-to-Right and Right-to-Left texts.
* The direction will be processed according to the Unicode Bidirectional Algorithm: * The direction will be processed according to the Unicode Bidirectioanl Algorithm:
* https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#ifndef LV_USE_BIDI #ifndef LV_USE_BIDI
#define LV_USE_BIDI 0 #define LV_USE_BIDI 0

View File

@ -37,7 +37,7 @@ static int32_t unicode_list_compare(const void * ref, const void * element);
static int32_t kern_pair_8_compare(const void * ref, const void * element); static int32_t kern_pair_8_compare(const void * ref, const void * element);
static int32_t kern_pair_16_compare(const void * ref, const void * element); static int32_t kern_pair_16_compare(const void * ref, const void * element);
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp); static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter);
static inline void decompress_line(uint8_t * out, lv_coord_t w); static inline void decompress_line(uint8_t * out, lv_coord_t w);
static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len); static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len);
static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len); static inline void bits_write(uint8_t * out, uint32_t bit_pos, uint8_t val, uint8_t len);
@ -114,7 +114,8 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
if(decompr_buf == NULL) return NULL; if(decompr_buf == NULL) return NULL;
} }
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp); bool prefilter = fdsc->bitmap_format == LV_FONT_FMT_TXT_COMPRESSED ? true : false;
decompress(&fdsc->glyph_bitmap[gdsc->bitmap_index], decompr_buf, gdsc->box_w, gdsc->box_h, (uint8_t)fdsc->bpp, prefilter);
return decompr_buf; return decompr_buf;
} }
@ -333,8 +334,9 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element)
* @param out buffer to store the result * @param out buffer to store the result
* @param px_num number of pixels in the glyph (width * height) * @param px_num number of pixels in the glyph (width * height)
* @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4) * @param bpp bit per pixel (bpp = 3 will be converted to bpp = 4)
* @param prefilter true: the lines are XORed
*/ */
static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp) static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord_t h, uint8_t bpp, bool prefilter)
{ {
uint32_t wrp = 0; uint32_t wrp = 0;
uint8_t wr_size = bpp; uint8_t wr_size = bpp;
@ -343,7 +345,12 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
rle_init(in, bpp); rle_init(in, bpp);
uint8_t * line_buf1 = _lv_mem_buf_get(w); uint8_t * line_buf1 = _lv_mem_buf_get(w);
uint8_t * line_buf2 = _lv_mem_buf_get(w);
uint8_t * line_buf2 = NULL;
if(prefilter) {
line_buf2= _lv_mem_buf_get(w);
}
decompress_line(line_buf1, w); decompress_line(line_buf1, w);
@ -356,12 +363,21 @@ static void decompress(const uint8_t * in, uint8_t * out, lv_coord_t w, lv_coord
} }
for(y = 1; y < h; y++) { for(y = 1; y < h; y++) {
decompress_line(line_buf2, w); if(prefilter) {
decompress_line(line_buf2, w);
for(x = 0; x < w; x++) { for(x = 0; x < w; x++) {
line_buf1[x] = line_buf2[x] ^ line_buf1[x]; line_buf1[x] = line_buf2[x] ^ line_buf1[x];
bits_write(out, wrp, line_buf1[x], bpp); bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size; wrp += wr_size;
}
} else {
decompress_line(line_buf1, w);
for(x = 0; x < w; x++) {
bits_write(out, wrp, line_buf1[x], bpp);
wrp += wr_size;
}
} }
} }

View File

@ -150,6 +150,7 @@ typedef struct {
typedef enum { typedef enum {
LV_FONT_FMT_TXT_PLAIN = 0, LV_FONT_FMT_TXT_PLAIN = 0,
LV_FONT_FMT_TXT_COMPRESSED = 1, LV_FONT_FMT_TXT_COMPRESSED = 1,
LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER= 1,
} lv_font_fmt_txt_bitmap_format_t; } lv_font_fmt_txt_bitmap_format_t;

View File

@ -27,9 +27,9 @@
#endif #endif
#if LV_COLOR_DEPTH == 16 #if LV_COLOR_DEPTH == 16
#define DMA2D_COLOR_FORMAT DMA2D_RGB565 #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_RGB565
#elif LV_COLOR_DEPTH == 32 #elif LV_COLOR_DEPTH == 32
#define DMA2D_COLOR_FORMAT DMA2D_ARGB8888 #define LV_DMA2D_COLOR_FORMAT LV_DMA2D_ARGB8888
#else #else
/*Can't use GPU with other formats*/ /*Can't use GPU with other formats*/
#endif #endif
@ -68,7 +68,7 @@ void lv_gpu_stm32_dma2d_init(void)
volatile uint32_t temp = RCC->AHB1ENR; volatile uint32_t temp = RCC->AHB1ENR;
/* set output colour mode */ /* set output colour mode */
DMA2D->OPFCCR = DMA2D_COLOR_FORMAT; DMA2D->OPFCCR = LV_DMA2D_COLOR_FORMAT;
} }
/** /**
@ -160,7 +160,7 @@ void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_
DMA2D->CR = 0; DMA2D->CR = 0;
/* copy output colour mode, this register controls both input and output colour format */ /* copy output colour mode, this register controls both input and output colour format */
DMA2D->FGPFCCR = DMA2D_COLOR_FORMAT; DMA2D->FGPFCCR = LV_DMA2D_COLOR_FORMAT;
DMA2D->FGMAR = (uint32_t)map; DMA2D->FGMAR = (uint32_t)map;
DMA2D->FGOR = map_w - copy_w; DMA2D->FGOR = map_w - copy_w;
DMA2D->OMAR = (uint32_t)buf; DMA2D->OMAR = (uint32_t)buf;
@ -189,11 +189,11 @@ void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color
invalidate_cache(); invalidate_cache();
DMA2D->CR = 0x20000; DMA2D->CR = 0x20000;
DMA2D->BGPFCCR = DMA2D_COLOR_FORMAT; DMA2D->BGPFCCR = LV_DMA2D_COLOR_FORMAT;
DMA2D->BGMAR = (uint32_t)buf; DMA2D->BGMAR = (uint32_t)buf;
DMA2D->BGOR = buf_w - copy_w; DMA2D->BGOR = buf_w - copy_w;
DMA2D->FGPFCCR = (uint32_t)DMA2D_COLOR_FORMAT DMA2D->FGPFCCR = (uint32_t)LV_DMA2D_COLOR_FORMAT
/* alpha mode 2, replace with foreground * alpha value */ /* alpha mode 2, replace with foreground * alpha value */
| (2 << DMA2D_FGPFCCR_AM_Pos) | (2 << DMA2D_FGPFCCR_AM_Pos)
/* alpha value */ /* alpha value */

View File

@ -20,11 +20,11 @@ extern "C" {
* DEFINES * DEFINES
*********************/ *********************/
#define DMA2D_ARGB8888 0 #define LV_DMA2D_ARGB8888 0
#define DMA2D_RGB888 1 #define LV_DMA2D_RGB888 1
#define DMA2D_RGB565 2 #define LV_DMA2D_RGB565 2
#define DMA2D_ARGB1555 3 #define LV_DMA2D_ARGB1555 3
#define DMA2D_ARGB4444 4 #define LV_DMA2D_ARGB4444 4
/********************** /**********************
* TYPEDEFS * TYPEDEFS

View File

@ -29,7 +29,7 @@
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
static uint32_t sys_time = 0; static uint32_t sys_time = 0;
static volatile uint32_t tick_irq_flag; static volatile uint8_t tick_irq_flag;
/********************** /**********************
* MACROS * MACROS

View File

@ -534,6 +534,7 @@ static uint32_t lv_txt_unicode_to_utf8(uint32_t letter_uni)
*/ */
static uint32_t lv_txt_utf8_conv_wc(uint32_t c) static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
{ {
#if LV_BIG_ENDIAN_SYSTEM == 0
/*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/ /*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/
if((c & 0x80) != 0) { if((c & 0x80) != 0) {
uint32_t swapped; uint32_t swapped;
@ -547,7 +548,7 @@ static uint32_t lv_txt_utf8_conv_wc(uint32_t c)
} }
c = swapped; c = swapped;
} }
#endif
return c; return c;
} }

View File

@ -98,12 +98,23 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
* Set a base theme for a theme. * Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme. * The styles from the base them will be added before the styles of the current theme.
* Arbitrary long chain of themes can be created by setting base themes. * Arbitrary long chain of themes can be created by setting base themes.
* @param new pointer to theme which base should be set * @param new_theme pointer to theme which base should be set
* @param base pointer to the base theme * @param base pointer to the base theme
*/ */
void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base) void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base)
{ {
new->base = base; new_theme->base = base;
}
/**
* Set a callback for a theme.
* The callback is used to add styles to different objects
* @param theme pointer to theme which callback should be set
* @param cb pointer to the callback
*/
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
{
theme->apply_cb = apply_cb;
} }
/** /**

View File

@ -201,10 +201,18 @@ void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy);
* Set a base theme for a theme. * Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme. * The styles from the base them will be added before the styles of the current theme.
* Arbitrary long chain of themes can be created by setting base themes. * Arbitrary long chain of themes can be created by setting base themes.
* @param new pointer to theme which base should be set * @param new_theme pointer to theme which base should be set
* @param base pointer to the base theme * @param base pointer to the base theme
*/ */
void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base); void lv_theme_set_base(lv_theme_t * new_theme, lv_theme_t * base);
/**
* Set an apply callback for a theme.
* The apply callback is used to add styles to different objects
* @param theme pointer to theme which callback should be set
* @param apply_cb pointer to the callback
*/
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
/** /**
* Get the small font of the theme * Get the small font of the theme

View File

@ -792,6 +792,39 @@ static void roller_init(void)
static void tabview_init(void) static void tabview_init(void)
{ {
#if LV_USE_TABVIEW != 0 #if LV_USE_TABVIEW != 0
#endif
}
static void tileview_init(void)
{
#if LV_USE_TILEVIEW != 0
#endif
}
static void table_init(void)
{
#if LV_USE_TABLE != 0
style_init_reset(&styles->table_cell);
lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
#endif
}
static void win_init(void)
{
#if LV_USE_WIN != 0
#endif
}
static void tabview_win_shared_init(void)
{
#if LV_USE_TABVIEW || LV_USE_WIN
style_init_reset(&styles->tabview_btns_bg); style_init_reset(&styles->tabview_btns_bg);
lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_opa(&styles->tabview_btns_bg, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG); lv_style_set_bg_color(&styles->tabview_btns_bg, LV_STATE_DEFAULT, COLOR_BG);
@ -831,34 +864,6 @@ static void tabview_init(void)
#endif #endif
} }
static void tileview_init(void)
{
#if LV_USE_TILEVIEW != 0
#endif
}
static void table_init(void)
{
#if LV_USE_TABLE != 0
style_init_reset(&styles->table_cell);
lv_style_set_border_color(&styles->table_cell, LV_STATE_DEFAULT, COLOR_BG_BORDER);
lv_style_set_border_width(&styles->table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&styles->table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
lv_style_set_pad_left(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_right(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_top(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
lv_style_set_pad_bottom(&styles->table_cell, LV_STATE_DEFAULT, PAD_DEF);
#endif
}
static void win_init(void)
{
#if LV_USE_WIN != 0
#endif
}
/********************** /**********************
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
@ -927,6 +932,7 @@ lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_s
tileview_init(); tileview_init();
table_init(); table_init();
win_init(); win_init();
tabview_win_shared_init();
theme.apply_xcb = NULL; theme.apply_xcb = NULL;
theme.apply_cb = theme_apply; theme.apply_cb = theme_apply;

View File

@ -289,6 +289,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
} }
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
if(lv_btn_get_checkable(btn)) { if(lv_btn_get_checkable(btn)) {
@ -309,6 +310,7 @@ static lv_res_t lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }
} }
#endif
} }
return res; return res;

View File

@ -992,6 +992,7 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = LV_BTNMATRIX_BTN_NONE; ext->btn_id_act = LV_BTNMATRIX_BTN_NONE;
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT) { if(c == LV_KEY_RIGHT) {
if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE) if(ext->btn_id_focused == LV_BTNMATRIX_BTN_NONE)
@ -1059,10 +1060,13 @@ static lv_res_t lv_btnmatrix_signal(lv_obj_t * btnm, lv_signal_t sign, void * pa
ext->btn_id_act = ext->btn_id_focused; ext->btn_id_act = ext->btn_id_focused;
lv_obj_invalidate(btnm); lv_obj_invalidate(btnm);
} }
#endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
return res; return res;
} }

View File

@ -519,6 +519,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
lv_obj_invalidate(calendar); lv_obj_invalidate(calendar);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint8_t c = *((uint8_t *)param); uint8_t c = *((uint8_t *)param);
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
@ -541,6 +542,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void *
} }
lv_obj_invalidate(calendar); lv_obj_invalidate(calendar);
} }
#endif
} }
return res; return res;

View File

@ -193,11 +193,13 @@ static lv_res_t lv_checkbox_signal(lv_obj_t * cb, lv_signal_t sign, void * param
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN || c == LV_KEY_LEFT || c == LV_KEY_UP) {
/*Follow the backgrounds state with the bullet*/ /*Follow the backgrounds state with the bullet*/
lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG)); lv_obj_set_state(ext->bullet, lv_obj_get_state(cb, LV_CHECKBOX_PART_BG));
} }
#endif
} }
return res; return res;

View File

@ -106,6 +106,15 @@ static inline void lv_checkbox_set_disabled(lv_obj_t * cb)
lv_btn_set_state(cb, LV_BTN_STATE_DISABLED); lv_btn_set_state(cb, LV_BTN_STATE_DISABLED);
} }
/**
* Set the state of a check box
* @param cb pointer to a check box object
* @param state the new state of the check box (from lv_btn_state_t enum)
*/
static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state)
{
lv_btn_set_state(cb, state);
}
/*===================== /*=====================
* Getter functions * Getter functions
*====================*/ *====================*/
@ -137,6 +146,15 @@ static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb)
return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false; return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false;
} }
/**
* Get the current state of a check box
* @param cb pointer to a check box object
* @return the state of the check box (from lv_btn_state_t enum)
*/
static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb)
{
return lv_btn_get_state(cb);
}
/********************** /**********************
* MACROS * MACROS

View File

@ -701,6 +701,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
lv_obj_invalidate(cpicker); lv_obj_invalidate(cpicker);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
@ -745,6 +746,7 @@ static lv_res_t lv_cpicker_signal(lv_obj_t * cpicker, lv_signal_t sign, void * p
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }
} }
#endif
} }
else if(sign == LV_SIGNAL_PRESSED) { else if(sign == LV_SIGNAL_PRESSED) {
ext->last_change_time = lv_tick_get(); ext->last_change_time = lv_tick_get();

View File

@ -968,6 +968,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL); if(ext->page) lv_obj_refresh_style(ext->page, LV_STYLE_PROP_ALL);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(ext->page == NULL) { if(ext->page == NULL) {
@ -992,10 +993,13 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * ddlist, lv_signal_t sign, void * p
ext->sel_opt_id = ext->sel_opt_id_orig; ext->sel_opt_id = ext->sel_opt_id_orig;
lv_dropdown_close(ddlist); lv_dropdown_close(ddlist);
} }
#endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
return res; return res;

View File

@ -730,8 +730,10 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
#endif #endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {

View File

@ -412,6 +412,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
{ {
lv_res_t res; lv_res_t res;
#if LV_USE_GROUP
/*Translate LV_KEY_UP/DOWN to LV_KEY_LEFT/RIGHT */ /*Translate LV_KEY_UP/DOWN to LV_KEY_LEFT/RIGHT */
char c_trans = 0; char c_trans = 0;
if(sign == LV_SIGNAL_CONTROL) { if(sign == LV_SIGNAL_CONTROL) {
@ -421,6 +422,7 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
param = &c_trans; param = &c_trans;
} }
#endif
if(sign == LV_SIGNAL_GET_STYLE) { if(sign == LV_SIGNAL_GET_STYLE) {
lv_get_style_info_t * info = param; lv_get_style_info_t * info = param;
@ -460,8 +462,11 @@ static lv_res_t lv_msgbox_signal(lv_obj_t * mbox, lv_signal_t sign, void * param
if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id); if(btn_id != LV_BTNMATRIX_BTN_NONE) lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
} }
} }
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || else if(
sign == LV_SIGNAL_GET_EDITABLE) { #if LV_USE_GROUP
sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_GET_EDITABLE ||
#endif
sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS) {
if(ext->btnm) { if(ext->btnm) {
ext->btnm->signal_cb(ext->btnm, sign, param); ext->btnm->signal_cb(ext->btnm, sign, param);
} }

View File

@ -171,6 +171,7 @@ void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask)
else { else {
lv_mem_free(mask->param); lv_mem_free(mask->param);
_lv_ll_remove(&ext->mask_ll, mask); _lv_ll_remove(&ext->mask_ll, mask);
lv_mem_free(mask);
} }
lv_obj_invalidate(objmask); lv_obj_invalidate(objmask);

View File

@ -859,6 +859,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
refr_ext_draw_pad(page); refr_ext_draw_pad(page);
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param); uint32_t c = *((uint32_t *)param);
if(c == LV_KEY_DOWN) { if(c == LV_KEY_DOWN) {
@ -883,10 +884,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
else else
lv_page_scroll_hor(page, lv_obj_get_width(page) / 4); lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
} }
#endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
return res; return res;

View File

@ -123,11 +123,16 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy)
} }
/*Copy an existing roller*/ /*Copy an existing roller*/
else { else {
lv_label_create(roller, get_label(copy));
lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy); lv_roller_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
lv_roller_set_options(roller, lv_roller_get_options(copy), copy_ext->mode); lv_roller_set_options(roller, lv_roller_get_options(copy), copy_ext->mode);
ext->auto_fit = copy_ext->auto_fit; ext->auto_fit = copy_ext->auto_fit;
lv_obj_t * scrl = lv_page_get_scrollable(roller); lv_obj_t * scrl = lv_page_get_scrollable(roller);
lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal); lv_obj_set_signal_cb(scrl, lv_roller_scrl_signal);
lv_style_list_copy(&ext->style_sel, &copy_ext->style_sel);
lv_obj_refresh_style(roller, LV_STYLE_PROP_ALL);
} }
LV_LOG_INFO("roller created"); LV_LOG_INFO("roller created");
@ -574,13 +579,16 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
/* Include the ancient signal function */ /* Include the ancient signal function */
if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/ if(sign != LV_SIGNAL_CONTROL) { /*Don't let the page to scroll on keys*/
#if LV_USE_GROUP
res = ancestor_signal(roller, sign, param); res = ancestor_signal(roller, sign, param);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
#endif
} }
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
LV_UNUSED(ext);
if(sign == LV_SIGNAL_STYLE_CHG) { if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_t * label = get_label(roller); lv_obj_t * label = get_label(roller);
@ -640,6 +648,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
#endif #endif
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) {
if(ext->sel_opt_id + 1 < ext->option_cnt) { if(ext->sel_opt_id + 1 < ext->option_cnt) {
@ -656,6 +665,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
ext->sel_opt_id_ori = ori_id; ext->sel_opt_id_ori = ori_id;
} }
} }
#endif
} }
else if(sign == LV_SIGNAL_CLEANUP) { else if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(roller, LV_ROLLER_PART_SELECTED); lv_obj_clean_style_list(roller, LV_ROLLER_PART_SELECTED);

View File

@ -407,6 +407,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) { if(c == LV_KEY_RIGHT || c == LV_KEY_UP) {
@ -419,13 +420,16 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL); res = lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }
#endif
} }
else if(sign == LV_SIGNAL_CLEANUP) { else if(sign == LV_SIGNAL_CLEANUP) {
lv_obj_clean_style_list(slider, LV_SLIDER_PART_KNOB); lv_obj_clean_style_list(slider, LV_SLIDER_PART_KNOB);
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
return res; return res;

View File

@ -390,8 +390,10 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
/* Include the ancient signal function */ /* Include the ancient signal function */
if(sign != LV_SIGNAL_CONTROL) { if(sign != LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
res = ancestor_signal(spinbox, sign, param); res = ancestor_signal(spinbox, sign, param);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
#endif
} }
if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);
@ -464,6 +466,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
} }
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
@ -488,6 +491,7 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
else { else {
lv_textarea_add_char(spinbox, c); lv_textarea_add_char(spinbox, c);
} }
#endif
} }
return res; return res;

View File

@ -296,12 +296,14 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
char c = *((char *)param); char c = *((char *)param);
if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON); if(c == LV_KEY_RIGHT || c == LV_KEY_UP) lv_switch_on(sw, LV_ANIM_ON);
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON); else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) lv_switch_off(sw, LV_ANIM_ON);
res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL); res = lv_event_send(sw, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
#endif
} }
else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB); lv_style_int_t knob_left = lv_obj_get_style_pad_left(sw, LV_SWITCH_PART_KNOB);
@ -320,8 +322,10 @@ static lv_res_t lv_switch_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
sw->ext_draw_pad = LV_MATH_MAX(sw->ext_draw_pad, knob_size); sw->ext_draw_pad = LV_MATH_MAX(sw->ext_draw_pad, knob_size);
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = false; /*The ancestor slider is editable the switch is not*/ *editable = false; /*The ancestor slider is editable the switch is not*/
#endif
} }
return res; return res;

View File

@ -645,12 +645,17 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
#endif #endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL || sign == LV_SIGNAL_PRESSED || if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS ||
sign == LV_SIGNAL_RELEASED) { #if LV_USE_GROUP
sign == LV_SIGNAL_CONTROL ||
#endif
sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED) {
/* The button matrix is not in a group (the tab view is in it) but it should handle the /* The button matrix is not in a group (the tab view is in it) but it should handle the
* group signals. So propagate the related signals to the button matrix manually*/ * group signals. So propagate the related signals to the button matrix manually*/

View File

@ -221,7 +221,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy)
/** /**
* Insert a character to the current cursor position. * Insert a character to the current cursor position.
* To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')`
* @param ta pointer to a text area object * @param ta pointer to a text area object
* @param c a character (e.g. 'a') * @param c a character (e.g. 'a')
*/ */
@ -231,9 +231,17 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta); lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
uint32_t letter_buf[2]; const char *letter_buf;
letter_buf[0] = c;
letter_buf[1] = '\0'; uint32_t u32_buf[2];
u32_buf[0] = c;
u32_buf[1] = 0;
letter_buf = (char*)&u32_buf;
#if LV_BIG_ENDIAN_SYSTEM
if (c != 0) while (*letter_buf == 0) ++letter_buf;
#endif
ta_insert_replace = NULL; ta_insert_replace = NULL;
lv_event_send(ta, LV_EVENT_INSERT, letter_buf); lv_event_send(ta, LV_EVENT_INSERT, letter_buf);
@ -241,7 +249,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
if(ta_insert_replace[0] == '\0') return; /*Drop this text*/ if(ta_insert_replace[0] == '\0') return; /*Drop this text*/
/*Add the replaced text directly it's different from the original*/ /*Add the replaced text directly it's different from the original*/
if(strcmp(ta_insert_replace, (char *)letter_buf)) { if(strcmp(ta_insert_replace, letter_buf)) {
lv_textarea_add_text(ta, ta_insert_replace); lv_textarea_add_text(ta, ta_insert_replace);
return; return;
} }
@ -272,7 +280,7 @@ void lv_textarea_add_char(lv_obj_t * ta, uint32_t c)
if(txt[0] == '\0') lv_obj_invalidate(ta); if(txt[0] == '\0') lv_obj_invalidate(ta);
} }
lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/ lv_label_ins_text(ext->label, ext->cursor.pos, letter_buf); /*Insert the character*/
lv_textarea_clear_selection(ta); /*Clear selection*/ lv_textarea_clear_selection(ta); /*Clear selection*/
if(ext->pwd_mode != 0) { if(ext->pwd_mode != 0) {
@ -1466,6 +1474,7 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param
} }
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/ uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
if(c == LV_KEY_RIGHT) if(c == LV_KEY_RIGHT)
lv_textarea_cursor_right(ta); lv_textarea_cursor_right(ta);
@ -1486,10 +1495,13 @@ static lv_res_t lv_textarea_signal(lv_obj_t * ta, lv_signal_t sign, void * param
else { else {
lv_textarea_add_char(ta, c); lv_textarea_add_char(ta, c);
} }
#endif
} }
else if(sign == LV_SIGNAL_GET_EDITABLE) { else if(sign == LV_SIGNAL_GET_EDITABLE) {
#if LV_USE_GROUP
bool * editable = (bool *)param; bool * editable = (bool *)param;
*editable = true; *editable = true;
#endif
} }
else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST || else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||
sign == LV_SIGNAL_RELEASED) { sign == LV_SIGNAL_RELEASED) {

View File

@ -106,7 +106,7 @@ lv_obj_t * lv_textarea_create(lv_obj_t * par, const lv_obj_t * copy);
/** /**
* Insert a character to the current cursor position. * Insert a character to the current cursor position.
* To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')` * To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')`
* @param ta pointer to a text area object * @param ta pointer to a text area object
* @param c a character (e.g. 'a') * @param c a character (e.g. 'a')
*/ */

View File

@ -645,8 +645,10 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param)
ext->title_txt = NULL; ext->title_txt = NULL;
} }
else if(sign == LV_SIGNAL_CONTROL) { else if(sign == LV_SIGNAL_CONTROL) {
#if LV_USE_GROUP
/*Forward all the control signals to the page*/ /*Forward all the control signals to the page*/
ext->page->signal_cb(ext->page, sign, param); ext->page->signal_cb(ext->page, sign, param);
#endif
} }
return res; return res;

39
src/lvgl.h Normal file
View File

@ -0,0 +1,39 @@
/**
* @file lvgl.h
* This file exists only to be compatible with Arduino's library structure
*/
#ifndef LVGL_SRC_H
#define LVGL_SRC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lvgl.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#ifdef __cplusplus
}
#endif
#endif /*LVGL_SRC_H*/