Add some cool battery icons
This commit is contained in:
@@ -8,6 +8,8 @@ idf_component_register(
|
|||||||
"themes.cpp" "widget_top_bar.cpp" "screen.cpp" "screen_onboarding.cpp"
|
"themes.cpp" "widget_top_bar.cpp" "screen.cpp" "screen_onboarding.cpp"
|
||||||
"modal_progress.cpp" "modal.cpp" "modal_confirm.cpp" "screen_settings.cpp"
|
"modal_progress.cpp" "modal.cpp" "modal_confirm.cpp" "screen_settings.cpp"
|
||||||
"splash.c" "font_fusion.c" "font_symbols.c"
|
"splash.c" "font_fusion.c" "font_symbols.c"
|
||||||
|
"icons/battery_empty.c" "icons/battery_full.c" "icons/battery_20.c"
|
||||||
|
"icons/battery_40.c" "icons/battery_60.c" "icons/battery_80.c"
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
REQUIRES "drivers" "lvgl" "tinyfsm" "events" "system_fsm" "database" "esp_timer" "battery")
|
REQUIRES "drivers" "lvgl" "tinyfsm" "events" "system_fsm" "database" "esp_timer" "battery")
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
|
target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS})
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_20
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_20
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_20 uint8_t battery_20_map[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
|
||||||
|
0xfd, 0xfe, 0xfd, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0xc1, 0x38, 0xff, /*Color of index 2*/
|
||||||
|
0x01, 0xbe, 0x37, 0xff, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x55, 0x00, 0x55,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_20 = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_20_map,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_40
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_40
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_40 uint8_t battery_40_map[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
|
||||||
|
0xfd, 0xfe, 0xfd, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0xc1, 0x38, 0xff, /*Color of index 2*/
|
||||||
|
0x01, 0xbe, 0x37, 0xff, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x55, 0x00, 0x55,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_40 = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_40_map,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_60
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_60
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_60 uint8_t battery_60_map[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
|
||||||
|
0xfd, 0xfe, 0xfd, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0xc1, 0x38, 0xff, /*Color of index 2*/
|
||||||
|
0x01, 0xbe, 0x37, 0xff, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x55, 0x00, 0x55,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_60 = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_60_map,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_80
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_80
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_80 uint8_t battery_80_map[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
|
||||||
|
0xfd, 0xfe, 0xfd, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0xc1, 0x38, 0xff, /*Color of index 2*/
|
||||||
|
0x01, 0xbe, 0x37, 0xff, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x55, 0x00, 0x55,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0x55, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_80 = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_80_map,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_EMPTY
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_EMPTY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_EMPTY uint8_t battery_empty_map[] = {
|
||||||
|
0xfd, 0xfd, 0xfd, 0xff, /*Color of index 0*/
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0x2c, 0xfa, 0xff, /*Color of index 2*/
|
||||||
|
0x00, 0x00, 0x00, 0x00, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x00, 0x55, 0x00,
|
||||||
|
0x01, 0x55, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0x00, 0x40,
|
||||||
|
0x01, 0xaa, 0x40,
|
||||||
|
0x01, 0xaa, 0x40,
|
||||||
|
0x01, 0x55, 0x40,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_empty = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_empty_map,
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#ifdef __has_include
|
||||||
|
#if __has_include("lvgl.h")
|
||||||
|
#ifndef LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#define LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
|
||||||
|
#include "lvgl.h"
|
||||||
|
#else
|
||||||
|
#include "lvgl/lvgl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#define LV_ATTRIBUTE_MEM_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LV_ATTRIBUTE_IMG_BATTERY_FULL
|
||||||
|
#define LV_ATTRIBUTE_IMG_BATTERY_FULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_BATTERY_FULL uint8_t battery_full_map[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xff, /*Color of index 0*/
|
||||||
|
0xfd, 0xfe, 0xfd, 0xff, /*Color of index 1*/
|
||||||
|
0x26, 0xc1, 0x38, 0xff, /*Color of index 2*/
|
||||||
|
0x01, 0xbe, 0x37, 0xff, /*Color of index 3*/
|
||||||
|
|
||||||
|
0x55, 0x00, 0x55,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xaa, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0xff, 0x15,
|
||||||
|
0x54, 0x00, 0x15,
|
||||||
|
};
|
||||||
|
|
||||||
|
const lv_img_dsc_t battery_full = {
|
||||||
|
.header.cf = LV_IMG_CF_INDEXED_2BIT,
|
||||||
|
.header.always_zero = 0,
|
||||||
|
.header.reserved = 0,
|
||||||
|
.header.w = 12,
|
||||||
|
.header.h = 12,
|
||||||
|
.data_size = 52,
|
||||||
|
.data = battery_full_map,
|
||||||
|
};
|
||||||
+23
-14
@@ -16,6 +16,13 @@
|
|||||||
#include "widgets/lv_img.h"
|
#include "widgets/lv_img.h"
|
||||||
#include "widgets/lv_label.h"
|
#include "widgets/lv_label.h"
|
||||||
|
|
||||||
|
LV_IMG_DECLARE(battery_empty);
|
||||||
|
LV_IMG_DECLARE(battery_20);
|
||||||
|
LV_IMG_DECLARE(battery_40);
|
||||||
|
LV_IMG_DECLARE(battery_60);
|
||||||
|
LV_IMG_DECLARE(battery_80);
|
||||||
|
LV_IMG_DECLARE(battery_full);
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
@@ -48,8 +55,7 @@ TopBar::TopBar(lv_obj_t* parent, const Configuration& config) {
|
|||||||
playback_ = lv_label_create(container_);
|
playback_ = lv_label_create(container_);
|
||||||
lv_label_set_text(playback_, "");
|
lv_label_set_text(playback_, "");
|
||||||
|
|
||||||
battery_ = lv_label_create(container_);
|
battery_ = lv_img_create(container_);
|
||||||
lv_label_set_text(battery_, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto TopBar::Update(const State& state) -> void {
|
auto TopBar::Update(const State& state) -> void {
|
||||||
@@ -65,18 +71,21 @@ auto TopBar::Update(const State& state) -> void {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_label_set_text(battery_, std::to_string(state.battery_percent).c_str());
|
if (state.battery_percent >= 95) {
|
||||||
// if (state.battery_percent >= 95) {
|
lv_img_set_src(battery_, &battery_full);
|
||||||
// lv_label_set_text(battery_, "100");
|
} else if (state.battery_percent >= 75) {
|
||||||
// } else if (state.battery_percent >= 70) {
|
lv_img_set_src(battery_, &battery_80);
|
||||||
// lv_label_set_text(battery_, ">70");
|
lv_label_set_text(battery_, ">70");
|
||||||
// } else if (state.battery_percent >= 40) {
|
} else if (state.battery_percent >= 55) {
|
||||||
// lv_label_set_text(battery_, ">40");
|
lv_img_set_src(battery_, &battery_60);
|
||||||
// } else if (state.battery_percent >= 10) {
|
lv_label_set_text(battery_, ">40");
|
||||||
// lv_label_set_text(battery_, ">10");
|
} else if (state.battery_percent >= 35) {
|
||||||
// } else {
|
lv_img_set_src(battery_, &battery_40);
|
||||||
// lv_label_set_text(battery_, "0");
|
} else if (state.battery_percent >= 15) {
|
||||||
// }
|
lv_img_set_src(battery_, &battery_20);
|
||||||
|
} else {
|
||||||
|
lv_img_set_src(battery_, &battery_empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 617 B |
Binary file not shown.
|
After Width: | Height: | Size: 617 B |
Binary file not shown.
|
After Width: | Height: | Size: 618 B |
Binary file not shown.
|
After Width: | Height: | Size: 622 B |
Binary file not shown.
|
After Width: | Height: | Size: 614 B |
Binary file not shown.
|
After Width: | Height: | Size: 618 B |
Reference in New Issue
Block a user