mirror of
https://github.com/arwidcool/Solder-Plate.git
synced 2024-12-01 01:27:17 +01:00
stuff
This commit is contained in:
parent
0aac756d7e
commit
b91e4cee1f
@ -12,13 +12,14 @@ void EEPROMDataManager::setup()
|
|||||||
saveToEEPROM();
|
saveToEEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
// THermistors part. for now we let the user set the thermistor values in code.
|
||||||
{
|
|
||||||
uint16_t resUint;
|
// for (int i = 0; i < 6; i++)
|
||||||
EEPROM.get(2 * i + EEPROM_START_TERMISTORS, resUint);
|
// {
|
||||||
float res = resUint / 1000.0;
|
// uint16_t resUint;
|
||||||
thermistors[i].setPotentiometerResistance(res);
|
// EEPROM.get(2 * i + EEPROM_START_TERMISTORS, resUint);
|
||||||
}
|
// thermistors[i].setPotentiometerResistance(resUint);
|
||||||
|
// }
|
||||||
|
|
||||||
EEPROM.get(EEPROM_START_PLATERES, plateResistanceOhm);
|
EEPROM.get(EEPROM_START_PLATERES, plateResistanceOhm);
|
||||||
}
|
}
|
||||||
@ -26,14 +27,15 @@ void EEPROMDataManager::saveToEEPROM()
|
|||||||
{
|
{
|
||||||
EEPROM.begin();
|
EEPROM.begin();
|
||||||
uint16_t tmp = 0x1234;
|
uint16_t tmp = 0x1234;
|
||||||
EEPROM.put(0, &tmp); // initialize the EEPROM
|
EEPROM.put(0, tmp); // initialize the EEPROM
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
// THermistors part. for now we dont save the thermistor values in code.
|
||||||
{
|
|
||||||
float res = thermistors[i].getResistance();
|
|
||||||
uint16_t resUint = res * 1000;
|
|
||||||
EEPROM.put(2 * i + EEPROM_START_TERMISTORS, &resUint);
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.put(EEPROM_START_PLATERES, &plateResistanceOhm);
|
// for (int i = 0; i < 6; i++)
|
||||||
|
// {
|
||||||
|
// uint16_t res = thermistors[i].getPotentiometerResistance();
|
||||||
|
// EEPROM.put(2 * i + EEPROM_START_TERMISTORS, res);
|
||||||
|
// }
|
||||||
|
|
||||||
|
EEPROM.put(EEPROM_START_PLATERES, plateResistanceOhm);
|
||||||
}
|
}
|
@ -4,115 +4,131 @@
|
|||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class OledMenuItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OledMenuItem(){};
|
||||||
|
OledMenuItem(char *title) : title(title), identifier(0){};
|
||||||
|
OledMenuItem(char *title, uint8_t identifier) : title(title), identifier(identifier){};
|
||||||
|
|
||||||
class OledMenuItem {
|
char const *title;
|
||||||
public:
|
// Identifier c
|
||||||
OledMenuItem(){};
|
uint8_t identifier;
|
||||||
OledMenuItem(char *title): title(title), identifier(0) {};
|
|
||||||
OledMenuItem(char *title, uint8_t identifier): title(title), identifier(identifier) {};
|
|
||||||
|
|
||||||
char const * title;
|
|
||||||
// Identifier c
|
|
||||||
uint8_t identifier;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OledMenu {
|
class OledMenu
|
||||||
public:
|
{
|
||||||
OledMenu(){};
|
public:
|
||||||
OledMenu(uint8_t identifier): identifier(identifier), elementsLength(0), childrenLength(0) {};
|
OledMenu(){};
|
||||||
~OledMenu() {
|
OledMenu(uint8_t identifier) : identifier(identifier), elementsLength(0), childrenLength(0){};
|
||||||
delete elements;
|
~OledMenu()
|
||||||
delete children;
|
{
|
||||||
delete childrenMatrix;
|
delete elements;
|
||||||
};
|
delete children;
|
||||||
uint8_t identifier;
|
delete childrenMatrix;
|
||||||
|
};
|
||||||
|
uint8_t identifier;
|
||||||
|
|
||||||
void setChildren(OledMenu **children, int length) {
|
void setChildren(OledMenu **children, int length)
|
||||||
this->children = children;
|
{
|
||||||
this->childrenLength = length;
|
this->children = children;
|
||||||
for (int i=0; i<length; i++) {
|
this->childrenLength = length;
|
||||||
children[i]->parent = this;
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
children[i]->parent = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setElements(OledMenuItem *elements, int length)
|
||||||
|
{
|
||||||
|
this->elements = new OledMenuItem[length];
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
this->elements[i].title = malloc(strlen(elements[i].title) + 1);
|
||||||
|
memcpy(this->elements[i].title, elements[i].title, strlen(elements[i].title) + 1);
|
||||||
|
this->elements[i].identifier = elements[i].identifier;
|
||||||
|
|
||||||
|
Serial.println(String(this->elements[i].title) + " " + String(elements[i].title));
|
||||||
|
}
|
||||||
|
this->elementsLength = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setChildrenMatrix(int length, uint8_t (*matrix)[2])
|
||||||
|
{
|
||||||
|
this->childrenMatrix = matrix;
|
||||||
|
this->childrenMatrixLength = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To be invoked when the user presses the SELECT btn
|
||||||
|
// If null is returned then the menu should not be changed
|
||||||
|
OledMenu *getNextMenu()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < childrenMatrixLength; i++)
|
||||||
|
{
|
||||||
|
if (childrenMatrix[i][0] == curItem)
|
||||||
|
{
|
||||||
|
return children[childrenMatrix[i][1]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void setElements(OledMenuItem *elements, int length) {
|
// To be invoked when the user presses the UP btn
|
||||||
this->elements = new OledMenuItem[length];
|
OledMenuItem goNextItem()
|
||||||
|
{
|
||||||
|
curItem++;
|
||||||
|
curItem = curItem % elementsLength;
|
||||||
|
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
||||||
|
return elements[curItem];
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<length; i++) {
|
// To be invoked when the user presses the DOWN btn
|
||||||
this->elements[i].title = malloc(strlen(elements[i].title) + 1);
|
OledMenuItem goPrevItem()
|
||||||
memcpy(this->elements[i].title, elements[i].title, strlen(elements[i].title) + 1);
|
{
|
||||||
this->elements[i].identifier = elements[i].identifier;
|
curItem--;
|
||||||
|
if (curItem < 0)
|
||||||
Serial.println(String(this->elements[i].title) + " " + String(elements[i].title));
|
{
|
||||||
}
|
curItem = elementsLength - 1;
|
||||||
this->elementsLength = length;
|
|
||||||
}
|
}
|
||||||
|
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
||||||
|
|
||||||
void setChildrenMatrix(int length, uint8_t (*matrix)[2]) {
|
return elements[curItem];
|
||||||
this->childrenMatrix = matrix;
|
}
|
||||||
this->childrenMatrixLength = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be invoked when the user presses the SELECT btn
|
OledMenuItem itemAt(uint8_t index)
|
||||||
// If null is returned then the menu should not be changed
|
{
|
||||||
OledMenu *getNextMenu() {
|
return elements[index];
|
||||||
for (int i=0; i<childrenMatrixLength; i++) {
|
}
|
||||||
if (childrenMatrix[i][0] == curItem) {
|
|
||||||
return children[childrenMatrix[i][1]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be invoked when the user presses the UP btn
|
OledMenuItem getCurItem()
|
||||||
OledMenuItem goNextItem() {
|
{
|
||||||
curItem++;
|
return elements[curItem];
|
||||||
curItem = curItem % elementsLength;
|
}
|
||||||
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
|
||||||
return elements[curItem];
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be invoked when the user presses the DOWN btn
|
|
||||||
OledMenuItem goPrevItem() {
|
|
||||||
curItem--;
|
|
||||||
if (curItem < 0) {
|
|
||||||
curItem = elementsLength - 1;
|
|
||||||
}
|
|
||||||
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
|
||||||
|
|
||||||
return elements[curItem];
|
|
||||||
}
|
|
||||||
|
|
||||||
OledMenuItem getCurItem() {
|
|
||||||
return elements[curItem];
|
|
||||||
}
|
|
||||||
|
|
||||||
OledMenu *parent;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int curItem = 0;
|
|
||||||
OledMenuItem *elements;
|
|
||||||
int elementsLength;
|
|
||||||
OledMenu **children;
|
|
||||||
int childrenLength;
|
|
||||||
/**
|
|
||||||
* Matrix of pairs of (element index, children index)
|
|
||||||
* ex if element at index 0 should go to children at index 1 when user hits SELECT
|
|
||||||
* then the matrix would be:
|
|
||||||
* { ..., {0, 1}, ...}
|
|
||||||
*/
|
|
||||||
uint8_t (*childrenMatrix)[2]; // First is element index, second is children index,
|
|
||||||
int childrenMatrixLength;
|
|
||||||
|
|
||||||
|
OledMenu *parent;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int curItem = 0;
|
||||||
|
OledMenuItem *elements;
|
||||||
|
int elementsLength;
|
||||||
|
OledMenu **children;
|
||||||
|
int childrenLength;
|
||||||
|
/**
|
||||||
|
* Matrix of pairs of (element index, children index)
|
||||||
|
* ex if element at index 0 should go to children at index 1 when user hits SELECT
|
||||||
|
* then the matrix would be:
|
||||||
|
* { ..., {0, 1}, ...}
|
||||||
|
*/
|
||||||
|
uint8_t (*childrenMatrix)[2]; // First is element index, second is children index,
|
||||||
|
int childrenMatrixLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETMATRIX(menuItem, CODE) { Pair<ButtonKind,int> matrix[] = { CODE }; menuItem.setMatrix( sizeof(matrix)/sizeof(matrix[0]), matrix); }
|
#define SETMATRIX(menuItem, CODE) \
|
||||||
|
{ \
|
||||||
|
Pair<ButtonKind, int> matrix[] = {CODE}; \
|
||||||
|
menuItem.setMatrix(sizeof(matrix) / sizeof(matrix[0]), matrix); \
|
||||||
|
}
|
||||||
#define UPBUTTON(index) Pair<ButtonKind, int>(ButtonKind::UP, index),
|
#define UPBUTTON(index) Pair<ButtonKind, int>(ButtonKind::UP, index),
|
||||||
#define DOWNBUTTON(index) Pair<ButtonKind, int>(ButtonKind::DOWN, index),
|
#define DOWNBUTTON(index) Pair<ButtonKind, int>(ButtonKind::DOWN, index),
|
||||||
#define SELECTBUTTON(index) Pair<ButtonKind, int>(ButtonKind::SELECT, index),
|
#define SELECTBUTTON(index) Pair<ButtonKind, int>(ButtonKind::SELECT, index),
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define SCREEN_WIDTH 128
|
#define SCREEN_WIDTH 128
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 64
|
||||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||||
#define MENUID_PLATERES 2
|
#define MENUID_DEBUG 2
|
||||||
#define MENUITEM_THERMISTOR_START 150
|
#define MENUITEM_THERMISTOR_START 150
|
||||||
|
|
||||||
unsigned long lastProcessedReflowState = 0;
|
unsigned long lastProcessedReflowState = 0;
|
||||||
@ -17,41 +17,82 @@ OledDisplay::OledDisplay()
|
|||||||
|
|
||||||
void OledDisplay::handleButtonStateChange(Pair<ButtonKind, StateChangeEvent<ButtonState>> change)
|
void OledDisplay::handleButtonStateChange(Pair<ButtonKind, StateChangeEvent<ButtonState>> change)
|
||||||
{
|
{
|
||||||
if (change.second.to == ButtonState::PRESSED)
|
ReflowProcessState state = reflowProcessState.get();
|
||||||
|
if (state == USER_INPUT)
|
||||||
{
|
{
|
||||||
if (change.first == ButtonKind::SELECT)
|
if (change.second.to == ButtonState::PRESSED)
|
||||||
{
|
{
|
||||||
OledMenu *selectedMenu = curMenu->getNextMenu();
|
if (change.first == ButtonKind::SELECT)
|
||||||
if (selectedMenu != NULL)
|
|
||||||
{
|
{
|
||||||
curMenu = selectedMenu;
|
OledMenu *selectedMenu = curMenu->getNextMenu();
|
||||||
|
if (selectedMenu != NULL)
|
||||||
|
{
|
||||||
|
curMenu = selectedMenu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (change.first == ButtonKind::BACK)
|
||||||
else if (change.first == ButtonKind::BACK)
|
|
||||||
{
|
|
||||||
OledMenu *selectedMenu = curMenu->parent;
|
|
||||||
if (selectedMenu != NULL)
|
|
||||||
{
|
{
|
||||||
curMenu = selectedMenu;
|
OledMenu *selectedMenu = curMenu->parent;
|
||||||
|
if (selectedMenu != NULL)
|
||||||
|
{
|
||||||
|
curMenu = selectedMenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (change.first == ButtonKind::UP)
|
||||||
|
{
|
||||||
|
curMenu->goPrevItem();
|
||||||
|
}
|
||||||
|
else if (change.first == ButtonKind::DOWN)
|
||||||
|
{
|
||||||
|
curMenu->goNextItem();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (change.first == ButtonKind::UP)
|
|
||||||
{
|
|
||||||
curMenu->goNextItem();
|
|
||||||
}
|
|
||||||
else if (change.first == ButtonKind::DOWN)
|
|
||||||
{
|
|
||||||
curMenu->goPrevItem();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OledDisplay::handleDrawThermistorMenu(OledMenuItem menuItem)
|
||||||
|
{
|
||||||
|
int thermistorIndex = menuItem.identifier - MENUITEM_THERMISTOR_START;
|
||||||
|
if (thermistorIndex == 6)
|
||||||
|
{
|
||||||
|
// Showing all thermistors values in a row
|
||||||
|
display.setTextSize(1, 2);
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
int thermistorTemp = thermistors[i].getTemperature();
|
||||||
|
display.setCursor(i < 3 ? 0 : (SCREEN_WIDTH / 2 + 20), 20 * (i % 3));
|
||||||
|
display.println(String(i + 1) + " " + String(thermistorTemp));
|
||||||
|
}
|
||||||
|
centerText(menuItem.title);
|
||||||
|
displayIndicators();
|
||||||
|
}
|
||||||
|
else if (thermistorIndex == 7)
|
||||||
|
{
|
||||||
|
display.setTextSize(1, 2);
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
float thermR = thermistors[i].getResistance();
|
||||||
|
display.setCursor(i < 3 ? 0 : (SCREEN_WIDTH / 2 + 20), 20 * (i % 3));
|
||||||
|
display.println(String(i + 1) + " " + String((int)(thermR)));
|
||||||
|
}
|
||||||
|
centerText(menuItem.title);
|
||||||
|
displayIndicators();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int thermistorTemp = thermistors[thermistorIndex].getTemperature();
|
||||||
|
centerText((String(menuItem.title) + ": " + String(thermistorTemp)).c_str());
|
||||||
|
displayIndicators();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OledDisplay::setup()
|
void OledDisplay::setup()
|
||||||
{
|
{
|
||||||
curMenu = new OledMenu();
|
curMenu = new OledMenu();
|
||||||
curMenu->setElements(new OledMenuItem[3]{
|
curMenu->setElements(new OledMenuItem[3]{
|
||||||
OledMenuItem("Reflow\0"),
|
OledMenuItem("Reflow\0"),
|
||||||
OledMenuItem("PlateR\0"),
|
|
||||||
OledMenuItem("Temps\0"),
|
OledMenuItem("Temps\0"),
|
||||||
|
OledMenuItem("Debug\0"),
|
||||||
},
|
},
|
||||||
3);
|
3);
|
||||||
|
|
||||||
@ -63,10 +104,11 @@ void OledDisplay::setup()
|
|||||||
}
|
}
|
||||||
pickProfilesMenu->setElements(pickProfilesMenuItems, nReflowProfiles);
|
pickProfilesMenu->setElements(pickProfilesMenuItems, nReflowProfiles);
|
||||||
|
|
||||||
OledMenu *plateRMenu = new OledMenu(MENUID_PLATERES);
|
OledMenu *debugMenu = new OledMenu(MENUID_DEBUG);
|
||||||
OledMenu *tempsMenu = new OledMenu(3);
|
OledMenu *tempsMenu = new OledMenu(3);
|
||||||
tempsMenu->setElements(new OledMenuItem[7]{
|
tempsMenu->setElements(new OledMenuItem[8]{
|
||||||
OledMenuItem("ALL\0", MENUITEM_THERMISTOR_START + 6),
|
OledMenuItem("C\0", MENUITEM_THERMISTOR_START + 6),
|
||||||
|
OledMenuItem("R\0", MENUITEM_THERMISTOR_START + 7),
|
||||||
OledMenuItem("T1\0", MENUITEM_THERMISTOR_START + 0),
|
OledMenuItem("T1\0", MENUITEM_THERMISTOR_START + 0),
|
||||||
OledMenuItem("T2\0", MENUITEM_THERMISTOR_START + 1),
|
OledMenuItem("T2\0", MENUITEM_THERMISTOR_START + 1),
|
||||||
OledMenuItem("T3\0", MENUITEM_THERMISTOR_START + 2),
|
OledMenuItem("T3\0", MENUITEM_THERMISTOR_START + 2),
|
||||||
@ -74,14 +116,14 @@ void OledDisplay::setup()
|
|||||||
OledMenuItem("T5\0", MENUITEM_THERMISTOR_START + 4),
|
OledMenuItem("T5\0", MENUITEM_THERMISTOR_START + 4),
|
||||||
OledMenuItem("T6\0", MENUITEM_THERMISTOR_START + 5),
|
OledMenuItem("T6\0", MENUITEM_THERMISTOR_START + 5),
|
||||||
},
|
},
|
||||||
6);
|
8);
|
||||||
|
|
||||||
curMenu->setChildren(
|
curMenu->setChildren(
|
||||||
new OledMenu *[3]
|
new OledMenu *[3]
|
||||||
{
|
{
|
||||||
pickProfilesMenu,
|
pickProfilesMenu,
|
||||||
plateRMenu,
|
|
||||||
tempsMenu,
|
tempsMenu,
|
||||||
|
debugMenu,
|
||||||
},
|
},
|
||||||
3);
|
3);
|
||||||
curMenu->setChildrenMatrix(3, new uint8_t[3][2]{
|
curMenu->setChildrenMatrix(3, new uint8_t[3][2]{
|
||||||
@ -112,38 +154,11 @@ void OledDisplay::loop()
|
|||||||
ReflowProcessState state = reflowProcessState.get();
|
ReflowProcessState state = reflowProcessState.get();
|
||||||
if (state == USER_INPUT)
|
if (state == USER_INPUT)
|
||||||
{
|
{
|
||||||
display.clearDisplay();
|
handleUserInputState();
|
||||||
display.setRotation(0);
|
}
|
||||||
display.setTextSize(2);
|
else if (state >= REFLOW && state <= DONE)
|
||||||
|
{
|
||||||
OledMenuItem menuItem = curMenu->getCurItem();
|
handleReflowState();
|
||||||
display.setTextSize(2);
|
|
||||||
if (menuItem.identifier >= MENUITEM_THERMISTOR_START && menuItem.identifier < MENUITEM_THERMISTOR_START + 7)
|
|
||||||
{
|
|
||||||
int thermistorIndex = menuItem.identifier - MENUITEM_THERMISTOR_START;
|
|
||||||
if (thermistorIndex == 6) {
|
|
||||||
// Showing all
|
|
||||||
} else {
|
|
||||||
int thermistorTemp = thermistors[thermistorIndex].getTemperature();
|
|
||||||
centerText((String(menuItem.title) + ": " + String(thermistorTemp)).c_str());
|
|
||||||
displayIndicators();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (curMenu->identifier == MENUID_PLATERES)
|
|
||||||
{
|
|
||||||
// TODO: Logic for plate resistance
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
// draw menu item with selectors.
|
|
||||||
|
|
||||||
centerText(menuItem.title);
|
|
||||||
displayIndicators();
|
|
||||||
}
|
|
||||||
|
|
||||||
display.display();
|
|
||||||
}
|
}
|
||||||
// Loop implementation
|
// Loop implementation
|
||||||
}
|
}
|
||||||
@ -171,6 +186,7 @@ void OledDisplay::drawDebug()
|
|||||||
}
|
}
|
||||||
void OledDisplay::displayIndicators()
|
void OledDisplay::displayIndicators()
|
||||||
{
|
{
|
||||||
|
display.setTextSize(2);
|
||||||
display.setRotation(1);
|
display.setRotation(1);
|
||||||
display.setCursor(0, SCREEN_WIDTH / 2 - 5);
|
display.setCursor(0, SCREEN_WIDTH / 2 - 5);
|
||||||
display.print("<");
|
display.print("<");
|
||||||
@ -190,16 +206,33 @@ void OledDisplay::centerText(const char *txt)
|
|||||||
void OledDisplay::handleUserInputState()
|
void OledDisplay::handleUserInputState()
|
||||||
{
|
{
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, SCREEN_HEIGHT / 2 + 10);
|
display.setRotation(0);
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
|
|
||||||
display.display();
|
OledMenuItem menuItem = curMenu->getCurItem();
|
||||||
|
display.setTextSize(2);
|
||||||
|
// THERMISTORS
|
||||||
|
if (menuItem.identifier >= MENUITEM_THERMISTOR_START && menuItem.identifier < MENUITEM_THERMISTOR_START + 8)
|
||||||
|
{
|
||||||
|
handleDrawThermistorMenu(menuItem);
|
||||||
|
}
|
||||||
|
else if (curMenu->identifier == MENUID_DEBUG)
|
||||||
|
{
|
||||||
|
drawDebug();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Default menu handling. Just display the title and the indicators to go back and forth
|
||||||
|
centerText(menuItem.title);
|
||||||
|
displayIndicators();
|
||||||
|
display.display();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void OledDisplay::handleReflowState()
|
void OledDisplay::handleReflowState()
|
||||||
{
|
{
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
|
ReflowProcessState state = reflowProcessState.get();
|
||||||
display.println("REFLOW");
|
centerText(STATE_STR(state));
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class OledDisplay {
|
|||||||
|
|
||||||
void centerText(const char * text);
|
void centerText(const char * text);
|
||||||
void displayIndicators();
|
void displayIndicators();
|
||||||
|
void handleDrawThermistorMenu(OledMenuItem item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ AnalogRef analogRef(5.0);
|
|||||||
TempCalibration calibration_100K_3950 = {25, 100000, 86, 10000, 170, 1000};
|
TempCalibration calibration_100K_3950 = {25, 100000, 86, 10000, 170, 1000};
|
||||||
// Initalize the 3950 100K thermistors with ACTUAL reference resistor measurnment(Measured between Left pin and GND when the board is powered off) using the default calibration data for 100K thermistor
|
// Initalize the 3950 100K thermistors with ACTUAL reference resistor measurnment(Measured between Left pin and GND when the board is powered off) using the default calibration data for 100K thermistor
|
||||||
Thermistor thermistor1(THERMISTOR1_PIN, 2500);
|
Thermistor thermistor1(THERMISTOR1_PIN, 2500);
|
||||||
Thermistor thermistor2(THERMISTOR2_PIN, 2500);
|
Thermistor thermistor2(THERMISTOR2_PIN, 1111);
|
||||||
Thermistor thermistor3(THERMISTOR3_PIN, 2500);
|
Thermistor thermistor3(THERMISTOR3_PIN, 2500);
|
||||||
Thermistor thermistor4(THERMISTOR4_PIN, 2500);
|
Thermistor thermistor4(THERMISTOR4_PIN, 2500);
|
||||||
Thermistor thermistor5(THERMISTOR5_PIN, 2500);
|
Thermistor thermistor5(THERMISTOR5_PIN, 2500);
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include "Thermistor.h"
|
#include "Thermistor.h"
|
||||||
|
|
||||||
|
|
||||||
void Thermistor::setPotentiometerResistance(float resistance)
|
|
||||||
{
|
|
||||||
setRes = resistance;
|
|
||||||
calculateCoefficents(resistance, calibration);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Thermistor::getTemperature()
|
int Thermistor::getTemperature()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,7 +20,7 @@ int Thermistor::getTemperature()
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thermistor::calculateCoefficents(float resistance, TempCalibration calibration)
|
void Thermistor::calculateCoefficents(TempCalibration calibration)
|
||||||
{
|
{
|
||||||
|
|
||||||
float lowK = calibration.lowC + K;
|
float lowK = calibration.lowC + K;
|
||||||
|
@ -41,27 +41,27 @@ public:
|
|||||||
// Constructor
|
// Constructor
|
||||||
Thermistor();
|
Thermistor();
|
||||||
|
|
||||||
Thermistor(uint8_t pin, float resistance, TempCalibration calibration): thermistorPin(pin), setRes(resistance), calibration(calibration) {
|
Thermistor(uint8_t pin, uint16_t resistance, TempCalibration calibration): thermistorPin(pin), setRes(resistance), calibration(calibration) {
|
||||||
calculateCoefficents(resistance, calibration);
|
calculateCoefficents(calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thermistor(uint8_t pin, float resistance): thermistorPin(pin), setRes(resistance), calibration(calibration_100K_3950) {
|
Thermistor(uint8_t pin, uint16_t resistance): thermistorPin(pin), setRes(resistance), calibration(calibration_100K_3950) {
|
||||||
calculateCoefficents(resistance, calibration);
|
calculateCoefficents(calibration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public Methods
|
// Public Methods
|
||||||
int getTemperature();
|
int getTemperature();
|
||||||
float getResistance();
|
float getResistance();
|
||||||
void setPotentiometerResistance(float resistance);
|
void setPotentiometerResistance(uint16_t resistance) { setRes = resistance; };
|
||||||
|
uint16_t getPotentiometerResistance() { return setRes; };
|
||||||
// Public Variables
|
// Public Variables
|
||||||
void calculateCoefficents(float resistance, TempCalibration calibration);
|
void calculateCoefficents(TempCalibration calibration);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double K = 273.15;
|
const double K = 273.15;
|
||||||
float sensorResistance;
|
float sensorResistance;
|
||||||
uint8_t thermistorPin;
|
uint8_t thermistorPin;
|
||||||
float setRes;
|
uint16_t setRes;
|
||||||
Coefficents coefficents;
|
Coefficents coefficents;
|
||||||
float referenceResistance;
|
float referenceResistance;
|
||||||
TempCalibration calibration;
|
TempCalibration calibration;
|
||||||
|
Loading…
Reference in New Issue
Block a user