mirror of
https://github.com/arwidcool/Solder-Plate.git
synced 2024-11-12 01:10:52 +01:00
Merge branch 'master' into reflow-in-millis
This commit is contained in:
commit
9f54c7ff26
@ -1,11 +1,157 @@
|
||||
#include "tft.h"
|
||||
|
||||
extern Adafruit_ST7789 tft;
|
||||
// LCD display pins
|
||||
#define TFT_CS 7
|
||||
#define TFT_RST 12
|
||||
#define TFT_DC 14
|
||||
#define MOSI 4 // MOSI
|
||||
#define SCK 6 // SCK
|
||||
// Create an instance of the Adafruit ST7789 class using the custom SPI pins
|
||||
|
||||
TFT::TFT()
|
||||
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST);
|
||||
|
||||
TFT_Display::TFT_Display()
|
||||
{
|
||||
}
|
||||
|
||||
TFT::~TFT()
|
||||
TFT_Display::~TFT_Display()
|
||||
{
|
||||
}
|
||||
|
||||
void TFT_Display::start()
|
||||
{
|
||||
tft.init(240, 320); // Init ST7789 320x240
|
||||
tft.setRotation(1); // Set screen orientation
|
||||
}
|
||||
|
||||
void TFT_Display::init(ReflowProfile *profile)
|
||||
{
|
||||
|
||||
clear();
|
||||
|
||||
tft.setTextColor(ST77XX_WHITE);
|
||||
tft.setTextSize(2);
|
||||
TFT_XY xy = getCenteredTextXY(profile->name);
|
||||
tft.setCursor(xy.x, xy.y);
|
||||
tft.println(profile->name);
|
||||
|
||||
drawGraph();
|
||||
}
|
||||
|
||||
void TFT_Display::clear()
|
||||
{
|
||||
tft.fillScreen(ST77XX_BLACK);
|
||||
}
|
||||
|
||||
TFT_XY TFT_Display::getCenteredTextXY(char *text)
|
||||
{
|
||||
TFT_XY xy;
|
||||
|
||||
uint8_t textLength = strlen(text);
|
||||
int16_t x, y;
|
||||
uint16_t w, h;
|
||||
w = tft.width();
|
||||
h = tft.height();
|
||||
|
||||
tft.getTextBounds(text, 0, 0, &x, &y, &w, &h);
|
||||
|
||||
xy.x = (w - textLength) / 2;
|
||||
xy.y = (h - 1) / 2;
|
||||
|
||||
return xy;
|
||||
}
|
||||
|
||||
TFT_XY TFT_Display::getRightAlignedTextXY(char *text, uint16_t x, uint16_t y)
|
||||
{
|
||||
TFT_XY xy;
|
||||
|
||||
uint8_t textLength = strlen(text);
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
w = tft.width();
|
||||
h = tft.height();
|
||||
|
||||
tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
|
||||
xy.x = x - textLength - 1;
|
||||
xy.y = y;
|
||||
|
||||
return xy;
|
||||
}
|
||||
|
||||
TFT_XY TFT_Display::getLeftAlignedTopTextXY(char *text, uint16_t x, uint16_t y)
|
||||
{
|
||||
TFT_XY xy;
|
||||
|
||||
uint8_t textLength = strlen(text);
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
w = tft.width();
|
||||
h = tft.height();
|
||||
|
||||
tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
|
||||
xy.x = x;
|
||||
xy.y = y - h - 1;
|
||||
|
||||
return xy;
|
||||
}
|
||||
|
||||
void TFT_Display::getMaxTempFromProfile(ReflowProfile *profile)
|
||||
{
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++)
|
||||
{
|
||||
if (profile->steps[i].targetTempAtEnd > maxTemp)
|
||||
{
|
||||
maxTemp = profile->steps[i].targetTempAtEnd;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxTemp < 200)
|
||||
{
|
||||
maxTemp = 200;
|
||||
}
|
||||
else if (maxTemp > 200 && maxTemp < 255)
|
||||
{
|
||||
if (maxTemp + 20 > 255)
|
||||
{
|
||||
maxTemp = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxTemp += 20;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
maxTemp = 255;
|
||||
}
|
||||
}
|
||||
|
||||
TFT_XY TFT_Display::getXYWithinGraphBounds(uint8_t temp, uint8_t time)
|
||||
{
|
||||
|
||||
TFT_XY xy;
|
||||
|
||||
xy.x = graphXY.x + (graphWidth * (time / totalTIme));
|
||||
xy.y = graphXY.y - (graphHeight * ((temp - minTemp) / (maxTemp - minTemp)));
|
||||
|
||||
return xy;
|
||||
}
|
||||
|
||||
void TFT_Display::drawGraph()
|
||||
{
|
||||
|
||||
tft.drawPixel(graphXY.x, graphXY.y, ST77XX_WHITE);
|
||||
|
||||
tft.drawFastHLine(graphXY.x, graphXY.y, graphWidth, ST77XX_WHITE);
|
||||
|
||||
tft.drawFastVLine(graphXY.x, graphXY.y - graphHeight, graphHeight, ST77XX_WHITE);
|
||||
|
||||
tft.setTextColor(ST77XX_WHITE);
|
||||
tft.setTextSize(1);
|
||||
TFT_XY position = getLeftAlignedTopTextXY("20", graphXY.x, graphXY.y);
|
||||
tft.setCursor(position.x, position.y);
|
||||
tft.println("20");
|
||||
}
|
@ -1,21 +1,44 @@
|
||||
#ifndef TFT_H
|
||||
#define TFT_H
|
||||
#ifndef TFT_Display_h
|
||||
#define TFT_Display_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_ST7789.h> // Include the ST7789 library
|
||||
#include <reflow.h>
|
||||
|
||||
class TFT {
|
||||
struct TFT_XY
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class TFT_Display
|
||||
{
|
||||
public:
|
||||
TFT();
|
||||
~TFT();
|
||||
TFT_Display();
|
||||
~TFT_Display();
|
||||
|
||||
void start();
|
||||
// Add your class methods here
|
||||
void init(ReflowProfile *profile);
|
||||
void clear();
|
||||
|
||||
|
||||
private:
|
||||
// Add your private members here
|
||||
TFT_XY getCenteredTextXY(char *text);
|
||||
TFT_XY getRightAlignedTextXY(char *text, uint16_t x, uint16_t y);
|
||||
TFT_XY getLeftAlignedTopTextXY(char *text, uint16_t x, uint16_t y);
|
||||
void getMaxTempFromProfile(ReflowProfile *profile);
|
||||
|
||||
uint8_t graphHeight = 180;
|
||||
uint16_t graphWidth = 256;
|
||||
TFT_XY graphXY = {32, 220};
|
||||
uint16_t maxTemp = 0;
|
||||
uint16_t totalTIme ;
|
||||
uint8_t minTemp = 20;
|
||||
|
||||
TFT_XY getXYWithinGraphBounds(uint8_t temp, uint8_t time);
|
||||
|
||||
void drawGraph();
|
||||
};
|
||||
|
||||
#endif // TFT_H
|
||||
|
@ -59,7 +59,7 @@ ReflowProfile reflowProfiles[] = {
|
||||
ReflowStep(ReflowProcessState::PREHEAT, 120, 35, EASE_OUT),
|
||||
ReflowStep(ReflowProcessState::SOAK, 90, 155),
|
||||
ReflowStep(ReflowProcessState::REFLOW, 45, 185, EASE_OUT),
|
||||
ReflowStep(ReflowProcessState::COOL, 45, 155, EASE_IN),
|
||||
ReflowStep(ReflowProcessState::COOL, 45, 155, EASE_OUT),
|
||||
ReflowStep(ReflowProcessState::DONE, 0, 0)},
|
||||
"138c Sn42Bi58\0"),
|
||||
|
||||
|
38
src/main.cpp
38
src/main.cpp
@ -1,6 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
#include "ArduPID.h"
|
||||
#include <Adafruit_ST7789.h> // Include the ST7789 library
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <voltageReference/AnalogRef.h>
|
||||
#include <Wire.h>
|
||||
@ -9,6 +8,7 @@
|
||||
#include "leds/leds.h"
|
||||
#include "reflow.h"
|
||||
#include "displays/oled.h"
|
||||
#include "displays/tft.h"
|
||||
#include "PID/PidController.h"
|
||||
#include "globals.h"
|
||||
#include "EEPROMDataManager.h"
|
||||
@ -16,17 +16,6 @@
|
||||
|
||||
|
||||
|
||||
// LCD display pins
|
||||
#define TFT_CS 7
|
||||
#define TFT_RST 12
|
||||
#define TFT_DC 14
|
||||
#define MOSI 4 // MOSI
|
||||
#define SCK 6 // SCK
|
||||
// Create an instance of the Adafruit ST7789 class using the custom SPI pins
|
||||
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, MOSI, SCK, TFT_RST);
|
||||
|
||||
|
||||
|
||||
#define MOSTFET_PIN 17
|
||||
|
||||
double currentTemp = 0;
|
||||
@ -39,7 +28,10 @@ LEDS leds = LEDS();
|
||||
ArduPID PID;
|
||||
OledDisplay oled = OledDisplay();
|
||||
|
||||
TemperatureController temperatureController ;
|
||||
TFT_Display tftDisplay ;
|
||||
|
||||
|
||||
TemperatureController temperatureController;
|
||||
|
||||
void setup()
|
||||
{
|
||||
@ -61,6 +53,8 @@ void setup()
|
||||
reflowProcessState.set(ReflowProcessState::USER_INPUT);
|
||||
|
||||
temperatureController.checkPluggedInThermistors();
|
||||
|
||||
tftDisplay.start();
|
||||
}
|
||||
void loop()
|
||||
{
|
||||
@ -89,11 +83,20 @@ void loop()
|
||||
}
|
||||
ReflowProcessState newState = reflowProcessState.get();
|
||||
|
||||
if (newState != state) {
|
||||
if (newState != state)
|
||||
{
|
||||
Serial.println("State changed from " + String(STATE_STR(state)) + " to " + String(STATE_STR(newState)));
|
||||
// State changed from state to newState (user input or wifi input needs to be above here)
|
||||
if (newState == ReflowProcessState::PREHEAT) {
|
||||
|
||||
|
||||
// Initalize the TFT
|
||||
tftDisplay.init(&chosenReflowProfile);
|
||||
|
||||
|
||||
//Start the reflow profile after tft to make sure the timer is accurate
|
||||
chosenReflowProfile.start();
|
||||
// Start the PID
|
||||
pidController.start();
|
||||
}
|
||||
}
|
||||
@ -118,4 +121,11 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
if (state == DONE)
|
||||
{
|
||||
// TODO: BUZZER
|
||||
pidController.stop();
|
||||
reflowProcessState.set(USER_INPUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -185,6 +185,7 @@ public:
|
||||
uint32_t elapsedMS = timer.elapsed();
|
||||
uint16_t startTimeMS = startTimes[STEPINDEX(reflowStep())] * 1000;
|
||||
return (elapsedMS - startTimeMS) / 1000;
|
||||
|
||||
}
|
||||
|
||||
void toBuffer(uint8_t *b)
|
||||
|
Loading…
Reference in New Issue
Block a user