Hi all
I am trying to get the following code to work
It is a basic plotter for a value on a TFT screen
The code is modified from this post Graph a single line from analog read in a TFT
All I get on the screen is the text and vert line to the left
#include <Adafruit_GFX.h> // Hardware-specific library
#include <Adafruit_ST7796S.h>
#define display_CS 10
#define display_RST 8
#define display_DC 9
#define display_MOSI 11
#define display_CLK 13
Adafruit_ST7796S display(display_CS, display_DC, display_MOSI, display_CLK, display_RST);
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int xPos = 0, xPosPrev = 0;
int n = 0;
int graphHeightPrev = 0;
int16_t ht = 16, top = 3, line, lines = 15, scroll;
void setup() {
Serial.begin(9600);
Serial.print("Oih !");
display.init(320, 480, 0, 0, ST7796S_BGR); //screen size 74 x 284
display.invertDisplay(1);
display.fillScreen(BLACK);
display.setRotation(1);
display.setTextColor(WHITE);
display.setCursor(80, 100);
display.setTextSize(3);
display.println("T.I.S.M"); // mum, we are serious. google it
delay(10);
}
void loop() {
int sensor = random(200); // for testing
//int graphHeight = map(sensor, 410, 614, 0, display.height());
int graphHeight = map(sensor, 205, 307, 0, display.height());
display.drawLine(xPosPrev, display.height() - graphHeightPrev, xPos, display.height() - graphHeight, WHITE);
graphHeightPrev = graphHeight;
if (xPos >= 480) {
xPos = 20;
xPosPrev = 20;
display.fillScreen(BLACK);
display.drawLine(20, 60, 20, 260, WHITE);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(30, 50);
display.print("value");
display.setCursor(30, 260);
display.print("value");
}
else {
xPosPrev = xPos;
xPos++;
}
delay(16);
}


