micropython tft display quotation
So you have a nifty display like a bright TFT LCD, Charlieplex LED or NeoPixel matrix powered by MicroPython, but what if you want to draw shapes and graphics on it? Most MicroPython display modules only give you basic pixel drawing commands so it"s difficult to draw graphics yourself pixel by pixel. Luckily there"s a handy new MicroPython graphics module you can use to draw basic shapes and graphics on any pixel-based display! This module shows some of the power of MicroPython--a single module can work with any pixel display because of MicroPython"s dynamic language features. In this guide you"ll learn how to use a MicroPython graphics module to draw basic line, rectangle, circle, and triangle shapes on pixel-based displays like the ILI9341 TFT FeatherWing.
For this guide there"s no special hardware you need to draw graphics on a display. However you do need to have a pixel-based display of some sort (LED, TFT, NeoPixel--anything!) connected to your MicroPython board. Check out the following guides for details on how to use a few pixel displays with MicroPython:
First make sure you are running the latest version of MicroPython for your board. If you"re using the ESP8266 MicroPython port you must be running version
If your board supports USB mass storage, like the SAMD21 MicroPython port, then simply drag the .mpy and other files to the board"s file system (eject the drive and reset the board to make sure it is picked up by MicroPython).
The following section will show how to draw shapes on a ILI9341 TFT display like the TFT FeatherWing. You"ll see how the module can be adpated to draw on any pixel-based display by plugging in a new pixel drawing function too.
Next you"ll need to initialize your display so that you can draw pixels on it. Consult the MicroPython display guides for details on initializing displays.
To use the graphics and shape rendering module you"ll need to import its module and create an instance of the GFX class inside it. For example, to create a graphics renderer for the TFT FeatherWing above you would run:
A pixel drawing function to call when the GFX class needs to write a pixel. For this example the TFT display classpixelfunction is specified. It"s important to note that to use the graphics class youmusthave a function it can call to draw pixels! This function can live anywhere, like as a global function or on a class instance. The function needs to take at least a pixel x position and pixel y position parameter (in that order), and any number of other positional and keyword parameters after them (like color, intensity, etc.).
There are two optional parameters you can specify as keyword arguments too. They aren"t shown in this guide but see how the ILI9341 display example code uses them:
hline- Optionally set hline to a fast horizontal line drawing function for your display. This will improve the speed of drawing certain shapes. The function should take as parameters an x position and y position of the line start, then width of the line in pixels. Any number of optional color or other parameters can follow. If you don"t provide a hline function a slow default implementation that draws pixel by pixel will be used.
vline - Optionally set vline to a fast vertical line drawing function for your display. This will improve the speed of drawing certain shapes, especially filled shapes. The function should take as parameters an x position, y position of the line start, then height of the line in pixels. Any number of optional color or other parameters can follow. If you don"t provide a vline function a slow default implementation that draws pixel by pixel will be used.
Now the fun begins! After creating the GFX class you can call functions to draw shapes on the display. For example, draw a simple line across the entire display with the line function:
That"s all there is to basic shape drawing with the Adafruit MicroPython GFX module! With these basic shape primitives you can start to create interesting graphic projects, like a pong or breakout game using filled rectangles and circles. You can add text with the Adafruit MicroPython bitmap font module too!
Remember any pixel-based display can be used with this library, for example, an OLED display or NeoPixel, Charlieplex LED, or simple LED backpack matrix are great targets to use with the library. Just plug in each module"s pixel function and you"ll be drawing shapes in no time!
I have just bought a TTGO esp32 with tft display. After 3 hours of struggling I managed to flash the firmware and bring life to the color display. However, I still have (at least) 3 problems:
The example below works fine but changing the text and adding more graphics has no effect when I rerun the program - until I disconnect and reconnect the board. How can I clear the screen (tft.clear() seems to have no effect) without disconnecting the board?
C:\esptoolmaster2>python esptool.py --chip esp32 --port COM14 --baud 460800 --before default_reset --after no_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader.bin 0xf000 phy_init_data.bin 0x10000 MicroPython.bin 0x8000 partitions_mpy.bin
The PyPortal uses an ATMEL (Microchip) ATSAMD51J20 and an Espressif ESP32 Wi-Fi coprocessor with TLS/SSL support built-in. PyPortal has a 3.2″ 320 x 240 color TFT with resistive touch screen. PyPortal includes: speaker, light sensor, temperature sensor, NeoPixel, microSD card slot, 8MB flash, plug-in ports for I2C and 2 analog/digital pins. There are 3D files for custom enclosures and lanyard fastening. PyPortal is Open Source hardware, and Open Source software, programmable in CircuitPython and Arduino. The device shows up as a USB drive and the Python code can be edited in any text editor.
At Hopper Local / Dublin, Vicky Twomey-Lee will be demonstrating MicroPython on Micro:Bit and CircuitPython on Circuit Playground Express – codinggrace.com
goodreads-quotes-raspberry-pi displays quotes scrapped from goodreads using a Raspberry Pi Zero and a display. This widget scrapes different quotes from goodreads and displays them on an Adafruit OLED Bonnet. The quotes can change after a user defined time interval – GitHub.
BNO: a mini cardboard BNO using a NodeMCU development board running MicroPython. A script reads button inputs, displays BNO’s menu and runs the selected scripts from MicroPython’s file system – YouTube – plus there is also a rotating cube.
March 11th, London, UK. Meet, learn and share ideas about MicroPython. Nicholas Tollervey will be telling us about the latest features of Mu – a free code editor for Python, MicroPython and CircuitPython devices – Meetup.
The CircuitPython Weekly Newsletter is a CircuitPython community-run newsletter emailed every Tuesday. The complete archives are here. It highlights the latest CircuitPython related news from around the web including Python and MicroPython developments. To contribute, edit next week’s draft on GitHub and submit a pull request with the changes. Join our Discord or post to the forum for any further questions.
Firstly, depending on the board you are using (with resistive touch, capacitive touch, or no touch) you will have to uncomment the correct one. For example, if you are using the ESP32 TouchDown uncomment: "#define ENABLE_CAP_TOUCH". If you are using a DevKitC with separate TFT, uncomment "#define ENABLE_RES_TOUCH".
You can also set the scale of the y-axis of the graphs. This is done under "// The scale of the Y-axis per graph". If these are to big or to small, the data will not be displayed correctly on the graph. You might have to experiment with these.
First, we use the Wio Terminal standalone as a Quote Generator. This uses the inbuilt LCD screen and WiFi module to get text data of famous quotes. We display programming-related quotes, however, you can modify the project to suit your requirements.
Finally, we build a multi-channel data logger that can be switched between various data sources to log them to an SD card for future analysis. It also displays a time graph on the Wio Terminal’s screen. In our example, we use a DHT11 weather sensor and a four-channel gas sensor.
Sitting shotgun with the main microprocessor is the Realtek RTL8720DN WiFi / Bluetooth chip. This makes it effortless to integrate quick IoT functionality into your projects. This would be perfect for mini informational displays with little fussing about with wires or external modules.
For our first project, we’re using both the inbuilt LCD screen and WiFi module to get text data of famous quotes. Since we’re all nerds at DIYODE, we’ve of course chosen to choose famous programming quotes. The centre button of the Wio Terminal will be used to load a new quote and display it on the screen.
WiFi is involved here because we’re using a simple Web API to gather data and display it live. Since it’s connecting to WiFi, we could connect it with virtually any other web interface and make it work.
There isn’t a ton of libraries we need to import here. We’re using the Arduino JSON, rpcWiFi and HTTPClient libraries to handle the internet connection and data, and the TFT_eSPI library to handle the screen on the Wio Terminal.
The ‘wasPressed’ variable will be used during the main loop to ensure we only display one new quote when the button is pressed, and not to continue looking for quotes when the button is held. This is typically referred to as state detection, and we’ll talk about this shortly.
Our setup code is verbose but should be fairly self-explanatory as we read through it. We’re starting the TFT screen and setting its rotation, background settings and a placeholder text while we wait for a connection to the WiFi.
While we haven’t looked into using it, there is also functionality within the eSPI_TFT library to draw sprites. This means that small images can be loaded onto the Wio which can then be displayed through code.
And we’re done! Once the code is uploaded, enjoy our brand-new game Whack-a-LED! It’s actually pretty fun and the cartoon-style sprites look pretty good on the TFT display. Every time we miss a hole (or don’t hit it in time), the red LED lights up. If we’re successful, the green LED lights up. Awesome!
It’ll also display a time graph on the Wio Terminal. We’re sprinkling in some juicy data to analyse by using a DHT11 weather sensor and a four-channel gas sensor!
While the Wio Terminal doesn’t include any inbuilt graphics libraries for graphing or data displays, there are a number of libraries available for this purpose. We’re using the Seeed Line Chart library for display of data.
To switch between each data display, we’re putting the directional pad on the Wio Terminal to allow the user to switch between data channels. Pressing right increments the current data view to the next sensor, while pressing left decrements. Recording the data to the SD card (discussed shortly) can also be started by pressing in the button, and saved by pressing it again.
Once it’s uploaded, data should immediately appear to scroll across the display. To start or stop recording, just hit the centre button. If a different data stream is desired, move the directional pad left or right to switch data channels.
The 1.8" display has 128x160 color pixels. The TFT driver (ST7735) can display full 18-bit color. The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector)
The 1.8" display has 128x160 color pixels. The TFT driver (ST7735) can display full 18-bit color. The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector)
I obtained an ER-TFTM035-6 module which uses the ILI9488 and XPT2046. I read the Module Datasheet and it has a multitude of interfaces available. I believe it to be a resistive touch type and focusing on trying to align the pins on the module with the pins in the configuration I have some confusion. The Datasheet shows two SPI bus sets of pins, one for the TFT and one for touch, and the configuration just has a chip select for touch. Did you connect the corresponding bus pins together? For example the LCD_SDI to SDI (for touch) and then to MOSI on the WROVER. What is the function of DC? On the datasheet it says Data/Command selection pin, fix to IOVCC or DGND level when not in use.
Here"s my issue: There is a dead pixel band around the edge of the display, 2 pixels wide on the right, 3 pixels wide on the bottom. I have tried tinkering with the library (I had to, as it was written for a 128 X 160 display) and the code, but any time the height and width values are changed from 128 to another value the image gets horribly skewed. How can I modify the library so that there isn"t a band of dead pixels on my display? I can provide images of the display in action if needed.
In the previous article (“WiFi OLED Mini Weather Station with ESP8266“) I have used the OLED kit from https://blog.squix.org. And as promised, this time it is about the “ESP8266 WiFi Color Display Kit”:
I had ordered both because I thought that the Color Display kit is needs the other kit as a base. Well, it turned out that both kits work independently. My bad. Actually this is good, as I have now two independent ESP8266 weather stations :-). An addition to that, they can exchange data (e.g. temperature/humidity) with a server, so that makes them a perfect dual weather station.
This time assembling the kit needs basic soldering skills. With the excellent tutorial by Daniel Eichhorn (https://blog.squix.org/wifi-color-display-kit) this should be a piece of cake. The only consideration is what kind of headers to use. I opted for the ‘larger but flexible’ approach. That way I can separate the boards if needed.