コード例 #1
0
ファイル: settings.c プロジェクト: AVRsteffen/grbl
int read_settings() {
  // Check version-byte of eeprom
  uint8_t version = eeprom_get_char(0);
  
  if (version == SETTINGS_VERSION) {
    // Read settings-record and check checksum
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
      return(false);
    }
  } else if (version == 1) {
    // Migrate from settings version 1
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) {
      return(false);
    }
    settings.acceleration = DEFAULT_ACCELERATION;
    settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION;
    write_settings();
  } else if ((version == 2) || (version == 3)) {
    // Migrate from settings version 2 and 3
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
      return(false);
    }
    if (version == 2) { settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION; }    
    settings.acceleration *= 3600; // Convert to mm/min^2 from mm/sec^2
    write_settings();
  } else {      
    return(false);
  }
  return(true);
}
コード例 #2
0
int read_settings() {
  // Check version-byte of eeprom
  uint8_t version = eeprom_get_char(0);

  if (version == SETTINGS_VERSION) {
    // Read settings-record and check checksum
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
      return(false);
    }
  }
  else
  if (version == 1) {
    // Migrate from settings version 1
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) {
      return(false);
    }
    settings.acceleration = DEFAULT_ACCELERATION;
    settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION;
//     settings.auto_start = DEFAULT_AUTO_START;
    write_settings();
  }
  else
  if ((version == 2) || (version == 3)) {
    // Migrate from settings version 2 and 3
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
      return(false);
    }
    if (version == 2) {
        settings.junction_deviation = DEFAULT_JUNCTION_DEVIATION;
    }
    settings.acceleration *= 3600; // Convert to mm/min^2 from mm/sec^2
//     settings.auto_start = DEFAULT_AUTO_START;
    write_settings();
  }
  else
  if (version == 4) {
     // Migrate from settings version 4
     if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
       return(false);
     }
     //settings.auto_start = DEFAULT_AUTO_START;
     settings.spindle_pwm = SPINDLE_PWM;
     settings.default_spindle = DEFAULT_SPINDLE_SPEED;
     settings.max_spindle = MAX_SPINDLE_SPEED;
     write_settings();
  }
  else
    return false;

  return true;
}
コード例 #3
0
ファイル: settings.c プロジェクト: 100takis/grbl
// Reads startup line from EEPROM. Updated pointed line string data.
uint8_t settings_read_build_info(char *line)
{
  if (!(memcpy_from_eeprom_with_checksum((char*)line, EEPROM_ADDR_BUILD_INFO, LINE_BUFFER_SIZE))) {
    // Reset line with default value
    line[0] = 0; // Empty line
    settings_store_build_info(line);
    return(false);
  }
  return(true);
}
コード例 #4
0
ファイル: settings.c プロジェクト: 100takis/grbl
// Read selected coordinate data from EEPROM. Updates pointed coord_data value.
uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data)
{
  uint32_t addr = coord_select*(sizeof(float)*N_AXIS+1) + EEPROM_ADDR_PARAMETERS;
  if (!(memcpy_from_eeprom_with_checksum((char*)coord_data, addr, sizeof(float)*N_AXIS))) {
    // Reset with default zero vector
    clear_vector_float(coord_data); 
    settings_write_coord_data(coord_select,coord_data);
    return(false);
  }
  return(true);
}  
コード例 #5
0
ファイル: settings.c プロジェクト: 100takis/grbl
// Reads startup line from EEPROM. Updated pointed line string data.
uint8_t settings_read_startup_line(uint8_t n, char *line)
{
  uint32_t addr = n*(LINE_BUFFER_SIZE+1)+EEPROM_ADDR_STARTUP_BLOCK;
  if (!(memcpy_from_eeprom_with_checksum((char*)line, addr, LINE_BUFFER_SIZE))) {
    // Reset line with default value
    line[0] = 0; // Empty line
    settings_store_startup_line(n, line);
    return(false);
  }
  return(true);
}
コード例 #6
0
int read_settings() {
  // Check version-byte of eeprom
  uint8_t version = eeprom_get_char(0);
  
  if (version == SETTINGS_VERSION) {
    // Read settings-record and check checksum
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_t)))) {
      return(FALSE);
    }
  } else if (version == 1) {
    // Migrate from old settings version
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v1_t)))) {
      return(FALSE);
    }
    settings.acceleration = DEFAULT_ACCELERATION;
    settings.max_jerk = DEFAULT_MAX_JERK;
  } else {      
    return(FALSE);
  }
  return(TRUE);
}
コード例 #7
0
ファイル: settings.c プロジェクト: rustyoz/grbl
// Reads Grbl global settings struct from EEPROM.
uint8_t read_global_settings() {
  // Check version-byte of eeprom
  uint8_t version = eeprom_get_char(0);
  if (version == SETTINGS_VERSION) {
    // Read settings-record and check checksum
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, EEPROM_ADDR_GLOBAL, sizeof(settings_t)))) {
      return(false);
    }
  } else {
    return(false); 
  }
  return(true);
}
コード例 #8
0
ファイル: settings.c プロジェクト: tiagodamian/grbl-simulator
// Reads Grbl global settings struct from EEPROM.
uint8_t read_global_settings() {
  // Check version-byte of eeprom
  uint8_t version = eeprom_get_char(0);
  
  if (version == SETTINGS_VERSION) {
    // Read settings-record and check checksum
    if (!(memcpy_from_eeprom_with_checksum((char*)&settings, EEPROM_ADDR_GLOBAL, sizeof(settings_t)))) {
      return(false);
    }
  } else {
    if (version <= 4) {
      // Migrate from settings version 4 to current version.
      if (!(memcpy_from_eeprom_with_checksum((char*)&settings, 1, sizeof(settings_v4_t)))) {
        return(false);
      }     
      settings_reset(false); // Old settings ok. Write new settings only.
    } else {      
      return(false);
    }
  }
  return(true);
}