How to work around blinking display when with SPI tft display
i playing using spi tft display little project displays data.
i'm using adafruit libraries
i've wired fast display find have how erase previous data displayed before updating it. @ first did clear screen with
before showing new data (text rotated)
but blinking awful
then tried drawing black rectange on area of text with
and it's tiny bit better. there must better way. can't wonder if it's overall structure of code real issue.
here's full code
i'm using adafruit libraries
code: [select]
#include <adafruit_gfx.h> // core graphics library
#include <adafruit_st7735.h> // hardware-specific library
i've wired fast display find have how erase previous data displayed before updating it. @ first did clear screen with
code: [select]
tft.fillscreen(st7735_black);
before showing new data (text rotated)
but blinking awful
then tried drawing black rectange on area of text with
code: [select]
tft.fillrect(0, 30, 200, 60, st7735_black);
and it's tiny bit better. there must better way. can't wonder if it's overall structure of code real issue.
here's full code
code: [select]
#define cs 10
#define dc 9
#define rst 8 // can connect arduino reset
#define trigger_pin 7 // arduino pin tied trigger pin on ultrasonic sensor.
#define echo_pin 6 // arduino pin tied echo pin on ultrasonic sensor.
#define max_distance 600 // maximum distance want ping (in centimeters). maximum sensor distance rated @ 400-500cm.
#include <adafruit_gfx.h> // core graphics library
#include <adafruit_st7735.h> // hardware-specific library
#include <spi.h>
#include <newping.h>
//#include <stdio.h>
newping sonar(trigger_pin, echo_pin, max_distance);
#if defined(__sam3x8e__)
#undef __flashstringhelper::f(string_literal)
#define f(string_literal) string_literal
#endif
adafruit_st7735 tft = adafruit_st7735(cs, dc, rst);
void setup(void){
serial.begin(115200);
tft.initr(initr_blacktab);
tft.settextwrap(false); // allow text run off right edge
tft.fillscreen(st7735_black);
tft.setrotation(1);
}
void loop(void) {
int totalping=0; // wait 50ms between pings (about 20 pings/sec). 29ms should shortest delay between pings.
unsigned int us;
(int i=0;i<=4;i++){
= sonar.ping(); // send ping, ping time in microseconds (us).
serial.print("reading");
serial.print(i);
serial.print(":");
serial.println(us/us_roundtrip_in);
totalping=totalping+us;
delay(30);
}
tft.fillrect(0, 30, 200, 60, st7735_black);
us=totalping/5;
int r;
int f;
int i;
int remainder;
tft.settextsize(1);
tft.setcursor(0,100);
tft.print("rangefinder v 0.1");
tft.settextcolor(st7735_yellow);
tft.settextsize(6);
tft.setcursor(0, 30);
r=us/us_roundtrip_in;
serial.println(r);
remainder=r%12;
f=(r-remainder)/12;
tft.print(f); // convert ping time distance in cm , print result (0 = outside set distance range)
tft.print(":");
tft.print(remainder);
//delay(50);
}
Arduino Forum > Using Arduino > Displays > How to work around blinking display when with SPI tft display
arduino
Comments
Post a Comment