Beispiel #1
0
struct menuinfo reset_type(FILE *cfgfile, struct menuinfo stats_menu, int vehicle)
{
// function loads the options for that type of plane

    char vehicle_str[15];       // for storing the vehicle heading (in the cfg file)
    char vehicle_number_str[3]; // for temporarily storing the vehicle number

// open the config file
    cfgfile = fopen("dogfight.cfg", "r");

// generate the vehicle heading required
    strcpy(vehicle_str, "vehicle ");
    fixed_str(vehicle_number_str, vehicle, 2);
    strcat(vehicle_str, vehicle_number_str);

    stats_menu.optionval[0] = read_value(cfgfile, '@', vehicle_str, "vehicle");
    stats_menu.optionval[1] = read_value(cfgfile, '@', vehicle_str, "turn_speed");
    stats_menu.optionval[2] = read_value(cfgfile, '@', vehicle_str, "acceleration");
    stats_menu.optionval[3] = read_value(cfgfile, '@', vehicle_str, "min_speed");
    stats_menu.optionval[4] = read_value(cfgfile, '@', vehicle_str, "max_speed");
    stats_menu.optionval[5] = read_value(cfgfile, '@', vehicle_str, "num_of_shots");
    stats_menu.optionval[6] = read_value(cfgfile, '@', vehicle_str, "shot_life");
    stats_menu.optionval[7] = read_value(cfgfile, '@', vehicle_str, "shot_lag");
    stats_menu.optionval[8] = read_value(cfgfile, '@', vehicle_str, "shot_base_speed");
    stats_menu.optionval[9] = read_value(cfgfile, '@', vehicle_str, "laser_length");

    fclose(cfgfile);

    return(stats_menu);
}
Beispiel #2
0
/* Draw the "idle" display */
void lcd_home_screen(const char *status)
{
  char buf[16];
  struct storage s;
  int32_t s_hi,s_lo;
  float tf,slf,shf;
  lcd_cmd(LCD_DISPCTL(1,0,0)); /* No cursor */
  lcd_cmd(LCD_DDADDR(ROW1));
  /* Top left is station name, up to 8 characters */
  reg_read_string(&ident,buf,9);
  var_str(buf);
  lcd_data(' ');
  /* Now current set range */
  s=reg_storage(&set_lo);
  eeprom_read_block(&s_lo,(void *)s.loc.eeprom.start,4);
  slf=s_lo/10000.0;
  s=reg_storage(&set_hi);
  eeprom_read_block(&s_hi,(void *)s.loc.eeprom.start,4);
  shf=s_hi/10000.0;
  snprintf_P(buf,16,PSTR("%0.1f-%0.1f"),(double)slf,(double)shf);
  var_str(buf);
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  lcd_data(' ');
  /* Next line */
  lcd_cmd(LCD_DDADDR(ROW2));
  if (status) {
    strncpy_P(buf,status,16);
    fixed_str(buf,16);
  } else {
    /* Bottom left is current temp, up to 5 characters */
    if (t0_temp==BAD_TEMP) {
      sprintf_P(buf,PSTR("XXXXX"));
    } else {
      tf=t0_temp/10000.0;
      snprintf_P(buf,9,PSTR("%0.1f"),(double)tf);
    }
    fixed_str(buf,5);
    lcd_data(' ');
    
    /* Current mode */
    reg_read_string(&mode,buf,9);
    fixed_str(buf,8);
    lcd_data(' ');
    /* Bottom right is valve state as 1 character */
    switch (get_valve_state()) {
    case VALVE_CLOSED:
      buf[0]='-';
      break;
    case VALVE_OPENING:
      buf[0]='O';
      break;
    case VALVE_OPEN:
      buf[0]='|';
      break;
    case VALVE_CLOSING:
      buf[0]='C';
      break;
    case VALVE_ERROR:
      buf[0]='E';
      break;
    default:
      buf[0]='?';
      break;
    }
    fixed_str(buf,1);
  }
}