Consolidated some power management functions; fixed a bug in status reports where SR_VERBOSE mode created filtered reports

This commit is contained in:
Alden Hart
2016-09-18 12:15:13 -04:00
parent d698a872bf
commit bd01ee779b
3 changed files with 19 additions and 33 deletions
Executable → Regular
+2 -1
View File
@@ -296,7 +296,8 @@ stat_t sr_status_report_callback() // called by controller dispatcher
}
sr.status_report_request = SR_OFF;
if (sr.status_report_request == SR_VERBOSE) {
if ((sr.status_report_request == SR_VERBOSE) ||
(sr.status_report_verbosity == SR_VERBOSE)) {
_populate_unfiltered_status_report();
} else {
if (_populate_filtered_status_report() == false) { // no new data
+12 -29
View File
@@ -192,28 +192,6 @@ stat_t st_clc(nvObj_t *nv) // clear diagnostic counters, reset stepper prep
return(STAT_OK);
}
/*
* Motor power management functions
*
* st_energize_motors() - apply power to all motors
* st_deenergize_motors() - remove power from all motors
* st_motor_power_callback() - callback to manage motor power sequencing
*/
void st_energize_motors(float timeout_seconds)
{
for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) {
Motors[motor]->enable(timeout_seconds);
}
}
void st_deenergize_motors()
{
for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) {
Motors[motor]->disable();
}
}
/*
* st_motor_power_callback() - callback to manage motor power sequencing
*
@@ -977,18 +955,23 @@ stat_t st_set_mt(nvObj_t *nv)
return (STAT_OK);
}
stat_t st_set_md(nvObj_t *nv) // Make sure this function is not part of initialization --> f00
stat_t st_set_me(nvObj_t *nv) // Make sure this function is not part of initialization --> f00
{
st_deenergize_motors();
for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) {
Motors[motor]->enable(nv->value); // nv->value is the timeout or 0 for default
}
return (STAT_OK);
}
stat_t st_set_me(nvObj_t *nv) // Make sure this function is not part of initialization --> f00
stat_t st_set_md(nvObj_t *nv) // Make sure this function is not part of initialization --> f00
{
if (((uint8_t)nv->value == 0) || (nv->valuetype == TYPE_NULL)) {
st_energize_motors(st_cfg.motor_power_timeout);
} else {
st_energize_motors(nv->value);
// de-energize all motors
if ((uint8_t)nv->value == 0) { // 0 means all motors
for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) {
Motors[motor]->disable();
}
} else { // otherwise it's just one motor
Motors[(uint8_t)nv->value -1]->disable();
}
return (STAT_OK);
}
+5 -3
View File
@@ -478,6 +478,7 @@ struct Stepper {
// };
// turn on motor in all cases unless it's disabled
// NOTE: in the future the default assigned timeout will be the motor's default value
void enable(float timeout = st_cfg.motor_power_timeout)
{
if (_power_mode == MOTOR_DISABLED) {
@@ -485,6 +486,10 @@ struct Stepper {
}
this->_enableImpl();
_power_state = MOTOR_RUNNING;
if ((uint8_t)timeout == 0) {
timeout = st_cfg.motor_power_timeout;
}
_motor_disable_timeout_ms = timeout * 1000.0;
};
@@ -554,9 +559,6 @@ stat_t stepper_test_assertions(void);
bool st_runtime_isbusy(void);
stat_t st_clc(nvObj_t *nv);
void st_energize_motors(float timeout_seconds);
void st_deenergize_motors(void);
void st_set_motor_power(const uint8_t motor);
stat_t st_motor_power_callback(void);