stm32 blue pill wires with 1.8 tft lcd display price
We will organize the kinds of display interfaces we offer, and how they differ. You will get to know what kind of external and internal interfaces we have and what are their main applications.
First, let us start with dividing internal and external interfaces in LCD modules. Internal interface of display means it used inside the device. Those are usually the embedded interfaces that are not visible, and we do not have access to them as the users of the device. External interfaces, on the other hand, are connected to the device using a cable. Once we have defined internal and external interfaces, both of these categories come as universal or image transfer interfaces.
A protocol defines the rules of information exchange, where the interface is the medium. The example here could be the language. When I use my voice to communicate with other people, my voice is an interface. Over this interface my voice is being sent to other people’s ears, and the protocol is the language used. Right now, I am using the English protocol. If you understand the protocol, you understand what I am saying. If I switch to a different language, Polish or some other language that you do not understand, you have the same interface, you will still hear me, but because of a different protocol, you do not understand me anymore. In this article we will talk only about interfaces, how to connect devices to each other. We will not focus on protocols.
Let’s try to get the interfaces right. For internal interfaces, interfaces embedded into the device, we have universal interfaces and image transfer interfaces. Universal display interface can send other data, not only an image. Being universal, they are not perfect for image transfer, because in most of the displays used nowadays, the image transfer is one of the most demanding. The bit rate, the data transfer needed for the image transfer is rather high. Higher that many universal interfaces can offer. If we need to send an image every once in a while, then we don’t need very high bandwidth. If we do not need live video stream, then we can use some of the internal universal interfaces such as SPI, I2C or even slow interfaces as RS232 or UART.
The first universal interface will be SPI (Serial Peripheral Interface). This interface is serial, used for communication between a host, in SPI called a Master, and devices called Slaves. One host can communicate with many slaves. To select the Slave, we use the Chip select or SS line and then we use two data lines, Master output or Master input. And of course we have to define the clock, to synchronize the data, because this is a clock synchronized interface.
It can be fast but is not fast enough for live video. The baud rate can be 1 MBd, but it can also be 10 MBd or even 50 MBd on the SPI or QSPI. QSPI is a Quad SPI, a kind of modification of SPI that is faster. But still this interface is very universal, we can use it to connect memory or some input and outputs internally in our device. In the display universe the SPI is used for simple displays, for small size displays, where we can transfer the image relatively fast, because the resolution is low. The maximum size for SPI display interface would be 3.5 inch, 320 by 240 pixel TFT displays. If we have higher resolution, image transfer will be too slow to use SPI even with a high-speed SPI.
If, for example, the Master is sending some data, the only thing Slaves can do is to receive it. And then we need to wait a little bit for the Master to finish. We can then respond as Slave to Master. In I2C Slave selection works a little bit different than in SPI, where we had a Chip Select line (CS line) or SS line to select from. In I2C we first need to send the logical address to the interface that is being written by Slaves. In general, this procedure is slow and universal interface used also to connect the simple memory and some other I2S that we have around our microcontroller on the PCB. It is very useful, but usually not used for image transfer. This interface is very popular in the display world for touchscreens. Most of the embedded touch screens that we use have I2C interface because the touchscreen does not generate many data. We only have coordinates of the finger or few fingers at most, that need to be sent back to the microcontroller, to the device processor. The slow baud rate is good enough for the touchscreen, but not enough for the image.
That is not a case for SPI or I2C, because we have a clock there that gives the speed to every device. Then each device works according to the clock. In UART we do not have a clock. It is rather not used for image transfer. The UART, or SPI, or I2C can be used for low resolution displays. For high resolution displays we need an Intelligent Display, a display that will generate the image internally and through these slow universal interfaces we only send commands, or we send the image once, the image is being stored into the internal memory of the intelligent display, that we will use later sending the commands. You can find Riverdi’s intelligent display line on our website: https://riverdi.com/product-category/intelligent-displays/.
These Riverdi products are very advanced Intelligent Displays, made with Bridgetek controllers. The controllers use SPI and QSPI for communication. That means your software, your system, your microcontroller can be simple. You can use SPI interface to drive them, and you can still have high resolution image, even as high as 1280 by 800 pixels in 10.1-inch LCD displays. So, please remember that if you want to use a slow universal interface and have a high-resolution image, you need to use an Intelligent Display.
There are also the internal image transfer interfaces. The image transfer interface allows continuous high speed image transfer. Internal transfer is high enough to refresh the display many times per second. This is called the refresh rate of a display. When you go to a display, monitor, or TV set specification, you will see refresh rate or maximum refresh rate parameter. If it’s 60 Hertz, that means the display image is refreshed 60 times per second. More advanced displays would have higher values, like 100 Hertz. The refresh rate means we need to send full image 60 times or 100 times in each second. To visualize this amount of data, we need to multiply refresh rate by the resolution of the screen. For example, for a 7-inch Riverdi LVDS display with resolution 1024 by 600 it is roughly 600 thousand pixels.
The most common internal image transfer interface in industrial LCD displays nowadays is LVDS – Low Voltage Differential Signal. A crucial feature of this interface is that it is differential. It means that the signal is immune to interference and we can use a twisted pair of wires to transfer the data. We can send data fast and it will not be corrupt by any noise, interference. This kind of data corruption is quite common in other interfaces.Key Takeaway: In LVDS display interface the differential signal allows you to send the signal at a very high speed and keep it safe from noise.
The next, older image transfer interface is called RGB. Name comes from the colors sent parallelly to the display: red, green and blue. LVDS is a serial interface and the RGB is a parallel interface. The main difference is that RGB is not differential, so it is easier to disturb signal with noise and you configure the speed of this interface too high. Parallel interface means that we send every bit in a separate line. In theory this interface could be fast, but because it is not differential, the transfer speed is limited. Moreover, the RGB display interface will work with rather small screen sizes – usually up to 7-inch or 10-inch.
12 inch screen size is the total maximum for a LCD display with RGB interface, but the resolution will be lower, like 800 by 600. For this display size it is very low resolution. This is the reason why the 7-inch is size above which the LCD displays are being switched from RGB to LVDS interface. Among Riverdi products (if you go to the Riverdi website and to the IPS display tab), there are displays without the controller, and the small displays like 3.5-inch, 4.3-inch and 5-inch are equipped with RGB interface. But when you go to the 7-inch LCD displays tab on Riverdi website, you will find RGB, LVDS and MIPI displays. But when you go to the 10-inch or bigger displays, you will only find the LVDS displays because our 10-inch LCD displays are high resolution 1280 by 800, and it is impossible to build it with the RGB interface.Key Takeaway: RGB is low speed and not immune to noise. Use it for the smaller size displays or with lower resolution.
MIPI – Mobile Industry Processor Interface – is an internally embedded image transfer interface, getting popular these days. This kind of interface is used in mobile applications, tablets or mobile phones, but it is entering as an option in industrial applications. In Riverdi we offer 7-inch MIPI displays, but please be careful with other MIPI displays on the market. Many come from mobile phones or tablet market. Also, the TFT glass availability may not be stable as the mobile market changes really fast, every six months or every year. When you buy a 7-inch Riverdi MIPI interface display you are safe, because it is an industrial display.
This is why we have a limited number of displays with MIPI interface – we want to be sure that what we sale will be available for a long time. Longevity is one of Riverdi’s core values and we do not want to deliver anything that will not be supported for a minimum 3 to 5 years. It is because many of our customers are making industrial, medical or military devices and they need displays to be available long-term.Key Takeaway: MIPI is an important and growing interface in the display market.
Next interface is the Vx1. It is similar to LVDS and MIPI, so it’s low voltage differential signal. Vx1 is a very high-speed interface, usually used in large high-resolution screens, like 55-inch 4K TVs or even larger ones. If you buy this kind of a TV set right now, probably the embedded interface inside will be the Vx1.Key takeaway: Vx1 is a super-fast interface used for high bandwidth image transfer, with high refresh rate and high-resolution displays, used in 4K screens and above.
The last internal image transfer interface is Embedded DisplayPort (eDP). We call it the new LVDS, because many new industrial displays are equipped with the eDP. If you go through industrial manufacturers of TFT LCD displays, you will notice increasing number of models available with the eDP. eDP is also a native interface in new Intel or AMD based processors.Key Takeaway: With the embedded DisplayPort as a native display interface you can cut down costs, because you do not need anything extra to connect a display to the processor.
Now, with the processors on the market, we need displays with embedded DisplayPort. Many laptops or monitors already use embedded DisplayPort as an internal interface instead of LVDS. LVDS still is the most popular industrial LCD display interface. All the internal image transfer interfaces like MIPI, Vx1 and eDP are variations of LVDS, where the protocols and the signals are a little bit different. For example, for eDP we can have lower noise and reduced power consumption. All of them have advantages over regular LVDS, but they are all LVDS type.
Now, let’s take a closer look at external interfaces. Those are the ones that we usually have direct access to. It can be TV or monitor connected to your computer with the HDMI . It can be a DVI usually used for monitors. Or VGA which is an outdated image interface for monitors. The DisplayPort that is a HDMI successor. Finally, an universal USB-C, the most common interface nowadays used to connect devices.
Let us start with USB-C, the most universal interface . It is one of the best interfaces that we have ever designed, because it is really fast and also very universal. It not only transfers data, not only it is fast enough to transfer image, but it can also transmit a lot of power.
USB-C transmits up to 100 watt of power, because you can increase voltage and current. In a regular USB it is usually 5 volt and 0.5 or 1.0 amp, so only a couple watts. In USB-C you increase the voltage up to 20 volt and with the 5 amp current, so in total it’s even 100 watt of power. This interface is made not only for data, but for real power transfer. Through USB-C you can charge your phone and your laptop. If you buy a new laptop right now, you may even not get a regular power connector, but only an USB-C. The USB-C is a very smart interface. If you connect the devices, they can negotiate with each other which one has more power. For example, if we connect a charger to a laptop, the charger has more power and will charge the laptop, but if you connect the laptop with the same interface to your mobile phone, then they will discuss the power levels, and of course the laptop will be charging the phone. You can already find monitors on the market that have USB-C instead of HDMI. Those monitors can be powered from your computer and need only one USB cable, both for image transfer and power. For sure the future belongs to USB-C implementations.Key Takeaway: USB-C is a really smart, universal and fast interface for displays. It comes with power transmission option.
Let’s move on to image transfer interfaces. The most common one is HDMI – High-Definition Multimedia Interface. M stands for Multimedia, because it transfers image with sound. If you connect your computer to your TV set with HDMI, you will need one cable for both the video and the audio. There are variations of HDMI connectors:standard HDMI,
The next one is DVI – Digital Visual Interface. The first DVI was not a multimedia interface, because it did not have audio data transfer. Nowadays, there are some variations that can transfer audio, but it is non-standard. We can assume DVI is rather for image transfer. It is a digital interface, similar in signals to HDMI. The latest variation is DVI-I, where I stands for integrated interface. It can have a digital and analog part for VGA compatibility. In the picture above there is a DVI-D, digital only, where we do not have the pins for analog VGA interface. Analog VGA is sometimes available in your desktop computer, but not in laptops anymore.Key Takeaway: DVI is digital visual interface with multiple variations and updates, similar in signal to HDMI
The oldest video interface still in use is the VGA – Video Graphic Array interface. It becomes less and less popular. This is an analog interface, not a digital one like all the other abovementioned interfaces. Analog interface means that we do not transmit the bits, but we send the voltages values. The analog signals are not stable, they are quite easy to disturb, so the transfer cannot be very high in speed and volumeKey takeaway: VGA’s popularity is declining, and it is not the best solution if you have a high-resolution display or noisy environment.
The last external interface that we can find in our devices nowadays is a DisplayPort. DisplayPort is similar to HDMI or DVI. It can also transfer image and sound. It is even faster than the HDMI. Usually, the DisplayPort is used for high resolution displays, for new monitors and TVs with 4K or 8K resolution where it is really hard, or nearly impossible, to achieve such resolution using HDMI interface.Key Takeaway: DisplayPort is super-fast image and sound transmitting interface, used in highest resolution displays.
An oscilloscope is an essential tool for any electronics engineer. A popular inexpensive digital signal oscilloscope is the Rigol DS1054Z, supporting 4 analog channels and 50 MHz bandwidth. But it retails for $349, probably a worthwhile investment for a professional but steep for a casual hobbyist. Fortunately, with about $10 in parts it is possible to build a minimal oscilloscope, sporting only 1 analog channel at ~2 MHz bandwidth maximum. Not in the league of “real” commercial oscilloscopies, but still powerful enough to be useful.
Based on Andy Hill’s project, pingumacpenguin/STM32-O-Scope: STM32F103 based minimalist oscilloscope., in turn based on Ray Burnette’s idea. See also this thread on stm32duino forums: $10 O-Scope revisited by ahull on May 09, 2015. All credit goes to them, I’m only following instructions.
One confusing part of the steps is that it says “Hardware SPI1 on the STM32F103C8T6 ALSO needs to be connected and pins are as follows.” then lists “SPI1_NSS (PA4) (LQFP44 pin 14) (n.c.)”, but n.c. means not-connected. PA4 is the slave select pin, also known as S̅S̅, SSEL, CS, C̅S̅, CE, nSS, /SS, or SS#. In this case they capitalized nSS as NSS. To be clear, PA4/NSS does not need to be connected.
Secondly, the instructions said “SPI1_MOSO (PA6) (LQFP48 pin 16) (White)” but there isn’t a MOSO master out / slave out label on my display, in contrast to “SPI1_MOSI (PA7) (LQFP48 pin 17) (Grey)” they probably meant MISO. Got it reversed the first time, but worked after swapping. To summarize here are all the connections that worked for me:
For prototyping, I used female-to-female jumper wires from this pack: Dupont line 120pcs 10cm male to male + male to female +female to female jumper wire Dupont cable for arduino, purchased for $3.51 (not included in the total price of this $10 o’scope). You could also use female-to-male jumper wires and a breadboard, or solder male-to-male wires, or use a custom printed circuit board, but F-F jumper wires are the most expedient for the initial prototype.
The STM32-O-Scope software is an Arduino project. Flash the generic_boot20_pc13.bin bootloader using a USB-to-serial adapter onto the STM32F103 blue pill board. Then connect over USB and select the board and virtual serial port in the Arduino application, load up the pingumacpenguin/STM32-O-Scope sketch.
-#include "Time.h" //If you have issues with the default Time library change the name of this library to Time1 for example.+#include "Time1.h" //If you have issues with the default Time library change the name of this library to Time1 for example. #define TZ "UTC+1"
Looks nice! To try it out, the STM32-O-Scope software includes a test signal on PB1, a square wave of approximately 500 Hz. Connect PB0 to PB1 and the square wave appears on the display as we expect:
The wiki recommends using a 1 MΩ resistor as an attentuator. I used a 1% 1/4 watt resistor (not included in the $10 price), measured 1.000 MΩ with a multimeter, in series with the PB0 input connecting to the PB1 test signal, and it was barely visible on the display. May be useful for measuring higher voltage signals, but not the test signal.
From the source code we see the additional wires for adding the optional touchscreen input. You can use an LCD screen without a touch panel, but I opted for one since it was only a couple more bucks. Now that the display works, time to hook it up, five more wires:
All of these pins are adjacent, but are on the other side of the blue pill board. I used right angle headers ($0.74 for 10pcs 40 Pin 1x40 Single Row Male 2.54mm Breakable Pin Header Right Angle Connector Strip bending, not included in the $10 price; also note panel module included pre-soldered striaght headers already). This leads to slightly awkward wiring, but it is passable:
That’s a lot of wires. Peeled off the protective film, but touching the screen did nothing. Turns out it is disabled in the code, enable by removing this code:
Rebuild and reflash. Boots up and asks to press the dot to calibrate the screen. When I touch and hold it, concentric circles appear. Then touching the signal display draws red dots. Will have to learn about how this is meant to work exactly, but seems to be functioning.
This display module not only has an LCD and touch screen panel, but also an SD card slot, through an unpopulated header. 4 connections, also using SPI: SD_CS, SD_MOSI, SD_MISO, and SD_SCK. The LCD is connected to SPI1 (PA7/6/5/4), touch to SPI2 (PB12/13/14/15), could the SD card adapter connect to PA15/PB3/PB4/PB5?
Haven’t tried it because the STM32-O-Scope sketch doesn’t include support for the SD card, but could be an interesting project to investigate adding it. Storing the time series to the SD card? In the meantime, the STM32-O-Scope can already send data over serial to a PC for later analysis.
For the price, $10 + change (and a few spare parts I had lying around), when combined with the STM32-O-Scope softwrae we have seen it is possible to build an inexpensive yet usable oscilloscope. I’m not sure if I’ll use it for any serious projects, or should instead buy a “real” scope (Hackaday has a review of some slightly more expensive commercial oscilloscopes: A tale of two sub-$100 oscilloscopes), but we’ll see, at least it’s something.
An excellent new compatible library is available which can render TrueType fonts on a TFT screen (or into a sprite). This has been developed by takkaO and is available here. I have been reluctant to support yet another font format but this is an amazing library which is very easy to use. It provides access to compact font files, with fully scaleable anti-aliased glyphs. Left, middle and right justified text can also be printed to the screen. I have added TFT_eSPI specific examples to the OpenFontRender library and tested on RP2040 and ESP32 processors, however the ESP8266 does not have sufficient RAM. Here is a demo screen where a single 12kbyte font file binary was used to render fully anti-aliased glyphs of gradually increasing size on a 320x480 TFT screen:
The TFT configuration (user setup) can now be included inside an Arduino IDE sketch providing the instructions in the example Generic->Sketch_with_tft_setup are followed. See ReadMe tab in that sketch for the instructions. If the setup is not in the sketch then the library settings will be used. This means that "per project" configurations are possible without modifying the library setup files. Please note that ALL the other examples in the library will use the library settings unless they are adapted and the "tft_setup.h" header file included. Note: there are issues with this approach, #2007 proposes an alternative method.
Support has been added in v2.4.70 for the RP2040 with 16 bit parallel displays. This has been tested and the screen update performance is very good (4ms to clear 320 x 480 screen with HC8357C). The use of the RP2040 PIO makes it easy to change the write cycle timing for different displays. DMA with 16 bit transfers is also supported.
Support for the ESP32-S2, ESP32-S3 and ESP32-C3 has been added (DMA not supported at the moment). Tested with v2.0.3 RC1 of the ESP32 board package. Example setups:
Smooth fonts can now be rendered direct to the TFT with very little flicker for quickly changing values. This is achieved by a line-by-line and block-by-block update of the glyph area without drawing pixels twice. This is a "breaking" change for some sketches because a new true/false parameter is needed to render the background. The default is false if the parameter is missing, Examples:
New anti-aliased graphics functions to draw lines, wedge shaped lines, circles and rounded rectangles. Examples are included. Examples have also been added to display PNG compressed images (note: requires ~40kbytes RAM).
Frank Boesing has created an extension library for TFT_eSPI that allows a large range of ready-built fonts to be used. Frank"s library (adapted to permit rendering in sprites as well as TFT) can be downloaded here. More than 3300 additional Fonts are available here. The TFT_eSPI_ext library contains examples that demonstrate the use of the fonts.
Users of PowerPoint experienced with running macros may be interested in the pptm sketch generator here, this converts graphics and tables drawn in PowerPoint slides into an Arduino sketch that renders the graphics on a 480x320 TFT. This is based on VB macros created by Kris Kasprzak here.
The RP2040 8 bit parallel interface uses the PIO. The PIO now manages the "setWindow" and "block fill" actions, releasing the processor for other tasks when areas of the screen are being filled with a colour. The PIO can optionally be used for SPI interface displays if #define RP2040_PIO_SPI is put in the setup file. Touch screens and pixel read operations are not supported when the PIO interface is used.
DMA can now be used with the Raspberry Pi Pico (RP2040) when used with both 8 bit parallel and 16 bit colour SPI displays. See "Bouncy_Circles" sketch.
The library now supports the Raspberry Pi Pico with both the official Arduino board package and the one provided by Earle Philhower. The setup file "Setup60_RP2040_ILI9341.h" has been used for tests with an ILI9341 display. At the moment only SPI interface displays have been tested. SPI port 0 is the default but SPI port 1 can be specifed in the setup file if those SPI pins are used.
The library now provides a "viewport" capability. See "Viewport_Demo" and "Viewport_graphicstest" examples. When a viewport is defined graphics will only appear within that window. The coordinate datum by default moves to the top left corner of the viewport, but can optionally remain at top left corner of TFT. The GUIslice library will make use of this feature to speed up the rendering of GUI objects (see #769).
An Arduino IDE compatible graphics and fonts library for 32 bit processors. The library is targeted at 32 bit processors, it has been performance optimised for STM32, ESP8266 and ESP32 types. The library can be loaded using the Arduino IDE"s Library Manager. Direct Memory Access (DMA) can be used with the ESP32, RP2040 and STM32 processors with SPI interface displays to improve rendering performance. DMA with a parallel interface is only supported with the RP2040.
For other processors the generic only SPI interface displays are supported and slower non-optimised standard Arduino SPI functions are used by the library.
"Four wire" SPI and 8 bit parallel interfaces are supported. Due to lack of GPIO pins the 8 bit parallel interface is NOT supported on the ESP8266. 8 bit parallel interface TFTs (e.g. UNO format mcufriend shields) can used with the STM32 Nucleo 64/144 range or the UNO format ESP32 (see below for ESP32).
The library supports some TFT displays designed for the Raspberry Pi (RPi) that are based on a ILI9486 or ST7796 driver chip with a 480 x 320 pixel screen. The ILI9486 RPi display must be of the Waveshare design and use a 16 bit serial interface based on the 74HC04, 74HC4040 and 2 x 74HC4094 logic chips. Note that due to design variations between these displays not all RPi displays will work with this library, so purchasing a RPi display of these types solely for use with this library is not recommended.
A "good" RPi display is the MHS-4.0 inch Display-B type ST7796 which provides good performance. This has a dedicated controller and can be clocked at up to 80MHz with the ESP32 (55MHz with STM32 and 40MHz with ESP8266). The MHS-3.5 inch RPi ILI9486 based display is also supported.
Some displays permit the internal TFT screen RAM to be read, a few of the examples use this feature. The TFT_Screen_Capture example allows full screens to be captured and sent to a PC, this is handy to create program documentation.
The library supports Waveshare 2 and 3 colour ePaper displays using full frame buffers. This addition is relatively immature and thus only one example has been provided.
The library includes a "Sprite" class, this enables flicker free updates of complex graphics. Direct writes to the TFT with graphics functions are still available, so existing sketches do not need to be changed.
A Sprite is notionally an invisible graphics screen that is kept in the processors RAM. Graphics can be drawn into the Sprite just as they can be drawn directly to the screen. Once the Sprite is completed it can be plotted onto the screen in any position. If there is sufficient RAM then the Sprite can be the same size as the screen and used as a frame buffer. Sprites by default use 16 bit colours, the bit depth can be set to 8 bits (256 colours) , or 1 bit (any 2 colours) to reduce the RAM needed. On an ESP8266 the largest 16 bit colour Sprite that can be created is about 160x128 pixels, this consumes 40Kbytes of RAM. On an ESP32 the workspace RAM is more limited than the datasheet implies so a 16 bit colour Sprite is limited to about 200x200 pixels (~80Kbytes), an 8 bit sprite to 320x240 pixels (~76kbytes). A 1 bit per pixel Sprite requires only 9600 bytes for a full 320 x 240 screen buffer, this is ideal for supporting use with 2 colour bitmap fonts.
One or more sprites can be created, a sprite can be any pixel width and height, limited only by available RAM. The RAM needed for a 16 bit colour depth Sprite is (2 x width x height) bytes, for a Sprite with 8 bit colour depth the RAM needed is (width x height) bytes. Sprites can be created and deleted dynamically as needed in the sketch, this means RAM can be freed up after the Sprite has been plotted on the screen, more RAM intensive WiFi based code can then be run and normal graphics operations still work.
Drawing graphics into a sprite is very fast, for those familiar with the Adafruit "graphicstest" example, this whole test completes in 18ms in a 160x128 sprite. Examples of sprite use can be found in the "examples/Sprite" folder.
The "Animated_dial" example shows how dials can be created using a rotated Sprite for the needle. To run this example the TFT interface must support reading from the screen RAM (not all do). The dial rim and scale is a jpeg image, created using a paint program.
The XPT2046 touch screen controller is supported for SPI based displays only. The SPI bus for the touch controller is shared with the TFT and only an additional chip select line is needed. This support will eventually be deprecated when a suitable touch screen library is available.
The library supports SPI overlap on the ESP8266 so the TFT screen can share MOSI, MISO and SCLK pins with the program FLASH, this frees up GPIO pins for other uses. Only one SPI device can be connected to the FLASH pins and the chips select for the TFT must be on pin D3 (GPIO0).
Configuration of the library font selections, pins used to interface with the TFT and other features is made by editing the User_Setup.h file in the library folder, or by selecting your own configuration in the "User_Setup_Selet,h" file. Fonts and features can easily be enabled/disabled by commenting out lines.
Anti-aliased (smooth) font files in "vlw" format are generated by the free Processing IDE using a sketch included in the library Tools folder. This sketch with the Processing IDE can be used to generate font files from your computer"s font set or any TrueType (.ttf) font, the font file can include any combination of 16 bit Unicode characters. This means Greek, Japanese and any other UCS-2 glyphs can be used. Character arrays and Strings in UTF-8 format are supported.
The .vlw files must be uploaded to the processors FLASH filing system (SPIFFS, LittleFS or SD card) for use. Alternatively the .vlw files can be converted to C arrays (see "Smooth Font -> FLASH_Array" examples) and stored directly in FLASH as part of the compile process. The array based approach is convenient, provides performance improvements and is suitable where: either use of a filing system is undesirable, or the processor type (e.g. STM32) does not support a FLASH based filing system.
It would be possible to compress the vlw font files but the rendering performance to a TFT is still good when storing the font file(s) in SPIFFS, LittleFS or FLASH arrays.
Anti-aliased fonts can also be drawn over a gradient background with a callback to fetch the background colour of each pixel. This pixel colour can be set by the gradient algorithm or by reading back the TFT screen memory (if reading the display is supported).
The common 8 bit "Mcufriend" shields are supported for the STM Nucleo 64/144 boards and ESP32 UNO style board. The STM32 "Blue/Black Pill" boards can also be used with 8 bit parallel displays.
Unfortunately the typical UNO/mcufriend TFT display board maps LCD_RD, LCD_CS and LCD_RST signals to the ESP32 analogue pins 35, 34 and 36 which are input only. To solve this I linked in the 3 spare pins IO15, IO33 and IO32 by adding wires to the bottom of the board as follows:
If the display board is fitted with a resistance based touch screen then this can be used by performing the modifications described here and the fork of the Adafruit library:
If you load a new copy of TFT_eSPI then it will overwrite your setups if they are kept within the TFT_eSPI folder. One way around this is to create a new folder in your Arduino library folder called "TFT_eSPI_Setups". You then place your custom setup.h files in there. After an upgrade simply edit the User_Setup_Select.h file to point to your custom setup file e.g.:
You must make sure only one setup file is called. In the custom setup file I add the file path as a commented out first line that can be cut and pasted back into the upgraded User_Setup_Select.h file. The ../ at the start of the path means go up one directory level. Clearly you could use different file paths or directory names as long as it does not clash with another library or folder name.
The library was intended to support only TFT displays but using a Sprite as a 1 bit per pixel screen buffer permits support for the Waveshare 2 and 3 colour SPI ePaper displays. This addition to the library is experimental and only one example is provided. Further examples will be added.
TFT LCDs are the most popular color displays – the displays in smartphones, tablets, and laptops are actually the TFT LCDs only. There are TFT LCD shields available for Arduino in a variety of sizes like 1.44″, 1.8″, 2.0″, 2.4″, and 2.8″. Arduino is quite a humble machine whenever it comes to process or control graphics. After all, it is a microcontroller platform, and graphical applications usually require much greater processing resources. Still, Arduino is capable enough to control small display units. TFT LCDs are colorful display screens that can host beautiful user interfaces.
Most of the smaller TFT LCD shields can be controlled using the Adafruit TFT LCD library. There is also a larger TFT LCD shield of 3.5 inches, with an ILI9486 8-bit driver.
The Adafruit library does not support the ILI9486 driver. Actually, the Adafruit library is written to control only TFT displays smaller than 3.5 inches. To control the 3.5 inch TFT LCD touch screen, we need another library. This is MCUFRIEND_kbv. The MCUFRIEND_kbv library is, in fact, even easier to use in comparison to the Adafruit TFT LCD library. This library only requires instantiating a TFT object and even does not require specifying pin connections.
TFT LCDs for ArduinoUser interfaces are an essential part of any embedded application. The user interface enables any interaction with the end-user and makes possible the ultimate use of the device. The user interfaces are hosted using a number of devices like seven-segments, character LCDs, graphical LCDs, and full-color TFT LCDs. Out of all these devices, only full-color TFT displays are capable of hosting sophisticated interfaces. A sophisticated user interface may have many data fields to display or may need to host menus and sub-menus or host interactive graphics. A TFT LCD is an active matrix LCD capable of hosting high-quality images.
Arduino operates at low frequency. That is why it is not possible to render high-definition images or videos with Arduino. However, Arduino can control a small TFT display screen rendering graphically enriched data and commands. By interfacing a TFT LCD touch screen with Arduino, it is possible to render interactive graphics, menus, charts, graphs, and user panels.
Some of the popular full-color TFT LCDs available for Arduino include 3.5″ 480×320 display, 2.8″ 400×200 display, 2.4″ 320×240 display and 1.8″ 220×176 display. A TFT screen of appropriate size and resolution can be selected as per a given application.
If the user interface has only graphical data and commands, Atmega328 Arduino boards can control the display. If the user interface is a large program hosting several menus and/or submenus, Arduino Mega2560 should be preferred to control the TFT display. If the user interface needs to host high-resolution images and motions, ARM core Arduino boards like the DUE should be used to control the TFT display.
MCUFRIEND_kbv libraryAdafruit TFT LCD library supports only small TFT displays. For large TFT display shields like 3.5-inch, 3.6-inch, 3.95-inch, including 2.4-inch and 2.8-inch TFT LCDs, MCUFRIEND_kbv library is useful. This library has been designed to control 28-pin TFT LCD shields for Arduino UNO. It also works with Arduino Mega2560. Apart from UNO and Mega2560, the library also supports LEONARDO, DUE, ZERO, and M0-PRO. It also runs on NUCLEO-F103 and TEENSY3.2 with Sparkfun Adapter. The Mcufriend-style shields tend to have a resistive TouchScreen on A1, 7, A2, 6 but are not always in the same direction rotation. The MCUFRIEND_kbv library can be included in an Arduino sketch from the library manager.
The 3.5-inch TFT LCD shield needs to be plugged atop the Arduino board. The Mcufriend-style shields are designed to fit into all the above-mentioned Arduino boards. The shields have a TFT touch screen that can display colorful images and interfaces and a micro SD card reader to save images and other data. A 3.5-inch TFT LCD touch screen has the following pin diagram.
The drawFastVLine function draws a vertical line that starts in x, y location, and its length is h pixel and its color is t. The drawFastHLine function draws a horizontal line that starts in x and y location, and the length is w pixel, and the color is t. The drawLine function draws a line that starts in xi and yi locationends is in xj and yj, and the color is t. These methods draw lines with 5-pixel thickness.
The fillRect function draws a filled rectangle in x and y locations. w is width, h is height, and t is the color of the rectangle. The drawRect function draws a rectangle in x and y location with w width and h height and t color. The fillRoundRect function draws a filled Rectangle with r radius round corners in x and y location and w width and h height and t color. The drawRoundRect function draws a Rectangle with r radius round corners in x and y location and w width and h height and t color.
The drawTriangle function draws a triangle with three corner location x, y and z, and t color. The fillTriangle function draws a filled triangle with three corner location x, y and z, and t color.
How project worksThe code fills a rectangle, then draws a rectangle within which text “EEWORLDONLINE” is displayed. Then, lines, circles, rectangles, and squares are drawn on the screen. The project ends with a greeting and a message.
Since it’s inception the Arduino IDE has demonstrated the desire to support all kind of platforms, from Arduino clones and variations of different manufacturers to third party boards like the ESP32 and ESp8266. As more people get familiar with the IDE, they are beginning to support more boards that are not based on ATMEL chips and for today’s tutorial we will look on one of such boards. We will examine how to program the STM32 based, STM32F103C8T6 development board with the Arduino IDE.
The STM32 board to be used for this tutorial is none other than the STM32F103C8T6 chip based STM32F1 development board commonly referred to as “Blue Pill” in line with the blue color of its PCB. Blue Pill is powered by the powerful 32-bit STM32F103C8T6 ARM processor, clocked at 72MHz. The board operates on 3.3v logic levels but its GPIO pins have been tested to be 5v tolerant. While it does not come with WiFi or Bluetooth like the ESP32 and Arduino variants, it offers 20KB of RAM and 64KB of flash memory which makes it adequate for large projects. It also possesses 37 GPIO pins, 10 of which can be used for Analog sensors since they have ADC enabled, along with others which are enabled for SPI, I2C, CAN, UART, and DMA. For a board which costs around $3, you will agree with me that these are impressive specs. A summarized version of these specifications compared with that of an Arduino Uno is shown in the image below.
Based on the specs above, the frequency at which Blue pill operates is about 4.5 times higher than an Arduino UNO, for today’s tutorial, as an example on how to use the STM32F1 board, we will connect it to a 1.44″ TFT display and program it to calculate the “Pi” constant. We will note how long it took the board to obtain the value an compare it with the time it takes an Arduino Uno to perform the same task.
As mentioned earlier, we will connect the STM32F1 board to the1.8″ ST7735 based colored TFT Display along with a push button. The push button will be used to instruct the board to start the calculation.
Go over the connections once again to be sure everything is as it should be as it tends to get a little bit tricky. With this done, we proceed to set up the STM32 board to be programmed with the Arduino IDE.
As with most boards not made by Arduino, a bit of setup needs to be done before the board can be used with the Arduino IDE. This involves installing the board file either via the Arduino Board manager or downloading from the internet and copy the files into the hardware folder. The Board Manager route is the less tedious one and since the STM32F1 is among the listed boards, we will go that route.
Start by adding the link for the STM32 board to the Arduino preference lists. Go to File -> Preferences, then enter this URL ( http://dan.drown.org/stm32duino/package_STM32duino_index.json ) in the box as indicated below and click ok.
The code will be written the same way we’d write any other sketch for an Arduino project, with the only difference being the way the pins are referenced.
To be able to easily develop the code for this project, we will use two libraries which are both modifications of standard Arduino Libraries to make them compatible for the STM32. We will use the modified version of the Adafruit GFX and the Adafruit ST7735 libraries. Both libraries can be downloaded via the links attached to them.
With this done, we create an object of the ST7735 library which will be used to reference the display all through the entire project. We also indicate the pin of the STM32 to which the pushbutton is connected and create a variable to hold its state.
Next, we initialize serial communication and the screen, setting the background of the display to black and calling the printUI() function to display the interface.
We start by reading the state of the push button. If the button has been pressed, we remove the current message on the screen using the removePressKeyText() and draw the changing progress bar using the drawBar() function. We then call the start calculation function to obtain and display the value of Pi along with the time it took to calculate it.
The remaining part of the code are the functions called to achieve the tasks from drawing the bar to calculating the Pi. Most of these functions have been covered in several other tutorials that involve the use of the ST7735 display.
Uploading sketches to the STM32f1 is a little bit complex compared to standard Arduino compatible boards. To upload code to the board, we need an FTDI based, USB to Serial converter.
With this done, we then change the position of the board’s state jumper to position one (as shown in the gif below), so as to put the board in programming mode. Press the reset button on the board once after this and we are ready to upload the code.
With the code complete, follow the upload process described above to upload the code to your setup. You should see the display come up as shown in the Image below.
Press the pushbutton to start the calculation. You should see the progress bar slide gradually until the end. At the end of the process, the value of Pi is displayed along with the time which the calculation took.
Comparing these two values, we see that “Blue Pill” is over 7 times faster than the Arduino Uno. This makes it ideal for projects which involves heavy processing and time constraints. The small size of the Blue pill also serves as an advantage here as it is only a bit bigger than the Arduino nano and it can be used in place where the Nano won’t be fast enough.
That’s it for today’s tutorial guys. What will you be building with the Blue Pill? feel free to share along with any questions you might have, under the comment section.
This is a third release of combined soldering iron controller for Hakko T12 tips and 858D rework station based on STM32 micro controller. This time the oled display was replaced by ili9341 TFT one with SPI interface. There are several display variants (2.2", 2.4", 2.8" or 3.2") in the market, so you can chose the one that satisfies your requirements, I used 2.2" display. The touch screen feature is not used in this project, but you can use display with touch screen panel.
The soldering controller supports using soldering iron and Hot Air Gun at the same time. In the main mode, you can activate any device or activate both devices simultaneously or turn them off. As soosn as the display resolution is higher than oled display, the information of both devices can be displayed on the main screen.
Before updating the firmware, save the PID parameters if you have modified them. The landscape orientation is still the default. Some issues can be faced in the portrait display mode. Report them to be fixed.
To decrease the controller price and increase its reusability, the complete schematics was split in 3 separate PCBs. The main PCB conntains the main low-voltage components: stm32 blackpill board, op-amps, voltage dc-dc converter and regulator, mosfets that manage the soldering iron and Hot Air Gun fan. The AC power PCB contains the high-voltage part of the project: the triac, optional high-voltage relay and opto-couplers that creates galvanic isolation from the main board. These boards connected via 5-wire interface cable. The display PCB contains the TFT display and two rotary encoders.
JP11 is a optional DIP-type connector for SD-card reader on the TFT display. This connector is used to load external files to the SPI flash memory IC. Just solder the pin-header here.
The debug switch is optional one. You can solder the wire instead. It is used to disconnect 24v power from the bluepill board when the firmware is loading from your PC or while debug the firmware. As soon as 24v AC-DC power supply is not isolated one and the PC has non-isolated power supply also, it is possible to destroy blackpill board when it receives the power from different sources.
The high-voltage board implements wide lines and should be ordered with2ozdepth to allow high current to the Hot Air Gun heater. It would be very expensive to order the complete board with 2 oz depth, so the high-voltage part was split to a separate PCB. Yet, the interface connector is completely isolated from AC power via two opto-couplers OK1 and OK2. The EasyEda page contains two versions of the pcb, both are correct. You can select the one you like.
The interface connector has 5 wires that manages the AC power board:"+24" is +24 volt from AC-DC power supply to activate K1 relay. You can remove this wire if you do not install the relay
The schematics of the board is very simple. It contains two rotary encoders and TFT display. Also, you can see the mosfet that manages the TFT display brightness.
The controller requires big size PCB to fit all the components so it is convenient to create the display separate board. Also, It is convenient to solder rotary encoders to the display board and use encoder neck to fix this board on the acrylic front panel.
This controller is working with ili9341 based TFT displays only. You can select the display size (2.2", 2.4", 2.8" or 3.2"). The display has sufficient resolution 320x240 to show required information. I used the 2.2" one to fit the case.
The Hakko T12 soldering tips are very convenient tools: they are heating extremely fast and have a sensor inside that allows to keep the temperature very accurate. The tips require just three wires: plus, minus (ground) and earth ground. The heating element inside the tip is connected consequently with the thermo couple allowing to decrease the required wires. It makes the cable very flexible and light weight.
When connecting the Hot Air Gun handle to the controller via GX16-8 plug you can use the following reference of the plug pin-out. Unfortunately, I do not know the color of the wires because my handle was assembled. I have been told that there is a different kind of hakko 858D handles in the market and your handle can have different pinout. To check your handle pinout you can keep in mind the following criteria:The plug should have two wires for the heating element, two wires for the temperature sensor and two wires for the fan. The reed switch shares gnd with a temperature sensor.
This feature increases the safety of soldering iron. There are two automatic power-off features are implemented inside the controller, software driven and hardware driven. The hardware driven one requires optional TILT or REED switch installed in the iron handle. In the software mode, the controller turns on the Idle mode if the supplied power to the iron is stable for a while. In this case, the controller will power off the iron in specified timeout. When the time to automatic shutdown near, it will be displayed as a seconds remaining. When you use the iron, the supplied power changes and the controller resets the automatic power off timeout.
To use the hardware TILT switch, you must setup automatic power off timeout and standby temperature. If the standby temperature is "OFF" the hardware tilt switch will not be used and software solution described previously will be activated. Also, you can setup standby time (timeout to switch to low power mode). When the tilt switch enabled, the main working mode changes the following way. The iron is starting heating. When it reaches the preset temperature the "Ready" message will be displayed and the controller will keep the preset temperature. If the soldering IRON is not used (laying on the table) the controller will switch low power mode. If the iron keep laying for automatic off timeout, the controller will switch off the power completely. As soon as you start using the iron, the controller restores the preset temperature.
The main component is the BlackPill board. You can use the pure STM32F401CCU6 micro controller if you wish to create compact variant of the soldering station.
Connect this DC-DC converter consequently with b0505 isolated cobverter: 24v -> MP1584 DC-DC converter -> b0505 -> ams1117 gnd you get isolated power supply for your stm32 micro controller. This king of power supply is isolated and low-noise power that ensure accurate ADC temperature readings.
This project is based on the BlackPill board with STM32F401CCU6 micro controller. To flash prebuilt firmware to the controller the st link v2 programmer and ST link utility are required.
Download the STM32 ST-LINK utility fromstsite. Install the utility in your system. Launch the ST-LINK utility, connect the programmer to the 4pins SWD interface of BlackPill board, press "connect" button. The main window should display the memory content of the BlackPill board. Press flash button to write the firmaware to the BlackPill board.
As you can see, the main AC power after fuse that can be installed on the pannel of the case, goes into JP3 socket on the high voltage board. You can connect main power switch to the JP6 socket or short it oins and completely remove main switch if do not like to use it. JP4 and JP2 sockets are used to connect to the GX16-8 connector of the Hot Air Gun. The power to the heater goes from JP4 socket and all other wires connected to the JP2. Earth ground should be connected to the Earth ground of AC power (not shown here). JP8 and JP9 connectors should be connected together. Soldering Iron GX12-5 connector should be connected to JP1 and JP5 sockets. JP10 used to connect optional automatic mode switch. Using this switch you can disconnect the Hot Air Gun completely from the controller when it is not needed. JP3 should be connected to the J1 connector on the TFT board. This is 14-wires connector to attach the display and rotary encoders.
Using JP11 you can connect the SD-CARD installed on TFT display to the controller when going to upload some files from SD-CARD to SPI FLASH. For instance, it can be used whel upload localization data files.
In the controller schematics you can see two 500k potentiometers R5 and R19 that tunes the operation amplifier U4.1 and U4.2 to get the expected temperature readings at controller pins PA4 and PA5 of BlackPill board. You can use different operating amplifier, so these potentiometers are increasing the controller flexibility.
To simplify controller tuning procedure, the tune modes are implemented in the controller. This modes can be activated from the system menu item "tune iron" or "gun menu->tune gun". When the tune mode is activated, the controller powers on the iron or Hot Air Gun and displays on the screen applied power (in percents) and the gauge of the current temperature readings. The gauge has a label "450" or "500" depending on what hardware you are tuning. When the gauge reaches this label, the temperature should be 450 or 500 degrees of Celsius.
As soon as you have stabilized the iron temperature near 450 degrees, rotate the 500k potentiometer trim to shift gauge bar on the display left or right. Adjust the potentiometer so the bar would be as near to the reference temperature as possible. Then long press the encoder handle (for about 2 seconds) to turn the iron off and finish the procedure. It is recommended to use the thick tip that produce the highest voltage when performing the tune procedure. For example, T12-K, T12-D52 or similar.
As you can see from the picture above, the debug screen shows the following information:iron status (off or on). You can manage the power supplied to the soldering iron by rotating the upper encoder. As the encoder rotated, you adjust the power supplied to the iron (in internal units). The more power supplied to the iron the faster it heats. Supplied power value displayied in the right column ("irnP") in the internal units.
If the SPI FLASH is formatted and working correctly, you should see the screen above. As you can see, it is the root directory list of SPI FLASH. In case of FLASH error, the error message would be displayed indicating the FLASH is not readable. If your SPI FLASH is unformatted, the corresponding message would be displayed and the controller asks you to confirm the FLASH should be formatted. When the FLASH will be formatted, you should see the empty file list.
The current tip can be calibrated using "calibrate tip" menu item. If the tip is not calibrated yet, the "[!]" sign would be displayed near the tip name on the main screen. There are two calibration modes in the current version of the controller firmware: automatic and manual.
First, turn the power on by pressing the encoder lightly to start calibration process from the first referense point. The iron start heating. When the reference temperature reached, the controller beeps and get ready to read the real temperature value. Check the iron temperature by the external thermo-couple and enter this temperature to the controller: rotate the encoder handle to select the real temperature then press the encoder lightly. Then the controller continues with the next reference point. This procedure finishes when you enter temperature of all 8 reference points or when the real temperature will be greater than 430 Celsius. During this procedure controller updates the tip calibration data.
In manual tip calibration you must "guess" the internal temperature readings that matches the calibration temperature. First, you should select one of the 4 calibration temperature and press the encoder lightly to start calibration process. This procedure is iterative: you start with the some preset temperature value in internal units (for example, calibrated by automatic procedure) the controller heats the tip to this preset temperature and gets ready. Then you measure the real temperature by the external thermo-couple. If the real temperature is not equal to the preset one, you should increase or decrease the internal preset temperature by rotating the encoder handle.
The progress bar in the lower part of the display shows the difference between preset and current temperature (in internal units) of the tip. The controller keeps the tip temperature near the preset value (vertical line on the progress bar) all the time. To increment the preset temperature, turn the encoder right, to decrease - turn it left.
When the low power (standby) mode activated, the controller shows the "standby" icon in the upper-right corner of the display lie shown on the picture below.
The "tune iron PID" and "gun setup->tune gun PID" menu items in the main menu allowing tuning PID parameters of soldering iron and Hot Air Gun. When tune PID mode activated, you can see three values of PID parameters on the display, Kp - proportional, Ki - integral, Kd - differential. First, choose the parameter you are going to change and press the encoder button. You turn into tuning test mode. There are two graphs: the temperature difference and power math dispersion. Both graphs are auto magnifying ones and its maximum value is shown on the Y-axis by the corresponding color.
Prebuilt version of the controller software can be downloaded from the github repository. To upload this hex file into controller, you can use stm32 st-linkutility.
In order to use your native language, the NLS data should be uploaded into SPI FLASH. To do so, you have to:Connect your SD-CARD reader (the TFT display board has one) to the JP11 connector via 4 wires: SD_CS (Chip Select), MOSI, MISO, SCK. If you have not implemet the JP11 socket, remember following: SD_CS (Chip Select) - PB12, MOSI - PB15, MISO - PB14, SCK - PB10.
When the controller copies files from SD-CARD to SPI FLASH, it reads thecfg.jsonfile and loads the language data accordingly with this file. For each language in the list, it checks the language consistency and copies data files when the language is consistent (have both message and font file). Yet, the controller copies only files that is newer that existed on SPI FLASH one. Font data file can be used for several languages. For instance, you can use ubuntu_we.font for several Wester Europe languages.
The SparkFun TFT LCD Breakout is a versatile, colorful, and easy way to experiment with graphics or create a user interface for your project. With a 4-wire SPI interface and microSD card holder, you can use this breakout to easily add visual display/interface capabilities to a project as well as providing all the storage you might need for multimedia files.
To get started with this breakout, you will need an Arduino compatible microcontroller of your choice - we recommend something with extra RAM like the SparkFun Thing Plus. The breakout can be powered with either 5V or 3.3V. The microSD card holder is connected to the same SPI bus as the display which keeps the required pin count low and exists to relieve the burden from your microcontroller"s poor memory due to having to store hundreds of images of cats, or really whatever you want to keep there. We have also gone ahead and tricked out the SparkFun HyperDisplay library with a driver made especially for this breakout!
Out of the box, the SparkFun TFT LCD Breakout will come with a large backing PCB that makes it easy to securely mount the display in a project. If you need a more flexible solution you can remove the display module, snap off half the backing board, and then re-insert the display module. When this is done you"ll be left with the bare minimum frame around the display to more seamlessly integrate with your project.
Got three of them all working(1 with Arduino Leonardo and 2 with NodeMCU ESP8266).arduino will need a solution to the 5v out 3.3v in(10s solder job) NodeMCU is directly compatible.i used adafruits code.Very happy. getting more. also hiletgo products have all been functional so far. becoming a fan.Update: switched to TFT_eSPI.h library. Wow. Orders of magnitude faster display now. A bit trickier to setup but well worth it.