Added lbm-extension app-pas-get-rpm

This commit is contained in:
Benjamin Vedder 2022-11-09 11:56:59 +01:00
parent 1130747bc3
commit a8c0968888
4 changed files with 20 additions and 0 deletions

View File

@ -93,6 +93,7 @@ void app_pas_stop(void);
bool app_pas_is_running(void);
void app_pas_configure(pas_config *conf);
float app_pas_get_current_target_rel(void);
float app_pas_get_pedal_rpm(void);
void app_pas_set_current_sub_scaling(float current_sub_scaling);
// Custom apps

View File

@ -115,6 +115,10 @@ float app_pas_get_current_target_rel(void) {
return output_current_rel;
}
float app_pas_get_pedal_rpm(void) {
return pedal_rpm;
}
void pas_event_handler(void) {
#ifdef HW_PAS1_PORT
const int8_t QEM[] = {0,-1,1,2,1,0,2,-1,-1,2,0,1,2,1,-1,0}; // Quadrature Encoder Matrix

View File

@ -372,6 +372,14 @@ Send input to the VESC Remote app. Unlike the ADC and PPM apps, input can be sen
Disable app output for ms milliseconds. 0 means enable now and -1 means disable forever. This can be used to override the control of apps temporarily.
#### app-pas-get-rpm
```clj
(app-pas-get-rpm)
```
Returns the pedal RPM measured by the PAS-app. If you want to implement your own PAS-control based on this RPM you can use [app-disable-output](#app-disable-output) to disable the output of the PAS-app.
### Motor Set Commands
#### set-current

View File

@ -1122,6 +1122,11 @@ static lbm_value ext_app_disable_output(lbm_value *args, lbm_uint argn) {
return ENC_SYM_TRUE;
}
static lbm_value ext_app_pas_get_rpm(lbm_value *args, lbm_uint argn) {
(void)args; (void)argn;
return lbm_enc_float(app_pas_get_pedal_rpm());
}
// Motor set commands
static lbm_value ext_set_current(lbm_value *args, lbm_uint argn) {
@ -4016,6 +4021,8 @@ void lispif_load_vesc_extensions(void) {
lbm_add_extension("app-ppm-override", ext_app_ppm_override);
lbm_add_extension("set-remote-state", ext_set_remote_state);
lbm_add_extension("app-disable-output", ext_app_disable_output);
lbm_add_extension("app-pas-get-rpm", ext_app_pas_get_rpm);
// Motor set commands
lbm_add_extension("set-current", ext_set_current);