+# NOTE Lines must not exceed 132 characters
# Robot module configurations : general handling of movement G-codes and slicing into moves
default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves
default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves
-mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation
-mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ).
+mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for
+ # these segments. Smaller values mean more resolution,
+ # higher values mean faster computation
+mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian
+ # coordinates robots ).
# Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions
alpha_steps_per_mm 80 # Steps per mm for alpha stepper
gamma_steps_per_mm 1600 # Steps per mm for gamma stepper
# Planner module configuration : Look-ahead and acceleration configuration
-planner_queue_size 32 # Size of the planning queue DO NOT CHANGE THIS UNLESS YOU KNOW EXACLTY WHAT YOU ARE DOING
+planner_queue_size 32 # DO NOT CHANGE THIS UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING
acceleration 3000 # Acceleration in mm/second/second.
acceleration_ticks_per_second 1000 # Number of times per second the speed is updated
-junction_deviation 0.05 # Similar to the old "max_jerk", in millimeters, see : https://github.com/grbl/grbl/blob/master/planner.c#L409
- # and https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.8 . Lower values mean being more careful, higher values means being faster and have more jerk
+junction_deviation 0.05 # Similar to the old "max_jerk", in millimeters,
+ # see https://github.com/grbl/grbl/blob/master/planner.c#L409
+ # and https://github.com/grbl/grbl/wiki/Configuring-Grbl-v0.8
+ # Lower values mean being more careful, higher values means being
+ # faster and have more jerk
#minimum_planner_speed 0.0 # sets the minimum planner speed in mm/sec
# Stepper module configuration
# Serial communications configuration ( baud rate default to 9600 if undefined )
uart0.baud_rate 115200 # Baud rate for the default hardware serial port
-second_usb_serial_enable false # This enables a second usb serial port (to have both pronterface and a terminal connected)
+second_usb_serial_enable false # This enables a second usb serial port (to have both pronterface
+ # and a terminal connected)
#leds_disable true # disable using leds after config loaded
# Extruder module configuration
-extruder_module_enable true # Whether to activate the extruder module at all. All configuration is ignored if false
+extruder_module_enable true # Whether to activate the extruder module at all. All configuration
+ # is ignored if false
extruder_steps_per_mm 140 # Steps per mm for extruder stepper
extruder_default_feed_rate 600 # Default rate ( mm/minute ) for moves where only the extruder moves
extruder_acceleration 50 # Acceleration for the stepper motor, as of 0.6, arbitrary ratio
delta_current 1.5 # Extruder stepper motor current
# Laser module configuration
-laser_module_enable false # Whether to activate the laser module at all. All configuration is ignored if false.
-#laser_module_pin 2.5 # this pin will be PWMed to control the laser. Only P2.0 - P2.5 can be used since laser requires hardware PWM
-#laser_module_max_power 0.8 # this is the maximum duty cycle that will be applied to the laser
-#laser_module_tickle_power 0.0 # this duty cycle will be used for travel moves to keep the laser active without actually burning
-#laser_module_pwm_period 20 # this sets the pwm frequency, the value is the period in microseconds
+laser_module_enable false # Whether to activate the laser module at all. All configuration is
+ # ignored if false.
+#laser_module_pin 2.5 # this pin will be PWMed to control the laser. Only P2.0 - P2.5
+ # can be used since laser requires hardware PWM
+#laser_module_max_power 0.8 # this is the maximum duty cycle that will be applied to the laser
+#laser_module_tickle_power 0.0 # this duty cycle will be used for travel moves to keep the laser
+ # active without actually burning
+#laser_module_pwm_period 20 # this sets the pwm frequency as the period in microseconds
# Hotend temperature control configuration
-temperature_control.hotend.enable true # Whether to activate this ( "hotend" ) module at all. All configuration is ignored if false.
+temperature_control.hotend.enable true # Whether to activate this ( "hotend" ) module at all.
+ # All configuration is ignored if false.
temperature_control.hotend.thermistor_pin 0.23 # Pin for the thermistor to read
temperature_control.hotend.heater_pin 2.7 # Pin that controls the heater
-temperature_control.hotend.thermistor EPCOS100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64 for a list of valid thermistor names
+temperature_control.hotend.thermistor EPCOS100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64
+ # for a list of valid thermistor names
temperature_control.hotend.set_m_code 104 #
temperature_control.hotend.set_and_wait_m_code 109 #
temperature_control.hotend.designator T #
#temperature_control.hotend.i_factor 0.097 #
#temperature_control.hotend.d_factor 24 #
-#temperature_control.hotend.max_pwm 64 # override max pwm, 64 is a good value if driving a 12v resistor with 24v.
+#temperature_control.hotend.max_pwm 64 # max pwm, 64 is a good value if driving a 12v resistor with 24v.
temperature_control.bed.enable true #
temperature_control.bed.thermistor_pin 0.24 #
temperature_control.bed.heater_pin 2.5 #
-temperature_control.bed.thermistor Honeywell100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64 for a list of valid thermistor names
+temperature_control.bed.thermistor Honeywell100K # see src/modules/tools/temperaturecontrol/TemperatureControl.cpp:64
+ # for a list of valid thermistor names
temperature_control.bed.set_m_code 140 #
temperature_control.bed.set_and_wait_m_code 190 #
temperature_control.bed.designator B #
-#temperature_control.bed.bang_bang false # set to true to use bang bang control rather than PID
-#temperature_control.bed.hysteresis 2.0 # set to the temperature in degrees C to use as hysteresis when using bang bang
+#temperature_control.bed.bang_bang false # set to true to use bang bang control rather than PID
+#temperature_control.bed.hysteresis 2.0 # set to the temperature in degrees C to use as hysteresis
+ # when using bang bang
# Switch module for fan control
switch.fan.enable true #
# Panel
panel.enable false # set to true to enable the panel code
-panel.lcd smoothiepanel # set type of panel also viki_lcd, i2c_lcd is a generic i2c panel, panelolu2
+panel.lcd smoothiepanel # set type of panel
panel.encoder_a_pin 3.25!^ # encoder pin
panel.encoder_b_pin 3.26!^ # encoder pin
using namespace std;
#include <string>
-#include <fstream>
-#include <stdio.h>
+#include <string.h>
FileConfigSource::FileConfigSource(string config_file, const char *name)
{
this->config_file_found = false;
}
+bool FileConfigSource::readLine(string& line, FILE *fp)
+{
+ char buf[132];
+ char *l= fgets(buf, sizeof(buf)-1, fp);
+ if(l != NULL) {
+ if(buf[strlen(l)-1] != '\n') {
+ // truncate long lines
+ printf("Truncated long line in: %s\n", config_file.c_str());
+ // read until the next \n or eof
+ int c;
+ while((c=fgetc(fp)) != '\n' && c != EOF) /* discard */;
+ }
+ line.assign(buf);
+ return true;
+ }
+
+ return false;
+}
+
// Transfer all values found in the file to the passed cache
void FileConfigSource::transfer_values_to_cache( ConfigCache *cache )
{
-
if( !this->has_config_file() ) {
return;
}
// Open the config file ( find it if we haven't already found it )
- std::ifstream ifs(this->get_config_file().c_str(), std::ifstream::in);
+ FILE *lp = fopen(this->get_config_file().c_str(), "r");
+
// For each line
- string line;
- while(ifs.good()) {
- std::getline(ifs, line);
- process_line_from_ascii_config(line, cache);
+ while(!feof(lp)) {
+ string line;
+ if(readLine(line, lp)) {
+ process_line_from_ascii_config(line, cache);
+ }else break;
}
- ifs.close();
+ fclose(lp);
}
// Return true if the check_sums match
}
// Open the config file ( find it if we haven't already found it )
- std::ifstream ifs(this->get_config_file().c_str(), std::ifstream::in);
+ FILE *lp = fopen(this->get_config_file().c_str(), "r");
// For each line
- string line;
- while(ifs.good()) {
- std::getline(ifs, line);
- value = process_line_from_ascii_config(line, check_sums);
- if(!value.empty()) break; // found it
+ while(!feof(lp)) {
+ string line;
+ if(readLine(line, lp)) {
+ value = process_line_from_ascii_config(line, check_sums);
+ if(!value.empty()) break; // found it
+ }else break;
}
- ifs.close();
+ fclose(lp);
return value;
}