/*
ESP32 HTTPClient Jokes API Example
https://wokwi.com/projects/342032431249883731
Copyright (C) 2022, Uri Shaked
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <vector>
#include "point.h"
std::vector<int> V1 = {1,2,3,4,5,6};
std::vector<point> Graph;
int loop_index = 0;
int ECG[] = {-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4,-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4,-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4,-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4,-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4,-4,-3,-3,-2,0,3,8,15,22,27,29,26,20,13,7,3,1,0,-4,-14,-15,42,130,142,36,-20,-22,-5,2,4,5,7,9,13,18,24,30,37,44,48,50,50,47,41,34,27,20,14,10,7,4,3,3,2,2,3,3,3,3,2,1,0,-2,-3,-4};
#define TFT_DC 2
#define TFT_CS 15
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(1);
int origin_x = 0;
int origin_y = tft.height() /2;
loop_index = origin_x;
//for (loop_index; loop_index < tft.width(); loop_index+=5)
for (loop_index; loop_index < sizeof(ECG)/sizeof(int); loop_index++)
Graph.emplace_back(ECG[loop_index], loop_index );
// for(int index = 0; index < Graph.size(); index++)
// {
// Serial.print(Graph[index].get_x());
// Serial.print(" , ");
// Serial.println(Graph[index].get_y());
// }
}
void loop() {
// int cx = tft.width() / 2;
// int cy = tft.height() / 2;
tft.fillScreen(ILI9341_BLACK);
//tft.print("Size of Vector = ");
//tft.print(Graph.size());
Serial.print("Size of Vector = ");
Serial.println(Graph.size());
// tft.drawRect(cx, cy, 50, 50, ILI9341_GREEN);
for(int index = 0; index < Graph.size(); index++)
{
tft.drawLine(Graph[index].get_x(), Graph[index].get_y(), Graph[index+1].get_x(), Graph[index+1].get_y(), ILI9341_GREEN);
}
delay(1000);
}