~jacqueline/neon-genesis-ovengeleon

eff1f14b869e7651d6afa9f0d91b0aa55226b119 — jacqueline 2 months ago 9082201
incorporate preheat in graph
1 files changed, 29 insertions(+), 6 deletions(-)

M src/main.cpp
M src/main.cpp => src/main.cpp +29 -6
@@ 7,6 7,7 @@
#include <SPI.h>
#include <LittleFS.h>

#include <cstdint>
#include <sstream>
#include <string>
#include <iostream>


@@ 163,7 164,7 @@ ReflowState reflow_state = PREHEAT;

// Reflow profile
int preheat_temp = 150;
int preheat_duration = 35'000;
int preheat_duration = -1;
int soak_temp = 175;
int soak_duration = 90'000;
int reflow_temp = 249;


@@ 294,13 295,21 @@ void draw_temperature() {
  int x = (320 / 2);
  int y = 240 - HEADER_FOOTER_SIZE + 2;

  uint16_t color_fg = kColorBackground;
  if (current_temp <= TEMPERATURE_WARM) {
    color_fg = kColorText;
  }

  send_config();
  send_text(text, x, y, CENTER, kColorText, current_temp_color);
  send_text(text, x, y, CENTER, color_fg, current_temp_color);
}

void draw_header() {
  uint16_t color_fg = kColorText;
  uint16_t color_fg = kColorBackground;
  uint16_t color_bg = current_temp_color;
  if (current_temp <= TEMPERATURE_WARM) {
    color_fg = kColorText;
  }
  text_bg_color = color_bg;

  send_rect(0, 0, 320, HEADER_FOOTER_SIZE, color_bg);


@@ 360,8 369,11 @@ void draw_header() {
}

void draw_footer() {
  uint16_t color_fg = kColorText;
  uint16_t color_fg = kColorBackground;
  uint16_t color_bg = current_temp_color;
  if (current_temp <= TEMPERATURE_WARM) {
    color_fg = kColorText;
  }
  text_bg_color = color_bg;

  send_rect(0, 240 - HEADER_FOOTER_SIZE, 320, HEADER_FOOTER_SIZE, color_bg);


@@ 404,11 416,13 @@ unsigned long last_temp_time = 0;
void set_elements_state(bool on_or_off) {
  test_elements_state = on_or_off;
  if (on_or_off) {
    digitalWrite(LED_RED, LOW);
#ifndef DEBUG
    digitalWrite(TOP_ELEMENT, HIGH);
    digitalWrite(BOTTOM_ELEMENT, HIGH);
#endif
  } else {
    digitalWrite(LED_RED, HIGH);
    digitalWrite(TOP_ELEMENT, LOW);
    digitalWrite(BOTTOM_ELEMENT, LOW);
  }


@@ 460,7 474,7 @@ void main_menu_setup() {
  if (is_calibrated) {
    send_text("CALIBRATION OK", 320, 220, RIGHT, kColorText, kColorSafeTemp);
  } else {
    send_text("NO CALIBRATION", 320, 220, RIGHT, kColorText, kColorDangerTemp);
    send_text("NO CALIBRATION", 320, 220, RIGHT, kColorBackground, kColorDangerTemp);
  }

  num_items = 2;


@@ 486,6 500,7 @@ void main_menu_loop() {

void calibrate_1_setup() {
  calibrate_1_start_time = millis();
  preheat_duration = -1;

  send_config(2);
  send_print("STAGE 1: HEATING to 240C", 0, 20);


@@ 506,6 521,10 @@ void calibrate_1_loop() {
  set_elements_state(true);

  unsigned long current_time = millis();
  if (current_temp > preheat_temp && preheat_duration == -1) {
    preheat_duration = current_time - calibrate_1_start_time;
  }

  if (current_temp >= 240) {
    calibrate_2_start_time = current_time;
    calibration_lag_degrees = current_temp;


@@ 605,6 624,8 @@ void finished_calibrate_setup() {
  send_print(get_time_string(calibration_cool_lag_time));
  send_print("\nHEAT LAG TIME: ");
  send_print(get_time_string(calibration_heat_lag_time));
  send_print("\nPREHEAT DURATION: ");
  send_print(get_time_string(preheat_duration / 1000));
  send_print("\nLAG DEGREES: ");
  send_print(std::to_string(calibration_lag_degrees));



@@ 616,11 637,12 @@ void finished_calibrate_setup() {
  } else {
    File f = LittleFS.open("CALIBRATION", "w");
    if (!f) {
      digitalWrite(LED_RED, LOW);
      digitalWrite(LED_GREEN, LOW);
    } else {
      f.println(calibration_cool_lag_time);
      f.println(calibration_heat_lag_time);
      f.println(calibration_lag_degrees);
      f.println(preheat_duration);
      f.close();
    }
    LittleFS.end();


@@ 993,6 1015,7 @@ void setup() {
      calibration_cool_lag_time = f.parseInt();
      calibration_heat_lag_time = f.parseInt();
      calibration_lag_degrees = f.parseInt();
      preheat_duration = f.parseInt();
      f.close();
      is_calibrated = true;
    }