Bluepill TFT LCD GPS Clock

What are you developing?
Post Reply
raduc
Posts: 3
Joined: Sat Apr 10, 2021 3:57 pm

Bluepill TFT LCD GPS Clock

Post by raduc »

This Clock is using a 320X240 ILI9341 tft lcd connected over SPI. Also the Blupill does have a 32Khz crystal for RTC and a backup CR2032 battery will keep the clock running and the battery backed up RAM with all the settings up and running even when the power is off. A GPS module is used to set the clock and display the QTH locator.

BOM: Bluepill module with 128K flash, even a clone SRM32 will work. 320X240 ILI9341 TFT LCD any size with a 14 pin connector, tested with 2.8' and 3.2 displays'. Neo 6M or 8M GPS module with antenna/ external antenna. Depending on the local conditions and building you may need an external antenna to get a good GPS fix. I will suggest a neo-8M with a full-size patch antenna or external antenna if that will not work inside. DS18B20 temperature sensor with F/C temperature display. 3 push buttons to control the clock and a piezo buzzer for alarm.

The clock has a menu with many options in order to set the time, date, 2 alarms, DST settings and multiple clock faces - Analog, Digital, BCD, GPS details - see attached pictures, display backlight will automatically adjust day/night.

Github link:
https://github.com/Express1/STM32TFTClock

Picture link:
https://github.com/Express1/STM32TFTClo ... SClock.jpg
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: Bluepill TFT LCD GPS Clock

Post by feluga »

Very nice! A complete project with STL and documentation.
Thanks for sharing!!
jacobli
Posts: 42
Joined: Fri Jun 11, 2021 3:40 am

Re: Bluepill TFT LCD GPS Clock

Post by jacobli »

Is the TFT LCD that is not ILI9341 also applicable?

Can I also use your program if I have another 320x240 TFT LCD?
raduc
Posts: 3
Joined: Sat Apr 10, 2021 3:57 pm

Re: Bluepill TFT LCD GPS Clock

Post by raduc »

Will work if you modify the code as necessary and the display library does support it. The simple answer is no, will not work with another display controller.
pwrgreg007
Posts: 13
Joined: Sun Jan 09, 2022 2:56 am
Location: LaGrange, GA

Re: Bluepill TFT LCD GPS Clock

Post by pwrgreg007 »

This Clock is using a 320X240 ILI9341 tft lcd connected over SPI. Also the Blupill does have a 32Khz crystal for RTC and a backup CR2032 battery will keep the clock running and the battery backed up RAM with all the settings up and running even when the power is off. A GPS module is used to set the clock and display the QTH locator.
Hey @raduc, nice implementation! I am building something similar, using Bruce Hall's design at https://www.universal-solder.ca/downloa ... 20Hall.pdf, which uses a WWVB receiver module instead of GPS. I have the WWVB time, display, touch control, and battery backup of RTC & date registers working. It is using the TFT_eSPI library for the display. My next step is to see if I can get the ILI9341 backlight to adjust. I have a 'TFT 2.8 inch red board' that I got from Amazon. I have not had much luck getting information from the manufacturer (or seller) about backlight control, but I do have the ILI9341 datasheet which shows eight backlight control registers. I have to say the power of these new VLSI chips (STM32F family, ILI9341) is amazing!
I have examined the TFT_eSPI.h file, and don't see any function definitions that look backlight related, although there appear to be some register control functions that could be used.
Before I download your project from github, I wanted to ask you, are you using the TFT_eSPI library, direct HAL control, or something else for your backlight control? At this point I just want to try a simple test program to see if the board was built to support the ILI9341 backlight control.
Once I get this all figured out, I plan to upload code & pictures to github to share this additional clock project so anyone can build one.
Thanks for your time.
Last edited by pwrgreg007 on Sat Feb 26, 2022 4:02 pm, edited 1 time in total.
raduc
Posts: 3
Joined: Sat Apr 10, 2021 3:57 pm

Re: Bluepill TFT LCD GPS Clock

Post by raduc »

Display brightness is controlled by a pwm signal, display pin 8, led backlight.
pwrgreg007
Posts: 13
Joined: Sun Jan 09, 2022 2:56 am
Location: LaGrange, GA

Re: Bluepill TFT LCD GPS Clock

Post by pwrgreg007 »

@raduc Thanks for your feedback. After searching for a couple days, I found many references to PWM code for Arduino and Blue Pill. One youTube video shows using pwmWrite() function, but STM32 core library doesn't seem to support it: I get 'not declared in this scope'. What I'm trying to do (simple explanation) is use a photocell on an analog input, and output a corresponding brightness to the TFT LED backlight. My TFT board does appear to support this (on pin 8), and I would say it is transistor controlled, since the pin sinks only 2.6 mA when connected to 3.3 v. The PWM signal does not need to be super-precise, as long as it's consistent when set. And it doesn't have to be fast, only enough to overcome persistence-of-vision sensitivity to flickering, so 100 Hz (give or take) would be fine. I'm lazy so I'm looking for the simplest way to do this (if there is such a thing).
I see a function analogWrite() in the Arduino reference, which sounds like it'd work, but STM32 isn't in the boards list.
In the Arduino (using 1.8.19 on Windows) library manager are "STM32_PWM" and "STM_Slow_PWM." Are either of these good to use for my application? Is there something better? Do I need to use a timer? I am using SPI already for TFT, and TIM3 for a periodic interrupt. There's so much conflicting information out there, I will have to rely on forum members to help me out. I'd like to use the latest builds if possible. I am using STM core library 2.2.0. A pointer to sample code for Blue Pill would be awesome.
Thanks - Greg
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 27
Location: Prudnik, Poland

Re: Bluepill TFT LCD GPS Clock

Post by GonzoG »

@pwrgreg007
Use standard Arduino function analogWrite(). You won't find any non-Arduino boards in Arduino reference.
e.g: for 50% duty cycle

Code: Select all

analogWrite(PA3,127);

Default frequency is 1kH but you can change by calling analogWriteFrequency() before analogWrite(), e.g:

Code: Select all

analogWriteFrequency(250);
analogWrite(PA3,127);
pwrgreg007
Posts: 13
Joined: Sun Jan 09, 2022 2:56 am
Location: LaGrange, GA

Re: Bluepill TFT LCD GPS Clock

Post by pwrgreg007 »

@GonzoG Thanks, that works!
Post Reply

Return to “Projects”