SubName: An ESP32 with a built in OLED display screen updating a progress bar.
Description: With this example source code, you can place a progress bar on the screen of an ESP32 microcontroller with a built in OLED display. You can display and update the progress bar using Inline C extremely easily. It's a pretty simple looking progress bar but it does look good if you need one in your project. I've attached the library that I used for this project.
Note: Download and unzip the attached files directly into your Arduino 'Documents\Arduino\libraries' folder.
Below is just one way to use Inline C to utilise a small part of the SSD1306 library.
Tags: ESP32, OLED, Display, Progress, Bar, Inline, C, C++
Here it is in action.
Enjoy...
Description: With this example source code, you can place a progress bar on the screen of an ESP32 microcontroller with a built in OLED display. You can display and update the progress bar using Inline C extremely easily. It's a pretty simple looking progress bar but it does look good if you need one in your project. I've attached the library that I used for this project.
Note: Download and unzip the attached files directly into your Arduino 'Documents\Arduino\libraries' folder.
Below is just one way to use Inline C to utilise a small part of the SSD1306 library.
B4X:
'************************
'*** BOARD TYPE ***
'*** ESP32 Dev Module ***
'************************
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private TmrPBar As Timer
Private UpDown As Boolean
Private Progress As Byte
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("setup", Null)
TmrPBar.Initialize("TmrPBar_Tick", 25)
TmrPBar.Enabled = True
End Sub
Sub TmrPBar_Tick
RunNative("cleardisplay", Null)
If UpDown Then
Progress = Progress - 1
If Progress <= 0 Then UpDown = False
Else
Progress = Progress + 1
If Progress >= 100 Then UpDown = True
End If
RunNative("drawbrogressbar", Null)
RunNative("updatedisplay", Null)
End Sub
#if c
#include "SSD1306.h"
// Initialize the OLED display
SSD1306 display(0x3c, 5, 4);
void setup(B4R::Object* unused)
{
display.init();
display.flipScreenVertically();
}
void drawbrogressbar(B4R::Object* unused)
{
// draw the progress bar
display.drawProgressBar(0, 32, 120, 10, b4r_main::_progress);
// draw the percentage as String
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 15, String(b4r_main::_progress) + "%");
}
void cleardisplay(B4R::Object* unused)
{
display.clear();
}
void updatedisplay(B4R::Object* unused)
{
display.display();
}
#End If
Here it is in action.
Enjoy...
Attachments
Last edited: