TFT Screen 2.2" only using a small part of its screen...
the adafruit tft screen (full name 2.2" 320x240 tft breakout) seems working fine except fact not using full 320x240 display... don't have aspect ratios in code i'm not sure issue... far displaying image micro sd card top right of screen... please help.
--edit--
// include necessary libraries
#include <spi.h>
#include <sd.h>
#include <tft.h> // arduino lcd library
// pin definition uno
#define sd_cs 4
#define lcd_cs 10
#define dc 9
#define rst 8
// pin definition leonardo
//#define sd_cs 8
//#define lcd_cs 7
//#define dc 0
//#define rst 1
tft tftscreen = tft(lcd_cs, dc, rst);
// variable represents image drawn on screen
pimage logo;
void setup() {
// initialize glcd , show message
// asking user open serial line
tftscreen.begin();
tftscreen.background(255, 255, 255);
tftscreen.stroke(0, 0, 255);
tftscreen.println();
tftscreen.println(f("arduino tft bitmap example"));
tftscreen.stroke(0, 0, 0);
tftscreen.println(f("open serial monitor"));
tftscreen.println(f("to run sketch"));
// initialize serial port: used to
// print diagnostic info
serial.begin(9600);
while (!serial) {
// wait serial port connect. needed native usb port only
}
// clear glcd screen before starting
tftscreen.background(255, 255, 255);
// try access sd card. if fails (e.g.
// no card present), setup process stop.
serial.print(f("initializing sd card..."));
if (!sd.begin(sd_cs)) {
serial.println(f("failed!"));
return;
}
serial.println(f("ok!"));
// initialize , clear glcd screen
tftscreen.begin();
tftscreen.background(255, 255, 255);
// sd card can access, try load the
// image file.
logo = tftscreen.loadimage("miniwoof.bmp");
if (!logo.isvalid()) {
serial.println(f("error while loading miniwoof.bmp"));
}
}
void loop() {
// don't if image wasn't loaded correctly.
if (logo.isvalid() == false) {
return;
}
serial.println(f("drawing image"));
// random location draw image.
// avoid image draw outside screen,
// take account image size.
int x = random(tftscreen.width() - logo.width());
int y = random(tftscreen.height() - logo.height());
// draw image screen
tftscreen.image(logo, x, y);
// wait little bit before drawing again
delay(1500);
}
--edit--
// include necessary libraries
#include <spi.h>
#include <sd.h>
#include <tft.h> // arduino lcd library
// pin definition uno
#define sd_cs 4
#define lcd_cs 10
#define dc 9
#define rst 8
// pin definition leonardo
//#define sd_cs 8
//#define lcd_cs 7
//#define dc 0
//#define rst 1
tft tftscreen = tft(lcd_cs, dc, rst);
// variable represents image drawn on screen
pimage logo;
void setup() {
// initialize glcd , show message
// asking user open serial line
tftscreen.begin();
tftscreen.background(255, 255, 255);
tftscreen.stroke(0, 0, 255);
tftscreen.println();
tftscreen.println(f("arduino tft bitmap example"));
tftscreen.stroke(0, 0, 0);
tftscreen.println(f("open serial monitor"));
tftscreen.println(f("to run sketch"));
// initialize serial port: used to
// print diagnostic info
serial.begin(9600);
while (!serial) {
// wait serial port connect. needed native usb port only
}
// clear glcd screen before starting
tftscreen.background(255, 255, 255);
// try access sd card. if fails (e.g.
// no card present), setup process stop.
serial.print(f("initializing sd card..."));
if (!sd.begin(sd_cs)) {
serial.println(f("failed!"));
return;
}
serial.println(f("ok!"));
// initialize , clear glcd screen
tftscreen.begin();
tftscreen.background(255, 255, 255);
// sd card can access, try load the
// image file.
logo = tftscreen.loadimage("miniwoof.bmp");
if (!logo.isvalid()) {
serial.println(f("error while loading miniwoof.bmp"));
}
}
void loop() {
// don't if image wasn't loaded correctly.
if (logo.isvalid() == false) {
return;
}
serial.println(f("drawing image"));
// random location draw image.
// avoid image draw outside screen,
// take account image size.
int x = random(tftscreen.width() - logo.width());
int y = random(tftscreen.height() - logo.height());
// draw image screen
tftscreen.image(logo, x, y);
// wait little bit before drawing again
delay(1500);
}
just run through library examples. you hang of new display.
you can edit name of bmp file display. e.g. "miniwoof.bmp" "woof.bmp".
this full size image.
the adafruit library works fine. there several other compatible libraries available.
david.
you can edit name of bmp file display. e.g. "miniwoof.bmp" "woof.bmp".
this full size image.
the adafruit library works fine. there several other compatible libraries available.
david.
Arduino Forum > Using Arduino > Displays > TFT Screen 2.2" only using a small part of its screen...
arduino
Comments
Post a Comment