Display Controllers
The NanoVNA-H firmware supports three LCD display controllers. The appropriate driver is selected at compile time or auto-detected at boot.
Supported Controllers
Section titled “Supported Controllers”| Controller | Display Size | Resolution | Hardware |
|---|---|---|---|
| ILI9341 | 2.8 inch | 320x240 | NanoVNA-H |
| ST7789 | 2.8 inch | 320x240 | NanoVNA-H |
| ST7796S | 4.0 inch | 480x320 | NanoVNA-H4 |
Controller Details
Section titled “Controller Details”ILI9341 (ILITEK)
Section titled “ILI9341 (ILITEK)”The ILI9341 is a 262K color TFT LCD controller commonly used in 2.8” displays.
Specifications:
| Parameter | Value |
|---|---|
| Resolution | 320 x 240 (QVGA) |
| Color Depth | 16-bit (RGB565) |
| Interface | SPI (4-wire) |
| Read Pixel Size | 3 bytes/pixel |
| Max SPI Clock | 10 MHz (read), 50 MHz (write) |
Firmware Configuration:
#define LCD_DRIVER_ILI9341#define LCD_320x240Touch Calibration Defaults:
#define DEFAULT_TOUCH_CONFIG {530, 795, 3460, 3350}ST7789 (Sitronix)
Section titled “ST7789 (Sitronix)”The ST7789 is a pin-compatible alternative to ILI9341 with similar characteristics.
Specifications:
| Parameter | Value |
|---|---|
| Resolution | 320 x 240 |
| Color Depth | 16-bit (RGB565) |
| Interface | SPI (4-wire) |
| Read Pixel Size | 3 bytes/pixel |
| Compatibility | ILI9341 command set (partial) |
Firmware Configuration:
#define LCD_DRIVER_ST7789#define LCD_320x240Auto-Detection:
The firmware can detect ILI9341 vs ST7789 at boot by reading the display ID register. Enable both drivers to allow auto-detection:
#define LCD_DRIVER_ILI9341#define LCD_DRIVER_ST7789ST7796S (Sitronix)
Section titled “ST7796S (Sitronix)”The ST7796S drives the larger 4.0” display on NanoVNA-H4.
Specifications:
| Parameter | Value |
|---|---|
| Resolution | 480 x 320 (HVGA) |
| Color Depth | 16-bit (RGB565) |
| Interface | SPI (4-wire) |
| Read Pixel Size | 2 bytes/pixel |
| Max SPI Clock | 80 MHz |
Firmware Configuration:
#define LCD_DRIVER_ST7796S#define LCD_480x320Touch Calibration Defaults:
#define DEFAULT_TOUCH_CONFIG {380, 665, 3600, 3450}Display Memory Layout
Section titled “Display Memory Layout”Cell-Based Rendering
Section titled “Cell-Based Rendering”The firmware uses a cell-based dirty-region rendering system:
| Parameter | 320x240 | 480x320 |
|---|---|---|
| Cell Width | 32 pixels | 32 pixels |
| Cell Height | 32 pixels | 32 pixels |
| Cells Wide | 10 | 15 |
| Cells High | 8 | 10 |
Frame Buffer
Section titled “Frame Buffer”The display does not use a full frame buffer. Instead:
- A small SPI buffer holds cell data during rendering
- Cells are rendered and transmitted one at a time
- DMA can be used to overlap rendering and transmission
Buffer Size:
// Cell dimensions for 16-bit color#define CELLWIDTH (64/DISPLAY_CELL_BUFFER_COUNT) // 32 pixels#define CELLHEIGHT 32 // 32 pixels#define SPI_BUFFER_SIZE (CELLWIDTH * CELLHEIGHT * DISPLAY_CELL_BUFFER_COUNT)SPI Interface
Section titled “SPI Interface”Pin Connections
Section titled “Pin Connections”| Signal | F072 Pin | F303 Pin | Description |
|---|---|---|---|
| SCLK | PB3 | PB3 | SPI clock |
| MOSI | PB5 | PB5 | Data to display |
| MISO | PB4 | PB4 | Data from display |
| CS | PB6 | PB6 | Chip select |
| DC | PB7 | PB7 | Data/Command |
| RESET | PA15 | PA15 | Hardware reset |
DMA Mode
Section titled “DMA Mode”When __USE_DISPLAY_DMA__ is enabled:
- DMA1 Channel 5 handles SPI TX
- Double buffering allows parallel render/transmit
- Reduces CPU load during display updates
#define __USE_DISPLAY_DMA__#define DISPLAY_CELL_BUFFER_COUNT 2 // Enable double bufferingColor Format
Section titled “Color Format”All controllers use RGB565 format with byte swapping for SPI:
// RGB565 format with byte swap for SPI// Input: R(5), G(6), B(5) in standard order// Output: gggBBBbb RRRrrGGG (byte-swapped for SPI)#define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) )Display Palette
Section titled “Display Palette”The firmware uses a 32-color palette for consistent colors:
| Index | Name | Default Color | Usage |
|---|---|---|---|
| 0 | BG_COLOR | Black | Background |
| 1 | FG_COLOR | White | Foreground text |
| 2 | GRID_COLOR | Gray | Grid lines |
| 3 | MENU_COLOR | Light gray | Menu background |
| 4 | MENU_TEXT_COLOR | Black | Menu text |
| 5 | MENU_ACTIVE_COLOR | Gray | Selected menu item |
| 6-9 | TRACE_1-4_COLOR | Yellow, Cyan, Green, Magenta | Active traces |
| 10-11 | TRACE_5-6_COLOR | Red, Blue | Stored traces |
| 12 | NORMAL_BAT_COLOR | Green | Battery OK |
| 13 | LOW_BAT_COLOR | Red | Battery low |
| 25 | LINK_COLOR | Blue | Menu value text |
Brightness Control
Section titled “Brightness Control”NanoVNA-H4 (F303)
Section titled “NanoVNA-H4 (F303)”The H4 supports adjustable backlight via DAC output:
#define __LCD_BRIGHTNESS__ // Enable brightness menu#define DEFAULT_BRIGHTNESS 70 // 0-100%Controlled via: CONFIG > BRIGHTNESS
NanoVNA-H (F072)
Section titled “NanoVNA-H (F072)”Standard NanoVNA-H does not support brightness control (fixed backlight).
Display Orientation
Section titled “Display Orientation”The display can be flipped 180 degrees:
Menu: CONFIG > EXPERT SETTINGS > FLIP DISPLAY
Shell command: config flip 1
This rotates both the display output and touch coordinates.
Touch Screen
Section titled “Touch Screen”The resistive touch panel uses ADC inputs:
| Signal | F072 Pin | F303 Pin |
|---|---|---|
| XP | PA6 | PA6 |
| YP | PA7 | PA7 |
| XN | PB0 | PB0 |
| YN | PB1 | PB1 |
Touch Calibration
Section titled “Touch Calibration”Calibration stores 4 values: X min, X max, Y min, Y max
Menu: CONFIG > TOUCH CAL
Shell command: touchcal
Font Support
Section titled “Font Support”The firmware includes multiple font sizes:
| Font ID | Size | File | Usage |
|---|---|---|---|
| 0 | 5x7 | Font5x7.c | Smallest |
| 1 | 6x10 | Font6x10.c | Default (320x240) |
| 2 | 7x11 | Font7x11b.c | Default (480x320) |
| 3 | 11x14 | Font11x14.c | Large |
| - | 16x22 | numfont16x22.c | Numeric keypad |
Source Code Reference
Section titled “Source Code Reference”Display driver code is located in:
- LCD driver:
lcd.c - Display defines:
nanovna.hlines 509-618 - Color palette:
nanovna.hlines 1193-1251 - Font data:
fonts/*.c