Added JSON handlers for Enable Polarity

This commit is contained in:
Alden Hart
2018-05-14 05:35:22 -04:00
parent dd1d35def6
commit edead24afc
3 changed files with 39 additions and 14 deletions
+6 -6
View File
@@ -408,7 +408,7 @@ const cfgItem_t cfgArray[] = {
{ "1","1po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M1_POLARITY },
{ "1","1pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M1_POWER_MODE },
{ "1","1pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M1_POWER_LEVEL },
// { "1","1ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M1_ENABLE_POLARITY },
{ "1","1ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M1_ENABLE_POLARITY },
{ "1","1sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M1_STEP_POLARITY },
// { "1","1pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_1].power_idle, M1_POWER_IDLE },
// { "1","1mt",_fip, 2, st_print_mt, st_get_mt, st_set_mt, (float *)&st_cfg.mot[MOTOR_1].motor_timeout, M1_MOTOR_TIMEOUT },
@@ -421,7 +421,7 @@ const cfgItem_t cfgArray[] = {
{ "2","2po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M2_POLARITY },
{ "2","2pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M2_POWER_MODE },
{ "2","2pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M2_POWER_LEVEL},
// { "2","2ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M2_ENABLE_POLARITY },
{ "2","2ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M2_ENABLE_POLARITY },
{ "2","2sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M2_STEP_POLARITY },
// { "2","2pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_2].power_idle, M2_POWER_IDLE },
// { "2","2mt",_fip, 2, st_print_mt, st_get_mt, st_set_mt, float *)&st_cfg.mot[MOTOR_2].motor_timeout, M2_MOTOR_TIMEOUT },
@@ -435,7 +435,7 @@ const cfgItem_t cfgArray[] = {
{ "3","3po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M3_POLARITY },
{ "3","3pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M3_POWER_MODE },
{ "3","3pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M3_POWER_LEVEL },
// { "3","3ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M3_ENABLE_POLARITY },
{ "3","3ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M3_ENABLE_POLARITY },
{ "3","3sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M3_STEP_POLARITY },
// { "3","3pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_3].power_idle, M3_POWER_IDLE },
// { "3","3mt",_fip, 2, st_print_mt, st_get_mt, st_set_mt, (float *)&st_cfg.mot[MOTOR_3].motor_timeout, M3_MOTOR_TIMEOUT },
@@ -449,7 +449,7 @@ const cfgItem_t cfgArray[] = {
{ "4","4po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M4_POLARITY },
{ "4","4pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M4_POWER_MODE },
{ "4","4pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M4_POWER_LEVEL },
// { "4","4ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M4_ENABLE_POLARITY },
{ "4","4ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M4_ENABLE_POLARITY },
{ "4","4sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M4_STEP_POLARITY },
// { "4","4pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_4].power_idle, M4_POWER_IDLE },
// { "4","4mt",_fip, 2, st_print_mt, st_get_mt, st_set_mt, (float *)&st_cfg.mot[MOTOR_4].motor_timeout, M4_MOTOR_TIMEOUT },
@@ -463,7 +463,7 @@ const cfgItem_t cfgArray[] = {
{ "5","5po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M5_POLARITY },
{ "5","5pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M5_POWER_MODE },
{ "5","5pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M5_POWER_LEVEL },
// { "5","5ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M5_ENABLE_POLARITY },
{ "5","5ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M5_ENABLE_POLARITY },
{ "5","5sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M5_STEP_POLARITY },
// { "5","5pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_5].power_idle, M5_POWER_IDLE },
// { "5","5mt",_fip, 2, st_print_mt, get_flt, st_set_mt, (float *)&st_cfg.mot[MOTOR_5].motor_timeout, M5_MOTOR_TIMEOUT },
@@ -477,7 +477,7 @@ const cfgItem_t cfgArray[] = {
{ "6","6po",_iip, 0, st_print_po, st_get_po, st_set_po, nullptr, M6_POLARITY },
{ "6","6pm",_iip, 0, st_print_pm, st_get_pm, st_set_pm, nullptr, M6_POWER_MODE },
{ "6","6pl",_fip, 3, st_print_pl, st_get_pl, st_set_pl, nullptr, M6_POWER_LEVEL },
// { "6","6ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M6_ENABLE_POLARITY },
{ "6","6ep",_iip, 0, st_print_ep, st_get_ep, st_set_ep, nullptr, M6_ENABLE_POLARITY },
{ "6","6sp",_iip, 0, st_print_sp, st_get_sp, st_set_sp, nullptr, M6_STEP_POLARITY },
// { "6","6pi",_fip, 3, st_print_pi, st_get_pi, st_set_pi, (float *)&st_cfg.mot[MOTOR_6].power_idle, M6_POWER_IDLE },
// { "6","6mt",_fip, 2, st_print_mt, st_get_mt, st_set_mt, (float *)&st_cfg.mot[MOTOR_6].motor_timeout, M6_MOTOR_TIMEOUT },
+29 -4
View File
@@ -1006,10 +1006,35 @@ stat_t st_get_pwr(nvObj_t *nv)
return (STAT_OK);
}
stat_t st_set_ep(nvObj_t *nv) // set motor enable polarity
{
if (nv->value_int < IO_ACTIVE_LOW) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > IO_ACTIVE_HIGH) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
uint8_t motor = _motor(nv->index);
if (motor > MOTORS) { return STAT_INPUT_VALUE_RANGE_ERROR; };
Motors[motor]->setEnablePolarity((ioMode)nv->value_int);
return (STAT_OK);
}
stat_t st_get_ep(nvObj_t *nv) // get motor enable polarity
{
if (nv->value_int < IO_ACTIVE_LOW) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > IO_ACTIVE_HIGH) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
uint8_t motor = _motor(nv->index);
if (motor > MOTORS) { return STAT_INPUT_VALUE_RANGE_ERROR; };
nv->value_int = (float)Motors[motor]->getEnablePolarity();
nv->valuetype = TYPE_INTEGER;
return (STAT_OK);
}
stat_t st_set_sp(nvObj_t *nv) // set motor step polarity
{
if (nv->value_int < 0) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > 1) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
if (nv->value_int < IO_ACTIVE_LOW) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > IO_ACTIVE_HIGH) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
uint8_t motor = _motor(nv->index);
if (motor > MOTORS) { return STAT_INPUT_VALUE_RANGE_ERROR; };
@@ -1020,8 +1045,8 @@ stat_t st_set_sp(nvObj_t *nv) // set motor step polarity
stat_t st_get_sp(nvObj_t *nv) // get motor step polarity
{
if (nv->value_int < 0) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > 1) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
if (nv->value_int < IO_ACTIVE_LOW) { return (STAT_INPUT_LESS_THAN_MIN_VALUE); }
if (nv->value_int > IO_ACTIVE_HIGH) { return (STAT_INPUT_EXCEEDS_MAX_VALUE); }
uint8_t motor = _motor(nv->index);
if (motor > MOTORS) { return STAT_INPUT_VALUE_RANGE_ERROR; };
+4 -4
View File
@@ -608,12 +608,12 @@ stat_t st_set_mi(nvObj_t *nv);
stat_t st_get_su(nvObj_t *nv);
stat_t st_set_su(nvObj_t *nv);
//stat_t st_set_ep(nvObj_t *nv);
//stat_t st_get_ep(nvObj_t *nv);
stat_t st_set_sp(nvObj_t *nv);
stat_t st_get_sp(nvObj_t *nv);
stat_t st_get_po(nvObj_t *nv);
stat_t st_set_po(nvObj_t *nv);
stat_t st_set_ep(nvObj_t *nv);
stat_t st_get_ep(nvObj_t *nv);
stat_t st_set_sp(nvObj_t *nv);
stat_t st_get_sp(nvObj_t *nv);
stat_t st_get_pm(nvObj_t *nv);
stat_t st_set_pm(nvObj_t *nv);