Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Floating point math #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ShuzzDE
Copy link

@ShuzzDE ShuzzDE commented Jun 13, 2017

I modified the portions of the code using float math.
Rewriting it to use (unsigned) longs instead makes the resulting binary around 500 Bytes smaller.
While this may not seem much on most Arduinos, it really does make a difference when compiling for things like e.g. a DigiSpark or directly for other ATtiny controllers.

Code was tested on Arduino Uno and Digispark. No problems found.

This should reduce size of compiled sketch by around 500 byte or so.
+ loopTimingFactor is now a simple long so we don't need to cast for floating point fix.
+ set_CS_Timeout_Millis() now takes long argument instead of unsigned long.
@batizisanya
Copy link

With theese changes i get -2.

@ShuzzDE
Copy link
Author

ShuzzDE commented Jun 24, 2017

-2?
Sorry, I don't understand what you mean...

@batizisanya
Copy link

batizisanya commented Jun 24, 2017

capacitiveSensor and capacitiveSensorRaw will return -2 if the methods timeout. This is caused by the count exceeding the value of CS_Timeout_Millis, which is set at a default value of 2000 milliseconds (2 seconds). This is most often caused by a missing resistor or the resistor in the wrong pin. It could also be caused by a sensor that is grounded or connected to +5 V. (http://playground.arduino.cc/Main/CapacitiveSensor)

I tried first with the original lib (that worked), then tried the modified lib with your changes and i got -2 (timeout)

@ShuzzDE
Copy link
Author

ShuzzDE commented Jun 26, 2017

Ah, ok, I see.
Has not happened during my testing and the code is running in several projects around my home.
Are you sure it's not a coincidental hardware issue?

If so, maybe I overlooked something. Can you maybe post your code so I can get a better idea of what might be going wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants