Last active
November 19, 2019 22:26
-
-
Save stepansnigirev/a69131411da45a9cb7a1c9a534a5abbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the default display driver | |
import imp, sys | |
sys.path.append('https://raw.githubusercontent.com/littlevgl/lv_binding_micropython/master/lib') | |
import display_driver | |
import utime as time | |
# Display a button with a label | |
import lvgl as lv | |
lv.init() | |
scr = lv.obj() | |
# Load the screen | |
lv.scr_load(scr) | |
def event_handler(obj, event): | |
if event == lv.EVENT.CLICKED: | |
date = obj.get_pressed_date() | |
if date: | |
obj.set_today_date(date) | |
calendar = lv.calendar(lv.scr_act()) | |
calendar.set_size(230, 230) | |
calendar.align(None, lv.ALIGN.CENTER, 0, 0) | |
calendar.set_event_cb(event_handler) | |
# Set the today | |
today = lv.calendar_date_t() | |
today.year = 2018 | |
today.month = 10 | |
today.day = 23 | |
calendar.set_today_date(today) | |
calendar.set_showed_date(today) | |
# Highlight some days | |
highlihted_days = [lv.calendar_date_t() for i in range(3)] | |
highlihted_days[0].year = 2018 | |
highlihted_days[0].month = 10 | |
highlihted_days[0].day = 6 | |
highlihted_days[1].year = 2018 | |
highlihted_days[1].month = 10 | |
highlihted_days[1].day = 11 | |
highlihted_days[2].year = 2018 | |
highlihted_days[2].month = 11 | |
highlihted_days[2].day = 22 | |
calendar.set_highlighted_dates(highlihted_days, len(highlihted_days)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment