8000 +lvstm32.py · mhepp63/lv_binding_micropython@cc60d68 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc60d68

Browse files
prolombamirgon
authored andcommitted
+lvstm32.py
1 parent cbd6a8e commit cc60d68

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

driver/stm32/lvstm32.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Module for advancing tick count and scheduling async event for lvgl on STM32.
2+
# Import after lvgl module.
3+
#
4+
# MIT license; Copyright (c) 2020 Amir Gonnen
5+
6+
import lvgl as lv
7+
import micropython
8+
import pyb
9+
10+
class lvstm32():
11+
def __init__(self, freq=25, timer_id=4):
12+
self.task_handler_ref = self.task_handler # Allocation occurs here
13+
self.delay = 1000 // freq
14+
tim = pyb.Timer(timer_id)
15+
tim.init(freq=freq)
16+
tim.callback(self.timer_cb)
17+
18+
def task_handler(self, _):
19+
lv.task_handler()
20+
21+
def timer_cb(self, t):
22+
lv.tick_inc(self.delay)
23+
# Passing self.task_handler would cause allocation.
24+
micropython.schedule(self.task_handler_ref, 0)
25+

lv_conf.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
/* clang-format off */
1010

1111
#include <stdint.h>
12+
#define mp_instance_cast_to_native_base mp_obj_cast_to_native_base
1213

1314
/*====================
1415
Graphical settings
1516
*====================*/
1617

1718
/* Maximal horizontal and vertical resolution to support by the library.*/
1819
#define LV_HOR_RES_MAX (480)
19-
#define LV_VER_RES_MAX (320)
20+
#define LV_VER_RES_MAX (272) //(320)
2021

2122
/* Color depth:
2223
* - 1: 1 byte per pixel
@@ -55,7 +56,7 @@
5556
/* Dot Per Inch: used to initialize default sizes.
5657
* E.g. a button with width = LV_DPI / 2 -> half inch wide
5758
* (Not so important, you can adjust it to modify default sizes and spaces)*/
58-
#define LV_DPI 100 /*[px]*/
59+
#define LV_DPI 60 /*[px]*/
5960

6061
/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
6162
typedef int16_t lv_coord_t;

0 commit comments

Comments
 (0)
0