void readKlixon(){
  if (digitalRead(klixon) == false) {
    statusMessage(4);
    //setAlert = true;
  }
}

void tempControl(int pos){
  oldtempMeas = tempMeas; //Serial.print(Setpoint); Serial.print("    "); Serial.println(tempMeas);
  tempMeas = maxthermo.readThermocoupleTemperature();
  //tempMeas = 20.5;
  delay(10);
  fault = maxthermo.readFault();
  if (fault) {
    //thermocoupleErrors(fault);
  } else {
    if(scrNr == 3){
      placeValue(0, pos+4, 3, 0, oldtempMeas, tempMeas);   
      outbar(int(Output/65.0), 139, 64);
    } else {
      placeValue(0, pos, 3, 0, oldtempMeas, tempMeas);    
      outbar(int(Output/40.95), 83, 102);
    }
  }
  Input = tempMeas;
  myPID.Compute();
  analogWrite(heat, Output);
  Serial.println(analogRead(heat));
}

void processTime(){
  oldtimeCounter0 = timeCounter0;
  timeCounter0++;
  if (timeCounter0 <= timeValue0){
    placeValue(0, POSX[1][3]+1, 3, 0, oldtimeCounter0, timeCounter0);                 //place actual procestime on screen
  } else {
    enter1Pos = 0;
    placeValue(0, POSX[1][3]+1, 3, 0, oldtimeCounter0, 0);
    changeMode(oldenter1Pos, enter1Pos);
    enter1Pos0();
    enter1Pos3(); //STOP
  }
}

void redrawCurve(){
  curveScreen();
  for( int i=0;i<lastx;i++){
    if(bacTemp[i]>0) oled.drawCircle(i+22, bacTemp[i], 1, SSD1322_WHITE);
    if(bacPoints[i]>0) oled.drawCircle(i+22, bacPoints[i], 2, SSD1322_WHITE);
  }
}
void processTimeC(){
  oldtimeCounter1 = timeCounter1;
  timeCounter1++;
  if (timeCounter1 <= timeValue1){
    int x = 22+(timeCounter1/curvetimescale)*210;
    int y = 60-(tempMeas/curvetempscale)*38;
    oled.drawCircle(x, y, 1, SSD1322_WHITE);
    lastx = x - 22; bacTemp[lastx] = y;
    if (timeCounter1 == CURVES[curveNr1][pointcnt][1]) {
      int x = 22+(CURVES[curveNr1][pointcnt][1]/curvetimescale)*210;
      int y = 60-(CURVES[curveNr1][pointcnt][0]/curvetempscale)*38;
      oled.drawCircle(x, y, 2, SSD1322_WHITE);
      bacPoints[x-22] = y;

      pointcnt++;
      oldSetpoint = Setpoint;
      Setpoint = CURVES[curveNr1][pointcnt][0];
      placeValue(0, POSX[1][2] -2, 3, 0, oldSetpoint, Setpoint);   

    }
    placeValue(0, POSX[1][3]+1, 3, 0, oldtimeCounter1, timeCounter1);                 //place actual procestime on screen
  } else {
    enter1Pos = 0;
    changeMode(oldenter1Pos, enter1Pos);
    enter3Pos0();
    enter3Pos3(); //STOP
  }
}
