GiorgioAresu / FanController

Arduino library to control 3 and 4 pins fans
MIT License
40 stars 13 forks source link

FanController constructor truncates "sensorThreshold" to 8 bits. #11

Closed MojaveTom closed 4 years ago

MojaveTom commented 4 years ago

FanController.h

class FanController
{
    public:
        FanController(byte sensorPin, unsigned int sensorThreshold, byte pwmPin = 0);
        void begin();
        unsigned int getSpeed();
        void setDutyCycle(byte dutyCycle);
        byte getDutyCycle();
    private:
        static FanController *_instances[6];
        byte _sensorPin;
        byte _sensorInterruptPin;
        byte _sensorThreshold;       //    <--- aka *uint8_t*
        byte _pwmPin;
        byte _pwmDutyCycle;
        byte _instance;
        unsigned int _lastReading;
        volatile unsigned int _halfRevs;
             . . . 

FanController.cpp

FanController::FanController(byte sensorPin, unsigned int sensorThreshold, byte pwmPin)
{
    _sensorPin = sensorPin;
    _sensorInterruptPin = digitalPinToInterrupt(sensorPin);
    _sensorThreshold = sensorThreshold;      //  <---  assign *unsigned int* to *byte*
    _pwmPin = pwmPin;
    pinMode(pwmPin, OUTPUT);
    _pwmDutyCycle = 100;
}
GiorgioAresu commented 4 years ago

Hi, thanks for taking the time for opening the issue. Version v1.0.6-rc1 should fix the issue, can you confirm?

MojaveTom commented 4 years ago

The code mods appear to fix this issue. I have run no tests to verify; but the fix is so simple that tests should not be necessary.

MojaveTom commented 4 years ago

Sorry I didn’t respond earlier. I agree the issue seems to be resolved by looking at the code. I haven’t had need to use that module recently.

Thanks, Tom

On Jan 25, 2020, at 8:31 AM, Giorgio Aresu notifications@github.com wrote:

Closed #11 https://github.com/GiorgioAresu/FanController/issues/11.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GiorgioAresu/FanController/issues/11?email_source=notifications&email_token=ADL2G3PCOB74W6OUBSH6UZ3Q7RLMXA5CNFSM4JIHXCB2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWGKYSII#event-2979367201, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADL2G3OYP6ABPIRYJYJ4BGDQ7RLMXANCNFSM4JIHXCBQ.

GiorgioAresu commented 4 years ago

No problems, I'm not very active either, I just remembered I never promoted it to stable :) have a nice day

Il sab 25 gen 2020, 16:46 Tom notifications@github.com ha scritto:

Sorry I didn’t respond earlier. I agree the issue seems to be resolved by looking at the code. I haven’t had need to use that module recently.

Thanks, Tom

On Jan 25, 2020, at 8:31 AM, Giorgio Aresu notifications@github.com wrote:

Closed #11 https://github.com/GiorgioAresu/FanController/issues/11.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/GiorgioAresu/FanController/issues/11?email_source=notifications&email_token=ADL2G3PCOB74W6OUBSH6UZ3Q7RLMXA5CNFSM4JIHXCB2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWGKYSII#event-2979367201>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ADL2G3OYP6ABPIRYJYJ4BGDQ7RLMXANCNFSM4JIHXCBQ .

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/GiorgioAresu/FanController/issues/11?email_source=notifications&email_token=AAWEF2P6FCB37KKHLGY36K3Q7RNFDA5CNFSM4JIHXCB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ47BLQ#issuecomment-578416814, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWEF2OF2W7RIVLP2N56WLLQ7RNFDANCNFSM4JIHXCBQ .