├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── macOS.yml │ ├── release.yml │ ├── unix.yml │ └── windows.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── _indev_base.pyi ├── api_drivers ├── common_api_drivers │ ├── display │ │ ├── axs15231b │ │ │ ├── _axs15231b_init.py │ │ │ └── axs15231b.py │ │ ├── driver_use_exmple.py │ │ ├── gc9107 │ │ │ ├── _gc9107_init.py │ │ │ └── gc9107.py │ │ ├── gc9a01 │ │ │ ├── _gc9a01_init.py │ │ │ └── gc9a01.py │ │ ├── hx8357.wip │ │ │ ├── _hx8357c_init.py │ │ │ └── hx8357c.py │ │ ├── hx8357b │ │ │ ├── _hx8357b_init.py │ │ │ └── hx8357b.py │ │ ├── hx8357d │ │ │ ├── _hx8357d_init.py │ │ │ ├── hx8357d.py │ │ │ └── sdkconfig │ │ ├── hx8369 │ │ │ ├── _hx8369_init_type1.py │ │ │ ├── hx8369.py │ │ │ └── sdkconfig │ │ ├── ili9163 │ │ │ ├── _ili9163_init.py │ │ │ └── ili9163.py │ │ ├── ili9225 │ │ │ ├── _ili9225_init.py │ │ │ └── ili9225.py │ │ ├── ili9341 │ │ │ ├── _ili9341_init_type1.py │ │ │ ├── _ili9341_init_type2.py │ │ │ └── ili9341.py │ │ ├── ili9481 │ │ │ ├── _ili9481_init_type1.py │ │ │ ├── _ili9481_init_type2.py │ │ │ ├── _ili9481_init_type3.py │ │ │ ├── _ili9481_init_type4.py │ │ │ ├── _ili9481_init_type5.py │ │ │ ├── _ili9481_init_type6.py │ │ │ ├── _ili9481_init_type7.py │ │ │ ├── _ili9481_init_type8.py │ │ │ └── ili9481.py │ │ ├── ili9486 │ │ │ ├── _ili9486_init.py │ │ │ └── ili9486.py │ │ ├── ili9488 │ │ │ ├── _ili9488_init.py │ │ │ └── ili9488.py │ │ ├── lcd_commands.py │ │ ├── lt7381 │ │ │ ├── _lt7381_init_type1.py │ │ │ └── lt7381.py │ │ ├── lt768x │ │ │ ├── _lt768x_init.py │ │ │ └── lt768x.py │ │ ├── nt35510.wip │ │ │ ├── _nt35510_init.py │ │ │ ├── _nt35510_init_type1.py │ │ │ ├── _nt35510_init_type2.py │ │ │ ├── nt35510.py │ │ │ └── sdkconfig │ │ ├── nv3041a │ │ │ ├── _nv3041a_init.py │ │ │ └── nv3041a.py │ │ ├── r61581 │ │ │ ├── _r61581_init.py │ │ │ └── r61581.py │ │ ├── ra8876 │ │ │ ├── _ra8876_init.py │ │ │ └── ra8876.py │ │ ├── rgb_display │ │ │ └── rgb_display.py │ │ ├── rm67162 │ │ │ ├── _rm67162_init.py │ │ │ └── rm67162.py │ │ ├── rm68120 │ │ │ ├── _rm68120_init.py │ │ │ └── rm68120.py │ │ ├── rm68140 │ │ │ ├── _rm68140_init.py │ │ │ └── rm68140.py │ │ ├── s6d02a1 │ │ │ ├── _s6d02a1_init.py │ │ │ └── s6d02a1.py │ │ ├── sdl_display │ │ │ └── sdl_display.py │ │ ├── spd2010 │ │ │ ├── _spd2010_init.py │ │ │ └── spd2010.py │ │ ├── ssd1306 │ │ │ ├── _ssd1306_init.py │ │ │ └── ssd1306.py │ │ ├── ssd1351 │ │ │ ├── _ssd1351_init.py │ │ │ └── ssd1351.py │ │ ├── ssd1963 │ │ │ ├── _ssd1963_init_type1.py │ │ │ ├── _ssd1963_init_type2.py │ │ │ ├── _ssd1963_init_type3.py │ │ │ ├── _ssd1963_init_type4.py │ │ │ └── ssd1963.py │ │ ├── st7565 │ │ │ ├── _st7565_init.py │ │ │ └── st7565.py │ │ ├── st7701 │ │ │ ├── _st7701_type1.py │ │ │ ├── _st7701_type10.py │ │ │ ├── _st7701_type11.py │ │ │ ├── _st7701_type12.py │ │ │ ├── _st7701_type13.py │ │ │ ├── _st7701_type14.py │ │ │ ├── _st7701_type15.py │ │ │ ├── _st7701_type16.py │ │ │ ├── _st7701_type17.py │ │ │ ├── _st7701_type2.py │ │ │ ├── _st7701_type3.py │ │ │ ├── _st7701_type4.py │ │ │ ├── _st7701_type5.py │ │ │ ├── _st7701_type6.py │ │ │ ├── _st7701_type7.py │ │ │ ├── _st7701_type8.py │ │ │ ├── _st7701_type9.py │ │ │ └── st7701.py │ │ ├── st7735 │ │ │ ├── _st7735_init_type1.py │ │ │ ├── _st7735_init_type2.py │ │ │ ├── _st7735_init_type3.py │ │ │ └── st7735.py │ │ ├── st7789 │ │ │ ├── _st7789_init.py │ │ │ └── st7789.py │ │ └── st7796 │ │ │ ├── _st7796_init.py │ │ │ └── st7796.py │ ├── frozen │ │ ├── machine_i2c.c │ │ ├── mp_i2c_common.h │ │ └── other │ │ │ ├── auto_rotation.py │ │ │ ├── i2c.py │ │ │ ├── spi3wire.py │ │ │ └── task_handler.py │ ├── imu_sensor │ │ └── qmi8658c.py │ ├── include │ │ └── common.h │ ├── indev │ │ ├── axs15231.py │ │ ├── cst328.py │ │ ├── cst340.py.wip │ │ ├── cst816s.py │ │ ├── evdev │ │ │ ├── button.py │ │ │ ├── devices.py │ │ │ ├── fnctl.py │ │ │ ├── joystick.py │ │ │ ├── keyboard.py │ │ │ ├── mouse.py │ │ │ └── mousewheel.py │ │ ├── focaltech_touch.py │ │ ├── ft5x06.py │ │ ├── ft5x16.py │ │ ├── ft5x26.py │ │ ├── ft5x36.py │ │ ├── ft5x46.py │ │ ├── ft6x06.py │ │ ├── ft6x36.py │ │ ├── gsl1680.py │ │ ├── gt911.py │ │ ├── gt911_extension.py │ │ ├── gt911_settings_gui.py │ │ ├── sdl_keyboard.py │ │ ├── sdl_pointer.py │ │ ├── spd2010t.py │ │ ├── stmpe610.py │ │ └── xpt2046.py │ ├── io_expander │ │ ├── axp192.py.wip │ │ ├── ch422g.py │ │ ├── ht8574a.py │ │ ├── ht8574b.py │ │ ├── tca9535.py │ │ └── tca9554.py │ └── utils │ │ ├── lv_colors.py │ │ └── utils.py └── py_api_drivers │ ├── frozen │ ├── display │ │ ├── display_driver_framework.py │ │ └── rgb_display_framework.py │ ├── imu_sensor │ │ └── imu_sensor_framework.py │ ├── indev │ │ ├── _indev_base.py │ │ ├── button_framework.py │ │ ├── encoder_framework.py │ │ ├── keypad_framework.py │ │ ├── pointer_framework.py │ │ └── touch_calibration │ │ │ ├── touch_cal_data.py │ │ │ └── touch_calibrate.py │ └── io_expander │ │ └── io_expander_framework.py │ └── fs_driver.py ├── builder ├── __init__.py ├── esp32.py ├── macOS.py ├── nrf.py ├── raspberry_pi.py ├── renesas.py ├── rp2.py ├── stm32.py ├── toml_reader.py ├── unix.py └── windows.py ├── button_framework.pyi ├── custom_board_and_toml_examples ├── MY_CUSTOM_BOARD │ ├── board.json │ ├── mpconfigboard.cmake │ ├── mpconfigboard.h │ ├── my_custom_board.toml │ ├── partitions.csv │ └── sdkconfig.board ├── README.md └── toml_example │ └── example_build_toml.toml ├── display_configs ├── CYD-2432S024C.toml ├── CYD-2432S028R.toml ├── CYD-2432S032C.toml ├── CYD-3248S035C.toml ├── CYD-8048S043C.toml ├── CYD-8048S050C_I.toml ├── CYD-8048S070C.toml ├── ER-TFTMC050-3.toml ├── ESP32-S3-Touch-LCD-4.3.toml └── LilyGo-TDeck │ ├── LilyGo-TDeck.toml │ ├── README.md │ ├── board.json │ ├── keyboard_c3.py │ ├── keyboard_s3.py │ ├── manifest.py │ ├── mpconfigboard.cmake │ ├── mpconfigboard.h │ ├── partitions.csv │ ├── pins.py │ ├── power.py │ ├── sdkconfig.board │ ├── sx1262.py │ └── trackball.py ├── display_driver_framework.pyi ├── encoder_framework.pyi ├── ext_mod ├── esp32_components.cmake ├── imu_fusion │ ├── include │ │ └── fusion.h │ ├── micropython.cmake │ └── src │ │ └── fusion.c ├── lcd_bus │ ├── common_include │ │ ├── i2c_bus.h │ │ ├── i80_bus.h │ │ ├── rgb_bus.h │ │ └── spi_bus.h │ ├── common_src │ │ ├── i2c_bus.c │ │ ├── i80_bus.c │ │ ├── rgb_bus.c │ │ └── spi_bus.c │ ├── esp32_include │ │ ├── dsi_bus.h │ │ ├── i2c_bus.h │ │ ├── i80_bus.h │ │ ├── led_bus.h │ │ ├── rgb565_dither.h │ │ ├── rgb_bus.h │ │ └── spi_bus.h │ ├── esp32_src │ │ ├── dsi_bus.c │ │ ├── i2c_bus.c │ │ ├── i80_bus.c │ │ ├── led_bus.c │ │ ├── rgb565_dither.c │ │ ├── rgb_bus.c │ │ ├── rgb_bus_rotation.c │ │ └── spi_bus.c │ ├── lcd_types.c │ ├── lcd_types.h │ ├── micropython.cmake │ ├── micropython.mk │ ├── modlcd_bus.c │ ├── modlcd_bus.h │ └── sdl_bus │ │ ├── sdl_bus.c │ │ └── sdl_bus.h ├── lcd_utils │ ├── include │ │ ├── binary_float.h │ │ └── remap.h │ ├── micropython.cmake │ ├── micropython.mk │ └── src │ │ ├── binary_float.c │ │ ├── lcd_utils.c │ │ └── remap.c ├── lvgl │ ├── mem_core.c │ ├── micropython.cmake │ └── micropython.mk ├── micropython.cmake └── spi3wire │ ├── include │ ├── esp_lcd_panel_io_additions.h │ └── spi3wire.h │ ├── micropython.cmake │ └── src │ ├── esp_lcd_panel_io_3wire_spi.c │ └── spi3wire.c ├── fusion.pyi ├── gen ├── .gitignore ├── fake_libc │ ├── X11 │ │ ├── Intrinsic.h │ │ ├── Xlib.h │ │ ├── _X11_fake_defines.h │ │ └── _X11_fake_typedefs.h │ ├── _ansi.h │ ├── _fake_defines.h │ ├── _fake_typedefs.h │ ├── _syslist.h │ ├── aio.h │ ├── alloca.h │ ├── ar.h │ ├── argz.h │ ├── arpa │ │ └── inet.h │ ├── asm-generic │ │ └── int-ll64.h │ ├── assert.h │ ├── complex.h │ ├── cpio.h │ ├── ctype.h │ ├── dirent.h │ ├── dlfcn.h │ ├── emmintrin.h │ ├── endian.h │ ├── envz.h │ ├── errno.h │ ├── fastmath.h │ ├── fcntl.h │ ├── features.h │ ├── fenv.h │ ├── float.h │ ├── fmtmsg.h │ ├── fnmatch.h │ ├── ftw.h │ ├── getopt.h │ ├── glob.h │ ├── grp.h │ ├── iconv.h │ ├── ieeefp.h │ ├── immintrin.h │ ├── inttypes.h │ ├── iso646.h │ ├── langinfo.h │ ├── libgen.h │ ├── libintl.h │ ├── limits.h │ ├── linux │ │ ├── socket.h │ │ └── version.h │ ├── locale.h │ ├── malloc.h │ ├── math.h │ ├── memory.h │ ├── mir_toolkit │ │ └── client_types.h │ ├── monetary.h │ ├── mqueue.h │ ├── ndbm.h │ ├── net │ │ └── if.h │ ├── netdb.h │ ├── netinet │ │ ├── in.h │ │ └── tcp.h │ ├── newlib.h │ ├── nl_types.h │ ├── openssl │ │ ├── err.h │ │ ├── evp.h │ │ ├── hmac.h │ │ ├── ssl.h │ │ └── x509v3.h │ ├── paths.h │ ├── poll.h │ ├── process.h │ ├── pthread.h │ ├── pwd.h │ ├── reent.h │ ├── regdef.h │ ├── regex.h │ ├── sched.h │ ├── search.h │ ├── semaphore.h │ ├── setjmp.h │ ├── signal.h │ ├── smmintrin.h │ ├── spawn.h │ ├── stdalign.h │ ├── stdarg.h │ ├── stdatomic.h │ ├── stdbool.h │ ├── stddef.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ ├── stdnoreturn.h │ ├── string.h │ ├── strings.h │ ├── stropts.h │ ├── sys │ │ ├── ioctl.h │ │ ├── ipc.h │ │ ├── mman.h │ │ ├── msg.h │ │ ├── poll.h │ │ ├── resource.h │ │ ├── select.h │ │ ├── sem.h │ │ ├── shm.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── statvfs.h │ │ ├── sysctl.h │ │ ├── time.h │ │ ├── times.h │ │ ├── types.h │ │ ├── uio.h │ │ ├── un.h │ │ ├── utsname.h │ │ └── wait.h │ ├── syslog.h │ ├── tar.h │ ├── termios.h │ ├── tgmath.h │ ├── threads.h │ ├── time.h │ ├── trace.h │ ├── types.h │ ├── uchar.h │ ├── ulimit.h │ ├── unctrl.h │ ├── unistd.h │ ├── utime.h │ ├── utmp.h │ ├── utmpx.h │ ├── vadefs.h │ ├── vcruntime.h │ ├── wchar.h │ ├── wctype.h │ ├── wordexp.h │ ├── xcb │ │ └── xcb.h │ └── zlib.h ├── fixed_gen_json.py ├── lvgl_api_gen_mpy.py ├── python_api_gen_mpy.py └── stub_gen.py ├── i2c.pyi ├── io_expander_framework.pyi ├── keypad_framework.pyi ├── lcd_bus.pyi ├── lcd_utils.pyi ├── lib └── lv_conf.h ├── machine.pyi ├── make.py ├── micropy_updates ├── common │ └── mp_spi_common.h ├── esp32 │ ├── machine_hw_spi.c │ └── machine_sdcard.c ├── rp2 │ └── machine_spi.c ├── stm32 │ └── machine_spi.c └── unix │ ├── machine_sdl.c │ ├── machine_sdl.h │ ├── machine_timer.c │ └── machine_timer.h ├── pointer_framework.pyi ├── spi3wire.pyi ├── task_handler.pyi ├── touch_cal_data.pyi └── touch_calibrate.pyi /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Bug Report 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Expected behavior** 14 | A clear and concise description of what you expected to happen. 15 | 16 | **Images** 17 | 18 | If it is a visual issue then take a picture of it or a video and add it here. 19 | 20 | **If you are having a problem compiling paste the build output below. (NO SCREENSHOTS)** 21 | 22 | ```shell 23 | PASTE OUTPUT HERE 24 | ``` 25 | 26 | **If your problem is running the binding please past the code you are using below.*** 27 | I need to see ALL of the setup code exactly as it is being ran. 28 | 29 | ```python 30 | PASTE CODE HERE 31 | ``` 32 | 33 | **Exact make and model number of the MCU that you are compiling for or the firmware is running on. ** 34 | 35 | * Make: 36 | * Model: 37 | 38 | **For ESP32 MCU's The PSRAM and FLASH SPI type, quad SPI or octal SPI.** 39 | 40 | * PSRAM: quad OR octal 41 | * FLASH: quad OR octal 42 | 43 | I need to know the OS and OS version of the machine that compiled the binary. If using a VM then I need to know the OS and OS version the VM is running. (WSL == VM) 44 | - OS: [e.g. iOS] 45 | 46 | **Build Command** 47 | 48 | ```shell 49 | BUILD COMMAND HERE 50 | ``` 51 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | name: Windows build 4 | 5 | on: 6 | push: 7 | pull_request: 8 | 9 | jobs: 10 | build: 11 | if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} 12 | runs-on: windows-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: Cyberboss/install-winget@v1 17 | - uses: carlosperate/arm-none-eabi-gcc-action@v1.8.1 18 | with: 19 | release: '9-2019-q4' # The arm-none-eabi-gcc release to use. 20 | 21 | # - uses: actions/setup-python@v5 22 | # with: 23 | # python-version: '3.10' 24 | 25 | # - name: Install Dependencies 26 | # run: | 27 | # winget install --accept-source-agreements --accept-package-agreements ezwinports.make 28 | # python3 -m pip install pyMSVC requests 29 | 30 | # - name: Build ESP32 port 31 | # run: python3 make.py esp32 submodules clean mpy_cross BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=rgb_display INDEV=gt911 32 | 33 | # - name: Build STM32 port 34 | # run: python3 make.py stm32 submodules clean mpy_cross BOARD=STM32H7B3I_DK DISPLAY=rgb_display INDEV=gt911 35 | 36 | # - name: Build Raspberry Pi PICO port 37 | # run: python3 make.py rp2 submodules clean mpy_cross BOARD=RPI_PICO DISPLAY=rgb_display INDEV=gt911 38 | 39 | # - name: Build Windows port 40 | # run: python3 make.py windows submodules clean mpy_cross DISPLAY=sdl_display INDEV=sdl_pointer 41 | 42 | 43 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/pycparser"] 2 | path = lib/pycparser 3 | url = https://github.com/eliben/pycparser 4 | [submodule "lib/SDL"] 5 | path = lib/SDL 6 | url = https://github.com/libsdl-org/SDL 7 | [submodule "lib/esp-idf"] 8 | path = lib/esp-idf 9 | url = https://github.com/espressif/esp-idf 10 | [submodule "lib/lvgl"] 11 | path = lib/lvgl 12 | url = https://github.com/lvgl/lvgl 13 | [submodule "lib/micropython"] 14 | path = lib/micropython 15 | url = https://github.com/micropython/micropython 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # Makefile for LVGL_Micropython Binding 4 | 5 | PYTHON_CMD=python3 6 | 7 | # User-friendly check for python3 8 | ifeq ($(shell which $(PYTHON_CMD) >/dev/null 2>&1; echo $$?), 1) 9 | $(error The '$(PYTHON)' command was not found. Make sure you have Python 3.8.x+) 10 | endif 11 | 12 | variables=$(foreach v,$(.VARIABLES),$(if $(filter command line,$(origin $(v))),$(v)=$($(v)))) 13 | BUILD_CMD=$(shell echo "${variables}" | sed 's/[ ][ ]*/ /g') 14 | 15 | arguments = $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) 16 | 17 | target =$@ 18 | 19 | PYTHON_CMD += make.py 20 | 21 | ifneq (,$(findstring clean ,$(arguments))) 22 | args=$(subst clean ,,$(arguments)) 23 | clean_cmd =clean 24 | else 25 | args=$(arguments) 26 | clean_cmd = 27 | endif 28 | 29 | BUILD_CMD+=$(foreach v,$(args),--$(v)) 30 | 31 | .ONESHELL: 32 | 33 | esp32: 34 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 35 | @exit 0 36 | 37 | stm32: 38 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 39 | @exit 0 40 | 41 | unix: 42 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 43 | @exit 0 44 | 45 | rp2: 46 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 47 | @exit 0 48 | 49 | macOS: 50 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 51 | @exit 0 52 | 53 | renesas-ra: 54 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 55 | @exit 0 56 | 57 | nrf: 58 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 59 | @exit 0 60 | 61 | mimxrt: 62 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 63 | @exit 0 64 | 65 | samd: 66 | @$(PYTHON_CMD) $@ $(clean_cmd) $(BUILD_CMD) 67 | @exit 0 68 | 69 | %: 70 | @exit 0 71 | -------------------------------------------------------------------------------- /_indev_base.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional, ClassVar, TYPE_CHECKING, Union 4 | 5 | 6 | if TYPE_CHECKING: 7 | import lvgl as _lv # NOQA 8 | import display_driver_framework as _display_driver_framework 9 | from keypad_framework import KeypadDriver as _KeypadDriver 10 | from pointer_framework import PointerDriver as _PointerDriver 11 | from encoder_framework import EncoderDriver as _EncoderDriver 12 | from button_framework import ButtonDriver as _ButtonDriver 13 | 14 | 15 | class IndevBase: 16 | _instance_counter: ClassVar[int] = ... 17 | _indevs: ClassVar[list] 18 | 19 | PRESSED: ClassVar[int] = ... 20 | RELEASED: ClassVar[int] = ... 21 | 22 | id: int = ... 23 | 24 | _disp_drv: _lv.display_t = ... 25 | _py_disp_drv: _display_driver_framework.DisplayDriver 26 | 27 | _height: int = ... 28 | _width: int = ... 29 | 30 | _indev_drv: _lv.indev_t = ... 31 | _current_state: int = ... 32 | 33 | def __init__(self, debug: bool=False): # NOQA 34 | ... 35 | 36 | def get_width(self) -> int: 37 | ... 38 | 39 | def get_height(self) -> int: 40 | ... 41 | 42 | def get_rotation(self) -> int: 43 | ... 44 | 45 | def _read(self, drv, data): # NOQA 46 | ... 47 | 48 | def read(self): 49 | ... 50 | 51 | def get_type(self) -> int: 52 | ... 53 | 54 | def send_event(self, code: _lv.event_t, param: int) -> bool: 55 | ... 56 | 57 | def remove_event(self, index) -> None: 58 | ... 59 | 60 | def get_event_dsc(self, index) -> Optional[_lv.event_dsc_t]: 61 | ... 62 | 63 | def get_event_count(self) -> int: 64 | ... 65 | 66 | def add_event_cb(self, event_cb, filter, user_data) -> None: 67 | ... 68 | 69 | def search_obj(self, point: _lv.point_t) -> Optional[_lv.obj]: 70 | ... 71 | 72 | def delete_read_timer(self) -> None: 73 | ... 74 | 75 | def get_read_timer(self) -> _lv.timer_t: 76 | ... 77 | 78 | def get_active_obj(self) -> _lv.obj: 79 | ... 80 | 81 | def wait_release(self) -> None: 82 | ... 83 | 84 | def get_state(self): 85 | ... 86 | 87 | def enable(self, en: bool) -> None: 88 | ... 89 | 90 | def get_group(self): 91 | ... 92 | 93 | def set_group(self, group) -> None: 94 | ... 95 | 96 | def reset(self, obj) -> None: 97 | ... 98 | 99 | def get_disp(self) -> _display_driver_framework.DisplayDriver: 100 | ... 101 | 102 | @staticmethod 103 | def active() -> Optional[ 104 | Union[_KeypadDriver, _PointerDriver, _EncoderDriver, _ButtonDriver] 105 | ]: 106 | ... 107 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/gc9107/gc9107.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | 5 | import lvgl as lv # NOQA 6 | import lcd_bus # NOQA 7 | import display_driver_framework 8 | 9 | 10 | STATE_HIGH = display_driver_framework.STATE_HIGH 11 | STATE_LOW = display_driver_framework.STATE_LOW 12 | STATE_PWM = display_driver_framework.STATE_PWM 13 | 14 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 15 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 16 | 17 | 18 | _MADCTL_MH = const(0x04) # Refresh 0=Left to Right, 1=Right to Left 19 | _MADCTL_BGR = const(0x08) # BGR color order 20 | _MADCTL_ML = const(0x10) # Refresh 0=Top to Bottom, 1=Bottom to Top 21 | _MADCTL_MV = const(0x20) # 0=Normal, 1=Row/column exchange 22 | _MADCTL_MX = const(0x40) # 0=Left to Right, 1=Right to Left 23 | _MADCTL_MY = const(0x80) # 0=Top to Bottom, 1=Bottom to Top 24 | 25 | 26 | class GC9107(display_driver_framework.DisplayDriver): 27 | 28 | _ORIENTATION_TABLE = ( 29 | 0, 30 | _MADCTL_MX | _MADCTL_MV, 31 | _MADCTL_MY | _MADCTL_MX, 32 | _MADCTL_MY | _MADCTL_MV 33 | ) 34 | 35 | def _set_memory_location(self, x1, y1, x2, y2): 36 | if self._rotation in (0, 2): 37 | x1 += 2 38 | x2 += 2 39 | y1 += 1 40 | y2 += 1 41 | else: 42 | x1 += 1 43 | x2 += 1 44 | y1 += 2 45 | y2 += 2 46 | 47 | return display_driver_framework.DisplayDriver(self, x1, y1, x2, y2) 48 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/gc9a01/gc9a01.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | 5 | import lvgl as lv # NOQA 6 | import lcd_bus # NOQA 7 | import display_driver_framework 8 | 9 | 10 | STATE_HIGH = display_driver_framework.STATE_HIGH 11 | STATE_LOW = display_driver_framework.STATE_LOW 12 | STATE_PWM = display_driver_framework.STATE_PWM 13 | 14 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 15 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 16 | 17 | 18 | _MADCTL_MH = const(0x04) # Refresh 0=Left to Right, 1=Right to Left 19 | _MADCTL_BGR = const(0x08) # BGR color order 20 | _MADCTL_ML = const(0x10) # Refresh 0=Top to Bottom, 1=Bottom to Top 21 | _MADCTL_MV = const(0x20) # 0=Normal, 1=Row/column exchange 22 | _MADCTL_MX = const(0x40) # 0=Left to Right, 1=Right to Left 23 | _MADCTL_MY = const(0x80) # 0=Top to Bottom, 1=Bottom to Top 24 | 25 | 26 | class GC9A01(display_driver_framework.DisplayDriver): 27 | 28 | _ORIENTATION_TABLE = ( 29 | 0, 30 | _MADCTL_MX | _MADCTL_MV, 31 | _MADCTL_MY | _MADCTL_MX, 32 | _MADCTL_MY | _MADCTL_MV 33 | ) 34 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357.wip/_hx8357c_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357b/_hx8357b_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import time 4 | from micropython import const # NOQA 5 | 6 | import lvgl as lv # NOQA 7 | import lcd_bus # NOQA 8 | 9 | 10 | _SLPOUT = const(0x11) 11 | _DISPON = const(0x29) 12 | _CASET = const(0x2A) 13 | _PASET = const(0x2B) 14 | _MADCTL = const(0x36) 15 | _COLMOD = const(0x3A) 16 | _WRDISBV = const(0x51) # display brightness 17 | _SETPANEL = const(0xC0) 18 | _SETOSC = const(0xC5) 19 | _SETGAMMA = const(0xC8) 20 | _SETPOWER = const(0xD0) 21 | _SETVCOM = const(0xD1) 22 | _SETNORPOW = const(0xD2) 23 | 24 | 25 | def init(self): 26 | param_buf = bytearray(12) 27 | param_mv = memoryview(param_buf) 28 | 29 | self.set_params(_SLPOUT) 30 | 31 | time.sleep_ms(20) # NOQA 32 | 33 | param_buf[:3] = bytearray([0x07, 0x42, 0x18]) 34 | self.set_params(_SETPOWER, param_mv[:3]) 35 | 36 | param_buf[:3] = bytearray([0x00, 0x07, 0x10]) 37 | self.set_params(_SETVCOM, param_mv[:3]) 38 | 39 | param_buf[:2] = bytearray([0x01, 0x02]) 40 | self.set_params(_SETNORPOW, param_mv[:2]) 41 | 42 | param_buf[:5] = bytearray([0x10, 0x3B, 0x00, 0x02, 0x11]) 43 | self.set_params(_SETPANEL, param_mv[:5]) 44 | 45 | param_buf[0] = 0x08 46 | self.set_params(_SETOSC, param_mv[:1]) 47 | 48 | param_buf[:12] = bytearray([ 49 | 0x00, 0x32, 0x36, 0x45, 0x06, 0x16, 0x37, 0x75, 0x77, 0x54, 0x0C, 0x00]) 50 | self.set_params(_SETGAMMA, param_mv[:12]) 51 | 52 | param_buf[0] = ( 53 | self._madctl( 54 | self._color_byte_order, 55 | self._ORIENTATION_TABLE # NOQA 56 | ) 57 | ) 58 | self.set_params(_MADCTL, param_mv[:1]) 59 | 60 | color_size = lv.color_format_get_size(self._color_space) 61 | if color_size == 2: # NOQA 62 | pixel_format = 0x55 63 | else: 64 | raise RuntimeError( 65 | f'{self.__class__.__name__} IC only supports ' 66 | 'lv.COLOR_FORMAT.RGB565' 67 | ) 68 | 69 | param_buf[0] = pixel_format 70 | self.set_params(_COLMOD, param_mv[:1]) 71 | 72 | param_buf[:4] = bytearray([0x00, 0x00, 0x01, 0x3F]) 73 | self.set_params(_CASET, param_mv[:4]) 74 | 75 | param_buf[3] = 0xDF 76 | self.set_params(_PASET, param_mv[:4]) 77 | 78 | time.sleep_ms(120) # NOQA 79 | self.set_params(_DISPON) 80 | time.sleep_ms(25) # NOQA 81 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357b/hx8357b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class HX8357B(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357d/_hx8357d_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import time 4 | from micropython import const # NOQA 5 | 6 | import lvgl as lv # NOQA 7 | import lcd_bus # NOQA 8 | 9 | 10 | _SWRESET = const(0x01) 11 | _SLPOUT = const(0x11) 12 | _DISPON = const(0x29) 13 | _COLMOD = const(0x3A) 14 | _MADCTL = const(0x36) 15 | _TEON = const(0x35) 16 | _TEARLINE = const(0x44) 17 | _SETOSC = const(0xB0) 18 | _SETPWR1 = const(0xB1) 19 | _SETRGB = const(0xB3) 20 | _SETCOM = const(0xB6) 21 | _SETCYC = const(0xB4) 22 | _SETC = const(0xB9) 23 | _SETSTBA = const(0xC0) 24 | _SETPANEL = const(0xCC) 25 | _SETGAMMA = const(0xE0) 26 | 27 | 28 | def init(self): 29 | param_buf = bytearray(34) 30 | param_mv = memoryview(param_buf) 31 | 32 | time.sleep_ms(300) # NOQA 33 | param_buf[:3] = bytearray([0xFF, 0x83, 0x57]) 34 | self.set_params(_SETC, param_mv[:3]) 35 | 36 | param_buf[0] = 0x80 37 | self.set_params(_SETRGB, param_mv[:1]) 38 | 39 | param_buf[:4] = bytearray([0x00, 0x06, 0x06, 0x25]) 40 | self.set_params(_SETCOM, param_mv[:4]) 41 | 42 | param_buf[0] = 0x68 43 | self.set_params(_SETOSC, param_mv[:1]) 44 | 45 | param_buf[0] = 0x05 46 | self.set_params(_SETPANEL, param_mv[:1]) 47 | 48 | param_buf[:6] = bytearray([0x00, 0x15, 0x1C, 0x1C, 0x83, 0xAA]) 49 | self.set_params(_SETPWR1, param_mv[:6]) 50 | 51 | param_buf[:6] = bytearray([0x50, 0x50, 0x01, 0x3C, 0x1E, 0x08]) 52 | self.set_params(_SETSTBA, param_mv[:6]) 53 | 54 | param_buf[:7] = bytearray([0x02, 0x40, 0x00, 0x2A, 0x2A, 0x0D, 0x78]) 55 | self.set_params(_SETCYC, param_mv[:7]) 56 | 57 | param_buf[:34] = bytearray([ 58 | 0x02, 0x0A, 0x11, 0x1d, 0x23, 0x35, 0x41, 0x4b, 0x4b, 0x42, 0x3A, 59 | 0x27, 0x1B, 0x08, 0x09, 0x03, 0x02, 0x0A, 0x11, 0x1d, 0x23, 0x35, 60 | 0x41, 0x4b, 0x4b, 0x42, 0x3A, 0x27, 0x1B, 0x08, 0x09, 0x03, 0x00, 0x01]) 61 | self.set_params(_SETGAMMA, param_mv[:34]) 62 | 63 | param_buf[0] = ( 64 | self._madctl( 65 | self._color_byte_order, 66 | self._ORIENTATION_TABLE # NOQA 67 | ) 68 | ) 69 | self.set_params(_MADCTL, param_mv[:1]) 70 | 71 | color_size = lv.color_format_get_size(self._color_space) 72 | if color_size == 2: # NOQA 73 | pixel_format = 0x55 74 | else: 75 | raise RuntimeError( 76 | f'{self.__class__.__name__} IC only supports ' 77 | 'lv.COLOR_FORMAT.RGB565' 78 | ) 79 | 80 | param_buf[0] = pixel_format 81 | self.set_params(_COLMOD, param_mv[:1]) 82 | 83 | param_buf[0] = 0x00 84 | self.set_params(_TEON, param_mv[:1]) 85 | 86 | param_buf[:2] = bytearray([0x00, 0x02]) 87 | self.set_params(_TEARLINE, param_mv[:2]) 88 | 89 | time.sleep_ms(150) # NOQA 90 | self.set_params(_SLPOUT) 91 | 92 | time.sleep_ms(50) # NOQA 93 | self.set_params(_DISPON) 94 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357d/hx8357d.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class HX8357D(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8357d/sdkconfig: -------------------------------------------------------------------------------- 1 | CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=34 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8369/hx8369.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | from micropython import const # NOQA 5 | 6 | import time 7 | 8 | TYPE_A = 1 9 | 10 | STATE_HIGH = display_driver_framework.STATE_HIGH 11 | STATE_LOW = display_driver_framework.STATE_LOW 12 | STATE_PWM = display_driver_framework.STATE_PWM 13 | 14 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 15 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 16 | 17 | _MADCTL_MV = const(0x20) # 0=Normal, 1=Row/column exchange 18 | _MADCTL_MX = const(0x40) # 0=Left to Right, 1=Right to Left 19 | _MADCTL_MY = const(0x80) # 0=Top to Bottom, 1=Bottom to Top 20 | 21 | 22 | class HX8369(display_driver_framework.DisplayDriver): 23 | 24 | _ORIENTATION_TABLE = ( 25 | 0, 26 | _MADCTL_MX | _MADCTL_MV, 27 | _MADCTL_MY | _MADCTL_MX, 28 | _MADCTL_MY | _MADCTL_MV 29 | ) 30 | 31 | def reset(self): 32 | if self._reset_pin is None: 33 | return 34 | 35 | self._reset_pin.value(self._reset_state) 36 | time.sleep_ms(25) # NOQA 37 | self._reset_pin.value(not self._reset_state) 38 | time.sleep_ms(50) # NOQA 39 | 40 | def set_brightness(self, value): 41 | value = int(value / 100.0 * 255) 42 | 43 | if 255 < value: 44 | mapped_level = 255 45 | elif value >= 102: 46 | mapped_level = 52 + (value - 102) * (255 - 52) / (255 - 102) 47 | else: # value < 102: 48 | mapped_level = 52 - (102 - value) * 52 / 102 49 | 50 | self._param_buf[0] = int(mapped_level) 51 | self.set_params(0x51, self._param_mv[:1]) 52 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/hx8369/sdkconfig: -------------------------------------------------------------------------------- 1 | CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=192 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9163/ili9163.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class ILI9163(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9225/ili9225.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | from micropython import const # NOQA 5 | 6 | 7 | _RAMWR = const(0x22) 8 | _HWINADDR1 = const(0x36) 9 | _HWINADDR2 = const(0x37) 10 | _VWINADDR1 = const(0x38) 11 | _VWINADDR2 = const(0x39) 12 | _RAMADDRSET1 = const(0x20) 13 | _RAMADDRSET2 = const(0x21) 14 | _ENTRYMODE = const(0x03) 15 | _DRVROUTCTRL = const(0x01) 16 | 17 | 18 | STATE_HIGH = display_driver_framework.STATE_HIGH 19 | STATE_LOW = display_driver_framework.STATE_LOW 20 | STATE_PWM = display_driver_framework.STATE_PWM 21 | 22 | BYTE_ORDER_RGB = 0x00 23 | BYTE_ORDER_BGR = 0x10 24 | 25 | 26 | class ILI9225(display_driver_framework.DisplayDriver): 27 | 28 | def _set_memory_location(self, x1, y1, x2, y2): 29 | # if self._rotation & 0x01: 30 | # x1, y1 = y1, x1 31 | # x2, y2 = y2, x2 32 | 33 | # Column addresses 34 | param_buf = self._param_buf 35 | 36 | param_buf[0] = (x1 >> 8) & 0xFF 37 | param_buf[1] = x1 & 0xFF 38 | self._data_bus.tx_param(_HWINADDR1, self._param_mv[:2]) 39 | 40 | param_buf[0] = (x2 >> 8) & 0xFF 41 | param_buf[1] = x2 & 0xFF 42 | self._data_bus.tx_param(_HWINADDR2, self._param_mv[:2]) 43 | 44 | # Page addresses 45 | param_buf[0] = (y1 >> 8) & 0xFF 46 | param_buf[1] = y1 & 0xFF 47 | self._data_bus.tx_param(_VWINADDR1, self._param_mv[:2]) 48 | 49 | param_buf[0] = (y2 >> 8) & 0xFF 50 | param_buf[1] = y2 & 0xFF 51 | self._data_bus.tx_param(_VWINADDR2, self._param_mv[:2]) 52 | 53 | param_buf[0] = (x1 >> 8) & 0xFF 54 | param_buf[1] = x1 & 0xFF 55 | self._data_bus.tx_param(_RAMADDRSET1, self._param_mv[:2]) 56 | 57 | param_buf[0] = (y1 >> 8) & 0xFF 58 | param_buf[1] = y1 & 0xFF 59 | self._data_bus.tx_param(_RAMADDRSET2, self._param_mv[:2]) 60 | 61 | return _RAMWR 62 | 63 | def _on_size_change(self, _): 64 | rotation = self._disp_drv.get_rotation() 65 | self._width = self._disp_drv.get_horizontal_resolution() 66 | self._height = self._disp_drv.get_vertical_resolution() 67 | 68 | if rotation == self._rotation: 69 | return 70 | 71 | self._rotation = rotation 72 | 73 | if self._initilized: 74 | if rotation <= 1: 75 | rotation = int(not rotation) 76 | 77 | self._param_buf[0] = rotation 78 | self._param_buf[1] = 0x1C 79 | self.set_params(_DRVROUTCTRL, self._param_mv[:2]) 80 | 81 | self._param_buf[0] = self._color_byte_order 82 | 83 | if rotation in (1, 2): 84 | self._param_buf[1] = 0x30 85 | else: 86 | self._param_buf[1] = 0x38 87 | 88 | self.set_params(_ENTRYMODE, self._param_mv[:2]) 89 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9341/ili9341.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class ILI9341(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9481/ili9481.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class ILI9481(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9486/ili9486.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class ILI9486(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ili9488/ili9488.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | from micropython import const # NOQA 5 | 6 | 7 | STATE_HIGH = display_driver_framework.STATE_HIGH 8 | STATE_LOW = display_driver_framework.STATE_LOW 9 | STATE_PWM = display_driver_framework.STATE_PWM 10 | 11 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 12 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 13 | 14 | _MADCTL_MV = const(0x20) # 0=Normal, 1=Row/column exchange 15 | _MADCTL_MX = const(0x40) # 0=Left to Right, 1=Right to Left 16 | _MADCTL_MY = const(0x80) # 0=Top to Bottom, 1=Bottom to Top 17 | 18 | 19 | class ILI9488(display_driver_framework.DisplayDriver): 20 | 21 | _ORIENTATION_TABLE = ( 22 | _MADCTL_MX, 23 | _MADCTL_MV | _MADCTL_MY | _MADCTL_MX, 24 | _MADCTL_MY, 25 | _MADCTL_MV 26 | ) 27 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/lt768x/_lt768x_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/lt768x/lt768x.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import ra8876 as _ra8876 # NOQA 4 | 5 | 6 | STATE_HIGH = _ra8876.STATE_HIGH 7 | STATE_LOW = _ra8876.STATE_LOW 8 | STATE_PWM = _ra8876.STATE_PWM 9 | 10 | PORTRAIT = _ra8876.PORTRAIT 11 | LANDSCAPE = _ra8876.LANDSCAPE 12 | REVERSE_PORTRAIT = _ra8876.REVERSE_PORTRAIT 13 | REVERSE_LANDSCAPE = _ra8876.REVERSE_LANDSCAPE 14 | 15 | BYTE_ORDER_RGB = _ra8876.BYTE_ORDER_RGB 16 | BYTE_ORDER_BGR = _ra8876.BYTE_ORDER_BGR 17 | 18 | 19 | IS42SM16160D = _ra8876.IS42SM16160D # integrated silicon solution dram IC 20 | IS42S16320B = _ra8876.IS42S16320B # integrated silicon solution dram IC 21 | IS42S16400F = _ra8876.IS42S16400F # integrated silicon solution dram IC 22 | M12L32162A = _ra8876.M12L32162A # elite semiconductor dram IC 23 | M12L2561616A = _ra8876.M12L2561616A # elite semiconductor dram IC 24 | W9825G6JH = _ra8876.W9825G6JH # winbond dram IC 25 | W9812G6JH = _ra8876.W9812G6JH # winbond dram IC 26 | MT48LC4M16A = _ra8876.MT48LC4M16A # micron dram IC 27 | K4S641632N = _ra8876.K4S641632N # samsung dram IC 28 | K4S281632K = _ra8876.K4S281632K # samsung dram IC 29 | 30 | 31 | class LT768x(_ra8876.RA8876): 32 | display_name = 'LT768x' 33 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/nt35510.wip/_nt35510_init_type1.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import _nt35510_init 4 | 5 | 6 | def init(self): 7 | _nt35510_init.init1(self) 8 | 9 | self._param_buf[0] = 0x50 10 | self.set_params(0xB500, self._param_mv[:1]) 11 | 12 | _nt35510_init.init2(self) 13 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/nt35510.wip/_nt35510_init_type2.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import _nt35510_init 4 | 5 | 6 | def init(self): 7 | _nt35510_init.init1(self) 8 | 9 | self._param_buf[0] = 0x6B 10 | self.set_params(0xB500, self._param_mv[:1]) 11 | 12 | _nt35510_init.init2(self) 13 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/nt35510.wip/sdkconfig: -------------------------------------------------------------------------------- 1 | CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=52 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/r61581/r61581.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class R61581(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ra8876/_ra8876_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/rgb_display/rgb_display.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import rgb_display_framework # NOQA 4 | import lvgl as lv 5 | 6 | 7 | STATE_HIGH = rgb_display_framework.STATE_HIGH 8 | STATE_LOW = rgb_display_framework.STATE_LOW 9 | STATE_PWM = rgb_display_framework.STATE_PWM 10 | 11 | BYTE_ORDER_RGB = rgb_display_framework.BYTE_ORDER_RGB 12 | BYTE_ORDER_BGR = rgb_display_framework.BYTE_ORDER_BGR 13 | 14 | 15 | class RGBDisplay(rgb_display_framework.RGBDisplayDriver): 16 | 17 | def __init__( 18 | self, 19 | data_bus, 20 | display_width, 21 | display_height, 22 | frame_buffer1=None, 23 | frame_buffer2=None, 24 | reset_pin=None, 25 | reset_state=STATE_HIGH, 26 | power_pin=None, 27 | power_on_state=STATE_HIGH, 28 | backlight_pin=None, 29 | backlight_on_state=STATE_HIGH, 30 | offset_x=0, 31 | offset_y=0, 32 | color_byte_order=BYTE_ORDER_RGB, 33 | color_space=lv.COLOR_FORMAT.RGB888, # NOQA 34 | rgb565_byte_swap=False, 35 | ): 36 | 37 | self._spi_3wire = None 38 | self._bus_shared_pins = False 39 | 40 | super().__init__( 41 | data_bus=data_bus, 42 | display_width=display_width, 43 | display_height=display_height, 44 | frame_buffer1=frame_buffer1, 45 | frame_buffer2=frame_buffer2, 46 | reset_pin=reset_pin, 47 | reset_state=reset_state, 48 | power_pin=power_pin, 49 | power_on_state=power_on_state, 50 | backlight_pin=backlight_pin, 51 | backlight_on_state=backlight_on_state, 52 | offset_x=offset_x, 53 | offset_y=offset_y, 54 | color_byte_order=color_byte_order, 55 | color_space=color_space, 56 | rgb565_byte_swap=rgb565_byte_swap, 57 | _cmd_bits=8, 58 | _param_bits=8, 59 | _init_bus=True 60 | ) 61 | 62 | def init(self): 63 | rgb_display_framework.RGBDisplayDriver.init(self, None) 64 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/rm68120/rm68120.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | from micropython import const # NOQA 5 | 6 | 7 | _CASET = const(0x2A00) 8 | _PASET = const(0x2B00) 9 | _RAMWR = const(0x2C00) 10 | _MADCTL = const(0x3600) 11 | 12 | STATE_HIGH = display_driver_framework.STATE_HIGH 13 | STATE_LOW = display_driver_framework.STATE_LOW 14 | STATE_PWM = display_driver_framework.STATE_PWM 15 | 16 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 17 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 18 | 19 | 20 | class RM68120(display_driver_framework.DisplayDriver): 21 | _INVOFF = 0x2000 22 | _INVON = 0x2100 23 | 24 | def _set_memory_location(self, x1, y1, x2, y2): 25 | # Column addresses 26 | param_buf = self._param_buf 27 | 28 | param_buf[0] = (x1 >> 8) & 0xFF 29 | param_buf[1] = x1 & 0xFF 30 | param_buf[2] = (x2 >> 8) & 0xFF 31 | param_buf[3] = x2 & 0xFF 32 | 33 | self._data_bus.tx_param(_CASET, self._param_mv[:4]) 34 | 35 | # Page addresses 36 | param_buf[0] = (y1 >> 8) & 0xFF 37 | param_buf[1] = y1 & 0xFF 38 | param_buf[2] = (y2 >> 8) & 0xFF 39 | param_buf[3] = y2 & 0xFF 40 | 41 | self._data_bus.tx_param(_PASET, self._param_mv[:4]) 42 | 43 | return _RAMWR 44 | 45 | def _on_size_change(self, _): 46 | rotation = self._disp_drv.get_rotation() 47 | self._width = self._disp_drv.get_horizontal_resolution() 48 | self._height = self._disp_drv.get_vertical_resolution() 49 | 50 | if rotation == self._rotation: 51 | return 52 | 53 | self._rotation = rotation 54 | 55 | if self._initilized: 56 | param_buf = bytearray([ 57 | 0x00, 58 | self._madctl(self._color_byte_order, ~rotation, self._ORIENTATION_TABLE) # NOQA 59 | ]) 60 | self._data_bus.tx_param(_MADCTL, param_buf) 61 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/rm68140/_rm68140_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import time 5 | 6 | 7 | _SLPOUT = const(0x11) 8 | _MADCTL = const(0x36) 9 | _DISPON = const(0x29) 10 | 11 | 12 | def init(self): 13 | param_buf = bytearray(12) 14 | param_mv = memoryview(param_buf) 15 | 16 | time.sleep_ms(20) # NOQA 17 | self.set_params(_SLPOUT) 18 | 19 | param_buf[0] = 0x07 20 | param_buf[1] = 0x42 21 | param_buf[2] = 0x18 22 | self.set_params(0xD0, param_mv[:3]) 23 | 24 | param_buf[0] = 0x00 25 | param_buf[1] = 0x07 26 | param_buf[2] = 0x10 27 | self.set_params(0xD1, param_mv[:3]) 28 | 29 | param_buf[0] = 0x01 30 | param_buf[1] = 0x02 31 | self.set_params(0xD2, param_mv[:2]) 32 | 33 | param_buf[0] = 0x10 34 | param_buf[1] = 0x3B 35 | param_buf[2] = 0x00 36 | param_buf[3] = 0x02 37 | param_buf[4] = 0x11 38 | self.set_params(0xC0, param_mv[:5]) 39 | 40 | param_buf[0] = 0x03 41 | self.set_params(0xC5, param_mv[:1]) 42 | 43 | param_buf[0] = 0x00 44 | param_buf[1] = 0x32 45 | param_buf[2] = 0x36 46 | param_buf[3] = 0x45 47 | param_buf[4] = 0x06 48 | param_buf[5] = 0x16 49 | param_buf[6] = 0x37 50 | param_buf[7] = 0x75 51 | param_buf[8] = 0x77 52 | param_buf[9] = 0x54 53 | param_buf[10] = 0x0C 54 | param_buf[11] = 0x00 55 | self.set_params(0xC8, param_mv[:12]) 56 | 57 | param_buf[0] = 0x0A 58 | self.set_params(_MADCTL, param_mv[:1]) 59 | 60 | param_buf[0] = 0x55 61 | self.set_params(0x3A, param_mv[:1]) 62 | 63 | time.sleep_ms(120) # NOQA 64 | self.set_params(_DISPON) 65 | 66 | time.sleep_ms(25) # NOQA 67 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/rm68140/rm68140.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class RM68140(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/s6d02a1/s6d02a1.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class S6D02A1(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1306/_ssd1306_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | 5 | _SET_CONTRAST = const(0x81) 6 | _SET_ENTIRE_ON = const(0xA4) 7 | _SET_NORM_INV = const(0xA6) 8 | _DISP_OFF = const(0xAE) 9 | _DISP_ON = const(0xAF) 10 | _SET_MEM_ADDR = const(0x20) 11 | _SET_COL_ADDR = const(0x21) 12 | _SET_PAGE_ADDR = const(0x22) 13 | _SET_DISP_START_LINE = const(0x40) 14 | _SET_SEG_REMAP = const(0xA0) 15 | _SET_MUX_RATIO = const(0xA8) 16 | _SET_COM_OUT_DIR = const(0xC0) 17 | _SET_DISP_OFFSET = const(0xD3) 18 | _SET_COM_PIN_CFG = const(0xDA) 19 | _SET_DISP_CLK_DIV = const(0xD5) 20 | _SET_PRECHARGE = const(0xD9) 21 | _SET_VCOM_DESEL = const(0xDB) 22 | _SET_CHARGE_PUMP = const(0x8D) 23 | 24 | 25 | def init(self): 26 | param_buf = bytearray(1) 27 | param_mv = bytearray(param_buf) 28 | 29 | self.set_params(_DISP_OFF) 30 | 31 | param_buf[0] = 0x00 32 | self.set_params(_SET_MEM_ADDR, param_mv[:1]) 33 | 34 | self.set_params(_SET_DISP_START_LINE | 0x00) 35 | 36 | self.set_params(_SET_SEG_REMAP | 0x01) 37 | 38 | param_buf[0] = self.height - 1 39 | self.set_params(_SET_MUX_RATIO, param_mv[:1]) 40 | 41 | self.set_params(_SET_COM_OUT_DIR | 0x08) 42 | 43 | param_buf[0] = 0x00 44 | self.set_params(_SET_DISP_OFFSET, param_mv[:1]) 45 | 46 | if self.width > 2 * self.height: 47 | param_buf[0] = 0x02 48 | else: 49 | param_buf[0] = 0x12 50 | self.set_params(_SET_COM_PIN_CFG, param_mv[:1]) 51 | 52 | param_buf[0] = 0x80 53 | self.set_params(_SET_DISP_CLK_DIV, param_mv[:1]) 54 | 55 | if self._power_pin is not None: 56 | param_buf[0] = 0x22 57 | else: 58 | param_buf[0] = 0xF1 59 | 60 | self.set_params(_SET_PRECHARGE, param_mv[:1]) 61 | 62 | param_buf[0] = 0x30 63 | self.set_params(_SET_VCOM_DESEL, param_mv[:1]) 64 | 65 | param_buf[0] = 0xFF 66 | self.set_params(_SET_CONTRAST, param_mv[:1]) 67 | 68 | self.set_params(_SET_ENTIRE_ON) 69 | 70 | self.set_params(_SET_NORM_INV) 71 | 72 | if self._power_pin is not None: 73 | param_buf[0] = 0x10 74 | else: 75 | param_buf[0] = 0x14 76 | self.set_params(_SET_CHARGE_PUMP, param_mv[:1]) 77 | 78 | self.set_params(_DISP_ON) 79 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1351/_ssd1351_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | def init(self): 4 | param_buf = bytearray(14) 5 | param_mv = memoryview(param_buf) 6 | 7 | param_buf[0] = 0x12 8 | self.set_params(0xFD, param_mv[:1]) 9 | 10 | param_buf[0] = 0xB1 11 | self.set_params(0xFD, param_mv[:1]) 12 | 13 | self.set_params(0xAE) 14 | 15 | param_buf[0] = 0xF1 16 | self.set_params(0xB3, param_mv[:1]) 17 | 18 | param_buf[0] = 127 19 | self.set_params(0xCA, param_mv[:1]) 20 | 21 | param_buf[0] = 0x00 22 | self.set_params(0xA2, param_mv[:1]) 23 | 24 | param_buf[0] = 0x00 25 | self.set_params(0xB5, param_mv[:1]) 26 | 27 | param_buf[0] = 0x01 28 | self.set_params(0xAB, param_mv[:1]) 29 | 30 | param_buf[0] = 0x32 31 | self.set_params(0xB1, param_mv[:1]) 32 | 33 | param_buf[0] = 0x05 34 | self.set_params(0xBE, param_mv[:1]) 35 | 36 | self.set_params(0xA6) 37 | 38 | param_buf[0] = 0xC8 39 | param_buf[1] = 0x80 40 | param_buf[2] = 0xC8 41 | self.set_params(0xC1, param_mv[:3]) 42 | 43 | param_buf[0] = 0x0F 44 | self.set_params(0xC7, param_mv[:1]) 45 | 46 | param_buf[0] = 0xA0 47 | param_buf[1] = 0xB5 48 | param_buf[2] = 0x55 49 | self.set_params(0xB4, param_mv[:3]) 50 | 51 | param_buf[0] = 0x01 52 | self.set_params(0xB6, param_mv[:1]) 53 | 54 | self.set_params(0xAF) 55 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1351/ssd1351.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import display_driver_framework 5 | 6 | 7 | _CASET = const(0x15) 8 | _PASET = const(0x75) 9 | _RAMWR = const(0x5C) 10 | 11 | STATE_HIGH = display_driver_framework.STATE_HIGH 12 | STATE_LOW = display_driver_framework.STATE_LOW 13 | STATE_PWM = display_driver_framework.STATE_PWM 14 | 15 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 16 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 17 | 18 | 19 | class SSD1351(display_driver_framework.DisplayDriver): 20 | _INVOFF = 0xA6 21 | _INVON = 0xA7 22 | 23 | def _set_memory_location(self, x1, y1, x2, y2): 24 | # Column addresses 25 | param_buf = self._param_buf 26 | 27 | param_buf[0] = (x1 >> 8) & 0xFF 28 | param_buf[1] = x1 & 0xFF 29 | param_buf[2] = (x2 >> 8) & 0xFF 30 | param_buf[3] = x2 & 0xFF 31 | 32 | self._data_bus.tx_param(_CASET, self._param_mv[:4]) 33 | 34 | # Page addresses 35 | param_buf[0] = (y1 >> 8) & 0xFF 36 | param_buf[1] = y1 & 0xFF 37 | param_buf[2] = (y2 >> 8) & 0xFF 38 | param_buf[3] = y2 & 0xFF 39 | 40 | self._data_bus.tx_param(_PASET, self._param_mv[:4]) 41 | 42 | return _RAMWR 43 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1963/_ssd1963_init_type3.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import time 4 | from micropython import const # NOQA 5 | 6 | 7 | def init(self): 8 | param_buf = bytearray(8) 9 | param_mv = memoryview(param_buf) 10 | 11 | param_buf[0] = 0x23 12 | param_buf[1] = 0x02 13 | param_buf[2] = 0x04 14 | self.set_params(0xE2, param_mv[:3]) 15 | 16 | param_buf[0] = 0x01 17 | self.set_params(0xE0, param_mv[:1]) 18 | 19 | time.sleep_ms(10) # NOQA 20 | param_buf[0] = 0x03 21 | self.set_params(0xE0, param_mv[:1]) 22 | 23 | time.sleep_ms(10) # NOQA 24 | self.set_params(0x01) 25 | 26 | time.sleep_ms(100) # NOQA 27 | param_buf[0] = 0x04 28 | param_buf[1] = 0x93 29 | param_buf[2] = 0xE0 30 | self.set_params(0xE6, param_mv[:3]) 31 | 32 | param_buf[0] = 0x00 33 | param_buf[1] = 0x00 34 | param_buf[2] = 0x03 35 | param_buf[3] = 0x1F 36 | param_buf[4] = 0x01 37 | param_buf[5] = 0xDF 38 | param_buf[6] = 0x00 39 | self.set_params(0xB0, param_mv[:7]) 40 | 41 | param_buf[0] = 0x03 42 | param_buf[1] = 0xA0 43 | param_buf[2] = 0x00 44 | param_buf[3] = 0x2E 45 | param_buf[4] = 0x30 46 | param_buf[5] = 0x00 47 | param_buf[6] = 0x0F 48 | param_buf[7] = 0x00 49 | self.set_params(0xB4, param_mv[:8]) 50 | 51 | param_buf[0] = 0x02 52 | param_buf[1] = 0x0D 53 | param_buf[2] = 0x00 54 | param_buf[3] = 0x10 55 | param_buf[4] = 0x10 56 | param_buf[5] = 0x00 57 | param_buf[6] = 0x08 58 | self.set_params(0xB6, param_mv[:7]) 59 | 60 | param_buf[0] = 0x05 61 | self.set_params(0xBA, param_mv[:1]) 62 | 63 | param_buf[0] = 0x07 64 | param_buf[1] = 0x01 65 | self.set_params(0xB8, param_mv[:2]) 66 | 67 | param_buf[0] = 0x21 # | TFT_MAD_COLOR_ORDER 68 | self.set_params(0x36, param_mv[:1]) 69 | 70 | param_buf[0] = 0x00 71 | self.set_params(0xF0, param_mv[:1]) 72 | 73 | time.sleep_ms(10) # NOQA 74 | param_buf[0] = 0 75 | param_buf[1] = 0 76 | param_buf[2] = (479 & 0xFF00) >> 8 77 | param_buf[3] = 479 & 0xFF 78 | self.set_params(0x2A, param_mv[:4]) 79 | 80 | param_buf[0] = 0 81 | param_buf[1] = 0 82 | param_buf[2] = (799 & 0xFF00) >> 8 83 | param_buf[3] = 799 & 0xFF 84 | self.set_params(0x2B, param_mv[:4]) 85 | 86 | self.set_params(0x2C) 87 | 88 | self.set_params(0x29) 89 | 90 | param_buf[0] = 0x06 91 | param_buf[1] = 0xF0 92 | param_buf[2] = 0x01 93 | param_buf[3] = 0xF0 94 | param_buf[4] = 0x00 95 | param_buf[5] = 0x00 96 | self.set_params(0xBE, param_mv[:6]) 97 | 98 | param_buf[0] = 0x0D 99 | self.set_params(0xD0, param_mv[:1]) 100 | 101 | self.set_params(0x2C) 102 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1963/_ssd1963_init_type4.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import time 4 | from micropython import const # NOQA 5 | 6 | 7 | def init(self): 8 | param_buf = bytearray(8) 9 | param_mv = memoryview(param_buf) 10 | 11 | param_buf[0] = 0x23 12 | param_buf[1] = 0x02 13 | param_buf[2] = 0x54 14 | self.set_params(0xE2, param_mv[:3]) 15 | 16 | param_buf[0] = 0x01 17 | self.set_params(0xE0, param_mv[:1]) 18 | 19 | time.sleep_ms(10) # NOQA 20 | param_buf[0] = 0x03 21 | self.set_params(0xE0, param_mv[:1]) 22 | 23 | time.sleep_ms(10) # NOQA 24 | self.set_params(0x01) 25 | 26 | time.sleep_ms(100) # NOQA 27 | param_buf[0] = 0x03 28 | param_buf[1] = 0x33 29 | param_buf[2] = 0x33 30 | self.set_params(0xE6, param_mv[:3]) 31 | 32 | param_buf[0] = 0x20 33 | param_buf[1] = 0x00 34 | param_buf[2] = 799 >> 8 35 | param_buf[3] = 799 & 0xFF 36 | param_buf[4] = 479 >> 8 37 | param_buf[5] = 479 & 0xFF 38 | param_buf[6] = 0x00 39 | self.set_params(0xB0, param_mv[:7]) 40 | 41 | param_buf[0] = 0x04 42 | param_buf[1] = 0x1F 43 | param_buf[2] = 0x00 44 | param_buf[3] = 0xD2 45 | param_buf[4] = 0x00 46 | param_buf[5] = 0x00 47 | param_buf[6] = 0x00 48 | param_buf[7] = 0x00 49 | self.set_params(0xB4, param_mv[:8]) 50 | 51 | param_buf[0] = 0x02 52 | param_buf[1] = 0x0C 53 | param_buf[2] = 0x00 54 | param_buf[3] = 0x22 55 | param_buf[4] = 0x00 56 | param_buf[5] = 0x00 57 | param_buf[6] = 0x00 58 | self.set_params(0xB6, param_mv[:7]) 59 | 60 | param_buf[0] = 0x0F 61 | param_buf[1] = 0x01 62 | self.set_params(0xB8, param_mv[:2]) 63 | 64 | param_buf[0] = 0x01 65 | self.set_params(0xBA, param_mv[:1]) 66 | 67 | param_buf[0] = 0x21 # | TFT_MAD_COLOR_ORDER 68 | self.set_params(0x36, param_mv[:1]) 69 | 70 | param_buf[0] = 0x00 71 | self.set_params(0xF0, param_mv[:1]) 72 | 73 | param_buf[0] = 0x40 74 | param_buf[1] = 0x80 75 | param_buf[2] = 0x40 76 | param_buf[3] = 0x01 77 | self.set_params(0xBC, param_mv[:4]) 78 | 79 | time.sleep_ms(10) # NOQA 80 | self.set_params(0x29) 81 | 82 | param_buf[0] = 0x06 83 | param_buf[1] = 0x80 84 | param_buf[2] = 0x01 85 | param_buf[3] = 0xF0 86 | param_buf[4] = 0x00 87 | param_buf[5] = 0x00 88 | self.set_params(0xBE, param_mv[:6]) 89 | 90 | param_buf[0] = 0x0D 91 | self.set_params(0xD0, param_mv[:1]) 92 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/ssd1963/ssd1963.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | TYPE_480 = 1 7 | TYPE_800 = 2 8 | TYPE_800ALT = 3 9 | TYPE_800BD = 4 10 | 11 | STATE_HIGH = display_driver_framework.STATE_HIGH 12 | STATE_LOW = display_driver_framework.STATE_LOW 13 | STATE_PWM = display_driver_framework.STATE_PWM 14 | 15 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 16 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 17 | 18 | 19 | class SSD1963(display_driver_framework.DisplayDriver): 20 | pass 21 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/st7565/_st7565_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import time 5 | 6 | 7 | _DISPLAY_OFF = const(0xAE) 8 | _DISPLAY_ON = const(0xAF) 9 | 10 | _DISP_START_LINE = const(0x40) 11 | _PAGE = const(0xB0) 12 | 13 | _COLUMN_UPPER = const(0x10) 14 | _COLUMN_LOWER = const(0x00) 15 | 16 | _ADC_NORMAL = const(0xA0) 17 | _ADC_REVERSE = const(0xA1) 18 | 19 | _DISP_NORMAL = const(0xA6) 20 | _DISP_REVERSE = const(0xA7) 21 | 22 | _ALLPTS_NORMAL = const(0xA4) 23 | _ALLPTS_ON = const(0xA5) 24 | _BIAS_9 = const(0xA2) 25 | _BIAS_7 = const(0xA3) 26 | 27 | _RMW = const(0xE0) 28 | _RMW_CLEAR = const(0xEE) 29 | _INTERNAL_RESET = const(0xE2) 30 | _COM_NORMAL = const(0xC0) 31 | _COM_REVERSE = const(0xC8) 32 | _POWER_CONTROL = const(0x28) 33 | _RESISTOR_RATIO = const(0x20) 34 | _VOLUME_FIRST = const(0x81) 35 | _VOLUME_SECOND = const(0x00) 36 | _STATIC_OFF = const(0xAC) 37 | _STATIC_ON = const(0xAD) 38 | _STATIC_REG = const(0x00) 39 | _BOOSTER_FIRST = const(0xF8) 40 | _BOOSTER_234 = const(0x00) 41 | _BOOSTER_5 = const(0x01) 42 | _BOOSTER_6 = const(0x03) 43 | _NOP = const(0xE3) 44 | _TEST = const(0xF0) 45 | 46 | 47 | def init(self): 48 | self.reset() 49 | 50 | self.set_params(_BIAS_7) 51 | self.set_params(_ADC_NORMAL) 52 | self.set_params(_COM_NORMAL) 53 | self.set_params(_DISP_START_LINE) 54 | self.set_params(_POWER_CONTROL | 0x4) 55 | time.sleep_ms(50) # NOQA 56 | 57 | self.set_params(_POWER_CONTROL | 0x6) 58 | time.sleep_ms(50) # NOQA 59 | 60 | self.set_params(_POWER_CONTROL | 0x7) 61 | time.sleep_ms(10) # NOQA 62 | 63 | # Defaulted to 0x26 (but could also be between 64 | # 0x20-0x27 based on display's specs) 65 | self.set_params(_RESISTOR_RATIO | 0x6) 66 | 67 | self.set_params(_DISPLAY_ON) 68 | self.set_params(_ALLPTS_NORMAL) 69 | 70 | # Set brightness 71 | self.set_params(_VOLUME_FIRST) 72 | self.set_params(_VOLUME_SECOND | (0x18 & 0x3f)) 73 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/st7565/st7565.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import display_driver_framework 4 | 5 | 6 | STATE_HIGH = display_driver_framework.STATE_HIGH 7 | STATE_LOW = display_driver_framework.STATE_LOW 8 | STATE_PWM = display_driver_framework.STATE_PWM 9 | 10 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 11 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 12 | 13 | 14 | class ST7565(display_driver_framework.DisplayDriver): 15 | pass 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/st7735/st7735.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import display_driver_framework 5 | 6 | 7 | STATE_HIGH = display_driver_framework.STATE_HIGH 8 | STATE_LOW = display_driver_framework.STATE_LOW 9 | STATE_PWM = display_driver_framework.STATE_PWM 10 | 11 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 12 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 13 | 14 | _MADCTL_MY = const(0x80) 15 | _MADCTL_MX = const(0x40) 16 | _MADCTL_MV = const(0x20) 17 | 18 | 19 | TYPE_B = 1 20 | TYPE_R_RED = 2 21 | TYPE_R_GREEN = 3 22 | 23 | 24 | class ST7735(display_driver_framework.DisplayDriver): 25 | 26 | def init(self, type): # NOQA 27 | if type == 1: 28 | ST7735._ORIENTATION_TABLE = ( 29 | 0x0, 30 | _MADCTL_MX | _MADCTL_MV, 31 | _MADCTL_MY | _MADCTL_MX, 32 | _MADCTL_MY | _MADCTL_MV 33 | ) 34 | elif type == 2: 35 | ST7735._ORIENTATION_TABLE = ( 36 | 0x0, 37 | _MADCTL_MX | _MADCTL_MV, 38 | _MADCTL_MY | _MADCTL_MX, 39 | _MADCTL_MY | _MADCTL_MV 40 | ) 41 | else: 42 | ST7735._ORIENTATION_TABLE = ( 43 | 0x0, 44 | _MADCTL_MV | _MADCTL_MY, 45 | _MADCTL_MY | _MADCTL_MX, 46 | _MADCTL_MV | _MADCTL_MX 47 | ) 48 | display_driver_framework.DisplayDriver.init(self, type) # NOQA 49 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/st7789/st7789.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import display_driver_framework 5 | import lcd_bus 6 | import lvgl as lv 7 | 8 | 9 | STATE_HIGH = display_driver_framework.STATE_HIGH 10 | STATE_LOW = display_driver_framework.STATE_LOW 11 | STATE_PWM = display_driver_framework.STATE_PWM 12 | 13 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 14 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 15 | 16 | _MADCTL_MV = const(0x20) # 0=Normal, 1=Row/column exchange 17 | _MADCTL_MX = const(0x40) # 0=Left to Right, 1=Right to Left 18 | _MADCTL_MY = const(0x80) # 0=Top to Bottom, 1=Bottom to Top 19 | 20 | 21 | class ST7789(display_driver_framework.DisplayDriver): 22 | _ORIENTATION_TABLE = ( 23 | 0x0, 24 | _MADCTL_MV | _MADCTL_MX, 25 | _MADCTL_MY | _MADCTL_MX, 26 | _MADCTL_MV | _MADCTL_MY 27 | ) 28 | 29 | def __init__( 30 | self, 31 | data_bus, 32 | display_width, 33 | display_height, 34 | frame_buffer1=None, 35 | frame_buffer2=None, 36 | reset_pin=None, 37 | reset_state=STATE_HIGH, 38 | power_pin=None, 39 | power_on_state=STATE_HIGH, 40 | backlight_pin=None, 41 | backlight_on_state=STATE_HIGH, 42 | offset_x=0, 43 | offset_y=0, 44 | color_byte_order=BYTE_ORDER_RGB, 45 | color_space=lv.COLOR_FORMAT.RGB888, # NOQA 46 | rgb565_byte_swap=False, 47 | ): 48 | 49 | if color_space != lv.COLOR_FORMAT.RGB565: # NOQA 50 | rgb565_byte_swap = False 51 | 52 | self._rgb565_byte_swap = rgb565_byte_swap 53 | 54 | if ( 55 | isinstance(data_bus, lcd_bus.I80Bus) and 56 | data_bus.get_lane_count() == 8 57 | ): 58 | rgb565_byte_swap = False 59 | 60 | super().__init__( 61 | data_bus=data_bus, 62 | display_width=display_width, 63 | display_height=display_height, 64 | frame_buffer1=frame_buffer1, 65 | frame_buffer2=frame_buffer2, 66 | reset_pin=reset_pin, 67 | reset_state=reset_state, 68 | power_pin=power_pin, 69 | power_on_state=power_on_state, 70 | backlight_pin=backlight_pin, 71 | backlight_on_state=backlight_on_state, 72 | offset_x=offset_x, 73 | offset_y=offset_y, 74 | color_byte_order=color_byte_order, 75 | color_space=color_space, # NOQA 76 | rgb565_byte_swap=rgb565_byte_swap, 77 | _cmd_bits=8, 78 | _param_bits=8, 79 | _init_bus=True 80 | ) 81 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/display/st7796/st7796.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import display_driver_framework 5 | 6 | 7 | STATE_HIGH = display_driver_framework.STATE_HIGH 8 | STATE_LOW = display_driver_framework.STATE_LOW 9 | STATE_PWM = display_driver_framework.STATE_PWM 10 | 11 | BYTE_ORDER_RGB = display_driver_framework.BYTE_ORDER_RGB 12 | BYTE_ORDER_BGR = display_driver_framework.BYTE_ORDER_BGR 13 | 14 | _MADCTL_MV = const(0x20) 15 | _MADCTL_MX = const(0x40) 16 | _MADCTL_MY = const(0x80) 17 | 18 | 19 | class ST7796(display_driver_framework.DisplayDriver): 20 | 21 | _ORIENTATION_TABLE = ( 22 | _MADCTL_MX, 23 | _MADCTL_MV | _MADCTL_MY | _MADCTL_MX, 24 | _MADCTL_MY, 25 | _MADCTL_MV 26 | ) 27 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/frozen/mp_i2c_common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include 4 | 5 | #include "py/obj.h" 6 | #include "py/runtime.h" 7 | 8 | #include "freertos/FreeRTOS.h" 9 | #include "freertos/task.h" 10 | #include "freertos/semphr.h" 11 | 12 | #ifndef __MP_I2C_COMMON_H__ 13 | #define __MP_I2C_COMMON_H__ 14 | 15 | #define I2C_MAX_DEVICES (31) 16 | 17 | typedef struct _mp_machine_hw_i2c_bus_obj_t mp_machine_hw_i2c_bus_obj_t; 18 | typedef struct _mp_machine_hw_i2c_device_obj_t mp_machine_hw_i2c_device_obj_t; 19 | 20 | typedef struct _i2c_bus_lock_t { 21 | SemaphoreHandle_t handle; 22 | StaticSemaphore_t buffer; 23 | } i2c_bus_lock_t; 24 | 25 | 26 | struct _mp_machine_hw_i2c_bus_obj_t { 27 | mp_obj_base_t base; 28 | i2c_port_t port : 8; 29 | gpio_num_t scl : 8; 30 | gpio_num_t sda : 8; 31 | uint8_t active : 1; 32 | uint8_t device_count : 5; 33 | mp_machine_hw_i2c_device_obj_t **devices; 34 | uint32_t freq; 35 | uint32_t timeout_us; 36 | uint8_t use_locks : 1; 37 | uint8_t pullup : 1; 38 | i2c_bus_lock_t lock; 39 | }; 40 | 41 | struct _mp_machine_hw_i2c_device_obj_t { 42 | mp_obj_base_t base; 43 | uint16_t device_id; 44 | uint8_t reg_bits; 45 | mp_machine_hw_i2c_bus_obj_t *bus; 46 | }; 47 | 48 | extern const mp_obj_type_t mp_machine_hw_i2c_device_type; 49 | extern const mp_obj_type_t mp_machine_hw_i2c_bus_type; 50 | 51 | void mp_machine_hw_i2c_bus_deinit_all(void); 52 | 53 | #endif /* __MP_I2C_COMMON_H__ */ 54 | 55 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/include/common.h: -------------------------------------------------------------------------------- 1 | #ifndef __LVMP_DRV_COMMON_H 2 | #define __LVMP_DRV_COMMON_H 3 | 4 | #include "py/obj.h" 5 | #include "py/runtime.h" 6 | #include "py/binary.h" 7 | 8 | ////////////////////////////////////////////////////////////////////////////// 9 | // A read-only buffer that contains a C pointer 10 | // Used to communicate function pointers to lvgl Micropython bindings 11 | // 12 | 13 | typedef struct mp_ptr_t 14 | { 15 | mp_obj_base_t base; 16 | void *ptr; 17 | } mp_ptr_t; 18 | 19 | STATIC mp_int_t mp_ptr_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) 20 | { 21 | mp_ptr_t *self = MP_OBJ_TO_PTR(self_in); 22 | 23 | if (flags & MP_BUFFER_WRITE) { 24 | // read-only ptr 25 | return 1; 26 | } 27 | 28 | bufinfo->buf = &self->ptr; 29 | bufinfo->len = sizeof(self->ptr); 30 | bufinfo->typecode = BYTEARRAY_TYPECODE; 31 | return 0; 32 | } 33 | 34 | #define PTR_OBJ(ptr_global) ptr_global ## _obj 35 | 36 | #define DEFINE_PTR_OBJ_TYPE(ptr_obj_type, ptr_type_qstr)\ 37 | STATIC MP_DEFINE_CONST_OBJ_TYPE(\ 38 | ptr_obj_type,\ 39 | ptr_type_qstr,\ 40 | MP_TYPE_FLAG_NONE,\ 41 | buffer, mp_ptr_get_buffer\ 42 | ); 43 | 44 | #define DEFINE_PTR_OBJ(ptr_global)\ 45 | DEFINE_PTR_OBJ_TYPE(ptr_global ## _type, MP_QSTR_ ## ptr_global);\ 46 | STATIC const mp_ptr_t PTR_OBJ(ptr_global) = {\ 47 | { &ptr_global ## _type },\ 48 | &ptr_global\ 49 | } 50 | 51 | #define NEW_PTR_OBJ(name, value)\ 52 | ({\ 53 | DEFINE_PTR_OBJ_TYPE(ptr_obj_type, MP_QSTR_ ## name);\ 54 | mp_ptr_t *self = m_new_obj(mp_ptr_t);\ 55 | self->base.type = &ptr_obj_type;\ 56 | self->ptr = value;\ 57 | MP_OBJ_FROM_PTR(self);\ 58 | }) 59 | 60 | #endif // __LVMP_DRV_COMMON_H 61 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/axs15231.py: -------------------------------------------------------------------------------- 1 | # Based on the work by straga (https://github.com/straga) 2 | # https://github.com/straga/micropython_lcd/blob/master/device/JC3248W535/driver/axs15231b/axs15231_touch.py 3 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 4 | 5 | from micropython import const # NOQA 6 | import pointer_framework 7 | 8 | 9 | # Constants 10 | _AXS_MAX_TOUCH_NUMBER = const(1) 11 | _AXS_TOUCH_POINT_NUM = const(1) 12 | I2C_ADDR = 0x3B 13 | BITS = 8 14 | 15 | 16 | class TouchRecord: 17 | def __init__(self): 18 | self.gesture = 0 19 | self.num = 0 20 | self.x = 0 21 | self.y = 0 22 | self.event = 0 23 | 24 | 25 | class AXS15231(pointer_framework.PointerDriver): 26 | 27 | def __init__( 28 | self, 29 | device, 30 | touch_cal=None, 31 | startup_rotation=lv.DISPLAY_ROTATION._0, # NOQA 32 | debug=False 33 | ): 34 | self._device = device 35 | 36 | super().__init__(touch_cal, startup_rotation, debug) 37 | 38 | self._tx_buf = bytearray( 39 | [0xB5, 0xAB, 0xA5, 0x5A, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00] 40 | ) 41 | self._tx_mv = memoryview(self._tx_buf) 42 | 43 | self._rx_buf = bytearray(8) 44 | self._rx_mv = memoryview(self._rx_buf) 45 | 46 | def _read_data(self): 47 | self._device.write(self._tx_mv) 48 | self._device.read(buf=self._rx_mv) 49 | 50 | touch_points = [] 51 | data = self._rx_buf 52 | 53 | num_points = data[_AXS_TOUCH_POINT_NUM] 54 | 55 | if num_points and num_points <= _AXS_MAX_TOUCH_NUMBER: 56 | for i in range(num_points): 57 | offset = i * 6 58 | record = TouchRecord() 59 | record.gesture = data[offset] 60 | record.num = data[offset + 1] 61 | record.x = ((data[offset + 2] & 0x0F) << 8) | data[offset + 3] 62 | record.y = ((data[offset + 4] & 0x0F) << 8) | data[offset + 5] 63 | record.event = (data[offset + 2] >> 6) & 0x03 64 | touch_points.append(record) 65 | 66 | return touch_points 67 | 68 | def _get_coords(self): 69 | touch_data = self._read_data() 70 | 71 | if touch_data: 72 | x = touch_data[0].x 73 | y = touch_data[0].y 74 | 75 | if touch_data[0].event == 1: 76 | return self.RELEASED, x, y 77 | 78 | return self.PRESSED, x, y 79 | else: 80 | return None 81 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/cst340.py.wip: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | 0x8140 Product ID 4 | 0x8141 Product ID 5 | 0x8142 Product ID 6 | 0x8143 Product ID 7 | 8 | 9 | 0x8144 Firmware version 10 | 0x8145 Firmware version 11 | 12 | 0x8146 x coordinate resolution 13 | 0x8147 x coordinate resolution 14 | 15 | 0x8148 y coordinate resolution 16 | 0x8149 y coordinate resolution 17 | 18 | 0x814A Vendor_id 19 | 20 | 0x814E buffer status | large detect | Reserved | HaveKey | number of touch points 21 | 22 | 0x8158 point 1 x coordinate 23 | 0x8159 point 1 x coordinate 24 | 25 | 0x815A point 1 y coordinate 26 | 0x815B point 1 y coordinate 27 | 28 | 29 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/evdev/button.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import struct 4 | import select 5 | import button_framework 6 | import lvgl as lv # NOQA 7 | 8 | 9 | 10 | 11 | 12 | class EvdevButtonDriver(button_framework.ButtonDriver): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/evdev/fnctl.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import ffi # NOQA 4 | import os 5 | import ffilib # NOQA 6 | 7 | 8 | libc = ffilib.libc() 9 | 10 | fcntl_l = libc.func("i", "fcntl", "iil") 11 | fcntl_s = libc.func("i", "fcntl", "iip") 12 | ioctl_l = libc.func("i", "ioctl", "iil") 13 | 14 | 15 | def fcntl(fd, op, arg=0): 16 | if type(arg) is int: 17 | r = fcntl_l(fd, op, arg) 18 | return r 19 | else: 20 | r = fcntl_s(fd, op, arg) 21 | return r 22 | 23 | 24 | def ioctl(fd, op, arg): 25 | if type(arg) is int: 26 | r = ioctl_l(fd, op, arg) 27 | return r 28 | else: 29 | r = ioctl_s(fd, op, arg) 30 | return r 31 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/evdev/joystick.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import struct 4 | import select 5 | import keypad_framework 6 | import lvgl as lv # NOQA 7 | 8 | 9 | 10 | 11 | 12 | class EvdevJoystickDriver(keypad_framework.KeypadDriver): 13 | pass 14 | 15 | 16 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/evdev/keyboard.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import struct 4 | import select 5 | import keypad_framework 6 | import lvgl as lv # NOQA 7 | 8 | 9 | 10 | class EvdevKeyboardDriver(keypad_framework.KeypadDriver): 11 | pass 12 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/evdev/mousewheel.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import struct 4 | import select 5 | import encoder_framework 6 | import lvgl as lv # NOQA 7 | 8 | 9 | class EvdevMouseWheelDriver(encoder_framework.EncoderDriver): 10 | pass 11 | 12 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft5x06.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT5206/FT5306/FT5406 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | _DEV_MODE = const(0x00) 10 | _GEST_ID = const(0x01) 11 | _TD_STATUS = const(0x02) 12 | 13 | I2C_ADDR = 0x38 14 | BITS = 8 15 | 16 | _FT5x06_CHIPID = const(0x55) 17 | 18 | 19 | class FT5x06(focaltech_touch.FocalTechTouch): 20 | 21 | def __init__( 22 | self, 23 | device, 24 | touch_cal=None, 25 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 26 | debug=False 27 | ): # NOQA 28 | 29 | super().__init__( 30 | device, 31 | touch_cal, 32 | startup_rotation, 33 | debug, 34 | (2.24, 2.14), 35 | _FT5x06_CHIPID 36 | ) 37 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft5x16.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT5216/FT5316 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | 10 | I2C_ADDR = 0x38 11 | BITS = 8 12 | 13 | _FT5x16_CHIPID = const(0x0A) 14 | 15 | 16 | class FT5x16(focaltech_touch.FocalTechTouch): 17 | 18 | def __init__( 19 | self, 20 | device, 21 | touch_cal=None, 22 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 23 | debug=False 24 | ): # NOQA 25 | 26 | super().__init__( 27 | device, 28 | touch_cal, 29 | startup_rotation, 30 | debug, 31 | (2.24, 2.14), 32 | _FT5x16_CHIPID 33 | ) 34 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft5x26.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT5426DQ8/FT5526EEZ 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | _DEV_MODE = const(0x00) 10 | _GEST_ID = const(0x01) 11 | _TD_STATUS = const(0x02) 12 | 13 | I2C_ADDR = 0x38 14 | BITS = 8 15 | 16 | _FT5x26_CHIPID = const(0x54) 17 | 18 | 19 | class FT5x26(focaltech_touch.FocalTechTouch): 20 | 21 | def __init__( 22 | self, 23 | device, 24 | touch_cal=None, 25 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 26 | debug=False 27 | ): # NOQA 28 | 29 | super().__init__( 30 | device, 31 | touch_cal, 32 | startup_rotation, 33 | debug, 34 | (2.24, 2.14), 35 | _FT5x26_CHIPID 36 | ) 37 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft5x36.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import focaltech_touch 5 | import pointer_framework 6 | 7 | _DEV_MODE = const(0x00) 8 | _GEST_ID = const(0x01) 9 | _TD_STATUS = const(0x02) 10 | 11 | I2C_ADDR = 0x38 12 | BITS = 8 13 | 14 | _FT5x36_CHIPID_1 = const(0x11) 15 | _FT5x36_CHIPID_2 = const(0x12) 16 | _FT5x36_CHIPID_3 = const(0x14) 17 | 18 | 19 | class FT5x36(focaltech_touch.FocalTechTouch): 20 | 21 | def __init__( 22 | self, 23 | device, 24 | touch_cal=None, 25 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 26 | debug=False 27 | ): # NOQA 28 | 29 | super().__init__( 30 | device, 31 | touch_cal, 32 | startup_rotation, 33 | debug, 34 | (2.24, 2.14), 35 | _FT5x36_CHIPID_1, 36 | _FT5x36_CHIPID_2, 37 | _FT5x36_CHIPID_3 38 | ) 39 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft5x46.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT5346/FT5446/FT5446S 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | _DEV_MODE = const(0x00) 10 | _GEST_ID = const(0x01) 11 | _TD_STATUS = const(0x02) 12 | 13 | I2C_ADDR = 0x38 14 | BITS = 8 15 | 16 | _FT5x46_CHIPID = const(0x54) 17 | 18 | 19 | class FT5x46(focaltech_touch.FocalTechTouch): 20 | 21 | def __init__( 22 | self, 23 | device, 24 | touch_cal=None, 25 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 26 | debug=False 27 | ): # NOQA 28 | 29 | super().__init__( 30 | device, 31 | touch_cal, 32 | startup_rotation, 33 | debug, 34 | (2.24, 2.14), 35 | _FT5x46_CHIPID 36 | ) 37 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft6x06.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT6206/FT6306 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | I2C_ADDR = 0x38 10 | BITS = 8 11 | 12 | _FT6206_CHIPID = const(0x06) 13 | _FT6x06_CHIPID = const(0x11) 14 | 15 | 16 | class FT6x06(focaltech_touch.FocalTechTouch): 17 | 18 | def __init__( 19 | self, 20 | device, 21 | touch_cal=None, 22 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 23 | debug=False 24 | ): # NOQA 25 | 26 | super().__init__( 27 | device, 28 | touch_cal, 29 | startup_rotation, 30 | debug, 31 | None, 32 | _FT6206_CHIPID, 33 | _FT6x06_CHIPID 34 | ) 35 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/ft6x36.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # FT6236/FT6336/FT6436/FT6436L 4 | 5 | from micropython import const # NOQA 6 | import focaltech_touch 7 | import pointer_framework 8 | 9 | 10 | I2C_ADDR = const(0x38) 11 | BITS = 8 12 | 13 | _FT6x36_CHIPID_1 = const(0x36) 14 | _FT6x36_CHIPID_2 = const(0x64) 15 | _FT6x36_CHIPID_3 = const(0xCD) 16 | 17 | 18 | class FT6x36(focaltech_touch.FocalTechTouch): 19 | 20 | def __init__( 21 | self, 22 | device, 23 | touch_cal=None, 24 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 25 | debug=False 26 | ): # NOQA 27 | 28 | super().__init__( 29 | device, 30 | touch_cal, 31 | startup_rotation, 32 | debug, 33 | None, 34 | _FT6x36_CHIPID_1, 35 | _FT6x36_CHIPID_2, 36 | _FT6x36_CHIPID_3 37 | ) 38 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/gsl1680.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import pointer_framework 5 | import machine # NOQA 6 | import time 7 | 8 | _DATA_REG = const(0x80) 9 | _STATUS_REG = const(0xE0) 10 | _PAGE_REG = const(0xF0) 11 | 12 | I2C_ADDR = 0x40 13 | BITS = 8 14 | 15 | 16 | class GSL1680(pointer_framework.PointerDriver): 17 | 18 | def _read_reg(self, reg, num_bytes=None, buf=None): 19 | self._tx_buf[0] = reg >> 8 20 | self._tx_buf[1] = reg & 0xFF 21 | if num_bytes is not None: 22 | self._device.write_readinto(self._tx_mv[:2], self._rx_mv[:num_bytes]) 23 | else: 24 | self._device.write_readinto(self._tx_mv[:2], buf) 25 | 26 | def _write_reg(self, reg, value=None, buf=None): 27 | if value is not None: 28 | self._tx_buf[0] = value 29 | self._device.write_mem(reg, self._tx_mv[:1]) 30 | elif buf is not None: 31 | self._device.write_mem(reg, buf) 32 | 33 | def __init__( 34 | self, 35 | device, 36 | wake_pin, 37 | touch_cal=None, 38 | startup_rotation=pointer_framework.lv.DISPLAY_ROTATION._0, # NOQA 39 | debug=False 40 | ): 41 | self._tx_buf = bytearray(4) 42 | self._tx_mv = memoryview(self._tx_buf) 43 | self._rx_buf = bytearray(24) 44 | self._rx_mv = memoryview(self._rx_buf) 45 | 46 | self._device = device 47 | 48 | if isinstance(wake_pin, int): 49 | wake_pin = machine.Pin(wake_pin, machine.Pin.OUT) 50 | 51 | self._wake_pin = wake_pin 52 | 53 | self._wake_up() 54 | time.sleep_ms(50) # NOQA 55 | self._write_reg(_STATUS_REG, 0x88) 56 | time.sleep_ms(10) # NOQA 57 | self._write_reg(0xE4, 0x04) 58 | time.sleep_ms(5) # NOQA 59 | self._tx_buf[:4] = bytearray([0x00, 0x00, 0x00, 0x00]) 60 | self._write_reg(0xBC, buf=self._tx_mv[:4]) 61 | time.sleep_ms(5) # NOQA 62 | self._write_reg(0xE0, 0x00) 63 | 64 | super().__init__( 65 | touch_cal=touch_cal, startup_rotation=startup_rotation, debug=debug 66 | ) 67 | 68 | def _wake_up(self): 69 | # toggle wake pin 70 | self._wake_pin.value(1) 71 | time.sleep_ms(1) # NOQA 72 | self._wake_pin.value(0) 73 | time.sleep_ms(1) # NOQA 74 | self._wake_pin.value(1) 75 | time.sleep_ms(1) # NOQA 76 | 77 | def _get_coords(self): 78 | self._wake_up() 79 | self._read_reg(_DATA_REG, buf=self._rx_mv) 80 | data = self._rx_buf 81 | 82 | touch_count = data[0] 83 | if touch_count > 0: 84 | x = ((data[5] << 8) & 0xF) | data[4] 85 | y = ((data[7] << 8) & 0xF) | data[6] 86 | 87 | return self.RELEASED, x, y 88 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/indev/gt911_settings_gui.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import lvgl as lv # NOQA 4 | 5 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/io_expander/ht8574a.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import io_expander_framework 4 | import machine 5 | 6 | 7 | EXIO1 = 0x01 8 | EXIO2 = 0x02 9 | EXIO3 = 0x03 10 | EXIO4 = 0x04 11 | EXIO5 = 0x05 12 | EXIO6 = 0x06 13 | EXIO7 = 0x07 14 | EXIO8 = 0x08 15 | 16 | 17 | # 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E 18 | I2C_ADDR = 0x70 19 | BITS = 8 20 | 21 | 22 | class Pin(io_expander_framework.Pin): 23 | _output_states = 0xFF 24 | _reg_int_pins = [] 25 | 26 | @property 27 | def __bit(self): 28 | return 1 << self._id 29 | 30 | def __read_reg(self): 31 | self._buf[0] = 0 32 | Pin._device.read(buf=self._mv[:1]) 33 | return self._buf[0] 34 | 35 | def __write_reg(self, value): 36 | self._buf[0] = value & 0xFF 37 | Pin._device.write(buf=self._mv[:1]) 38 | 39 | def _set_dir(self, direction): 40 | if direction == self.OPEN_DRAIN: 41 | raise ValueError('OPEN_DRAIN is not supported') 42 | 43 | def _set_level(self, level): 44 | if self._mode == self.OUT: 45 | if level: 46 | states = Pin._output_states | self.__bit 47 | else: 48 | states = Pin._output_states & ~self.__bit 49 | 50 | # 0nly set if there is an actual change 51 | if states != Pin._output_states: 52 | self.__write_reg(Pin._output_states) 53 | Pin._output_states = states 54 | 55 | def _get_level(self): 56 | if self._mode == self.IN: 57 | states = self.__read_reg() 58 | elif self.mode == self.OUT: 59 | states = Pin._output_states 60 | else: 61 | raise ValueError('Unsupported pin mode') 62 | 63 | return int(bool(states & self.__bit)) 64 | 65 | def _set_irq(self, handler, trigger): 66 | pass 67 | 68 | def _set_pull(self, pull): 69 | pass 70 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/io_expander/ht8574b.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import io_expander_framework 4 | 5 | 6 | EXIO1 = 0x01 7 | EXIO2 = 0x02 8 | EXIO3 = 0x03 9 | EXIO4 = 0x04 10 | EXIO5 = 0x05 11 | EXIO6 = 0x06 12 | EXIO7 = 0x07 13 | EXIO8 = 0x08 14 | 15 | 16 | # 0x40, 0x42, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E 17 | I2C_ADDR = 0x40 18 | BITS = 8 19 | 20 | 21 | class Pin(io_expander_framework.Pin): 22 | _output_states = 0xFF 23 | _reg_int_pins = [] 24 | 25 | @property 26 | def __bit(self): 27 | return 1 << self._id 28 | 29 | def __read_reg(self): 30 | self._buf[0] = 0 31 | Pin._device.read(buf=self._mv[:1]) 32 | return self._buf[0] 33 | 34 | def __write_reg(self, value): 35 | self._buf[0] = value & 0xFF 36 | Pin._device.write(buf=self._mv[:1]) 37 | 38 | def _set_dir(self, direction): 39 | if direction == self.OPEN_DRAIN: 40 | raise ValueError('OPEN_DRAIN is not supported') 41 | 42 | def _set_level(self, level): 43 | if self._mode == self.OUT: 44 | if level: 45 | states = Pin._output_states | self.__bit 46 | else: 47 | states = Pin._output_states & ~self.__bit 48 | 49 | # 0nly set if there is an actual change 50 | if states != Pin._output_states: 51 | self.__write_reg(Pin._output_states) 52 | Pin._output_states = states 53 | 54 | def _get_level(self): 55 | if self._mode == self.IN: 56 | states = self.__read_reg() 57 | elif self.mode == self.OUT: 58 | states = Pin._output_states 59 | else: 60 | raise ValueError('Unsupported pin mode') 61 | 62 | return int(bool(states & self.__bit)) 63 | 64 | def _set_irq(self, handler, trigger): 65 | pass 66 | 67 | def _set_pull(self, pull): 68 | pass 69 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/io_expander/tca9535.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import io_expander_framework 5 | 6 | 7 | EXIO1 = 0x01 8 | EXIO2 = 0x02 9 | EXIO3 = 0x03 10 | EXIO4 = 0x04 11 | EXIO5 = 0x05 12 | EXIO6 = 0x06 13 | EXIO7 = 0x07 14 | EXIO8 = 0x08 15 | EXIO9 = 0x09 16 | EXIO10 = 0x0A 17 | EXIO11 = 0x0B 18 | EXIO12 = 0x0C 19 | EXIO13 = 0x0D 20 | EXIO14 = 0x0E 21 | EXIO15 = 0x0F 22 | EXIO16 = 0x10 23 | 24 | _INPUT_PORT_REG = const(0x00) 25 | _OUTPUT_PORT_REG = const(0x02) 26 | _POLARITY_INVERSION_REG = const(0x04) 27 | _CONFIGURATION_REG = const(0x06) 28 | 29 | # 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, or 0x27 30 | I2C_ADDR = 0x20 31 | BITS = 8 32 | 33 | 34 | class Pin(io_expander_framework.Pin): 35 | _config_settings = 0x00 36 | _output_states = 0x00 37 | _reg_int_pins = [] 38 | 39 | @property 40 | def __bit(self): 41 | return 1 << self._id 42 | 43 | def __read_reg(self, reg): 44 | self._buf[0] = 0 45 | self._buf[1] = 0 46 | Pin._device.read_mem(reg, buf=self._mv) 47 | return self._buf[0] << 8 | self._buf[1] 48 | 49 | def __write_reg(self, reg, value): 50 | self._buf[0] = value >> 8 & 0xFF 51 | self._buf[1] = value & 0xFF 52 | Pin._device.write_mem(reg, buf=self._mv) 53 | 54 | def _set_dir(self, direction): 55 | if direction == self.OUT: 56 | Pin._config_settings &= ~self.__bit 57 | elif direction == self.IN: 58 | Pin._config_settings |= self.__bit 59 | else: 60 | raise ValueError('OPEN_DRAIN is not supported') 61 | 62 | self.__write_reg(_CONFIGURATION_REG, Pin._config_settings) 63 | 64 | def _set_level(self, level): 65 | if self._mode == self.OUT: 66 | if level: 67 | states = Pin._output_states | self.__bit 68 | else: 69 | states = Pin._output_states & ~self.__bit 70 | 71 | # 0nly set if there is an actual change 72 | if states != Pin._output_states: 73 | self.__write_reg(_OUTPUT_PORT_REG, Pin._output_states) 74 | Pin._output_states = states 75 | 76 | def _get_level(self): 77 | if self._mode == self.IN: 78 | states = self.__read_reg(_INPUT_PORT_REG) 79 | elif self._mode == self.OUT: 80 | states = Pin._output_states 81 | else: 82 | raise ValueError('Unsupported pin mode') 83 | 84 | return int(bool(states & self.__bit)) 85 | 86 | def _set_irq(self, handler, trigger): 87 | pass 88 | 89 | def _set_pull(self, pull): 90 | pass 91 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/io_expander/tca9554.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from micropython import const # NOQA 4 | import io_expander_framework 5 | 6 | 7 | EXIO1 = 0x01 8 | EXIO2 = 0x02 9 | EXIO3 = 0x03 10 | EXIO4 = 0x04 11 | EXIO5 = 0x05 12 | EXIO6 = 0x06 13 | EXIO7 = 0x07 14 | EXIO8 = 0x08 15 | 16 | 17 | _INPUT_PORT_REG = const(0x00) 18 | _OUTPUT_PORT_REG = const(0x02) 19 | _POLARITY_INVERSION_REG = const(0x04) 20 | _CONFIGURATION_REG = const(0x06) 21 | 22 | I2C_ADDR = 0x20 23 | BITS = 8 24 | 25 | # 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 or 0x27 26 | I2C_TCA9554_ADDR = 0x20 27 | 28 | # 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E or 0x3F 29 | I2C_TCA9554A_ADDR = 0x38 30 | 31 | 32 | class Pin(io_expander_framework.Pin): 33 | _config_settings = 0x00 34 | _output_states = 0x00 35 | _reg_int_pins = [] 36 | 37 | @property 38 | def __bit(self): 39 | return 1 << (self._id - 1) 40 | 41 | def __read_reg(self, reg): 42 | self._buf[0] = 0 43 | self._buf[1] = 0 44 | self._device.read_mem(reg, buf=self._mv) 45 | return self._buf[0] << 8 | self._buf[1] 46 | 47 | def __write_reg(self, reg, value): 48 | self._buf[0] = value >> 8 & 0xFF 49 | self._buf[1] = value & 0xFF 50 | self._device.write_mem(reg, buf=self._mv) 51 | 52 | def _set_dir(self, direction): 53 | if direction == self.OUT: 54 | Pin._config_settings &= ~self.__bit 55 | elif direction == self.IN: 56 | Pin._config_settings |= self.__bit 57 | else: 58 | raise ValueError('OPEN_DRAIN is not supported') 59 | 60 | self.__write_reg(_CONFIGURATION_REG, Pin._config_settings) 61 | 62 | def _set_level(self, level): 63 | if self._mode == self.OUT: 64 | if level: 65 | states = Pin._output_states | self.__bit 66 | else: 67 | states = Pin._output_states & ~self.__bit 68 | 69 | # 0nly set if there is an actual change 70 | if states != Pin._output_states: 71 | self.__write_reg(_OUTPUT_PORT_REG, Pin._output_states) 72 | Pin._output_states = states 73 | 74 | def _get_level(self): 75 | if self._mode == self.IN: 76 | states = self.__read_reg(_INPUT_PORT_REG) 77 | elif self._mode == self.OUT: 78 | states = Pin._output_states 79 | else: 80 | raise ValueError('Unsupported pin mode') 81 | 82 | return int(bool(states & self.__bit)) 83 | 84 | def _set_irq(self, handler, trigger): 85 | pass 86 | 87 | def _set_pull(self, pull): 88 | pass 89 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/utils/lv_colors.py: -------------------------------------------------------------------------------- 1 | import lvgl as lv 2 | 3 | 4 | def LV_COLOR_MAKE(r=None, g=None, b=None, rgb=None): 5 | if rgb is not None: 6 | r = (rgb >> 16) & 0xFF 7 | g = (rgb >> 8) & 0xFF 8 | b = rgb & 0xFF 9 | 10 | return lv.color_make(r, g, b) 11 | 12 | 13 | class _LV_COLORS: 14 | 15 | def __getattr__(self, item): 16 | if item in self.__dict__: 17 | return self.__dict__[item] 18 | 19 | mapping = dict( 20 | WHITE=0xFFFFFF, 21 | SILVER=0xC0C0C0, 22 | GRAY=0x808080, 23 | BLACK=0x000000, 24 | RED=0xFF0000, 25 | MAROON=0x800000, 26 | YELLOW=0xFFFF00, 27 | OLIVE=0x808000, 28 | LIME=0x00FF00, 29 | GREEN=0x008000, 30 | CYAN=0x00FFFF, 31 | TEAL=0x008080, 32 | BLUE=0x0000FF, 33 | NAVY=0x000080, 34 | MAGENTA=0xFF00FF, 35 | PURPLE=0x800080, 36 | ORANGE=0xFFA500 37 | ) 38 | mapping['AQUA'] = mapping['CYAN'] 39 | 40 | if item in mapping: 41 | return LV_COLOR_MAKE(rgb=mapping[item]) 42 | 43 | raise AttributeError(item) 44 | -------------------------------------------------------------------------------- /api_drivers/common_api_drivers/utils/utils.py: -------------------------------------------------------------------------------- 1 | 2 | import lvgl as lv 3 | import struct 4 | import ctypes 5 | 6 | # Calculate pointer size on current machine, and corresponding fmt 7 | 8 | ptr_size = ctypes.sizeof({'p': (ctypes.PTR, ctypes.VOID)}) # NOQA 9 | fmt_options = {2: 'H', 4: 'L', 8: 'Q'} 10 | buf_fmt = fmt_options[ptr_size] if ptr_size in fmt_options else None 11 | 12 | 13 | def aligned_buf(buf, alignment): 14 | 15 | """Return an aligned buffer 16 | 17 | Given a buffer, return a memory view within that buffer, which starts 18 | at an aligned address in RAM. 19 | The returned memory view is possibly smaller. 20 | 21 | !! You must keep a reference to the original buffer to prevent the 22 | garbage collector from collecting the aligned view! 23 | 24 | Arguments: 25 | 26 | buf -- An object that implements buffer protocol 27 | alignment -- Integer value 28 | 29 | """ 30 | 31 | p = lv.C_Pointer() # NOQA 32 | p.ptr_val = buf 33 | 34 | if not buf_fmt: 35 | return None 36 | 37 | addr = struct.unpack(buf_fmt, p.ptr_val)[0] 38 | mod = addr % alignment 39 | 40 | offset = alignment - mod if mod != 0 else 0 41 | if len(buf) <= offset: 42 | return None 43 | 44 | addr += offset 45 | p = lv.C_Pointer.__cast__(struct.pack(buf_fmt, addr)) # NOQA 46 | 47 | return p.ptr_val.__dereference__(len(buf) - offset) 48 | -------------------------------------------------------------------------------- /api_drivers/py_api_drivers/frozen/imu_sensor/imu_sensor_framework.py: -------------------------------------------------------------------------------- 1 | import fusion 2 | import time 3 | 4 | 5 | class IMUSensorFramework: 6 | # delay between samples is nanosecond resolution. 1000 nanoseconds = 1 millisecond 7 | 8 | def __init__(self, device, declination_adjustment=0.0, delay_between_samples=100): 9 | self._device = device 10 | self._fusion = fusion.Fusion(declination=declination_adjustment) 11 | self._delay_between_samples = delay_between_samples 12 | self._roll = 0.0 13 | self._pitch = 0.0 14 | self._yaw = 0.0 15 | 16 | @property 17 | def roll(self): 18 | return self._roll 19 | 20 | @property 21 | def pitch(self): 22 | return self._pitch 23 | 24 | @property 25 | def yaw(self): 26 | return self._yaw 27 | 28 | def _get_gyrometer(self): 29 | raise NotImplementedError 30 | 31 | def _get_accelerometer(self): 32 | raise NotImplementedError 33 | 34 | def _get_magnetometer(self): 35 | raise NotImplementedError 36 | 37 | def calibrate(self, sample_count=5): 38 | ts = [time.ticks_ns()] 39 | count = [0] 40 | 41 | def _stop_func(): 42 | if count[0] == sample_count: 43 | return True 44 | 45 | now_ts = time.ticks_ns() 46 | diff = time.ticks_diff(now_ts, ts[0]) 47 | remaining = self._delay_between_samples - diff 48 | if remaining > 0: 49 | time.sleep_ns(remaining) 50 | 51 | ts[0] = time.ticks_ns() 52 | count[0] += 1 53 | return False 54 | 55 | self._fusion.calibrate(self._get_magnetometer, _stop_func) 56 | 57 | def read(self): 58 | accel = self._get_accelerometer() 59 | gyro = self._get_gyrometer() 60 | 61 | try: 62 | mag = self._get_magnetometer() 63 | except NotImplementedError: 64 | mag = None 65 | 66 | self._roll, self._pitch, self._yaw = self._fusion.update(accel, gyro, mag) 67 | 68 | return self._roll, self._pitch, self._yaw 69 | -------------------------------------------------------------------------------- /api_drivers/py_api_drivers/frozen/indev/button_framework.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import lvgl as lv # NOQA 4 | import _indev_base 5 | 6 | 7 | class ButtonDriver(_indev_base.IndevBase): 8 | 9 | def __init__(self): # NOQA 10 | self._last_button = -1 11 | self._button_points = [] 12 | 13 | super().__init__() 14 | self._set_type(lv.INDEV_TYPE.BUTTON) # NOQA 15 | 16 | def set_button_points(self, *points): 17 | self._indev_drv.set_button_points(list(points)) 18 | self._button_points = list(points) 19 | 20 | def _get_button(self): 21 | # this method needs to be overridden. 22 | # the returned value from this method is going to be a keycode 23 | # or None if no key event has occured 24 | raise NotImplementedError 25 | 26 | def _read(self, drv, data): # NOQA 27 | button = self._get_button() 28 | 29 | if button is None: # ignore no touch & multi touch 30 | if self._current_state != self.RELEASED: 31 | self._current_state = self.RELEASED 32 | res = True 33 | else: 34 | res = False 35 | 36 | data.enc_diff = self._last_button 37 | data.state = self._current_state 38 | data.continue_reading = False 39 | return res 40 | 41 | self._last_button = button 42 | self._current_state = data.state = self.PRESSED 43 | 44 | data.btn_id = self._last_button 45 | data.state = self._current_state 46 | data.continue_reading = True 47 | 48 | return True 49 | 50 | def reset_long_press(self): 51 | self._indev_drv.reset_long_press() 52 | -------------------------------------------------------------------------------- /builder/raspberry_pi.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | import os 4 | 5 | from .unix import ( 6 | parse_args as _parse_args, 7 | build_commands as _build_commands, 8 | build_manifest as _build_manifest, 9 | force_clean as _force_clean, 10 | clean as _clean, 11 | build_sdl as _build_sdl, 12 | submodules as _submodules, 13 | compile as _compile, 14 | mpy_cross as _mpy_cross 15 | ) 16 | 17 | from . import unix 18 | 19 | 20 | if not os.path.exists('micropy_updates/originals/raspberry_pi'): 21 | os.makedirs('micropy_updates/originals/raspberry_pi') 22 | 23 | 24 | unix.REAL_PORT = 'raspberry_pi' 25 | 26 | 27 | def parse_args(extra_args, lv_cflags, board): 28 | return _parse_args(extra_args, lv_cflags, board) 29 | 30 | 31 | def build_commands(not_sure, extra_args, script_dir, lv_cflags, board): 32 | return _build_commands(not_sure, extra_args, script_dir, lv_cflags, board) 33 | 34 | 35 | def build_manifest( 36 | target, 37 | script_dir, 38 | lvgl_api, 39 | displays, 40 | indevs, 41 | expanders, 42 | imus, 43 | frozen_manifest 44 | ): 45 | _build_manifest(target, script_dir, lvgl_api, displays, 46 | indevs, expanders, imus, frozen_manifest) 47 | 48 | 49 | def clean(): 50 | _clean() 51 | 52 | 53 | def force_clean(clean_mpy_cross): 54 | _force_clean(clean_mpy_cross) 55 | 56 | 57 | def build_sdl(addl_commands): 58 | if addl_commands.startswith('"') and addl_commands.endswith('"'): 59 | addl_commands = addl_commands[1:-1] 60 | 61 | if has_neon(): 62 | addl_commands += ' CFLAGS="-mfpu=neon"' 63 | 64 | _build_sdl(addl_commands.strip()) 65 | 66 | 67 | unix.build_sdl = build_sdl 68 | 69 | 70 | def submodules(): 71 | _submodules() 72 | 73 | 74 | def compile(*args): # NOQA 75 | _compile(*args) 76 | 77 | 78 | def mpy_cross(): 79 | _mpy_cross() 80 | 81 | 82 | def has_neon(): 83 | """ 84 | Features : half thumb fastmult vfp edsp neon vfpv3 85 | tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 86 | """ 87 | 88 | res = False 89 | 90 | with os.popen('cat /proc/cpuinfo') as file: 91 | for line in file: 92 | if not line.startswith('Features'): 93 | continue 94 | 95 | res = ' neon ' in line 96 | 97 | if res: 98 | break 99 | 100 | return res 101 | -------------------------------------------------------------------------------- /button_framework.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional, TYPE_CHECKING 4 | 5 | import _indev_base 6 | 7 | if TYPE_CHECKING: 8 | import lvgl as _lv 9 | 10 | 11 | class ButtonDriver(_indev_base.IndevBase): 12 | _last_button: int = ... 13 | 14 | def set_button_points(self, *points: list[_lv.point_t]) -> None: 15 | """ 16 | :param points: this is a varargs (*args) parameter. 17 | Example of use: 18 | 19 | button_driver.set_button_points( 20 | (lv.point_t(dict(x=0, y=0)), lv.point_t(dict(x=100, y=50))), 21 | (lv.point_t(dict(x=0, y=55)), lv.point_t(dict(x=100, y=110))), 22 | (lv.point_t(dict(x=0, y=115)), lv.point_t(dict(x=100, y=170))) 23 | ) 24 | 25 | You do not need to worry about keeping a reference to the points. 26 | This is done internally in the driver. You do however need to 27 | keep a reference to the driver. 28 | """ 29 | 30 | def __init__(self): 31 | ... 32 | 33 | def _get_button(self) -> Optional[int]: 34 | """ 35 | Reads the botton 36 | 37 | This function needs to return the id of the button that is pressed. 38 | In order for this to work you need to add the points to a coorsponding 39 | software button that you make. The id is going to be the index number 40 | of the points you have set. 41 | 42 | :return: None if there is no button pressed or the id of the button 43 | 44 | :raises: NotImplimentedError if the method is not overridden 45 | in the button driver 46 | """ 47 | ... 48 | 49 | def reset_long_press(self): 50 | ... 51 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "mcu": "esp32s3", 3 | "product": "Custom ESP32-S3 display board", 4 | "url": "https://www.come_manufacturer.com/board.html", 5 | "vendor": "Vendor name of board" 6 | } 7 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | set(SDKCONFIG_DEFAULTS 4 | boards/sdkconfig.base 5 | ${SDKCONFIG_IDF_VERSION_SPECIFIC} 6 | boards/sdkconfig.usb 7 | boards/sdkconfig.ble 8 | boards/sdkconfig.spiram_sx 9 | boards/sdkconfig.spiram_oct 10 | boards/sdkconfig.240mhz 11 | boards/MY_CUSTOM_BOARD/sdkconfig.board 12 | ) 13 | 14 | list(APPEND MICROPY_DEF_BOARD 15 | MICROPY_HW_BOARD_NAME="custom ESP32 board" 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #ifndef MICROPY_HW_BOARD_NAME 2 | // Can be set by mpconfigboard.cmake. 3 | #define MICROPY_HW_BOARD_NAME "Custom ESP32S3 board" 4 | #endif 5 | #define MICROPY_HW_MCU_NAME "ESP32S3" 6 | 7 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 8 | #define MICROPY_HW_ENABLE_UART_REPL (1) 9 | 10 | #define MICROPY_HW_I2C0_SCL (9) 11 | #define MICROPY_HW_I2C0_SDA (8) 12 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/my_custom_board.toml: -------------------------------------------------------------------------------- 1 | 2 | [MCU.esp32] 3 | BOARD = "MY_CUSTOM_BOARD" 4 | 5 | 6 | [I80Bus.display_bus] 7 | data0 = 9 8 | data1 = 46 9 | data2 = 3 10 | data3 = 8 11 | data4 = 18 12 | data5 = 17 13 | data6 = 16 14 | data7 = 15 15 | dc = 0 16 | wr = 47 17 | cs = -1 18 | freq = 20000000 19 | 20 | 21 | [I2C.Bus.i2c_bus] 22 | host = 0 23 | scl = 5 24 | sda = 6 25 | freq = 100000 26 | 27 | 28 | [I2C.Device.indev_device] 29 | bus = "i2c_bus" 30 | dev_id = "ft6x36.I2C_ADDR" 31 | reg_bits = "ft6x36.BITS" 32 | 33 | 34 | [ST7796.display] 35 | data_bus = "display_bus" 36 | display_width = 320 37 | display_height = 480 38 | backlight_pin = 45 39 | color_byte_order = "st7789.BYTE_ORDER_BGR" 40 | color_space = "lv.COLOR_FORMAT.RGB565" 41 | rgb565_byte_swap = true 42 | 43 | [ST7796.display.init] 44 | params = [] 45 | 46 | [FT6x36.indev] 47 | device = "indev_device" 48 | 49 | [display.set_color_inversion] 50 | params = [true] 51 | 52 | [display.set_rotation] 53 | params = ["lv.DISPLAY_ROTATION._90"] 54 | 55 | [display.set_backlight] 56 | params = [100] 57 | 58 | [task_handler.TaskHandler] 59 | params=[] 60 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x2F0000, 7 | vfs, data, fat, 0x300000, 0x1D00000, 8 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/MY_CUSTOM_BOARD/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 2 | 3 | CONFIG_FREERTOS_HZ=1000 4 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 5 | 6 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 7 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=y 8 | CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y 9 | 10 | CONFIG_SPIRAM_SPEED_120M=y 11 | CONFIG_SPIRAM_IGNORE_NOTFOUND=n 12 | CONFIG_SPIRAM_RODATA=y 13 | CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y 14 | 15 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 16 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 17 | 18 | CONFIG_PARTITION_TABLE_CUSTOM=y 19 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="boards/MY_CUSTOM_BOARD/partitions.csv" 20 | 21 | CONFIG_LWIP_LOCAL_HOSTNAME="my_custom_board" 22 | 23 | CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n 24 | CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n 25 | CONFIG_TINYUSB_DESC_CUSTOM_VID=0x2341 26 | CONFIG_TINYUSB_DESC_CUSTOM_PID=0x056B 27 | CONFIG_TINYUSB_DESC_MANUFACTURER_STRING="MyCustomBoard" 28 | CONFIG_TINYUSB_DESC_PRODUCT_STRING="Custom ESP32" 29 | 30 | -------------------------------------------------------------------------------- /custom_board_and_toml_examples/toml_example/example_build_toml.toml: -------------------------------------------------------------------------------- 1 | 2 | [MCU.esp32] 3 | BOARD = "ESP32_GENERIC_S3" 4 | BOARD_VARIANT = "SPIRAM_OCT" 5 | octal_flash = true 6 | flash_size = 16 7 | enable_jtag_repl = 'n' 8 | enable_cdc_repl = 'n' 9 | enable_uart_repl = 'y' 10 | uart_repl_bitrate = 115200 11 | 12 | 13 | 14 | [I80Bus.display_bus] 15 | data0 = 9 16 | data1 = 46 17 | data2 = 3 18 | data3 = 8 19 | data4 = 18 20 | data5 = 17 21 | data6 = 16 22 | data7 = 15 23 | dc = 0 24 | wr = 47 25 | cs = -1 26 | freq = 20000000 27 | 28 | 29 | [I2C.Bus.i2c_bus] 30 | host = 0 31 | scl = 5 32 | sda = 6 33 | freq = 100000 34 | 35 | 36 | [I2C.Device.indev_device] 37 | bus = "i2c_bus" 38 | dev_id = "ft6x36.I2C_ADDR" 39 | reg_bits = "ft6x36.BITS" 40 | 41 | 42 | [ST7796.display] 43 | data_bus = "display_bus" 44 | display_width = 320 45 | display_height = 480 46 | backlight_pin = 45 47 | color_byte_order = "st7796.BYTE_ORDER_BGR" 48 | color_space = "lv.COLOR_FORMAT.RGB565" 49 | rgb565_byte_swap = true 50 | 51 | [display.init] 52 | params = [] 53 | 54 | [FT6x36.indev] 55 | device = "indev_device" 56 | 57 | [display.set_color_inversion] 58 | params = [true] 59 | 60 | [display.set_rotation] 61 | params = ["lv.DISPLAY_ROTATION._90"] 62 | 63 | [display.set_backlight] 64 | params = [100] 65 | 66 | [task_handler.TaskHandler] 67 | params=[] 68 | -------------------------------------------------------------------------------- /display_configs/CYD-2432S024C.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC" 3 | BOARD_VARIANT = "SPIRAM" 4 | uart_repl_bitrate = 115200 5 | 6 | [SPI.Bus.spi_bus] 7 | host = 1 8 | mosi = 13 9 | miso = 12 10 | sck = 14 11 | 12 | [SPIBus.display_bus] 13 | spi_bus = "spi_bus" 14 | freq = 40000000 15 | dc = 2 16 | cs = 15 17 | 18 | 19 | [I2C.Bus.i2c_bus] 20 | host = 0 21 | scl = 32 22 | sda = 33 23 | freq = 400000 24 | 25 | 26 | [I2C.Device.indev_device] 27 | bus = "i2c_bus" 28 | dev_id = "cst820.I2C_ADDR" 29 | reg_bits = "cst820.BITS" 30 | 31 | 32 | [ILI9341.display] 33 | data_bus = "display_bus" 34 | display_width = 240 35 | display_height = 320 36 | backlight_pin = 27 37 | reset_pin = 17 38 | backlight_on_state = "st7789.STATE_PWM" 39 | color_space = "lv.COLOR_FORMAT.RGB565" 40 | color_byte_order = "ili9341.BYTE_ORDER_BGR" 41 | rgb565_byte_swap = true 42 | 43 | [display._ORIENTATION_TABLE] 44 | value = [0, 96, 192, 160] 45 | 46 | 47 | [display.set_power] 48 | params = [true] 49 | 50 | [display.init] 51 | params = [1] 52 | 53 | [cst820.indev] 54 | device = "indev_device" 55 | 56 | [display.set_backlight] 57 | params = [100] 58 | 59 | [task_handler.TaskHandler] 60 | params=[] 61 | -------------------------------------------------------------------------------- /display_configs/CYD-2432S028R.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC" 3 | BOARD_VARIANT = "SPIRAM" 4 | uart_repl_bitrate = 115200 5 | 6 | [SPI.Bus.spi_bus] 7 | host = 1 8 | mosi = 13 9 | miso = 12 10 | sck = 14 11 | 12 | [SPIBus.display_bus] 13 | spi_bus = "spi_bus" 14 | freq = 24000000 15 | dc = 2 16 | cs = 15 17 | 18 | 19 | [SPI.Bus.indev_bus] 20 | host = 2 21 | mosi= 32 22 | miso = 39 23 | sck = 25 24 | 25 | 26 | [SPI.Device.indev_device] 27 | spi_bus = "indev_bus" 28 | freq = 2000000 29 | cs = 33 30 | 31 | 32 | [ILI9341.display] 33 | data_bus = "display_bus" 34 | display_width = 320 35 | display_height = 240 36 | backlight_pin = 21 37 | backlight_on_state = "st7789.STATE_PWM" 38 | color_space = "lv.COLOR_FORMAT.RGB565" 39 | rgb565_byte_swap = true 40 | 41 | [display._ORIENTATION_TABLE] 42 | value = [0, 96, 192, 160] 43 | 44 | 45 | [display.set_power] 46 | params = [true] 47 | 48 | [display.init] 49 | params = [1] 50 | 51 | [xpt2046.indev] 52 | device = "indev_device" 53 | 54 | [display.set_backlight] 55 | params = [100] 56 | 57 | [task_handler.TaskHandler] 58 | params=[] 59 | -------------------------------------------------------------------------------- /display_configs/CYD-2432S032C.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC" 3 | BOARD_VARIANT = "SPIRAM" 4 | uart_repl_bitrate = 115200 5 | 6 | [SPI.Bus.spi_bus] 7 | host = 1 8 | mosi = 13 9 | miso = 12 10 | sck = 14 11 | 12 | [SPIBus.display_bus] 13 | spi_bus = "spi_bus" 14 | freq = 24000000 15 | dc = 2 16 | cs = 15 17 | 18 | 19 | [I2C.Bus.i2c_bus] 20 | host = 0 21 | scl = 32 22 | sda = 33 23 | freq = 400000 24 | 25 | 26 | [I2C.Device.indev_device] 27 | bus = "i2c_bus" 28 | dev_id = "gt911.I2C_ADDR" 29 | reg_bits = "gt911.BITS" 30 | 31 | 32 | [ST7789.display] 33 | data_bus = "display_bus" 34 | display_width = 240 35 | display_height = 320 36 | backlight_pin = 27 37 | backlight_on_state = "st7789.STATE_PWM" 38 | color_space = "lv.COLOR_FORMAT.RGB565" 39 | color_byte_order = "st7789.BYTE_ORDER_BGR" 40 | rgb565_byte_swap = true 41 | 42 | [display.set_power] 43 | params = [true] 44 | 45 | [display.init] 46 | params = [] 47 | 48 | [gt911.indev] 49 | device = "indev_device" 50 | 51 | [indev.firmware_config.fw_config] 52 | 53 | [fw_config.width] 54 | value=240 55 | 56 | [fw_config.height] 57 | value=320 58 | 59 | [fw_config.save] 60 | params=[] 61 | 62 | [display.set_backlight] 63 | params = [100] 64 | 65 | [task_handler.TaskHandler] 66 | params=[] 67 | -------------------------------------------------------------------------------- /display_configs/CYD-3248S035C.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC" 3 | BOARD_VARIANT = "SPIRAM" 4 | uart_repl_bitrate = 115200 5 | 6 | [SPI.Bus.spi_bus] 7 | host = 1 8 | mosi = 13 9 | miso = 12 10 | sck = 14 11 | 12 | [SPIBus.display_bus] 13 | spi_bus = "spi_bus" 14 | freq = 24000000 15 | dc = 2 16 | cs = 15 17 | 18 | 19 | [I2C.Bus.i2c_bus] 20 | host = 0 21 | scl = 32 22 | sda = 33 23 | freq = 400000 24 | 25 | 26 | [I2C.Device.indev_device] 27 | bus = "i2c_bus" 28 | dev_id = "gt911.I2C_ADDR" 29 | reg_bits = "gt911.BITS" 30 | 31 | 32 | [ST7796.display] 33 | data_bus = "display_bus" 34 | display_width = 320 35 | display_height = 480 36 | backlight_pin = 27 37 | backlight_on_state = "st7796.STATE_PWM" 38 | reset_pin = 17 39 | reset_state = "st7796.STATE_LOW" 40 | color_space = "lv.COLOR_FORMAT.RGB565" 41 | color_byte_order = "st7796.BYTE_ORDER_BGR" 42 | rgb565_byte_swap = true 43 | 44 | [display.set_power] 45 | params = [true] 46 | 47 | [display.init] 48 | params = [] 49 | 50 | [gt911.indev] 51 | device = "indev_device" 52 | 53 | [indev.firmware_config.fw_config] 54 | 55 | [fw_config.width] 56 | value=320 57 | 58 | [fw_config.height] 59 | value=480 60 | 61 | [fw_config.save] 62 | params=[] 63 | 64 | [display.set_backlight] 65 | params = [100] 66 | 67 | [task_handler.TaskHandler] 68 | params=[] 69 | -------------------------------------------------------------------------------- /display_configs/CYD-8048S043C.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC_S3" 3 | BOARD_VARIANT = "SPIRAM_OCT" 4 | flash_size = 8 5 | enable_jtag_repl = 'n' 6 | enable_cdc_repl = 'n' 7 | enable_uart_repl = 'y' 8 | uart_repl_bitrate = 115200 9 | 10 | 11 | [RGBBus.display_bus] 12 | data0 = 8 13 | data1 = 3 14 | data2 = 46 15 | data3 = 9 16 | data4 = 1 17 | data5 = 5 18 | data6 = 6 19 | data7 = 7 20 | data8 = 15 21 | data9 = 16 22 | data10 = 4 23 | data11 = 45 24 | data12 = 48 25 | data13 = 47 26 | data14 = 21 27 | data15 = 14 28 | hsync = 39 29 | vsync = 41 30 | de = 40 31 | pclk = 42 32 | freq = 12000000 33 | hsync_front_porch = 8 34 | hsync_back_porch = 8 35 | hsync_pulse_width = 4 36 | hsync_idle_low = true 37 | vsync_front_porch = 8 38 | vsync_back_porch = 8 39 | vsync_pulse_width = 4 40 | vsync_idle_low = true 41 | de_idle_high = false 42 | pclk_idle_high = false 43 | pclk_active_low = true 44 | 45 | 46 | [I2C.Bus.i2c_bus] 47 | host = 0 48 | scl = 20 49 | sda = 19 50 | freq = 400000 51 | 52 | 53 | [I2C.Device.indev_device] 54 | bus = "i2c_bus" 55 | dev_id = "ft6x36.I2C_ADDR" 56 | reg_bits = "ft6x36.BITS" 57 | 58 | 59 | [RGBDisplay.display] 60 | data_bus = "display_bus" 61 | display_width = 800 62 | display_height = 480 63 | backlight_pin = 2 64 | color_space = "lv.COLOR_FORMAT.RGB565" 65 | 66 | 67 | [display.set_power] 68 | params = [true] 69 | 70 | 71 | [display.init] 72 | params = [] 73 | 74 | [FT6x36.indev] 75 | device = "indev_device" 76 | 77 | [indev.firmware_config.fw_config] 78 | 79 | [fw_config.width] 80 | value=800 81 | 82 | [fw_config.height] 83 | value=480 84 | 85 | [fw_config.save] 86 | params=[] 87 | 88 | [display.set_backlight] 89 | params = [100] 90 | 91 | [task_handler.TaskHandler] 92 | params=[] 93 | -------------------------------------------------------------------------------- /display_configs/CYD-8048S050C_I.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC_S3" 3 | BOARD_VARIANT = "SPIRAM_OCT" 4 | flash_size = 8 5 | enable_jtag_repl = 'n' 6 | enable_cdc_repl = 'n' 7 | enable_uart_repl = 'y' 8 | uart_repl_bitrate = 115200 9 | 10 | 11 | [RGBBus.display_bus] 12 | data0 = 8 13 | data1 = 3 14 | data2 = 46 15 | data3 = 9 16 | data4 = 1 17 | data5 = 5 18 | data6 = 6 19 | data7 = 7 20 | data8 = 15 21 | data9 = 16 22 | data10 = 4 23 | data11 = 45 24 | data12 = 48 25 | data13 = 47 26 | data14 = 21 27 | data15 = 14 28 | hsync = 39 29 | vsync = 41 30 | de = 40 31 | pclk = 42 32 | freq = 12000000 33 | hsync_front_porch = 8 34 | hsync_back_porch = 8 35 | hsync_pulse_width = 4 36 | hsync_idle_low = true 37 | vsync_front_porch = 8 38 | vsync_back_porch = 8 39 | vsync_pulse_width = 4 40 | vsync_idle_low = true 41 | de_idle_high = false 42 | pclk_idle_high = false 43 | pclk_active_low = true 44 | 45 | 46 | [I2C.Bus.i2c_bus] 47 | host = 0 48 | scl = 20 49 | sda = 19 50 | freq = 400000 51 | 52 | 53 | [I2C.Device.indev_device] 54 | bus = "i2c_bus" 55 | dev_id = "ft6x36.I2C_ADDR" 56 | reg_bits = "ft6x36.BITS" 57 | 58 | 59 | [RGBDisplay.display] 60 | data_bus = "display_bus" 61 | display_width = 800 62 | display_height = 480 63 | backlight_pin = 2 64 | color_space = "lv.COLOR_FORMAT.RGB565" 65 | 66 | 67 | [display.set_power] 68 | params = [true] 69 | 70 | 71 | [display.init] 72 | params = [] 73 | 74 | [FT6x36.indev] 75 | device = "indev_device" 76 | 77 | [indev.firmware_config.fw_config] 78 | 79 | [fw_config.width] 80 | value=800 81 | 82 | [fw_config.height] 83 | value=480 84 | 85 | [fw_config.save] 86 | params=[] 87 | 88 | [display.set_backlight] 89 | params = [100] 90 | 91 | [task_handler.TaskHandler] 92 | params=[] 93 | -------------------------------------------------------------------------------- /display_configs/CYD-8048S070C.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC_S3" 3 | BOARD_VARIANT = "SPIRAM_OCT" 4 | flash_size = 8 5 | enable_jtag_repl = 'n' 6 | enable_cdc_repl = 'n' 7 | enable_uart_repl = 'y' 8 | uart_repl_bitrate = 115200 9 | 10 | [RGBBus.display_bus] 11 | data0 = 15 12 | data1 = 7 13 | data2 = 6 14 | data3 = 5 15 | data4 = 4 16 | data5 = 9 17 | data6 = 46 18 | data7 = 3 19 | data8 = 8 20 | data9 = 16 21 | data10 = 1 22 | data11 = 14 23 | data12 = 21 24 | data13 = 47 25 | data14 = 48 26 | data15 = 45 27 | hsync = 39 28 | vsync = 40 29 | de = 41 30 | pclk = 42 31 | freq = 12000000 32 | hsync_front_porch = 210 33 | hsync_back_porch = 16 34 | hsync_pulse_width = 30 35 | hsync_idle_low = true 36 | vsync_front_porch = 22 37 | vsync_back_porch = 10 38 | vsync_pulse_width = 13 39 | vsync_idle_low = true 40 | de_idle_high = false 41 | pclk_idle_high = false 42 | pclk_active_low = true 43 | 44 | 45 | [I2C.Bus.i2c_bus] 46 | host = 0 47 | scl = 20 48 | sda = 19 49 | freq = 400000 50 | 51 | 52 | [I2C.Device.indev_device] 53 | bus = "i2c_bus" 54 | dev_id = "ft6x36.I2C_ADDR" 55 | reg_bits = "ft6x36.BITS" 56 | 57 | 58 | [RGBDisplay.display] 59 | data_bus = "display_bus" 60 | display_width = 800 61 | display_height = 480 62 | backlight_pin = 2 63 | color_space = "lv.COLOR_FORMAT.RGB565" 64 | 65 | 66 | [display.set_power] 67 | params = [true] 68 | 69 | 70 | [display.init] 71 | params = [] 72 | 73 | [FT6x36.indev] 74 | device = "indev_device" 75 | 76 | [indev.firmware_config.fw_config] 77 | 78 | [fw_config.width] 79 | value=800 80 | 81 | [fw_config.height] 82 | value=480 83 | 84 | [fw_config.save] 85 | params=[] 86 | 87 | [display.set_backlight] 88 | params = [100] 89 | 90 | [task_handler.TaskHandler] 91 | params=[] 92 | -------------------------------------------------------------------------------- /display_configs/ER-TFTMC050-3.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC_S3" 3 | BOARD_VARIANT = "SPIRAM_OCT" 4 | flash_size = 16 5 | enable_jtag_repl = 'n' 6 | enable_cdc_repl = 'n' 7 | enable_uart_repl = 'y' 8 | uart_repl_bitrate = 115200 9 | 10 | [I2C.Bus.i2c_bus] 11 | host = 0 12 | scl = 48 13 | sda = 47 14 | freq = 400000 15 | 16 | [I80Bus.display_bus] 17 | data0 = 11 18 | data1 = 12 19 | data2 = 13 20 | data3 = 14 21 | data4 = 15 22 | data5 = 16 23 | data6 = 17 24 | data7 = 18 25 | dc = 8 26 | wr = 6 27 | cs = -1 28 | freq = 80000000 29 | 30 | [I2C.Device.indev_device] 31 | bus = "i2c_bus" 32 | dev_id = "gsl1680.I2C_ADDR" 33 | reg_bits = "gsl1680.BITS" 34 | 35 | [LT7381.display] 36 | data_bus = "display_bus" 37 | display_width = 800 38 | display_height = 480 39 | backlight_pin = 4 40 | reset_pin = 21 41 | wait_pin = 9 42 | color_space = "lv.COLOR_FORMAT.RGB565" 43 | 44 | [display.set_power] 45 | params = [true] 46 | 47 | [display.init] 48 | params = ["lt7381.TYPE_ER_TFTMC050_3"] 49 | 50 | [GSL1680.indev] 51 | device = "indev_device" 52 | wake_pin = 10 53 | 54 | [display.set_backlight] 55 | params = [100] 56 | 57 | [task_handler.TaskHandler] 58 | params=[] 59 | -------------------------------------------------------------------------------- /display_configs/ESP32-S3-Touch-LCD-4.3.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | BOARD = "ESP32_GENERIC_S3" 3 | BOARD_VARIANT = "SPIRAM_OCT" 4 | flash_size = 8 5 | enable_jtag_repl = 'n' 6 | enable_cdc_repl = 'n' 7 | enable_uart_repl = 'y' 8 | uart_repl_bitrate = 115200 9 | CONFIG_FREERTOS_HZ=1000 10 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 = "y" 11 | CONFIG_ESPTOOLPY_FLASHMODE_QIO = "y" 12 | CONFIG_ESPTOOLPY_FLASHFREQ_120M = "y" 13 | CONFIG_IDF_EXPERIMENTAL_FEATURES = "y" 14 | CONFIG_SPIRAM_SPEED_120M = "y" 15 | CONFIG_SPIRAM_FETCH_INSTRUCTIONS = "y" 16 | CONFIG_SPIRAM_RODATA = "y" 17 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B = "y" 18 | CONFIG_COMPILER_OPTIMIZATION_PERF = "y" 19 | 20 | 21 | [RGBBus.display_bus] 22 | data0 = 14 23 | data1 = 38 24 | data2 = 18 25 | data3 = 17 26 | data4 = 10 27 | data5 = 39 28 | data6 = 0 29 | data7 = 45 30 | data8 = 48 31 | data9 = 47 32 | data10 = 21 33 | data11 = 1 34 | data12 = 2 35 | data13 = 42 36 | data14 = 41 37 | data15 = 40 38 | hsync = 46 39 | vsync = 3 40 | de = 5 41 | pclk = 7 42 | freq = 13000000 43 | hsync_front_porch = 10 44 | hsync_back_porch = 10 45 | hsync_pulse_width = 10 46 | hsync_idle_low = false 47 | vsync_front_porch = 20 48 | vsync_back_porch = 10 49 | vsync_pulse_width = 10 50 | vsync_idle_low = false 51 | de_idle_high = false 52 | pclk_idle_high = false 53 | pclk_active_low = false 54 | 55 | 56 | [I2C.Bus.i2c_bus] 57 | host = 0 58 | scl = 9 59 | sda = 8 60 | freq = 400000 61 | 62 | 63 | [I2C.Device.indev_device] 64 | bus = "i2c_bus" 65 | dev_id = "ft6x36.I2C_ADDR" 66 | reg_bits = "ft6x36.BITS" 67 | 68 | 69 | [RGBDisplay.display] 70 | data_bus = "display_bus" 71 | display_width = 800 72 | display_height = 480 73 | backlight_pin = 2 74 | color_space = "lv.COLOR_FORMAT.RGB565" 75 | rgb565_byte_swap = true 76 | 77 | [display.set_power] 78 | params = [true] 79 | 80 | 81 | [display.init] 82 | params = [] 83 | 84 | [FT6x36.indev] 85 | device = "indev_device" 86 | 87 | [indev.firmware_config.fw_config] 88 | 89 | [fw_config.width] 90 | value=800 91 | 92 | [fw_config.height] 93 | value=480 94 | 95 | [fw_config.save] 96 | params=[] 97 | 98 | [display.set_backlight] 99 | params = [100] 100 | 101 | [task_handler.TaskHandler] 102 | params=[] 103 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/LilyGo-TDeck.toml: -------------------------------------------------------------------------------- 1 | [MCU.esp32] 2 | FROZEN_MANIFEST = "display_configs/LilyGo-TDeck/manifest.py" 3 | 4 | [SPI.Bus.spi_bus] 5 | host = 1 6 | mosi = 41 7 | miso = 38 8 | sck = 40 9 | 10 | [SPI.Device.lora_device] 11 | spi_bus = "spi_bus" 12 | freq = 20000000 13 | cs = 9 14 | 15 | [SPIBus.display_bus] 16 | spi_bus = "spi_bus" 17 | freq = 40000000 18 | dc = 11 19 | cs = 12 20 | 21 | [SDCard.sdcard] 22 | spi_bus = "spi_bus" 23 | freq = 10000000 24 | cs = 39 25 | 26 | [I2C.Bus.i2c_bus] 27 | host = 0 28 | scl = 8 29 | sda = 18 30 | freq = 100000 31 | 32 | [I2C.Device.touch_device] 33 | bus = "i2c_bus" 34 | dev_id = "gt911.I2C_ADDR" 35 | reg_bits = "gt911.BITS" 36 | 37 | [I2C.Device.keyboard_device] 38 | bus = "i2c_bus" 39 | dev_id = 85 40 | reg_bits = 8 41 | 42 | [ST7789.display] 43 | data_bus = "display_bus" 44 | display_width = 320 45 | display_height = 240 46 | backlight_pin = 42 47 | backlight_on_state = "st7789.STATE_PWM" 48 | color_space = "lv.COLOR_FORMAT.RGB565" 49 | color_byte_order = "st7789.BYTE_ORDER_BGR" 50 | rgb565_byte_swap = true 51 | 52 | [display.set_power] 53 | params = [true] 54 | 55 | [display.init] 56 | params = [] 57 | 58 | [gt911.touch] 59 | device = "touch_device" 60 | 61 | [keyboard_s3.Keyboard.keyboard] 62 | device = "keyboard_device" 63 | 64 | [trackball.TrackBall.tball] 65 | up_pin = 3 66 | down_pin = 2 67 | left_pin = 15 68 | right_pin = 1 69 | 70 | [power.Button.pwr_button] 71 | pin = 10 72 | 73 | [display.set_backlight] 74 | params = [100] 75 | 76 | [sx1262.SX1262.lora] 77 | spi_device = "lora_device" 78 | gpio = 13 79 | irq = 45 80 | rst = 17 81 | 82 | [task_handler.TaskHandler] 83 | params=[] 84 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/README.md: -------------------------------------------------------------------------------- 1 | To use this board all you need to do is run this build command... 2 | 3 | python3 make.py --custom-board-path=display_configs/LilyGo-TDeck 4 | 5 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "mcu": "esp32s3", 3 | "product": "Custom ESP32-S3 display board", 4 | "url": "https://www.come_manufacturer.com/board.html", 5 | "vendor": "Vendor name of board" 6 | } 7 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/manifest.py: -------------------------------------------------------------------------------- 1 | freeze('$(MPY_DIR)/../../display_configs/LilyGo-TDeck', 'keyboard_s3.py') 2 | freeze('$(MPY_DIR)/../../display_configs/LilyGo-TDeck', 'sx1262.py') 3 | freeze('$(MPY_DIR)/../../display_configs/LilyGo-TDeck', 'trackball.py') 4 | freeze('$(MPY_DIR)/../../display_configs/LilyGo-TDeck', 'power.py') 5 | 6 | 7 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | set(SDKCONFIG_DEFAULTS 4 | boards/sdkconfig.base 5 | ${SDKCONFIG_IDF_VERSION_SPECIFIC} 6 | boards/sdkconfig.usb 7 | boards/sdkconfig.ble 8 | boards/sdkconfig.spiram_sx 9 | boards/sdkconfig.spiram_oct 10 | boards/sdkconfig.240mhz 11 | boards/LilyGo-TDeck/sdkconfig.board 12 | ) 13 | 14 | list(APPEND MICROPY_DEF_BOARD 15 | MICROPY_HW_BOARD_NAME="LilyGo-TDeck" 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #ifndef MICROPY_HW_BOARD_NAME 2 | // Can be set by mpconfigboard.cmake. 3 | #define MICROPY_HW_BOARD_NAME "LilyGo-TDeck" 4 | #endif 5 | #define MICROPY_HW_MCU_NAME "ESP32S3" 6 | 7 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 8 | #define MICROPY_HW_ENABLE_UART_REPL (0) 9 | #define MICROPY_HW_USB_CDC (1) 10 | #define MICROPY_HW_ESP_USB_SERIAL_JTAG (0) 11 | 12 | #define MICROPY_HW_I2C0_SCL (9) 13 | #define MICROPY_HW_I2C0_SDA (8) 14 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name,Type,SubType,Offset,Size,Flags 2 | nvs,data,nvs,0x9000,0x6000, 3 | phy_init,data,phy,0xf000,0x1000, 4 | factory,app,factory,0x10000,0x2F0000, 5 | vfs,data,fat,0x300000,0xD00000, 6 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/pins.py: -------------------------------------------------------------------------------- 1 | _C3_INT = const(46) 2 | 3 | _ES7210_DIN = const(14) 4 | _ES2710_LRCK = const(21) 5 | _ES2710_SCLK = const(47) 6 | _ES2710_MCLK = const(48) 7 | 8 | _I2S_WS = const(5) 9 | _I2S_DA = const(6) 10 | _I2S_BCK = const(7) 11 | 12 | _GPIO0 = const(0) 13 | 14 | _UART0_RX = const(43) 15 | _UART0_TX = const(44) 16 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/power.py: -------------------------------------------------------------------------------- 1 | import machine # NOQA 2 | 3 | import lvgl as lv 4 | import time 5 | 6 | 7 | class Button: 8 | 9 | def __init__(self, pin): 10 | self._pin = machine.Pin(pin, machine.Pin.IN) 11 | 12 | if not lv.is_initialized(): 13 | lv.init() 14 | 15 | # press duration <= this number will call the sleep callback 16 | self._sleep_time = 75 17 | self._sleep_callback = None 18 | # press duration > sleep_time and <= this number will call the menu callback 19 | self._menu_time = 150 20 | self._menu_callback = None 21 | # press duration >= this number will call the power off callback 22 | self._power_off_time = 3000 23 | self._power_off_callback = None 24 | 25 | self._timer = lv.timer_create_basic() 26 | self._timer.pause() 27 | self._timer.set_cb(self.__callback) 28 | self._timer.set_period(33) 29 | self._timer.set_repeat_count(-1) 30 | self._timer.resume() 31 | 32 | def set_menu_time(self, val): 33 | self._menu_time = val 34 | 35 | def get_menu_time(self): 36 | return self._menu_time 37 | 38 | def set_menu_callback(self, cb): 39 | self._menu_callback = cb 40 | 41 | def get_menu_callback(self): 42 | return self._menu_callback 43 | 44 | def set_sleep_time(self, val): 45 | self._sleep_time = val 46 | 47 | def get_sleep_time(self): 48 | return self._sleep_time 49 | 50 | def set_sleep_callback(self, cb): 51 | self._sleep_callback = cb 52 | 53 | def get_sleep_callback(self): 54 | return self._sleep_callback 55 | 56 | def set_power_off_time(self, val): 57 | self._power_off_time = val 58 | 59 | def get_power_off_time(self): 60 | return self._power_off_time 61 | 62 | def set_power_off_callback(self, cb): 63 | self._power_off_callback = cb 64 | 65 | def get_power_off_callback(self): 66 | return self._power_off_callback 67 | 68 | def __callback(self, _): 69 | value = self._pin.value() 70 | 71 | if value: 72 | start_time = time.ticks_ms() # NOQA 73 | 74 | while value: 75 | value = self._pin.value() 76 | time.sleep_ms(1) # NOQA 77 | 78 | end_time = time.ticks_ms() # NOQA 79 | diff = time.ticks_diff(end_time, start_time) # NOQA 80 | 81 | if diff <= self._sleep_time: 82 | if self._sleep_callback is not None: 83 | self._sleep_callback(self._pin) 84 | 85 | elif diff <= self._menu_time: 86 | if self._menu_callback is not None: 87 | self._menu_callback() 88 | 89 | elif diff >= self._power_off_time: 90 | if self._power_off_callback is not None: 91 | self._power_off_callback(self._pin) 92 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/sdkconfig.board: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_FREERTOS_HZ=1000 3 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB=n 7 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n 8 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n 9 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 10 | CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n 11 | CONFIG_ESPTOOLPY_FLASHSIZE_64MB=n 12 | CONFIG_ESPTOOLPY_FLASHSIZE_128MB=n 13 | 14 | CONFIG_ESPTOOLPY_FLASHMODE_OPI=n 15 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 16 | CONFIG_ESPTOOLPY_FLASHMODE_QOUT=n 17 | CONFIG_ESPTOOLPY_FLASHMODE_DIO=n 18 | CONFIG_ESPTOOLPY_FLASHMODE_DOUT=n 19 | 20 | CONFIG_ESPTOOLPY_FLASHFREQ_15M=n 21 | CONFIG_ESPTOOLPY_FLASHFREQ_16M=n 22 | CONFIG_ESPTOOLPY_FLASHFREQ_20M=n 23 | CONFIG_ESPTOOLPY_FLASHFREQ_24M=n 24 | CONFIG_ESPTOOLPY_FLASHFREQ_26M=n 25 | CONFIG_ESPTOOLPY_FLASHFREQ_30M=n 26 | CONFIG_ESPTOOLPY_FLASHFREQ_32M=n 27 | CONFIG_ESPTOOLPY_FLASHFREQ_40M=n 28 | CONFIG_ESPTOOLPY_FLASHFREQ_48M=n 29 | CONFIG_ESPTOOLPY_FLASHFREQ_60M=n 30 | CONFIG_ESPTOOLPY_FLASHFREQ_64M=n 31 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 32 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=n 33 | 34 | CONFIG_SPIRAM_SPEED_20M=n 35 | CONFIG_SPIRAM_SPEED_26M=n 36 | CONFIG_SPIRAM_SPEED_40M=n 37 | CONFIG_SPIRAM_SPEED_80M=y 38 | CONFIG_SPIRAM_SPEED_120M=n 39 | 40 | CONFIG_SPIRAM_IGNORE_NOTFOUND=n 41 | CONFIG_SPIRAM_RODATA=y 42 | CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y 43 | 44 | CONFIG_COMPILER_OPTIMIZATION_SIZE=n 45 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 46 | CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y 47 | 48 | CONFIG_PARTITION_TABLE_CUSTOM=y 49 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="boards/LilyGo-TDeck/partitions.csv" 50 | 51 | CONFIG_LWIP_LOCAL_HOSTNAME="LilyGo-TDeck" 52 | 53 | CONFIG_TINYUSB_DESC_USE_ESPRESSIF_VID=n 54 | CONFIG_TINYUSB_DESC_USE_DEFAULT_PID=n 55 | CONFIG_TINYUSB_DESC_CUSTOM_VID=0x2341 56 | CONFIG_TINYUSB_DESC_CUSTOM_PID=0x056B 57 | CONFIG_TINYUSB_DESC_MANUFACTURER_STRING="LilyGo" 58 | CONFIG_TINYUSB_DESC_PRODUCT_STRING="TDeck" 59 | -------------------------------------------------------------------------------- /display_configs/LilyGo-TDeck/trackball.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | import lvgl as lv # NOQA 3 | import keypad_framework 4 | import machine 5 | from micropython import const # NOQA 6 | 7 | _UP = 0x01 8 | _DOWN = 0x02 9 | _LEFT = 0x04 10 | _RIGHT = 0x08 11 | 12 | 13 | class TrackBall(keypad_framework.KeypadDriver): 14 | 15 | def __init__(self, up_pin, down_pin, left_pin, right_pin): # NOQA 16 | 17 | self._up_pin = machine.Pin(up_pin, machine.Pin.IN) 18 | self._down_pin = machine.Pin(down_pin, machine.Pin.IN) 19 | self._left_pin = machine.Pin(left_pin, machine.Pin.IN) 20 | self._right_pin = machine.Pin(right_pin, machine.Pin.IN) 21 | self._key = 0x00 22 | 23 | super().__init__() 24 | 25 | self._indev_drv.set_mode(lv.INDEV_MODE.EVENT) # NOQA 26 | self.__timer = lv.timer_create(self.__callback, 33, None) # NOQA 27 | self.__timer.set_repeat_count(-1) # NOQA 28 | 29 | def __callback(self, _): 30 | self.read() 31 | last_state = self._current_state 32 | 33 | while self._current_state == self.PRESSED: 34 | # this might be too fast so I may have to put a stall in here. 35 | lv.refr_now(self._disp_drv) 36 | self.read() 37 | 38 | if last_state == self.PRESSED: 39 | lv.refr_now(self._disp_drv) 40 | 41 | def _get_key(self): 42 | key = self._key 43 | if key == 0x00: 44 | if self._up_pin.value(): 45 | key |= _UP 46 | if self._down_pin.value(): 47 | key |= _DOWN 48 | if self._left_pin.value(): 49 | key |= _LEFT 50 | if self._right_pin.value(): 51 | key |= _RIGHT 52 | 53 | if key & _UP: 54 | key &= ~_UP 55 | self._key = key 56 | return lv.KEY.UP 57 | elif key & _DOWN: 58 | key &= ~_DOWN 59 | self._key = key 60 | return lv.KEY.DOWN 61 | elif key & _LEFT: 62 | key &= ~_LEFT 63 | self._key = key 64 | return lv.KEY.LEFT 65 | elif key & _RIGHT: 66 | key &= ~_RIGHT 67 | self._key = key 68 | return lv.KEY.RIGHT 69 | else: 70 | self._key = 0x00 71 | -------------------------------------------------------------------------------- /encoder_framework.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Union, Optional, Tuple, ClassVar 4 | from typing import TYPE_CHECKING 5 | 6 | 7 | if TYPE_CHECKING: 8 | import lvgl as lv # NOQA 9 | import display_driver_framework 10 | 11 | import _indev_base 12 | 13 | class EncoderDriver(_indev_base.IndevBase): 14 | _last_enc_value: int = ... 15 | _last_enc_diff: int = ... 16 | _last_key: int = ... 17 | 18 | def __init__(self): 19 | ... 20 | 21 | def _get_enc( 22 | self 23 | ) -> Optional[Union[Tuple[int, int], Tuple[None, int], Tuple[int, None]]]: 24 | """ 25 | Reads the encoder position and any buttons that may exist 26 | 27 | This function needs to return the encoder value and the key value. 28 | If either of those is not being used then you can return None for 29 | that item. 30 | If both items are not being used then return a single None 31 | 32 | :return: None if there is no button press and there is no encoder value 33 | 34 | :raises: NotImplimentedError if the method is not overridden 35 | in the encoder driver 36 | """ 37 | ... 38 | 39 | def get_scroll_obj(self): 40 | ... 41 | 42 | def get_scroll_dir(self): 43 | ... 44 | 45 | def reset_long_press(self): 46 | ... 47 | -------------------------------------------------------------------------------- /ext_mod/esp32_components.cmake: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ext_mod/imu_fusion/include/fusion.h: -------------------------------------------------------------------------------- 1 | #include "py/obj.h" 2 | 3 | #ifndef __FUSION_H__ 4 | #define __FUSION_H__ 5 | 6 | typedef struct { 7 | mp_obj_base_t base; 8 | 9 | uint32_t start_ts; 10 | float mag_bias[3]; 11 | float beta; // 0.6045997880780725842169464404f 12 | float declination; 13 | float q[4]; 14 | 15 | } mp_fusion_obj_t; 16 | 17 | 18 | extern const mp_obj_type_t mp_fusion_type; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /ext_mod/imu_fusion/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # Create an INTERFACE library for our C module. 4 | add_library(usermod_fusion INTERFACE) 5 | 6 | set(FUSION_INCLUDES 7 | ${CMAKE_CURRENT_LIST_DIR}/include 8 | ) 9 | 10 | set(FUSION_SOURCES 11 | ${CMAKE_CURRENT_LIST_DIR}/src/fusion.c 12 | ) 13 | 14 | 15 | # Add our source files to the lib 16 | target_sources(usermod_fusion INTERFACE ${FUSION_SOURCES}) 17 | 18 | # Add include directories. 19 | target_include_directories(usermod_fusion INTERFACE ${FUSION_INCLUDES}) 20 | 21 | # Link our INTERFACE library to the usermod target. 22 | target_link_libraries(usermod INTERFACE usermod_fusion) 23 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/common_include/i2c_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _I2C_BUS_H_ 4 | #define _I2C_BUS_H_ 5 | 6 | //local_includes 7 | #include "modlcd_bus.h" 8 | 9 | // micropython includes 10 | #include "py/obj.h" 11 | #include "py/runtime.h" 12 | 13 | 14 | typedef struct _mp_lcd_i2c_bus_obj_t { 15 | mp_obj_base_t base; 16 | 17 | mp_obj_t callback; 18 | 19 | void *buf1; 20 | void *buf2; 21 | uint32_t buffer_flags; 22 | 23 | bool trans_done; 24 | bool rgb565_byte_swap; 25 | 26 | lcd_panel_io_t panel_io_handle; 27 | void *panel_io_config; 28 | void *bus_config; 29 | void *bus_handle; 30 | 31 | int host; 32 | 33 | } mp_lcd_i2c_bus_obj_t; 34 | 35 | extern const mp_obj_type_t mp_lcd_i2c_bus_type; 36 | #endif /* _I2C_BUS_H_ */ -------------------------------------------------------------------------------- /ext_mod/lcd_bus/common_include/rgb_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _RGB_BUS_H_ 4 | #define _RGB_BUS_H_ 5 | 6 | //local_includes 7 | #include "modlcd_bus.h" 8 | 9 | // micropython includes 10 | #include "py/obj.h" 11 | #include "py/runtime.h" 12 | 13 | 14 | typedef struct _mp_lcd_rgb_bus_obj_t { 15 | mp_obj_base_t base; 16 | 17 | mp_obj_t callback; 18 | 19 | void *buf1; 20 | void *buf2; 21 | uint32_t buffer_flags; 22 | 23 | bool trans_done; 24 | bool rgb565_byte_swap; 25 | 26 | lcd_panel_io_t panel_io_handle; 27 | 28 | void *panel_io_config; 29 | void *bus_config; 30 | void *bus_handle; 31 | 32 | } mp_lcd_rgb_bus_obj_t; 33 | 34 | 35 | extern const mp_obj_type_t mp_lcd_rgb_bus_type; 36 | #endif /* _RGB_BUS_H_ */ -------------------------------------------------------------------------------- /ext_mod/lcd_bus/common_src/i2c_bus.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | // local includes 4 | #include "lcd_types.h" 5 | #include "modlcd_bus.h" 6 | #include "i2c_bus.h" 7 | 8 | // micropython includes 9 | #include "py/obj.h" 10 | #include "py/runtime.h" 11 | 12 | // stdlib includes 13 | #include 14 | 15 | 16 | static mp_obj_t mp_lcd_i2c_bus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) 17 | { 18 | LCD_UNUSED(type); 19 | LCD_UNUSED(n_args); 20 | LCD_UNUSED(n_kw); 21 | LCD_UNUSED(all_args); 22 | 23 | mp_raise_msg(&mp_type_NotImplementedError, MP_ERROR_TEXT("I2C display bus is not supported")); 24 | return mp_const_none; 25 | } 26 | 27 | 28 | MP_DEFINE_CONST_OBJ_TYPE( 29 | mp_lcd_i2c_bus_type, 30 | MP_QSTR_I2CBus, 31 | MP_TYPE_FLAG_NONE, 32 | make_new, mp_lcd_i2c_bus_make_new, 33 | locals_dict, (mp_obj_dict_t *)&mp_lcd_bus_locals_dict 34 | ); 35 | 36 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/common_src/rgb_bus.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | // local includes 4 | #include "lcd_types.h" 5 | #include "modlcd_bus.h" 6 | #include "rgb_bus.h" 7 | 8 | // micropython includes 9 | #include "py/obj.h" 10 | #include "py/runtime.h" 11 | 12 | // stdlib includes 13 | #include 14 | 15 | 16 | mp_obj_t mp_lcd_rgb_bus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) 17 | { 18 | LCD_UNUSED(type); 19 | LCD_UNUSED(n_args); 20 | LCD_UNUSED(n_kw); 21 | LCD_UNUSED(all_args); 22 | 23 | mp_raise_msg(&mp_type_NotImplementedError, MP_ERROR_TEXT("RGB display bus is not supported")); 24 | return mp_const_none; 25 | } 26 | 27 | 28 | MP_DEFINE_CONST_OBJ_TYPE( 29 | mp_lcd_rgb_bus_type, 30 | MP_QSTR_RGBBus, 31 | MP_TYPE_FLAG_NONE, 32 | make_new, mp_lcd_rgb_bus_make_new, 33 | locals_dict, (mp_obj_dict_t *)&mp_lcd_bus_locals_dict 34 | ); 35 | 36 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/dsi_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | 4 | #ifndef _ESP32_DSI_BUS_H_ 5 | #define _ESP32_DSI_BUS_H_ 6 | 7 | //local_includes 8 | #include "lcd_types.h" 9 | 10 | // micropython includes 11 | #include "mphalport.h" 12 | #include "py/obj.h" 13 | #include "py/objarray.h" 14 | 15 | // esp-idf includes 16 | #include "soc/soc_caps.h" 17 | 18 | 19 | #if SOC_MIPI_DSI_SUPPORTED 20 | // esp-idf includes 21 | #include "esp_lcd_panel_io.h" 22 | #include "esp_lcd_panel_interface.h" 23 | #include "esp_lcd_panel_io.h" 24 | #include "esp_lcd_mipi_dsi.h" 25 | 26 | 27 | typedef struct _mp_lcd_dsi_bus_obj_t { 28 | mp_obj_base_t base; 29 | 30 | mp_obj_t callback; 31 | 32 | void *buf1; 33 | void *buf2; 34 | uint32_t buffer_flags; 35 | 36 | bool trans_done; 37 | bool rgb565_byte_swap; 38 | 39 | lcd_panel_io_t panel_io_handle; 40 | 41 | esp_lcd_dbi_io_config_t panel_io_config; 42 | esp_lcd_dsi_bus_config_t bus_config; 43 | esp_lcd_dsi_bus_handle_t bus_handle; 44 | esp_lcd_panel_handle_t panel_handle; 45 | esp_lcd_dpi_panel_config_t panel_config; 46 | 47 | uint32_t buffer_size; 48 | mp_obj_array_t *view1; 49 | mp_obj_array_t *view2; 50 | 51 | void *transmitting_buf; 52 | 53 | } mp_lcd_dsi_bus_obj_t; 54 | 55 | extern const mp_obj_type_t mp_lcd_dsi_bus_type; 56 | 57 | #endif /* SOC_MIPI_DSI_SUPPORTED */ 58 | #endif /* _ESP32_DSI_BUS_H_ */ 59 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/i2c_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _ESP32_I2C_BUS_H_ 4 | #define _ESP32_I2C_BUS_H_ 5 | 6 | //local_includes 7 | #include "lcd_types.h" 8 | 9 | // esp-idf includes 10 | #include "esp_lcd_panel_io.h" 11 | #include "driver/i2c.h" 12 | 13 | // micropython includes 14 | #include "mphalport.h" 15 | #include "py/obj.h" 16 | #include "py/objarray.h" 17 | 18 | typedef struct _mp_lcd_i2c_bus_obj_t { 19 | mp_obj_base_t base; 20 | 21 | mp_obj_t callback; 22 | 23 | mp_obj_array_t *view1; 24 | mp_obj_array_t *view2; 25 | 26 | uint32_t buffer_flags; 27 | 28 | bool trans_done; 29 | bool rgb565_byte_swap; 30 | 31 | lcd_panel_io_t panel_io_handle; 32 | esp_lcd_panel_io_i2c_config_t panel_io_config; 33 | i2c_config_t bus_config; 34 | esp_lcd_i2c_bus_handle_t bus_handle; 35 | 36 | int host; 37 | 38 | } mp_lcd_i2c_bus_obj_t; 39 | 40 | extern const mp_obj_type_t mp_lcd_i2c_bus_type; 41 | 42 | extern void mp_lcd_i2c_bus_deinit_all(void); 43 | 44 | #endif /* _ESP32_I2C_BUS_H_ */ -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/i80_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _ESP32_I80_BUS_H_ 4 | #define _ESP32_I80_BUS_H_ 5 | 6 | //local_includes 7 | #include "lcd_types.h" 8 | 9 | // micropython includes 10 | #include "mphalport.h" 11 | #include "py/obj.h" 12 | #include "py/objarray.h" 13 | 14 | // esp-idf includes 15 | #include "soc/soc_caps.h" 16 | 17 | #if SOC_LCD_I80_SUPPORTED 18 | // esp-idf includes 19 | #include "esp_lcd_panel_io.h" 20 | 21 | 22 | typedef struct _mp_lcd_i80_bus_obj_t { 23 | mp_obj_base_t base; 24 | 25 | mp_obj_t callback; 26 | 27 | mp_obj_array_t *view1; 28 | mp_obj_array_t *view2; 29 | 30 | uint32_t buffer_flags; 31 | 32 | bool trans_done; 33 | bool rgb565_byte_swap; 34 | 35 | lcd_panel_io_t panel_io_handle; 36 | 37 | esp_lcd_panel_io_i80_config_t panel_io_config; 38 | esp_lcd_i80_bus_config_t bus_config; 39 | esp_lcd_i80_bus_handle_t bus_handle; 40 | } mp_lcd_i80_bus_obj_t; 41 | 42 | extern const mp_obj_type_t mp_lcd_i80_bus_type; 43 | 44 | extern void mp_lcd_i80_bus_deinit_all(void); 45 | 46 | #else 47 | #include "../common_include/i80_bus.h" 48 | 49 | #endif /* SOC_LCD_I80_SUPPORTED */ 50 | #endif /* _ESP32_I80_BUS_H_ */ 51 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/led_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | 4 | #ifndef _ESP32_LED_BUS_H_ 5 | #define _ESP32_LED_BUS_H_ 6 | 7 | //local_includes 8 | #include "lcd_types.h" 9 | #include "../../../micropy_updates/common/mp_spi_common.h" 10 | 11 | #include "driver/rmt.h" 12 | 13 | // micropython includes 14 | #include "mphalport.h" 15 | #include "py/obj.h" 16 | #include "py/objarray.h" 17 | 18 | typedef enum mp_lcd_led_pixel_order { 19 | RGB, 20 | RBG, 21 | GRB, 22 | GBR, 23 | BRG, 24 | BGR, 25 | } mp_lcd_led_pixel_order; 26 | 27 | typedef struct _mp_lcd_led_bit_timing { 28 | int duration1; 29 | int duration2; 30 | } mp_lcd_led_bit_timing; 31 | 32 | typedef struct { 33 | rmt_encoder_t base; 34 | rmt_encoder_t *bytes_encoder; 35 | rmt_encoder_t *copy_encoder; 36 | int state; 37 | rmt_symbol_word_t reset_code; 38 | } mp_lcd_led_strip_encoder_t; 39 | 40 | typedef struct _mp_lcd_led_color_temp { 41 | uint8_t r; 42 | uint8_t g; 43 | uint8_t b; 44 | bool blue_correct; 45 | } mp_lcd_led_color_temp; 46 | 47 | typedef struct _mp_lcd_led_bus_obj_t { 48 | mp_obj_base_t base; 49 | 50 | mp_obj_t callback; 51 | 52 | void *buf1; 53 | void *buf2; 54 | uint32_t buffer_flags; 55 | 56 | bool trans_done; 57 | bool rgb565_byte_swap; 58 | 59 | lcd_panel_io_t panel_io_handle; 60 | 61 | uint32_t buffer_size; 62 | 63 | mp_obj_array_t *view1; 64 | mp_obj_array_t *view2; 65 | 66 | // common config 67 | mp_lcd_led_pixel_order pixel_order; 68 | uint8_t rgb_order[3]; 69 | uint16_t pixel_count; 70 | uint8_t leds_per_pixel; 71 | mp_lcd_led_color_temp color_temp; 72 | 73 | // RMT specific config 74 | esp_gpio_t data_pin; 75 | mp_lcd_led_bit_timing bit0; 76 | mp_lcd_led_bit_timing bit1; 77 | uint16_t res; 78 | rmt_channel_handle_t rmt_chan; 79 | mp_lcd_led_strip_encoder_t *strip_encoder 80 | 81 | // SPI specific config 82 | esp_lcd_panel_io_spi_config_t *panel_io_config; 83 | esp_lcd_spi_bus_handle_t *bus_handle; 84 | machine_hw_spi_device_obj_t *spi_device; 85 | 86 | } mp_lcd_led_bus_obj_t; 87 | 88 | 89 | extern const mp_obj_type_t mp_lcd_led_bus_type; 90 | 91 | #endif /* _ESP32_LED_BUS_H_ */ 92 | 93 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/rgb565_dither.h: -------------------------------------------------------------------------------- 1 | #ifndef __RGB565_DITHER_H__ 2 | #define __RGB565_DITHER_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define CALC_THRESHOLD(x, y) (uint8_t)(((y & 7) << 3) + (x & 7)) 8 | 9 | extern uint8_t *red_thresh; 10 | extern uint8_t *green_thresh; 11 | extern uint8_t *blue_thresh; 12 | 13 | bool rgb565_dither_init(void); 14 | 15 | static inline void rgb565_dither_pixel(uint8_t treshold_id, uint16_t *pixel) 16 | { 17 | *pixel = (((((*pixel >> 8) & 0xF8) + red_thresh[treshold_id]) << 8) | 18 | ((((*pixel >> 3) & 0xFC) + green_thresh[treshold_id]) << 3) | 19 | ((((*pixel & 0x1F) << 3) + blue_thresh[treshold_id]) >> 3)); 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_include/spi_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _ESP32_SPI_BUS_H_ 4 | #define _ESP32_SPI_BUS_H_ 5 | 6 | //local_includes 7 | #include "lcd_types.h" 8 | #include "../../../micropy_updates/common/mp_spi_common.h" 9 | 10 | // esp-idf includes 11 | #include "esp_lcd_panel_io.h" 12 | #include "driver/spi_common.h" 13 | #include "driver/spi_master.h" 14 | #include "hal/spi_types.h" 15 | 16 | // micropython includes 17 | #include "py/objarray.h" 18 | #include "mphalport.h" 19 | #include "py/obj.h" 20 | 21 | 22 | typedef struct _mp_lcd_spi_bus_obj_t { 23 | mp_obj_base_t base; 24 | 25 | mp_obj_t callback; 26 | 27 | mp_obj_array_t *view1; 28 | mp_obj_array_t *view2; 29 | 30 | uint32_t buffer_flags; 31 | 32 | bool trans_done; 33 | bool rgb565_byte_swap; 34 | 35 | lcd_panel_io_t panel_io_handle; 36 | esp_lcd_panel_io_spi_config_t panel_io_config; 37 | spi_bus_config_t bus_config; 38 | esp_lcd_spi_bus_handle_t bus_handle; 39 | 40 | spi_host_device_t host; 41 | mp_machine_hw_spi_device_obj_t spi_device; 42 | } mp_lcd_spi_bus_obj_t; 43 | 44 | extern const mp_obj_type_t mp_lcd_spi_bus_type; 45 | 46 | extern void mp_lcd_spi_bus_deinit_all(void); 47 | 48 | 49 | #endif /* _ESP32_SPI_BUS_H_ */ 50 | 51 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/esp32_src/rgb565_dither.c: -------------------------------------------------------------------------------- 1 | 2 | #include "rgb565_dither.h" 3 | #include 4 | 5 | uint8_t* red_thresh = NULL; 6 | uint8_t* green_thresh = NULL; 7 | uint8_t* blue_thresh = NULL; 8 | 9 | bool rgb565_dither_init(void) 10 | { 11 | if (red_thresh == NULL) { 12 | red_thresh = (uint8_t *)malloc(64); 13 | if (red_thresh != NULL) { 14 | memcpy(red_thresh, 15 | (uint8_t []){ 16 | 1, 7, 3, 5, 0, 8, 2, 6, 17 | 7, 1, 5, 3, 8, 0, 6, 2, 18 | 3, 5, 0, 8, 2, 6, 1, 7, 19 | 5, 3, 8, 0, 6, 2, 7, 1, 20 | 0, 8, 2, 6, 1, 7, 3, 5, 21 | 8, 0, 6, 2, 7, 1, 5, 3, 22 | 2, 6, 1, 7, 3, 5, 0, 8, 23 | 6, 2, 7, 1, 5, 3, 8, 0 24 | }, 64); 25 | } 26 | } 27 | 28 | if (green_thresh == NULL) { 29 | green_thresh = (uint8_t *)malloc(64); 30 | if (green_thresh != NULL) { 31 | memcpy(green_thresh, 32 | (uint8_t []){ 33 | 1, 3, 2, 2, 3, 1, 2, 2, 34 | 2, 2, 0, 4, 2, 2, 4, 0, 35 | 3, 1, 2, 2, 1, 3, 2, 2, 36 | 2, 2, 4, 0, 2, 2, 0, 4, 37 | 1, 3, 2, 2, 3, 1, 2, 2, 38 | 2, 2, 0, 4, 2, 2, 4, 0, 39 | 3, 1, 2, 2, 1, 3, 2, 2, 40 | 2, 2, 4, 0, 2, 2, 0, 4 41 | }, 64); 42 | } 43 | } 44 | if (blue_thresh == NULL) { 45 | blue_thresh = (uint8_t *)malloc(64); 46 | if (blue_thresh != NULL) { 47 | memcpy(blue_thresh, 48 | (uint8_t []){ 49 | 5, 3, 8, 0, 6, 2, 7, 1, 50 | 3, 5, 0, 8, 2, 6, 1, 7, 51 | 8, 0, 6, 2, 7, 1, 5, 3, 52 | 0, 8, 2, 6, 1, 7, 3, 5, 53 | 6, 2, 7, 1, 5, 3, 8, 0, 54 | 2, 6, 1, 7, 3, 5, 0, 8, 55 | 7, 1, 5, 3, 8, 0, 6, 2, 56 | 1, 7, 3, 5, 0, 8, 2, 6 57 | }, 64); 58 | } 59 | } 60 | 61 | if (red_thresh == NULL || blue_thresh == NULL || green_thresh == NULL) return false; 62 | else return true; 63 | } 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # Create an INTERFACE library for our C module. 4 | 5 | add_library(usermod_lcd_bus INTERFACE) 6 | 7 | if(ESP_PLATFORM) 8 | set(LCD_INCLUDES 9 | ${CMAKE_CURRENT_LIST_DIR} 10 | ${CMAKE_CURRENT_LIST_DIR}/esp32_include 11 | ) 12 | 13 | set(LCD_SOURCES 14 | ${CMAKE_CURRENT_LIST_DIR}/modlcd_bus.c 15 | ${CMAKE_CURRENT_LIST_DIR}/lcd_types.c 16 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/i2c_bus.c 17 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/spi_bus.c 18 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/i80_bus.c 19 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/rgb_bus.c 20 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/rgb_bus_rotation.c 21 | ${CMAKE_CURRENT_LIST_DIR}/esp32_src/rgb565_dither.c 22 | ) 23 | 24 | # gets esp_lcd include paths 25 | idf_component_get_property(ESP_LCD_INCLUDES esp_lcd INCLUDE_DIRS) 26 | idf_component_get_property(ESP_LCD_DIR esp_lcd COMPONENT_DIR) 27 | 28 | # sets the include paths into INCLUDES variable 29 | if(ESP_LCD_INCLUDES) 30 | list(TRANSFORM ESP_LCD_INCLUDES PREPEND ${ESP_LCD_DIR}/) 31 | list(APPEND LCD_INCLUDES ${ESP_LCD_INCLUDES}) 32 | endif() 33 | 34 | else() 35 | set(LCD_INCLUDES 36 | ${CMAKE_CURRENT_LIST_DIR} 37 | ${CMAKE_CURRENT_LIST_DIR}/common_include 38 | ${CMAKE_CURRENT_LIST_DIR}/sdl_bus 39 | ) 40 | 41 | set(LCD_SOURCES 42 | ${CMAKE_CURRENT_LIST_DIR}/lcd_types.c 43 | ${CMAKE_CURRENT_LIST_DIR}/modlcd_bus.c 44 | ${CMAKE_CURRENT_LIST_DIR}/common_src/i2c_bus.c 45 | ${CMAKE_CURRENT_LIST_DIR}/common_src/spi_bus.c 46 | ${CMAKE_CURRENT_LIST_DIR}/common_src/i80_bus.c 47 | ${CMAKE_CURRENT_LIST_DIR}/common_src/rgb_bus.c 48 | ${CMAKE_CURRENT_LIST_DIR}/sdl_bus/sdl_bus.c 49 | ) 50 | 51 | endif(ESP_PLATFORM) 52 | 53 | 54 | # Add our source files to the lib 55 | target_sources(usermod_lcd_bus INTERFACE ${LCD_SOURCES}) 56 | 57 | # Add include directories. 58 | target_include_directories(usermod_lcd_bus INTERFACE ${LCD_INCLUDES}) 59 | 60 | # Link our INTERFACE library to the usermod target. 61 | target_link_libraries(usermod INTERFACE usermod_lcd_bus) 62 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/micropython.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | ################################################################################ 4 | # lcd_bus build rules 5 | 6 | MOD_DIR := $(USERMOD_DIR) 7 | LVGL_BINDING_DIR = $(subst /ext_mod/lcd_bus,,$(MOD_DIR)) 8 | 9 | CFLAGS_USERMOD += -I$(MOD_DIR) 10 | CFLAGS_USERMOD += -I$(MOD_DIR)/common_include 11 | CFLAGS_USERMOD += -I$(MOD_DIR)/sdl_bus 12 | 13 | ifneq (,$(findstring -Wno-missing-field-initializers, $(CFLAGS_USERMOD))) 14 | CFLAGS_USERMOD += -Wno-missing-field-initializers 15 | endif 16 | 17 | SRC_USERMOD_C += $(MOD_DIR)/modlcd_bus.c 18 | SRC_USERMOD_C += $(MOD_DIR)/lcd_types.c 19 | SRC_USERMOD_C += $(MOD_DIR)/common_src/i2c_bus.c 20 | SRC_USERMOD_C += $(MOD_DIR)/common_src/i80_bus.c 21 | SRC_USERMOD_C += $(MOD_DIR)/common_src/spi_bus.c 22 | SRC_USERMOD_C += $(MOD_DIR)/common_src/rgb_bus.c 23 | SRC_USERMOD_C += $(MOD_DIR)/sdl_bus/sdl_bus.c 24 | 25 | ifneq (,$(findstring unix, $(LV_PORT))) 26 | CFLAGS_USERMOD += -DMP_PORT_UNIX=1 27 | CFLAGS_USERMOD += -I$(BUILD)/SDL/include/SDL2 28 | CFLAGS_USERMOD += -I$(BUILD)/SDL/include-config-release/SDL2 29 | CFLAGS_USERMOD += -Wno-discarded-qualifiers 30 | LDFLAGS_USERMOD += -L$(BUILD)/SDL 31 | LDFLAGS_USERMOD += -lSDL2 32 | else 33 | ifneq (,$(findstring macOS, $(LV_PORT))) 34 | # -F/Library/Frameworks -framework SDL2 35 | CFLAGS_USERMOD += -DMP_PORT_UNIX=1 36 | CFLAGS_USERMOD += -Wno-incompatible-pointer-types-discards-qualifiers 37 | CFLAGS_USERMOD += -I/Library/Frameworks/SDL2.framework/Headers/SDL2 38 | CFLAGS_USERMOD += $(shell sdl2-config --cflags) 39 | LDFLAGS_USERMOD += $(shell sdl2-config --libs) 40 | endif 41 | endif 42 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/modlcd_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef _MODLCD_BUS_H_ 4 | #define _MODLCD_BUS_H_ 5 | 6 | #include "lcd_types.h" 7 | 8 | // micropython includes 9 | #include "py/obj.h" 10 | #include "py/runtime.h" 11 | #include "py/objarray.h" 12 | 13 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_init_obj; 14 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_get_lane_count_obj; 15 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_tx_param_obj; 16 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_tx_color_obj; 17 | extern const mp_obj_fun_builtin_fixed_t mp_lcd_bus_deinit_obj; 18 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_rx_param_obj; 19 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_register_callback_obj; 20 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_free_framebuffer_obj; 21 | extern const mp_obj_fun_builtin_var_t mp_lcd_bus_allocate_framebuffer_obj; 22 | 23 | extern const mp_obj_dict_t mp_lcd_bus_locals_dict; 24 | 25 | #endif /* _MODLCD_BUS_H_ */ 26 | 27 | 28 | -------------------------------------------------------------------------------- /ext_mod/lcd_bus/sdl_bus/sdl_bus.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "py/obj.h" 4 | #include "modlcd_bus.h" 5 | #include 6 | 7 | 8 | #ifndef _SDL_BUS_H 9 | #define _SDL_BUS_H 10 | 11 | #define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/ 12 | 13 | #ifdef MP_PORT_UNIX 14 | #include "SDL.h" 15 | #include "SDL_thread.h" 16 | 17 | typedef struct { 18 | int32_t x; 19 | int32_t y; 20 | uint8_t state; 21 | } pointer_event_t; 22 | 23 | typedef struct _panel_io_config_t { 24 | uint16_t width; 25 | uint16_t height; 26 | uint32_t win_id; 27 | void *buf_to_flush; 28 | uint8_t bytes_per_pixel; 29 | int flags; 30 | } panel_io_config_t; 31 | 32 | typedef struct _mp_lcd_sdl_bus_obj_t { 33 | mp_obj_base_t base; 34 | 35 | mp_obj_t callback; 36 | 37 | void *buf1; 38 | void *buf2; 39 | 40 | bool trans_done; 41 | bool rgb565_byte_swap; 42 | 43 | lcd_panel_io_t panel_io_handle; 44 | 45 | panel_io_config_t panel_io_config; 46 | SDL_Window *window; 47 | SDL_Renderer *renderer; 48 | SDL_Texture *texture; 49 | 50 | pointer_event_t pointer_event; 51 | mp_obj_t keypad_callback; 52 | mp_obj_t window_callback; 53 | mp_obj_t mouse_callback; 54 | mp_obj_t quit_callback; 55 | 56 | bool ignore_size_chg; 57 | bool inited; 58 | 59 | } mp_lcd_sdl_bus_obj_t; 60 | 61 | extern const mp_obj_type_t mp_lcd_sdl_bus_type; 62 | #endif 63 | #endif 64 | -------------------------------------------------------------------------------- /ext_mod/lcd_utils/include/binary_float.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "py/obj.h" 4 | #include "py/runtime.h" 5 | 6 | #ifndef __BINARY_FLOAT_H__ 7 | #define __BINARY_FLOAT_H__ 8 | extern const mp_obj_fun_builtin_var_t mp_lcd_utils_int_float_converter_obj; 9 | #endif /* __BINARY_FLOAT_H__ */ -------------------------------------------------------------------------------- /ext_mod/lcd_utils/include/remap.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "py/obj.h" 4 | #include "py/runtime.h" 5 | 6 | #ifndef __REMAP_H__ 7 | #define __REMAP_H__ 8 | extern const mp_obj_fun_builtin_var_t mp_lcd_utils_remap_obj; 9 | #endif /* __REMAP_H__ */ -------------------------------------------------------------------------------- /ext_mod/lcd_utils/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # Create an INTERFACE library for our C module. 4 | 5 | add_library(usermod_lcd_utils INTERFACE) 6 | 7 | set(LCD_UTILS_INCLUDES) 8 | 9 | set(LCD_UTILS_SOURCES 10 | ${CMAKE_CURRENT_LIST_DIR}/src/lcd_utils.c 11 | ${CMAKE_CURRENT_LIST_DIR}/src/remap.c 12 | ${CMAKE_CURRENT_LIST_DIR}/src/binary_float.c 13 | ) 14 | 15 | # Add our source files to the lib 16 | target_sources(usermod_lcd_utils INTERFACE ${LCD_UTILS_SOURCES}) 17 | 18 | # Add include directories. 19 | target_include_directories(usermod_lcd_utils INTERFACE ${LCD_UTILS_INCLUDES}) 20 | 21 | # Link our INTERFACE library to the usermod target. 22 | target_link_libraries(usermod INTERFACE usermod_lcd_utils) 23 | -------------------------------------------------------------------------------- /ext_mod/lcd_utils/micropython.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | ################################################################################ 4 | # lcd_bus build rules 5 | 6 | MOD_DIR := $(USERMOD_DIR) 7 | 8 | ifneq (,$(findstring -Wno-missing-field-initializers, $(CFLAGS_USERMOD))) 9 | CFLAGS_USERMOD += -Wno-missing-field-initializers 10 | endif 11 | 12 | SRC_USERMOD_C += $(MOD_DIR)/src/lcd_utils.c 13 | SRC_USERMOD_C += $(MOD_DIR)/src/remap.c 14 | SRC_USERMOD_C += $(MOD_DIR)/src/binary_float.c 15 | -------------------------------------------------------------------------------- /ext_mod/lcd_utils/src/binary_float.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "../include/remap.h" 4 | 5 | #include "py/obj.h" 6 | #include "py/runtime.h" 7 | 8 | 9 | typedef union { 10 | float f; 11 | uint32_t i; 12 | } converter_t; 13 | 14 | 15 | static mp_obj_t mp_lcd_utils_int_float_converter(size_t n_args, const mp_obj_t *args) 16 | { 17 | converter_t u; 18 | 19 | if (mp_obj_is_float(args[0])) { 20 | u.f = mp_obj_get_float_to_f(args[0]); 21 | return mp_obj_new_int_from_uint(u.i); 22 | } else { 23 | u.i = (uint32_t)mp_obj_get_int_truncated(args[0]); 24 | return mp_obj_new_float_from_f(u.f); 25 | } 26 | } 27 | 28 | MP_DEFINE_CONST_FUN_OBJ_VAR(mp_lcd_utils_int_float_converter_obj, 1, mp_lcd_utils_int_float_converter); 29 | -------------------------------------------------------------------------------- /ext_mod/lcd_utils/src/lcd_utils.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "../include/remap.h" 4 | #include "../include/binary_float.h" 5 | 6 | #include "py/obj.h" 7 | #include "py/runtime.h" 8 | 9 | 10 | static mp_obj_t spi_mode_to_polarity_phase(mp_obj_t mode) 11 | { 12 | uint8_t spi_mode = (uint8_t)mp_obj_get_int_truncated(mode); 13 | uint8_t polarity = (spi_mode >> 1) & 0x1; 14 | uint8_t phase = spi_mode & 0x1; 15 | mp_obj_t tuple[2] = { 16 | mp_obj_new_int_from_uint(polarity), 17 | mp_obj_new_int_from_uint(phase), 18 | }; 19 | return mp_obj_new_tuple(2, tuple); 20 | } 21 | 22 | static MP_DEFINE_CONST_FUN_OBJ_1(spi_mode_to_polarity_phase_obj, spi_mode_to_polarity_phase); 23 | 24 | 25 | static mp_obj_t spi_polarity_phase_to_mode(mp_obj_t polarity, mp_obj_t phase) 26 | { 27 | uint8_t spi_polarity = (uint8_t)mp_obj_get_int_truncated(polarity); 28 | uint8_t spi_phase = (uint8_t)mp_obj_get_int_truncated(phase); 29 | uint8_t spi_mode = ((spi_polarity & 0x1) << 1) | (spi_phase & 0x1); 30 | 31 | return mp_obj_new_int_from_uint(spi_mode); 32 | } 33 | 34 | static MP_DEFINE_CONST_FUN_OBJ_2(spi_polarity_phase_to_mode_obj, spi_polarity_phase_to_mode); 35 | 36 | 37 | static const mp_rom_map_elem_t mp_lcd_utils_module_globals_table[] = { 38 | { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_lcd_utils) }, 39 | { MP_ROM_QSTR(MP_QSTR_remap), MP_ROM_PTR(&mp_lcd_utils_remap_obj) }, 40 | { MP_ROM_QSTR(MP_QSTR_int_float_converter), MP_ROM_PTR(&mp_lcd_utils_int_float_converter_obj) }, 41 | { MP_ROM_QSTR(MP_QSTR_spi_mode_to_polarity_phase), MP_ROM_PTR(&spi_mode_to_polarity_phase_obj) }, 42 | { MP_ROM_QSTR(MP_QSTR_spi_polarity_phase_to_mode), MP_ROM_PTR(&spi_polarity_phase_to_mode_obj) }, 43 | 44 | }; 45 | 46 | static MP_DEFINE_CONST_DICT(mp_lcd_utils_module_globals, mp_lcd_utils_module_globals_table); 47 | 48 | 49 | const mp_obj_module_t mp_module_lcd_utils = { 50 | .base = {&mp_type_module}, 51 | .globals = (mp_obj_dict_t *)&mp_lcd_utils_module_globals, 52 | }; 53 | 54 | MP_REGISTER_MODULE(MP_QSTR_lcd_utils, mp_module_lcd_utils); -------------------------------------------------------------------------------- /ext_mod/lcd_utils/src/remap.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "../include/remap.h" 4 | 5 | #include "py/obj.h" 6 | #include "py/runtime.h" 7 | 8 | static mp_obj_t mp_lcd_utils_remap(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { 9 | 10 | enum { ARG_value, ARG_old_min, ARG_old_max, ARG_new_min, ARG_new_max}; 11 | static const mp_arg_t allowed_args[] = { 12 | { MP_QSTR_value, MP_ARG_OBJ | MP_ARG_REQUIRED }, 13 | { MP_QSTR_old_min, MP_ARG_OBJ | MP_ARG_REQUIRED }, 14 | { MP_QSTR_old_max, MP_ARG_OBJ | MP_ARG_REQUIRED }, 15 | { MP_QSTR_new_min, MP_ARG_OBJ | MP_ARG_REQUIRED }, 16 | { MP_QSTR_new_max, MP_ARG_OBJ | MP_ARG_REQUIRED }, 17 | }; 18 | 19 | mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; 20 | mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); 21 | 22 | float value; 23 | float old_min; 24 | float old_max; 25 | float new_min; 26 | float new_max; 27 | float ret_val; 28 | 29 | bool is_float = (mp_obj_is_float(args[ARG_value].u_obj) || 30 | mp_obj_is_float(args[ARG_old_min].u_obj) || mp_obj_is_float(args[ARG_old_max].u_obj) || 31 | mp_obj_is_float(args[ARG_new_min].u_obj) || mp_obj_is_float(args[ARG_new_max].u_obj) 32 | ) ? true: false; 33 | 34 | if (mp_obj_is_float(args[ARG_value].u_obj)) value = mp_obj_get_float_to_f(args[ARG_value].u_obj); 35 | else value = mp_obj_get_int(args[ARG_value].u_obj) * 1.0f; 36 | 37 | if (mp_obj_is_float(args[ARG_old_min].u_obj)) old_min = mp_obj_get_float_to_f(args[ARG_old_min].u_obj); 38 | else old_min = mp_obj_get_int(args[ARG_old_min].u_obj) * 1.0f; 39 | 40 | if (mp_obj_is_float(args[ARG_old_max].u_obj)) old_max = mp_obj_get_float_to_f(args[ARG_old_max].u_obj); 41 | else old_max = mp_obj_get_int(args[ARG_old_max].u_obj) * 1.0f; 42 | 43 | if (mp_obj_is_float(args[ARG_new_min].u_obj)) new_min = mp_obj_get_float_to_f(args[ARG_new_min].u_obj); 44 | else new_min = mp_obj_get_int(args[ARG_new_min].u_obj) * 1.0f; 45 | 46 | if (mp_obj_is_float(args[ARG_new_max].u_obj)) new_max = mp_obj_get_float_to_f(args[ARG_new_max].u_obj); 47 | else new_max = mp_obj_get_int(args[ARG_new_max].u_obj) * 1.0f; 48 | 49 | ret_val = (((value - old_min) * (new_max - new_min)) / (old_max - old_min)) + new_min; 50 | 51 | if (is_float) return mp_obj_new_float_from_f(ret_val); 52 | else return mp_obj_new_int((int)ret_val); 53 | } 54 | 55 | MP_DEFINE_CONST_FUN_OBJ_KW(mp_lcd_utils_remap_obj, 5, mp_lcd_utils_remap); -------------------------------------------------------------------------------- /ext_mod/lvgl/mem_core.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_malloc_core.c 3 | */ 4 | 5 | /********************* 6 | * INCLUDES 7 | *********************/ 8 | #include "lvgl/src/stdlib/lv_mem.h" 9 | #if LV_USE_STDLIB_MALLOC == LV_STDLIB_MPY 10 | #include 11 | #include 12 | #include 13 | /********************* 14 | * DEFINES 15 | *********************/ 16 | 17 | /********************** 18 | * TYPEDEFS 19 | **********************/ 20 | 21 | /********************** 22 | * STATIC PROTOTYPES 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC VARIABLES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | /********************** 34 | * GLOBAL FUNCTIONS 35 | **********************/ 36 | 37 | void lv_mem_init(void) 38 | { 39 | return; /*Nothing to init*/ 40 | } 41 | 42 | void lv_mem_deinit(void) 43 | { 44 | return; /*Nothing to deinit*/ 45 | 46 | } 47 | 48 | lv_mem_pool_t lv_mem_add_pool(void * mem, size_t bytes) 49 | { 50 | /*Not supported*/ 51 | LV_UNUSED(mem); 52 | LV_UNUSED(bytes); 53 | return NULL; 54 | } 55 | 56 | void lv_mem_remove_pool(lv_mem_pool_t pool) 57 | { 58 | /*Not supported*/ 59 | LV_UNUSED(pool); 60 | return; 61 | } 62 | 63 | void * lv_malloc_core(size_t size) 64 | { 65 | #if MICROPY_MALLOC_USES_ALLOCATED_SIZE 66 | return gc_alloc(size, true); 67 | #else 68 | return m_malloc(size); 69 | #endif 70 | } 71 | 72 | void * lv_realloc_core(void * p, size_t new_size) 73 | { 74 | 75 | #if MICROPY_MALLOC_USES_ALLOCATED_SIZE 76 | return gc_realloc(p, new_size, true); 77 | #else 78 | return m_realloc(p, new_size); 79 | #endif 80 | } 81 | 82 | void lv_free_core(void * p) 83 | { 84 | 85 | #if MICROPY_MALLOC_USES_ALLOCATED_SIZE 86 | gc_free(p); 87 | 88 | #else 89 | m_free(p); 90 | #endif 91 | } 92 | 93 | void lv_mem_monitor_core(lv_mem_monitor_t * mon_p) 94 | { 95 | /*Not supported*/ 96 | LV_UNUSED(mon_p); 97 | return; 98 | } 99 | 100 | lv_result_t lv_mem_test_core(void) 101 | { 102 | /*Not supported*/ 103 | return LV_RESULT_OK; 104 | } 105 | 106 | /********************** 107 | * STATIC FUNCTIONS 108 | **********************/ 109 | 110 | #endif /*LV_STDLIB_MICROPYTHON*/ -------------------------------------------------------------------------------- /ext_mod/lvgl/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # This file is to be given as "make USER_C_MODULES=..." when building Micropython port 4 | 5 | find_package(Python3 REQUIRED COMPONENTS Interpreter) 6 | 7 | get_filename_component(BINDING_DIR ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE) 8 | 9 | separate_arguments(LV_CFLAGS_ENV UNIX_COMMAND $ENV{LV_CFLAGS}) 10 | list(APPEND LV_CFLAGS 11 | ${LV_CFLAGS_ENV} 12 | -Wno-unused-function 13 | -DMICROPY_FLOAT=1 14 | ) 15 | 16 | separate_arguments(SECOND_BUILD_ENV UNIX_COMMAND $ENV{SECOND_BUILD}) 17 | 18 | set(LVGL_DIR "${BINDING_DIR}/lib/lvgl") 19 | 20 | 21 | file(GLOB_RECURSE LVGL_HEADERS ${BINDING_DIR}/lib/lvgl/src/*.h ${BINDING_DIR}/lib/lv_conf.h) 22 | 23 | # this MUST be an execute_process because of the order in which cmake does things 24 | # if add_custom_command is used it errors becasue add_custom_command doesn't 25 | # actually run before the lv_mp.c file gets added to the source list. That causes 26 | # the compilation to error because the source file doesn't exist. It needs to 27 | # exist before it gets added to the source list and this is the only way I have 28 | # found to go about doing it. 29 | 30 | if(${SECOND_BUILD_ENV} EQUAL "0") 31 | 32 | execute_process( 33 | COMMAND 34 | ${Python3_EXECUTABLE} ${BINDING_DIR}/gen/$ENV{GEN_SCRIPT}_api_gen_mpy.py ${LV_CFLAGS} --output=${CMAKE_BINARY_DIR}/lv_mp.c --include=${BINDING_DIR}/lib --include=${BINDING_DIR}/lib/lvgl --board=$ENV{LV_PORT} --module_name=lvgl --module_prefix=lv --metadata=${CMAKE_BINARY_DIR}/lv_mp.c.json --header_file=${LVGL_DIR}/lvgl.h 35 | WORKING_DIRECTORY 36 | ${CMAKE_CURRENT_LIST_DIR} 37 | 38 | RESULT_VARIABLE mpy_result 39 | OUTPUT_VARIABLE mpy_output 40 | ) 41 | 42 | if(${mpy_result} GREATER "0") 43 | message("OUTPUT: ${mpy_output}") 44 | message("RESULT: ${mpy_result}") 45 | message( FATAL_ERROR "Failed to generate ${CMAKE_BINARY_DIR}/lv_mp.c" ) 46 | endif() 47 | endif() 48 | 49 | # file(WRITE ${CMAKE_BINARY_DIR}/lv_mp.c ${mpy_output}) 50 | 51 | file(GLOB_RECURSE LVGL_SOURCES ${BINDING_DIR}/lib/lvgl/src/*.c) 52 | list(APPEND LVGL_SOURCES 53 | ${BINDING_DIR}/ext_mod/lvgl/mem_core.c 54 | ) 55 | 56 | add_library(lvgl_interface INTERFACE) 57 | 58 | target_sources(lvgl_interface INTERFACE ${LVGL_SOURCES}) 59 | target_compile_options(lvgl_interface INTERFACE ${LV_CFLAGS}) 60 | 61 | set(LVGL_MPY_INCLUDES 62 | ${BINDING_DIR}/lib/micropython 63 | ${BINDING_DIR}/lib 64 | ${BINDING_DIR}/lib/lvgl 65 | ) 66 | 67 | add_library(usermod_lvgl INTERFACE) 68 | target_sources(usermod_lvgl INTERFACE ${CMAKE_BINARY_DIR}/lv_mp.c) 69 | target_include_directories(usermod_lvgl INTERFACE ${LVGL_MPY_INCLUDES}) 70 | target_link_libraries(usermod_lvgl INTERFACE lvgl_interface) 71 | target_link_libraries(usermod INTERFACE usermod_lvgl) 72 | -------------------------------------------------------------------------------- /ext_mod/lvgl/micropython.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | ################################################################################ 4 | # LVGL build rules 5 | 6 | 7 | MOD_DIR := $(USERMOD_DIR) 8 | LVGL_BINDING_DIR = $(subst /ext_mod/lvgl,,$(MOD_DIR)) 9 | 10 | LIB_DIR = $(LVGL_BINDING_DIR)/lib 11 | LVGL_DIR = $(LVGL_BINDING_DIR)/lib/lvgl 12 | 13 | CURRENT_DIR = $(LVGL_BINDING_DIR)/ext_mod/lvgl 14 | CFLAGS_USERMOD += -I$(LVGL_DIR) 15 | CFLAGS_USERMOD += -I$(LIB_DIR) 16 | 17 | 18 | ifdef $(LV_CFLAGS) 19 | CFLAGS_USERMOD += $(LV_CFLAGS) 20 | endif 21 | 22 | ifneq (,$(findstring -Wno-missing-field-initializers, $(CFLAGS_USERMOD))) 23 | CFLAGS_USERMOD += -Wno-missing-field-initializers 24 | endif 25 | 26 | 27 | ALL_LVGL_SRC = $(shell find $(LVGL_DIR) -type f -name '*.h') $(LVGL_BINDING_DIR)/lib/lv_conf.h 28 | 29 | LVGL_MPY = $(BUILD)/lv_mpy.c 30 | LVGL_MPY_METADATA = $(BUILD)/lv_mpy.json 31 | 32 | 33 | SRC_USERMOD_LIB_C += $(shell find $(LVGL_DIR)/src -type f -name "*.c") 34 | SRC_USERMOD_LIB_C += $(CURRENT_DIR)/mem_core.c 35 | SRC_USERMOD_C += $(LVGL_MPY) 36 | 37 | $(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/$(GEN_SCRIPT)_api_gen_mpy.py 38 | $(ECHO) "LVGL-GEN $@" 39 | $(Q)mkdir -p $(dir $@) 40 | 41 | $(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/$(GEN_SCRIPT)_api_gen_mpy.py $(LV_CFLAGS) --board=$(LV_PORT) --output=$(LVGL_MPY) --include=$(LIB_DIR) --include=$(LVGL_DIR) --module_name=lvgl --module_prefix=lv --metadata=$(LVGL_MPY_METADATA) --header_file=$(LVGL_DIR)/lvgl.h 42 | 43 | .PHONY: LVGL_MPY 44 | LVGL_MPY: $(LVGL_MPY) 45 | 46 | -------------------------------------------------------------------------------- /ext_mod/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | if(ESP_PLATFORM) 4 | include(${CMAKE_CURRENT_LIST_DIR}/esp32_components.cmake) 5 | include(${CMAKE_CURRENT_LIST_DIR}/spi3wire/micropython.cmake) 6 | endif(ESP_PLATFORM) 7 | 8 | include(${CMAKE_CURRENT_LIST_DIR}/lcd_bus/micropython.cmake) 9 | include(${CMAKE_CURRENT_LIST_DIR}/lvgl/micropython.cmake) 10 | include(${CMAKE_CURRENT_LIST_DIR}/lcd_utils/micropython.cmake) 11 | 12 | if(DEFINED ENV{FUSION}) 13 | include(${CMAKE_CURRENT_LIST_DIR}/imu_fusion/micropython.cmake) 14 | endif() 15 | -------------------------------------------------------------------------------- /ext_mod/spi3wire/include/spi3wire.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef __SPI3WIRE_H__ 4 | #define __SPI3WIRE_H__ 5 | 6 | // micropython includes 7 | #include "mphalport.h" 8 | #include "py/obj.h" 9 | 10 | #include "esp_lcd_panel_io_additions.h" 11 | #include "esp_lcd_panel_io.h" 12 | 13 | #if CONFIG_LCD_ENABLE_DEBUG_LOG 14 | #define SPI3WIRE_DEBUG_PRINT(...) mp_printf(&mp_plat_print, __VA_ARGS__); 15 | #else 16 | #define SPI3WIRE_DEBUG_PRINT(...) 17 | #endif 18 | 19 | typedef struct { 20 | mp_obj_base_t base; 21 | 22 | esp_lcd_panel_io_handle_t panel_io_handle; 23 | esp_lcd_panel_io_3wire_spi_config_t *io_config; 24 | } mp_spi3wire_obj_t; 25 | 26 | extern const mp_obj_type_t mp_spi3wire_type; 27 | 28 | extern void mp_spi3wire_deinit_all(void); 29 | 30 | #endif -------------------------------------------------------------------------------- /ext_mod/spi3wire/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | # Create an INTERFACE library for our C module. 4 | add_library(usermod_spi3wire INTERFACE) 5 | 6 | set(SPI3WIRE_INCLUDES 7 | ${CMAKE_CURRENT_LIST_DIR} 8 | ${CMAKE_CURRENT_LIST_DIR}/include 9 | ) 10 | 11 | set(SPI3WIRE_SOURCES 12 | ${CMAKE_CURRENT_LIST_DIR}/src/spi3wire.c 13 | ${CMAKE_CURRENT_LIST_DIR}/src/esp_lcd_panel_io_3wire_spi.c 14 | ) 15 | 16 | 17 | # Add our source files to the lib 18 | target_sources(usermod_spi3wire INTERFACE ${SPI3WIRE_SOURCES}) 19 | 20 | # Add include directories. 21 | target_include_directories(usermod_spi3wire INTERFACE ${SPI3WIRE_INCLUDES}) 22 | 23 | # Link our INTERFACE library to the usermod target. 24 | target_link_libraries(usermod INTERFACE usermod_spi3wire) 25 | -------------------------------------------------------------------------------- /fusion.pyi: -------------------------------------------------------------------------------- 1 | from typing import Callable, Tuple 2 | 3 | 4 | class Fusion: 5 | 6 | def __init__(self, declination: float | None = None): 7 | ... 8 | 9 | def calibrate(self, mag_xyz: Callable[[], Tuple[float, float, float]], stopfunc: Callable[[], bool], /): 10 | ... 11 | 12 | def update(self, 13 | accel: Tuple[float, float, float], 14 | gyro: Tuple[float, float, float], 15 | mag: Tuple[float, float, float] | None = None 16 | ) -> Tuple[float, float, float]: 17 | ... 18 | -------------------------------------------------------------------------------- /gen/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | lextab.py 3 | yacctab.py 4 | 5 | -------------------------------------------------------------------------------- /gen/fake_libc/X11/Intrinsic.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | #include "_X11_fake_defines.h" 4 | #include "_X11_fake_typedefs.h" 5 | -------------------------------------------------------------------------------- /gen/fake_libc/X11/Xlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | #include "_X11_fake_defines.h" 4 | #include "_X11_fake_typedefs.h" 5 | -------------------------------------------------------------------------------- /gen/fake_libc/X11/_X11_fake_defines.h: -------------------------------------------------------------------------------- 1 | #ifndef _X11_FAKE_DEFINES_H 2 | #define _X11_FAKE_DEFINES_H 3 | 4 | #define Atom CARD32 5 | #define Bool int 6 | #define KeySym CARD32 7 | #define Pixmap CARD32 8 | #define Time CARD32 9 | #define _XFUNCPROTOBEGIN 10 | #define _XFUNCPROTOEND 11 | #define _Xconst const 12 | 13 | #define _X_RESTRICT_KYWD 14 | #define Cardinal unsigned int 15 | #define Boolean int 16 | #endif 17 | -------------------------------------------------------------------------------- /gen/fake_libc/X11/_X11_fake_typedefs.h: -------------------------------------------------------------------------------- 1 | #ifndef _X11_FAKE_TYPEDEFS_H 2 | #define _X11_FAKE_TYPEDEFS_H 3 | 4 | typedef char* XPointer; 5 | typedef unsigned char KeyCode; 6 | typedef unsigned int CARD32; 7 | typedef unsigned long VisualID; 8 | typedef unsigned long XIMResetState; 9 | typedef unsigned long XID; 10 | typedef XID Window; 11 | typedef XID Colormap; 12 | typedef XID Cursor; 13 | typedef XID Drawable; 14 | typedef void* XtPointer; 15 | typedef XtPointer XtRequestId; 16 | typedef struct Display Display; 17 | typedef struct Screen Screen; 18 | typedef struct Status Status; 19 | typedef struct Visual Visual; 20 | typedef struct Widget *Widget; 21 | typedef struct XColor XColor; 22 | typedef struct XClassHint XClassHint; 23 | typedef struct XEvent XEvent; 24 | typedef struct XFontStruct XFontStruct; 25 | typedef struct XGCValues XGCValues; 26 | typedef struct XKeyEvent XKeyEvent; 27 | typedef struct XKeyPressedEvent XKeyPressedEvent; 28 | typedef struct XPoint XPoint; 29 | typedef struct XRectangle XRectangle; 30 | typedef struct XSelectionRequestEvent XSelectionRequestEvent; 31 | typedef struct XWindowChanges XWindowChanges; 32 | typedef struct _XGC _XCG; 33 | typedef struct _XGC *GC; 34 | typedef struct _XIC *XIC; 35 | typedef struct _XIM *XIM; 36 | typedef struct _XImage XImage; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /gen/fake_libc/_ansi.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/_syslist.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/aio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/alloca.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/ar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/argz.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/arpa/inet.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/asm-generic/int-ll64.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/assert.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/complex.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/cpio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/ctype.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/dirent.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/dlfcn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/emmintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/endian.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/envz.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/errno.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/fastmath.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/fcntl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/features.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/fenv.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/float.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/fmtmsg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/fnmatch.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/ftw.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/getopt.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/glob.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/grp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/iconv.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/ieeefp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/immintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/inttypes.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/iso646.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/langinfo.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/libgen.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/libintl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/limits.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/linux/socket.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/linux/version.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/locale.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/malloc.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | 4 | void *malloc(size_t size); 5 | void *realloc(void *memblock, size_t size); 6 | void free(void *memblock); 7 | -------------------------------------------------------------------------------- /gen/fake_libc/math.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/memory.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | 4 | void *memset(void *dest, int c, size_t count); 5 | void *memcpy(void *dest, const void *src, size_t count); 6 | int memcmp(const void *buffer1, const void *buffer2, size_t count); -------------------------------------------------------------------------------- /gen/fake_libc/mir_toolkit/client_types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/monetary.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/mqueue.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/ndbm.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/net/if.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/netdb.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/netinet/in.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/newlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/nl_types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/openssl/err.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/openssl/evp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/openssl/hmac.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/openssl/ssl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/openssl/x509v3.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/paths.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/poll.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/process.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/pthread.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/pwd.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/reent.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/regdef.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/regex.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sched.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/search.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/semaphore.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/setjmp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/signal.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/smmintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/spawn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdalign.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdarg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdbool.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stddef.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | 4 | #define __attribute__(x) 5 | -------------------------------------------------------------------------------- /gen/fake_libc/stdint.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/string.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | 4 | size_t strlen(const char *str); 5 | char *strncpy(char *strDest, const char *strSource, size_t count); 6 | char *strcpy(char *strDestination, const char *strSource); -------------------------------------------------------------------------------- /gen/fake_libc/strings.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/stropts.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/ipc.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/mman.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/msg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/poll.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/resource.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/select.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/sem.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/shm.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/socket.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/stat.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/statvfs.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/sysctl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/time.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/times.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/uio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/un.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/utsname.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/sys/wait.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/syslog.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/tar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/termios.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/tgmath.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/threads.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/time.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/trace.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/types.h: -------------------------------------------------------------------------------- 1 | typedef unsigned int size_t; 2 | typedef long time_t; 3 | 4 | typedef long ptrdiff_t; 5 | 6 | #define NULL ((void *) 0) 7 | 8 | typedef long blkcnt_t 9 | typedef long clock_t 10 | typedef long daddr_t 11 | typedef ulong_t dev_t 12 | typedef ulong_t fsblkcnt_t 13 | typedef ulong_t fsfilcnt_t 14 | typedef int gid_t 15 | typedef int id_t 16 | typedef long ino_t 17 | typedef int key_t 18 | typedef uint_t major_t 19 | typedef uint_t minor_t 20 | typedef uint_t mode_t 21 | typedef uint_t nlink_t 22 | typedef int pid_t 23 | typedef ptrdiff_t intptr_t 24 | typedef ulong_t rlim_t 25 | typedef ulong_t size_t 26 | typedef uint_t speed_t 27 | typedef long ssize_t 28 | typedef long suseconds_t 29 | typedef uint_t tcflag_t 30 | typedef long time_t 31 | typedef int uid_t 32 | typedef int wchar_t 33 | 34 | 35 | typedef int pid_t; 36 | typedef unsigned short uid_t; 37 | typedef unsigned char gid_t; 38 | typedef unsigned short dev_t; 39 | typedef unsigned short ino_t; 40 | typedef unsigned short mode_t; 41 | typedef unsigned short umode_t; 42 | typedef unsigned char nlink_t; 43 | typedef long off_t; 44 | typedef unsigned char u_char; 45 | typedef unsigned short ushort; 46 | 47 | typedef struct { int quot,rem; } div_t; 48 | typedef struct { long quot,rem; } ldiv_t; 49 | typedef struct { long long quot,rem; } lldiv_t; 50 | 51 | struct ustat; -------------------------------------------------------------------------------- /gen/fake_libc/uchar.h: -------------------------------------------------------------------------------- 1 | #include "stdint.h" 2 | 3 | typedef uint_least16_t char16_t; 4 | typedef uint_least32_t char32_t; -------------------------------------------------------------------------------- /gen/fake_libc/ulimit.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/unctrl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/unistd.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/utime.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/utmp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/utmpx.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/vadefs.h: -------------------------------------------------------------------------------- 1 | typedef unsigned int uintptr_t; 2 | typedef char* va_list; 3 | 4 | -------------------------------------------------------------------------------- /gen/fake_libc/vcruntime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvgl-micropython/lvgl_micropython/f7fbf64b19683e988bd66e5e395393cd8b39267e/gen/fake_libc/vcruntime.h -------------------------------------------------------------------------------- /gen/fake_libc/wchar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/wctype.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/wordexp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/xcb/xcb.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /gen/fake_libc/zlib.h: -------------------------------------------------------------------------------- 1 | #ifndef ZLIB_H 2 | #define ZLIB_H 3 | 4 | #include "_fake_defines.h" 5 | #include "_fake_typedefs.h" 6 | 7 | typedef int uInt; 8 | typedef int uLong; 9 | #if !defined(__MACTYPES__) 10 | typedef int Byte; 11 | #endif 12 | 13 | typedef int Bytef; 14 | typedef int charf; 15 | typedef int intf; 16 | typedef int uIntf; 17 | typedef int uLongf; 18 | 19 | typedef int voidpc; 20 | typedef int voidpf; 21 | typedef int voidp; 22 | 23 | #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) 24 | typedef int Z_U4; 25 | #endif 26 | 27 | typedef int z_crc_t; 28 | typedef int z_size_t; 29 | 30 | typedef int alloc_func; 31 | typedef int free_func; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /i2c.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional, Union 4 | from typing import TYPE_CHECKING 5 | 6 | 7 | if TYPE_CHECKING: 8 | import array 9 | 10 | 11 | _BUFFER_TYPE = Union[bytearray, bytes, memoryview, array.array] 12 | 13 | 14 | class I2C(object): 15 | class Bus(object): 16 | 17 | def __init__( 18 | self, 19 | host: Union[str, int], 20 | scl: Union[str, int], 21 | sda: Union[str, int], 22 | freq: int = 4000000, 23 | use_locks: bool = False 24 | ): 25 | ... 26 | 27 | def __enter__(self) -> "I2C.Bus": 28 | ... 29 | 30 | def __exit__(self, exc_type, exc_val, exc_tb) -> None: 31 | ... 32 | 33 | def scan(self) -> list: 34 | ... 35 | 36 | def start(self) -> None: 37 | ... 38 | 39 | def stop(self) -> None: 40 | ... 41 | 42 | def readinto(self, buf: _BUFFER_TYPE, nack: bool = True) -> None: 43 | ... 44 | 45 | def write(self, buf: _BUFFER_TYPE) -> None: 46 | ... 47 | 48 | def readfrom(self, addr: int, nbytes: int, stop: bool = True) -> bytes: 49 | ... 50 | 51 | def readfrom_into(self, addr: int, buf: _BUFFER_TYPE, stop: bool = True) -> None: 52 | ... 53 | 54 | def writeto(self, addr: int, buf: _BUFFER_TYPE, stop: bool = True) -> None: 55 | ... 56 | 57 | def writevto(self, addr: int, vector: list, stop: bool = True) -> None: 58 | ... 59 | 60 | def readfrom_mem(self, addr: int, memaddr: int, nbytes: int, addrsize: int = 8) -> bytes: 61 | ... 62 | 63 | def readfrom_mem_into(self, addr: int, memaddr: int, buf: _BUFFER_TYPE, addrsize: int = 8) -> None: 64 | ... 65 | 66 | def writeto_mem(self, addr: int, memaddr: int, buf: _BUFFER_TYPE, addrsize: int = 8) -> None: 67 | ... 68 | 69 | 70 | class Device(object): 71 | _bus: "I2C.Bus" = ... 72 | dev_id: int = ... 73 | _reg_bits: int = ... 74 | 75 | def __init__(self, bus: "I2C.Bus", dev_id: int, reg_bits: int = 8): 76 | ... 77 | 78 | def write_readinto(self, write_buf: _BUFFER_TYPE, read_buf: _BUFFER_TYPE) -> None: 79 | ... 80 | 81 | def read_mem(self, memaddr: int, num_bytes: Optional[int] = None, buf: Optional[_BUFFER_TYPE] = None) -> Optional[bytes]: 82 | ... 83 | 84 | def write_mem(self, memaddr: int, buf: _BUFFER_TYPE): 85 | ... 86 | 87 | def read(self, nbytes: Optional[int] = None, buf: Optional[_BUFFER_TYPE] = None, stop: bool=True) -> Optional[bytes]: 88 | ... 89 | 90 | def write(self, buf: _BUFFER_TYPE, stop: bool=True) -> None: 91 | ... 92 | -------------------------------------------------------------------------------- /keypad_framework.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional, Tuple 4 | import _indev_base 5 | 6 | 7 | class KeypadDriver(_indev_base.IndevBase): 8 | _last_key: int = ... 9 | 10 | def __init__(self): 11 | ... 12 | 13 | def _get_key(self) -> Optional[Tuple[int, int]]: 14 | """ 15 | Reads the keys from the keypad 16 | 17 | This function needs to return one of the LV_KEY enumerations 18 | 19 | :return: None if there is no keypress or the id of the key 20 | 21 | :raises: NotImplimentedError if the method is not overridden 22 | in the keypad driver 23 | """ 24 | ... 25 | 26 | def reset_long_press(self) -> None: 27 | ... 28 | 29 | 30 | -------------------------------------------------------------------------------- /lcd_utils.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Union 4 | 5 | def remap( 6 | value: Union[float, int], 7 | old_min: Union[float, int], 8 | old_max: Union[float, int], 9 | new_min: Union[float, int], 10 | new_max: Union[float, int] 11 | ) -> Union[float, int]: 12 | """ 13 | Remaps a value from one one range to another range 14 | 15 | NOTE: If any of the parameters is a `float` than the return value is `float`. 16 | If all of the parameters are `int` than the return value is `int`. 17 | 18 | :param value: Value to remap 19 | :param old_min: minimum of the range that value is mapped to 20 | :param old_max: maximum of the range that value is mapped to 21 | :param new_min: minimum of the range to map value to 22 | :param new_max: maximum of the range to map value to 23 | :return: value that has been mapped to new_min and new_max 24 | """ 25 | ... 26 | 27 | 28 | def int_float_converter(value: Union[float, int], /) -> Union[float, int]: 29 | ... 30 | 31 | 32 | def spi_mode_to_polarity_phase(mode: int, /) -> tuple[int]: 33 | """ 34 | 35 | :param mode: spi mode, can be 0, 1, 2 or 3 36 | :type mode: `int` 37 | 38 | :returns: the 2 integer values as `(polarity, phase)` 39 | :rtype: `tuple` 40 | """ 41 | 42 | def spi_polarity_phase_to_mode(polarity: int, phase: int, /) -> int: 43 | """ 44 | :param polarity: 1 or 0 45 | :type polarity: `int` 46 | 47 | :param phase: 1 or 0 48 | :type phase: `int` 49 | 50 | :returns: 0, 1, 2 or 3 51 | :rtype: `int` 52 | """ -------------------------------------------------------------------------------- /micropy_updates/common/mp_spi_common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include 4 | 5 | #include "py/obj.h" 6 | #include "py/runtime.h" 7 | 8 | #ifndef __MP_SPI_COMMON_H__ 9 | #define __MP_SPI_COMMON_H__ 10 | 11 | typedef enum _mp_machine_hw_spi_state_t { 12 | MP_SPI_STATE_STOPPED, 13 | MP_SPI_STATE_STARTED, 14 | MP_SPI_STATE_SENDING 15 | } mp_machine_hw_spi_state_t; 16 | 17 | typedef struct _mp_machine_hw_spi_bus_obj_t mp_machine_hw_spi_bus_obj_t; 18 | typedef struct _mp_machine_hw_spi_device_obj_t mp_machine_hw_spi_device_obj_t; 19 | 20 | struct _mp_machine_hw_spi_bus_obj_t { 21 | mp_obj_base_t base; 22 | uint8_t host; 23 | mp_obj_t sck; 24 | mp_obj_t data0; 25 | mp_obj_t data1; 26 | mp_obj_t data2; 27 | mp_obj_t data3; 28 | mp_obj_t data4; 29 | mp_obj_t data5; 30 | mp_obj_t data6; 31 | mp_obj_t data7; 32 | bool dual; 33 | bool quad; 34 | bool octal; 35 | uint8_t device_count; 36 | mp_machine_hw_spi_device_obj_t **devices; 37 | mp_machine_hw_spi_state_t state; 38 | const void *user_data; 39 | void (*deinit)(mp_machine_hw_spi_bus_obj_t *bus); 40 | }; 41 | 42 | struct _mp_machine_hw_spi_device_obj_t { 43 | mp_obj_base_t base; 44 | uint32_t freq; 45 | uint8_t polarity; 46 | uint8_t phase; 47 | uint8_t bits; 48 | uint8_t firstbit; 49 | bool dual; 50 | bool quad; 51 | bool octal; 52 | bool active; 53 | mp_obj_t cs; 54 | mp_machine_hw_spi_bus_obj_t *spi_bus; 55 | void *user_data; 56 | void (*deinit)(mp_machine_hw_spi_device_obj_t *device); 57 | }; 58 | 59 | void mp_machine_hw_spi_bus_initilize(mp_machine_hw_spi_bus_obj_t *bus); 60 | void mp_machine_hw_spi_bus_add_device(mp_machine_hw_spi_device_obj_t *device); 61 | void mp_machine_hw_spi_bus_remove_device(mp_machine_hw_spi_device_obj_t *device); 62 | 63 | extern const mp_obj_type_t mp_machine_hw_spi_device_type; 64 | extern const mp_obj_type_t mp_machine_hw_spi_bus_type; 65 | 66 | void mp_machine_hw_spi_bus_deinit_all(void); 67 | 68 | #endif /* __MP_SPI_COMMON_H__ */ 69 | -------------------------------------------------------------------------------- /micropy_updates/unix/machine_sdl.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "machine_sdl.h" 4 | #include "SDL.h" 5 | 6 | void init_sdl(void) 7 | { 8 | SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); 9 | SDL_InitSubSystem(SDL_INIT_JOYSTICK); 10 | SDL_InitSubSystem(SDL_INIT_EVENTS); 11 | } 12 | 13 | 14 | void deinit_sdl(void) 15 | { 16 | SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); 17 | SDL_QuitSubSystem(SDL_INIT_JOYSTICK); 18 | SDL_QuitSubSystem(SDL_INIT_EVENTS); 19 | } 20 | -------------------------------------------------------------------------------- /micropy_updates/unix/machine_sdl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #ifndef __MACHINE_SDL_H__ 4 | #define __MACHINE_SDL_H__ 5 | 6 | #define SDL_MAIN_HANDLED 7 | 8 | void init_sdl(void); 9 | void deinit_sdl(void); 10 | 11 | #endif -------------------------------------------------------------------------------- /micropy_updates/unix/machine_timer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | #include "py/obj.h" 4 | #include "py/runtime.h" 5 | 6 | #ifndef __MACHINE_TIMER_H__ 7 | #define __MACHINE_TIMER_H__ 8 | 9 | #define TIMER_COUNT 20 10 | 11 | typedef struct _machine_timer_obj_t { 12 | mp_obj_base_t base; 13 | uint8_t id; 14 | bool active; 15 | 16 | uint8_t repeat; 17 | uint16_t period; 18 | uint16_t ms_ticks; 19 | mp_obj_t callback; 20 | 21 | } machine_timer_obj_t; 22 | 23 | void machine_timer_deinit_all(void); 24 | 25 | #endif // __MACHINE_TIMER_H__ -------------------------------------------------------------------------------- /pointer_framework.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional, Tuple, TYPE_CHECKING 4 | import _indev_base 5 | import lcd_utils as _lcd_utils 6 | import lvgl as _lv # NOQA 7 | 8 | lv = _lv 9 | 10 | 11 | if TYPE_CHECKING: 12 | import touch_cal_data as _touch_cal_data 13 | import display_driver_framework as _display_driver_framework 14 | 15 | 16 | 17 | remap = _lcd_utils.remap 18 | _remap = _lcd_utils.remap 19 | 20 | 21 | class PointerDriver(_indev_base.IndevBase): 22 | _last_x: int = ... 23 | _last_y: int = ... 24 | _orig_width: int = ... 25 | _orig_height: int = ... 26 | _config: _touch_cal_data.TouchCalData = ... 27 | 28 | def __init__(self, touch_cal: Optional[_touch_cal_data.TouchCalData] = None, startup_rotation=lv.DISPLAY_ROTATION._0, debug: bool=False): 29 | ... 30 | 31 | def calibrate(self) -> None: 32 | ... 33 | 34 | @property 35 | def is_calibrated(self) -> bool: 36 | ... 37 | 38 | def _get_coords(self) -> Optional[Tuple[int, int, int]]: 39 | """ 40 | Reads the coordinates from the touch panel 41 | 42 | This is where the work is done by the touch driver. This method MUST 43 | be overridden when a touch driver is made. 44 | 45 | :return: None if there is no touch input or a tuple of (x, y) 46 | if there is touch input 47 | 48 | :raises: NotImplimentedError if the method is not overridden 49 | in the touch driver 50 | """ 51 | ... 52 | 53 | def get_vect(self, point: lv.point_t): 54 | ... 55 | 56 | def get_scroll_obj(self) -> Optional[lv.obj]: 57 | ... 58 | 59 | def get_scroll_dir(self) -> int: 60 | ... 61 | 62 | def get_gesture_dir(self) -> int: 63 | ... 64 | 65 | def get_point(self, point: lv.point_t) -> None: 66 | ... 67 | 68 | def set_cursor(self, cur_obj) -> None: 69 | ... 70 | 71 | def reset_long_press(self) -> None: 72 | ... 73 | -------------------------------------------------------------------------------- /spi3wire.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional 4 | 5 | class Spi3Wire: 6 | 7 | def __init__( 8 | self, 9 | scl: int, 10 | sda: int, 11 | cs: int, 12 | freq: int, 13 | spi_mode: int = 0, 14 | use_dc_bit: bool = True, 15 | dc_zero_on_data: bool = False, 16 | lsb_first: bool = False, 17 | cs_high_active: bool = False, 18 | del_keep_cs_inactive: bool = False, 19 | ): 20 | ... 21 | 22 | def __del__(self): 23 | ... 24 | 25 | def init(self, cmd_bits: int, param_bits: int) -> None: 26 | ... 27 | 28 | def deinit(self) -> None: 29 | ... 30 | 31 | def tx_param(self, cmd: int, params: Optional[memoryview]=None): 32 | ... 33 | -------------------------------------------------------------------------------- /task_handler.pyi: -------------------------------------------------------------------------------- 1 | # MIT license; Copyright (c) 2021 Amir Gonnen 2 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 3 | 4 | from typing import Callable, ClassVar, Optional 5 | from machine import Timer 6 | 7 | _default_timer_id: int = ... 8 | 9 | 10 | def _default_exception_hook(e: Exception): 11 | ... 12 | 13 | ############################################################################## 14 | 15 | class TaskHandler(object): 16 | _current_instance: Optional[ClassVar["TaskHandler"]] = ... 17 | 18 | duration: int = ... 19 | refresh_cb: Optional[Callable] = ... 20 | _timer: Timer = ... 21 | _task_handler_ref: Callable = ... 22 | 23 | exception_hook: Callable[[Exception], None] = ... 24 | max_scheduled: int = ... 25 | _scheduled: int = ... 26 | 27 | def __init__( 28 | self, 29 | duration: int = 33, 30 | timer_id: int = _default_timer_id, 31 | max_scheduled: int = 2, 32 | refresh_cb: Optional[Callable] = None, 33 | exception_hook: Callable[[Exception], None] = _default_exception_hook 34 | ): 35 | ... 36 | 37 | def deinit(self) -> None: 38 | ... 39 | 40 | def disable(self) -> None: 41 | ... 42 | 43 | def enable(self) -> None: 44 | ... 45 | 46 | @classmethod 47 | def is_running(cls) -> bool: 48 | ... 49 | 50 | def _task_handler(self, _) -> None: 51 | ... 52 | 53 | def _timer_cb(self, _) -> None: 54 | ... 55 | -------------------------------------------------------------------------------- /touch_cal_data.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Optional 4 | 5 | # this class is used as a template for writing the mechanism that is 6 | # used to store the touch screen calibration data. All properties and functions 7 | # seen in this class need to exist in the class that is written to store the 8 | # touch calibration data. 9 | 10 | # For more information on how to do this see the touch calibration for the ESP32 11 | 12 | class TouchCalData(object): 13 | 14 | def __init__(self, name): 15 | ... 16 | def save(self): 17 | ... 18 | 19 | @property 20 | def left(self) -> Optional[int]: 21 | ... 22 | 23 | @left.setter 24 | def left(self, value: int): 25 | ... 26 | 27 | @property 28 | def right(self) -> Optional[int]: 29 | ... 30 | 31 | @right.setter 32 | def right(self, value: int): 33 | ... 34 | 35 | @property 36 | def top(self) -> Optional[int]: 37 | ... 38 | 39 | @top.setter 40 | def top(self, value: int): 41 | ... 42 | 43 | @property 44 | def bottom(self) -> Optional[int]: 45 | ... 46 | 47 | @bottom.setter 48 | def bottom(self, value: int): 49 | ... 50 | 51 | def reset(self): 52 | ... 53 | -------------------------------------------------------------------------------- /touch_calibrate.pyi: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 - 2025 Kevin G. Schlosser 2 | 3 | from typing import Tuple 4 | 5 | import lvgl as lv 6 | 7 | style: lv.style_t = ... 8 | 9 | 10 | class Tpcal_point(object): 11 | 12 | def __init__(self, x, y, name): 13 | ... 14 | 15 | def __repr__(self): 16 | ... 17 | 18 | 19 | class Tpcal(object): 20 | 21 | def __init__(self, touch_count=500): 22 | ... 23 | 24 | def show_text(self, txt): 25 | ... 26 | 27 | def show_circle(self): 28 | ... 29 | 30 | def calibrate_clicked(self, x, y): 31 | ... 32 | 33 | def check(self): 34 | ... 35 | 36 | def calibrate(self, points) -> Tuple[(int, int, int, int)]: 37 | ... 38 | 39 | 40 | # Run calibration 41 | def run(): 42 | ... 43 | 44 | --------------------------------------------------------------------------------