From d33566ad16b3ed2c4ae415e2fa86a2490564f134 Mon Sep 17 00:00:00 2001 From: willem Date: Wed, 17 Nov 2021 17:23:31 +0100 Subject: [PATCH] fix: touch and update constants --- .../lib/ft6206_touch/ft6206_touch.cpp | 10 ++-- .../lib/ft6206_touch/ft6206_touch.h | 2 +- reflow_plate_fw/src/controlloop.cpp | 4 +- reflow_plate_fw/src/controlloop.h | 50 +++++++++---------- reflow_plate_fw/src/lcd.cpp | 2 +- reflow_plate_fw/src/lcd.h | 5 +- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.cpp b/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.cpp index 057939c..5fda619 100644 --- a/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.cpp +++ b/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.cpp @@ -19,11 +19,11 @@ FT6206::FT6206() { touches = 0; } /**************************************************************************/ // bool begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD, uint16_t width, uint16_t height, bool flip ); -bool FT6206::begin(uint16_t width, uint16_t height, bool flip, uint8_t thresh) { - Wire.begin(); - _width = width; - _height = height; -_flip = flip; +bool FT6206::begin(uint8_t sda, uint8_t scl, uint16_t width, uint16_t height, bool flip, uint8_t thresh) { + Wire.begin(sda, scl); + _width = width; + _height = height; + _flip = flip; #ifdef FT6206_DEBUG Serial.print("Vend ID: 0x"); Serial.println(readRegister8(FT62XX_REG_VENDID), HEX); diff --git a/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.h b/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.h index cdeaba9..3cd974c 100644 --- a/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.h +++ b/reflow_plate_fw/lib/ft6206_touch/ft6206_touch.h @@ -56,7 +56,7 @@ public: class FT6206 { public: FT6206(void); - bool begin(uint16_t width, uint16_t height, bool flip = false, uint8_t thresh = FT62XX_DEFAULT_THRESHOLD); + bool begin(uint8_t sda, uint8_t scl, uint16_t width, uint16_t height, bool flip = false, uint8_t thresh = FT62XX_DEFAULT_THRESHOLD); uint8_t touched(void); TS_Point getPoint(uint8_t n = 0); diff --git a/reflow_plate_fw/src/controlloop.cpp b/reflow_plate_fw/src/controlloop.cpp index 167e507..bc53746 100644 --- a/reflow_plate_fw/src/controlloop.cpp +++ b/reflow_plate_fw/src/controlloop.cpp @@ -215,7 +215,7 @@ String getReflowState_str(void) return String("Completed"); break; case REFLOW_STATE_TOO_HOT: - return String("OVERHEATING!"); + return String("HOT!"); break; case REFLOW_STATE_ERROR: return String("Error"); @@ -582,7 +582,7 @@ void handleControlLoop() Serial.println("handlecontrolloop: ERROR state"); return; } - getSafetyCheck(); + //getSafetyCheck(); handleTemperatureReadings(); handleReflowStatemachine(); handleReflowPID(); diff --git a/reflow_plate_fw/src/controlloop.h b/reflow_plate_fw/src/controlloop.h index 63989c5..f560fe3 100644 --- a/reflow_plate_fw/src/controlloop.h +++ b/reflow_plate_fw/src/controlloop.h @@ -3,37 +3,35 @@ #include "Arduino.h" // ***** CONSTANTS ***** -#define TEMPERATURE_ROOM 50 +#define TEMPERATURE_ROOM 75 +#define SENSOR_SAMPLING_TIME 1000 +#define DEBOUNCE_PERIOD_MIN 50 + +// ***** PARAMETERS ***** +// ***** PRE-HEAT STAGE ***** +#define PID_KP_PREHEAT 100 +#define PID_KI_PREHEAT 0.025 +#define PID_KD_PREHEAT 20 +#define PREHEAT_PERIOD 20000 +// ***** SOAKING STAGE ***** +#define PID_KP_SOAK 300 +#define PID_KI_SOAK 0.05 +#define PID_KD_SOAK 250 #define TEMPERATURE_SOAK_MIN 150 #define TEMPERATURE_SOAK_MAX 185 -#define TEMPERATURE_REFLOW_MAX 220 -#define TEMPERATURE_COOL_MIN 100 -#define SENSOR_SAMPLING_TIME 1000 #define SOAK_TEMPERATURE_STEP 5 #define SOAK_MICRO_PERIOD 9000 -#define DEBOUNCE_PERIOD_MIN 50 -#define PREHEAT_PERIOD 12000 -#define REFLOW_PERIOD 12000 -#define COOLDOWN_PERIOD 30000 - -// ***** PID PARAMETERS ***** -// ***** PRE-HEAT STAGE ***** -#define PID_KP_PREHEAT 100 -#define PID_KI_PREHEAT 0.025 -#define PID_KD_PREHEAT 20 -// ***** SOAKING STAGE ***** -#define PID_KP_SOAK 300 -#define PID_KI_SOAK 0.05 -#define PID_KD_SOAK 250 // ***** REFLOW STAGE ***** -#define PID_KP_REFLOW 300 -#define PID_KI_REFLOW 0.05 -#define PID_KD_REFLOW 350 -#define PID_SAMPLE_TIME 1000 -// This is for testing on different board -// #define LCD_PIN 14 -// #define ODROID - +#define PID_KP_REFLOW 300 +#define PID_KI_REFLOW 0.05 +#define PID_KD_REFLOW 350 +#define TEMPERATURE_REFLOW_MAX 220 +#define REFLOW_PERIOD 30000 +// ***** COOLING STAGE ***** +#define COOLDOWN_PERIOD 180000 +#define TEMPERATURE_COOL_MIN 100 +//PID settings +#define PID_SAMPLE_TIME 1000 // ***** TYPE DEFINITIONS ***** typedef enum REFLOW_STATE diff --git a/reflow_plate_fw/src/lcd.cpp b/reflow_plate_fw/src/lcd.cpp index 0574471..af3389e 100644 --- a/reflow_plate_fw/src/lcd.cpp +++ b/reflow_plate_fw/src/lcd.cpp @@ -358,7 +358,7 @@ void updateGUIButtons(void) void initTouchScreen(void) { //ts.begin(); - if (!ts.begin(tft.width(), tft.height(), true, 40)) + if (!ts.begin(TOUCH_SDA, TOUCH_SCL, tft.width(), tft.height(), true, 40)) { Serial.println("Unable to start touchscreen."); } diff --git a/reflow_plate_fw/src/lcd.h b/reflow_plate_fw/src/lcd.h index 6610b76..c2d11cb 100644 --- a/reflow_plate_fw/src/lcd.h +++ b/reflow_plate_fw/src/lcd.h @@ -28,10 +28,10 @@ #define CHART_H 200 #define CHART_FONT 1 -#define CHART_TIME_MAX 140 //time scale in seconds +#define CHART_TIME_MAX 500 //time scale in seconds #define CHART_TEMP_MIN 20 //offset in degrees #define CHART_TEMP_MAX 240 //degrees -#define CHART_Y_TICKS 10 +#define CHART_Y_TICKS 10 #define CHART_X_TICKS 7 #define CHART_LINE_COLOR TFT_WHITE #define CHART_TEXT_COLOR TFT_RED @@ -39,7 +39,6 @@ #define CHART_ACTUAL_COLOR TFT_RED #define CHART_BG_COLOR TFT_BLACK - #define STATE_X 0 #define STATE_Y 13 #define STATE_W TFT_WIDTH