|
Forum Index : Microcontroller and PC projects : LCD Visual Design Studio Free browser-based UI builder & C++ generator
| Page 1 of 3 |
|||||
| Author | Message | ||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi everyone, Over the past few years (very many!), I’ve been working on a project to solve a headache I’m sure many of you have run into: designing touch screen interfaces for microcontrollers without having to manually calculate X/Y pixel coordinates and write endless boilerplate code. I’ve developed a free, browser-based visual designer called ESP32 Visual Studio (though it now supports quite a bit more than just the ESP32!): Website URL: https://esp32-lcd-designer.prontogwyn.site/ There is no account or sign-up required—you just open the page and can start designing right away. Why I Built It? I worked in the biotech instrument design and development industry, designing and bringing to market various precision measurement instruments. I'd write software apps to be able to create rapid concepts and prototypes for future instrument products. I also enjoy developing DIY homebrew projects and write little apps to make it easier to develop, so if you've ever tried building a multi-screen menu, a dashboard with gauges, or a keypad input on an SPI LCD in Arduino C++, you know how tedious it gets testing button hit-boxes, debouncing touch, and redrawing elements. I wanted an environment inspired by the classic Visual Basic / RAD workflow where you can: Drag controls onto an LCD canvas (sized for your exact screen). Set colors, styles, fonts, and ranges in an inspector. Double-click to write simple, familiar event code (e.g. Button1_Click, Slider1_Change, Timer1_Tick). Test it instantly in a browser simulator with interactive GPIO switches and LEDs. Click Export ZIP and get a clean, standard Arduino sketch with all libraries and headers configured. What’s Supported Microcontrollers: ESP32 (WROOM, S3), ESP8266, Raspberry Pi Pico / Pico W (RP2040), and the new Pico 2 / RP2350 (including 48-pin RP2350B boards). Displays: Standard SPI LCDs with XPT2046 touch (ILI9341 2.4"/2.8"/3.2", ILI9488 4", ST7789, ST7735), plus ready-made profiles for the Cheap Yellow Display (CYD 2.8") and Elecrow CrowPanel boards (2.4", 2.8", and the 7" RGB panel). Graphics Drivers: Generates clean code for TFT_eSPI (with automatic User_Setup.h), Adafruit GFX, Arduino_GFX, or LovyanGFX. Toolbox Controls: Pushbuttons (Rounded, Pill, Industrial Square, 3D Beveled, Ghost outline, Circular) Radio buttons with independent grouping Circular, Semicircular, and Linear Gauges with customizable warning/danger zones Sliders, Progress Bars, and Toggles Embedded resizable Images (auto-converted to RGB565 arrays) & Shapes Full Numeric Keypads (Phone, Calculator, PIN, Decimal) and a pop-up QWERTY Keyboard Canvas Waveform drawing (DrawLine, DrawCircle, DrawRect, FillScreen, DrawWidth) for plotting sensor curves or sine waves Multi-page/form navigation (Form2.ShowForm) Simulator: A built-in "Run Preview" with a virtual GPIO hardware bench that simulates pushbuttons, toggle switches, and glowing LEDs/PWM outputs before you touch any hardware. Looking for Your Thoughts & Feedback I’ve built this web-based version as a personal project to give something genuinely useful back to the maker community. I’d love for fellow BackShedders to give it a spin on their bench screens and let me know how it works for you. If you have a specific display driver, pinout, or feature you'd like to see added, please let me know—I'm actively refining it! Oh, I'm new to posting on forums! Please be gentle.. Cheers, Peter |
||||
| vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1200 |
That's kinda cool! I've had a brief play with it, next I need to figure out how to use the output. An Undo button might be handy, for when I drag/resize a control un-intentionally. Font choice is unclear. For example, in the demo panel chosen at startup, the numerical value of the temperature shown in the Sensor1 control uses a different font than the value shown in the Gauge1 control. <Hmm, is the BackShed "Upload Image" button broken?> Would zoom make more sense if it showed screen resolution/pixels better? Visit Vegipete's *Mite Library for cool programs. |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 3475 |
![]() Some formats (eg .BMP) not supported but .PNG and .JPG should be ok. There may also be a size limit. Clickable link for UI builder Edited 2026-11-18 08:56 by phil99 |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Thanks vegipete for taking a look and for the great feedback! Also phil99 for the clickable link, I just noticed the icon above the post editor. On Undo: Spot on. It’s very easy to accidentally nudge or resize a control while clicking around, so I'm adding an Undo (and Ctrl+Z) feature to make quick rollbacks seamless. On Fonts: Good catch! In the generated C++ code, the microcontrollers use TFT_eSPI's built-in bitmap fonts (Font 1 = 8px, Font 2 = 16px, Font 4 = 24px). The circular Gauge defaults to Font 2 so the number fits inside the dial arc, whereas the Sensor card uses Font 4 for a larger readout. On the browser LCD canvas, the sensor was also using a smoothed browser font instead of the pixel-accurate LCD font preview that the gauge uses. I'm updating this so all controls preview with consistent font rendering, and adding clearer font size controls in the property panel. Thanks again for trying it out, keep the ideas coming! Peter |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
I'm currently working on adding a Wi-Fi component to the studio, this will make it a useful feature. Some of the code i used on my ESP8089, 8089EX (work) and ESP8266 (home projects). WiFi and WebServer are now in the toolbox, below Oscillator. Like the Timer, they show as small icons on your design but aren't drawn on the LCD. WiFi settings: Mode (Station to join your router, or Access Point to make its own network), network name (SSID), Password and Auto connect. Its events are WiFi1_Connected and WiFi1_Disconnected. WebServer settings: Port (80 to start with) and a Web page menu with three choices: Mirror LCD controls, Custom VB handler, or Both. Its event is WebServer1_Request. Export check now warns you about: a board that has no Wi-Fi a plain Pico, since only the Pico W has Wi-Fi a missing network name a password shorter than 8 characters a WebServer with no WiFi control more than one of either control In progress (not done yet): the exported sketch leaves these two controls out for now, and the export check tells you so. Your settings are still saved in the .pgproj file. Run Preview doesn't act out a connection yet, and there's no Help page for them. Those are the next steps. The Wi-Fi password is saved as plain readable text in your .pgproj file, so don't share that file publicly. I hope to finish unit testing and verification tests tomorrow ( )!I'm also updating the help guide Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Logic tests for Wi-Fi (connect and AP) passed, implemented now So the WiFi control now goes into the exported sketch: it connects (or starts an access point), and your WiFi1_Connected / WiFi1_Disconnected subs run when the connection comes up or drops. What you can now use in code.vb: WiFi1.IPAddress, WiFi1.RSSI, WiFi1.IsConnected, WiFi1.Connect() and WiFi1.Disconnect(). In Run Preview: the Wi-Fi connects about 2 seconds after start and shows a fake IP address (192.168.1.120, or 192.168.4.1 in access point mode). The status appears in the top bar, along with Connect and Drop Wi-Fi buttons so you can test both events. Just finishing the Web Server and the Help guide page which are the next steps. Peter ESP32 Visual Studio - link |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 2178 |
I agree, that's a bit irritating. I had the same experience, yesterday. Tried everything. I use Duckduckgo browser and never have a problem but yesterday, the only way for me to upload was to use Chrome. |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 2178 |
Never been a problem for me. I have always put a lot of emphasis on making my GUIs stand-out. ![]() ![]() ![]() ![]() ![]() ![]() |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, Finally got the WI-FI aspect of the project working. The ESP32 webserver can now be accessed by a browser connected to 192.168.4.1 (ESP32 address) and you can see and interact with your ESP32 program as mirrored on the LCD, however i have put an option in the properties to allow you to use custom VB handling or both with custom URL's. ![]() I'm still verifying the handling logic to capture any issues! ESP32 Visual Studio - link Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, Im adding SDcard capability to the studio, this will allow:- Datalogging: writing sensor readings, timestamps, and button events to CSV files (SD.Append "log.csv", ...). Configuration & presets: saving and loading settings, Wi-Fi credentials, or calibration values from text files without hardcoding them in the sketch. Loading full-resolution images from SD: currently, the Image control stores pixels in the ESP32’s flash memory (PROGMEM), which quickly fills up flash on 4MB chips. With an SD card, you can hold hundreds of full-screen 320×240 (153 KB) or 800×480 (768 KB) BMP pictures or wallpapers and draw them directly to the LCD on demand! The VB.Code as an example: ' Datalogging Sub Sensor1_Reading() SD1.Append "datalog.csv", Sensor1.Value & "," & Sensor2.Value End Sub ' Loading configuration Sub Form_Load() If SD1.Exists("config.txt") Then Label1.Caption = SD1.Read("config.txt") End If End Sub ' Loading pictures onto LCD from SD Sub Button1_Click() SD1.DrawBMP "photo1.bmp", 0, 0 End Sub Non-Visual Toolbox Control (SDCard) Just like Timer, WiFi, and WebServer, you'd drag an SDCard icon onto your project canvas: Properties Inspector: Card Detect / Auto-Mount: True/False (mounts in setup()). CS Pin: read-only default for integrated boards (GPIO 5 on CYD, GPIO 10 on CrowPanel 7"); selectable dropdown for generic ESP32/Pico boards. Status in Run Preview: simulated 16 GB FAT32 card with mock files so you can test code in the browser. Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, I've added an SDCard control to the Toolbox, set up for each of your boards: Cheap Yellow Display: uses its built-in SD slot (CS GPIO 5). CrowPanel 7": uses its built-in SD slot (CS GPIO 10). Plain ESP32, ESP8266 and Pico boards: use a plug-in SD module. You pick its CS pin in Properties (13 on ESP32, GP15 on Pico). The pre-export check flags the pin if something else already uses it. New commands in your code: SDCard1.Append "log.csv", Sensor1.Value adds one line to a file. SDCard1.Write "cfg.txt", "x" replaces a file. SDCard1.Read("cfg.txt") reads a whole file back. SDCard1.Exists(...), SDCard1.Delete "..." and SDCard1.IsReady check, remove and test. The card is ready at start-up, so Form_Load can read saved settings. Nothing extra needs installing. In Run (Simulation), a pretend card stands in for the real one. Click SD files to see what your code wrote. There's also a new Help topic, "SD card: data logs & text files", with a Try in Studio example. All automatic checks pass, but none of this has run on a real board yet. Two boards need extra care: Cheap Yellow Display: its SD slot and touch take turns on the same connection. That's the part most likely to need a fix. CrowPanel Pico: I don't know which pin its SD slot uses, so the check warns you to confirm it from Elecrow's pin chart. Drawing pictures from the card is on the roadmap as still testing the logic! Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, Just added a new feature that allows you to create controls and move your controls in the vb code Private Sub Form1_Load() Button1.Create(40, 100, 120, 45) Button1.Text = "Move me" Label1.Move(40, 30, 220, 30) Label1.Text = "Position from VB" End Sub Private Sub Button1_Click() Button1.Left = Button1.Left + 10 Button1.Top = 100 Button1.Width = 120 Button1.Height = 45 Label1.Text = "Left: " & Button1.Left End Sub this is added to the help guide with 'Try In Studio" Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, A friend of mine just shared his ESP32 Studio project he has been developing. Copy and paste into the studio and hit run to see it in simulation. The text in the buttons are to large, so i decreased to font size 1, ill add a font size command to the vb code soon as this will allow a straight copy and paste into the studio. connect to the esp32 wifi and see the dashboard on your web browser ' ======================================================== ' ESP32 IOT SMART NODE & ACCESS POINT DASHBOARD ' Live switches, telemetry, web mirror & custom HTTP API ' ======================================================== ' WiFi1 Mode: AccessPoint ' WiFi1 SSID: ESP32-IoT-Node ' WiFi1 Password: password123 ' WebServer1 Mode: Both Dim webHits As Integer Dim curTemp As Single Dim curHum As Single Dim heartbeat As Integer ' ===== FORM 1: SMART HOME DASHBOARD ===== Sub Form_Load() ' Top header title & heartbeat LED Label1.Create 10, 6, 220, 20 Label1.Text = "ESP32 IoT Home Node" Label1.ForeColor = vbCyan Shape4.Create 296, 10, 12, 12 Shape4.BackColor = vbGreen ' Wi-Fi AP address banner Label2.Create 10, 26, 300, 16 Label2.Text = "AP: ESP32-IoT-Node | 192.168.4.1" Label2.ForeColor = vbYellow ' Left column: Environmental Telemetry Label3.Create 10, 48, 130, 16 Label3.Text = "ENVIRONMENT" Label3.ForeColor = vbLightGray Gauge1.Create 15, 68, 80, 80 Label4.Create 100, 88, 50, 22 Label4.Text = "24 C" Label4.ForeColor = vbYellow Label5.Create 15, 152, 130, 16 Label5.Text = "Humidity:" ProgressBar1.Create 15, 170, 130, 14 Label6.Create 15, 186, 130, 16 Label6.Text = "55 %" Label6.ForeColor = vbCyan ' Right column: IoT Switches & Relays Label7.Create 160, 48, 145, 16 Label7.Text = "DEVICE RELAYS" Label7.ForeColor = vbLightGray Shape1.Create 160, 72, 12, 12 Shape1.BackColor = vbDarkGray Label8.Create 178, 70, 70, 16 Label8.Text = "Living Light" Toggle1.Create 252, 68, 54, 20 Toggle1.Checked = False Shape2.Create 160, 102, 12, 12 Shape2.BackColor = vbDarkGray Label9.Create 178, 100, 70, 16 Label9.Text = "Ceiling Fan" Toggle2.Create 252, 98, 54, 20 Toggle2.Checked = False Shape3.Create 160, 132, 12, 12 Shape3.BackColor = vbDarkGray Label10.Create 178, 130, 70, 16 Label10.Text = "AC Cooler" Toggle3.Create 252, 128, 54, 20 Toggle3.Checked = False Button1.Create 160, 156, 68, 24 Button1.Text = "All ON" Button1.BackColor = vbNavy Button2.Create 238, 156, 68, 24 Button2.Text = "All OFF" Button2.BackColor = vbRed ' Footer navigation & Web Hit counter Button3.Create 10, 208, 135, 26 Button3.Text = "Web API & Info >" Button3.BackColor = vbDarkGray Label11.Create 160, 212, 145, 18 Label11.Text = "Web Hits: 0" Label11.ForeColor = vbGreen ' Sensors, WiFi, WebServer & 1s Timer Sensor1.Create 10, 235, 20, 5 Sensor2.Create 40, 235, 20, 5 Timer1.Interval = 1000 curTemp = 24 curHum = 55 webHits = 0 heartbeat = 0 End Sub ' ===== FORM 2: SYSTEM DIAGNOSTICS & REST API ===== Sub Form2_Load() Label12.Create 10, 6, 220, 20 Label12.Text = "System & Web API Log" Label12.ForeColor = vbCyan Button4.Create 240, 6, 70, 24 Button4.Text = "< Main" Button4.BackColor = vbDarkGray Label13.Create 15, 34, 290, 16 Label13.Text = "WiFi AP: ESP32-IoT-Node (Pass: password123)" Label13.ForeColor = vbYellow Label14.Create 15, 52, 290, 16 Label14.Text = "Web URL: http://192.168.4.1" Label14.ForeColor = vbWhite Label15.Create 15, 76, 290, 16 Label15.Text = "Custom HTTP Endpoints:" Label15.ForeColor = vbLightGray Label16.Create 15, 94, 290, 16 Label16.Text = "/api/all_on -> Turn all switches ON" Label17.Create 15, 112, 290, 16 Label17.Text = "/api/all_off -> Turn all switches OFF" Label18.Create 15, 130, 290, 16 Label18.Text = "/api/telemetry -> Telemetry status" Label19.Create 15, 156, 290, 20 Label19.Text = "Total Web Requests: 0" Label19.ForeColor = vbGreen Button5.Create 15, 195, 110, 30 Button5.Text = "Reset Hits" Button5.BackColor = vbNavy End Sub ' ===== RELAY SWITCH EVENT HANDLERS ===== Sub Toggle1_Change() If Toggle1.Checked Then Shape1.BackColor = vbYellow Else Shape1.BackColor = vbDarkGray End If End Sub Sub Toggle2_Change() If Toggle2.Checked Then Shape2.BackColor = vbCyan Else Shape2.BackColor = vbDarkGray End If End Sub Sub Toggle3_Change() If Toggle3.Checked Then Shape3.BackColor = vbGreen Else Shape3.BackColor = vbDarkGray End If End Sub ' Master buttons Sub Button1_Click() Toggle1.Checked = True Toggle2.Checked = True Toggle3.Checked = True Shape1.BackColor = vbYellow Shape2.BackColor = vbCyan Shape3.BackColor = vbGreen End Sub Sub Button2_Click() Toggle1.Checked = False Toggle2.Checked = False Toggle3.Checked = False Shape1.BackColor = vbDarkGray Shape2.BackColor = vbDarkGray Shape3.BackColor = vbDarkGray End Sub ' Form navigation Sub Button3_Click() Form2.Show End Sub Sub Button4_Click() Form1.Show End Sub Sub Button5_Click() webHits = 0 Label11.Text = "Web Hits: 0" Label19.Text = "Total Web Requests: 0" End Sub ' Telemetry updates from sensors Sub Sensor1_Change() curTemp = Sensor1.Value Gauge1.Value = curTemp Label4.Text = curTemp & " C" End Sub Sub Sensor2_Change() curHum = Sensor2.Value ProgressBar1.Value = curHum Label6.Text = curHum & " %" End Sub ' Wi-Fi connection state Sub WiFi1_Connected() Label2.Text = "IP: " & WiFi1.IPAddress & " (AP Ready)" End Sub Sub WiFi1_Disconnected() Label2.Text = "Wi-Fi AP offline" End Sub ' Web server request dispatcher Sub WebServer1_Request() webHits = webHits + 1 Label11.Text = "Web Hits: " & webHits Label19.Text = "Total Web Requests: " & webHits If WebServer1.Path = "/api/all_on" Then Button1_Click WebServer1.Send("OK: All ON") ElseIf WebServer1.Path = "/api/all_off" Then Button2_Click WebServer1.Send("OK: All OFF") ElseIf WebServer1.Path = "/api/telemetry" Then WebServer1.Send("temp=" & curTemp & "&hum=" & curHum) ElseIf WebServer1.Path = "/ping" Then WebServer1.Send("PONG") End If End Sub ' Background ticker (heartbeat LED) Sub Timer1_Tick() heartbeat = 1 - heartbeat If heartbeat = 1 Then Shape4.BackColor = vbGreen Else Shape4.BackColor = vbDarkGray End If End Sub Peter ESP32 Visual Studio - link |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, I've now added text font size so for example: Button1.Font =1 Label1.Font =1 Peter |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, For the SD card storage, you can now in vb code make folders, remove them and check file sizes, both in Run and in the exported sketch: Make a folder: SDCard1.CreateDir "logs". You can then write into it, for example SDCard1.Append "logs/day1.csv", text. Remove a folder: SDCard1.RemoveDir "logs". This only works once the folder is empty. It also returns True or False, so you can write If SDCard1.RemoveDir("logs") Then. Check a file's size: SDCard1.FileSize("log.csv") gives the size in bytes, or -1 if the file doesn't exist. You can use it to start a new log file once the current one gets big. ' SD Card Folder & File Size Demonstration ' Demonstrates: CreateDir, RemoveDir, FileSize, Append, Delete, and .Create layout Dim logCount As Long Private Sub Form_Load() ' Auto-position header labels Label1.Create(10, 8, 300, 22) Label2.Create(10, 32, 300, 18) Label3.Create(10, 52, 300, 18) ' 4 action buttons (2x2 grid) Button1.Create(10, 76, 145, 34) Button2.Create(165, 76, 145, 34) Button3.Create(10, 116, 145, 34) Button4.Create(165, 116, 145, 34) ' Progress and file size readouts Label4.Create(10, 158, 300, 18) ProgressBar1.Create(10, 180, 300, 20) Label5.Create(10, 206, 300, 20) ' Small 8px font so button labels fit crisply Button1.Font = 1 Button2.Font = 1 Button3.Font = 1 Button4.Font = 1 Button1.Text = "1. Create /logs" Button2.Text = "2. Append Entry" Button3.Text = "3. Check Size" Button4.Text = "4. Clean Up" ' Highlight Step 1 as ready Button1.BackColor = vbNavy Button2.BackColor = vbDarkGray Button3.BackColor = vbDarkGray Button4.BackColor = vbDarkGray Label1.Text = "SD Folder & Size Demo" Label2.Text = "Status: SD card ready" Label3.Text = "Click [1. Create /logs] to start" Label4.Text = "File size gauge (0 to 100 bytes):" Label5.Text = "Size: 0 bytes" ProgressBar1.Value = 0 End Sub ' --- STEP 1: CREATE DIRECTORY --- Private Sub Button1_Click() If SDCard1.CreateDir("logs") Then Label2.Text = "Created folder: /logs" Label3.Text = "Ready to write into /logs" Button1.BackColor = vbDarkGray Button2.BackColor = vbNavy Else Label2.Text = "Folder /logs already exists" Label3.Text = "Ready to write into /logs" Button2.BackColor = vbNavy End If End Sub ' --- STEP 2: APPEND DATA & CHECK SIZE --- Private Sub Button2_Click() logCount = logCount + 1 SDCard1.Append "logs/sensor.csv", "entry_" + Str(logCount) + ",22.4C,58%" ' Check file size immediately after appending Dim sz As Long sz = SDCard1.FileSize("logs/sensor.csv") Label2.Text = "Appended entry #" + Str(logCount) Label3.Text = "File: /logs/sensor.csv" Label5.Text = "Size: " + Str(sz) + " bytes" ' Update progress bar (0 - 100 bytes) If sz <= 100 Then ProgressBar1.Value = sz Else ProgressBar1.Value = 100 End If Button3.BackColor = vbNavy Button4.BackColor = vbDarkGray End Sub ' --- STEP 3: INSPECT FILE SIZE --- Private Sub Button3_Click() Dim sz As Long sz = SDCard1.FileSize("logs/sensor.csv") If sz >= 0 Then Label2.Text = "logs/sensor.csv verified" Label3.Text = "Actual size: " + Str(sz) + " bytes" Label5.Text = "Size: " + Str(sz) + " bytes" Else Label2.Text = "File not found (-1)" Label3.Text = "logs/sensor.csv does not exist yet" Label5.Text = "Size: -1 (missing)" End If Button4.BackColor = vbNavy End Sub ' --- STEP 4: CLEAN UP FILE & REMOVE DIRECTORY --- Private Sub Button4_Click() ' An SD folder can only be removed once empty: ' 1. Delete the files inside SDCard1.Delete "logs/sensor.csv" ' 2. Remove the empty folder If SDCard1.RemoveDir("logs") Then Label2.Text = "Deleted CSV & removed /logs" Label3.Text = "Directory cleaned up completely" Label5.Text = "Size: 0 bytes (deleted)" ProgressBar1.Value = 0 logCount = 0 ' Reset buttons for another run Button1.BackColor = vbNavy Button2.BackColor = vbDarkGray Button3.BackColor = vbDarkGray Button4.BackColor = vbDarkGray Else Label2.Text = "Could not remove /logs folder" Label3.Text = "Check if files are still inside" End If End Sub Peter |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, I've been working on the task of loading images from the SD card to display in the image control! It is about 300–400 lines of code across the generator, simulator, and preview panel (phew!). I decided the VB syntax. The cleanest design is two complementary commands: Image1.LoadBMP "pic.bmp": loads the BMP into an existing Image control, drawing it at Image1.Left, Image1.Top, clipped/scaled to fit the control box. SDCard1.DrawBMP "bg.bmp", 0, 0: draws a full-screen wallpaper or icon directly to any LCD coordinate (x, y) without needing a pre-placed control. Unit tests covering VB translation, C++ generation across all display drivers, (display engines TFT_eSPI, Adafruit GFX, LovyanGFX, and Arduino_GFX) and simulator decoding have passed, once all done I'll update the studio. The challenge is the esp memory. A 320×240 24-bit BMP is ~230 KB uncompressed. My ESP8266 only has ~40 KB of free RAM, and a standard ESP32 or Pico without PSRAM cannot hold 230 KB in memory at once. Solution — Streaming Line Decoder: We emit a small, self-contained ui_drawBmpSD() helper in C++: Opens the file via SD.open(path, FILE_READ).Verifies the 54-byte header ('BM' signature, width, height, 24-bit uncompressed, bottom-up scan order, and 4-byte row padding). Then allocate a tiny line buffer (e.g. 1 scanline of 320 pixels = 640 bytes of RAM). Reads one row at a time from bottom to top, converts 24-bit BGR to RGB565, and pushes it to the display using tft.pushImage (or drawRGBBitmap on Adafruit GFX). Peter |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, Here is a ready-to-run Visual Basic program for you to test the SD card BMP picture feature. It uses .Create(x, y, w, h) layout commands so when pasted into the VB Code tab, the studio automatically creates Image1, SDCard1, Button1–Button3, and all labels, placing them on a 320×240 canvas. ' ============================================================ ' SD Card BMP Picture Viewer ' Demonstrates: Image.LoadBMP, SDCard.DrawBMP, FileSize, Exists ' ============================================================ Private Sub Form_Load() ' Header readouts Label1.Create(10, 8, 300, 20) Label2.Create(10, 30, 300, 18) ' Left side: Image control box for scaled picture Image1.Create(10, 54, 140, 110) ' Right side: Direct draw area label Label3.Create(165, 54, 145, 18) ' 3 action buttons across the bottom Button1.Create(10, 175, 95, 32) Button2.Create(112, 175, 98, 32) Button3.Create(216, 175, 94, 32) ' Small font so button labels fit neatly Button1.Font = 1 Button2.Font = 1 Button3.Font = 1 Button1.Text = "1. Check File" Button2.Text = "2. Load in Box" Button3.Text = "3. Direct Draw" Button1.BackColor = vbNavy Button2.BackColor = vbDarkGray Button3.BackColor = vbDarkGray Label1.Text = "SD Card BMP Picture Viewer" Label2.Text = "Status: SD ready. Tap [1. Check File]" Label3.Text = "Direct Draw (165, 74):" End Sub ' --- STEP 1: CHECK IF PICTURE IS ON SD --- Private Sub Button1_Click() Dim sz As Long sz = SDCard1.FileSize("picture.bmp") If sz >= 0 Then Label2.Text = "Found picture.bmp: " & Str(sz) & " bytes" Button2.BackColor = vbNavy Button3.BackColor = vbNavy Else Label2.Text = "picture.bmp not found! Upload in Run panel." End If End Sub ' --- STEP 2: LOAD INTO IMAGE CONTROL BOX --- ' Fits and scales the picture into Image1, keeping it for form redraws Private Sub Button2_Click() If SDCard1.Exists("picture.bmp") Then Image1.LoadBMP "picture.bmp" Label2.Text = "Loaded picture.bmp into Image1 box!" Else Label2.Text = "Upload picture.bmp to SD first!" End If End Sub ' --- STEP 3: DIRECT DRAW ONTO LCD SCREEN --- ' Stamps the picture at x=165, y=74 at original pixel size Private Sub Button3_Click() If SDCard1.Exists("picture.bmp") Then SDCard1.DrawBMP "picture.bmp", 165, 74 Label2.Text = "Drawn directly to LCD at (165, 74)!" Else Label2.Text = "Upload picture.bmp to SD first!" End If End Sub How to test it in Run Preview (no hardware needed): Prepare a sample BMP: Open any image in Windows Paint (or GIMP / Photoshop).Optional: resize it to around 100×80 or 120×100 pixels so it fits nicely on screen. Click File → Save As → BMP picture. Under Save as type, choose 24-bit Bitmap (*.bmp) and save it as picture.bmp. Paste into Studio: Go to the VB Code tab and paste the code above. All controls will appear on the canvas in their assigned positions. Run & Upload: Click ▶ Run.Below the LCD screen in the SD files box, click "Upload to SD" and select your picture.bmp (or drag and drop it into the box). Click 1. Check File — it verifies the file and displays its byte size. Click 2. Load in Box — loads and fits the image into the Image1 box. Click 3. Direct Draw — paints the image directly at pixel coordinate (165, 74). Running on physical hardware: Copy picture.bmp to the root directory of a FAT32 microSD card and insert it into your ESP32 / Pico board. Click Export ZIP, open the sketch in Arduino IDE, and upload. Peter |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi, So the last post was to use a streaming decoder method to load a bitmap image from the SD card on an ESP32 or Pico device that has no PSRAM etc. I'm updating it so for devices that have PSRAM that is large enough, i can load the image in one read pass (or read files in 16 KB to 32 KB blocks if PSRAM is not enough) and display it. I don't want the user to be able to select the different methods of loading, so Rather than choosing one or the other, we can make the generated C++ sketch dynamically adapt: At Runtime: Has PSRAM? (psramFound() on ESP32-S3) └── Allocate fast multi-sector buffer in PSRAM for high-speed loading & caching No PSRAM? (Standard ESP32, ESP8266, Pico) └── Use the proven streaming line decoder (low RAM, safe everywhere) Peter ESP32 Visual Studio - link |
||||
| jwettroth Regular Member Joined: 02/08/2011 Location: United StatesPosts: 95 |
Batteryman, This is a nice piece of work. I have played with it in the editor, I will give pushing it to my Elecrow 7" HMI today. A few constructive comments and excuse me if I'm telling you things you know of if some of these are dumb ideas: 1. MMBASIC, Micromite and PICOMite specifically, the main star of this Forum, have similar UI features built in to their MMBASIC natively. Of course, like most of these UI libraries, it can be tedious to design with. I see you support several different graphics libraries and have support for PI Pico. Would it be possible to write a back end that generated MMBASIC code that could run on these 'Mites. The attraction of these devices to many on this forum is they don't require all the complexity of downloading and linking libraries and running through a compiler, etc. Its all built in to MMBASIC. Would it be possible to support these devices using the built in graphics controls. The MMBASIC documentation is very well done, I think a graphics editor would make a nice addition. I could be wrong, but I don't recall such an app for Micro or PICO mites. 2. I love the whole Visual Basic vibe, its a nice way to implement UI code. I still use VB 6.0 occasionally, as I imagine others here do. I am rusty at VB really, are the supported commands documented somewhere (Github?). The basics of taking a property from an object and copying to other objects is straightforward and it the main feature which you have implemented. How hard would it be to have a facility to implement custom controls or add properties to objects? I was playing with a screen and I really wanted to have centered text for example, as-is, I had to cut and try with spaces, etc. Can I extend an object/control somehow? Could I create a new control or could expert third parties provide them ala VB6? 3. I really like the calculator keypad option, my oscilloscope has this feature and I really like it. It seems I often want to input a calc'ed value. I was fooling around with having the keypad pop up in the foreground and hide with a button control. Is this easy? I don't need a full time keypad- just a pop-up. On a related note, would a full qwerty or abc keypad be possible. One the larger screen devices, this would be useful. The Elecrow boards with 5 and 7 inch displays support 800 x 480 which is a lot of real estate. Like many here, I'm an older guy who learned Basic in high school and like it and it perhaps ruined my brain but it makes sense to me. I wrote microcontroller code in assembly and C for work, mainly driver type code to tickle hardware as an applications guy at Maxim. Most of this code was for internal test or for an Eval board, etc. I never fully embraced even C++ and a lot of the more modern languages that have evolved. I've always found it confusing and seems to be addressing problems that I don't have. Even Python, though interpreted and seemingly simple gets obtuse and seems a poor fit for smaller micros. As we get these more sophisticated 32 bit ARM core machines like the PICO and ESP32, this isn't such an issue, but it seems like its unnecessarily complex for what I need. In summary, really nice work. Take the above in the constructive spirit given. John Wettroth |
||||
| Batteryman Newbie Joined: 05/04/2016 Location: United KingdomPosts: 32 |
Hi John, Many thanks for your kind comments (They are very constructive) and for having a go at the LCD Visual Studio Web app. I have used MMBASIC for my homebrew projects and it is the greatest tool for programming the PIC32 MCU's, I even added it to my desktop web app BasicBASIC Visual Design Studio . A good friend of mine has made a weather station with it using the Explorer64 and the SSD1963 parallel touch screen. 1. I shall look into generating MMBASIC code in my transpiler. I would have to have MMBASIC control graphics in the designer and simulator. I can ask permission from Geoff Graham before I am able to do this. 2. Custom control with properties is on the roadmap (even add new property elements to existing controls). These would be saved locally as a property config .cnf & .pty file. 3. Yes, the keypad and keyboard controls have a Keyboard1.Visible = True / False ' Form1 event handlers (Visual Basic) Private Sub Form_Load() End Sub Private Sub Button1_Click() Keyboard1.Visible = False End Sub Private Sub Button2_Click() Keyboard1.Visible = True End Sub If you copy the above into the vb code tab, check the Form1(Design) tab as the buttons maybe sitting on top of each other! I hope this has answered your questions, please feel free to comeback and ask more if it will help you with your projects. Enjoy! Peter |
||||
| Page 1 of 3 |
|||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |