BigW Consortium Gitlab

Commit 791a5a7e by Kiss-Vamosi Gabor

Adding the already exting code

parents
# lvgl
The core of the LittleV Graphical Library
MIT licence
Copyright (c) 2016 Gábor Kiss-Vámosi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/**
* @file lv_conf.h
*
*/
#ifndef LV_CONF_H
#define LV_CONF_H
#if 0 /*Remove this to enable the content*/
/*=================
Basic setting
*=================*/
/* 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)
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE (LV_HOR_RES * LV_DOWNSCALE * 20)
/* Anti-aliasing with downscaling everything
* 1: disabled
* 2: 2x anti-alias -> half size
* 4: 4x anti-alias -> quarter size */
#define LV_DOWNSCALE 1
#define LV_UPSCALE_FONT 0 /*Scale up fonts to compensate LV_DOWNSCALE*/
#define LV_UPSCALE_MAP 0 /*Scale up maps (e.g. images) elements to compensate LV_DOWNSCALE*/
#define LV_UPSCALE_SYTLE 0 /*Scale up default styles to compensate LV_DOWNSCALE*/
/*=====================
Graphical settings
*=====================*/
/* Horizontal and vertical resolution of the library.
* Screen resolution multiplied by LV_DOWN_SCALE*/
#define LV_HOR_RES (480 * LV_DOWNSCALE)
#define LV_VER_RES (320 * LV_DOWNSCALE)
/* Buffered rendering: >= LV_DOWNSCALE * LV_HOR_RES or 0 to disable buffering*/
#define LV_VDB_SIZE (LV_HOR_RES * LV_DOWNSCALE * 20)
/* Anti-aliasing with downscaling everything
* 1: disabled
* 2: 2x anti-alias -> half size
* 4: 4x anti-alias -> quarter size */
#define LV_DOWNSCALE 2
#define LV_UPSCALE_FONT 0 /*Scale up fonts to compensate LV_DOWNSCALE*/
#define LV_UPSCALE_MAP 0 /*Scale up maps (e.g. images) elements to compensate LV_DOWNSCALE*/
#define LV_UPSCALE_SYTLE 1 /*Scale up default styles to compensate LV_DOWNSCALE*/
#define LV_REFR_PERIOD 50 /*Screen refresh period in milliseconds*/
#define LV_INV_FIFO_SIZE 32 /*The average number 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*/
#define LV_DISPI_DRAG_LIMIT 10 /*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*/
/*Coordinates*/
#define LV_CORD_TYPE int16_t /*Coordinate type*/
#define LV_CORD_MAX (32000)
#define LV_CORD_MIN (-32000)
/*Fonts and texts*/
#define USE_FONT_DEJAVU_14 1
#define USE_FONT_DEJAVU_20 1
#define USE_FONT_DEJAVU_30 1
#define USE_FONT_DEJAVU_40 1
#define USE_FONT_DEJAVU_60 1
#define USE_FONT_DEJAVU_80 1
#define LV_FONT_DEFAULT FONT_DEJAVU_40 /*Always set a default font*/
#define LV_TXT_BREAK_CHARS " ,.;-" /*Can break texts on these chars*/
/*lv_obj (base object) settings*/
#define LV_OBJ_FREE_P 1 /*Enable the free pointer attribute*/
#define LV_OBJ_DEF_SCR_COLOR COLOR_WHITE /*Default screen color*/
/*==================
* LV OBJ X USAGE
* ================*/
#define USE_LV_RECT 1
#define USE_LV_LABEL 1
#define USE_LV_BTN 1
#define USE_LV_LINE 1
#define USE_LV_IMG 1
#if USE_LV_IMG != 0
#define LV_IMG_COLOR_TRANSP COLOR_LIME
#endif /*USE_LV_IMG*/
#define USE_LV_PAGE 1
#define USE_LV_LIST 1
/*==================
* LV APP SETTINGS
* =================*/
/*==================
* LV APP X USAGE
* ================*/
#endif /*Remove this to enable the content*/
#endif
/**
* @file lv_draw_img.h
*
*/
#ifndef LV_DRAW_H
#define LV_DRAW_H
/*********************
* INCLUDES
*********************/
#include "../lv_objx/lv_btn.h"
#include "../lv_objx/lv_rect.h"
#include "../lv_objx/lv_line.h"
#include "../lv_objx/lv_img.h"
#include "../lv_objx/lv_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_draw_rect(const area_t * cords_p, const area_t * mask_p,
const lv_rects_t * rects_p, opa_t opa);
void lv_draw_label(const area_t * cords_p,const area_t * mask_p,
const lv_labels_t * labels_p, opa_t opa, const char * txt);
void lv_draw_line(const point_t * p1, const point_t * p2, const area_t * mask_p,
const lv_lines_t * lines_p, opa_t opa);
void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
const lv_imgs_t * imgs_p, opa_t opa, const char * fn, const color_t * map_p);
/**********************
* MACROS
**********************/
#endif
/**
* @file lv_draw_rbasic.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_draw_rbasic.h"
#include "lv_conf.h"
#include "hal/disp/disp.h"
#include "../lv_misc/font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Fill an area on the display
* @param cords_p coordinates of the area to fill
* @param mask_p fill only o this mask
* @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)
{
area_t masked_area;
bool union_ok = true;
if(mask_p != NULL) {
union_ok = 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);
}
if(union_ok != false){
disp_area(DISP_ID_ALL, masked_area.x1, masked_area.y1, masked_area.x2, masked_area.y2);
disp_fill(DISP_ID_ALL, color);
}
}
/**
* Draw a letter to the display
* @param pos_p left-top coordinate of the latter
* @param mask_p the letter will be drawn only on this area
* @param font_p pointer to font
* @param letter a letter to draw
* @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)
{
uint8_t w = font_get_width(font_p, letter);
const uint8_t * bitmap_p = font_get_bitmap(font_p, letter);
uint8_t col, col_sub, row;
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)) {
lv_rpx(pos_p->x + col, pos_p->y + row, mask_p, color);
}
if(col_sub == 0) {
bitmap_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 ++;
}
}
/**
* 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 opa opacity of the map (ignored, only for compatibility with lv_vmap)
* @param transp true: enable transparency of LV_IMG_COLOR_TRANSP color pixels
*/
void lv_rmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp)
{
area_t masked_a;
bool union_ok;
union_ok = 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);
map_p+= (masked_a.y1 - cords_p->y1) * map_width;
map_p += masked_a.x1 - cords_p->x1;
if(transp == false) {
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_rpx(masked_a.x1 + col, masked_a.y1 + row, mask_p, map_p[col]);
}
map_p += map_width;
}
}else {
color_t transp_color = LV_IMG_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 ++) {
if(map_p[col].full != transp_color.full) {
lv_rpx(masked_a.x1 + col, masked_a.y1 + row, mask_p, map_p[col]);
}
}
map_p += map_width;
}
}
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Put a pixel to the display
* @param x x coordinate of the pixel
* @param y y coordinate of the pixel
* @param mask_p the pixel will be drawn on this area
* @param color color of the pixel
*/
static void lv_rpx(cord_t x, cord_t y, const area_t * mask_p, color_t color)
{
area_t area;
area.x1 = x;
area.y1 = y;
area.x2 = x;
area.y2 = y;
lv_rfill(&area, mask_p, color, OPA_COVER);
}
/**
* @file lv_draw_rbasic..h
*
*/
#ifndef LV_DRAW_RBASIC_H
#define LV_DRAW_RBASIC_H
/*********************
* INCLUDES
*********************/
#include "misc/others/color.h"
#include "../lv_misc/2d.h"
#include "../lv_misc/font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_rfill(const area_t * area_p, const area_t * mask_p,
color_t color, opa_t opa);
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_rmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp);
/**********************
* MACROS
**********************/
#endif
/**
* @file lv_draw_vbasic.h
*
*/
#ifndef LV_DRAW_VBASIC_H
#define LV_DRAW_VBASIC_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if LV_VDB_SIZE != 0
#include "misc/others/color.h"
#include "../lv_misc/2d.h"
#include "../lv_misc/font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_vfill(const area_t * cords_p, const area_t * mask_p,
color_t color, opa_t opa);
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_vmap(const area_t * cords_p, const area_t * mask_p,
const color_t * map_p, opa_t opa, bool transp);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file 2d.c
*
*/
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/2d.h>
#include "misc/math/math_base.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 area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2)
{
area_p->x1 = x1;
area_p->y1 = y1;
area_p->x2 = x2;
area_p->y2 = y2;
}
/**
* Return with area of an area (x * y)
* @param area_p pointer to an area
* @return size of area
*/
uint32_t area_get_size(const 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 area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
{
/* Get the smaller area from 'a1_p' and 'a2_p' */
res_p->x1 = max(a1_p->x1, a2_p->x1);
res_p->y1 = max(a1_p->y1, a2_p->y1);
res_p->x2 = min(a1_p->x2, a2_p->x2);
res_p->y2 = 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 area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p)
{
a_res_p->x1 = min(a1_p->x1, a2_p->x1);
a_res_p->y1 = min(a1_p->y1, a2_p->y1);
a_res_p->x2 = max(a1_p->x2, a2_p->x2);
a_res_p->y2 = 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 area_is_point_on(const area_t * a_p, const 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 area_is_on(const area_t * a1_p, const area_t * a2_p)
{
/*Two area are on each other if... */
point_t p;
/*a2 left-top corner is on a1*/
p.x = a2_p->x1;
p.y = a2_p->y1;
if(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(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(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(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 on aholder_p
* @param aholder pointer to an area which could involve ain_p
* @return
*/
bool area_is_in(const area_t * ain_p, const 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
**********************/
/**
* @file 2d.h
*
*/
#ifndef _2D_H
#define _2D_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef LV_CORD_TYPE cord_t;
typedef struct
{
cord_t x;
cord_t y;
}point_t;
typedef struct
{
cord_t x1;
cord_t y1;
cord_t x2;
cord_t y2;
}area_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
static void inline area_cpy(area_t * dest, const area_t * src)
{
memcpy(dest, src, sizeof(area_t));
}
static inline cord_t area_get_width(const area_t * area_p)
{
return area_p->x2 - area_p->x1 + 1;
}
static inline cord_t area_get_height(const area_t * area_p)
{
return area_p->y2 - area_p->y1 + 1;
}
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
uint32_t area_get_size(const area_t * area_p);
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p);
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p);
bool area_is_point_on(const area_t * a_p, const point_t * p_p);
bool area_is_on(const area_t * a1_p, const area_t * a2_p);
bool area_is_in(const area_t * a_in, const area_t * a_holder);
/**********************
* MACROS
**********************/
#endif
/**
* @file 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 <lvgl/lv_misc/2d.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 circ_init(point_t * c, cord_t * tmp, cord_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 circ_cont(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 circ_next(point_t * c, cord_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
**********************/
/**
* @file circ.h
*
*/
#ifndef CIRC_H
#define CIRC_H
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/2d.h>
#include <stddef.h>
/*********************
* DEFINES
*********************/
#define CIRC_OCT1_X(p) (p.x)
#define CIRC_OCT1_Y(p) (p.y)
#define CIRC_OCT2_X(p) (p.y)
#define CIRC_OCT2_Y(p) (p.x)
#define CIRC_OCT3_X(p) (-p.y)
#define CIRC_OCT3_Y(p) (p.x)
#define CIRC_OCT4_X(p) (-p.x)
#define CIRC_OCT4_Y(p) (p.y)
#define CIRC_OCT5_X(p) (-p.x)
#define CIRC_OCT5_Y(p) (-p.y)
#define CIRC_OCT6_X(p) (-p.y)
#define CIRC_OCT6_Y(p) (-p.x)
#define CIRC_OCT7_X(p) (p.y)
#define CIRC_OCT7_Y(p) (-p.x)
#define CIRC_OCT8_X(p) (p.x)
#define CIRC_OCT8_Y(p) (-p.y)
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void circ_init(point_t * c, cord_t * tmp, cord_t radius);
bool circ_cont(point_t * c);
void circ_next(point_t * c, cord_t * tmp);
/**********************
* MACROS
**********************/
#endif
/**
* @file font.c
*
*/
/*********************
* INCLUDES
*********************/
#include <stddef.h>
#include "font.h"
#include "fonts/dejavu_14.h"
#include "fonts/dejavu_20.h"
#include "fonts/dejavu_30.h"
#include "fonts/dejavu_40.h"
#include "fonts/dejavu_60.h"
#include "fonts/dejavu_80.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Get the font from its id
* @param font_id: the id of a font (an element of font_types_t enum)
* @return pointer to a font descriptor
*/
const font_t * font_get(font_types_t font_id)
{
const font_t * font_p = NULL;
switch(font_id)
{
#if USE_FONT_DEJAVU_14 != 0
case FONT_DEJAVU_14:
font_p = dejavu_14_get_dsc();
break;
#endif
#if USE_FONT_DEJAVU_20 != 0
case FONT_DEJAVU_20:
font_p = dejavu_20_get_dsc();
break;
#endif
#if USE_FONT_DEJAVU_30 != 0
case FONT_DEJAVU_30:
font_p = dejavu_30_get_dsc();
break;
#endif
#if USE_FONT_DEJAVU_40 != 0
case FONT_DEJAVU_40:
font_p = dejavu_40_get_dsc();
break;
#endif
#if USE_FONT_DEJAVU_60 != 0
case FONT_DEJAVU_60:
font_p = dejavu_60_get_dsc();
break;
#endif
#if USE_FONT_DEJAVU_80 != 0
case FONT_DEJAVU_80:
font_p = dejavu_80_get_dsc();
break;
#endif
default:
font_p = NULL;
}
return font_p;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* @file font.h
*
*/
#ifndef FONT_H
#define FONT_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#include <stdint.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum
{
#if USE_FONT_DEJAVU_14
FONT_DEJAVU_14,
#endif
#if USE_FONT_DEJAVU_20
FONT_DEJAVU_20,
#endif
#if USE_FONT_DEJAVU_30
FONT_DEJAVU_30,
#endif
#if USE_FONT_DEJAVU_40
FONT_DEJAVU_40,
#endif
#if USE_FONT_DEJAVU_60
FONT_DEJAVU_60,
#endif
#if USE_FONT_DEJAVU_80
FONT_DEJAVU_80,
#endif
FONT_TYPE_NUM,
}font_types_t;
typedef struct
{
uint8_t letter_cnt;
uint8_t start_ascii;
uint8_t width_byte;
uint8_t height_row;
uint8_t fixed_width;
const uint8_t * width_bit_a;
const uint8_t * bitmaps_a;
}font_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
const font_t * font_get(font_types_t letter);
/**********************
* MACROS
**********************/
/**
* 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
*/
static inline const uint8_t * font_get_bitmap(const font_t * font_p, uint8_t letter)
{
uint32_t index = (letter - font_p->start_ascii) * font_p->height_row * font_p->width_byte;
return &font_p->bitmaps_a[index];
}
/**
* Get the height of a font
* @param font_p pointer to a font
* @return the height of a font
*/
static inline uint8_t font_get_height(const font_t * font_p)
{
#if LV_DOWNSCALE > 1 && LV_UPSCALE_FONT != 0
return font_p->height_row * LV_DOWNSCALE;
#else
return font_p->height_row;
#endif
}
/**
* 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
*/
static inline uint8_t font_get_width(const font_t * font_p, uint8_t letter)
{
if(letter < font_p->start_ascii) return 0;
letter -= font_p->start_ascii;
uint8_t w = 0;
if(letter < font_p->letter_cnt) {
w = font_p->fixed_width != 0 ? font_p->fixed_width :
font_p->width_bit_a[letter];
}
#if LV_DOWNSCALE > 1 && LV_UPSCALE_FONT != 0
return w * LV_DOWNSCALE;
#else
return w;
#endif
}
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_14_H
#define DEJAVU_14_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_DEJAVU_14 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_14_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_20_H
#define DEJAVU_20_H
/*Use ISO8859-1 encoding in the IDE*/
#include "misc_conf.h"
#if USE_FONT_DEJAVU_20 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_20_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_30_H
#define DEJAVU_30_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_DEJAVU_30 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_30_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_40_H
#define DEJAVU_40_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_DEJAVU_40 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_40_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_60_H
#define DEJAVU_60_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_DEJAVU_60 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_60_get_dsc(void);
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DEJAVU_80_H
#define DEJAVU_80_H
/*Use ISO8859-1 encoding in the IDE*/
#include "lv_conf.h"
#if USE_FONT_DEJAVU_80 != 0
#include <stdint.h>
#include "../font.h"
const font_t * dejavu_80_get_dsc(void);
#endif
#endif
/**
* @file font.c
*
*/
/*********************
* INCLUDES
*********************/
#include "text.h"
/*********************
* DEFINES
*********************/
#define TXT_NO_BREAK_FOUND UINT16_MAX
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool txt_is_break_char(char letter);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Get the next line of text. Check line length and break chars too.
* @param txt a '\0' terminated string
* @param font_p pointer to a font
* @param letter_space letter space
* @param max_l max line length
* @return the index of the first char of the new line
*/
uint16_t txt_get_next_line(const char * txt, const font_t * font_p,
uint16_t letter_space, cord_t max_l)
{
uint32_t i = 0;
cord_t act_l = 0;
uint16_t last_break = TXT_NO_BREAK_FOUND;
while(txt[i] != '\0') {
/*Check for new line chars*/
if(txt[i] == '\n' || txt[i] == '\r') {
/*Handle \n\r and \r\n as well*/
if(txt[i + 1] == '\n' || txt[i + 1] == '\r') {
i++;
}
return i+1; /*Return with the first letter of the next line*/
} else { /*Check the actual length*/
act_l += font_get_width(font_p, txt[i]);
/*If the txt is too long then finish, this is the line end*/
if(act_l >= max_l) {
/*If already a break character is found, then break there*/
if(last_break != TXT_NO_BREAK_FOUND) {
i = last_break;
}
while(txt[i] == ' ') i++;
return i;
}
/*If this char still can fit to this line then check if
* txt can be broken here later */
else if(txt_is_break_char(txt[i])) {
last_break = i;
last_break++;/*Go to the next char, the break char stays in this line*/
}
}
act_l += letter_space;
i++;
}
return i;
}
/**
* Give the length of a text with a given font
* @param txt a '\0' terminate string
* @param char_num number of characters in 'txt'
* @param font_p pointer to a font
* @param letter_space letter sapce
* @return length of a char_num long text
*/
cord_t txt_get_length(const char * txt, uint16_t char_num,
const font_t * font_p, uint16_t letter_space)
{
uint16_t i;
cord_t len = 0;
if(char_num != 0) {
for(i = 0; i < char_num; i++) {
len += font_get_width(font_p, txt[i]);
len += letter_space;
}
/*Trim closing spaces */
for(i = char_num - 1; i > 0; i--) {
if(txt[i] == ' ') {
len -= font_get_width(font_p, txt[i]);
len -= letter_space;
} else {
break;
}
}
/*Correct the last letter space,
* because thee is no letter space after the last char*/
len -= letter_space;
}
return len;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Test if char is break char or not (a text can broken here or not)
* @param letter a letter
* @return false: 'letter' is not break char
*/
static bool txt_is_break_char(char letter)
{
uint8_t i;
bool ret = false;
/*Compare the letter to TXT_BREAK_CHARS*/
for(i = 0; LV_TXT_BREAK_CHARS[i] != '\0'; i++) {
if(letter == LV_TXT_BREAK_CHARS[i]) {
ret = true; /*If match then it is break char*/
break;
}
}
return ret;
}
/**
* @file text.h
*
*/
#ifndef TEXT_H
#define TEXT_H
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/2d.h>
#include <stdbool.h>
#include "font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
uint16_t txt_get_next_line(const char * txt, const font_t * font_p, uint16_t letter_space, cord_t max_l);
cord_t txt_get_length(const char * txt, uint16_t char_num, const font_t * font_p, uint16_t letter_space);
/**********************
* MACROS
**********************/
#endif
/**
* @file lv_dispi.h
*
*/
#ifndef LV_DISPI_H
#define LV_DISPI_H
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
bool pressed;
point_t act_point;
point_t last_point;
point_t vect;
point_t vect_sum;
lv_obj_t* act_obj_dp;
lv_obj_t* last_obj_dp;
uint32_t press_time_stamp;
/*Flags*/
uint8_t drag_in_prog :1;
uint8_t long_press_sent :1;
}lv_dispi_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_dispi_init(void);
void lv_dispi_reset(void);
bool lv_dispi_is_dragging(lv_dispi_t * dispi_p);
void lv_dispi_get_point(lv_dispi_t * dispi_p, point_t * point_p);
void lv_dispi_get_vect(lv_dispi_t * dispi_p, point_t * point_p);
/**********************
* MACROS
**********************/
#endif
\ No newline at end of file
This diff is collapsed. Click to expand it.
/**
* @file lv_base_obj.h
*
*/
#ifndef LV_OBJ_H
#define LV_OBJ_H
/*********************
* INCLUDES
*********************/
#include <lvgl/lv_misc/2d.h>
#include <stddef.h>
#include <stdbool.h>
#include "misc/mem/dyn_mem.h"
#include "misc/mem/linked_list.h"
#include "misc/others/color.h"
/*********************
* DEFINES
*********************/
/*Error check of lv_conf.h*/
#if LV_HOR_RES == 0 || LV_VER_RES == 0
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
#endif
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2 && LV_DOWNSCALE != 4
#error "LV: LV_DOWNSCALE can be only 1, 2 or 4"
#endif
#if LV_VDB_SIZE == 0 && (LV_DOWNSCALE != 1 || LV_UPSCALE_MAP != 0 || LV_UPSCALE_FONT != 0 || LV_UPSCALE_STYLE != 0)
#error "LV: If LV_VDB_SIZE == 0 then LV_DOWNSCALE must be 1, LV_UPSCALE_MAP 0, LV_UPSCALE_FONT 0, LV_UPSCALE_STYLE 0"
#endif
/*New defines*/
#if LV_UPSCALE_SYTLE != 0
#define LV_STYLE_MULT LV_DOWNSCALE
#else
#define LV_STYLE_MULT 1
#endif
/**********************
* TYPEDEFS
**********************/
struct __LV_OBJ_T;
typedef enum
{
LV_DESIGN_DRAW,
LV_DESIGN_COVER_CHK,
}lv_design_mode_t;
typedef bool (* lv_design_f_t) (struct __LV_OBJ_T* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
typedef enum
{
LV_SIGNAL_CLEANUP,
LV_SIGNAL_PRESSED,
LV_SIGNAL_PRESS_LOST,
LV_SIGNAL_RELEASED,
LV_SIGNAL_LONG_PRESS,
LV_SIGNAL_DRAG_BEGIN,
LV_SIGNAL_DRAG_END,
LV_SIGNAL_CHILD_CHG,
LV_SIGNAL_CORD_CHG,
LV_SIGNAL_STYLE_CHG,
}lv_signal_t;
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T* obj_dp, lv_signal_t sign, void * param);
typedef struct __LV_OBJ_T
{
struct __LV_OBJ_T* par_dp;
ll_dsc_t child_ll;
area_t cords;
/*Basic appearance*/
opa_t opa;
/*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 drag_parent :1; /*1. Parent will be dragged instead*/
uint8_t style_iso :1; /*1: The object has got an own style*/
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 res :1;
uint8_t free_num; /*Application specific identifier (set it freely)*/
lv_signal_f_t signal_f;
lv_design_f_t design_f;
void * ext_dp; /*The object attributes can be extended here*/
void * style_p; /*Object specific style*/
#if LV_OBJ_FREE_P != 0
void * free_p; /*Application specific pointer (set it freely)*/
#endif
}lv_obj_t;
typedef enum
{
LV_ALIGN_CENTER = 0,
LV_ALIGN_IN_TOP_LEFT,
LV_ALIGN_IN_TOP_MID,
LV_ALIGN_IN_TOP_RIGHT,
LV_ALIGN_IN_BOTTOM_LEFT,
LV_ALIGN_IN_BOTTOM_MID,
LV_ALIGN_IN_BOTTOM_RIGHT,
LV_ALIGN_IN_LEFT_MID,
LV_ALIGN_IN_RIGHT_MID,
LV_ALIGN_OUT_TOP_LEFT,
LV_ALIGN_OUT_TOP_MID,
LV_ALIGN_OUT_TOP_RIGHT,
LV_ALIGN_OUT_BOTTOM_LEFT,
LV_ALIGN_OUT_BOTTOM_MID,
LV_ALIGN_OUT_BOTTOM_RIGHT,
LV_ALIGN_OUT_LEFT_TOP,
LV_ALIGN_OUT_LEFT_MID,
LV_ALIGN_OUT_LEFT_BOTTOM,
LV_ALIGN_OUT_RIGHT_TOP,
LV_ALIGN_OUT_RIGHT_MID,
LV_ALIGN_OUT_RIGHT_BOTTOM,
}lv_align_t;
typedef struct
{
color_t color;
uint8_t empty :1;
uint8_t auto_color :1;
}lv_objs_t;
typedef enum
{
LV_OBJS_DEF,
LV_OBJS_COLOR,
LV_OBJS_SCR,
LV_OBJS_EMPTY,
LV_OBJS_AUTOCOLOR,
}lv_objs_builtin_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_init(void);
void lv_obj_inv(lv_obj_t* obj_dp);
void lv_obj_refr_style(lv_obj_t* obj_dp);
void lv_style_refr_all(void * style_p);
/*Create and delete*/
lv_obj_t* lv_obj_create(lv_obj_t* parent_dp, lv_obj_t * copy_dp);
void lv_obj_del(lv_obj_t* obj_dp);
/*Virtual functions*/
bool lv_obj_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
/*SETTER FUNCTIONS*/
/*Parent/children set*/
void lv_obj_set_parent(lv_obj_t* obj_dp, lv_obj_t* parent_dp);
/*Coordinate set (set_cord_f will be called)*/
void lv_obj_set_pos(lv_obj_t* obj_dp, cord_t x, cord_t y);
void lv_obj_set_pos_us(lv_obj_t* obj_dp, cord_t x, cord_t y);
void lv_obj_set_x(lv_obj_t* obj_dp, cord_t x);
void lv_obj_set_x_us(lv_obj_t* obj_dp, cord_t x);
void lv_obj_set_y(lv_obj_t* obj_dp, cord_t y);
void lv_obj_set_y_us(lv_obj_t* obj_dp, cord_t y);
void lv_obj_set_size(lv_obj_t* obj_dp, cord_t w, cord_t h);
void lv_obj_set_size_us(lv_obj_t* obj_dp, cord_t w, cord_t h);
void lv_obj_set_width(lv_obj_t* obj_dp, cord_t w);
void lv_obj_set_width_us(lv_obj_t* obj_dp, cord_t w);
void lv_obj_set_height(lv_obj_t* obj_dp, cord_t h);
void lv_obj_set_height_us(lv_obj_t* obj_dp, cord_t h);
void lv_obj_align(lv_obj_t* obj_dp,lv_obj_t* base_dp, lv_align_t align, cord_t x_mod, cord_t y_mod);
void lv_obj_align_us(lv_obj_t* obj_dp,lv_obj_t* base_dp, lv_align_t align, cord_t x_mod, cord_t y_mod);
/*Appearance set*/
void lv_obj_set_hidden(lv_obj_t* obj_dp, bool hidden_en);
void lv_obj_set_opa(lv_obj_t* obj_dp, opa_t opa);
void lv_obj_set_opar(lv_obj_t* obj_dp, opa_t opa);
/*Attribute set*/
void lv_obj_set_click(lv_obj_t* obj_dp, bool click_en);
void lv_obj_set_top(lv_obj_t* obj_dp, bool click_en);
void lv_obj_set_drag(lv_obj_t* obj_dp, bool drag_en);
void lv_obj_set_drag_throw(lv_obj_t* obj_dp, bool dragthr_en);
void lv_obj_set_drag_parent(lv_obj_t* obj_dp, bool dragpar_en);
void lv_obj_set_signal_f(lv_obj_t* obj_dp, lv_signal_f_t fp);
void lv_obj_set_design_f(lv_obj_t* obj_dp, lv_design_f_t fp);
/*Other set*/
void * lv_obj_alloc_ext(lv_obj_t* obj_dp, uint16_t ext_size);
void lv_obj_set_style(lv_obj_t* obj_dp, void * style_p);
void * lv_obj_iso_style(lv_obj_t * obj_dp, uint32_t style_size);
void lv_obj_set_free_num(lv_obj_t* obj_dp, uint8_t free_num);
void lv_obj_set_free_p(lv_obj_t* obj_dp, void * free_p);
void lv_obj_merge_style(lv_obj_t* obj_dp);
/*GETTER FUNCTIONS*/
/*Screen get*/
lv_obj_t* lv_scr_act(void);
void lv_scr_load(lv_obj_t* scr_dp);
/*Parent/children get*/
lv_obj_t* lv_obj_get_scr(lv_obj_t* obj_dp);
lv_obj_t* lv_obj_get_parent(lv_obj_t* obj_dp);
lv_obj_t * lv_obj_get_child(lv_obj_t * obj_dp, lv_obj_t * child_dp);
/*Coordinate get*/
void lv_obj_get_cords(lv_obj_t* obj_dp, area_t * cords_p);
cord_t lv_obj_get_x(lv_obj_t* obj_dp);
cord_t lv_obj_get_y(lv_obj_t* obj_dp);
cord_t lv_obj_get_width(lv_obj_t* obj_dp);
cord_t lv_obj_get_height(lv_obj_t* obj_dp);
/*Appearance get*/
bool lv_obj_get_hidden(lv_obj_t* obj_dp);
opa_t lv_obj_get_opa(lv_obj_t* obj_dp);
/*Attribute get*/
bool lv_obj_get_click(lv_obj_t* obj_dp);
bool lv_obj_get_top(lv_obj_t* obj_dp);
bool lv_obj_get_drag(lv_obj_t* obj_dp);
bool lv_obj_get_drag_throw(lv_obj_t* obj_dp);
bool lv_obj_get_drag_parent(lv_obj_t* obj_dp);
/*Virtual functions get*/
lv_design_f_t lv_obj_get_design_f(lv_obj_t* obj_dp);
lv_signal_f_t lv_obj_get_signal_f(lv_obj_t* obj_dp);
/*Other get*/
void * lv_obj_get_ext(lv_obj_t* obj_dp);
void * lv_obj_get_style(lv_obj_t* obj_dp);
uint8_t lv_obj_get_free_num(lv_obj_t* obj_dp);
lv_objs_t * lv_objs_get(lv_objs_builtin_t style, lv_objs_t * copy_p);
/**********************
* MACROS
**********************/
#define LV_SA(obj_dp, style_type) ((style_type *) obj_dp->style_p)
#define LV_EA(obj_dp, obj_type) ((obj_type *) obj_dp->ext_dp)
#endif
/**
* @file lv_refr.h
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_obj.h"
#include <stdbool.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_refr_init(void);
void lv_inv_area(const area_t * area_p);
/**********************
* STATIC FUNCTIONS
**********************/
\ No newline at end of file
/**
* @file lv_vdb.c
*
*/
#include "../../lv_conf.h"
#if LV_VDB_SIZE != 0
#include "hal/disp/disp.h"
#include <stddef.h>
#include "lv_vdb.h"
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static lv_vdb_t vdb;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Get the vdb variable
* @return pointer to the vdb variable
*/
lv_vdb_t * lv_vdb_get(void)
{
return &vdb;
}
/**
* Flush the content of the vdb
*/
void lv_vdb_flush(void)
{
#if LV_DOWNSCALE < 2
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 , vdb.vdb_area.y1, vdb.vdb_area.x2, vdb.vdb_area.y2);
disp_map(DISP_ID_ALL, vdb.buf);
#elif LV_DOWNSCALE == 2
color_t row_buf[LV_HOR_RES / LV_DOWNSCALE];
color_t * row_buf_p;
cord_t x;
cord_t y;
cord_t w = area_get_width(&vdb.vdb_area);
cord_t i;
color_t * buf_p = vdb.buf;
for(y = vdb.vdb_area.y1 >> 1; y <= vdb.vdb_area.y2 >> 1; y ++) {
i = 0;
row_buf_p = row_buf;
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2, i += 2) {
row_buf_p->red = (buf_p[i].red +
buf_p[i + 1].red +
buf_p[i + w].red +
buf_p[i + w + 1].red) >> 2;
row_buf_p->green = (buf_p[i].green +
buf_p[i + 1].green +
buf_p[i + w].green +
buf_p[i + w + 1].green) >> 2;
row_buf_p->blue = (buf_p[i].blue +
buf_p[i + 1].blue +
buf_p[i + w].blue +
buf_p[i + w + 1].blue) >> 2;
row_buf_p++;
}
buf_p += LV_DOWNSCALE * w;
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 1, y, vdb.vdb_area.x2 >> 1, y);
disp_map(DISP_ID_ALL, row_buf);
}
#elif LV_DOWNSCALE == 4
color_t row_buf[LV_HOR_RES / LV_DOWNSCALE];
color_t * row_buf_p;
cord_t x;
cord_t y;
cord_t w = area_get_width(&vdb.vdb_area);
cord_t i;
color_t * buf_p = vdb.buf;
for(y = vdb.vdb_area.y1 >> 2; y <= vdb.vdb_area.y2 >> 2; y ++) {
i = 0;
row_buf_p = row_buf;
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 4, i += 4) {
row_buf_p->red = (buf_p[i].red + buf_p[i + 1].red +
buf_p[i + 2].red + buf_p[i + 3].red +
buf_p[i + w].red + buf_p[i + w + 1].red +
buf_p[i + w + 2].red + buf_p[i + w + 3].red +
buf_p[i + 2 * w].red + buf_p[i + 2 * w + 1].red +
buf_p[i + 2 * w + 2].red + buf_p[i + 2 * w + 3].red +
buf_p[i + 3 * w].red + buf_p[i + 3 * w + 1].red +
buf_p[i + 3 * w + 2].red + buf_p[i + 3 * w + 3].red) >>4 ;
row_buf_p->green = (buf_p[i].green + buf_p[i + 1].green +
buf_p[i + 2].green + buf_p[i + 3].green +
buf_p[i + w].green + buf_p[i + w + 1].green +
buf_p[i + w + 2].green + buf_p[i + w + 3].green +
buf_p[i + 2 * w].green + buf_p[i + 2 * w + 1].green +
buf_p[i + 2 * w + 2].green + buf_p[i + 2 * w + 3].green +
buf_p[i + 3 * w].green + buf_p[i + 3 * w + 1].green +
buf_p[i + 3 * w + 2].green + buf_p[i + 3 * w + 3].green) >>4 ;
row_buf_p->blue = (buf_p[i].blue + buf_p[i + 1].blue +
buf_p[i + 2].blue + buf_p[i + 3].blue +
buf_p[i + w].blue + buf_p[i + w + 1].blue +
buf_p[i + w + 2].blue + buf_p[i + w + 3].blue +
buf_p[i + 2 * w].blue + buf_p[i + 2 * w + 1].blue +
buf_p[i + 2 * w + 2].blue + buf_p[i + 2 * w + 3].blue +
buf_p[i + 3 * w].blue + buf_p[i + 3 * w + 1].blue +
buf_p[i + 3 * w + 2].blue + buf_p[i + 3 * w + 3].blue) >>4 ;
row_buf_p++;
}
buf_p += LV_DOWNSCALE * w;
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 2, y, vdb.vdb_area.x2 >> 2, y);
disp_map(DISP_ID_ALL, row_buf);
}
#else
#error "LV: Not supported LV_DOWNSCALE"
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif
/**
* @file lv_vdb.h
*
*/
#ifndef LV_VDB_H
#define LV_VDB_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if LV_VDB_SIZE != 0
#include "misc/others/color.h"
#include <lvgl/lv_misc/2d.h>
#include "../lv_misc/font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
area_t vdb_area;
color_t buf[LV_VDB_SIZE];
}lv_vdb_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_vdb_t * lv_vdb_get(void);
void lv_vdb_flush(void);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_btn.h
*
*/
#ifndef LV_BTN_H
#define LV_BTN_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_BTN != 0
#include "lv_rect.h"
#include "../lv_obj/lv_dispi.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum
{
LV_BTN_PR,
LV_BTN_REL,
LV_BTN_TGL_PR,
LV_BTN_TGL_REL,
LV_BTN_INA,
}lv_btn_state_t;
typedef struct
{
lv_rects_t rel;
lv_rects_t pr;
lv_rects_t tgl_rel;
lv_rects_t tgl_pr;
lv_rects_t ina;
}lv_btns_t;
typedef enum
{
LV_BTNS_DEF,
LV_BTNS_TRANSP,
LV_BTNS_BORDER,
}lv_btns_builtin_t;
typedef struct
{
bool (*pr_action)(lv_obj_t*, lv_dispi_t *);
bool (*rel_action)(lv_obj_t*, lv_dispi_t *);
bool (*lpr_action)(lv_obj_t*, lv_dispi_t *);
lv_btn_state_t state;
uint8_t tgl :1; /*1: Toggle enabled*/
uint8_t lpr_exec :1; /*1: long press action executed (Not for user)*/
}lv_btn_ext_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * c_dp);
bool lv_btn_signal(lv_obj_t * obj_dp, lv_signal_t sign, void * param);
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy_p);
void lv_btn_set_tgl(lv_obj_t* obj_dp, bool tgl);
void lv_btn_set_state(lv_obj_t* obj_dp, lv_btn_state_t state);
void lv_btn_set_pr_action(lv_obj_t* obi_p, bool (*pr_action)(lv_obj_t*, lv_dispi_t *));
void lv_btn_set_rel_action(lv_obj_t* obj_dp, bool (*rel_action)(lv_obj_t*, lv_dispi_t *));
void lv_btn_set_lpr_action(lv_obj_t* obj_dp, bool (*lpr_action)(lv_obj_t*, lv_dispi_t *));
bool lv_btn_get_tgl(lv_obj_t* obj_dp);
lv_btn_state_t lv_btn_get_state(lv_obj_t* obj_dp);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_img.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_IMG != 0
#include "lv_img.h"
#include "../lv_draw/lv_draw.h"
#include "misc/fs/fsint.h"
#include "misc/fs/ufs/ufs.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
/*-----------------
* Style definition
*-----------------*/
static lv_imgs_t lv_imgs_def = {.transp_en = 0};
static lv_imgs_t lv_imgs_transp = {.transp_en = 1};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create an image objects
* @param par_dp pointer to an object, it will be the parent of the new button
* @param copy_dp pointer to a rectangle object, if not NULL then the new object will be copied from it
* @return pointer to the created image
*/
lv_obj_t* lv_img_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
{
lv_obj_t* new_obj_dp = NULL;
/*Create a basic object*/
new_obj_dp = lv_obj_create(par_dp, NULL);
/*Extend the basic object to image object*/
lv_obj_alloc_ext(new_obj_dp, sizeof(lv_img_ext_t));
/*Init the new object*/
lv_obj_set_signal_f(new_obj_dp, lv_img_signal);
lv_obj_set_design_f(new_obj_dp, lv_img_design);
lv_img_ext_t * img_ext_dp = lv_obj_get_ext(new_obj_dp);
if(copy_dp == NULL) {
img_ext_dp->fn_dp = NULL;
img_ext_dp->w = lv_obj_get_width(new_obj_dp);
img_ext_dp->h = lv_obj_get_height(new_obj_dp);
if(par_dp != NULL) {
img_ext_dp->auto_size = 1;
} else {
img_ext_dp->auto_size = 0;
}
lv_obj_set_style(new_obj_dp, &lv_imgs_def);
} else {
img_ext_dp->auto_size = LV_EA(copy_dp, lv_img_ext_t)->auto_size;
lv_img_set_file(new_obj_dp, LV_EA(copy_dp, lv_img_ext_t)->fn_dp);
}
return new_obj_dp;
}
/**
* Signal function of the image
* @param obj_dp pointer to animage object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_img_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid = true;
/* Include the ancient signal function */
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
lv_img_ext_t * img_p = lv_obj_get_ext(obj_dp);
switch(sign) {
case LV_SIGNAL_CLEANUP:
dm_free(img_p->fn_dp);
break;
default:
break;
}
}
return valid;
}
/**
* Return with a pointer to built-in style and/or copy it to a variable
* @param style a style name from lv_imgs_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_imgs_t style
*/
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy_p)
{
lv_imgs_t * style_p;
switch(style) {
case LV_IMGS_DEF:
style_p = &lv_imgs_def;
break;
case LV_IMGS_TRANSP:
style_p = &lv_imgs_transp;
break;
default:
style_p = NULL;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_imgs_t));
else memcpy(copy_p, &lv_imgs_def, sizeof(lv_imgs_t));
}
return style_p;
}
/**
* Create a file to the RAMFS from a picture data
* @param fn file name of the new file (e.g. "pic1", will be avaliable at "U:/pic1")
* @param data_p pointer to a color map with lv_img_raw_header_t header
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
*/
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data_p)
{
const lv_img_raw_header_t * raw_p = (lv_img_raw_header_t *) data_p;
fs_res_t res;
res = ufs_create_const(fn, data_p, raw_p->w * raw_p->h * sizeof(color_t));
return res;
}
/*=====================
* Setter functions
*====================*/
/**
* Set a file to the image
* @param obj_dp pointer to an image object
* @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1").
*/
void lv_img_set_file(lv_obj_t* obj_dp, const char * fn)
{
lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp);
fs_file_t file;
fs_res_t res;
lv_img_raw_header_t header;
uint32_t rn;
res = fs_open(&file, fn, FS_MODE_RD);
if(res == FS_RES_OK) {
res = fs_read(&file, &header, sizeof(header), &rn);
}
if(res != FS_RES_OK || rn != sizeof(header)) {
/*Create a dummy header*/
header.w = lv_obj_get_width(obj_dp);
header.h = lv_obj_get_height(obj_dp);
}
fs_close(&file);
img_ext_p->w = header.w;
img_ext_p->h = header.h;
#if LV_UPSCALE_MAP != 0
img_ext_p->w *= LV_DOWNSCALE;
img_ext_p->h *= LV_DOWNSCALE;
#endif
if(fn != NULL) {
img_ext_p->fn_dp = dm_realloc(img_ext_p->fn_dp, strlen(fn) + 1);
strcpy(img_ext_p->fn_dp, fn);
} else {
img_ext_p->fn_dp = NULL;
}
if(lv_img_get_auto_size(obj_dp) != false) {
lv_obj_set_size(obj_dp, img_ext_p->w, img_ext_p->h);
}
}
/**
* Enable the auto size feature. If enabled the object size will be same as the picture size.
* @param obj_dp pointer to an image
* @param en true: auto size enable, false: auto size disable
*/
void lv_img_set_auto_size(lv_obj_t* obj_dp, bool en)
{
lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp);
img_ext_p->auto_size = (en == false ? 0 : 1);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the auto size enable attribute
* @param obj_dp pinter to an image
* @return true: auto size is enabled, false: auto size is disabled
*/
bool lv_img_get_auto_size(lv_obj_t* obj_dp)
{
lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp);
return img_ext_p->auto_size == 0 ? false : true;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the images
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
lv_imgs_t * imgs_p = lv_obj_get_style(obj_dp);
if(imgs_p->transp_en == 0) {
bool cover;
cover = area_is_in(mask_p, &obj_dp->cords);
return cover;
}
else return false;
}
lv_img_ext_t * img_ext_p = lv_obj_get_ext(obj_dp);
area_t cords;
lv_obj_get_cords(obj_dp, &cords);
opa_t opa = lv_obj_get_opa(obj_dp);
area_t cords_tmp;
cords_tmp.y1 = cords.y1;
cords_tmp.y2 = cords.y1 + img_ext_p->h - 1;
for(; cords_tmp.y1 < cords.y2; cords_tmp.y1 += img_ext_p->h, cords_tmp.y2 += img_ext_p->h) {
cords_tmp.x1 = cords.x1;
cords_tmp.x2 = cords.x1 + img_ext_p->w - 1;
for(; cords_tmp.x1 < cords.x2; cords_tmp.x1 += img_ext_p->w, cords_tmp.x2 += img_ext_p->w) {
lv_draw_img(&cords_tmp, mask_p, lv_obj_get_style(obj_dp),opa, img_ext_p->fn_dp, NULL);
}
}
return true;
}
#endif
/**
* @file lv_img.h
*
*/
#ifndef LV_IMG_H
#define LV_IMG_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_IMG != 0
#include "../lv_obj/lv_obj.h"
#include "misc/fs/fsint.h"
/*********************
* DEFINES
*********************/
#define LV_IMG_DECLARE(var_name) extern const color_int_t var_name[];
/**********************
* TYPEDEFS
**********************/
typedef struct
{
uint8_t transp_en :1;
}lv_imgs_t;
typedef struct
{
char* fn_dp;
cord_t w;
cord_t h;
uint8_t auto_size :1;
}lv_img_ext_t;
typedef enum
{
LV_IMGS_DEF,
LV_IMGS_TRANSP
}lv_imgs_builtin_t;
typedef struct
{
uint16_t w;
uint16_t h;
uint16_t res1;
uint16_t res2;
}lv_img_raw_header_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_img_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_img_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
void lv_img_set_file(lv_obj_t* obj_p, const char * fn);
fs_res_t lv_img_create_file(const char * fn, const color_int_t * data_p);
void lv_img_set_auto_size(lv_obj_t* obj_dp, bool mosaic_en);
bool lv_img_get_auto_size(lv_obj_t* obj_dp);
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy_p);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_rect.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_LABEL != 0
#include "misc/others/color.h"
#include "lv_label.h"
#include "../lv_obj/lv_obj.h"
#include "../lv_misc/text.h"
#include "../lv_draw/lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
static lv_labels_t lv_labels_def = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x10, 0x18, 0x20),
.letter_space = 3 * LV_STYLE_MULT, .line_space = 3 * LV_STYLE_MULT,
.mid = 1, .auto_break = 0
};
static lv_labels_t lv_labels_btn = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0xd0, 0xe0, 0xf0),
.letter_space = 2 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
.mid = 1, .auto_break = 0
};
static lv_labels_t lv_labels_title = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x10, 0x20, 0x30),
.letter_space = 4 * LV_STYLE_MULT, .line_space = 4 * LV_STYLE_MULT,
.mid = 0, .auto_break = 1
};
static lv_labels_t lv_labels_txt = {
.font = LV_FONT_DEFAULT, .color = COLOR_MAKE(0x16, 0x23, 0x34),
.letter_space = 1 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
.mid = 0, .auto_break = 1
};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create a label objects
* @param par_dp pointer to an object, it will be the parent of the new label
* @param copy_dp pointer to a button object, if not NULL then the new object will be copied from it
* @return pointer to the created button
*/
lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * ori_dp)
{
/*Create a basic object*/
lv_obj_t* new_obj = lv_obj_create(par_dp, ori_dp);
dm_assert(new_obj);
/*Extend the basic object to a label object*/
lv_obj_alloc_ext(new_obj, sizeof(lv_label_ext_t));
lv_label_ext_t * label_p = lv_obj_get_ext(new_obj);
label_p->txt = NULL;
lv_obj_set_design_f(new_obj, lv_label_design);
lv_obj_set_signal_f(new_obj, lv_label_signal);
/*Init the new label*/
if(ori_dp == NULL) {
lv_obj_set_opa(new_obj, OPA_COVER);
lv_obj_set_click(new_obj, false);
lv_obj_set_style(new_obj, &lv_labels_def);
lv_label_set_text(new_obj, "Text");
}
/*Copy 'ori_dp' if not NULL*/
else {
lv_obj_set_opa(new_obj, lv_obj_get_opa(ori_dp));
lv_obj_set_click(new_obj, lv_obj_get_click(ori_dp));
lv_obj_set_style(new_obj, lv_obj_get_style(ori_dp));
lv_label_set_text(new_obj, lv_label_get_text(ori_dp));
}
return new_obj;
}
/**
* Signal function of the label
* @param obj_dp pointer to a label object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_label_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
lv_label_ext_t * label_p = lv_obj_get_ext(obj_dp);
/*No signal handling*/
switch(sign) {
case LV_SIGNAL_CLEANUP:
dm_free(label_p->txt);
label_p->txt = NULL;
break;
case LV_SIGNAL_STYLE_CHG:
lv_label_set_text(obj_dp, lv_label_get_text(obj_dp));
break;
default:
break;
}
}
return valid;
}
/*=====================
* Setter functions
*====================*/
/**
* Set a new text for a label
* @param obj_dp pointer to a label object
* @param text '\0' terminated chacter string
*/
void lv_label_set_text(lv_obj_t * obj_dp, const char * text)
{
if(text == NULL) return;
lv_obj_inv(obj_dp);
lv_label_ext_t * label_p = lv_obj_get_ext(obj_dp);
uint32_t len = strlen(text) + 1;
if(label_p->txt != NULL && text != label_p->txt) {
dm_free(label_p->txt);
}
label_p->txt = dm_alloc(len);
strcpy(label_p->txt, text);
uint32_t line_start = 0;
uint32_t new_line_start = 0;
cord_t max_length = lv_obj_get_width(obj_dp);
lv_labels_t * labels_p = lv_obj_get_style(obj_dp);
const font_t * font_p = font_get(labels_p->font);
uint8_t letter_height = font_get_height(font_p);
cord_t new_height = 0;
cord_t longest_line = 0;
cord_t act_line_length;
/*If the auto-break is not enabled the set the max length to very big */
if(labels_p->auto_break == 0) {
max_length = LV_CORD_MAX;
}
/*Calc. the height and longest line*/;
while (text[line_start] != '\0')
{
new_line_start += txt_get_next_line(&text[line_start], font_p, labels_p->letter_space, max_length);
new_height += letter_height;
new_height += labels_p->line_space;
/*If no auto break then calc. the longest line */
if(labels_p->auto_break == false) {
act_line_length = txt_get_length(&text[line_start], new_line_start - line_start,
font_p, labels_p->letter_space);
if(act_line_length > longest_line) {
longest_line = act_line_length;
}
}
line_start = new_line_start;
}
/*Correction with the last line space*/
new_height -= labels_p->line_space;
lv_obj_set_height(obj_dp, new_height);
/*Refresh the length if no autobreak*/
if(labels_p->auto_break == 0) {
lv_obj_set_width(obj_dp, longest_line);
}
lv_obj_inv(obj_dp);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a label
* @param obj_dp pointer to a label object
* @return the text of the label
*/
const char * lv_label_get_text(lv_obj_t* obj_dp)
{
lv_label_ext_t * label_p = lv_obj_get_ext(obj_dp);
return label_p->txt;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_labels_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_labels_t style
*/
lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy_p)
{
lv_labels_t * style_p;
switch(style) {
case LV_LABELS_DEF:
style_p = &lv_labels_def;
break;
case LV_LABELS_BTN:
style_p = &lv_labels_btn;
break;
case LV_LABELS_TXT:
style_p = &lv_labels_txt;
break;
case LV_LABELS_TITLE:
style_p = &lv_labels_title;
break;
default:
style_p = NULL;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_labels_t));
else memcpy(copy_p, &lv_labels_def, sizeof(lv_labels_t));
}
return style_p;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the labels
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
/* A label never covers an area */
if(mode == LV_DESIGN_COVER_CHK) return false;
/*TEST: draw a background for the label*/
/*lv_vfill(&obj_dp->cords, mask_p, COLOR_LIME, OPA_COVER);*/
area_t cords;
lv_obj_get_cords(obj_dp, &cords);
opa_t opa= lv_obj_get_opa(obj_dp);
const char * txt = lv_label_get_text(obj_dp);
lv_draw_label(&cords, mask_p, lv_obj_get_style(obj_dp), opa, txt);
return true;
}
#endif
/**
* @file lv_rect.h
*
*/
#ifndef LV_LABEL_H
#define LV_LABEL_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_LABEL != 0
#include "../lv_obj/lv_obj.h"
#include "../lv_misc/font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
font_types_t font;
color_t color;
color_t bg_color;
uint16_t letter_space;
uint16_t line_space;
uint8_t mid :1;
uint8_t auto_break :1;
}lv_labels_t;
typedef struct
{
char* txt;
}lv_label_ext_t;
typedef enum
{
LV_LABELS_DEF,
LV_LABELS_BTN,
LV_LABELS_TXT,
LV_LABELS_TITLE,
}lv_labels_builtin_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * ori_dp);
bool lv_label_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy_p);
void lv_label_set_text(lv_obj_t* obj_dp, const char * text);
const char * lv_label_get_text(lv_obj_t* obj_dp);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_line.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_LINE != 0
#include "lv_line.h"
#include "../lv_draw/lv_draw_vbasic.h"
#include "../lv_draw/lv_draw_rbasic.h"
#include "../lv_draw/lv_draw.h"
#include <lvgl/lv_misc/2d.h>
#include <misc/math/math_base.h>
#include <misc/mem/dyn_mem.h>
#include <misc/others/color.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
static lv_lines_t lv_lines_def = { .width = 2 * LV_STYLE_MULT, .color = COLOR_RED,
.bg_color = COLOR_BLACK, .bg_opa = 0};
static lv_lines_t lv_lines_decor = { .width = 1 * LV_STYLE_MULT, .color = COLOR_GRAY,
.bg_color = COLOR_BLACK, .bg_opa = 0};
static lv_lines_t lv_lines_chart = { .width = 3 * LV_STYLE_MULT, .color = COLOR_BLUE,
.bg_color = COLOR_BLACK, .bg_opa = 0};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Create a line objects
* @param par_dp pointer to an object, it will be the parent of the new line
* @return pointer to the created line
*/
lv_obj_t* lv_line_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
{
/*Create a basic object*/
lv_obj_t* new_obj_dp = lv_obj_create(par_dp, copy_dp);
dm_assert(new_obj_dp);
/*Extend the basic object to rectangle object*/
lv_line_t *line_ext_p = lv_obj_alloc_ext(new_obj_dp, sizeof(lv_line_t));
lv_obj_set_design_f(new_obj_dp, lv_line_design);
lv_obj_set_signal_f(new_obj_dp, lv_line_signal);
/*Init the new rectangle*/
if(copy_dp == NULL) {
line_ext_p->point_num = 0;
line_ext_p->point_p = NULL;
line_ext_p->auto_size = 1;
line_ext_p->y_inv = 0;
lv_obj_set_style(new_obj_dp, &lv_lines_def);
}
/*Copy 'copy_p' is not NULL*/
else {
lv_line_set_auto_size(new_obj_dp,lv_line_get_auto_size(copy_dp));
lv_line_set_y_inv(new_obj_dp,lv_line_get_y_inv(copy_dp));
lv_line_set_auto_size(new_obj_dp,lv_line_get_auto_size(copy_dp));
lv_line_set_points(new_obj_dp, LV_EA(copy_dp, lv_line_t)->point_p,
LV_EA(copy_dp, lv_line_t)->point_num);
}
return new_obj_dp;
}
/**
* Signal function of the line
* @param obj_dp pointer to a line object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_line_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
switch(sign) {
default:
break;
}
}
return valid;
}
/*=====================
* Setter functions
*====================*/
/**
* Set an array of points. The line object will connect these points.
* @param obj_dp pointer to a line object
* @param point_a an array of points. Only the address is saved,
* so the array can be a local variable which will be destroyed
* @param point_num number of points in 'point_a'
*/
void lv_line_set_points(lv_obj_t* obj_dp, const point_t * point_a, uint16_t point_num)
{
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
line_p->point_p = point_a;
line_p->point_num = point_num;
if(point_num > 0 && line_p->auto_size != 0) {
uint16_t i;
cord_t xmax = LV_CORD_MIN;
cord_t ymax = LV_CORD_MIN;
for(i = 0; i < point_num; i++) {
xmax = max(point_a[i].x, xmax);
ymax = max(point_a[i].y, ymax);
}
lv_lines_t * lines_p = lv_obj_get_style(obj_dp);
lv_obj_set_size(obj_dp, xmax + lines_p->width, ymax + lines_p->width);
}
}
/**
* Enable (or disable) the auto-size option. The size of the object will fit to its points.
* (set width to x max and height to y max)
* @param obj_dp pointer to a line object
* @param en true: auto size is enabled, false: auto size is disabled
*/
void lv_line_set_auto_size(lv_obj_t * obj_dp, bool en)
{
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
line_p->auto_size = en == false ? 0 : 1;
/*Refresh the object*/
if(en != false) {
lv_line_set_points(obj_dp, line_p->point_p, line_p->point_num);
}
}
/**
* Enable (or disable) the y coordinate inversion.
* If enabled then y will be subtracted from the height of the object,
* therefore the y=0 coordinate will be on the bottom.
* @param obj_dp pointer to a line object
* @param en true: enable the y inversion, false:disable the y inversion
*/
void lv_line_set_y_inv(lv_obj_t * obj_dp, bool en)
{
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
line_p->y_inv = en == false ? 0 : 1;
lv_obj_inv(obj_dp);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the auto size attribute
* @param obj_dp pointer to a line object
* @return true: auto size is enabled, false: disabled
*/
bool lv_line_get_auto_size(lv_obj_t * obj_dp)
{
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
return line_p->auto_size == 0 ? false : true;
}
/**
* Get the y inversion attribute
* @param obj_dp pointer to a line object
* @return true: y inversion is enabled, false: disabled
*/
bool lv_line_get_y_inv(lv_obj_t * obj_dp)
{
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
return line_p->y_inv == 0 ? false : true;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_lines_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_lines_t style
*/
lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p)
{
lv_lines_t *style_p;
switch(style) {
case LV_LINES_DEF:
style_p = &lv_lines_def;
break;
case LV_LINES_DECOR:
style_p = &lv_lines_decor;
break;
case LV_LINES_CHART:
style_p = &lv_lines_chart;
break;
default:
style_p = NULL;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_lines_t));
else memcpy(copy_p, &lv_lines_def, sizeof(lv_lines_t));
}
return style_p;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the lines
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
/*A line never covers an area*/
if(mode == LV_DESIGN_COVER_CHK) return false;
lv_line_t * line_p = lv_obj_get_ext(obj_dp);
if(line_p->point_num == 0 || line_p->point_p == NULL) return false;
lv_lines_t * lines_p = lv_obj_get_style(obj_dp);
if(lines_p->bg_opa != 0) {
#if LV_VDB_SIZE != 0
lv_vfill(&obj_dp->cords, mask_p, lines_p->bg_color, lines_p->bg_opa * 255 / 100);
#else
lv_rfill(&obj_dp->cords, mask_p, lines_p->bg_color, lines_p->bg_opa * 255 / 100);
#endif
}
opa_t opa = lv_obj_get_opa(obj_dp);
area_t area;
lv_obj_get_cords(obj_dp, &area);
cord_t x_ofs = area.x1;
cord_t y_ofs = area.y1;
point_t p1;
point_t p2;
cord_t h = lv_obj_get_height(obj_dp);
uint16_t i;
/*Read all pints and draw the lines*/
for (i = 0; i < line_p->point_num - 1; i++) {
p1.x = line_p->point_p[i].x + x_ofs;
p2.x = line_p->point_p[i + 1].x + x_ofs;
if(line_p->y_inv == 0) {
p1.y = line_p->point_p[i].y + y_ofs;
p2.y = line_p->point_p[i + 1].y + y_ofs;
} else {
p1.y = h - line_p->point_p[i].y + y_ofs;
p2.y = h - line_p->point_p[i + 1].y + y_ofs;
}
lv_draw_line(&p1, &p2, mask_p, lines_p, opa);
}
return true;
}
#endif
/**
* @file lv_line.h
*
*/
#ifndef LV_LINE_H
#define LV_LINE_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_LINE != 0
#include "lvgl/lv_obj/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
const point_t * point_p;
uint16_t point_num;
uint8_t auto_size :1;
uint8_t y_inv :1;
}lv_line_t;
typedef struct
{
color_t color;
color_t bg_color;
uint16_t width;
opa_t bg_opa;
}lv_lines_t;
typedef enum
{
LV_LINES_DEF,
LV_LINES_DECOR,
LV_LINES_CHART,
}lv_lines_builtin_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t* lv_line_create(lv_obj_t * par_dp, lv_obj_t * copy_dp);
bool lv_line_signal(lv_obj_t * obj_dp, lv_signal_t sign, void * param);
lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p);
void lv_line_set_points(lv_obj_t * obj_dp, const point_t * point_a, uint16_t point_num);
void lv_line_set_auto_size(lv_obj_t * obj_dp, bool en);
void lv_line_set_y_inv(lv_obj_t * obj_dp, bool en);
bool lv_line_get_auto_size(lv_obj_t * obj_dp);
bool lv_line_get_y_inv(lv_obj_t * obj_dp);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_temp.c
*
*/
/*Search an replace: templ -> object short name (e.g. btn, label etc)
* TEMPLATE -> object normal name (e.g. button, label etc.)
*Modify USE_LV_TEMPL by hand */
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_TEMPL != 0
#include "lv_templ.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_templ_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
static lv_templs_t lv_templs_def =
{ /*Create a default style*/ };
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a TEMPLATE objects
* @param par_dp pointer to an object, it will be the parent of the new label
* @return pointer to the created label
*/
lv_obj_t* lv_templ_create(lv_obj_t* par_dp)
{
/*Create a basic object*/
lv_obj_t* new_obj = lv_obj_create(par_dp);
dm_assert(new_obj);
/*Init the new TEMPLATE object*/
return new_obj;
}
/**
* Signal function of the TEMPLATE
* @param obj_dp pointer to a TEMPLATE object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
switch(sign) {
default:
break;
}
}
return valid;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_rects_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_templs_t style
*/
lv_templs_t * lv_rects_get(lv_templs_builtin_t style, lv_templs_t * copy_p)
{
lv_rects_t *style_p;
switch(style) {
case LV_RECTS_DEF:
style_p = &lv_rects_def;
break;
case LV_RECTS_BORDER:
style_p = &lv_rects_border;
break;
case LV_RECTS_TRANSP:
style_p = &lv_rects_transp;
break;
default:
style_p = NULL;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_templs_t));
else memcpy(copy_p, &lv_rects_def, sizeof(lv_templs_t));
}
return style_p;
}
/*=====================
* Setter functions
*====================*/
/*=====================
* Getter functions
*====================*/
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the TEMPLATEs
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
if(mode == LV_DESIGN_COVER_CHK) {
/*Return false if the object is not covers the mask_p area*/
return false;
}
/*Draw the object*/
return true;
}
#endif
/**
* @file lv_rect.h
*
*/
#ifndef LV_RECT_H
#define LV_RECT_H
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_TEMPL != 0
#include "../lv_obj/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Style of TEMPLATE*/
typedef struct
{
}lv_templs_t;
/*Built-in styles of TEMPLATE*/
typedef enum
{
LV_RECTS_DEF,
LV_RECTS_TRANSP,
LV_RECTS_BORDER,
}lv_templs_builtin_t;
/*Data of TEMPLATE*/
typedef struct
{
}lv_templ_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t* lv_templ_create(lv_obj_t* par_dp);
bool lv_templ_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_page.h
*
*/
#ifndef LV_PAGE_H
#define LV_PAGE_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_PAGE != 0
#include "../lv_obj/lv_obj.h"
#include "lv_rect.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum
{
LV_PAGE_SB_MODE_OFF,
LV_PAGE_SB_MODE_ON,
LV_PAGE_SB_MODE_AUTO,
}lv_page_sb_mode_t;
typedef struct
{
lv_rects_t bg_rects;
lv_rects_t sb_rects;
cord_t sb_width;
cord_t margin_hor; /*Extra size between the parent and the page horizontally*/
cord_t margin_ver; /*Extra size between the parent and the page vertically*/
cord_t padding_hor; /*Extra size on page horizontally*/
cord_t padding_ver; /*Extra size on page vertically*/
lv_page_sb_mode_t sb_mode;
uint8_t sb_opa;
}lv_pages_t;
typedef struct
{
lv_obj_t* sbh_dp; /*Horizontal scrollbar*/
lv_obj_t* sbv_dp; /*Vertical scrollbar*/
}lv_page_t;
typedef enum
{
LV_PAGES_DEF,
LV_PAGES_PAPER,
LV_PAGES_TRANSP,
}lv_pages_builtin_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_page_create(lv_obj_t* par_dp, lv_obj_t * ori_dp);
void lv_page_glue_obj(lv_obj_t* page_p, bool en);
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * to_copy);
bool lv_page_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lv_rect.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_RECT != 0
#include "lv_rect.h"
#include "../lv_draw/lv_draw.h"
#include "../lv_draw/lv_draw_vbasic.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
/**********************
* STATIC VARIABLES
**********************/
static lv_rects_t lv_rects_def =
{ .mcolor = COLOR_MAKE(0x50, 0x70, 0x90), .gcolor = COLOR_MAKE(0x20, 0x40, 0x60),
.bcolor = COLOR_WHITE, .bwidth = 2 * LV_STYLE_MULT, .bopa = 50,
.round = 4 * LV_STYLE_MULT, .empty = 0 };
static lv_rects_t lv_rects_transp =
{ .bwidth = 0, .empty = 0 };
static lv_rects_t lv_rects_border =
{ .bcolor = COLOR_BLACK, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100,
.round = 4 * LV_STYLE_MULT, .empty = 1 };
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a label objects
* @param par_dp pointer to an object, it will be the parent of the new label
* @param copy_dp pointer to a rectangle object, if not NULL then the new object will be copied from it
* @return pointer to the created label
*/
lv_obj_t* lv_rect_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
{
/*Create a basic object*/
lv_obj_t* new_obj_dp = lv_obj_create(par_dp, copy_dp);
dm_assert(new_obj_dp);
lv_obj_set_design_f(new_obj_dp, lv_rect_design);
lv_obj_set_signal_f(new_obj_dp, lv_rect_signal);
/*Init the new rectangle*/
if(copy_dp == NULL) {
lv_obj_set_style(new_obj_dp, &lv_rects_def);
}
/*Copy 'copy_dp' if it is not NULL*/
else {
lv_obj_set_style(new_obj_dp, lv_obj_get_style(copy_dp));
}
return new_obj_dp;
}
/**
* Signal function of the rectangle
* @param obj_dp pointer to a rectangle object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(obj_dp, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
switch(sign) {
default:
break;
}
}
return valid;
}
/**
* Return with a pointer to a built-in style and/or copy it to a variable
* @param style a style name from lv_rects_builtin_t enum
* @param copy_p copy the style to this variable. (NULL if unused)
* @return pointer to an lv_rects_t style
*/
lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy_p)
{
lv_rects_t *style_p;
switch(style) {
case LV_RECTS_DEF:
style_p = &lv_rects_def;
break;
case LV_RECTS_BORDER:
style_p = &lv_rects_border;
break;
case LV_RECTS_TRANSP:
style_p = &lv_rects_transp;
break;
default:
style_p = NULL;
}
if(copy_p != NULL) {
if(style_p != NULL) memcpy(copy_p, style_p, sizeof(lv_rects_t));
else memcpy(copy_p, &lv_rects_def, sizeof(lv_rects_t));
}
return style_p;
}
/*=====================
* Setter functions
*====================*/
/*=====================
* Getter functions
*====================*/
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Handle the drawing related tasks of the labels
* @param obj_dp pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* @param return true/false, depends on 'mode'
*/
static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode)
{
/* Because of the radius it is not sure the area is covered*/
if(mode == LV_DESIGN_COVER_CHK) {
if(LV_SA(obj_dp, lv_rects_t)->empty != 0) return false;
uint16_t r = LV_SA(obj_dp, lv_rects_t)->round;
area_t area_tmp;
/*Check horizontally without radius*/
lv_obj_get_cords(obj_dp, &area_tmp);
area_tmp.x1 += r;
area_tmp.x2 -= r;
if(area_is_in(mask_p, &area_tmp) == true) return true;
/*Check vertically without radius*/
lv_obj_get_cords(obj_dp, &area_tmp);
area_tmp.y1 += r;
area_tmp.y2 -= r;
if(area_is_in(mask_p, &area_tmp) == true) return true;
return false;
}
opa_t opa = lv_obj_get_opa(obj_dp);
area_t area;
lv_obj_get_cords(obj_dp, &area);
/*Draw the rectangle*/
lv_draw_rect(&area, mask_p, lv_obj_get_style(obj_dp), opa);
return true;
}
#endif
/**
* @file lv_rect.h
*
*/
#ifndef LV_RECT_H
#define LV_RECT_H
/*********************
* INCLUDES
*********************/
#include "../../lv_conf.h"
#if USE_LV_RECT != 0
#include "../lv_obj/lv_obj.h"
#include "../lv_obj/lv_dispi.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
color_t mcolor;
color_t gcolor;
color_t bcolor;
uint16_t bwidth;
uint8_t bopa;
uint8_t empty :1;
uint16_t round;
}lv_rects_t;
typedef struct
{
}lv_rect_ext_t;
typedef enum
{
LV_RECTS_DEF,
LV_RECTS_TRANSP,
LV_RECTS_BORDER,
}lv_rects_builtin_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*Create function*/
lv_obj_t* lv_rect_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy_p);
/**********************
* MACROS
**********************/
#endif
#endif
/**
* @file lvgl.h
* Include all LittleV GL related headers
*/
#ifndef LV_GL_H
#define LV_GL_H
/*********************
* INCLUDES
*********************/
#include "lv_obj/lv_obj.h"
#include "lv_objx/lv_btn.h"
#include "lv_objx/lv_img.h"
#include "lv_objx/lv_label.h"
#include "lv_objx/lv_line.h"
#include "lv_objx/lv_page.h"
#include "lv_objx/lv_rect.h"
/*********************
* DEFINES
*********************/
#define LV_GL_VERSION_MAJOR 1
#define LV_GL_VERSION_MINOR 0
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment