refactured temperature.cpp so that there are now abstract functions to access temperatures.
This commit is contained in:
parent
0b82465168
commit
2afb7bd4cf
@ -157,6 +157,7 @@ const int dropsegments=5; //everything with this number of steps will be ignore
|
|||||||
//// Experimental watchdog and minimal temp
|
//// Experimental watchdog and minimal temp
|
||||||
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||||
// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
|
// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
|
||||||
|
/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
|
||||||
//#define WATCHPERIOD 5000 //5 seconds
|
//#define WATCHPERIOD 5000 //5 seconds
|
||||||
|
|
||||||
// Actual temperature must be close to target for this long before M109 returns success
|
// Actual temperature must be close to target for this long before M109 returns success
|
||||||
|
@ -150,10 +150,7 @@ extern float HeaterPower;
|
|||||||
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
||||||
|
|
||||||
float tt = 0, bt = 0;
|
float tt = 0, bt = 0;
|
||||||
#ifdef WATCHPERIOD
|
|
||||||
int watch_raw = -1000;
|
|
||||||
unsigned long watchmillis = 0;
|
|
||||||
#endif //WATCHPERIOD
|
|
||||||
|
|
||||||
//Inactivity shutdown variables
|
//Inactivity shutdown variables
|
||||||
unsigned long previous_millis_cmd = 0;
|
unsigned long previous_millis_cmd = 0;
|
||||||
@ -817,28 +814,18 @@ inline void process_commands()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 104: // M104
|
case 104: // M104
|
||||||
if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(code_value());
|
if (code_seen('S')) setTargetHotend0(code_value());
|
||||||
#ifdef PIDTEMP
|
setWatch();
|
||||||
pid_setpoint = code_value();
|
|
||||||
#endif //PIDTEM
|
|
||||||
#ifdef WATCHPERIOD
|
|
||||||
if(target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0]){
|
|
||||||
watchmillis = max(1,millis());
|
|
||||||
watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
|
|
||||||
}else{
|
|
||||||
watchmillis = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case 140: // M140 set bed temp
|
case 140: // M140 set bed temp
|
||||||
if (code_seen('S')) target_raw[TEMPSENSOR_BED] = temp2analogBed(code_value());
|
if (code_seen('S')) setTargetBed(code_value());
|
||||||
break;
|
break;
|
||||||
case 105: // M105
|
case 105: // M105
|
||||||
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
||||||
tt = analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
|
tt = degHotend0();
|
||||||
#endif
|
#endif
|
||||||
#if TEMP_1_PIN > -1
|
#if TEMP_1_PIN > -1
|
||||||
bt = analog2tempBed(current_raw[TEMPSENSOR_BED]);
|
bt = degBed();
|
||||||
#endif
|
#endif
|
||||||
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
||||||
Serial.print("ok T:");
|
Serial.print("ok T:");
|
||||||
@ -866,36 +853,27 @@ inline void process_commands()
|
|||||||
//break;
|
//break;
|
||||||
case 109: {// M109 - Wait for extruder heater to reach target.
|
case 109: {// M109 - Wait for extruder heater to reach target.
|
||||||
LCD_MESSAGE("Heating...");
|
LCD_MESSAGE("Heating...");
|
||||||
if (code_seen('S')) target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(code_value());
|
if (code_seen('S')) setTargetHotend0(code_value());
|
||||||
#ifdef PIDTEMP
|
|
||||||
pid_setpoint = code_value();
|
setWatch();
|
||||||
#endif //PIDTEM
|
|
||||||
#ifdef WATCHPERIOD
|
|
||||||
if(target_raw[TEMPSENSOR_HOTEND_0]>current_raw[TEMPSENSOR_HOTEND_0]){
|
|
||||||
watchmillis = max(1,millis());
|
|
||||||
watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
|
|
||||||
} else {
|
|
||||||
watchmillis = 0;
|
|
||||||
}
|
|
||||||
#endif //WATCHPERIOD
|
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
|
|
||||||
/* See if we are heating up or cooling down */
|
/* See if we are heating up or cooling down */
|
||||||
bool target_direction = (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]); // true if heating, false if cooling
|
bool target_direction = isHeatingHotend0(); // true if heating, false if cooling
|
||||||
|
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
long residencyStart;
|
long residencyStart;
|
||||||
residencyStart = -1;
|
residencyStart = -1;
|
||||||
/* continue to loop until we have reached the target temp
|
/* continue to loop until we have reached the target temp
|
||||||
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
||||||
while((target_direction ? (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]) : (current_raw[TEMPSENSOR_HOTEND_0] > target_raw[TEMPSENSOR_HOTEND_0])) ||
|
while((target_direction ? (isHeatingHotend0()) : (isCoolingHotend0()) ||
|
||||||
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
||||||
#else
|
#else
|
||||||
while ( target_direction ? (current_raw[TEMPSENSOR_HOTEND_0] < target_raw[TEMPSENSOR_HOTEND_0]) : (current_raw[TEMPSENSOR_HOTEND_0] > target_raw[TEMPSENSOR_HOTEND_0]) ) {
|
while ( target_direction ? (isHeatingHotend0()) : (isCoolingHotend0()) ) {
|
||||||
#endif //TEMP_RESIDENCY_TIME
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
|
if( (millis() - codenum) > 1000 ) { //Print Temp Reading every 1 second while heating up/cooling down
|
||||||
Serial.print("T:");
|
Serial.print("T:");
|
||||||
Serial.println( analog2temp(current_raw[TEMPSENSOR_HOTEND_0]) );
|
Serial.println( degHotend0() );
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
}
|
}
|
||||||
manage_heater();
|
manage_heater();
|
||||||
@ -903,9 +881,9 @@ inline void process_commands()
|
|||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
||||||
or when current temp falls outside the hysteresis after target temp was reached */
|
or when current temp falls outside the hysteresis after target temp was reached */
|
||||||
if ((residencyStart == -1 && target_direction && current_raw[TEMPSENSOR_HOTEND_0] >= target_raw[TEMPSENSOR_HOTEND_0]) ||
|
if ((residencyStart == -1 && target_direction && !isHeatingHotend0()) ||
|
||||||
(residencyStart == -1 && !target_direction && current_raw[TEMPSENSOR_HOTEND_0] <= target_raw[TEMPSENSOR_HOTEND_0]) ||
|
(residencyStart == -1 && !target_direction && !isCoolingHotend0()) ||
|
||||||
(residencyStart > -1 && labs(analog2temp(current_raw[TEMPSENSOR_HOTEND_0]) - analog2temp(target_raw[TEMPSENSOR_HOTEND_0])) > TEMP_HYSTERESIS) ) {
|
(residencyStart > -1 && labs(degHotend0() - degTargetHotend0()) > TEMP_HYSTERESIS) ) {
|
||||||
residencyStart = millis();
|
residencyStart = millis();
|
||||||
}
|
}
|
||||||
#endif //TEMP_RESIDENCY_TIME
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
@ -915,19 +893,19 @@ inline void process_commands()
|
|||||||
break;
|
break;
|
||||||
case 190: // M190 - Wait bed for heater to reach target.
|
case 190: // M190 - Wait bed for heater to reach target.
|
||||||
#if TEMP_1_PIN > -1
|
#if TEMP_1_PIN > -1
|
||||||
if (code_seen('S')) target_raw[TEMPSENSOR_BED] = temp2analog(code_value());
|
if (code_seen('S')) setTargetBed(code_value());
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
while(current_raw[TEMPSENSOR_BED] < target_raw[TEMPSENSOR_BED])
|
while(isHeatingBed())
|
||||||
{
|
{
|
||||||
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
|
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
|
||||||
{
|
{
|
||||||
float tt=analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
|
float tt=degHotend0();
|
||||||
Serial.print("T:");
|
Serial.print("T:");
|
||||||
Serial.println( tt );
|
Serial.println( tt );
|
||||||
Serial.print("ok T:");
|
Serial.print("ok T:");
|
||||||
Serial.print( tt );
|
Serial.print( tt );
|
||||||
Serial.print(" B:");
|
Serial.print(" B:");
|
||||||
Serial.println( analog2temp(current_raw[TEMPSENSOR_BED]) );
|
Serial.println( degBed() );
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
}
|
}
|
||||||
manage_heater();
|
manage_heater();
|
||||||
@ -1331,24 +1309,8 @@ void wd_reset() {
|
|||||||
|
|
||||||
inline void kill()
|
inline void kill()
|
||||||
{
|
{
|
||||||
#if TEMP_0_PIN > -1
|
disable_heater();
|
||||||
target_raw[0]=0;
|
|
||||||
#if HEATER_0_PIN > -1
|
|
||||||
WRITE(HEATER_0_PIN,LOW);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TEMP_1_PIN > -1
|
|
||||||
target_raw[1]=0;
|
|
||||||
#if HEATER_1_PIN > -1
|
|
||||||
WRITE(HEATER_1_PIN,LOW);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TEMP_2_PIN > -1
|
|
||||||
target_raw[2]=0;
|
|
||||||
#if HEATER_2_PIN > -1
|
|
||||||
WRITE(HEATER_2_PIN,LOW);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
disable_x();
|
disable_x();
|
||||||
disable_y();
|
disable_y();
|
||||||
disable_z();
|
disable_z();
|
||||||
|
@ -37,28 +37,27 @@
|
|||||||
#include "streaming.h"
|
#include "streaming.h"
|
||||||
#include "temperature.h"
|
#include "temperature.h"
|
||||||
|
|
||||||
int target_bed_raw = 0;
|
|
||||||
int current_bed_raw = 0;
|
|
||||||
|
|
||||||
int target_raw[3] = {0, 0, 0};
|
int target_raw[3] = {0, 0, 0};
|
||||||
int current_raw[3] = {0, 0, 0};
|
int current_raw[3] = {0, 0, 0};
|
||||||
unsigned char temp_meas_ready = false;
|
|
||||||
|
bool temp_meas_ready = false;
|
||||||
|
|
||||||
unsigned long previous_millis_heater, previous_millis_bed_heater;
|
unsigned long previous_millis_heater, previous_millis_bed_heater;
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
double temp_iState = 0;
|
float temp_iState = 0;
|
||||||
double temp_dState = 0;
|
float temp_dState = 0;
|
||||||
double pTerm;
|
float pTerm;
|
||||||
double iTerm;
|
float iTerm;
|
||||||
double dTerm;
|
float dTerm;
|
||||||
//int output;
|
//int output;
|
||||||
double pid_error;
|
float pid_error;
|
||||||
double temp_iState_min;
|
float temp_iState_min;
|
||||||
double temp_iState_max;
|
float temp_iState_max;
|
||||||
double pid_setpoint = 0.0;
|
float pid_setpoint = 0.0;
|
||||||
double pid_input;
|
float pid_input;
|
||||||
double pid_output;
|
float pid_output;
|
||||||
bool pid_reset;
|
bool pid_reset;
|
||||||
float HeaterPower;
|
float HeaterPower;
|
||||||
|
|
||||||
@ -68,6 +67,11 @@ unsigned long previous_millis_heater, previous_millis_bed_heater;
|
|||||||
float Kc=DEFAULT_Kc;
|
float Kc=DEFAULT_Kc;
|
||||||
#endif //PIDTEMP
|
#endif //PIDTEMP
|
||||||
|
|
||||||
|
#ifdef WATCHPERIOD
|
||||||
|
int watch_raw[3] = {-1000,-1000,-1000};
|
||||||
|
unsigned long watchmillis = 0;
|
||||||
|
#endif //WATCHPERIOD
|
||||||
|
|
||||||
#ifdef HEATER_0_MINTEMP
|
#ifdef HEATER_0_MINTEMP
|
||||||
int minttemp_0 = temp2analog(HEATER_0_MINTEMP);
|
int minttemp_0 = temp2analog(HEATER_0_MINTEMP);
|
||||||
#endif //MINTEMP
|
#endif //MINTEMP
|
||||||
@ -330,6 +334,22 @@ void tp_init()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setWatch()
|
||||||
|
{
|
||||||
|
#ifdef WATCHPERIOD
|
||||||
|
if(isHeatingHotend0())
|
||||||
|
{
|
||||||
|
watchmillis = max(1,millis());
|
||||||
|
watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
watchmillis = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Timer 0 is shared with millies
|
// Timer 0 is shared with millies
|
||||||
ISR(TIMER0_COMPB_vect)
|
ISR(TIMER0_COMPB_vect)
|
||||||
{
|
{
|
||||||
@ -501,3 +521,4 @@ ISR(TIMER0_COMPB_vect)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,18 +22,97 @@
|
|||||||
#define temperature_h
|
#define temperature_h
|
||||||
|
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
|
#include "fastio.h"
|
||||||
#ifdef PID_ADD_EXTRUSION_RATE
|
#ifdef PID_ADD_EXTRUSION_RATE
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#endif
|
#endif
|
||||||
void tp_init();
|
|
||||||
void manage_heater();
|
void tp_init(); //initialise the heating
|
||||||
//int temp2analogu(int celsius, const short table[][2], int numtemps);
|
void manage_heater(); //it is critical that this is called periodically.
|
||||||
//float analog2tempu(int raw, const short table[][2], int numtemps);
|
|
||||||
|
enum TempSensor {TEMPSENSOR_HOTEND_0=0,TEMPSENSOR_BED=1, TEMPSENSOR_HOTEND_1=2};
|
||||||
|
|
||||||
|
//low leven conversion routines
|
||||||
|
// do not use this routines and variables outsie of temperature.cpp
|
||||||
int temp2analog(int celsius);
|
int temp2analog(int celsius);
|
||||||
int temp2analogBed(int celsius);
|
int temp2analogBed(int celsius);
|
||||||
float analog2temp(int raw);
|
float analog2temp(int raw);
|
||||||
float analog2tempBed(int raw);
|
float analog2tempBed(int raw);
|
||||||
|
extern int target_raw[3];
|
||||||
|
extern int current_raw[3];
|
||||||
|
extern float Kp,Ki,Kd,Kc;
|
||||||
|
#ifdef PIDTEMP
|
||||||
|
float pid_setpoint = 0.0;
|
||||||
|
#endif
|
||||||
|
#ifdef WATCHPERIOD
|
||||||
|
extern int watch_raw[3] ;
|
||||||
|
extern unsigned long watchmillis;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//high level conversion routines, for use outside of temperature.cpp
|
||||||
|
//inline so that there is no performance decrease.
|
||||||
|
//deg=degreeCelsius
|
||||||
|
|
||||||
|
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
|
||||||
|
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
|
||||||
|
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
|
||||||
|
|
||||||
|
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
|
||||||
|
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
|
||||||
|
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
|
||||||
|
|
||||||
|
inline void setTargetHotend0(float celsius)
|
||||||
|
{
|
||||||
|
target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
|
||||||
|
#ifdef PIDTEMP
|
||||||
|
pid_setpoint = celsius;
|
||||||
|
#endif //PIDTEMP
|
||||||
|
};
|
||||||
|
inline void setTargetHotend1(float celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
|
||||||
|
inline void setTargetBed(float celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
|
||||||
|
|
||||||
|
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
|
||||||
|
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
|
||||||
|
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
|
||||||
|
|
||||||
|
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
|
||||||
|
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
|
||||||
|
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
|
||||||
|
|
||||||
|
inline void disable_heater()
|
||||||
|
{
|
||||||
|
#if TEMP_0_PIN > -1
|
||||||
|
target_raw[0]=0;
|
||||||
|
#if HEATER_0_PIN > -1
|
||||||
|
WRITE(HEATER_0_PIN,LOW);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if TEMP_1_PIN > -1
|
||||||
|
target_raw[1]=0;
|
||||||
|
#if HEATER_1_PIN > -1
|
||||||
|
WRITE(HEATER_1_PIN,LOW);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if TEMP_2_PIN > -1
|
||||||
|
target_raw[2]=0;
|
||||||
|
#if HEATER_2_PIN > -1
|
||||||
|
WRITE(HEATER_2_PIN,LOW);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void setWatch() {
|
||||||
|
if(isHeatingHotend0())
|
||||||
|
{
|
||||||
|
watchmillis = max(1,millis());
|
||||||
|
watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
watchmillis = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef HEATER_0_USES_THERMISTOR
|
#ifdef HEATER_0_USES_THERMISTOR
|
||||||
#define HEATERSOURCE 1
|
#define HEATERSOURCE 1
|
||||||
#endif
|
#endif
|
||||||
@ -41,18 +120,9 @@ float analog2tempBed(int raw);
|
|||||||
#define BEDSOURCE 1
|
#define BEDSOURCE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define temp2analogh( c ) temp2analogu((c),temptable,NUMTEMPS)
|
|
||||||
//#define analog2temp( c ) analog2tempu((c),temptable,NUMTEMPS
|
|
||||||
|
|
||||||
|
|
||||||
extern float Kp;
|
|
||||||
extern float Ki;
|
|
||||||
extern float Kd;
|
|
||||||
extern float Kc;
|
|
||||||
|
|
||||||
enum {TEMPSENSOR_HOTEND_0=0,TEMPSENSOR_BED=1, TEMPSENSOR_HOTEND_1=2};
|
|
||||||
extern int target_raw[3];
|
|
||||||
extern int current_raw[3];
|
|
||||||
extern double pid_setpoint;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PIN
|
|||||||
|
|
||||||
unsigned long previous_millis_lcd=0;
|
unsigned long previous_millis_lcd=0;
|
||||||
|
|
||||||
|
inline int intround(const float &x){return int(0.5+x);}
|
||||||
|
|
||||||
volatile char buttons=0; //the last checked buttons in a bit array.
|
volatile char buttons=0; //the last checked buttons in a bit array.
|
||||||
int encoderpos=0;
|
int encoderpos=0;
|
||||||
@ -29,13 +29,10 @@ void lcd_status(const char* message)
|
|||||||
strncpy(messagetext,message,LCD_WIDTH);
|
strncpy(messagetext,message,LCD_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
inline void clear()
|
||||||
{
|
{
|
||||||
//lcd.setCursor(0,0);
|
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
//delay(1);
|
|
||||||
// lcd.begin(LCD_WIDTH,LCD_HEIGHT);
|
|
||||||
//lcd_init();
|
|
||||||
}
|
}
|
||||||
long previous_millis_buttons=0;
|
long previous_millis_buttons=0;
|
||||||
|
|
||||||
@ -102,6 +99,7 @@ void beepshort()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_status()
|
void lcd_status()
|
||||||
{
|
{
|
||||||
#ifdef ULTIPANEL
|
#ifdef ULTIPANEL
|
||||||
@ -161,8 +159,7 @@ void buttons_check()
|
|||||||
if((blocking<millis()) &&(READ(BTN_ENC)==0))
|
if((blocking<millis()) &&(READ(BTN_ENC)==0))
|
||||||
newbutton|=EN_C;
|
newbutton|=EN_C;
|
||||||
buttons=newbutton;
|
buttons=newbutton;
|
||||||
#else
|
#else //read it from the shift register
|
||||||
//read it from the shift register
|
|
||||||
uint8_t newbutton=0;
|
uint8_t newbutton=0;
|
||||||
WRITE(SHIFT_LD,LOW);
|
WRITE(SHIFT_LD,LOW);
|
||||||
WRITE(SHIFT_LD,HIGH);
|
WRITE(SHIFT_LD,HIGH);
|
||||||
@ -238,8 +235,8 @@ extern volatile bool feedmultiplychanged;
|
|||||||
void MainMenu::showStatus()
|
void MainMenu::showStatus()
|
||||||
{
|
{
|
||||||
#if LCD_HEIGHT==4
|
#if LCD_HEIGHT==4
|
||||||
static int oldcurrentraw=-1;
|
static int olddegHotEnd0=-1;
|
||||||
static int oldtargetraw=-1;
|
static int oldtargetHotEnd0=-1;
|
||||||
//force_lcd_update=true;
|
//force_lcd_update=true;
|
||||||
if(force_lcd_update||feedmultiplychanged) //initial display of content
|
if(force_lcd_update||feedmultiplychanged) //initial display of content
|
||||||
{
|
{
|
||||||
@ -252,33 +249,36 @@ void MainMenu::showStatus()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tHotEnd0=intround(degHotend0());
|
||||||
if((abs(current_raw[TEMPSENSOR_HOTEND_0]-oldcurrentraw)>3)||force_lcd_update)
|
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update) //>1 because otherwise the lcd is refreshed to often.
|
||||||
{
|
{
|
||||||
lcd.setCursor(1,0);
|
lcd.setCursor(1,0);
|
||||||
lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND_0])));
|
lcd.print(ftostr3(tHotEnd0));
|
||||||
oldcurrentraw=current_raw[TEMPSENSOR_HOTEND_0];
|
olddegHotEnd0=tHotEnd0;
|
||||||
}
|
}
|
||||||
if((target_raw[TEMPSENSOR_HOTEND_0]!=oldtargetraw)||force_lcd_update)
|
int ttHotEnd0=intround(degTargetHotend0());
|
||||||
|
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(5,0);
|
lcd.setCursor(5,0);
|
||||||
lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND_0])));
|
lcd.print(ftostr3(ttHotEnd0));
|
||||||
oldtargetraw=target_raw[TEMPSENSOR_HOTEND_0];
|
oldtargetHotEnd0=ttHotEnd0;
|
||||||
}
|
}
|
||||||
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
|
||||||
static int oldcurrentbedraw=-1;
|
static int oldtBed=-1;
|
||||||
static int oldtargetbedraw=-1;
|
static int oldtargetBed=-1;
|
||||||
if((current_bed_raw!=oldcurrentbedraw)||force_lcd_update)
|
int tBed=intround(degBed());
|
||||||
|
if((tBed!=oldtBed)||force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(1,0);
|
lcd.setCursor(1,0);
|
||||||
lcd.print(ftostr3(analog2temp(current_bed_raw)));
|
lcd.print(ftostr3(tBed));
|
||||||
oldcurrentraw=current_raw[TEMPSENSOR_BED];
|
olddegHotEnd0=tBed;
|
||||||
}
|
}
|
||||||
if((target_bed_raw!=oldtargebedtraw)||force_lcd_update)
|
int targetBed=intround(degTargetBed());
|
||||||
|
if((targetBed!=oldtargetBed)||force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(5,0);
|
lcd.setCursor(5,0);
|
||||||
lcd.print(ftostr3(analog2temp(target_bed_raw)));
|
lcd.print(ftostr3(targetBed));
|
||||||
oldtargetraw=target_bed_raw;
|
oldtargetBed=targetBed;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//starttime=2;
|
//starttime=2;
|
||||||
@ -327,8 +327,8 @@ void MainMenu::showStatus()
|
|||||||
messagetext[0]='\0';
|
messagetext[0]='\0';
|
||||||
}
|
}
|
||||||
#else //smaller LCDS----------------------------------
|
#else //smaller LCDS----------------------------------
|
||||||
static int oldcurrentraw=-1;
|
static int olddegHotEnd0=-1;
|
||||||
static int oldtargetraw=-1;
|
static int oldtargetHotEnd0=-1;
|
||||||
if(force_lcd_update) //initial display of content
|
if(force_lcd_update) //initial display of content
|
||||||
{
|
{
|
||||||
encoderpos=feedmultiply;
|
encoderpos=feedmultiply;
|
||||||
@ -338,18 +338,21 @@ void MainMenu::showStatus()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int tHotEnd0=intround(degHotend0());
|
||||||
|
int ttHotEnd0=intround(degTargetHotend0());
|
||||||
|
|
||||||
if((abs(current_raw[TEMPSENSOR_HOTEND]-oldcurrentraw)>3)||force_lcd_update)
|
|
||||||
|
if((abs(tHotEnd0-olddegHotEnd0)>1)||force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(1,0);
|
lcd.setCursor(1,0);
|
||||||
lcd.print(ftostr3(analog2temp(current_raw[TEMPSENSOR_HOTEND])));
|
lcd.print(ftostr3(tHotEnd0));
|
||||||
oldcurrentraw=current_raw[TEMPSENSOR_HOTEND];
|
olddegHotEnd0=tHotEnd0;
|
||||||
}
|
}
|
||||||
if((target_raw[TEMPSENSOR_HOTEND]!=oldtargetraw)||force_lcd_update)
|
if((ttHotEnd0!=oldtargetHotEnd0)||force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(5,0);
|
lcd.setCursor(5,0);
|
||||||
lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND])));
|
lcd.print(ftostr3(ttHotEnd0));
|
||||||
oldtargetraw=target_raw[TEMPSENSOR_HOTEND];
|
oldtargetHotEnd0=ttHotEnd0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(messagetext[0]!='\0')
|
if(messagetext[0]!='\0')
|
||||||
@ -426,7 +429,7 @@ void MainMenu::showPrepare()
|
|||||||
if((activeline==line) && CLICKED)
|
if((activeline==line) && CLICKED)
|
||||||
{
|
{
|
||||||
BLOCK
|
BLOCK
|
||||||
target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(170);
|
setTargetHotend0(170);
|
||||||
beepshort();
|
beepshort();
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
@ -531,7 +534,7 @@ void MainMenu::showControl()
|
|||||||
if(force_lcd_update)
|
if(force_lcd_update)
|
||||||
{
|
{
|
||||||
lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
|
lcd.setCursor(0,line);lcd.print(" \002Nozzle:");
|
||||||
lcd.setCursor(13,line);lcd.print(ftostr3(analog2temp(target_raw[TEMPSENSOR_HOTEND_0])));
|
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if((activeline==line) )
|
if((activeline==line) )
|
||||||
@ -541,11 +544,11 @@ void MainMenu::showControl()
|
|||||||
linechanging=!linechanging;
|
linechanging=!linechanging;
|
||||||
if(linechanging)
|
if(linechanging)
|
||||||
{
|
{
|
||||||
encoderpos=(int)analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);
|
encoderpos=intround(degHotend0());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
target_raw[TEMPSENSOR_HOTEND_0] = temp2analog(encoderpos);
|
setTargetHotend0(encoderpos);
|
||||||
encoderpos=activeline*lcdslow;
|
encoderpos=activeline*lcdslow;
|
||||||
beepshort();
|
beepshort();
|
||||||
}
|
}
|
||||||
@ -1591,3 +1594,4 @@ char *fillto(int8_t n,char *c)
|
|||||||
inline void lcd_status() {};
|
inline void lcd_status() {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user