![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: BufferedSerial FastAnalogIn FastPWM mbed SHT75
Diff: commandt.cpp
- Revision:
- 1:5c42ec7f1aeb
- Parent:
- 0:9bfc4aea91e2
- Child:
- 2:4c51394fb35b
diff -r 9bfc4aea91e2 -r 5c42ec7f1aeb commandt.cpp --- a/commandt.cpp Fri Feb 19 07:07:26 2016 +0000 +++ b/commandt.cpp Mon Feb 22 06:03:11 2016 +0000 @@ -14,6 +14,7 @@ command_t::command_t(BufferedSerial* _pc, control_t* _control) { + time=0; count=0; control=_control; pc=_pc; @@ -40,23 +41,60 @@ { case 'm': control->set_mode(data[2]-'0'); + printf("set mode %d\n", data[2]-'0'); break; - case 'p': + case 'r': control->control_PWM(asci_to_bin(data+2)); - printf("set WPM duty ratio %f\n", asci_to_bin(data+2)); + control->set_PWM_value(asci_to_bin(data+2)); + printf("set PWM duty ratio %f1.5\n", asci_to_bin(data+2)); break; case 't': - + control->set_target_temp(asci_to_bin(data+2)); + printf("set target temp %f\n", asci_to_bin(data+2)); + break; + case 'p': + control->set_P_value(asci_to_bin(data+2)); + printf("set P value %f\n", asci_to_bin(data+2)); + break; + case 'i': + control->set_I_value(asci_to_bin(data+2)); + printf("set I value %f\n", asci_to_bin(data+2)); + break; + case 'd': + control->set_D_value(asci_to_bin(data+2)); + printf("set D value %f\n", asci_to_bin(data+2)); break; } break; case 'g': + switch(data[1]) + { + case 'm': + printf("mode is %d\n", control->get_mode()); + break; + case 'r': + printf("duty ratio is %f\n", control->get_PWM_value()); + break; + case 't': + printf("target temp is %f\n", control->get_target_temp()); + break; + case 'p': + printf("P value is %f\n", control->get_P_value()); + break; + case 'i': + printf("I value is %f\n", control->get_I_value()); + break; + case 'd': + printf("D value is %f\n", control->get_P_value()); + break; + } break; dafault: pc->printf("command error"); } pc->printf("\n"); + count=0; } void command_t::get_data() @@ -77,8 +115,9 @@ void command_t::refreshPWM() { - printf("temperature is %f\n", control->get_temp()); - + printf(",%2.2f\n", control->get_temp()); + time=time+3; + control->refresh_PWM(); } double command_t::asci_to_bin(int *start)