pid-controller icon indicating copy to clipboard operation
pid-controller copied to clipboard

Mismatch between legacy constants and setMode()

Open cmcconomy opened this issue 9 years ago • 1 comments

in the pid code, the following are defined:

// Constants for backward compatibility
PID.AUTOMATIC = 1;
PID.MANUAL = 0;

I assumed these were to be passed to setMode() - I prefer explicit constants to "magic strings".

However, in setMode(), instead of values 0 and 1, setMode() refers to 1 and 2:

    if (Mode == 1 || Mode.toString().toLowerCase() == 'automatic' || Mode.toString().toLowerCase() == 'auto') {
        newAuto = 1;
    }
    else if (Mode == 2 || Mode.toString().toLowerCase() == 'manual') {
        newAuto = 0;
    }

Shouldn't these correspond?

cmcconomy avatar Jan 19 '17 05:01 cmcconomy

Yes - it looks like it might be related to this update:

https://github.com/wilberforce/pid-controller/commit/9f62aa5e49491ab70ff046b3d64dd826cad79e47

Do you want to update and do a pull request?

wilberforce avatar Jan 19 '17 22:01 wilberforce