#include "MultiMap.h"
#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
#include <Wire.h> // this is needed for FT6206
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
#define prnt Serial.println // Short serial print commands
#define prt Serial.print
float floating = 0;
boolean start_calibration = false;
int current_cal_point=0;
int incomingData;
static int change_con=190;
void setup()
{
Serial.begin(115200);
prnt ("start");
tft.init();
tft.drawLine(0, 100, 240, 100, TFT_GREEN);
}
void loop() {
if(Serial.available() > 0) {
incomingData=serial_input();
change_con+=incomingData;
prnt("duty_con: " + (String)change_con);
}
}
// Functions for echoing serial keyboard input, useed for calibration of duty_con
int serial_input(){
incomingData=Serial.parseInt();
prnt("Incoming: " + (String)incomingData);
return incomingData;
}
/* String string_input(){
incomingString=Serial.readString();
prnt("Incoming String: " + (String)incomingString);
return incomingString;
}
*/
void calibration_start(){
prnt("Enter callibration point for X .");
prnt("Current sensor value is: read from the table array here .");
prnt("Default value is:.");
prnt("To stop the callibration press the numbers -321 in the terminal");
//get the input
//check if input correct
if (current_cal_point <=11 && incomingData != -321){
//save_single_entry('X', 2, incomingData);
prnt ("Calibration value for position " + String(current_cal_point) + " was saved");
current_cal_point++; //move to next line
}
if (current_cal_point >11 && incomingData != -321){
prnt("Press -1 if you dont want to update the temperature table.");
// wait for input
if (incomingData != -1){
// call the function to write the temperature
// or make new function to read and write the current temp
// save_raw_temp(1234);
}
// if end of calibration, than end the function
// write all values from the array to the sensor
// if all values already written thn exit with confirmation
prnt("Calibration was successfull");
start_calibration=false;
}
}