int whatTheHellDirectionIsTheWindBlowingNow() { PTRType test; int n; test.PD7 = ISHIGH(7, PORTD); test.PD6 = ISHIGH(6, PORTD); test.PD5 = ISHIGH(5, PORTD); test.PD4 = ISHIGH(4, PORTD); test.PC2 = ISHIGH(2, PORTC); test.PC3 = ISHIGH(3, PORTC); test.PC4 = ISHIGH(4, PORTC); test.PC5 = ISHIGH(5, PORTC); for (n = 0; n < 32; n++) { if( stateTable[n].state == test ) { return stateTable[n].next; } } return -1 // we dont know!? }