if(!pdr->second_element_is(this->name_checksum)) return; // will be bed or hotend
- // ok this is us send back the requested value
+ // ok this is targeted at us, so send back the requested data
if(pdr->third_element_is(current_temperature_checksum)) {
- pdr->set_data_ptr(&this->last_reading);
- pdr->set_taken();
- }else if(pdr->third_element_is(target_temperature_checksum)) {
- pdr->set_data_ptr((target_temperature == UNDEFINED) ? NULL : &this->target_temperature);
- pdr->set_taken();
- }else if(pdr->third_element_is(temperature_pwm_checksum)) {
- pdr->set_data_ptr(&this->o);
+ // this must be static as it will be accessed long after we have returned
+ static struct pad_temperature temp_return;
+ temp_return.current_temperature= this->get_temperature();
+ temp_return.target_temperature= (target_temperature == UNDEFINED) ? 0 : this->target_temperature;
+ temp_return.pwm= this->o;
+
+ pdr->set_data_ptr(&temp_return);
pdr->set_taken();
}
-
}
void TemperatureControl::set_desired_temperature(double desired_temperature)
#define target_temperature_checksum CHECKSUM("target_temperature")
#define temperature_pwm_checksum CHECKSUM("temperature_pwm")
+struct pad_temperature {
+ double current_temperature;
+ double target_temperature;
+ int pwm;
+};
#endif
\ No newline at end of file
// used to test out the get public data events
void SimpleShell::get_temp_command( string parameters, StreamOutput* stream){
string type= shift_parameter( parameters );
- double* temp;
- bool ok= this->kernel->public_data->get_value( temperature_control_checksum, get_checksum(type), current_temperature_checksum, (void**)&temp );
+ void *returned_data;
+ bool ok= this->kernel->public_data->get_value( temperature_control_checksum, get_checksum(type), current_temperature_checksum, &returned_data );
if(ok) {
- stream->printf("%s temp: %f\r\n", type.c_str(), *temp);
+ struct pad_temperature temp= *static_cast<struct pad_temperature*>(returned_data);
+ stream->printf("%s temp: %f/%f @%d\r\n", type.c_str(), temp.current_temperature, temp.target_temperature, temp.pwm);
}else{
stream->printf("%s is not a known temperature device\r\n", type.c_str());
}
#include "version.h"
const char *Version::get_build(void) const {
- return "feature/get_public_value_event-688c613";
+ return "feature/get_public_value_event-47339e4";
}
const char *Version::get_build_date(void) const {
return __DATE__ " " __TIME__;