Skip to player
Skip to main content
Search
Connect
Watch fullscreen
Like
Bookmark
Share
More
Add to Playlist
Report
TouchGFX with STM32 (PART 1) | Toggle LED Using Button UI
ControllersTech
Follow
7 weeks ago
#stm32
#touchgfx
#embeddedsystems
#stm32tutorial
#ledcontrol
#stm32cubeide
#microcontroller
#controllertech
Learn how to **toggle an LED using TouchGFX** on STM32 with a simple button interface. This tutorial is perfect for beginners and embedded system developers.
š„ Download:
- Project files ā [https://controllerstech.com/getting-started-with-touchgfx-stm32f750/]
ā¶ļø Related Videos:
- TouchGFX with SPI Displays (ILI9341) ā https://youtu.be/suMytEyQTP4
- TouchGFX PART 2 ā https://youtu.be/vy1c1LbypuM
TouchGFX Playlist ā https://www.youtube.com/playlist?list=PLfIJKC1ud8giOsk-C4BCOwSHtbXqTNb1W
#STM32 #TouchGFX #EmbeddedSystems #STM32Tutorial #LEDControl #STM32CubeIDE #Microcontroller #ControllerTech
________________________________________________________________________________________
Facebook Page : https://www.facebook.com/controllerstech
Telegram Group : https://t.me/controllerstechdiscuss
Instagram : https://www.instagram.com/controllerstech/
For more info, visit https://controllerstech.com
Category
š¤
Tech
Transcript
Display full video transcript
00:00
Hello, and welcome to Controllers Tech. A lot of you guys requested this, so today I am starting
00:17
the Touch GFX series for STM32. I guess you have already tried some experiments with the Touch GFX,
00:25
and you already know how to create a project for your board. So I will just keep this video to the
00:31
point, where I will connect the GFX to our own code. This is the first video in the series,
00:38
and today we will see how to toggle the LED, using the button on the display. So let's start the Touch
00:45
GFX Designer. Click Create, and choose your board. If you are doing this first time, you will need an
00:57
internet connection, or else it won't show anything. I am using STM32F750 Discovery Board.
01:06
Give the name to the project, and click Create.
01:09
Alright we got our blank project. There are a lot of things here, which we will cover in the future
01:21
videos. Today we will start with the simple image. Let's add the image to our display.
01:30
If you click on the image, you will get its properties on the right. Like, the name,
01:36
its location, etc. To add the image, click this image, and select from here.
01:46
If you don't have any image, you can choose from the preloaded backgrounds.
01:53
They are available for pretty much every size. Or else, click Add and choose the image.
02:00
The image should be in the ping format. I already have one created for backgrounds.
02:07
So this will be our background image, and now we will add a button on the display.
02:15
I am adding this toggle button, as we are going to toggle the LED.
02:19
Here are the properties for this button. You can choose the style here.
02:32
Or how will it look if pressed, or released.
02:35
Let's keep the default state to pressed. So it will be in on state by default.
02:42
Alright the button has been created. Now what will happen, when we press this button?
02:49
Well we need to define that, and to do that, we will add the interaction.
02:53
This interaction will trigger, when the button is clicked. The button is this one, that we created just now.
03:06
In the action, you can choose whatever action you want, but for toggling the LED,
03:11
we will call a new virtual function, which we will define later in the code.
03:17
The name for the function, let's keep it toggle LED.
03:21
Interaction name, let's keep it same.
03:25
So that's it for the design part.
03:27
Click here to generate the code.
03:40
Let's open the files.
03:42
This is the touch GFX folder, we will go back to project, and open the cube IDE.
03:48
Inside the application, user, we have our main file.
04:11
Here the generated folder is generated based on our setup, and we can't modify these.
04:16
The GUI folder is where we can write our code for the application.
04:22
We will check these in a while, let's open the cube MX setup first.
04:32
This setup is configured for QSB AirFlash, SDRAM, display library, and other things.
04:40
Here we will just add the things we need.
04:43
For example, here in this project, I want to control the LED, so set the LED pin as output.
04:51
There is no onboard LED on this board, but here you can see, pin PK3 is the display backlight control pin.
05:00
So I will control this with the button I just created.
05:03
This pin is already set as output, so I don't need to configure anything.
05:09
Let's go back to our project.
05:14
Screen 1 view base is where the code is generated for the elements on the screen.
05:20
Here is the image, and this is the button we created.
05:23
The button calls the button callback, which further calls the toggle LED function.
05:33
Like I said earlier, we can't do any modification in these files, so we will copy this function,
05:40
and we will modify this in other file.
05:47
Open the screen 1 view.
05:49
Now open the header file.
05:54
Here we have to add the function first.
05:57
So add the virtual void, toggle LED.
06:00
Save it, and go back to the source file.
06:04
Here we will write the code for the function.
06:07
This is defined in class, screen 1 view.
06:11
Before we write the code to toggle the LED, let's run the project once.
06:26
You can see the toggle button, and the default state is on.
06:34
So the toggle button is working well, let's go back to the project.
06:41
Here first we will get the state of the toggle button.
06:44
If the state is true, we will turn on the LED.
06:59
Else, the LED will be off.
07:04
Let's build it once.
07:06
We got some error about the whole functions.
07:09
Include the whole library according to your board.
07:14
And now everything is fine.
07:21
Let's flash it to the board again.
07:37
You can see, the display is turning off, and it only turns on when I tap the button again.
07:43
So we were able to toggle the LED using the button on the display.
07:50
There is one more thing I want to confirm here.
07:53
Let's try to run the simulator.
07:55
Well, we can't.
08:00
Well, we can't.
08:01
The reason is that we are using some code which depends on external factors, like the whole code.
08:07
So let's exclude all the whole related code from the file, and now try to run the simulator.
08:20
It runs OK now.
08:21
If you write a code, that depends on any other variable, which is external to the generated files, the simulator can not run.
08:39
We will see more to this in the near future.
08:43
This is it for the video.
08:45
I hope you understood the process for controlling the LED using the button.
08:50
The next video will cover the counter on the display, and how to change the value of this counter using various methods.
08:57
The code is very big, so I will only upload the necessary files.
09:02
You can download it from the description.
09:06
Leave comments in case of any doubt.
09:08
Keep watching, and have a nice day ahead.
Be the first to comment
Add your comment
Recommended
20:00
|
Up next
STM32 CAN Communication Explained | Send & Receive Data Between Two Microcontrollers
ControllersTech
7 weeks ago
13:03
How to Interface BLDC MOTOR with STM32
ControllersTech
7 weeks ago
10:53
STM32 LCD Tutorial | 16x2 LCD in 4-Bit Mode (No I2C, Full HAL Code Walkthrough)
ControllersTech
7 weeks ago
19:04
STM32 + ESP8266 Tutorial (Part 1) | WiFi Setup & Obtain IP Address
ControllersTech
7 weeks ago
12:06
STM32 Flash Memory: Erase, Write, Read & Debug in CubeIDE
ControllersTech
2 months ago
20:27
STM32H7 Memory Management Demystified: TCM, SRAM & DMA Access
ControllersTech
2 months ago
14:38
Next Level Stepper Motor Control with STM32 | RPM, Angle & Direction Explained
ControllersTech
2 months ago
18:16
Master Real-Time Clock on STM32 Using DS3231 & CubeIDE
ControllersTech
2 months ago
11:20
STM32 Tutorial: HC-SR04 Ultrasonic Sensor via Timer Input Capture
ControllersTech
2 months ago
14:22
SSD1306 OLED with STM32 | I2C Display Tutorial for Beginners
ControllersTech
2 months ago
16:55
WATCHDOGS in STM32 ā IWDG and WWDG | CubeIDE Tutorial #STM32 #CubeIDE
ControllersTech
2 months ago
12:22
Interface 16x2 LCD with STM32 via I²C | CubeMX + HAL Guide
ControllersTech
7 weeks ago
16:07
DAC in STM32 | Sine Wave Generation | HAL | CubeIDE Tutorial
ControllersTech
7 weeks ago
17:46
Interfacing BME280 Sensor with STM32 via I²C ā Measure Temperature, Pressure & Humidity
ControllersTech
7 weeks ago
0:51
Former Aide Claims She Was Asked to Make a āHit Listā For Trump
Veuer
2 years ago
1:08
Muskās X Is āthe Platform With the Largest Ratio of Misinformation or Disinformationā Amongst All Social Media Platforms
Veuer
2 years ago
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
2 years ago
0:46
3 Things to Know About Coco Gauff's Parents
People
2 years ago
0:35
8 Things to Do in the Morning to Improve Productivity
Martha Stewart Living
2 years ago
2:11
Why You Should Remember Aretha Franklin
Goalcast
2 years ago
1:18
USC vs. Colorado: Can Caleb Williams Earn a New Heisman Moment?
SportsGrid
2 years ago
1:04
Vic Mensa Reveals Celebrity Crush, Biggest Dating Pet Peeve & More on Speed Dating | Billboard News
Billboard
2 years ago
1:09
Hollywood Writers Reach āTentative Agreementā With Studios After 146 Day Strike
Veuer
2 years ago
1:26
Love is Blind stars admit they're burnt out from social media
Fortune
2 years ago
2:01
NHA Customers in Limbo as Company Faces Potential Merger
SportsGrid
2 years ago
Be the first to comment