For use with an 8-bit parallel TFT touchscreen using micropython

Overview

ILI9341-parallel-TFT-driver-for-micropython

For use with an 8-bit parallel TFT touchscreen using micropython. Many thanks to prenticedavid and his MCUFriend TFT library, written in C code and from which I derived this micropython driver. Thank you also to Roberthh on the micropython forum for all his very instructive posts about the use of the micropython viper decorator. This helped me much !

You'll find 2 different ILI9341 drivers for micropython in this repository :
ILI9341_ESP32 -> for use with standard ESP32 microcontroller
ILI9341_RP2 -> for use with Raspberry PICO microcontroller

For the ESP32, it's working well but I sometime have memory issues, in this case use of gc.collect() might be usefull

Both libraries have been fully tested using micropython 1.17

These libraries are exclusively purposed for an 8bit parallel Touchscreen using the ILI9341 driver. Like the ones you find on this page : http://www.lcdwiki.com/2.8inch_Arduino_Display

image image

These libraries include 3 different fonts.

The libraries use micropython_viper decorator to improve speed and achieve reasonable graphic display speed

How to use the files in the repository :

1. After installing micropython on your device:

copy the full content of the corresponding folder to the root directory (using Thonny, Rshell or wathever software you usually use)

2. Short description of the files :

ILI9341.py : Main LCD display library, must be imported in full in the py program in order to use all the features, from this library you can declare a "screen" class object

ILI9341_touch.py : Touchscreen library, must be imported if you need to use the touch feature of the display, from this library you can declare a "touchscreen" class object

ILI9341_char.py : Used to draw characters from the font libraries

sdcard.py : Library to use for SD card access (The ILI9341 parallel display has an integrated micro SD card reader)

FreeMono12pt7b.py : Big fonts
FreeMono9pt7b.py : Medium fonts
FreeSansSerif7pt7b.py : Small fonts

main.py : First example; loaded by default, a test of various routines and a mesaure of the display time
mainfull.py : The example above + touchscreen calibration
scroll.py : An example of a scrolling text (The ILI9341 parallel display has a hardware scrolling feature)

SdcardTimerTest.py : An example to set and display the time and print on screen the content of the SDcard

All the examples above start by setting the pins connected to the display (and if needed to the SD card pins)

3. Pin definition

3.1 Pin definition for the LCD display

LCD_RD = 2
LCD_WR = 4
LCD_RS = 32 # RS & CS pins must be ADC and OUTPUT
LCD_CS = 33 # for touch capability -> For ESP32 only pins 32 & 33 - For PICO only pins 26,27 & 28
LCD_RST = 22
LCD_D0 = 12
LCD_D1 = 13
LCD_D2 = 26
LCD_D3 = 25
LCD_D4 = 17
LCD_D5 = 16
LCD_D6 = 27
LCD_D7 = 14

3.2 Pin definition for the touchscreen

XP = LCD_D0 #
YM = LCD_D1 # Those four pins are used for the touchscreen
YP = LCD_CS # Please note that CS and RS are the same as for the display above
XM = LCD_RS #

Except for the RS and CS pins, you can choose any I/O pin, but be aware that to use the SDcard you will need an available SPI, so save at least one set of SPI pins for this !

4. Touchsceen calibration procedure

Once you have loaded the "main_full_test_LCD_TOUCH.py" file, after a few tests you'll see on screen the calibration procédure. It is a basic set of green crosses you have to touch and when it's done calcultations are made to interpolate the x and y position with the ADC values. Once it is complete you'll find the results giving a set of parameters:

Cal. result : Pos(pixel) = a * ADC_val + b

Short direction ->  a = -0.005244441
                    b = 292.7332

Long direction  ->  a = 0.006892291
                    b = -72.781

Touch anywhere to test !

What you have to do is copy these paramters in the ILI9341_touch.py library :

self.coeff_short = results above for Short direction a
self.const_short = results above for Short direction b
self.coeff_long = results above for Long direction a
self.const_long = results above for Long direction b

and that's it ! See a full video of the process :https://drive.google.com/file/d/1L7yVWag6e606RgQF5fxj9b6aB8_0982Q/view?usp=sharing

5. Using the routines

5.1 Display routines

Once you've declared your "screen" class object using tft=ILI9341.screen(LCD_RD,LCD_WR,LCD_RS,LCD_CS,LCD_RST,LCD_D0,LCD_D1,LCD_D2,LCD_D3,LCD_D4,LCD_D5,LCD_D6,LCD_D7)

the following commands are availabe :

tft.begin() : You have to start with this one, this initiates and resets the display
tft.fillscreen(Color) : Fill the entire screen with the corresponding color (16-bit color value)
tft.setrotation(0) : 0 an 2 are portrait mode, 1 and 3 are landscape mode
tft.fillRect(start x,start y, width, height ,color) : Draw a filled rectangle
tft.drawFastVLine(start x,start y, length, color) : Draw a vertical line
tft.drawFastHLine(start x,start y, length, color) : Draw an horizontal line
tft.drawLine(start x,start y, end x, end y, color) : Draw any other type of line
tft.drawPixel(x, y, color) : Draw a Pixel
tft.drawCircle(x, y, r, color) : Draw a circle, x,y = center position, r = radius in pixels
tft.fillDisk(x, y, r, color) : Draw a completely filled disk x,y = center position, r = radius in pixels
tft.drawDisk(x, y, y, r1, r2, color) : Draw a ring x,y = center position, r1 = inner radius in pixels, r2 = outer radius in pixels

tft.SetFont(i) : i 1 or 2 or 3 at the moment since only 3 fonts are available - A font MUST BE SET in order to use the following text features
tft.setTextColor(color) : Sets the characters color (16-bit value)
tft.setTextCursor(x,y) : Position the text cursor at the desired value - This position is the lowest-left pixel to start character printing
tft.printh(String) : Print the string, add a "\n" character at the end for linefeed
tft.prints(String) : Same as printh, but with a very cool scrolling additional feature (only in portrait mode) ! (see example)

5.2 Touch routines

Once you've declared your "screen" class object using ts = ILI9341_touch.touchscreen(XP, YP, XM, YM)

the following commands are availabe :
ts.Pin_reset() :
This is an important function. in every methods you want to implement, you have to do this reset before every call to a tft (display) routine (remember: CS and RS Pins are shared between the LCD display and the touchscreen interface, if the pins are not reset the screen functions will not work).

ts.pressure() : Return a value corresponding to the pressing strength - Mostly used to detect a touch
ts.getPoint() : Return the (x,y) position of the touch (provided the touchscreen has been correctly calibrated, see #4)
ts.Point_Listen() : Use with care, this loop returns the (x,y) touch value after the user has stopped touching (when removing the pencil). Used in the calibration function if you want to see it working.

Blender Camera Switcher

Blender Camera Switcher A simple camera switcher addon for blender. Useful when use reference image for camera. This addon will automatically fix the

Corgice 1 Jan 31, 2022
Programming of Robotics Systems course at the University of Aveiro, Portugal, 2021-2022.

Programação de Sistemas Robóticos Miguel Riem Oliveira Universidade de Aveiro 2021-2022 Projeto AtlasCar Projecto RACE IROS 2014 AtlasCar2 ATOM IROS 2

Miguel Riem de Oliveira 22 Jul 13, 2022
Electrolux Pure i9 robot vacuum integration for Home Assistant.

Home Assistant Pure i9 This repository integrates your Electrolux Pure i9 robot vacuum with the smart home platform Home Assistant. The integration co

Niklas Ekman 15 Dec 22, 2022
Python module for the qwiic serial control motor driver

Qwiic_SCMD_Py Python module for the qwiic motor driver This python package is a port of the existing SparkFun Serial Controlled Motor Driver Arduino L

SparkFun Electronics 6 Dec 06, 2022
uOTA - OTA updater for MicroPython

Update your device firmware written in MicroPython over the air. Suitable for private and/or larger projects with many files.

Martin Komon 25 Dec 19, 2022
A Raspberry Pi Pico plant sensor hub coded in Micropython

plantsensor A Raspberry Pi Pico plant sensor hub coded in Micropython I used: 1x Raspberry Pi Pico - microcontroller 1x Waveshare Pico OLED 1.3 - scre

78 Sep 20, 2022
ENC28J60 Ethernet chip driver for MicroPython (RP2)

micropy-ENC28J60 ENC28J60 Ethernet chip driver for MicroPython v1.17 (RP2) Rationale ENC28J60 is a popular and cheap module for DIY projects. At the m

11 Nov 16, 2022
♟️ QR Code display for P4wnP1 (SSH, VNC, any text / URL)

♟️ Display QR Codes on P4wnP1 (p4wnsolo-qr) 🟢 QR Code display for P4wnP1 w/OLED (SSH, VNC, P4wnP1 WebGUI, any text / URL / exfiltrated data) Note: Th

PawnSolo 4 Dec 19, 2022
Monitor Live USB Plug In & Plug Out Events

I/O - Live USB Monitoring Author: Jonathan Scott @jonathandata1 Date: 3/13/2021 CURRENT VERSION 1.0 This is just a simple bash script that calls a pyt

Jonathan Scott 17 Dec 03, 2022
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

25 Dec 28, 2022
raspberry pi servo control using pca9685

RPi_servo-control_pca9685 raspberry pi 180° servo control using pca9685 Requirements Requires you to have the adafruit servokit library installed You

1 Jan 10, 2022
OctoPrint is the snappy web interface for your 3D printer!

OctoPrint OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software and released under the GNU Affero Genera

OctoPrint 7.1k Jan 03, 2023
Robot Framework keyword library wrapper for atlassian-python-api

Robot Framework keyword library wrapper for atlassian-python-api

Marcin Koperski 3 Jul 29, 2022
Volta: A Virtual Assistant which increases your productivity with time as you use it…

Volta Official Documentation Overview & Purpose Volta: A Virtual Assistant which increases your productivity with time as you use it… Volta, developed

Abeer Joshi 1 Jan 14, 2022
A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

A PYTHON Library for Controlling Motors using SOLO Motor Controllers with RASPBERRY PI, Linux, windows, and more!

SOLO Motor Controllers 3 Apr 29, 2022
Python Wrapper for Homeassistant's REST API

HomeassistantAPI Python Wrapper for Homeassistant's REST API Please ⭐️ the repo if you find this project useful or cool! Here is a quick example. from

Nate 29 Dec 31, 2022
Claussoft Personal Digital Assistant

Claussoft Personal Digital Assistant Install on Linux $ sudo apt update $ sudo apt install espeak ffmpeg libespeak1 portaudio19-dev $ pip install -r r

Christian Clauss 3 Dec 14, 2022
Port of Uxn to digital hardware in the Logisim simulator

Uxn-Logisim Implements the Uxn instruction set in digital hardware. Very WIP. Contents cpu.circ - The Logisim file microcode.mc - Microcode source fil

DeltaF1 11 Mar 27, 2022
Get input from OLED Joystick, Runs command, Displays output on OLED Screen (Great for P4wnP1)

p4wnsolo-joyterm Gets text input from OLED Joystick Runs the command you typed Displays output on OLED Screen (Great for P4wnP1 - even better on Raspb

PawnSolo 7 Dec 19, 2022
Windhager myComfort custom component for Home Assistant

Windhager myComfort custom component for Home Assistant

5 Apr 27, 2022