Browse Source

pwm steps bugs fixed (#4719)

fix the divide 0 bug in using "pwm steps" in NSH, and add it's
description
sbg
CAI Dongcai 9 years ago committed by Lorenz Meier
parent
commit
f8ff667dde
  1. 7
      src/systemcmds/pwm/pwm.c

7
src/systemcmds/pwm/pwm.c

@ -75,7 +75,7 @@ usage(const char *reason) @@ -75,7 +75,7 @@ usage(const char *reason)
errx(1,
"usage:\n"
"pwm arm|disarm|rate|failsafe|disarmed|min|max|test|info ...\n"
"pwm arm|disarm|rate|failsafe|disarmed|min|max|test|steps|info ...\n"
"\n"
"arm\t\t\t\tArm output\n"
"disarm\t\t\t\tDisarm output\n"
@ -101,6 +101,9 @@ usage(const char *reason) @@ -101,6 +101,9 @@ usage(const char *reason)
"\t[-a]\t\t\tConfigure all outputs\n"
"\t-p <pwm value>\t\tPWM value\n"
"\n"
"steps ...\t\t\tRun 5 steps\n"
"\t[-c <channels>]\t\t(e.g. 1234)\n"
"\n"
"info\t\t\t\tPrint information\n"
"\n"
"\t-v\t\t\tVerbose\n"
@ -663,7 +666,7 @@ pwm_main(int argc, char *argv[]) @@ -663,7 +666,7 @@ pwm_main(int argc, char *argv[])
} else if (phase == 1) {
/* ramp - depending how steep it is this ramp will look instantaneous on the output */
val = idle + (full - idle) * (phase_maxcount / (float)phase_counter);
val = idle + (full - idle) * ((float)phase_counter / phase_maxcount);
} else {
val = off;

Loading…
Cancel
Save