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,8 +4,8 @@
|
|||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class OledMenuItem
|
||||||
class OledMenuItem {
|
{
|
||||||
public:
|
public:
|
||||||
OledMenuItem(){};
|
OledMenuItem(){};
|
||||||
OledMenuItem(char *title) : title(title), identifier(0){};
|
OledMenuItem(char *title) : title(title), identifier(0){};
|
||||||
@ -14,34 +14,37 @@ class OledMenuItem {
|
|||||||
char const *title;
|
char const *title;
|
||||||
// Identifier c
|
// Identifier c
|
||||||
uint8_t identifier;
|
uint8_t identifier;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OledMenu {
|
class OledMenu
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
OledMenu(){};
|
OledMenu(){};
|
||||||
OledMenu(uint8_t identifier) : identifier(identifier), elementsLength(0), childrenLength(0){};
|
OledMenu(uint8_t identifier) : identifier(identifier), elementsLength(0), childrenLength(0){};
|
||||||
~OledMenu() {
|
~OledMenu()
|
||||||
|
{
|
||||||
delete elements;
|
delete elements;
|
||||||
delete children;
|
delete children;
|
||||||
delete childrenMatrix;
|
delete childrenMatrix;
|
||||||
};
|
};
|
||||||
uint8_t identifier;
|
uint8_t identifier;
|
||||||
|
|
||||||
void setChildren(OledMenu **children, int length) {
|
void setChildren(OledMenu **children, int length)
|
||||||
|
{
|
||||||
this->children = children;
|
this->children = children;
|
||||||
this->childrenLength = length;
|
this->childrenLength = length;
|
||||||
for (int i=0; i<length; i++) {
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
children[i]->parent = this;
|
children[i]->parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setElements(OledMenuItem *elements, int length) {
|
void setElements(OledMenuItem *elements, int length)
|
||||||
|
{
|
||||||
this->elements = new OledMenuItem[length];
|
this->elements = new OledMenuItem[length];
|
||||||
|
|
||||||
for (int i=0; i<length; i++) {
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
this->elements[i].title = malloc(strlen(elements[i].title) + 1);
|
this->elements[i].title = malloc(strlen(elements[i].title) + 1);
|
||||||
memcpy(this->elements[i].title, elements[i].title, 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;
|
this->elements[i].identifier = elements[i].identifier;
|
||||||
@ -51,16 +54,20 @@ class OledMenu {
|
|||||||
this->elementsLength = length;
|
this->elementsLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setChildrenMatrix(int length, uint8_t (*matrix)[2]) {
|
void setChildrenMatrix(int length, uint8_t (*matrix)[2])
|
||||||
|
{
|
||||||
this->childrenMatrix = matrix;
|
this->childrenMatrix = matrix;
|
||||||
this->childrenMatrixLength = length;
|
this->childrenMatrixLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be invoked when the user presses the SELECT btn
|
// To be invoked when the user presses the SELECT btn
|
||||||
// If null is returned then the menu should not be changed
|
// If null is returned then the menu should not be changed
|
||||||
OledMenu *getNextMenu() {
|
OledMenu *getNextMenu()
|
||||||
for (int i=0; i<childrenMatrixLength; i++) {
|
{
|
||||||
if (childrenMatrix[i][0] == curItem) {
|
for (int i = 0; i < childrenMatrixLength; i++)
|
||||||
|
{
|
||||||
|
if (childrenMatrix[i][0] == curItem)
|
||||||
|
{
|
||||||
return children[childrenMatrix[i][1]];
|
return children[childrenMatrix[i][1]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +75,8 @@ class OledMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// To be invoked when the user presses the UP btn
|
// To be invoked when the user presses the UP btn
|
||||||
OledMenuItem goNextItem() {
|
OledMenuItem goNextItem()
|
||||||
|
{
|
||||||
curItem++;
|
curItem++;
|
||||||
curItem = curItem % elementsLength;
|
curItem = curItem % elementsLength;
|
||||||
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
||||||
@ -76,9 +84,11 @@ class OledMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// To be invoked when the user presses the DOWN btn
|
// To be invoked when the user presses the DOWN btn
|
||||||
OledMenuItem goPrevItem() {
|
OledMenuItem goPrevItem()
|
||||||
|
{
|
||||||
curItem--;
|
curItem--;
|
||||||
if (curItem < 0) {
|
if (curItem < 0)
|
||||||
|
{
|
||||||
curItem = elementsLength - 1;
|
curItem = elementsLength - 1;
|
||||||
}
|
}
|
||||||
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
Serial.println(String(elements[curItem].title) + " - " + String(curItem));
|
||||||
@ -86,14 +96,18 @@ class OledMenu {
|
|||||||
return elements[curItem];
|
return elements[curItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
OledMenuItem getCurItem() {
|
OledMenuItem itemAt(uint8_t index)
|
||||||
|
{
|
||||||
|
return elements[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
OledMenuItem getCurItem()
|
||||||
|
{
|
||||||
return elements[curItem];
|
return elements[curItem];
|
||||||
}
|
}
|
||||||
|
|
||||||
OledMenu *parent;
|
OledMenu *parent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int curItem = 0;
|
int curItem = 0;
|
||||||
OledMenuItem *elements;
|
OledMenuItem *elements;
|
||||||
@ -108,11 +122,13 @@ class OledMenu {
|
|||||||
*/
|
*/
|
||||||
uint8_t (*childrenMatrix)[2]; // First is element index, second is children index,
|
uint8_t (*childrenMatrix)[2]; // First is element index, second is children index,
|
||||||
int childrenMatrixLength;
|
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;
|
||||||
@ -16,6 +16,9 @@ OledDisplay::OledDisplay()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OledDisplay::handleButtonStateChange(Pair<ButtonKind, StateChangeEvent<ButtonState>> change)
|
void OledDisplay::handleButtonStateChange(Pair<ButtonKind, StateChangeEvent<ButtonState>> change)
|
||||||
|
{
|
||||||
|
ReflowProcessState state = reflowProcessState.get();
|
||||||
|
if (state == USER_INPUT)
|
||||||
{
|
{
|
||||||
if (change.second.to == ButtonState::PRESSED)
|
if (change.second.to == ButtonState::PRESSED)
|
||||||
{
|
{
|
||||||
@ -37,21 +40,59 @@ void OledDisplay::handleButtonStateChange(Pair<ButtonKind, StateChangeEvent<Butt
|
|||||||
}
|
}
|
||||||
else if (change.first == ButtonKind::UP)
|
else if (change.first == ButtonKind::UP)
|
||||||
{
|
{
|
||||||
curMenu->goNextItem();
|
curMenu->goPrevItem();
|
||||||
}
|
}
|
||||||
else if (change.first == ButtonKind::DOWN)
|
else if (change.first == ButtonKind::DOWN)
|
||||||
{
|
{
|
||||||
curMenu->goPrevItem();
|
curMenu->goNextItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
|
||||||
display.setTextSize(2);
|
|
||||||
if (menuItem.identifier >= MENUITEM_THERMISTOR_START && menuItem.identifier < MENUITEM_THERMISTOR_START + 7)
|
|
||||||
{
|
{
|
||||||
int thermistorIndex = menuItem.identifier - MENUITEM_THERMISTOR_START;
|
handleReflowState();
|
||||||
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);
|
||||||
|
|
||||||
|
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();
|
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