How to clear a value from an #include

Hello all,

I'm new to the Arduino but have been working with PICBasic for a few years.

I'm liking the C stuff though.

My question- I'm working with the QuadratureEncoder Library Example and having good success. One thing I'm not sure about is how to clear(0) or reset the encoder count from inside my program. This is so that the next time it's called, the position will be correct regardless of where it was before.

Is it as simple as declaring the outside variable in my sketch or would that cause "havoc"? Is it a specific "C" thing I just haven't found yet? I have search the site and Google without much luck but maybe my terms haven't been correct.

I've included the piece of code in question:

   long currentEncoderCount = rotaryEncoder.getEncoderCount();
     rotaryEncoder = 0;

Thanks for you time looking at this.

Please provide a link to the documentation for the QuadratureEncoder Library

It is very unlikely that you would set the value with rotaryEncoder = 0;. Maybe there is a function something like rotaryEncoder.setEncoderCount();

...R

Understood. Kinda thought I was going down the wrong path.
Here's the link to the library. It did pull from Arduino IDE though.

I did try a few things from the Keywords text list but still get the "was not declared in this scope" error.

Post the whole code.

post the entire error message. There is a "copy error message" button (lower right of IDE window). Copy the error and paste into a new post in code tags. Paraphrasing the error message leaves out important information.

Why do you need to zero the count ?

If you need to start a new session of counting then save the count at that point in a variable with a sensible names, say startCount. At any time in the future when you read the current count subtract startCount from the current count to determine how many events have occurred

Robin2:
It is very unlikely that you would set the value with rotaryEncoder = 0;.

It's easily done by overloading the Assignment Operator. Common in OOP. Did it in My Encoder Library.

Maybe there is a function something like rotaryEncoder.setEncoderCount();

Correct. From link OP provided - QuadratureEncoder.h:

void setEncoderCount(long);

iphillipsca:
Here's the link to the library. It did pull from Arduino IDE though.

GitHub - Saeterncj/QuadratureEncoder: Arduino Quadrature Encoder

If you look at the code in the .cpp file you will see that there is a function called setEncoderCount()

...R

I did see that in the cpp. When I tried to access or use it, I would get a declaration error.

Looks very interesting, I'll check out that gfvalvo.

Also, I know it's probably better to to manage the counts myself(or buy an absolute). I was just curious on how the Sketches work in conjunction with the includes. Didn't know how much was accessible or not. Again, probably has more to do with my ignorance in C than the Arduino aspect. I will study more.

Thanks again.

iphillipsca:
I did see that in the cpp. When I tried to access or use it, I would get a declaration error.

Show us what you tried and the complete error message.

BT, to answer your question you use #UNDEF the same way ase #DEFINE

#DEFINE name John
#UNDEF name