BioAmp-EXG-Pill
                                
                                
                                
                                    BioAmp-EXG-Pill copied to clipboard
                            
                            
                            
                        Claw constrain and arithmetic overflow fix
- Using 
constrainto guarantee servo angles are valid and between the desired 90 to180 (inclusive) range. - Enlarging 
sumvariable to avoid overflow, nowint32_t(frominttypes.h) - Adding some explcit (tradtitional C style) casts for 
floatconversions. - Converted 
getEnvelop()to return float and using a locally definedmapffor improved conversion resolution. 
Tested on the Arduino Uno (from pro kit). And on an Uno R4 WiFi as I happened to have it plugged in.
Fixes #38.
I was thinking about float for getEnvelop() and use of mapf. This will change how the servo reacts - my testing so far has been without servo attached. The current integer code may have a slightly unintentional effect of smoothing the movement of the servo due to the effective quantisation and small number of values, e.g. if value is varying between certain values with a <1.0 range these can all map to N degrees setting and servo will settle not make any small movements.
Worth testing with a real setup using a servo to see how it behaves.
@kevinjwalters Thank you for your contribution, we tested this yesterday and it works great after some parameter adjustments. Sorry for the delayed response, I am merging this now.