 double freq = 0 ;  // this is a variable (changes) - set it to the beginning of the band
 double freqDelta = 10000; // how much to change the frequency by, clicking the rotary encoder will change this.
 
-byte counter = 0;
+byte spinDirection = 0; // rotary encoder spun ccw (-1), cw (1), or no change (0)
 
 long lastClick = 0;
 long lastBlink = 0;

  int freqCursorPosition = 4;
  
  // change freq dependent on rotary encoder spin direction
  if(counter != 0) {
    if (counter == 1) {
      freq=constrain(freq-freqDelta,bandStart,bandEnd);
    } else {
      freq=constrain(freq+freqDelta,bandStart,bandEnd);
    }
    counter = 0;
    display_frequency(freq); // push the frequency to LCD display
    send_frequency(freq);  // set the DDS to the new frequency  
  }

  encval += pgm_read_byte(&(enc_states[( old_AB & 0x0f )]));
  
  if( encval > 3 ) {  //four steps forward
    spinDirection = 1;
    encval = 0;
  }
  else if( encval < -3 ) {  //four steps backwards
   spinDirection = 2;
   encval = 0;
  } 
}
