On Mon, Jun 10, 2013 at 8:50 PM, Joe Wronski w= rote: > On 6/10/2013 10:55 AM, Manu Abraham wrote: >> On Mon, Jun 10, 2013 at 8:07 PM, Joe Wronski wrote: >>> On 6/10/2013 10:03 AM, Manu Abraham wrote: >>>> One thing that I don't understand is, why he does this: " static >>>> uint8_t old_AB =3D 0;" that would loose the previous state altogether, >>>> wouldn't it ? >>> No, the "=3D0" is only assigned when the static old_AB is allocated and >>> initialized, after that, it retains it's value as set by the "old_AB = =3D" >>> assignments in read_encoder() >> >> Please note the next line: >> >> >> static uint8_t old_AB =3D 0; >> /**/ >> old_AB <<=3D 2; //remember previous state >> >> Once you initialize the variable to 0, then there is no way that it >> can remember >> the previous state. >> > I can't find my K&R book right now, but this should clear that idea up: > > > > In func() there is this line: > > static int x=3D 0; // x is initialized only once across three calls o= f func() > ugh, Right. He could've used the variable in global scope instead.. But, still the issue persists that the increments are in the order of 4, decrements too.. Regards, Manu --=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 .