Experimental project to drive a TFT LCD with an AVR MCU and avr-libc

@Torsten Römer Torsten Römer authored on 17 May 2024
GitHub committed on 17 May 2024
cats Improve scripts 2 years ago
emojis Display next image on touch event (#10) 1 year ago
nbproject Read BMP images from SD card (#8) 2 years ago
scripts Display next image on touch event (#10) 1 year ago
.gitignore Project setup 2 years ago
CODE_OF_CONDUCT.md Initial commit 2 years ago
LICENSE Initial commit 2 years ago
Makefile Read BMP images from SD card (#8) 2 years ago
README.md Add info on image conversion to README.md 2 years ago
avrtft.c Display next image on touch event (#10) 1 year ago
bitmaps.c Initial implementation of touch screen (#7) 2 years ago
bitmaps.h Initial implementation of touch screen (#7) 2 years ago
bmp.c Display next image on touch event (#10) 1 year ago
bmp.h Display next image on touch event (#10) 1 year ago
cmd.c Read BMP images from SD card 2 years ago
cmd.h Read BMP images from SD card (#8) 2 years ago
display.c Initial implementation of touch screen (#7) 2 years ago
display.h Initial implementation of touch screen (#7) 2 years ago
emojis.c Display next image on touch event (#10) 1 year ago
emojis.h Use font for emojis instead of bitmaps (#3) 2 years ago
font.c Initial commit 2 years ago
font.h Add emojis 🙂 (#2) 2 years ago
hack.c Use font for emojis instead of bitmaps (#3) 2 years ago
hack.h basics are working 2 years ago
i2c.c Initial implementation of touch screen (#7) 2 years ago
i2c.h Initial implementation of touch screen (#7) 2 years ago
paint.c Just some cleanup/fix rounding 2 years ago
paint.h Initial implementation of touch screen (#7) 2 years ago
pins.h Read BMP images from SD card (#8) 2 years ago
sdcard.c Display next image on touch event (#10) 1 year ago
sdcard.h Display next image on touch event (#10) 1 year ago
spi.c Read BMP images from SD card (#8) 2 years ago
spi.h Read BMP images from SD card (#8) 2 years ago
tft.c Cosmetics 2 years ago
tft.h Initial implementation of touch screen (#7) 2 years ago
touch.c Just some cleanup 2 years ago
touch.h Initial implementation of touch screen (#7) 2 years ago
types.h Display next image on touch event (#10) 1 year ago
usart.c Read BMP images from SD card (#8) 2 years ago
usart.h Initial implementation of touch screen (#7) 2 years ago
utils.h Initial commit 2 years ago
README.md

AVRTFT

Experimental project to drive a TFT LCD with an AVR MCU (ATmega328P) and avr-libc.

Currently supported displays/drivers:

Currently implemented features:

  • Mostly complete UTF-8 set (code points U+0000 to U+00FF) of Hack font
    with antialiasing (4-Bit greyscale)
  • Some emojis (16-Bit RGB)
  • Write text in Hack including emojis 🙂
  • Draw bitmaps
  • Write text and bitmaps via USART
  • Upload BMP images via USART (16-Bit 5/6/5 RGB)
  • Basic SD card support: read and write blocks of 512 bytes
  • Read BMP images from SD card (raw)
  • Process touch events (FT6206)
  • Very basic paint application
  • Logging via USART

Ideas:

  • Make features usable from a touch screen menu

IMG_20231125_011054

Write something via USART

Connect to the controller with for example GTKTerm (38400 Baud).
Write some text and a bitmap, and upload a BMP image:

c 0xffff // clear display
d // display the demo
t 0 0 Just some text // write text in Hack to row 0 column 0
b 0 0 1 // write bitmap with index 1 (tiny Linus cat) to row 0 column 0
p 0 0 // prepare to "stream" a 16-Bit (5/6/5) RGB BMP image to row 0 column 0
cat Bali160x128.bmp > /dev/ttyUSB0 // upload a BMP image
s 0 // read BMP image from SD card starting at address 0 (to row 0 column 0)
a // start paint application

Enter emojis

Emojis are entered with a tabulation char + their "code", i.e. Smile!<TAB>s for a smiling emoji.

IMG_20231129_004922

Convert and write images to SD card

Without any file system, to write any number of pictures with a specific
resolution as 16-Bit (5/6/5) RGB BMP image files:

  1. Convert pictures with ImageMagick 'convert' and pad them to a multiple of
    512 bytes

     for i in *.jpg; do convert $i -scale 320x240 -define bmp:subtype=RGB565 $i.bmp; truncate -s 154112 $i.bmp; echo $i; done
  2. Concatenate the images to a single file

     for i in *.bmp; do cat $i >> sdcard.img; echo $i; done
  3. Write the images raw to SD card (danger zone!)

     sudo dd if=sdcard.img of=/dev/mmcblk0 bs=512

Now the images can be read one by one from SD card with an address offset of 301.

Paint application

A super basic paint application created to learn about processing touch events
and draw something on the screen.

The FT6206 based touch screen of the
Adafruit 2.8" Color TFT LCD with Cap Touch 320x240 ILI9341
works quite well but at least for me the coordinates of touches close to the
long edges of the screen are a bit off (too close to the edge) and there seems
to be no calibration capability - the data sheet mentions "auto calibration".

But still it is fun and it should be possible to create an application
supporting touch with reliable usability.

IMG_20240103_134738