diff --git a/reflow_plate_fw/.vscode/tasks.json b/reflow_plate_fw/.vscode/tasks.json new file mode 100644 index 0000000..b234000 --- /dev/null +++ b/reflow_plate_fw/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "PlatformIO", + "task": "Build", + "problemMatcher": [ + "$platformio" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "PlatformIO: Build" + } + ] +} \ No newline at end of file diff --git a/reflow_plate_fw/include/Setup202_SSD1351_128.h b/reflow_plate_fw/include/Setup202_SSD1351_128.h index 7b74204..48d2b7c 100644 --- a/reflow_plate_fw/include/Setup202_SSD1351_128.h +++ b/reflow_plate_fw/include/Setup202_SSD1351_128.h @@ -2,7 +2,6 @@ #define SSD1351_DRIVER - #define TFT_WIDTH 128 #define TFT_HEIGHT 128 @@ -11,19 +10,6 @@ #define SSD1351_1DOT5_INCH_128 // For 128 x 128 display -// Wiring: -// +-------------+------------+-------------------------------------------------------------------+ -// | Display PCB | TFT_eSPI | Info | -// +-------------+------------+-------------------------------------------------------------------+ -// | GND | GND (0V) | Common | -// | VCC | 5V or 3.3V | Better to power with 5V if display PCB supports it | -// | DIN | TFT_MOSI | SPI data | -// | SCK | TFT_SCLK | SPI clock | -// | DC | TFT_DC | Distinguish between a command or its data | -// | RST | TFT_RST | Hardware reset, can connect to MCU RST pin as well | -// | CS | TFT_CS | Chip select, Set to -1 if for manually use with multiple displays | -// +-------------+------------+-------------------------------------------------------------------+ - //#define TFT_MOSI PA7 //#define TFT_SCLK PA5 #define TFT_DC PB1 diff --git a/reflow_plate_fw/platformio.ini b/reflow_plate_fw/platformio.ini index 0784a53..170cda3 100644 --- a/reflow_plate_fw/platformio.ini +++ b/reflow_plate_fw/platformio.ini @@ -19,4 +19,7 @@ lib_deps = bodmer/TFT_eSPI@^2.3.70 lib_ldf_mode = deep+ build_flags = + -D USER_SETUP_LOADED=1 + -include include/Setup202_SSD1351_128.h + diff --git a/reflow_plate_fw/src/lcd.cpp b/reflow_plate_fw/src/lcd.cpp index eac1f81..750664d 100644 --- a/reflow_plate_fw/src/lcd.cpp +++ b/reflow_plate_fw/src/lcd.cpp @@ -1,22 +1,7 @@ #include "lcd.h" +#include "thermo.h" - -// void initLCD(void) -// { - -// } - -// void handleLCD(void) -// { - - -// } - -unsigned int rainbow(byte value); - -#include // Include the graphics library - TFT_eSPI tft = TFT_eSPI(); // Create object "tft" // ------------------------------------------------------------------------- @@ -24,10 +9,28 @@ TFT_eSPI tft = TFT_eSPI(); // Create object "tft" // ------------------------------------------------------------------------- void initLCD(void) { tft.init(); - tft.setRotation(0); - tft.setTextFont(1); + tft.setTextFont(2); tft.fillScreen(TFT_BLACK); tft.invertDisplay(false); + //tft.setTextColor(TFT_WHITE); + tft.setRotation(0); + + +} + +String showValue(String designator, float value, String unit) +{ + String text; + //text.clear(); + if (designator != "") + { + text = designator; + text += " "; + } + text += value; + text += " "; + text += unit; + return text; } // ------------------------------------------------------------------------- @@ -35,7 +38,5 @@ void initLCD(void) { // ------------------------------------------------------------------------- void handleLCD() { - //tft.setTextColor(TFT_WHITE); - //tft.setTextPadding(60); - tft.drawString("hello World!", 10, 10); + tft.drawString(showValue("Temp", getTemperature(), "grC"), 10, 10); } \ No newline at end of file diff --git a/reflow_plate_fw/src/lcd.h b/reflow_plate_fw/src/lcd.h index c571ae2..6aefcb8 100644 --- a/reflow_plate_fw/src/lcd.h +++ b/reflow_plate_fw/src/lcd.h @@ -1,6 +1,8 @@ #include "Arduino.h" #include "board.h" +#include "Setup202_SSD1351_128.h" +#include // Include the graphics library void initLCD(void); diff --git a/reflow_plate_fw/src/thermo.cpp b/reflow_plate_fw/src/thermo.cpp index 7af83c7..2381490 100644 --- a/reflow_plate_fw/src/thermo.cpp +++ b/reflow_plate_fw/src/thermo.cpp @@ -1,12 +1,46 @@ #include "thermo.h" +Thermocouple* thermocouple = NULL; -void initThermo(void) -{ +// the setup function runs once when you press reset or power the board +void initThermo() { + Thermocouple* originThermocouple = new MAX6675_Thermocouple(THERM_CL, THERM_CS, THERM_SO); + thermocouple = new AverageThermocouple( + originThermocouple, + READINGS_NUMBER, + DELAY_TIME + ); + + /* OR + thermocouple = new AverageThermocouple( + new MAX6675_Thermocouple(SCK_PIN, CS_PIN, SO_PIN), + READINGS_NUMBER, + DELAY_TIME + ); + */ } -void handleThermo(void) -{ +// the loop function runs over and over again forever +void handleThermo(void) { + // Reads temperature + const double celsius = thermocouple->readCelsius(); + const double kelvin = thermocouple->readKelvin(); + const double fahrenheit = thermocouple->readFahrenheit(); -} \ No newline at end of file + // Output of information + Serial.print("Temperature: "); + Serial.print(celsius); + Serial.print(" C, "); + Serial.print(kelvin); + Serial.print(" K, "); + Serial.print(fahrenheit); + Serial.println(" F"); + + delay(100); // optionally, only to delay the output of information in the example. +} + +double getTemperature(void) +{ + return thermocouple->readCelsius(); +} diff --git a/reflow_plate_fw/src/thermo.h b/reflow_plate_fw/src/thermo.h index d285d1f..2b7c492 100644 --- a/reflow_plate_fw/src/thermo.h +++ b/reflow_plate_fw/src/thermo.h @@ -2,6 +2,26 @@ #include "Arduino.h" #include "board.h" +#include +#include +#include + + + + +/** + How many readings are taken to determine a mean temperature. + The more values, the longer a calibration is performed, + but the readings will be more accurate. +*/ +#define READINGS_NUMBER 10 + +/** + Delay time between a temperature readings + from the temperature sensor (ms). +*/ +#define DELAY_TIME 10 void initThermo(void); -void handleThermo(void); \ No newline at end of file +void handleThermo(void); +double getTemperature(void);