Commit 78be2cbd authored by Simone Primarosa's avatar Simone Primarosa

Added a value to store the Power on time

parent 6440ed0a
...@@ -781,6 +781,9 @@ static float analog2tempBed(int raw) { ...@@ -781,6 +781,9 @@ static float analog2tempBed(int raw) {
/* Called to get the raw values into the the actual temperatures. The raw values are created in interrupt context, /* Called to get the raw values into the the actual temperatures. The raw values are created in interrupt context,
and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise */ and this function is called from normal context as it is too slow to run in interrupts and will block the stepper routine otherwise */
static void updateTemperaturesFromRawValues() { static void updateTemperaturesFromRawValues() {
static millis_t last_update = millis();
millis_t temp_last_update = millis();
millis_t from_last_update = temp_last_update - last_update;
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
current_temperature_raw[0] = read_max6675(); current_temperature_raw[0] = read_max6675();
#endif #endif
...@@ -796,17 +799,22 @@ static void updateTemperaturesFromRawValues() { ...@@ -796,17 +799,22 @@ static void updateTemperaturesFromRawValues() {
#endif #endif
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
static float watt_overflow = 0.0; static float watt_overflow = 0.0;
static millis_t last_power_update = millis();
millis_t temp_last_power_update = millis();
power_consumption_meas = analog2power(); power_consumption_meas = analog2power();
//MYSERIAL.println(analog2current(),3); //MYSERIAL.println(analog2current(),3);
watt_overflow += (power_consumption_meas * (temp_last_power_update - last_power_update)) / 3600000.0; watt_overflow += (power_consumption_meas * from_last_update) / 3600000.0;
if (watt_overflow >= 1.0) { if (watt_overflow >= 1.0) {
power_consumption_hour++; power_consumption_hour++;
watt_overflow--; watt_overflow--;
} }
last_power_update = temp_last_power_update;
#endif #endif
static unsigned int second_overflow = 0;
second_overflow += from_last_update;
if(second_overflow >= 1000) {
printer_usage_seconds++;
second_overflow -= 1000;
}
last_update = temp_last_update;
//Reset the watchdog after we know we have a temperature measurement. //Reset the watchdog after we know we have a temperature measurement.
watchdog_reset(); watchdog_reset();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment