Bayley Wang / Mbed 2 deprecated dc_motor_control

Dependencies:   mbed FastPWM3

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cmd_mode.cpp Source File

cmd_mode.cpp

00001 #include "mbed.h"
00002 #include "CommandProcessor.h"
00003 
00004 #include "globals.h"
00005 
00006 void cmd_setp(Serial *pc, char *buf) {
00007     float dtc = atof(buf);
00008     if (dtc < 0.0f) dtc = 0.0f;
00009     if (dtc > 1.0f) dtc = 1.0f;
00010     user_cmd = dtc;
00011 }
00012 
00013 void cmd_freq(Serial *pc, char *buf) {
00014     float freq = atof(buf);
00015     if (freq < 500.0f) freq = 500.0f;
00016     if (freq > 10000.0f) freq = 10000.0f;
00017     TIM1->ARR = (int) ((float) 9e7 / freq);
00018 }
00019 
00020 void cmd_src(Serial *pc, char *buf) {
00021     int n = str_to_src(buf);
00022     if (n < 0) {
00023         pc->printf("%s\n", "Invalid Source");
00024         return;
00025     }
00026     BREMS_src = n;
00027     pc->printf("Set source to %s\n", src_to_str(n));
00028 }
00029 
00030 void cmd_op(Serial *pc, char *buf) {
00031     int n = str_to_op(buf);
00032     if (n < 0) {
00033         pc->printf("%s\n", "Invalid operation");
00034         return;
00035     }
00036     BREMS_op = n;
00037     pc->printf("Set operation to %s\n", op_to_str(n));
00038 }
00039