Motorcycle Control Panel with Arduino + Bluetooth

remaining code:

int whichgear(float ratio){
  float validratios[]={
    11.7,8.37,6.65,5.54,4.61  }; 
  int maxratioindex=4; //ratios for motorcycle

  int gearsforratios[]={
    1,2,3,4,5    };
  for (int i=0;i<=maxratioindex;i++){
    if (closeto(ratio,validratios[i],5)) return gearsforratios[i];
  }
  return 0;
}

boolean closeto(float param, float reference, float pcttolerance){ //true if param is within tolerance% of reference
  return (param>=(reference*(100-pcttolerance)/100))&&(param<=(reference*(100+pcttolerance)/100));
}


void setgear(){ //determine which gear the bike is in
  int newgear; 
  static int prevgear, prev2gear;  
  if (wheelrpm!=0 && insttachrpm!=0){
    revratio=insttachrpm/wheelrpm;
    //Serial.print("<"); Serial.print(revratio); Serial.print(">");
    newgear=whichgear(revratio);
    if (newgear!=0){
      if (newgear==prevgear /*&& newgear==prev2gear*/){
        currentgear=newgear;
      //  Serial.print("Sel: "); Serial.print(newgear); Serial.print(" ");
      }
      //prev2gear=prevgear; 
      prevgear=newgear;
      //Serial.print("Candidate: "); Serial.print(newgear); Serial.print(" ");
    }
  }
}

void clearlog(){ //clear the interrupt log
  for(int i=0; i<=maxlog; i++){
    lflag[i]=' '; 
    lmillis[i]=12345678;
  }
  ilog=0; 
  logoflo=false;
}

void pbc(byte x){
  //routine to print digits 0-9 & letter N in double height characters on an LCD
  //strings to index into for displaying the big numbers
  char bignumchars1[]={
    32,32,32,0, 1,4,32,0, 3,3,4,0, 1,3,4,0, 4,2,4,0,   4,3,3,0, 4,3,3,0, 1,1,4,0,   4,3,4,0, 4,3,4,0, 4,6,4,0  }; //0 was 4,4,4
  char bignumchars2[]={
    32,32,32,0, 2,4,2,0,  4,2,2,0, 2,2,4,0, 32,32,4,0, 2,2,4,0, 4,2,4,0, 32,32,4,0, 4,2,4,0, 2,2,4,0, 4,7,4,0  }; //0 was 4,2,4
  lcd.setCursor(0,0);
  lcd.print(bignumchars1+x*4);
  lcd.setCursor(0,1);
  lcd.print(bignumchars2+x*4);
}
void setupbigchars(){
  //routine to load the character generator ram on an lcd controller with block characters
  //credit to dcb on arduino forums http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213319639
  lcd.command(B01001000);  // set cgram
  byte chars[]={
    B11111,B00000,B11111,B11111,B00000,B00000,B01110,
    B11111,B00000,B11111,B11111,B00000,B11000,B00111,
    B00000,B00000,B00000,B11111,B00000,B11000,B00111,
    B00000,B00000,B00000,B11111,B00000,B11000,B00111,
    B00000,B00000,B00000,B11111,B00000,B11100,B00011,
    B00000,B00000,B00000,B11111,B01110,B11100,B00011,
    B00000,B11111,B11111,B11111,B01110,B11100,B00011,
    B00000,B11111,B11111,B11111,B01110,B01110,B00000  };

  for(byte x=0;x<7;x++)
    for(byte y=0;y<8;y++)
      lcd.write(chars[y*7+x]); //write the character data to the character generator ram    
}

void lcdbegin(){
  delay(25); //make sure there's a clear delay for lcd power-on initialization
  lcd.command(0x28);  // function set: 4 bits, 1 line, 5x8 dots
  lcd.command(0x0C);  // display control: turn display on, cursor off, no blinking
  lcd.command(0x06);  // entry mode set: increment automatically, display shift, right shift
  lcd.clear();delay(5);
  lcd.print("V8 Bill!"); delay(250); lcd.clear(); delay(5);
  setupbigchars();delay(25); //write big fonts to lcd cgram
}