Initial commit.

This commit is contained in:
imi415 2022-07-31 21:27:47 +08:00
parent 976df88c63
commit 11773e1cbf
Signed by: imi415
GPG Key ID: 17F01E106F9F5E0A
15 changed files with 251501 additions and 8 deletions

View File

@ -9,6 +9,15 @@ set(TARGET_SOURCES
"src/hal.c"
"src/mouse_cursor_icon.c"
"src/ui/ui_demo.c"
"src/assets/fonts/noto_sans_24.c"
"src/assets/fonts/noto_sans_96.c"
"src/assets/fonts/noto_sans_150.c"
"src/assets/fonts/noto_sans_240.c"
"src/assets/fonts/weather_icon_24.c"
"src/assets/fonts/weather_icon_96.c"
"src/assets/fonts/weather_icon_150.c"
"src/assets/fonts/weather_icon_240.c"
)
set(TARGET_INCLUDES
@ -23,6 +32,8 @@ set(TARGET_LIBRARIES
"lvgl_demos"
)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(LV_CONF_PATH "${CMAKE_CURRENT_LIST_DIR}/include/lv_conf.h")
add_subdirectory(lib/lvgl)

View File

@ -270,7 +270,7 @@
/*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 1
#if LV_USE_PERF_MONITOR
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_TOP_RIGHT
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#endif
/*1: Show the used memory and the memory fragmentation
@ -393,13 +393,13 @@
/*Enable handling large font and/or fonts with a lot of characters.
*The limit depends on the font size, font face and bpp.
*Compiler error will be triggered if a font needs it.*/
#define LV_FONT_FMT_TXT_LARGE 0
#define LV_FONT_FMT_TXT_LARGE 1
/*Enables/disables support for compressed fonts.*/
#define LV_USE_FONT_COMPRESSED 0
#define LV_USE_FONT_COMPRESSED 1
/*Enable subpixel rendering*/
#define LV_USE_FONT_SUBPX 0
#define LV_USE_FONT_SUBPX 1
#if LV_USE_FONT_SUBPX
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/

1
lib/SDL Submodule

@ -0,0 +1 @@
Subproject commit 7f42fb54adbb9fa86bbdbd09abac628ccfaef648

1
lib/lvgl Submodule

@ -0,0 +1 @@
Subproject commit 9024b72b4853e1e7ac29a42e54b7a10d3c4f3b20

94
src/assets/fonts/LICENSE Normal file
View File

@ -0,0 +1,94 @@
Copyright (c) 2021, Erik Flowers (twitter.com/erik_flowers),
Copyright 2018 The Noto Project Authors (github.com/googlei18n/noto-fonts)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,8 +36,7 @@ void hal_init(void) {
lv_disp_t *disp = lv_disp_drv_register(&disp_drv);
lv_theme_t *th = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
lv_theme_t *th = lv_theme_mono_init(disp, false, &lv_font_montserrat_12);
lv_disp_set_theme(disp, th);
lv_group_t *g = lv_group_create();

View File

@ -2,9 +2,242 @@
#include "lvgl.h"
#include "lv_demos.h"
LV_FONT_DECLARE(noto_sans_24)
LV_FONT_DECLARE(noto_sans_96)
LV_FONT_DECLARE(noto_sans_150)
LV_FONT_DECLARE(noto_sans_240)
LV_FONT_DECLARE(weather_icon_24)
LV_FONT_DECLARE(weather_icon_96)
LV_FONT_DECLARE(weather_icon_150)
LV_FONT_DECLARE(weather_icon_240)
static lv_style_t s_epd_style;
static lv_theme_t s_epd_theme;
static void app_ui_theme_apply(lv_theme_t *th, lv_obj_t *obj) {
lv_obj_add_style(obj, &s_epd_style, 0);
}
void ui_demo_init(void) {
lv_demo_music();
lv_obj_t *screen_cond;
/* Top bar */
lv_obj_t *container_topbar;
lv_obj_t *label_sunrise;
lv_obj_t *label_sunrise_time;
lv_obj_t *label_sunset;
lv_obj_t *label_sunset_time;
lv_obj_t *label_uvi;
lv_obj_t *label_uvi_value;
lv_obj_t *label_updated;
lv_obj_t *label_updated_time;
/* Seperation line */
lv_obj_t *line_topbar;
/* Middle display */
lv_obj_t *container_main;
lv_obj_t *label_wxicon;
lv_obj_t *label_temperature;
lv_obj_t *label_temperature_hi;
lv_obj_t *label_temperature_lo;
lv_obj_t *label_temperature_real;
lv_obj_t *label_temperature_real_desc;
lv_obj_t *label_temperature_unit;
lv_obj_t *label_temperature_hi_unit;
lv_obj_t *label_temperature_lo_unit;
lv_obj_t *label_temperature_real_unit;
lv_obj_t *label_humidity;
lv_obj_t *label_humidity_unit;
lv_obj_t *label_wind_level;
lv_obj_t *label_wind_speed;
lv_obj_t *label_wind_direction;
lv_point_t points_line_topbar[] = {{0, 37}, {959, 37}};
lv_style_init(&s_epd_style);
lv_style_set_pad_all(&s_epd_style, 0);
lv_style_set_radius(&s_epd_style, 0);
lv_style_set_border_width(&s_epd_style, 1);
lv_theme_set_apply_cb(&s_epd_theme, app_ui_theme_apply);
lv_disp_set_theme(NULL, &s_epd_theme);
screen_cond = lv_obj_create(NULL);
container_topbar = lv_obj_create(screen_cond);
label_sunrise = lv_label_create(container_topbar);
label_sunrise_time = lv_label_create(container_topbar);
label_sunset = lv_label_create(container_topbar);
label_sunset_time = lv_label_create(container_topbar);
label_uvi = lv_label_create(container_topbar);
label_uvi_value = lv_label_create(container_topbar);
label_updated = lv_label_create(container_topbar);
label_updated_time = lv_label_create(container_topbar);
line_topbar = lv_line_create(screen_cond);
container_main = lv_obj_create(screen_cond);
label_wxicon = lv_label_create(container_main);
label_temperature = lv_label_create(container_main);
label_temperature_hi = lv_label_create(container_main);
label_temperature_lo = lv_label_create(container_main);
label_temperature_real = lv_label_create(container_main);
label_temperature_real_desc = lv_label_create(container_main);
label_temperature_unit = lv_label_create(container_main);
label_temperature_hi_unit = lv_label_create(container_main);
label_temperature_lo_unit = lv_label_create(container_main);
label_temperature_real_unit = lv_label_create(container_main);
label_humidity = lv_label_create(container_main);
label_humidity_unit = lv_label_create(container_main);
label_wind_level = lv_label_create(container_main);
label_wind_direction = lv_label_create(container_main);
label_wind_speed = lv_label_create(container_main);
/* Top bar parts */
lv_obj_set_style_text_font(label_sunrise, &weather_icon_24, 0U);
lv_obj_set_style_text_font(label_sunset, &weather_icon_24, 0U);
lv_obj_set_style_text_font(label_uvi, &weather_icon_24, 0U);
lv_obj_set_style_text_font(label_updated, &weather_icon_24, 0U);
lv_obj_set_style_text_font(label_sunrise_time, &noto_sans_24, 0U);
lv_obj_set_style_text_font(label_sunset_time, &noto_sans_24, 0U);
lv_obj_set_style_text_font(label_uvi_value, &noto_sans_24, 0U);
lv_obj_set_style_text_font(label_updated_time, &noto_sans_24, 0U);
lv_label_set_text(label_sunrise, "\U0000F051");
lv_label_set_text(label_sunset, "\U0000F052");
lv_label_set_text(label_uvi, "\U0000F00D");
lv_label_set_text(label_updated, "\U0000F04C");
lv_label_set_text(label_sunrise_time, "--:--");
lv_label_set_text(label_sunset_time, "--:--");
lv_label_set_text(label_uvi_value, "-");
lv_label_set_text(label_updated_time, "----/--/-- --:--");
lv_obj_set_size(container_topbar, 960, 36);
lv_obj_set_width(label_sunrise, 32);
lv_obj_set_width(label_sunset, 32);
lv_obj_set_width(label_uvi, 32);
lv_obj_set_width(label_updated, 32);
lv_obj_set_style_text_align(label_sunrise, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_sunset, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_uvi, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_updated, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_sunrise_time, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_text_align(label_sunset_time, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_text_align(label_uvi_value, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_text_align(label_updated_time, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_align(container_topbar, LV_ALIGN_TOP_LEFT, 0, 0);
lv_obj_align(label_sunrise, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_align(label_sunset, LV_ALIGN_LEFT_MID, 160, 0);
lv_obj_align(label_uvi, LV_ALIGN_LEFT_MID, 320, 0);
lv_obj_align(label_updated, LV_ALIGN_LEFT_MID, 480, 0);
lv_obj_align(label_sunrise_time, LV_ALIGN_LEFT_MID, 40, 3);
lv_obj_align(label_sunset_time, LV_ALIGN_LEFT_MID, 200, 3);
lv_obj_align(label_uvi_value, LV_ALIGN_LEFT_MID, 360, 3);
lv_obj_align(label_updated_time, LV_ALIGN_LEFT_MID, 520, 3);
lv_line_set_points(line_topbar, points_line_topbar, 2);
lv_obj_set_style_line_width(line_topbar, 1, 0);
/* Main parts */
lv_obj_set_style_text_font(label_wxicon, &weather_icon_150, 0);
lv_obj_set_style_text_font(label_temperature_unit, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_humidity_unit, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_temperature_hi_unit, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_temperature_lo_unit, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_temperature_real_unit, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_wind_direction, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_wind_level, &weather_icon_96, 0);
lv_obj_set_style_text_font(label_temperature, &noto_sans_150, 0);
lv_obj_set_style_text_font(label_temperature_hi, &noto_sans_96, 0);
lv_obj_set_style_text_font(label_temperature_lo, &noto_sans_96, 0);
lv_obj_set_style_text_font(label_temperature_real, &noto_sans_96, 0);
lv_obj_set_style_text_font(label_temperature_real_desc, &noto_sans_24, 0);
lv_obj_set_style_text_font(label_humidity, &noto_sans_96, 0);
lv_obj_set_style_text_font(label_wind_speed, &noto_sans_96, 0);
lv_label_set_text(label_wxicon, "\U0000F07B");
lv_label_set_text(label_temperature_unit, "\U0000F03C");
lv_label_set_text(label_temperature_hi_unit, "\U0000F058");
lv_label_set_text(label_temperature_lo_unit, "\U0000F044");
lv_label_set_text(label_temperature_real_unit, "\U0000F03C");
lv_label_set_text(label_humidity_unit, "\U0000F07A");
lv_label_set_text(label_wind_direction, "\U0000F0B1");
lv_label_set_text(label_wind_level, "\U0000F0BA");
lv_label_set_text(label_temperature, "--");
lv_label_set_text(label_temperature_hi, "--");
lv_label_set_text(label_temperature_lo, "--");
lv_label_set_text(label_temperature_real, "--");
lv_label_set_text(label_temperature_real_desc, "Real\nFeel");
lv_label_set_text(label_humidity, "---");
lv_label_set_text(label_wind_speed, "----");
lv_obj_set_size(container_main, 960, 370);
lv_obj_set_size(label_temperature_unit, 96, 96);
lv_obj_set_size(label_temperature_hi_unit, 96, 96);
lv_obj_set_size(label_temperature_lo_unit, 96, 96);
lv_obj_set_size(label_temperature_real_unit, 96, 96);
lv_obj_set_size(label_humidity_unit, 96, 150);
lv_obj_set_size(label_wind_direction, 96, 96);
lv_obj_set_size(label_wind_level, 96, 96);
lv_obj_set_width(label_wxicon, 200);
lv_obj_set_width(label_temperature, 200);
lv_obj_set_width(label_temperature_hi, 150);
lv_obj_set_width(label_temperature_lo, 150);
lv_obj_set_width(label_temperature_real, 150);
lv_obj_set_width(label_temperature_real_desc, 50);
lv_obj_set_width(label_humidity, 200);
lv_obj_set_width(label_wind_speed, 150);
lv_obj_set_style_text_align(label_wxicon, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_temperature, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_text_align(label_temperature_hi, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_text_align(label_temperature_lo, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_text_align(label_temperature_real, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_text_align(label_temperature_real_desc, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_text_align(label_temperature_unit, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_temperature_hi_unit, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_temperature_lo_unit, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_temperature_real_unit, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_humidity, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_set_style_text_align(label_humidity_unit, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_wind_direction, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_wind_level, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_align(label_wind_speed, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_align(container_main, LV_ALIGN_TOP_LEFT, 0, 38);
lv_obj_align(label_wxicon, LV_ALIGN_LEFT_MID, 0, 0);
lv_obj_align(label_temperature_unit, LV_ALIGN_TOP_LEFT, 400, -20);
lv_obj_align(label_temperature_hi_unit, LV_ALIGN_TOP_LEFT, 200, 115);
lv_obj_align(label_temperature_lo_unit, LV_ALIGN_TOP_LEFT, 200, 235);
lv_obj_align(label_temperature, LV_ALIGN_TOP_LEFT, 200, 0);
lv_obj_align(label_temperature_hi, LV_ALIGN_TOP_LEFT, 250, 150);
lv_obj_align(label_temperature_lo, LV_ALIGN_TOP_LEFT, 250, 250);
lv_obj_align(label_temperature_real, LV_ALIGN_TOP_LEFT, 650, 130);
lv_obj_align(label_temperature_real_desc, LV_ALIGN_TOP_LEFT, 585, 165);
lv_obj_align(label_humidity, LV_ALIGN_TOP_LEFT, 600, 10);
lv_obj_align(label_humidity_unit, LV_ALIGN_TOP_LEFT, 800, -20);
lv_obj_align(label_temperature_real_unit, LV_ALIGN_TOP_LEFT, 800, 120);
lv_obj_align(label_wind_direction, LV_ALIGN_TOP_LEFT, 560, 230);
lv_obj_align(label_wind_speed, LV_ALIGN_TOP_LEFT, 650, 250);
lv_obj_align(label_wind_level, LV_ALIGN_TOP_LEFT, 815, 240);
lv_scr_load(screen_cond);
}