Josh, It is possible to use OOP in C, we've been doing it at our company for abou= t 7 years. Search the archives, I posted some details on our implementation, a few yea= rs ago. Basically, it boils down to (1) using naming conventions to emulate OOP, an= d (2) using aggregation instead of inheritance. You can quickly get in trouble if you try to emulate inheritance/method ove= rloading in C. The good news is, you can reap the benefits of OOP without i= t. Sent from my phone > On Mar 19, 2015, at 10:21, Josh Koffman wrote: >=20 > Hi all, >=20 > So as you may have guessed, I'm working on some rotary encoder routines i= n XC8. >=20 > I've been looking around, and I've actually found a pretty neat > Arduino library. It handles the encoder, acceleration (values change > faster if you spin faster), encoder switch status (click, double > click, held, etc). I'm considering trying to port it to XC8 as I think > it would be useful, but also a really good exercise in coding. >=20 > I have no Arduino experience, but from what I've been reading, it > appears that in their ecosystem you can define multiple instances of a > class. So in my case if I made one routine that dealt with a single > encoder, I could create 2 instances to deal with 2 encoders, etc. As > far as I understand it, I can't do that in straight C. >=20 > So, what is the preferred way of dealing with this? I could make the > original function deal with total number of encoders that I have. Or I > could make multiple copies of a function that dealt with a single > encoder. In both cases I'll need to deal with variables carefully. >=20 > Is there another (possibly better) way? I'm interested in this in the > abstract as eventually I will likely run into this situation with > other routines (switch debounce, for instance). >=20 > Thanks! >=20 > Josh > --=20 > A common mistake that people make when trying to design something > completely foolproof is to underestimate the ingenuity of complete > fools. > -Douglas Adams > --=20 > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .