int temp_get_celsius(channel_tag temp_ch, double *value) { int idx = 0; if (!value) { return -1; } idx = temp_index_lookup(temp_ch); if (idx < 0) { return -1; } temp_update(temp_ch); *value = temps[idx].value; return 0; }
/*! Manages motor and heater based on measured temperature: o If temp is too low, don't start the motor o Adjust the heater power to keep the temperature at the target */ void Heater::manage_temperature() { int output, dt; unsigned long time; //make sure we know what our temp is. current_temperature = get_current_temperature(); // ignoring millis rollover for now time = millis(); dt = time - temp_prev_time; if (dt > TEMP_UPDATE_INTERVAL) { temp_prev_time = time; output = temp_update(dt); digitalWrite(DEBUG_PIN, (output > 0)?HIGH:LOW); analogWrite(outputPin, output); } }