Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add calendar app #187

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ __pycache__
/test

/.vscode

.cache/
app/.cache/

7 changes: 6 additions & 1 deletion app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ menu "ZSWatch"
prompt "Activate the application 'Battery'"
default y

config APPLICATIONS_USE_CALENDAR
bool
prompt "Activate the application 'Calendar'"
default y

config APPLICATIONS_USE_COMPASS
bool
prompt "Activate the application 'Compass'"
Expand Down Expand Up @@ -230,4 +235,4 @@ menu "ZSWatch"
rsource "src/applications/trivia/Kconfig"
rsource "src/applications/ppt_remote/Kconfig"
endmenu
endmenu
endmenu
6 changes: 3 additions & 3 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CONFIG_LV_USE_LOG=n
CONFIG_LV_USE_BAR=y
CONFIG_LV_USE_CANVAS=n
CONFIG_LV_USE_CHECKBOX=n
CONFIG_LV_USE_DROPDOWN=n
CONFIG_LV_USE_DROPDOWN=y
CONFIG_LV_USE_LINE=y
CONFIG_LV_USE_ROLLER=n
CONFIG_LV_USE_SLIDER=y
Expand All @@ -71,7 +71,7 @@ CONFIG_LV_USE_TABLE=n
CONFIG_LV_USE_TEXTAREA=n
CONFIG_LV_USE_FLEX=y
CONFIG_LV_USE_ANIMIMG=y
CONFIG_LV_USE_CALENDAR=n
CONFIG_LV_USE_CALENDAR=y
CONFIG_LV_USE_CHART=y
CONFIG_LV_USE_COLORWHEEL=n
CONFIG_LV_USE_IMGBTN=y
Expand Down Expand Up @@ -207,4 +207,4 @@ CONFIG_BMI270_PLUS_TRIGGER_GLOBAL_THREAD=y
#CONFIG_BME680=n
#CONFIG_EXTERNAL_USE_BOSCH_BSEC=y

CONFIG_RESET_ON_FATAL_ERROR=y
CONFIG_RESET_ON_FATAL_ERROR=y
4 changes: 4 additions & 0 deletions app/src/applications/calendar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if(CONFIG_APPLICATIONS_USE_CALENDAR)
FILE(GLOB app_sources *.c)
target_sources(app PRIVATE ${app_sources})
endif()
36 changes: 36 additions & 0 deletions app/src/applications/calendar/calendar_app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <zephyr/kernel.h>
#include <zephyr/init.h>

#include "calendar_ui.h"
#include "managers/zsw_app_manager.h"

static void calendar_app_start(lv_obj_t *root, lv_group_t *group);
static void calendar_app_stop(void);

LV_IMG_DECLARE(calendar);

static application_t app = {
.name = "Calendar",
.icon = &calendar,
.start_func = calendar_app_start,
.stop_func = calendar_app_stop
};

static void calendar_app_start(lv_obj_t *root, lv_group_t *group)
{
calendar_ui_show(root);
}

static void calendar_app_stop(void)
{
calendar_ui_remove();
}

static int calendar_app_add(void)
{
zsw_app_manager_add_application(&app);

return 0;
}

SYS_INIT(calendar_app_add, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
33 changes: 33 additions & 0 deletions app/src/applications/calendar/calendar_ui.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "calendar_ui.h"
#include "app_version.h"
#include <zsw_clock.h>

static lv_obj_t *root_page = NULL;

void calendar_ui_show(lv_obj_t *root)
{
assert(root_page == NULL);

root_page = lv_obj_create(root);
lv_obj_set_style_border_width(root_page, 0, LV_PART_MAIN);
lv_obj_set_size(root_page, LV_PCT(100), LV_PCT(100));
lv_obj_set_scrollbar_mode(root_page, LV_SCROLLBAR_MODE_OFF);

lv_obj_t * calendar = lv_calendar_create(root_page);
lv_obj_set_size(calendar, 180, 180);

struct tm *time = zsw_clock_get_time();
int year = time->tm_year + 1900;
int month = time->tm_mon + 1;
lv_calendar_set_showed_date(calendar, year, month);
lv_calendar_set_today_date(calendar, year, month, time->tm_mday);

lv_calendar_header_arrow_create(calendar);
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 0);
}

void calendar_ui_remove(void)
{
lv_obj_del(root_page);
root_page = NULL;
}
8 changes: 8 additions & 0 deletions app/src/applications/calendar/calendar_ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <inttypes.h>
#include <lvgl.h>

void calendar_ui_show(lv_obj_t *root);

void calendar_ui_remove(void);
174 changes: 174 additions & 0 deletions app/src/images/calendar.c

Large diffs are not rendered by default.

Loading