Skip to content

Display Controllers

The NanoVNA-H firmware supports three LCD display controllers. The appropriate driver is selected at compile time or auto-detected at boot.

ControllerDisplay SizeResolutionHardware
ILI93412.8 inch320x240NanoVNA-H
ST77892.8 inch320x240NanoVNA-H
ST7796S4.0 inch480x320NanoVNA-H4

The ILI9341 is a 262K color TFT LCD controller commonly used in 2.8” displays.

Specifications:

ParameterValue
Resolution320 x 240 (QVGA)
Color Depth16-bit (RGB565)
InterfaceSPI (4-wire)
Read Pixel Size3 bytes/pixel
Max SPI Clock10 MHz (read), 50 MHz (write)

Firmware Configuration:

#define LCD_DRIVER_ILI9341
#define LCD_320x240

Touch Calibration Defaults:

#define DEFAULT_TOUCH_CONFIG {530, 795, 3460, 3350}

The firmware uses a cell-based dirty-region rendering system:

Parameter320x240480x320
Cell Width32 pixels32 pixels
Cell Height32 pixels32 pixels
Cells Wide1015
Cells High810

The display does not use a full frame buffer. Instead:

  1. A small SPI buffer holds cell data during rendering
  2. Cells are rendered and transmitted one at a time
  3. 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)
SignalF072 PinF303 PinDescription
SCLKPB3PB3SPI clock
MOSIPB5PB5Data to display
MISOPB4PB4Data from display
CSPB6PB6Chip select
DCPB7PB7Data/Command
RESETPA15PA15Hardware reset

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 buffering

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) )

The firmware uses a 32-color palette for consistent colors:

IndexNameDefault ColorUsage
0BG_COLORBlackBackground
1FG_COLORWhiteForeground text
2GRID_COLORGrayGrid lines
3MENU_COLORLight grayMenu background
4MENU_TEXT_COLORBlackMenu text
5MENU_ACTIVE_COLORGraySelected menu item
6-9TRACE_1-4_COLORYellow, Cyan, Green, MagentaActive traces
10-11TRACE_5-6_COLORRed, BlueStored traces
12NORMAL_BAT_COLORGreenBattery OK
13LOW_BAT_COLORRedBattery low
25LINK_COLORBlueMenu value text

The H4 supports adjustable backlight via DAC output:

#define __LCD_BRIGHTNESS__ // Enable brightness menu
#define DEFAULT_BRIGHTNESS 70 // 0-100%

Controlled via: CONFIG > BRIGHTNESS

Standard NanoVNA-H does not support brightness control (fixed backlight).

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.

The resistive touch panel uses ADC inputs:

SignalF072 PinF303 Pin
XPPA6PA6
YPPA7PA7
XNPB0PB0
YNPB1PB1

Calibration stores 4 values: X min, X max, Y min, Y max

Menu: CONFIG > TOUCH CAL

Shell command: touchcal

The firmware includes multiple font sizes:

Font IDSizeFileUsage
05x7Font5x7.cSmallest
16x10Font6x10.cDefault (320x240)
27x11Font7x11b.cDefault (480x320)
311x14Font11x14.cLarge
-16x22numfont16x22.cNumeric keypad

Display driver code is located in:

  • LCD driver: lcd.c
  • Display defines: nanovna.h lines 509-618
  • Color palette: nanovna.h lines 1193-1251
  • Font data: fonts/*.c