diff --git a/A10/Marlin/BlinkM.cpp b/A10/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/A10/Marlin/BlinkM.cpp +++ b/A10/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/A10/Marlin/Configuration.h b/A10/Marlin/Configuration.h index e008e791..a7bf5703 100644 --- a/A10/Marlin/Configuration.h +++ b/A10/Marlin/Configuration.h @@ -97,7 +97,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -239,15 +239,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -464,9 +464,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -669,7 +669,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -767,9 +767,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -786,7 +786,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY diff --git a/A10/Marlin/ConfigurationStore.cpp b/A10/Marlin/ConfigurationStore.cpp index 2e4377b5..c2c22ee6 100644 --- a/A10/Marlin/ConfigurationStore.cpp +++ b/A10/Marlin/ConfigurationStore.cpp @@ -7,7 +7,7 @@ extern char uuid_sn[17]; extern char uuid_hw[6]; - + extern unsigned int Z_t,T0_t,B_t; extern uint32_t pos_t,E_t; @@ -52,13 +52,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -136,7 +136,7 @@ void Config_StoreSettings() // tmp_d[0]=uuid_sn[0]; // sprintf_P(tmp_n,PSTR("==Z%d,Z%d=="),Recover_print.Z_t,uuid_sn[0]); // SERIAL_ECHOLN(tmp_d); - + EEPROM_WRITE_VAR(i,Z_t); EEPROM_WRITE_VAR(i,E_t); EEPROM_WRITE_VAR(i,pos_t); @@ -148,7 +148,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -166,7 +166,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -175,42 +175,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -239,19 +239,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -278,11 +278,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -309,12 +309,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -344,7 +344,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -383,8 +383,8 @@ void Config_RetrieveSettings() //EEPROM_READ_VAR(i,uuid_hw); //char *tmp_d; // tmp_d=(char *)(&Recover_print); - - + + EEPROM_READ_VAR(i,Z_t); EEPROM_READ_VAR(i,E_t); EEPROM_READ_VAR(i,pos_t); @@ -392,8 +392,8 @@ void Config_RetrieveSettings() EEPROM_READ_VAR(i,B_t); EEPROM_READ_VAR(i,recovery); EEPROM_READ_VAR(i,P_file_name); - - + + calculate_volumetric_multipliers(); // Call updatePID (similar to when we have processed M301) updatePID(); @@ -415,23 +415,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -462,10 +462,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/A10/Marlin/DOGMbitmaps.h b/A10/Marlin/DOGMbitmaps.h index 5c7f594b..df713bab 100644 --- a/A10/Marlin/DOGMbitmaps.h +++ b/A10/Marlin/DOGMbitmaps.h @@ -1,6 +1,6 @@ // BitMap for splashscreen // Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php -// Please note that using the high-res version takes 402Bytes of PROGMEM. +// Please note that using the high-res version takes 402Bytes of PROGMEM. //#define START_BMPHIGH #ifdef START_BMPHIGH @@ -8,7 +8,7 @@ #define START_BMPHEIGHT 38 #define START_BMPBYTEWIDTH 14 #define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8 - + const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff @@ -49,11 +49,11 @@ ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 ,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80 }; #else - #ifdef GEEETECH_STARTUP_BMP + #ifdef GEEETECH_STARTUP_BMP #define START_BMPWIDTH 128 #define START_BMPHEIGHT 64 #define START_BMPBYTEWIDTH 16 - #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 + #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -187,7 +187,7 @@ #else - #define START_BMPWIDTH 56 + #define START_BMPWIDTH 56 #define START_BMPHEIGHT 19 #define START_BMPBYTEWIDTH 7 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 @@ -215,10 +215,10 @@ #endif #endif -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -371,6 +371,6 @@ 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/A10/Marlin/LiquidCrystalRus.cpp b/A10/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/A10/Marlin/LiquidCrystalRus.cpp +++ b/A10/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/A10/Marlin/LiquidCrystalRus.h b/A10/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/A10/Marlin/LiquidCrystalRus.h +++ b/A10/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/A10/Marlin/MarlinSerial.cpp b/A10/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/A10/Marlin/MarlinSerial.cpp +++ b/A10/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/A10/Marlin/MarlinSerial.h b/A10/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/A10/Marlin/MarlinSerial.h +++ b/A10/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -322,9 +322,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -334,19 +334,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -635,7 +635,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -657,21 +657,21 @@ void setup() if(recovery==3) { lcd_resume_menu() ; - + //return; } // uint32_t tmpd=197267; // sprintf(tmp_y,"recoverytmpd:%lu",tmpd); - + // SERIAL_ECHOLN(tmp_y); } - + void loop() -{ - - +{ + + if(buflen < (BUFSIZE-1)) get_command(); #ifdef SDSUPPORT @@ -715,7 +715,7 @@ void loop() if((buflen==0)&&(recovery==1)) { ////////////////// - + sprintf_P(tmp_y,PSTR("M190 S%u"),B_t); SERIAL_ECHOLN(tmp_y); enquecommand(tmp_y); @@ -740,9 +740,9 @@ void loop() if((buflen==0)&&(recovery==2)) { ////////////////// - + sprintf(tmp_y,"M32 S%lu !%s",pos_t,P_file_name); - + enquecommand(tmp_y); SERIAL_ECHOLN(tmp_y); ////////////// @@ -752,7 +752,7 @@ void loop() enquecommand(tmp_y);*/ ////////////// recovery=0; - } + } manage_heater(); manage_inactivity(); checkHitEndstops(); @@ -852,7 +852,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -1027,45 +1027,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1393,9 +1393,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1416,7 +1416,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1518,7 +1518,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1951,11 +1951,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2140,10 +2140,10 @@ void process_commands() card.openLogFile(strchr_pointer+5); break; case 929: //M928 - Start SD write - - - - + + + + Z_t=current_position[Z_AXIS]*10; E_t=current_position[E_AXIS]; pos_t=card.getStatus(); @@ -2165,24 +2165,24 @@ void process_commands() card.write_command(tmp_d); card.closefile(false); SERIAL_ECHOLN(tmp_d);*/ - + break; case 930: //M928 - Start SD write char tmp_n[64+10]; - /* + /* card.openFile("recovery.txt",true); - + char *st_start,*st_end; - int16_t n; + int16_t n; char i; for(i=0;i<64+10;i++) { n=card.get(); tmp_n[i]=n; - // if(tmp_n[i]=='\n') + // if(tmp_n[i]=='\n') // break; } - + card.closefile(false); SERIAL_ECHOLN(tmp_n); st_start=tmp_n; @@ -2191,28 +2191,28 @@ void process_commands() Z_t=atoi(st_start); ///////////// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); //st_end='\0'; //SERIAL_ECHOLN(st_start+3); E_t=atoi(st_start+1); //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); pos_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); T0_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); B_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+3, ','); + st_end = strchr(st_start+3, ','); *st_end='\0'; sprintf_P(card.file_name_t,PSTR("%s"),st_start+3); //// @@ -2222,7 +2222,7 @@ void process_commands() SERIAL_ECHOLN("=e=="); SERIAL_ECHOLN(P_file_name); recovery=1; - + sprintf_P(tmp_n,PSTR("G92 Z%d.%d"),Z_t/10,Z_t%10); SERIAL_ECHOLN(tmp_n); enquecommand(tmp_n); @@ -2236,9 +2236,9 @@ void process_commands() SERIAL_ECHOLN(tmp_n); enquecommand(tmp_n); ////////////// - - - break; + + + break; #endif //SDSUPPORT case 31: //M31 take time since the start of the SD print or an M109 command @@ -2287,7 +2287,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2299,7 +2299,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2307,14 +2307,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2342,7 +2342,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2363,7 +2363,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2385,10 +2385,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2402,12 +2402,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2434,7 +2434,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2477,7 +2477,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2489,7 +2489,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2499,7 +2499,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2521,15 +2521,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2554,7 +2554,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2743,7 +2743,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2960,13 +2960,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -3130,7 +3130,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -3174,7 +3174,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -3185,7 +3185,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3435,14 +3435,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3509,7 +3509,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3527,7 +3527,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3544,7 +3544,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3561,7 +3561,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3577,21 +3577,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3616,64 +3616,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3701,7 +3701,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -4086,12 +4086,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -4185,13 +4185,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4206,9 +4206,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4244,7 +4244,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4268,7 +4268,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4276,13 +4276,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4308,7 +4308,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4434,70 +4434,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4542,7 +4542,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4552,8 +4552,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4573,7 +4573,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4581,9 +4581,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4625,7 +4625,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4682,12 +4682,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/A10/Marlin/Sd2Card.h b/A10/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/A10/Marlin/Sd2Card.h +++ b/A10/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/A10/Marlin/SdBaseFile.cpp b/A10/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/A10/Marlin/SdBaseFile.cpp +++ b/A10/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/A10/Marlin/SdFatStructs.h b/A10/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/A10/Marlin/SdFatStructs.h +++ b/A10/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/A10/Marlin/SdFile.h b/A10/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/A10/Marlin/SdFile.h +++ b/A10/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/A10/Marlin/Servo.cpp b/A10/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/A10/Marlin/Servo.cpp +++ b/A10/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/A10/Marlin/cardreader.cpp b/A10/Marlin/cardreader.cpp index 513a8720..2af5772b 100644 --- a/A10/Marlin/cardreader.cpp +++ b/A10/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -553,17 +553,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -573,7 +573,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -591,10 +591,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; @@ -649,4 +649,4 @@ void CardReader::printingHasFinished() autotempShutdown(); } } -#endif //SDSUPPORT +#endif //SDSUPPORT diff --git a/A10/Marlin/cardreader.h b/A10/Marlin/cardreader.h index ce570b41..e4977e36 100644 --- a/A10/Marlin/cardreader.h +++ b/A10/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -72,10 +72,10 @@ class CardReader uint32_t filesize; //int16_t n; unsigned long autostart_atmillis; - + bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -85,7 +85,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) @@ -100,4 +100,4 @@ extern CardReader card; #define IS_SD_PRINTING (false) #endif //SDSUPPORT -#endif +#endif diff --git a/A10/Marlin/dogm_font_data_marlin.h b/A10/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/A10/Marlin/dogm_font_data_marlin.h +++ b/A10/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/A10/Marlin/dogm_lcd_implementation.h b/A10/Marlin/dogm_lcd_implementation.h index 1d9f1636..720b09f6 100644 --- a/A10/Marlin/dogm_lcd_implementation.h +++ b/A10/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,17 +117,17 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp #ifdef GEEETECH_STARTUP_BMP - u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); + u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); #else u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -151,7 +151,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -192,12 +192,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -206,10 +206,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -218,7 +218,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -231,7 +231,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -243,7 +243,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -253,8 +253,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -278,7 +278,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -305,23 +305,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -335,7 +335,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -344,7 +344,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/A10/Marlin/fastio.h b/A10/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/A10/Marlin/fastio.h +++ b/A10/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/A10/Marlin/language.h b/A10/Marlin/language.h index 1d96b0e4..52cce133 100644 --- a/A10/Marlin/language.h +++ b/A10/Marlin/language.h @@ -109,7 +109,7 @@ #define MSG_HEATING_COMPLETE "Heating done." #define MSG_BED_HEATING "Bed Heating." #define MSG_BED_DONE "Bed done." -#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" +#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" #define MSG_COUNT_X " Count X: " #define MSG_ERR_KILLED "Printer halted. kill() called!" #define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" @@ -157,4 +157,4 @@ #include LANGUAGE_INCLUDE -#endif //__LANGUAGE_H +#endif //__LANGUAGE_H diff --git a/A10/Marlin/motion_control.cpp b/A10/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/A10/Marlin/motion_control.cpp +++ b/A10/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -139,8 +139,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -148,8 +148,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -159,7 +159,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -172,12 +172,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -196,10 +196,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -222,7 +222,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -240,16 +240,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -259,8 +259,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -274,7 +274,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -284,22 +284,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -310,8 +310,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -332,11 +332,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -349,8 +349,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -381,22 +381,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -462,7 +462,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -497,7 +497,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -537,7 +537,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -549,12 +549,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -568,7 +568,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -580,7 +580,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -618,8 +618,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -628,34 +628,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -684,37 +684,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -725,15 +725,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -769,7 +769,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -786,7 +786,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -794,25 +794,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -825,12 +825,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -852,7 +852,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -954,11 +954,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -970,13 +970,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -993,11 +993,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1014,12 +1014,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1073,8 +1073,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1085,7 +1085,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/A10/Marlin/planner.h b/A10/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/A10/Marlin/planner.h +++ b/A10/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/A10/Marlin/qr_solve.cpp b/A10/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/A10/Marlin/qr_solve.cpp +++ b/A10/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/A10/Marlin/qr_solve.h b/A10/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/A10/Marlin/qr_solve.h +++ b/A10/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/A10/Marlin/speed_lookuptable.h b/A10/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/A10/Marlin/speed_lookuptable.h +++ b/A10/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/A10/Marlin/stepper.cpp b/A10/Marlin/stepper.cpp index f395bfec..e3477390 100644 --- a/A10/Marlin/stepper.cpp +++ b/A10/Marlin/stepper.cpp @@ -318,17 +318,17 @@ FORCE_INLINE void trapezoid_generator_reset() { // It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately. ISR(TIMER1_COMPA_vect) { - + if((digitalRead(A0)==0)&&(P_file_name[0])&&(recovery==0)) { SERIAL_ECHOLN("Down"); // enquecommand("M929"); char tmp_d[32]; - + Z_t=current_position[Z_AXIS]*10; E_t=current_position[E_AXIS]; pos_t=card.getStatus(); - + T0_t=degTargetHotend(0); B_t=degTargetBed(); recovery=3; @@ -338,7 +338,7 @@ ISR(TIMER1_COMPA_vect) SERIAL_ECHOLN(tmp_d); sprintf_P(tmp_d,PSTR("%s,"),P_file_name); SERIAL_ECHOLN(tmp_d); - + } // If there is no current block, attempt to pop one from the buffer if (current_block == NULL) { @@ -390,7 +390,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -407,25 +407,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -460,9 +460,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -512,7 +512,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -613,7 +613,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -651,9 +651,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -673,15 +673,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -690,7 +690,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -698,7 +698,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -861,7 +861,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -896,7 +896,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1126,17 +1126,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1158,17 +1158,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1188,7 +1188,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1199,8 +1199,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1227,25 +1227,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1256,7 +1256,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1315,12 +1315,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/A10/Marlin/stepper.h b/A10/Marlin/stepper.h index 6ca0c2cf..86ac5f82 100644 --- a/A10/Marlin/stepper.h +++ b/A10/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -71,7 +71,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -96,7 +96,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/A10/Marlin/temperature.cpp b/A10/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/A10/Marlin/temperature.cpp +++ b/A10/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/A10/Marlin/temperature.h b/A10/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/A10/Marlin/temperature.h +++ b/A10/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/A10/Marlin/thermistortables.h b/A10/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/A10/Marlin/thermistortables.h +++ b/A10/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/A10/Marlin/ultralcd.cpp b/A10/Marlin/ultralcd.cpp index dfc600c3..e6159b41 100644 --- a/A10/Marlin/ultralcd.cpp +++ b/A10/Marlin/ultralcd.cpp @@ -209,17 +209,17 @@ float raw_Ki, raw_Kd; } } -void lcd_resume_menu_ok(void) +void lcd_resume_menu_ok(void) { char tmp_n[64+10]; recovery=0; // Config_StoreSettings(); //Config_RetrieveSettings(); lcd_goto_menu(lcd_status_screen); - // enquecommand("M930"); + // enquecommand("M930"); SERIAL_ECHOLN(P_file_name); recovery=1; - + sprintf_P(tmp_n,PSTR("G92 Z%u.%u"),Z_t/10,Z_t%10); SERIAL_ECHOLN(tmp_n); enquecommand(tmp_n); @@ -234,23 +234,23 @@ void lcd_resume_menu_ok(void) enquecommand(tmp_n); ////////////// } -void lcd_resume_menu_cancel(void) +void lcd_resume_menu_cancel(void) { recovery=0; //Config_StoreSettings(); //Config_RetrieveSettings(); lcd_goto_menu(lcd_status_screen, 0, false); - - + + } -void lcd_resume_menu0(void) +void lcd_resume_menu0(void) { START_MENU(); ////////// MENU_ITEM(submenu, "", lcd_resume_menu0); lcd.setCursor(0,0); lcd.print("Resume print ? "); - + MENU_ITEM(submenu, "", lcd_resume_menu_ok); lcd.setCursor(1,1); lcd.print("Yes "); @@ -264,15 +264,15 @@ void lcd_resume_menu0(void) -void lcd_resume_menu(void) +void lcd_resume_menu(void) { - + lcd_goto_menu(lcd_resume_menu0); } /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ static void lcd_status_screen() { - + #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) uint16_t mil = millis(); #ifndef PROGRESS_MSG_ONCE @@ -415,14 +415,14 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:" VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -430,12 +430,12 @@ static void lcd_about_menu() lcd.print("No SN"); else { - + lcd.print("SN:"); lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -480,13 +480,13 @@ static void lcd_main_menu() } #endif #ifdef LIGHT_SUPPORT - if(light_level>0) - { + if(light_level>0) + { light_level = 0; MENU_ITEM(function, MSG_LIGHT_OFF, light_ctrl); light_level = LIGHT_LEVEL; } - else + else { light_level = LIGHT_LEVEL; MENU_ITEM(function, MSG_LIGHT_ON, light_ctrl); @@ -1669,7 +1669,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/A10/Marlin/ultralcd.h b/A10/Marlin/ultralcd.h index f575424a..14c9fc2a 100644 --- a/A10/Marlin/ultralcd.h +++ b/A10/Marlin/ultralcd.h @@ -45,13 +45,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -92,7 +92,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/A10/Marlin/ultralcd_st7920_u8glib_rrd.h b/A10/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/A10/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/A10/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/A10/Marlin/vector_3.cpp b/A10/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/A10/Marlin/vector_3.cpp +++ b/A10/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/A10/Marlin/vector_3.h b/A10/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/A10/Marlin/vector_3.h +++ b/A10/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/A10/Marlin/watchdog.cpp b/A10/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/A10/Marlin/watchdog.cpp +++ b/A10/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/A10/Marlin_main.cpp b/A10/Marlin_main.cpp index 07bc45d1..e94a5519 100644 --- a/A10/Marlin_main.cpp +++ b/A10/Marlin_main.cpp @@ -162,9 +162,9 @@ extern char uuid_hw[6]; // M401 - Lower z-probe if present // M402 - Raise z-probe if present // M404 - N Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -314,9 +314,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -326,19 +326,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -618,7 +618,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -680,7 +680,7 @@ void loop() if((buflen==0)&&(recovery==1)) { ////////////////// - + sprintf_P(tmp_y,PSTR("M190 S%d"),B_t); SERIAL_ECHOLN(tmp_y); enquecommand(tmp_y); @@ -716,7 +716,7 @@ void loop() enquecommand(tmp_y);*/ ////////////// recovery=0; - } + } } //check heater every n milliseconds manage_heater(); @@ -818,7 +818,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -993,45 +993,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1359,9 +1359,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1382,7 +1382,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1484,7 +1484,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1917,11 +1917,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2106,10 +2106,10 @@ void process_commands() card.openLogFile(strchr_pointer+5); break; case 929: //M928 - Start SD write - - + + char tmp_d[64+10]; - + Z_t=current_position[Z_AXIS]*10; E_t=current_position[E_AXIS]; pos_t=card.getStatus(); @@ -2126,20 +2126,20 @@ void process_commands() SERIAL_ECHOLN(tmp_d); break; case 930: //M928 - Start SD write - + card.openFile("recovery.txt",true); char tmp_n[64+10]; char *st_start,*st_end; - int16_t n; + int16_t n; char i; for(i=0;i<64+10;i++) { n=card.get(); tmp_n[i]=n; - // if(tmp_n[i]=='\n') + // if(tmp_n[i]=='\n') // break; } - + card.closefile(false); SERIAL_ECHOLN(tmp_n); st_start=tmp_n; @@ -2148,38 +2148,38 @@ void process_commands() Z_t=atoi(st_start); ///////////// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); //st_end='\0'; //SERIAL_ECHOLN(st_start+3); E_t=atoi(st_start+1); //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); pos_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); T0_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+1, ','); + st_end = strchr(st_start+1, ','); B_t=atoi(st_start+1); //// //// st_start=st_end; - st_end = strchr(st_start+3, ','); + st_end = strchr(st_start+3, ','); *st_end='\0'; sprintf_P(card.file_name_t,PSTR("%s"),st_start+3); //// - + //sprintf_P(tmp_n,PSTR("ppppp Z%d,E%d,P%d,T%d,B%d, =="),Z_t,E_t,pos_t,T0_t,B_t); ////////////////// SERIAL_ECHOLN("===="); SERIAL_ECHOLN(card.file_name_t); recovery=1; - + sprintf_P(tmp_n,PSTR("G92 Z%d.%d"),Z_t/10,Z_t%10); SERIAL_ECHOLN(tmp_n); enquecommand(tmp_n); @@ -2193,9 +2193,9 @@ void process_commands() SERIAL_ECHOLN(tmp_n); enquecommand(tmp_n); ////////////// - - - break; + + + break; #endif //SDSUPPORT case 31: //M31 take time since the start of the SD print or an M109 command @@ -2244,7 +2244,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2256,7 +2256,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2264,14 +2264,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2299,7 +2299,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2320,7 +2320,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2342,10 +2342,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2359,12 +2359,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2391,7 +2391,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2434,7 +2434,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2446,7 +2446,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2456,7 +2456,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2478,15 +2478,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2511,7 +2511,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2699,7 +2699,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2916,13 +2916,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -3086,7 +3086,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -3130,7 +3130,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -3141,7 +3141,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3391,14 +3391,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3465,7 +3465,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3483,7 +3483,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3500,7 +3500,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3517,7 +3517,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3533,21 +3533,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3572,64 +3572,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3657,7 +3657,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -4042,12 +4042,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -4141,13 +4141,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4162,9 +4162,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4200,7 +4200,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4224,7 +4224,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4232,13 +4232,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4264,7 +4264,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4390,70 +4390,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4498,7 +4498,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4508,8 +4508,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4529,7 +4529,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4537,9 +4537,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4581,7 +4581,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4638,12 +4638,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/A10D/Marlin/BlinkM.cpp b/A10D/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/A10D/Marlin/BlinkM.cpp +++ b/A10D/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/A10D/Marlin/Configuration.h b/A10D/Marlin/Configuration.h index 9be5011b..e9e1f0cd 100644 --- a/A10D/Marlin/Configuration.h +++ b/A10D/Marlin/Configuration.h @@ -46,9 +46,9 @@ // The following define selects which electronics board you have. // Please choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - + #define MOTHERBOARD BOARD_ULTIMAKER - + #endif // Define this to set a custom name for your generic Mendel, @@ -97,7 +97,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -239,15 +239,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -464,9 +464,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -669,7 +669,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -767,9 +767,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -786,7 +786,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY diff --git a/A10D/Marlin/ConfigurationStore.cpp b/A10D/Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/A10D/Marlin/ConfigurationStore.cpp +++ b/A10D/Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/A10D/Marlin/DOGMbitmaps.h b/A10D/Marlin/DOGMbitmaps.h index 5c7f594b..df713bab 100644 --- a/A10D/Marlin/DOGMbitmaps.h +++ b/A10D/Marlin/DOGMbitmaps.h @@ -1,6 +1,6 @@ // BitMap for splashscreen // Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php -// Please note that using the high-res version takes 402Bytes of PROGMEM. +// Please note that using the high-res version takes 402Bytes of PROGMEM. //#define START_BMPHIGH #ifdef START_BMPHIGH @@ -8,7 +8,7 @@ #define START_BMPHEIGHT 38 #define START_BMPBYTEWIDTH 14 #define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8 - + const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff @@ -49,11 +49,11 @@ ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 ,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80 }; #else - #ifdef GEEETECH_STARTUP_BMP + #ifdef GEEETECH_STARTUP_BMP #define START_BMPWIDTH 128 #define START_BMPHEIGHT 64 #define START_BMPBYTEWIDTH 16 - #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 + #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -187,7 +187,7 @@ #else - #define START_BMPWIDTH 56 + #define START_BMPWIDTH 56 #define START_BMPHEIGHT 19 #define START_BMPBYTEWIDTH 7 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 @@ -215,10 +215,10 @@ #endif #endif -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -371,6 +371,6 @@ 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/A10D/Marlin/LiquidCrystalRus.cpp b/A10D/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/A10D/Marlin/LiquidCrystalRus.cpp +++ b/A10D/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/A10D/Marlin/LiquidCrystalRus.h b/A10D/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/A10D/Marlin/LiquidCrystalRus.h +++ b/A10D/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/A10D/Marlin/MarlinSerial.cpp b/A10D/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/A10D/Marlin/MarlinSerial.cpp +++ b/A10D/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/A10D/Marlin/MarlinSerial.h b/A10D/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/A10D/Marlin/MarlinSerial.h +++ b/A10D/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -616,7 +616,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -776,7 +776,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -951,45 +951,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1317,9 +1317,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1340,7 +1340,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1441,7 +1441,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1874,11 +1874,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2111,7 +2111,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2123,7 +2123,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2131,14 +2131,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2166,7 +2166,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2187,7 +2187,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2209,10 +2209,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2226,12 +2226,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2258,7 +2258,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2301,7 +2301,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2313,7 +2313,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2323,7 +2323,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2345,15 +2345,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2378,7 +2378,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2566,7 +2566,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2783,13 +2783,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2953,7 +2953,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -3008,7 +3008,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3258,14 +3258,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3332,7 +3332,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3350,7 +3350,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3367,7 +3367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3384,7 +3384,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3400,21 +3400,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3439,64 +3439,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3524,7 +3524,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3909,12 +3909,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -4008,13 +4008,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4029,9 +4029,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4067,7 +4067,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4091,7 +4091,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4099,13 +4099,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4131,7 +4131,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4257,70 +4257,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4365,7 +4365,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4375,8 +4375,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4396,7 +4396,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4404,9 +4404,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4448,7 +4448,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4505,12 +4505,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/A10D/Marlin/Sd2Card.h b/A10D/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/A10D/Marlin/Sd2Card.h +++ b/A10D/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/A10D/Marlin/SdBaseFile.cpp b/A10D/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/A10D/Marlin/SdBaseFile.cpp +++ b/A10D/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/A10D/Marlin/SdFatStructs.h b/A10D/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/A10D/Marlin/SdFatStructs.h +++ b/A10D/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/A10D/Marlin/SdFile.h b/A10D/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/A10D/Marlin/SdFile.h +++ b/A10D/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/A10D/Marlin/Servo.cpp b/A10D/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/A10D/Marlin/Servo.cpp +++ b/A10D/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/A10D/Marlin/cardreader.cpp b/A10D/Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/A10D/Marlin/cardreader.cpp +++ b/A10D/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/A10D/Marlin/cardreader.h b/A10D/Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/A10D/Marlin/cardreader.h +++ b/A10D/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/A10D/Marlin/dogm_font_data_marlin.h b/A10D/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/A10D/Marlin/dogm_font_data_marlin.h +++ b/A10D/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/A10D/Marlin/dogm_lcd_implementation.h b/A10D/Marlin/dogm_lcd_implementation.h index 1d9f1636..720b09f6 100644 --- a/A10D/Marlin/dogm_lcd_implementation.h +++ b/A10D/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,17 +117,17 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp #ifdef GEEETECH_STARTUP_BMP - u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); + u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); #else u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -151,7 +151,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -192,12 +192,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -206,10 +206,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -218,7 +218,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -231,7 +231,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -243,7 +243,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -253,8 +253,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -278,7 +278,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -305,23 +305,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -335,7 +335,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -344,7 +344,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/A10D/Marlin/fastio.h b/A10D/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/A10D/Marlin/fastio.h +++ b/A10D/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/A10D/Marlin/language.h b/A10D/Marlin/language.h index 632d419d..0fb15466 100644 --- a/A10D/Marlin/language.h +++ b/A10D/Marlin/language.h @@ -109,7 +109,7 @@ #define MSG_HEATING_COMPLETE "Heating done." #define MSG_BED_HEATING "Bed Heating." #define MSG_BED_DONE "Bed done." -#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" +#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" #define MSG_COUNT_X " Count X: " #define MSG_ERR_KILLED "Printer halted. kill() called!" #define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" diff --git a/A10D/Marlin/motion_control.cpp b/A10D/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/A10D/Marlin/motion_control.cpp +++ b/A10D/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -129,8 +129,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -138,8 +138,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -149,7 +149,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -162,12 +162,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -186,10 +186,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -212,7 +212,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -230,16 +230,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -249,8 +249,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -264,7 +264,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -274,22 +274,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -300,8 +300,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -322,11 +322,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -339,8 +339,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -371,22 +371,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -452,7 +452,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -487,7 +487,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -527,7 +527,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -539,12 +539,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -558,7 +558,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -570,7 +570,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -608,8 +608,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -618,34 +618,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -674,37 +674,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -715,15 +715,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -759,7 +759,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -776,7 +776,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -784,25 +784,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -815,12 +815,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -842,7 +842,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -944,11 +944,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -960,13 +960,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -983,11 +983,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1004,12 +1004,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1063,8 +1063,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1075,7 +1075,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/A10D/Marlin/planner.h b/A10D/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/A10D/Marlin/planner.h +++ b/A10D/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/A10D/Marlin/qr_solve.cpp b/A10D/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/A10D/Marlin/qr_solve.cpp +++ b/A10D/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/A10D/Marlin/qr_solve.h b/A10D/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/A10D/Marlin/qr_solve.h +++ b/A10D/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/A10D/Marlin/speed_lookuptable.h b/A10D/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/A10D/Marlin/speed_lookuptable.h +++ b/A10D/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/A10D/Marlin/stepper.cpp b/A10D/Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/A10D/Marlin/stepper.cpp +++ b/A10D/Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/A10D/Marlin/stepper.h b/A10D/Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/A10D/Marlin/stepper.h +++ b/A10D/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/A10D/Marlin/temperature.cpp b/A10D/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/A10D/Marlin/temperature.cpp +++ b/A10D/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/A10D/Marlin/temperature.h b/A10D/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/A10D/Marlin/temperature.h +++ b/A10D/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/A10D/Marlin/thermistortables.h b/A10D/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/A10D/Marlin/thermistortables.h +++ b/A10D/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/A10D/Marlin/ultralcd.cpp b/A10D/Marlin/ultralcd.cpp index fdfe38cf..ec970f5a 100644 --- a/A10D/Marlin/ultralcd.cpp +++ b/A10D/Marlin/ultralcd.cpp @@ -351,14 +351,14 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:" VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -366,12 +366,12 @@ static void lcd_about_menu() lcd.print("No SN"); else { - + lcd.print("SN:"); lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -416,13 +416,13 @@ static void lcd_main_menu() } #endif #ifdef LIGHT_SUPPORT - if(light_level>0) - { + if(light_level>0) + { light_level = 0; MENU_ITEM(function, MSG_LIGHT_OFF, light_ctrl); light_level = LIGHT_LEVEL; } - else + else { light_level = LIGHT_LEVEL; MENU_ITEM(function, MSG_LIGHT_ON, light_ctrl); @@ -1597,7 +1597,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; @@ -1783,4 +1783,4 @@ void copy_and_scalePID_d() #endif } -#endif //ULTRA_LCD +#endif //ULTRA_LCD diff --git a/A10D/Marlin/ultralcd.h b/A10D/Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/A10D/Marlin/ultralcd.h +++ b/A10D/Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/A10D/Marlin/ultralcd_st7920_u8glib_rrd.h b/A10D/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/A10D/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/A10D/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/A10D/Marlin/vector_3.cpp b/A10D/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/A10D/Marlin/vector_3.cpp +++ b/A10D/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/A10D/Marlin/vector_3.h b/A10D/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/A10D/Marlin/vector_3.h +++ b/A10D/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/A10D/Marlin/watchdog.cpp b/A10D/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/A10D/Marlin/watchdog.cpp +++ b/A10D/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/A10M_marlin1.1.8/Marlin/Marlin_main.cpp b/A10M_marlin1.1.8/Marlin/Marlin_main.cpp index 06e91044..d55c3bb6 100644 --- a/A10M_marlin1.1.8/Marlin/Marlin_main.cpp +++ b/A10M_marlin1.1.8/Marlin/Marlin_main.cpp @@ -11065,7 +11065,7 @@ inline void gcode_M355() { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } SERIAL_ECHOPGM("Gradient Mix "); if ((mixer.gradient_flag = gflag)) { @@ -11106,17 +11106,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12528,10 +12528,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14476,7 +14476,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14732,7 +14732,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14743,7 +14743,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); if(powerloss.Nozzle0_Value <101) @@ -14757,7 +14757,7 @@ void loop() { mixer.start_pct =powerloss.start_ps; mixer.end_pct=powerloss.end_ps; mixer.start_z =powerloss.start_zs; - mixer.end_z =powerloss.end_zs; + mixer.end_z =powerloss.end_zs; } axis_homed[Z_AXIS] = axis_known_position[Z_AXIS] = true; diff --git a/A10M_marlin1.1.8/Marlin/configuration_store.cpp b/A10M_marlin1.1.8/Marlin/configuration_store.cpp index c19cb455..34b7625b 100644 --- a/A10M_marlin1.1.8/Marlin/configuration_store.cpp +++ b/A10M_marlin1.1.8/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A10M_marlin1.1.8/Marlin/ultralcd.cpp b/A10M_marlin1.1.8/Marlin/ultralcd.cpp index 220ae883..4a32dbbc 100644 --- a/A10M_marlin1.1.8/Marlin/ultralcd.cpp +++ b/A10M_marlin1.1.8/Marlin/ultralcd.cpp @@ -1025,7 +1025,7 @@ void kill_screen(const char* lcd_msg) { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } MENU_ITEM_ADDON_END(); @@ -4186,7 +4186,7 @@ void kill_screen(const char* lcd_msg) { START_SCREEN(); STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000 - + // SERIAL_ECHOPAIR("hardware version:", hardware_version); //liu.. //STATIC_ITEM(MSG_FW_VER, false, true); STATIC_ITEM("" MSG_FW_VER, true); diff --git a/A10M_marlin1.1.8_3Dtouch/Marlin/Marlin_main.cpp b/A10M_marlin1.1.8_3Dtouch/Marlin/Marlin_main.cpp index 06e91044..d55c3bb6 100644 --- a/A10M_marlin1.1.8_3Dtouch/Marlin/Marlin_main.cpp +++ b/A10M_marlin1.1.8_3Dtouch/Marlin/Marlin_main.cpp @@ -11065,7 +11065,7 @@ inline void gcode_M355() { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } SERIAL_ECHOPGM("Gradient Mix "); if ((mixer.gradient_flag = gflag)) { @@ -11106,17 +11106,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12528,10 +12528,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14476,7 +14476,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14732,7 +14732,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14743,7 +14743,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); if(powerloss.Nozzle0_Value <101) @@ -14757,7 +14757,7 @@ void loop() { mixer.start_pct =powerloss.start_ps; mixer.end_pct=powerloss.end_ps; mixer.start_z =powerloss.start_zs; - mixer.end_z =powerloss.end_zs; + mixer.end_z =powerloss.end_zs; } axis_homed[Z_AXIS] = axis_known_position[Z_AXIS] = true; diff --git a/A10M_marlin1.1.8_3Dtouch/Marlin/configuration_store.cpp b/A10M_marlin1.1.8_3Dtouch/Marlin/configuration_store.cpp index c19cb455..34b7625b 100644 --- a/A10M_marlin1.1.8_3Dtouch/Marlin/configuration_store.cpp +++ b/A10M_marlin1.1.8_3Dtouch/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A10M_marlin1.1.8_3Dtouch/Marlin/ultralcd.cpp b/A10M_marlin1.1.8_3Dtouch/Marlin/ultralcd.cpp index 220ae883..4a32dbbc 100644 --- a/A10M_marlin1.1.8_3Dtouch/Marlin/ultralcd.cpp +++ b/A10M_marlin1.1.8_3Dtouch/Marlin/ultralcd.cpp @@ -1025,7 +1025,7 @@ void kill_screen(const char* lcd_msg) { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } MENU_ITEM_ADDON_END(); @@ -4186,7 +4186,7 @@ void kill_screen(const char* lcd_msg) { START_SCREEN(); STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000 - + // SERIAL_ECHOPAIR("hardware version:", hardware_version); //liu.. //STATIC_ITEM(MSG_FW_VER, false, true); STATIC_ITEM("" MSG_FW_VER, true); diff --git a/A10_marlin1.1.8/Marlin/Marlin_main.cpp b/A10_marlin1.1.8/Marlin/Marlin_main.cpp index 4093276d..266ebe6e 100644 --- a/A10_marlin1.1.8/Marlin/Marlin_main.cpp +++ b/A10_marlin1.1.8/Marlin/Marlin_main.cpp @@ -11050,17 +11050,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12467,10 +12467,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14416,7 +14416,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14678,7 +14678,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14689,7 +14689,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); @@ -14702,7 +14702,7 @@ void loop() { else sprintf_P(tmp_y, PSTR("M32 S%lu !%s"), powerloss.pos_t, powerloss.P_file_name); - + //SERIAL_ECHOLNPAIR("Gco : ", tmp_y); diff --git a/A10_marlin1.1.8/Marlin/configuration_store.cpp b/A10_marlin1.1.8/Marlin/configuration_store.cpp index f776eb3e..648744fe 100644 --- a/A10_marlin1.1.8/Marlin/configuration_store.cpp +++ b/A10_marlin1.1.8/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A10_marlin1.1.8/Marlin/ultralcd.cpp b/A10_marlin1.1.8/Marlin/ultralcd.cpp index 00643d67..4cc54a1d 100644 --- a/A10_marlin1.1.8/Marlin/ultralcd.cpp +++ b/A10_marlin1.1.8/Marlin/ultralcd.cpp @@ -3951,7 +3951,7 @@ void kill_screen(const char* lcd_msg) { START_SCREEN(); STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000 - + // SERIAL_ECHOPAIR("hardware version:", hardware_version); //liu.. //STATIC_ITEM(MSG_FW_VER, false, true); STATIC_ITEM("" MSG_FW_VER, true); diff --git a/A10_marlin1.1.8_3DTtouch/Marlin/Marlin_main.cpp b/A10_marlin1.1.8_3DTtouch/Marlin/Marlin_main.cpp index 4093276d..266ebe6e 100644 --- a/A10_marlin1.1.8_3DTtouch/Marlin/Marlin_main.cpp +++ b/A10_marlin1.1.8_3DTtouch/Marlin/Marlin_main.cpp @@ -11050,17 +11050,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12467,10 +12467,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14416,7 +14416,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14678,7 +14678,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14689,7 +14689,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); @@ -14702,7 +14702,7 @@ void loop() { else sprintf_P(tmp_y, PSTR("M32 S%lu !%s"), powerloss.pos_t, powerloss.P_file_name); - + //SERIAL_ECHOLNPAIR("Gco : ", tmp_y); diff --git a/A10_marlin1.1.8_3DTtouch/Marlin/configuration_store.cpp b/A10_marlin1.1.8_3DTtouch/Marlin/configuration_store.cpp index f776eb3e..648744fe 100644 --- a/A10_marlin1.1.8_3DTtouch/Marlin/configuration_store.cpp +++ b/A10_marlin1.1.8_3DTtouch/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A10_marlin1.1.8_3DTtouch/Marlin/ultralcd.cpp b/A10_marlin1.1.8_3DTtouch/Marlin/ultralcd.cpp index 00643d67..4cc54a1d 100644 --- a/A10_marlin1.1.8_3DTtouch/Marlin/ultralcd.cpp +++ b/A10_marlin1.1.8_3DTtouch/Marlin/ultralcd.cpp @@ -3951,7 +3951,7 @@ void kill_screen(const char* lcd_msg) { START_SCREEN(); STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000 - + // SERIAL_ECHOPAIR("hardware version:", hardware_version); //liu.. //STATIC_ITEM(MSG_FW_VER, false, true); STATIC_ITEM("" MSG_FW_VER, true); diff --git a/A20M_Marlin-1.1.x12864/Marlin/Marlin_main.cpp b/A20M_Marlin-1.1.x12864/Marlin/Marlin_main.cpp index b24df87a..1eec20ca 100644 --- a/A20M_Marlin-1.1.x12864/Marlin/Marlin_main.cpp +++ b/A20M_Marlin-1.1.x12864/Marlin/Marlin_main.cpp @@ -11065,7 +11065,7 @@ inline void gcode_M355() { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } SERIAL_ECHOPGM("Gradient Mix "); if ((mixer.gradient_flag = gflag)) { @@ -11080,7 +11080,7 @@ inline void gcode_M355() { else SERIAL_ECHOPGM("OFF"); SERIAL_EOL(); - + } #endif @@ -11107,17 +11107,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12529,10 +12529,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14477,7 +14477,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14733,7 +14733,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14744,7 +14744,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); if(powerloss.Nozzle0_Value <101) @@ -14758,7 +14758,7 @@ void loop() { mixer.start_pct =powerloss.start_ps; mixer.end_pct=powerloss.end_ps; mixer.start_z =powerloss.start_zs; - mixer.end_z =powerloss.end_zs; + mixer.end_z =powerloss.end_zs; } axis_homed[Z_AXIS] = axis_known_position[Z_AXIS] = true; diff --git a/A20M_Marlin-1.1.x12864/Marlin/configuration_store.cpp b/A20M_Marlin-1.1.x12864/Marlin/configuration_store.cpp index 2b229638..428fe89e 100644 --- a/A20M_Marlin-1.1.x12864/Marlin/configuration_store.cpp +++ b/A20M_Marlin-1.1.x12864/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A20M_Marlin-1.1.x12864/Marlin/ultralcd.cpp b/A20M_Marlin-1.1.x12864/Marlin/ultralcd.cpp index e6a812dc..b1c8e73c 100644 --- a/A20M_Marlin-1.1.x12864/Marlin/ultralcd.cpp +++ b/A20M_Marlin-1.1.x12864/Marlin/ultralcd.cpp @@ -1025,7 +1025,7 @@ void kill_screen(const char* lcd_msg) { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } MENU_ITEM_ADDON_END(); diff --git a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp index b24df87a..1eec20ca 100644 --- a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp +++ b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp @@ -11065,7 +11065,7 @@ inline void gcode_M355() { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } SERIAL_ECHOPGM("Gradient Mix "); if ((mixer.gradient_flag = gflag)) { @@ -11080,7 +11080,7 @@ inline void gcode_M355() { else SERIAL_ECHOPGM("OFF"); SERIAL_EOL(); - + } #endif @@ -11107,17 +11107,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12529,10 +12529,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14477,7 +14477,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14733,7 +14733,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14744,7 +14744,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); if(powerloss.Nozzle0_Value <101) @@ -14758,7 +14758,7 @@ void loop() { mixer.start_pct =powerloss.start_ps; mixer.end_pct=powerloss.end_ps; mixer.start_z =powerloss.start_zs; - mixer.end_z =powerloss.end_zs; + mixer.end_z =powerloss.end_zs; } axis_homed[Z_AXIS] = axis_known_position[Z_AXIS] = true; diff --git a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp index 2b229638..428fe89e 100644 --- a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp +++ b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/ultralcd.cpp b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/ultralcd.cpp index e6a812dc..b1c8e73c 100644 --- a/A20M_Marlin-1.1.x12864_3DTouch/Marlin/ultralcd.cpp +++ b/A20M_Marlin-1.1.x12864_3DTouch/Marlin/ultralcd.cpp @@ -1025,7 +1025,7 @@ void kill_screen(const char* lcd_msg) { powerloss.end_ps = mixer.end_pct; powerloss.start_zs = mixer.start_z; powerloss.end_zs = mixer.end_z; - + } MENU_ITEM_ADDON_END(); diff --git a/A20_Marlin-1.1.x12864/Marlin/Marlin_main.cpp b/A20_Marlin-1.1.x12864/Marlin/Marlin_main.cpp index da44a470..bf2b9492 100644 --- a/A20_Marlin-1.1.x12864/Marlin/Marlin_main.cpp +++ b/A20_Marlin-1.1.x12864/Marlin/Marlin_main.cpp @@ -11050,17 +11050,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12467,10 +12467,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14415,7 +14415,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14677,7 +14677,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14688,7 +14688,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); diff --git a/A20_Marlin-1.1.x12864/Marlin/configuration_store.cpp b/A20_Marlin-1.1.x12864/Marlin/configuration_store.cpp index 938ef075..6712ecde 100644 --- a/A20_Marlin-1.1.x12864/Marlin/configuration_store.cpp +++ b/A20_Marlin-1.1.x12864/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/A20_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp b/A20_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp index da44a470..bf2b9492 100644 --- a/A20_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp +++ b/A20_Marlin-1.1.x12864_3DTouch/Marlin/Marlin_main.cpp @@ -11050,17 +11050,17 @@ inline void gcode_M999() { FlushSerialRequestResend(); } inline void gcode_M2000(){ - + } inline void gcode_M2009(){ if (parser.seen('V')) hardware_version = parser.value_celsius(); //SERIAL_ECHOPAIR("HV...:", hardware_version);//liu (void)settings.Fixed_parameter_save(); SERIAL_ECHOLNPGM("HV_set_ok"); - + } - + #if ENABLED(SWITCHING_EXTRUDER) #if EXTRUDERS > 3 @@ -12467,10 +12467,10 @@ void process_parsed_command() { case 999: // M999: Restart after being Stopped gcode_M999(); break; - case 2000: // + case 2000: // gcode_M2000(); break; - case 2009: // + case 2009: // gcode_M2009(); break; } @@ -14415,7 +14415,7 @@ void setup() { // This also updates variables in the planner, elsewhere (void)settings.load(); (void)settings.Fixed_parameter_load(); - + #if HAS_M206_COMMAND // Initialize current position based on home_offset @@ -14677,7 +14677,7 @@ void loop() { sprintf_P(tmp_y, PSTR("M109 T0 S%u"), powerloss.T0_t); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("M106 S255")); enqueue_and_echo_command(tmp_y); @@ -14688,7 +14688,7 @@ void loop() { sprintf_P(tmp_y,PSTR("G28 Y")); //SERIAL_ECHOLN(tmp_y); enqueue_and_echo_command(tmp_y); - + sprintf_P(tmp_y, PSTR("G0 F1000 Z%u.%u"), powerloss.Z_t / 10, powerloss.Z_t % 10);//jone enqueue_and_echo_command(tmp_y); diff --git a/A20_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp b/A20_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp index 938ef075..6712ecde 100644 --- a/A20_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp +++ b/A20_Marlin-1.1.x12864_3DTouch/Marlin/configuration_store.cpp @@ -817,21 +817,21 @@ float hardware_version=0.1; uint16_t working_crc = 0; EEPROM_START(); eeprom_index = EEPROM_OFFSET_SN_VER; - + EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; + working_crc = 0; EEPROM_WRITE(hardware_version);//liu hw ver - + const uint16_t final_crc = working_crc; const int eeprom_size = eeprom_index; eeprom_index = EEPROM_OFFSET_SN_VER; EEPROM_WRITE(final_crc); - + SERIAL_ECHO_START(); SERIAL_ECHOPAIR("Fixed parameter (", eeprom_size - EEPROM_OFFSET_SN_VER); SERIAL_ECHOPAIR("Fixed parameter bytes; crc ", (uint32_t)final_crc); SERIAL_ECHOLNPGM(")"); - + } bool MarlinSettings::Fixed_parameter_load(){ uint16_t working_crc = 0; @@ -843,7 +843,7 @@ float hardware_version=0.1; EEPROM_READ(hardware_version);//liu hhardware_version if(hardware_version< 0.1) { - hardware_version = 0.1; + hardware_version = 0.1; } SERIAL_ECHOPAIR(" hardware version:", hardware_version);//liu if (working_crc == stored_crc) { diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/BlinkM.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/BlinkM.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/Configuration.h b/I3pro/Firmware_Marlin/I3proB/Marlin/Configuration.h index d4b12a60..75f6bb3f 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/Configuration.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/Configuration.h @@ -89,7 +89,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -231,15 +231,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -456,9 +456,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -661,7 +661,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -759,9 +759,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -778,7 +778,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY @@ -791,4 +791,4 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #include "Configuration_adv.h" #include "thermistortables.h" -#endif //__CONFIGURATION_H +#endif //__CONFIGURATION_H diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/ConfigurationStore.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/ConfigurationStore.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/DOGMbitmaps.h b/I3pro/Firmware_Marlin/I3proB/Marlin/DOGMbitmaps.h index de436543..4ac5fc67 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/DOGMbitmaps.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/DOGMbitmaps.h @@ -64,10 +64,10 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f }; -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -220,6 +220,6 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.h b/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.h b/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -605,7 +605,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -765,7 +765,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -940,45 +940,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1306,9 +1306,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1329,7 +1329,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1430,7 +1430,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1863,11 +1863,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2100,7 +2100,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2112,7 +2112,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2120,14 +2120,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2155,7 +2155,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2176,7 +2176,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2198,10 +2198,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2215,12 +2215,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2247,7 +2247,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2290,7 +2290,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2302,7 +2302,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2312,7 +2312,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2334,15 +2334,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2367,7 +2367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2555,7 +2555,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2772,13 +2772,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2942,7 +2942,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2986,7 +2986,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3247,14 +3247,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3321,7 +3321,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3339,7 +3339,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3356,7 +3356,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3373,7 +3373,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3389,21 +3389,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3428,64 +3428,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3513,7 +3513,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3898,12 +3898,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -3997,13 +3997,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4018,9 +4018,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4056,7 +4056,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4080,7 +4080,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4088,13 +4088,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4120,7 +4120,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4246,70 +4246,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4354,7 +4354,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4364,8 +4364,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4385,7 +4385,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4393,9 +4393,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4437,7 +4437,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4494,12 +4494,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/Sd2Card.h b/I3pro/Firmware_Marlin/I3proB/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/Sd2Card.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/SdBaseFile.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/SdBaseFile.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/SdFatStructs.h b/I3pro/Firmware_Marlin/I3proB/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/SdFatStructs.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/SdFile.h b/I3pro/Firmware_Marlin/I3proB/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/SdFile.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/Servo.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/Servo.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.h b/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_font_data_marlin.h b/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_font_data_marlin.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_lcd_implementation.h b/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_lcd_implementation.h index 73088d95..d4b91446 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_lcd_implementation.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,14 +117,14 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -147,7 +147,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -188,12 +188,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -202,10 +202,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -214,7 +214,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -227,7 +227,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -239,7 +239,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -249,8 +249,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -274,7 +274,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -301,23 +301,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -331,7 +331,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -340,7 +340,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/fastio.h b/I3pro/Firmware_Marlin/I3proB/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/fastio.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/motion_control.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/motion_control.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -131,8 +131,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -140,8 +140,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -151,7 +151,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -164,12 +164,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -188,10 +188,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -214,7 +214,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -232,16 +232,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -251,8 +251,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -266,7 +266,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -276,22 +276,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -302,8 +302,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -324,11 +324,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -341,8 +341,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -373,22 +373,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -454,7 +454,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -489,7 +489,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -529,7 +529,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -541,12 +541,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -560,7 +560,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -572,7 +572,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -610,8 +610,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -620,34 +620,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -676,37 +676,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -717,15 +717,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -761,7 +761,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -778,7 +778,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -786,25 +786,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -817,12 +817,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -844,7 +844,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -946,11 +946,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -962,13 +962,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -985,11 +985,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1006,12 +1006,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1065,8 +1065,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1077,7 +1077,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/planner.h b/I3pro/Firmware_Marlin/I3proB/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/planner.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.h b/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/speed_lookuptable.h b/I3pro/Firmware_Marlin/I3proB/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/speed_lookuptable.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.h b/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.h b/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/thermistortables.h b/I3pro/Firmware_Marlin/I3proB/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/thermistortables.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.cpp index 3e8f3067..fc45655c 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.cpp @@ -351,16 +351,16 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:"); - lcd.setCursor(8,2); + lcd.setCursor(8,2); lcd.print(VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -368,12 +368,12 @@ static void lcd_about_menu() lcd.print("No SN"); else { - + lcd.print("SN:"); lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -1583,7 +1583,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.h b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd_st7920_u8glib_rrd.h b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.h b/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.h +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/I3pro/Firmware_Marlin/I3proB/Marlin/watchdog.cpp b/I3pro/Firmware_Marlin/I3proB/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/I3pro/Firmware_Marlin/I3proB/Marlin/watchdog.cpp +++ b/I3pro/Firmware_Marlin/I3proB/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/BlinkM.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/BlinkM.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/Configuration.h b/I3pro/Firmware_Marlin/I3proC/Marlin/Configuration.h index 59934234..74d7f4db 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/Configuration.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/Configuration.h @@ -89,7 +89,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -231,15 +231,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -456,9 +456,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -661,7 +661,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -759,9 +759,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -778,7 +778,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/ConfigurationStore.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/ConfigurationStore.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/DOGMbitmaps.h b/I3pro/Firmware_Marlin/I3proC/Marlin/DOGMbitmaps.h index de436543..4ac5fc67 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/DOGMbitmaps.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/DOGMbitmaps.h @@ -64,10 +64,10 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f }; -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -220,6 +220,6 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.h b/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.h b/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -605,7 +605,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -765,7 +765,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -940,45 +940,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1306,9 +1306,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1329,7 +1329,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1430,7 +1430,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1863,11 +1863,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2100,7 +2100,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2112,7 +2112,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2120,14 +2120,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2155,7 +2155,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2176,7 +2176,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2198,10 +2198,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2215,12 +2215,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2247,7 +2247,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2290,7 +2290,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2302,7 +2302,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2312,7 +2312,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2334,15 +2334,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2367,7 +2367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2555,7 +2555,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2772,13 +2772,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2942,7 +2942,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2986,7 +2986,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3247,14 +3247,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3321,7 +3321,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3339,7 +3339,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3356,7 +3356,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3373,7 +3373,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3389,21 +3389,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3428,64 +3428,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3513,7 +3513,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3898,12 +3898,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -3997,13 +3997,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4018,9 +4018,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4056,7 +4056,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4080,7 +4080,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4088,13 +4088,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4120,7 +4120,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4246,70 +4246,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4354,7 +4354,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4364,8 +4364,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4385,7 +4385,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4393,9 +4393,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4437,7 +4437,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4494,12 +4494,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/Sd2Card.h b/I3pro/Firmware_Marlin/I3proC/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/Sd2Card.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/SdBaseFile.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/SdBaseFile.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/SdFatStructs.h b/I3pro/Firmware_Marlin/I3proC/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/SdFatStructs.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/SdFile.h b/I3pro/Firmware_Marlin/I3proC/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/SdFile.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/Servo.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/Servo.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.h b/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_font_data_marlin.h b/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_font_data_marlin.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_lcd_implementation.h b/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_lcd_implementation.h index 73088d95..d4b91446 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_lcd_implementation.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,14 +117,14 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -147,7 +147,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -188,12 +188,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -202,10 +202,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -214,7 +214,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -227,7 +227,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -239,7 +239,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -249,8 +249,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -274,7 +274,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -301,23 +301,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -331,7 +331,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -340,7 +340,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/fastio.h b/I3pro/Firmware_Marlin/I3proC/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/fastio.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/motion_control.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/motion_control.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -131,8 +131,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -140,8 +140,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -151,7 +151,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -164,12 +164,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -188,10 +188,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -214,7 +214,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -232,16 +232,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -251,8 +251,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -266,7 +266,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -276,22 +276,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -302,8 +302,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -324,11 +324,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -341,8 +341,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -373,22 +373,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -454,7 +454,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -489,7 +489,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -529,7 +529,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -541,12 +541,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -560,7 +560,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -572,7 +572,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -610,8 +610,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -620,34 +620,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -676,37 +676,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -717,15 +717,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -761,7 +761,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -778,7 +778,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -786,25 +786,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -817,12 +817,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -844,7 +844,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -946,11 +946,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -962,13 +962,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -985,11 +985,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1006,12 +1006,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1065,8 +1065,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1077,7 +1077,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/planner.h b/I3pro/Firmware_Marlin/I3proC/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/planner.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.h b/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/speed_lookuptable.h b/I3pro/Firmware_Marlin/I3proC/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/speed_lookuptable.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.h b/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.h b/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/thermistortables.h b/I3pro/Firmware_Marlin/I3proC/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/thermistortables.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.cpp index 3e8f3067..fc45655c 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.cpp @@ -351,16 +351,16 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:"); - lcd.setCursor(8,2); + lcd.setCursor(8,2); lcd.print(VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -368,12 +368,12 @@ static void lcd_about_menu() lcd.print("No SN"); else { - + lcd.print("SN:"); lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -1583,7 +1583,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.h b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd_st7920_u8glib_rrd.h b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.h b/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.h +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/I3pro/Firmware_Marlin/I3proC/Marlin/watchdog.cpp b/I3pro/Firmware_Marlin/I3proC/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/I3pro/Firmware_Marlin/I3proC/Marlin/watchdog.cpp +++ b/I3pro/Firmware_Marlin/I3proC/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/BlinkM.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/BlinkM.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/Configuration.h b/I3pro/Firmware_Marlin/I3proW/Marlin/Configuration.h index a4b469b1..032081f8 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/Configuration.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/Configuration.h @@ -89,7 +89,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -231,15 +231,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -456,9 +456,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -661,7 +661,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -759,9 +759,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -778,7 +778,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY @@ -791,4 +791,4 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #include "Configuration_adv.h" #include "thermistortables.h" -#endif //__CONFIGURATION_H +#endif //__CONFIGURATION_H diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/ConfigurationStore.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/ConfigurationStore.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/DOGMbitmaps.h b/I3pro/Firmware_Marlin/I3proW/Marlin/DOGMbitmaps.h index de436543..4ac5fc67 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/DOGMbitmaps.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/DOGMbitmaps.h @@ -64,10 +64,10 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f }; -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -220,6 +220,6 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.h b/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.h b/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -605,7 +605,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -765,7 +765,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -940,45 +940,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1306,9 +1306,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1329,7 +1329,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1430,7 +1430,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1863,11 +1863,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2100,7 +2100,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2112,7 +2112,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2120,14 +2120,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2155,7 +2155,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2176,7 +2176,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2198,10 +2198,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2215,12 +2215,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2247,7 +2247,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2290,7 +2290,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2302,7 +2302,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2312,7 +2312,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2334,15 +2334,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2367,7 +2367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2555,7 +2555,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2772,13 +2772,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2942,7 +2942,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2986,7 +2986,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3247,14 +3247,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3321,7 +3321,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3339,7 +3339,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3356,7 +3356,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3373,7 +3373,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3389,21 +3389,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3428,64 +3428,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3513,7 +3513,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3898,12 +3898,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -3997,13 +3997,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4018,9 +4018,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4056,7 +4056,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4080,7 +4080,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4088,13 +4088,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4120,7 +4120,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4246,70 +4246,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4354,7 +4354,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4364,8 +4364,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4385,7 +4385,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4393,9 +4393,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4437,7 +4437,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4494,12 +4494,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/Sd2Card.h b/I3pro/Firmware_Marlin/I3proW/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/Sd2Card.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/SdBaseFile.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/SdBaseFile.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/SdFatStructs.h b/I3pro/Firmware_Marlin/I3proW/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/SdFatStructs.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/SdFile.h b/I3pro/Firmware_Marlin/I3proW/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/SdFile.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/Servo.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/Servo.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.h b/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_font_data_marlin.h b/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_font_data_marlin.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_lcd_implementation.h b/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_lcd_implementation.h index 73088d95..d4b91446 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_lcd_implementation.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,14 +117,14 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -147,7 +147,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -188,12 +188,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -202,10 +202,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -214,7 +214,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -227,7 +227,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -239,7 +239,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -249,8 +249,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -274,7 +274,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -301,23 +301,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -331,7 +331,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -340,7 +340,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/fastio.h b/I3pro/Firmware_Marlin/I3proW/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/fastio.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/motion_control.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/motion_control.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -131,8 +131,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -140,8 +140,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -151,7 +151,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -164,12 +164,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -188,10 +188,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -214,7 +214,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -232,16 +232,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -251,8 +251,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -266,7 +266,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -276,22 +276,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -302,8 +302,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -324,11 +324,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -341,8 +341,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -373,22 +373,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -454,7 +454,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -489,7 +489,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -529,7 +529,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -541,12 +541,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -560,7 +560,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -572,7 +572,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -610,8 +610,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -620,34 +620,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -676,37 +676,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -717,15 +717,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -761,7 +761,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -778,7 +778,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -786,25 +786,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -817,12 +817,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -844,7 +844,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -946,11 +946,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -962,13 +962,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -985,11 +985,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1006,12 +1006,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1065,8 +1065,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1077,7 +1077,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/planner.h b/I3pro/Firmware_Marlin/I3proW/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/planner.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.h b/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/speed_lookuptable.h b/I3pro/Firmware_Marlin/I3proW/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/speed_lookuptable.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.h b/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.h b/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/thermistortables.h b/I3pro/Firmware_Marlin/I3proW/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/thermistortables.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.cpp index a91e694d..43bbf443 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.cpp @@ -344,7 +344,7 @@ static void lcd_about_menu() // MENU_ITEM(submenu, VERSION_STRING, NULL); // MENU_ITEM(submenu, VERSION_STRING, NULL); lcd.setCursor(1,1); - + //////////// //lcd.print( MACHINE_NAME); if(uuid_hw[0]<'0'||uuid_hw[0]>'Z') @@ -352,16 +352,16 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:"); - lcd.setCursor(8,2); + lcd.setCursor(8,2); lcd.print(VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -374,7 +374,7 @@ static void lcd_about_menu() lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -1584,7 +1584,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.h b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd_st7920_u8glib_rrd.h b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.h b/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.h +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/I3pro/Firmware_Marlin/I3proW/Marlin/watchdog.cpp b/I3pro/Firmware_Marlin/I3proW/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/I3pro/Firmware_Marlin/I3proW/Marlin/watchdog.cpp +++ b/I3pro/Firmware_Marlin/I3proW/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/BlinkM.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/BlinkM.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Configuration.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Configuration.h index 0eeb7c68..214dc908 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Configuration.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Configuration.h @@ -89,7 +89,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -231,15 +231,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -456,9 +456,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -661,7 +661,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -759,9 +759,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -778,7 +778,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY @@ -791,4 +791,4 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o #include "Configuration_adv.h" #include "thermistortables.h" -#endif //__CONFIGURATION_H +#endif //__CONFIGURATION_H diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ConfigurationStore.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ConfigurationStore.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/DOGMbitmaps.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/DOGMbitmaps.h index de436543..4ac5fc67 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/DOGMbitmaps.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/DOGMbitmaps.h @@ -64,10 +64,10 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0f }; -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -220,6 +220,6 @@ const unsigned char start_bmp[574] PROGMEM = { //AVR-GCC, WinAVR 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -605,7 +605,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -765,7 +765,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -940,45 +940,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1306,9 +1306,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1329,7 +1329,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1430,7 +1430,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1863,11 +1863,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2100,7 +2100,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2112,7 +2112,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2120,14 +2120,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2155,7 +2155,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2176,7 +2176,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2198,10 +2198,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2215,12 +2215,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2247,7 +2247,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2290,7 +2290,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2302,7 +2302,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2312,7 +2312,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2334,15 +2334,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2367,7 +2367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2555,7 +2555,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2772,13 +2772,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2942,7 +2942,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2986,7 +2986,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3247,14 +3247,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3321,7 +3321,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3339,7 +3339,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3356,7 +3356,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3373,7 +3373,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3389,21 +3389,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3428,64 +3428,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3513,7 +3513,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3898,12 +3898,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -3997,13 +3997,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4018,9 +4018,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4056,7 +4056,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4080,7 +4080,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4088,13 +4088,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4120,7 +4120,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4246,70 +4246,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4354,7 +4354,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4364,8 +4364,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4385,7 +4385,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4393,9 +4393,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4437,7 +4437,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4494,12 +4494,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Sd2Card.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Sd2Card.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdBaseFile.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdBaseFile.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFatStructs.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFatStructs.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFile.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFile.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Servo.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Servo.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_font_data_marlin.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_font_data_marlin.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_lcd_implementation.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_lcd_implementation.h index 73088d95..d4b91446 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_lcd_implementation.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,14 +117,14 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -147,7 +147,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -188,12 +188,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -202,10 +202,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -214,7 +214,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -227,7 +227,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -239,7 +239,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -249,8 +249,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -274,7 +274,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -301,23 +301,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -331,7 +331,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -340,7 +340,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/fastio.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/fastio.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/motion_control.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/motion_control.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -129,8 +129,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -138,8 +138,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -149,7 +149,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -162,12 +162,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -186,10 +186,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -212,7 +212,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -230,16 +230,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -249,8 +249,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -264,7 +264,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -274,22 +274,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -300,8 +300,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -322,11 +322,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -339,8 +339,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -371,22 +371,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -452,7 +452,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -487,7 +487,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -527,7 +527,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -539,12 +539,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -558,7 +558,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -570,7 +570,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -608,8 +608,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -618,34 +618,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -674,37 +674,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -715,15 +715,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -759,7 +759,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -776,7 +776,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -784,25 +784,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -815,12 +815,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -842,7 +842,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -944,11 +944,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -960,13 +960,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -983,11 +983,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1004,12 +1004,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1063,8 +1063,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1075,7 +1075,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/planner.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/planner.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/speed_lookuptable.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/speed_lookuptable.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/thermistortables.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/thermistortables.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.cpp index a91e694d..43bbf443 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.cpp @@ -344,7 +344,7 @@ static void lcd_about_menu() // MENU_ITEM(submenu, VERSION_STRING, NULL); // MENU_ITEM(submenu, VERSION_STRING, NULL); lcd.setCursor(1,1); - + //////////// //lcd.print( MACHINE_NAME); if(uuid_hw[0]<'0'||uuid_hw[0]>'Z') @@ -352,16 +352,16 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:"); - lcd.setCursor(8,2); + lcd.setCursor(8,2); lcd.print(VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -374,7 +374,7 @@ static void lcd_about_menu() lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -1584,7 +1584,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd_st7920_u8glib_rrd.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.h b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.h +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/watchdog.cpp b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/watchdog.cpp +++ b/I3pro/Firmware_Marlin/I3proX/I3_pro_X/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update(); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Conditionals.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Conditionals.h index 36974d01..860b5a60 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Conditionals.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Conditionals.h @@ -208,7 +208,7 @@ #endif #ifdef U8GLIB_SSD1306 #undef HAS_LCD_CONTRAST - #endif + #endif #endif #else // CONFIGURATION_LCD @@ -293,11 +293,11 @@ /** * Sled Options - */ + */ #ifdef Z_PROBE_SLED #define Z_SAFE_HOMING #endif - + /** * MAX_STEP_FREQUENCY differs for TOSHIBA */ diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration.h index 4807e095..181ef404 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration.h @@ -403,7 +403,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic const bool FIL_RUNOUT_INVERTING = true; // Should be uncommented and true or false should assigned #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. #define FILAMENT_RUNOUT_SCRIPT "M600" -#endif +#endif //=========================================================================== //=========================== Manual Bed Leveling =========================== @@ -495,7 +495,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // #define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" //These commands will be executed in the end of G29 routine. //Useful to retract a deployable probe. - + //#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell //#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like. @@ -706,7 +706,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic // Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI - + // SSD1306 OLED generic display support // ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib //#define U8GLIB_SSD1306 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration_adv.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration_adv.h index 8a05298d..ce7fa57b 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration_adv.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Configuration_adv.h @@ -131,7 +131,7 @@ #ifdef Z_DUAL_STEPPER_DRIVERS // Z_DUAL_ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper. - // That way the machine is capable to align the bed during home, since both Z steppers are homed. + // That way the machine is capable to align the bed during home, since both Z steppers are homed. // There is also an implementation of M666 (software endstops adjustment) to this feature. // After Z homing, this adjustment is applied to just one of the steppers in order to align the bed. // One just need to home the Z axis and measure the distance difference between both Z axis and apply the math: Z adjust = Z - Z2. @@ -323,8 +323,8 @@ // save 3120 bytes of PROGMEM by commenting out #define USE_BIG_EDIT_FONT // we don't have a big font for Cyrillic, Kana //#define USE_BIG_EDIT_FONT - - // If you have spare 2300Byte of progmem and want to use a + + // If you have spare 2300Byte of progmem and want to use a // smaller font on the Info-screen uncomment the next line. //#define USE_SMALL_INFOFONT #endif // DOGLCD @@ -448,7 +448,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st #endif /******************************************************************************\ - * enable this section if you have TMC26X motor drivers. + * enable this section if you have TMC26X motor drivers. * you need to import the TMC26XStepper library into the arduino IDE for this ******************************************************************************/ @@ -461,56 +461,56 @@ const unsigned int dropsegments=5; //everything with less than this number of st #define X_MAX_CURRENT 1000 //in mA #define X_SENSE_RESISTOR 91 //in mOhms #define X_MICROSTEPS 16 //number of microsteps - + // #define X2_IS_TMC #define X2_MAX_CURRENT 1000 //in mA #define X2_SENSE_RESISTOR 91 //in mOhms #define X2_MICROSTEPS 16 //number of microsteps - + // #define Y_IS_TMC #define Y_MAX_CURRENT 1000 //in mA #define Y_SENSE_RESISTOR 91 //in mOhms #define Y_MICROSTEPS 16 //number of microsteps - + // #define Y2_IS_TMC #define Y2_MAX_CURRENT 1000 //in mA #define Y2_SENSE_RESISTOR 91 //in mOhms - #define Y2_MICROSTEPS 16 //number of microsteps - + #define Y2_MICROSTEPS 16 //number of microsteps + // #define Z_IS_TMC #define Z_MAX_CURRENT 1000 //in mA #define Z_SENSE_RESISTOR 91 //in mOhms #define Z_MICROSTEPS 16 //number of microsteps - + // #define Z2_IS_TMC #define Z2_MAX_CURRENT 1000 //in mA #define Z2_SENSE_RESISTOR 91 //in mOhms #define Z2_MICROSTEPS 16 //number of microsteps - + // #define E0_IS_TMC #define E0_MAX_CURRENT 1000 //in mA #define E0_SENSE_RESISTOR 91 //in mOhms #define E0_MICROSTEPS 16 //number of microsteps - + // #define E1_IS_TMC #define E1_MAX_CURRENT 1000 //in mA #define E1_SENSE_RESISTOR 91 //in mOhms - #define E1_MICROSTEPS 16 //number of microsteps - + #define E1_MICROSTEPS 16 //number of microsteps + // #define E2_IS_TMC #define E2_MAX_CURRENT 1000 //in mA #define E2_SENSE_RESISTOR 91 //in mOhms - #define E2_MICROSTEPS 16 //number of microsteps - + #define E2_MICROSTEPS 16 //number of microsteps + // #define E3_IS_TMC #define E3_MAX_CURRENT 1000 //in mA #define E3_SENSE_RESISTOR 91 //in mOhms - #define E3_MICROSTEPS 16 //number of microsteps + #define E3_MICROSTEPS 16 //number of microsteps #endif /******************************************************************************\ - * enable this section if you have L6470 motor drivers. + * enable this section if you have L6470 motor drivers. * you need to import the L6470 library into the arduino IDE for this ******************************************************************************/ @@ -521,67 +521,67 @@ const unsigned int dropsegments=5; //everything with less than this number of st // #define X_IS_L6470 #define X_MICROSTEPS 16 //number of microsteps - #define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define X_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define X_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define X2_IS_L6470 #define X2_MICROSTEPS 16 //number of microsteps - #define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define X2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define X2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define Y_IS_L6470 #define Y_MICROSTEPS 16 //number of microsteps - #define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define Y_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Y_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define Y2_IS_L6470 - #define Y2_MICROSTEPS 16 //number of microsteps - #define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Y2_MICROSTEPS 16 //number of microsteps + #define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define Y2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off - #define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + #define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall + // #define Z_IS_L6470 #define Z_MICROSTEPS 16 //number of microsteps - #define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define Z_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Z_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define Z2_IS_L6470 #define Z2_MICROSTEPS 16 //number of microsteps - #define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define Z2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define Z2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define E0_IS_L6470 #define E0_MICROSTEPS 16 //number of microsteps - #define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define E0_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E0_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define E1_IS_L6470 - #define E1_MICROSTEPS 16 //number of microsteps #define E1_MICROSTEPS 16 //number of microsteps - #define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E1_MICROSTEPS 16 //number of microsteps + #define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define E1_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E1_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define E2_IS_L6470 - #define E2_MICROSTEPS 16 //number of microsteps #define E2_MICROSTEPS 16 //number of microsteps - #define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E2_MICROSTEPS 16 //number of microsteps + #define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define E2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E2_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + // #define E3_IS_L6470 - #define E3_MICROSTEPS 16 //number of microsteps #define E3_MICROSTEPS 16 //number of microsteps - #define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high + #define E3_MICROSTEPS 16 //number of microsteps + #define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high #define E3_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off #define E3_STALLCURRENT 1500 //current in mA where the driver will detect a stall - + #endif #include "Conditionals.h" diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.cpp index dc36e14c..dc3ebb43 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -74,7 +74,7 @@ void MarlinSerial::begin(long baud) { useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = BIT(M_U2Xx); baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -95,7 +95,7 @@ void MarlinSerial::begin(long baud) { void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -178,7 +178,7 @@ void MarlinSerial::print(double n, int digits) { void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) { @@ -229,13 +229,13 @@ void MarlinSerial::println(double n, int digits) { // Private Methods ///////////////////////////////////////////////////////////// void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -259,7 +259,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) { double rounding = 0.5; for (uint8_t i = 0; i < digits; ++i) rounding /= 10.0; - + number += rounding; // Extract the integer part of the number and print it @@ -275,8 +275,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) { remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.h index dbad3fd7..ff38965e 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/MarlinSerial.h @@ -30,8 +30,8 @@ // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Marlin_main.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Marlin_main.cpp index ec8072de..9b69118e 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Marlin_main.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Marlin_main.cpp @@ -155,7 +155,7 @@ * M150 - Set BlinkM Color Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work. * M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating * Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling - * M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D- + * M200 - set filament diameter and set E axis units to cubic millimeters (use S0 to set back to millimeters).:D- * M201 - Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) * M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!! * M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec @@ -337,7 +337,7 @@ bool target_direction; #endif // FWRETRACT #if defined(ULTIPANEL) && HAS_POWER_SWITCH - bool powersupply = + bool powersupply = #ifdef PS_DEFAULT_OFF false #else @@ -354,9 +354,9 @@ bool target_direction; // these are the default values, can be overriden with M665 float delta_radius = DELTA_RADIUS; float delta_tower1_x = -SIN_60 * delta_radius; // front left tower - float delta_tower1_y = -COS_60 * delta_radius; + float delta_tower1_y = -COS_60 * delta_radius; float delta_tower2_x = SIN_60 * delta_radius; // front right tower - float delta_tower2_y = -COS_60 * delta_radius; + float delta_tower2_y = -COS_60 * delta_radius; float delta_tower3_x = 0; // back middle tower float delta_tower3_y = delta_radius; float delta_diagonal_rod = DELTA_DIAGONAL_ROD; @@ -665,7 +665,7 @@ void setup() { #endif // Z_PROBE_SLED setup_homepin(); - + #ifdef STAT_LED_RED pinMode(STAT_LED_RED, OUTPUT); digitalWrite(STAT_LED_RED, LOW); // turn it off @@ -674,7 +674,7 @@ void setup() { #ifdef STAT_LED_BLUE pinMode(STAT_LED_BLUE, OUTPUT); digitalWrite(STAT_LED_BLUE, LOW); // turn it off - #endif + #endif } /** @@ -748,11 +748,11 @@ void gcode_line_error(const char *err, bool doFlush=true) { void get_command() { if (drain_queued_commands_P()) return; // priority is given to non-serial commands - + #ifdef NO_TIMEOUTS static millis_t last_command_time = 0; millis_t ms = millis(); - + if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) { SERIAL_ECHOLNPGM(MSG_WAIT); last_command_time = ms; @@ -834,7 +834,7 @@ void get_command() { LCD_MESSAGEPGM(MSG_STOPPED); break; } - } + } } // If command was e-stop process now @@ -1018,7 +1018,7 @@ static void axis_is_at_home(AxisEnum axis) { #endif #ifdef SCARA - + if (axis == X_AXIS || axis == Y_AXIS) { float homeposition[3]; @@ -1026,28 +1026,28 @@ static void axis_is_at_home(AxisEnum axis) { // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (int i = 0; i < 2; i++) delta[i] -= home_offset[i]; - + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(home_offset[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(home_offset[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); @@ -1180,23 +1180,23 @@ static void setup_for_endstop_move() { static void run_z_probe() { #ifdef DELTA - + float start_z = current_position[Z_AXIS]; long start_steps = st_get_position(Z_AXIS); - + // move down slowly until you find the bed feedrate = homing_feedrate[Z_AXIS] / 4; destination[Z_AXIS] = -10; prepare_move_raw(); // this will also set_current_to_destination st_synchronize(); endstops_hit_on_purpose(); // clear endstop hit flags - + // we have to let the planner know where we are right now as it is not where we said to go. long stop_steps = st_get_position(Z_AXIS); float mm = start_z - float(start_steps - stop_steps) / axis_steps_per_unit[Z_AXIS]; current_position[Z_AXIS] = mm; sync_plan_position_delta(); - + #else // !DELTA plan_bed_level_matrix.set_to_identity(); @@ -1228,7 +1228,7 @@ static void setup_for_endstop_move() { // Get the current stepper position after bumping an endstop current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); sync_plan_position(); - + #endif // !DELTA } @@ -1242,7 +1242,7 @@ static void setup_for_endstop_move() { #ifdef DELTA feedrate = XY_TRAVEL_SPEED; - + destination[X_AXIS] = x; destination[Y_AXIS] = y; destination[Z_AXIS] = z; @@ -1309,12 +1309,12 @@ static void setup_for_endstop_move() { feedrate = homing_feedrate[X_AXIS]/10; destination[X_AXIS] = 0; prepare_move_raw(); // this will also set_current_to_destination - + // Home Y for safety feedrate = homing_feedrate[X_AXIS]/2; destination[Y_AXIS] = 0; prepare_move_raw(); // this will also set_current_to_destination - + st_synchronize(); #ifdef Z_PROBE_ENDSTOP @@ -1380,18 +1380,18 @@ static void setup_for_endstop_move() { feedrate = homing_feedrate[Z_AXIS]/10; destination[Z_AXIS] = current_position[Z_AXIS] - Z_PROBE_ALLEN_KEY_STOW_DEPTH; prepare_move_raw(); // this will also set_current_to_destination - + // Move up for safety feedrate = homing_feedrate[Z_AXIS]/2; destination[Z_AXIS] = current_position[Z_AXIS] + Z_PROBE_ALLEN_KEY_STOW_DEPTH * 2; prepare_move_raw(); // this will also set_current_to_destination - + // Home XY for safety feedrate = homing_feedrate[X_AXIS]/2; destination[X_AXIS] = 0; destination[Y_AXIS] = 0; prepare_move_raw(); // this will also set_current_to_destination - + st_synchronize(); #ifdef Z_PROBE_ENDSTOP @@ -1543,8 +1543,8 @@ static void setup_for_endstop_move() { if (dock) { float oldXpos = current_position[X_AXIS]; // save x position - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z - do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]); // Dock sled a bit closer to ensure proper capturing + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z + do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]); // Dock sled a bit closer to ensure proper capturing digitalWrite(SLED_PIN, LOW); // turn off magnet do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking } else { @@ -1589,7 +1589,7 @@ static void homeaxis(AxisEnum axis) { if (axis_home_dir < 0) dock_sled(false); } #endif - + #if SERVO_LEVELING && !defined(Z_PROBE_SLED) // Deploy a probe if there is one, and homing towards the bed @@ -1689,7 +1689,7 @@ static void homeaxis(AxisEnum axis) { // bring probe back if (axis == Z_AXIS) { if (axis_home_dir < 0) dock_sled(true); - } + } #endif #if SERVO_LEVELING && !defined(Z_PROBE_SLED) @@ -1849,54 +1849,54 @@ void plan_arc( r_axis1 = -offset[Y_AXIS], rt_axis0 = target[X_AXIS] - center_axis0, rt_axis1 = target[Y_AXIS] - center_axis1; - + // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += RADIANS(360); } if (clockwise) { angular_travel -= RADIANS(360); } - + // Make a circle if the angular rotation is 0 if (current_position[X_AXIS] == target[X_AXIS] && current_position[Y_AXIS] == target[Y_AXIS] && angular_travel == 0) angular_travel += RADIANS(360); - + float mm_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (mm_of_travel < 0.001) { return; } uint16_t segments = floor(mm_of_travel / MM_PER_ARC_SEGMENT); if (segments == 0) segments = 1; - + float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large MM_PER_ARC_SEGMENT values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows plan_arc to immediately insert a line segment into the planner + + This approximation also allows plan_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial plan_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial plan_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -1906,7 +1906,7 @@ void plan_arc( // Initialize the linear axis arc_target[Z_AXIS] = current_position[Z_AXIS]; - + // Initialize the extruder axis arc_target[E_AXIS] = current_position[E_AXIS]; @@ -2321,7 +2321,7 @@ inline void gcode_G28() { * | * | * v Y-axis - * + * */ inline void gcode_G29() { @@ -2448,7 +2448,7 @@ inline void gcode_G28() { * Will fail if the printer has not been homed with G28. * * Enhanced G29 Auto Bed Leveling Probe Routine - * + * * Parameters With AUTO_BED_LEVELING_GRID: * * P Set the size of the grid that will be probed (P x P points). @@ -3114,7 +3114,7 @@ inline void gcode_M42() { * V = Verbose level (0-4, default=1) * E = Engage probe for each reading * L = Number of legs of movement before probe - * + * * This function assumes the bed has been homed. Specifically, that a G28 command * as been issued prior to invoking the M48 Z-Probe repeatability measurement function. * Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -3189,7 +3189,7 @@ inline void gcode_M42() { // // Now get everything to the specified probe point So we can safely do a probe to - // get us close to the bed. If the Z-Axis is far from the bed, we don't want to + // get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // if (verbose_level > 2) @@ -3206,7 +3206,7 @@ inline void gcode_M42() { current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = E_current = st_get_position_mm(E_AXIS); - // + // // OK, do the initial probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // @@ -3270,7 +3270,7 @@ inline void gcode_M42() { } // n_legs if (deploy_probe_for_each_reading) { - deploy_z_probe(); + deploy_z_probe(); delay(1000); } @@ -3538,7 +3538,7 @@ inline void gcode_M109() { setTargetBed(code_value()); millis_t temp_ms = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -3822,13 +3822,13 @@ inline void gcode_M114() { SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_EOL; - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+home_offset[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+home_offset[Y_AXIS]); SERIAL_EOL; - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -4009,7 +4009,7 @@ inline void gcode_M204() { SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration ); SERIAL_EOL; } - + } /** @@ -4079,7 +4079,7 @@ inline void gcode_M206() { SERIAL_ECHOPAIR("Z Endstop Adjustment set to (mm):", z_endstop_adj); SERIAL_EOL; } - + #endif // !DELTA && defined(Z_DUAL_ENDSTOPS) #ifdef FWRETRACT @@ -4312,7 +4312,7 @@ inline void gcode_M226() { if (code_seen('D')) PID_PARAM(Kd, e) = scalePID_d(code_value()); #ifdef PID_ADD_EXTRUSION_RATE if (code_seen('C')) PID_PARAM(Kc, e) = code_value(); - #endif + #endif updatePID(); SERIAL_PROTOCOL(MSG_OK); @@ -4331,7 +4331,7 @@ inline void gcode_M226() { //Kc does not have scaling applied above, or in resetting defaults SERIAL_PROTOCOL(PID_PARAM(Kc, e)); #endif - SERIAL_EOL; + SERIAL_EOL; } else { SERIAL_ECHO_START; @@ -4369,11 +4369,11 @@ inline void gcode_M226() { */ inline void gcode_M240() { #ifdef CHDK - + OUT_WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #elif HAS_PHOTOGRAPH const uint8_t NUM_PULSES = 16; @@ -4615,7 +4615,7 @@ inline void gcode_M400() { st_synchronize(); } } #endif } - + /** * M405: Turn on filament sensor for control */ @@ -4644,13 +4644,13 @@ inline void gcode_M400() { st_synchronize(); } * M406: Turn off filament sensor for control */ inline void gcode_M406() { filament_sensor = false; } - + /** * M407: Get measured filament diameter on serial output */ inline void gcode_M407() { - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); } #endif // FILAMENT_SENSOR @@ -4908,12 +4908,12 @@ inline void gcode_M503() { plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move xy back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract - #endif + #endif #ifdef FILAMENT_RUNOUT_SENSOR filrunoutEnqueued = false; #endif - + } #endif // FILAMENTCHANGEENABLE @@ -5735,14 +5735,14 @@ void ok_to_send() { SERIAL_PROTOCOLPGM(" P"); SERIAL_PROTOCOL(int(BLOCK_BUFFER_SIZE - movesplanned() - 1)); SERIAL_PROTOCOLPGM(" B"); SERIAL_PROTOCOL(BUFSIZE - commands_in_queue); #endif - SERIAL_EOL; + SERIAL_EOL; } void clamp_to_software_endstops(float target[3]) { if (min_software_endstops) { NOLESS(target[X_AXIS], min_pos[X_AXIS]); NOLESS(target[Y_AXIS], min_pos[Y_AXIS]); - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset += Z_PROBE_OFFSET_FROM_EXTRUDER; @@ -6121,49 +6121,49 @@ void prepare_move() { //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); - } + } void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -6241,7 +6241,7 @@ void idle() { * - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT) */ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { - + #if HAS_FILRUNOUT if (IS_SD_PRINTING && !(READ(FILRUNOUT_PIN) ^ FIL_RUNOUT_INVERTING)) filrunout(); @@ -6265,7 +6265,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { #endif #if HAS_KILL - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -6298,7 +6298,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { homeDebounceCount = 0; } #endif - + #if HAS_CONTROLLERFAN controllerFan(); // Check if fan should be turned on to cool stepper drivers down #endif @@ -6395,7 +6395,7 @@ void kill(const char *lcd_msg) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for (int i = 5; i--; lcd_update()) delay(200); // Wait a short time diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2Card.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2Card.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2PinMap.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2PinMap.h index 97fea8bb..415be2d8 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2PinMap.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/Sd2PinMap.h @@ -314,12 +314,12 @@ static const pin_map_t digitalPinMap[] = { }; #elif defined(__AVR_ATmega1281__) // Waspmote - + // Two Wire (aka I2C) ports uint8_t const SDA_PIN = 41; uint8_t const SCL_PIN = 40; - - + + #undef MOSI_PIN #undef MISO_PIN // SPI port @@ -327,7 +327,7 @@ uint8_t const SS_PIN = 16; // B0 uint8_t const MOSI_PIN = 11; // B2 uint8_t const MISO_PIN = 12; // B3 uint8_t const SCK_PIN = 10; // B1 - + static const pin_map_t digitalPinMap[] = { {&DDRE, &PINE, &PORTE, 0}, // E0 0 {&DDRE, &PINE, &PORTE, 1}, // E1 1 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdBaseFile.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdBaseFile.cpp index f92f48e1..76f3d2a4 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdBaseFile.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdBaseFile.cpp @@ -1113,7 +1113,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) longFilename[0] = '\0'; diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFatStructs.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFatStructs.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFile.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFile.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/blinkm.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/blinkm.cpp index 1ec5b656..6499d1df 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/blinkm.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/blinkm.cpp @@ -8,7 +8,7 @@ #include "blinkm.h" void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/configuration_store.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/configuration_store.cpp index b950b88c..6e68ba24 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/configuration_store.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/configuration_store.cpp @@ -715,7 +715,7 @@ void Config_PrintSettings(bool forReplay) { CONFIG_ECHO_START; } SERIAL_ECHOPAIR(" M666 Z", z_endstop_adj); - SERIAL_EOL; + SERIAL_EOL; #endif // DELTA #ifdef ULTIPANEL @@ -752,7 +752,7 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i))); #ifdef PID_ADD_EXTRUSION_RATE SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i)); - #endif + #endif SERIAL_EOL; } } @@ -766,7 +766,7 @@ void Config_PrintSettings(bool forReplay) { SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0))); #ifdef PID_ADD_EXTRUSION_RATE SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0)); - #endif + #endif SERIAL_EOL; } #endif // PIDTEMP diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_bitmaps.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_bitmaps.h index 7c822796..8b1878c4 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_bitmaps.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_bitmaps.h @@ -1,6 +1,6 @@ // BitMap for splashscreen // Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php -// Please note that using the high-res version takes 402Bytes of PROGMEM. +// Please note that using the high-res version takes 402Bytes of PROGMEM. //#define START_BMPHIGH #ifdef START_BMPHIGH @@ -8,7 +8,7 @@ #define START_BMPHEIGHT 38 #define START_BMPBYTEWIDTH 14 #define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8 - + const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff @@ -49,11 +49,11 @@ ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 ,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80 }; #else - #ifdef GEEETECH_STARTUP_BMP + #ifdef GEEETECH_STARTUP_BMP #define START_BMPWIDTH 128 #define START_BMPHEIGHT 64 #define START_BMPBYTEWIDTH 16 - #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 + #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -186,7 +186,7 @@ }; #else - #define START_BMPWIDTH 56 + #define START_BMPWIDTH 56 #define START_BMPHEIGHT 19 #define START_BMPBYTEWIDTH 7 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 @@ -214,10 +214,10 @@ #endif #endif -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -370,6 +370,6 @@ 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_lcd_implementation.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_lcd_implementation.h index 257ea039..a8290e01 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_lcd_implementation.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/dogm_lcd_implementation.h @@ -197,7 +197,7 @@ static void lcd_implementation_init() { digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // FIXME: remove this workaround // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight @@ -210,7 +210,7 @@ static void lcd_implementation_init() { #elif defined(LCD_SCREEN_ROT_270) u8g.setRot270(); // Rotate screen by 270° #endif - + // Show splashscreen int offx = (u8g.getWidth() - START_BMPWIDTH) / 2; #ifdef START_BMPHIGH @@ -277,7 +277,7 @@ static void lcd_implementation_status_screen() { // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT // SD Card Symbol u8g.drawBox(42, 42 - TALL_FONT_CORRECTION, 8, 7); @@ -290,7 +290,7 @@ static void lcd_implementation_status_screen() { // SD Card Progress bar and clock lcd_setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar solid part u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION); @@ -367,7 +367,7 @@ static void lcd_implementation_status_screen() { else lcd_printPGM(PSTR("---.--")); u8g.setColorIndex(1); // black on white - + // Feedrate lcd_setFont(FONT_MENU); u8g.setPrintPos(3,49); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/fastio.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/fastio.h index 0e3b34d2..fcd19264 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/fastio.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/fastio.h @@ -2038,7 +2038,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2678,8 +2678,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_bg.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_bg.h index 3acc1748..e65e3b20 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_bg.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_bg.h @@ -7,12 +7,12 @@ */ #ifndef LANGUAGE_BG_H #define LANGUAGE_BG_H - + #define MAPPER_D0D1 // For Cyrillic // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT #define DISPLAY_CHARSET_ISO10646_5 - + #define WELCOME_MSG MACHINE_NAME " Готов." #define MSG_SD_INSERTED "Картата е поставена" #define MSG_SD_REMOVED "Картата е извадена" @@ -126,7 +126,7 @@ #define MSG_ENDSTOP_ABORT "Стоп Кр.Изключватели" #define MSG_END_HOUR "часа" #define MSG_END_MINUTE "минути" - + #ifdef DELTA_CALIBRATION_MENU #define MSG_DELTA_CALIBRATE "Делта Калибровка" #define MSG_DELTA_CALIBRATE_X "Калибровка X" @@ -134,5 +134,5 @@ #define MSG_DELTA_CALIBRATE_Z "Калибровка Z" #define MSG_DELTA_CALIBRATE_CENTER "Калибровка Център" #endif // DELTA_CALIBRATION_MENU - + #endif // LANGUAGE_BG_H diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_ca.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_ca.h index 35eb0382..abbb48cf 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_ca.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_ca.h @@ -8,7 +8,7 @@ #ifndef LANGUAGE_CA_H #define LANGUAGE_CA_H -//#define MAPPER_NON +//#define MAPPER_NON #define MAPPER_C2C3 // because of "ó" // Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h //#define SIMULATE_ROMFONT diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana.h index 9a05b6bb..0198211f 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana.h @@ -5,7 +5,7 @@ * See also documentation/LCDLanguageFont.md * */ - + #ifndef LANGUAGE_KANA_H #define LANGUAGE_KANA_H diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana_utf8.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana_utf8.h index 4bb58a1e..05190040 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana_utf8.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_kana_utf8.h @@ -5,7 +5,7 @@ * See also documentation/LCDLanguageFont.md * */ - + #ifndef LANGUAGE_KANA_UTF_H #define LANGUAGE_KANA_UTF_H @@ -15,7 +15,7 @@ #define DISPLAY_CHARSET_ISO10646_KANA // This is very crude replacement of the codes used in language_kana.h from somebody who really does not know what he is doing. -// Just to show the potential benefit of unicode. +// Just to show the potential benefit of unicode. // This translation can be improved by using the full charset of unicode codeblock U+30A0 to U+30FF. // 片仮名表示定義 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_test.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_test.h index 57505bc1..1a666dcf 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_test.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/language_test.h @@ -8,16 +8,16 @@ #ifndef LANGUAGE_TEST_H #define LANGUAGE_TEST_H -// Select ONE of the following Mappers. -// They decide what to do with a symbol in the area of [0x80:0xFF]. They take a symbol of this language file and make them point +// Select ONE of the following Mappers. +// They decide what to do with a symbol in the area of [0x80:0xFF]. They take a symbol of this language file and make them point // into an array with 128 cells, where they'll find the place of the symbol of the font in use. // -// a.)For ASCII coded Language_xx.h files like (en) there are no occurrences of symbols above 0x7F so no mapper is needed. +// a.)For ASCII coded Language_xx.h files like (en) there are no occurrences of symbols above 0x7F so no mapper is needed. // If such a symbol appears it is mapped directly into the font. This is the case for the language files we used until now, with all the STR_XX or // "\xxx" symbols. All Symbols are only one byte long. // b.) For Unicoded Language_xx.h files (currently ru, de and kana_utf8 ) the non ASCII [0x00-0x7F] symbols are represented by more then one byte. // In the case of two bytes the first is pointing to a 'codepage' and the second to a place in the codepage. These codepages contain 64 symbols. -// So two of them can be mapped. For most of the European languages the necessary symbols are contained in the pages C2 and C3. Cyrillic uses D0 +// So two of them can be mapped. For most of the European languages the necessary symbols are contained in the pages C2 and C3. Cyrillic uses D0 // and D1. // c.) For katakana (one of the Japanese symbol sets) Unicode uses 3 bytes. Here the second byte also points to a codepage and byte 3 to the symbol. // I hope the pages E282 and E283 are sufficient to write katakana. @@ -124,14 +124,14 @@ #define MSG_COOLDOWN STRG_C3_9 #define MSG_SWITCH_PS_OFF STRG_C3_a #define MSG_MOVE_AXIS STRG_C3_b - + #define MSG_MAIN STRG_OKTAL_2 #define MSG_TEMPERATURE STRG_OKTAL_3 #define MSG_MOTION STRG_OKTAL_4 #define MSG_VOLUMETRIC STRG_OKTAL_5 #define MSG_CONTRAST STRG_OKTAL_6 #define MSG_RESTORE_FAILSAFE STRG_OKTAL_7 - + #define MSG_NOZZLE STRG_OKTAL_8 #define MSG_FAN_SPEED STRG_OKTAL_9 #define MSG_AUTOTEMP STRG_OKTAL_a @@ -159,14 +159,14 @@ #define MSG_COOLDOWN STRG_D1_9 #define MSG_SWITCH_PS_OFF STRG_D1_a #define MSG_MOVE_AXIS STRG_D1_b - + #define MSG_MAIN STRG_OKTAL_2 #define MSG_TEMPERATURE STRG_OKTAL_3 #define MSG_MOTION STRG_OKTAL_4 #define MSG_VOLUMETRIC STRG_OKTAL_5 #define MSG_CONTRAST STRG_OKTAL_6 #define MSG_RESTORE_FAILSAFE STRG_OKTAL_7 - + #define MSG_NOZZLE STRG_OKTAL_8 #define MSG_FAN_SPEED STRG_OKTAL_9 #define MSG_AUTOTEMP STRG_OKTAL_a @@ -194,14 +194,14 @@ #define MSG_COOLDOWN STRG_E383_9 #define MSG_SWITCH_PS_OFF STRG_E383_a #define MSG_MOVE_AXIS STRG_E383_b - + #define MSG_MAIN STRG_OKTAL_2 #define MSG_TEMPERATURE STRG_OKTAL_3 #define MSG_MOTION STRG_OKTAL_4 #define MSG_VOLUMETRIC STRG_OKTAL_5 #define MSG_CONTRAST STRG_OKTAL_6 #define MSG_RESTORE_FAILSAFE STRG_OKTAL_7 - + #define MSG_NOZZLE STRG_OKTAL_8 #define MSG_FAN_SPEED STRG_OKTAL_9 #define MSG_AUTOTEMP STRG_OKTAL_a diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.cpp index a48a6e61..047ad991 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.cpp @@ -5,7 +5,7 @@ mesh_bed_leveling mbl; mesh_bed_leveling::mesh_bed_leveling() { reset(); } - + void mesh_bed_leveling::reset() { active = 0; for (int y = 0; y < MESH_NUM_Y_POINTS; y++) diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.h index bf7275e5..ba051130 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/mesh_bed_leveling.h @@ -9,33 +9,33 @@ public: uint8_t active; float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS]; - + mesh_bed_leveling(); - + void reset(); - + float get_x(int i) { return MESH_MIN_X + MESH_X_DIST * i; } float get_y(int i) { return MESH_MIN_Y + MESH_Y_DIST * i; } void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; } - + int select_x_index(float x) { int i = 1; while (x > get_x(i) && i < MESH_NUM_X_POINTS-1) i++; return i - 1; } - + int select_y_index(float y) { int i = 1; while (y > get_y(i) && i < MESH_NUM_Y_POINTS - 1) i++; return i - 1; } - + float calc_z0(float a0, float a1, float z1, float a2, float z2) { float delta_z = (z2 - z1)/(a2 - a1); float delta_a = a0 - a1; return z1 + delta_a * delta_z; } - + float get_z(float x0, float y0) { int x_index = select_x_index(x0); int y_index = select_y_index(y0); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins.h index d53f2259..89062e30 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins.h @@ -194,7 +194,7 @@ #endif #ifdef DISABLE_XMIN_ENDSTOP - #undef X_MIN_PIN + #undef X_MIN_PIN #define X_MIN_PIN -1 #endif @@ -213,7 +213,7 @@ #endif #ifdef DISABLE_ZMIN_ENDSTOP - #undef Z_MIN_PIN + #undef Z_MIN_PIN #define Z_MIN_PIN -1 #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3.h index e961e7a2..4a54f84d 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3.h @@ -11,18 +11,18 @@ #if defined(VIKI2) || defined(miniVIKI) #define BEEPER 33 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 31 - #define DOGLCD_CS 32 + #define DOGLCD_A0 31 + #define DOGLCD_CS 32 #define LCD_SCREEN_ROT_180 - - //The encoder and click button - #define BTN_EN1 22 + + //The encoder and click button + #define BTN_EN1 22 #define BTN_EN2 7 #define BTN_ENC 12 //the click switch - + #define SDSS 53 - #define SDCARDDETECT -1 // Pin 49 if using display sd interface - + #define SDCARDDETECT -1 // Pin 49 if using display sd interface + #ifdef TEMP_STAT_LEDS #define STAT_LED_RED 64 #define STAT_LED_BLUE 63 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3_PRO.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3_PRO.h index 83de4520..69fc3884 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3_PRO.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_AZTEEG_X3_PRO.h @@ -15,7 +15,7 @@ #define EXTRUDER_3_AUTO_FAN_PIN 5 // //This section is to swap the MIN and MAX pins because the X3 Pro comes with only -//MIN endstops soldered onto the board. Delta code wants the homing endstops to be +//MIN endstops soldered onto the board. Delta code wants the homing endstops to be //the MAX so I swapped them here. // #ifdef DELTA @@ -73,7 +73,7 @@ // //These Servo pins are for when they are defined. Tested for usage with bed leveling -//on a Delta with 1 servo. Running through the Z servo endstop in code. +//on a Delta with 1 servo. Running through the Z servo endstop in code. //Physical wire attachment was done on EXT1 on the GND, 5V, and D47 pins. // #undef SERVO0_PIN @@ -102,15 +102,15 @@ #define DOGLCD_A0 44 #define DOGLCD_CS 45 #define LCD_SCREEN_ROT_180 - + //The encoder and click button #define BTN_EN1 22 #define BTN_EN2 7 #define BTN_ENC 39 //the click switch - + #define SDSS 53 #define SDCARDDETECT 49 - + #define KILL_PIN 31 #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN3_PLUS.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN3_PLUS.h index 4d216bb8..5e74f34e 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN3_PLUS.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN3_PLUS.h @@ -37,9 +37,9 @@ #define E0_ENABLE_PIN 13 #define TEMP_0_PIN 0 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 33 extruder) -#define TEMP_1_PIN -1 +#define TEMP_1_PIN -1 #define TEMP_2_PIN -1 -#define TEMP_BED_PIN 5 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed) +#define TEMP_BED_PIN 5 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed) #define SDPOWER -1 #define SDSS 4 #define HEATER_2_PIN -1 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN7_CUSTOM.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN7_CUSTOM.h index a8626ece..5e9ffc6c 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN7_CUSTOM.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_GEN7_CUSTOM.h @@ -3,7 +3,7 @@ * * These Pins are assigned for the modified GEN7 Board from Alfons3. * Please review the pins and adjust them for your needs. - */ + */ #if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__) #error Oops! Make sure you have 'Gen7' selected from the 'Tools -> Boards' menu. diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_MEGATRONICS_3.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_MEGATRONICS_3.h index ed627274..f4f4a5c4 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_MEGATRONICS_3.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_MEGATRONICS_3.h @@ -31,17 +31,17 @@ #define X_DIR_PIN 57 #define X_ENABLE_PIN 59 #define X_MIN_PIN 37 -#define X_MAX_PIN 40 // put to -1 to disable +#define X_MAX_PIN 40 // put to -1 to disable -#define Y_STEP_PIN 5 -#define Y_DIR_PIN 17 +#define Y_STEP_PIN 5 +#define Y_DIR_PIN 17 #define Y_ENABLE_PIN 4 #define Y_MIN_PIN 41 #define Y_MAX_PIN 38 // put to -1 to disable -#define Z_STEP_PIN 16 +#define Z_STEP_PIN 16 #define Z_DIR_PIN 11 -#define Z_ENABLE_PIN 3 +#define Z_ENABLE_PIN 3 #define Z_MIN_PIN 18 #define Z_MAX_PIN 19 // put to -1 to disable diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_PRINTRBOARD.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_PRINTRBOARD.h index 74deb915..df27fde9 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_PRINTRBOARD.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_PRINTRBOARD.h @@ -86,7 +86,7 @@ #define SDSS 40 //use SD card on Panelolu2 (Teensyduino pin mapping) #endif // LCD_I2C_PANELOLU2 //not connected to a pin - #define SDCARDDETECT -1 + #define SDCARDDETECT -1 #endif // ULTRA_LCD && NEWPANEL #if defined(VIKI2) || defined(miniVIKI) @@ -95,17 +95,17 @@ #define DOGLCD_A0 42 //Non-FastIO #define DOGLCD_CS 43 //Non-FastIO #define LCD_SCREEN_ROT_180 - + //The encoder and click button (FastIO Pins) - #define BTN_EN1 26 + #define BTN_EN1 26 #define BTN_EN2 27 #define BTN_ENC 47 //the click switch #define SDSS 45 - #define SDCARDDETECT -1 // FastIO (Manual says 72 I'm not certain cause I can't test) + #define SDCARDDETECT -1 // FastIO (Manual says 72 I'm not certain cause I can't test) #ifdef TEMP_STAT_LEDS #define STAT_LED_RED 12 //Non-FastIO #define STAT_LED_BLUE 10 //Non-FastIO - #endif + #endif #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_RAMBO.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_RAMBO.h index 4c008d6c..7a0ee906 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_RAMBO.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_RAMBO.h @@ -36,7 +36,7 @@ #undef E0_MS2_PIN #undef E1_MS1_PIN #undef E1_MS2_PIN - + #define X_STEP_PIN 37 #define X_DIR_PIN 48 #define X_MIN_PIN 12 @@ -97,7 +97,7 @@ #define SDPOWER -1 #define SDSS 53 #define LED_PIN 13 -#define FAN_PIN 8 +#define FAN_PIN 8 /********************************************************** Fan Pins @@ -167,24 +167,24 @@ #if defined(VIKI2) || defined(miniVIKI) #define BEEPER 44 // Pins for DOGM SPI LCD Support - #define DOGLCD_A0 70 - #define DOGLCD_CS 71 + #define DOGLCD_A0 70 + #define DOGLCD_CS 71 #define LCD_SCREEN_ROT_180 - - //The encoder and click button - #define BTN_EN1 85 + + //The encoder and click button + #define BTN_EN1 85 #define BTN_EN2 84 #define BTN_ENC 83 //the click switch - #define SDCARDDETECT -1 // Pin 72 if using easy adapter board + #define SDCARDDETECT -1 // Pin 72 if using easy adapter board #ifdef TEMP_STAT_LEDS #define STAT_LED_RED 22 - #define STAT_LED_BLUE 32 + #define STAT_LED_BLUE 32 #endif #endif // VIKI2/miniVIKI #ifdef FILAMENT_SENSOR - //Filip added pin for Filament sensor analog input + //Filip added pin for Filament sensor analog input #define FILWIDTH_PIN 3 #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSY2.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSY2.h index c7144266..f893970f 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSY2.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSY2.h @@ -11,32 +11,32 @@ * * USB * GND GND |-----#####-----| +5V ATX +5SB - * ATX PS_ON PWM 27 |b7 ##### b6| 26 PWM* Stepper Enable - * PWM 0 |d0 b5| 25 PWM* - * PWM 1 |d1 b4| 24 PWM + * ATX PS_ON PWM 27 |b7 ##### b6| 26 PWM* Stepper Enable + * PWM 0 |d0 b5| 25 PWM* + * PWM 1 |d1 b4| 24 PWM * X_MIN 2 |d2 b3| 23 MISO_PIN * Y_MIN 3 |d3 b2| 22 MOSI_PIN - * Z_MIN 4 |d4 * * b1| 21 SCK_PIN - * 5 |d5 e e b0| 20 SDSS - * LED 6 |d6 5 4 e7| 19 - * 7 |d7 e6| 18 - * LCD RS 8 |e0 | GND - * LCD EN 9 |e1 a4 a0 R| AREF - * LCD D4 10 |c0 a5 a1 f0| 38 A0 ENC_1 + * Z_MIN 4 |d4 * * b1| 21 SCK_PIN + * 5 |d5 e e b0| 20 SDSS + * LED 6 |d6 5 4 e7| 19 + * 7 |d7 e6| 18 + * LCD RS 8 |e0 | GND + * LCD EN 9 |e1 a4 a0 R| AREF + * LCD D4 10 |c0 a5 a1 f0| 38 A0 ENC_1 * LCD D5 11 |c1 a6 a2 f1| 39 A1 ENC_2 * LCD D6 12 |c2 a7 a3 f2| 40 A2 ENC_CLK - * LCD D6 13 |c3 f3| 41 A3 - * Bed Heat PWM 14 |c4 V G R f4| 42 A4 - * Extruder Heat PWM 15 |c5 c n S f5| 43 A5 + * LCD D6 13 |c3 f3| 41 A3 + * Bed Heat PWM 14 |c4 V G R f4| 42 A4 + * Extruder Heat PWM 15 |c5 c n S f5| 43 A5 * Fan PWM 16 |c6 c d T f6| 44 A6 Bed TC - * 17 |c7 * * * f7| 45 A7 Extruder TC * 4.7k * +5 - * ----------------- + * 17 |c7 * * * f7| 45 A7 Extruder TC * 4.7k * +5 + * ----------------- * * Interior E4: 36, INT4 * Interior E5: 37, INT5 * Interior PA0-7: 28-35 -- Printrboard and Teensylu use these pins for step & direction: * T++ PA Signal Marlin - * + * * Z STEP 32 a4 a0 28 X STEP * Z DIR 33 a5 a1 29 X DIR * E STEP 34 a6 a2 30 Y STEP @@ -58,7 +58,7 @@ #define X_STEP_PIN 28 // 0 Marlin #define X_DIR_PIN 29 // 1 Marlin -#define X_ENABLE_PIN 26 +#define X_ENABLE_PIN 26 #define Y_STEP_PIN 30 // 2 Marlin #define Y_DIR_PIN 31 // 3 @@ -88,7 +88,7 @@ #define TEMP_2_PIN -1 #define SDPOWER -1 -#define SDCARDDETECT -1 +#define SDCARDDETECT -1 #define SDSS 20 // 8 #define LED_PIN 6 #define PS_ON_PIN 27 diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSYLU.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSYLU.h index 46da7d29..0c2b8b71 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSYLU.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/pins_TEENSYLU.h @@ -80,6 +80,6 @@ #define SDSS 40 //use SD card on Panelolu2 (Teensyduino pin mapping) #endif // LCD_I2C_PANELOLU2 //not connected to a pin - #define SDCARDDETECT -1 + #define SDCARDDETECT -1 #endif // ULTRA_LCD && NEWPANEL diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.cpp index 02bde487..a6dedec1 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.cpp @@ -1,7 +1,7 @@ /** * planner.cpp - Buffer movement commands and manage the acceleration profile plan * Part of Grbl - * + * * Copyright (c) 2009-2011 Simen Svale Skogsrud * * Grbl is free software: you can redistribute it and/or modify @@ -134,14 +134,14 @@ unsigned char g_uc_extruder_last_move[4] = {0,0,0,0}; FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); } FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); } -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0 return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2); } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) @@ -179,7 +179,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance * entry_factor * entry_factor; + volatile long initial_advance = block->advance * entry_factor * entry_factor; volatile long final_advance = block->advance * exit_factor * exit_factor; #endif // ADVANCE @@ -197,16 +197,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity * target_velocity - 2 * acceleration * distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -229,7 +229,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if (!current->nominal_length_flag && current->max_entry_speed > next->entry_speed) { current->entry_speed = min(current->max_entry_speed, max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -239,16 +239,16 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if (BLOCK_MOD(block_buffer_head - tail + BLOCK_BUFFER_SIZE) > 3) { // moves queued block_index = BLOCK_MOD(block_buffer_head - 3); block_t *block[3] = { NULL, NULL, NULL }; @@ -300,8 +300,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -332,22 +332,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster acceleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster acceleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -356,7 +356,7 @@ void planner_recalculate() { void plan_init() { block_buffer_head = block_buffer_tail = 0; memset(position, 0, sizeof(position)); // clear position - for (int i=0; ie_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block uint8_t db = 0; #ifdef COREXY if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis @@ -562,10 +562,10 @@ float junction_deviation = 0.1; if (dx - dy < 0) db |= BIT(B_AXIS); // Motor B direction #else if (dx < 0) db |= BIT(X_AXIS); - if (dy < 0) db |= BIT(Y_AXIS); + if (dy < 0) db |= BIT(Y_AXIS); #endif if (dz < 0) db |= BIT(Z_AXIS); - if (de < 0) db |= BIT(E_AXIS); + if (de < 0) db |= BIT(E_AXIS); block->direction_bits = db; block->active_extruder = extruder; @@ -591,7 +591,7 @@ float junction_deviation = 0.1; for (int i=0; i 0) g_uc_extruder_last_move[i]--; - + switch(extruder) { case 0: enable_e0(); @@ -655,13 +655,13 @@ float junction_deviation = 0.1; NOLESS(feed_rate, mintravelfeedrate); /** - * This part of the code calculates the total length of the movement. + * This part of the code calculates the total length of the movement. * For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS. * But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS * and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y. - * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. + * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. - */ + */ #ifdef COREXY float delta_mm[6]; delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS]; @@ -678,7 +678,7 @@ float junction_deviation = 0.1; if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { block->millimeters = sqrt( #ifdef COREXY @@ -689,7 +689,7 @@ float junction_deviation = 0.1; + square(delta_mm[Z_AXIS]) ); } - float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -722,7 +722,7 @@ float junction_deviation = 0.1; #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - + if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) { //only for extruder with filament sensor and if ring buffer is initialized const int MMD = MAX_MEASUREMENT_DELAY + 1, MMD10 = MMD * 10; @@ -763,7 +763,7 @@ float junction_deviation = 0.1; unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + long xs0 = axis_segment_time[X_AXIS][0], xs1 = axis_segment_time[X_AXIS][1], xs2 = axis_segment_time[X_AXIS][2], @@ -794,14 +794,14 @@ float junction_deviation = 0.1; } #endif // XY_FREQUENCY_LIMIT - // Correct the speed + // Correct the speed if (speed_factor < 1.0) { for (unsigned char i = 0; i < NUM_AXIS; i++) current_speed[i] *= speed_factor; block->nominal_speed *= speed_factor; block->nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count / block->millimeters; long bsx = block->steps[X_AXIS], bsy = block->steps[Y_AXIS], bsz = block->steps[Z_AXIS], bse = block->steps[E_AXIS]; if (bsx == 0 && bsy == 0 && bsz == 0) { @@ -823,7 +823,7 @@ float junction_deviation = 0.1; if ((float)acc_st * bsy / block->step_event_count > ysteps) acc_st = ysteps; if ((float)acc_st * bsz / block->step_event_count > zsteps) acc_st = zsteps; if ((float)acc_st * bse / block->step_event_count > esteps) acc_st = esteps; - + block->acceleration_st = acc_st; block->acceleration = acc_st / steps_per_mm; block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0)); @@ -871,7 +871,7 @@ float junction_deviation = 0.1; // Start with a safe speed float vmax_junction = max_xy_jerk / 2; - float vmax_junction_factor = 1.0; + float vmax_junction_factor = 1.0; float mz2 = max_z_jerk / 2, me2 = max_e_jerk / 2; float csz = current_speed[Z_AXIS], cse = current_speed[E_AXIS]; if (fabs(csz) > mz2) vmax_junction = min(vmax_junction, mz2); @@ -909,7 +909,7 @@ float junction_deviation = 0.1; // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - block->nominal_length_flag = (block->nominal_speed <= v_allowable); + block->nominal_length_flag = (block->nominal_speed <= v_allowable); block->recalculate_flag = true; // Always calculate trapezoid for new block // Update previous path unit_vector and nominal speed @@ -989,7 +989,7 @@ float junction_deviation = 0.1; } void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.h index c54ed441..37eae095 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef PLANNER_H @@ -26,7 +26,7 @@ #include "Marlin.h" -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -46,7 +46,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -55,8 +55,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -69,7 +69,7 @@ typedef struct { #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1)) -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); void check_axes_activity(); @@ -142,7 +142,7 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Returns true if the buffer has a queued block, false otherwise FORCE_INLINE bool blocks_queued() { return (block_buffer_head != block_buffer_tail); } diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.cpp index 4202db06..1b2121f5 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -647,7 +647,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -672,7 +672,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -756,7 +756,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -774,7 +774,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -968,7 +968,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1005,7 +1005,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1041,7 +1041,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1159,7 +1159,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1189,7 +1189,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1277,7 +1277,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1343,7 +1343,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1616,14 +1616,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1648,7 +1648,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1738,7 +1738,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1756,8 +1756,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1919,7 +1919,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/servo.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/servo.cpp index 81d73ae8..1084017e 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/servo.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/speed_lookuptable.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/speed_lookuptable.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.cpp index 32d2c9e2..1809f8f3 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.cpp @@ -50,8 +50,8 @@ static unsigned char out_bits = 0; // The next stepping-bits to be output static unsigned int cleaning_buffer_counter; #ifdef Z_DUAL_ENDSTOPS - static bool performing_homing = false, - locked_z_motor = false, + static bool performing_homing = false, + locked_z_motor = false, locked_z2_motor = false; #endif @@ -344,7 +344,7 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) { // set the stepper direction of each axis void set_stepper_direction() { - + // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY) if (TEST(out_bits, X_AXIS)) { X_APPLY_DIR(INVERT_X_DIR,0); @@ -363,7 +363,7 @@ void set_stepper_direction() { Y_APPLY_DIR(!INVERT_Y_DIR,0); count_direction[Y_AXIS] = 1; } - + if (TEST(out_bits, Z_AXIS)) { Z_APPLY_DIR(INVERT_Z_DIR,0); count_direction[Z_AXIS] = -1; @@ -372,7 +372,7 @@ void set_stepper_direction() { Z_APPLY_DIR(!INVERT_Z_DIR,0); count_direction[Z_AXIS] = 1; } - + #ifndef ADVANCE if (TEST(out_bits, E_AXIS)) { REV_E_DIR(); @@ -393,7 +393,7 @@ FORCE_INLINE void trapezoid_generator_reset() { out_bits = current_block->direction_bits; set_stepper_direction(); } - + #ifdef ADVANCE advance = current_block->initial_advance; final_advance = current_block->final_advance; @@ -469,7 +469,7 @@ ISR(TIMER1_COMPA_vect) { // Check endstops if (check_endstops) { - + #ifdef Z_DUAL_ENDSTOPS uint16_t #else @@ -497,7 +497,7 @@ ISR(TIMER1_COMPA_vect) { _ENDSTOP_HIT(AXIS); \ step_events_completed = current_block->step_event_count; \ } - + #ifdef COREXY // Head direction in -X axis for CoreXY bots. // If DeltaX == -DeltaY, the movement is only in Y axis @@ -612,10 +612,10 @@ ISR(TIMER1_COMPA_vect) { #endif // !Z_DUAL_ENDSTOPS #endif // Z_MAX_PIN - + #ifdef Z_PROBE_ENDSTOP UPDATE_ENDSTOP(Z, PROBE); - + if (TEST_ENDSTOP(Z_PROBE)) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; @@ -1040,7 +1040,7 @@ void st_init() { enable_endstops(true); // Start with endstops active. After homing they can be disabled sei(); - + set_stepper_direction(); // Init directions to out_bits = 0 } @@ -1124,7 +1124,7 @@ void quickStop() { case Y_AXIS: BABYSTEP_AXIS(y, Y, false); break; - + case Z_AXIS: { #ifndef DELTA @@ -1145,13 +1145,13 @@ void quickStop() { X_DIR_WRITE(INVERT_X_DIR^z_direction); Y_DIR_WRITE(INVERT_Y_DIR^z_direction); Z_DIR_WRITE(INVERT_Z_DIR^z_direction); - //perform step + //perform step X_STEP_WRITE(!INVERT_X_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN); delayMicroseconds(2); - X_STEP_WRITE(INVERT_X_STEP_PIN); - Y_STEP_WRITE(INVERT_Y_STEP_PIN); + X_STEP_WRITE(INVERT_X_STEP_PIN); + Y_STEP_WRITE(INVERT_Y_STEP_PIN); Z_STEP_WRITE(INVERT_Z_STEP_PIN); //get old pin state back. X_DIR_WRITE(old_x_dir_pin); @@ -1161,7 +1161,7 @@ void quickStop() { #endif } break; - + default: break; } } diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.h index 15d81433..30a5a708 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" #include "stepper_indirection.h" @@ -42,7 +42,7 @@ #define E_STEP_WRITE(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_extruder == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }} - #endif + #endif #else #define E_STEP_WRITE(v) E0_STEP_WRITE(v) #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR) @@ -75,7 +75,7 @@ long st_get_position(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -106,5 +106,5 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.cpp index 03c4a3c4..9ba45ce8 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.cpp @@ -1,5 +1,5 @@ /* - stepper_indirection.c - stepper motor driver indirection + stepper_indirection.c - stepper motor driver indirection to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation Part of Marlin @@ -57,7 +57,7 @@ #endif #ifdef E3_IS_TMC TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR); -#endif +#endif #ifdef HAVE_TMCDRIVER void tmc_init() @@ -142,7 +142,7 @@ void tmc_init() #endif #ifdef E3_IS_L6470 L6470 stepperE3(E3_ENABLE_PIN); -#endif +#endif // init routine @@ -218,7 +218,7 @@ void L6470_init() stepperE3.setMicroSteps(E3_MICROSTEPS); stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection stepperE3.setStallCurrent(E3_STALLCURRENT); -#endif +#endif } #endif diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.h index 408fccbe..b69f1aa2 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/stepper_indirection.h @@ -153,7 +153,7 @@ #define E3_ENABLE_READ READ(E3_ENABLE_PIN) ////////////////////////////////// -// Pin redefines for TMC drivers. +// Pin redefines for TMC drivers. // TMC26X drivers have step and dir on normal pins, but everything else via SPI ////////////////////////////////// #ifdef HAVE_TMCDRIVER @@ -163,120 +163,120 @@ void tmc_init(); #ifdef X_IS_TMC extern TMC26XStepper stepperX; - #undef X_ENABLE_INIT + #undef X_ENABLE_INIT #define X_ENABLE_INIT ((void)0) - + #undef X_ENABLE_WRITE #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE) - + #undef X_ENABLE_READ #define X_ENABLE_READ stepperX.isEnabled() - + #endif #ifdef X2_IS_TMC extern TMC26XStepper stepperX2; #undef X2_ENABLE_INIT #define X2_ENABLE_INIT ((void)0) - + #undef X2_ENABLE_WRITE #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE) - + #undef X2_ENABLE_READ - #define X2_ENABLE_READ stepperX2.isEnabled() + #define X2_ENABLE_READ stepperX2.isEnabled() #endif #ifdef Y_IS_TMC extern TMC26XStepper stepperY; #undef Y_ENABLE_INIT #define Y_ENABLE_INIT ((void)0) - + #undef Y_ENABLE_WRITE #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE) - + #undef Y_ENABLE_READ - #define Y_ENABLE_READ stepperY.isEnabled() + #define Y_ENABLE_READ stepperY.isEnabled() #endif #ifdef Y2_IS_TMC extern TMC26XStepper stepperY2; #undef Y2_ENABLE_INIT #define Y2_ENABLE_INIT ((void)0) - + #undef Y2_ENABLE_WRITE #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE) - + #undef Y2_ENABLE_READ - #define Y2_ENABLE_READ stepperY2.isEnabled() + #define Y2_ENABLE_READ stepperY2.isEnabled() #endif #ifdef Z_IS_TMC extern TMC26XStepper stepperZ; #undef Z_ENABLE_INIT #define Z_ENABLE_INIT ((void)0) - + #undef Z_ENABLE_WRITE #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE) - + #undef Z_ENABLE_READ - #define Z_ENABLE_READ stepperZ.isEnabled() + #define Z_ENABLE_READ stepperZ.isEnabled() #endif #ifdef Z2_IS_TMC extern TMC26XStepper stepperZ2; #undef Z2_ENABLE_INIT #define Z2_ENABLE_INIT ((void)0) - + #undef Z2_ENABLE_WRITE #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE) - + #undef Z2_ENABLE_READ - #define Z2_ENABLE_READ stepperZ2.isEnabled() + #define Z2_ENABLE_READ stepperZ2.isEnabled() #endif #ifdef E0_IS_TMC extern TMC26XStepper stepperE0; #undef E0_ENABLE_INIT #define E0_ENABLE_INIT ((void)0) - + #undef E0_ENABLE_WRITE #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE) - + #undef E0_ENABLE_READ - #define E0_ENABLE_READ stepperE0.isEnabled() + #define E0_ENABLE_READ stepperE0.isEnabled() #endif #ifdef E1_IS_TMC extern TMC26XStepper stepperE1; #undef E1_ENABLE_INIT #define E1_ENABLE_INIT ((void)0) - + #undef E1_ENABLE_WRITE #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE) - + #undef E1_ENABLE_READ - #define E1_ENABLE_READ stepperE1.isEnabled() + #define E1_ENABLE_READ stepperE1.isEnabled() #endif #ifdef E2_IS_TMC extern TMC26XStepper stepperE2; #undef E2_ENABLE_INIT #define E2_ENABLE_INIT ((void)0) - + #undef E2_ENABLE_WRITE #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE) - + #undef E2_ENABLE_READ - #define E2_ENABLE_READ stepperE2.isEnabled() + #define E2_ENABLE_READ stepperE2.isEnabled() #endif #ifdef E3_IS_TMC extern TMC26XStepper stepperE3; #undef E3_ENABLE_INIT #define E3_ENABLE_INIT ((void)0) - + #undef E3_ENABLE_WRITE #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE) - + #undef E3_ENABLE_READ - #define E3_ENABLE_READ stepperE3.isEnabled() + #define E3_ENABLE_READ stepperE3.isEnabled() #endif #endif // HAVE_TMCDRIVER ////////////////////////////////// -// Pin redefines for L6470 drivers. +// Pin redefines for L6470 drivers. // L640 drivers have step on normal pins, but dir and everything else via SPI ////////////////////////////////// #ifdef HAVE_L6470DRIVER @@ -287,42 +287,42 @@ void L6470_init(); #ifdef X_IS_L6470 extern L6470 stepperX; - #undef X_ENABLE_INIT + #undef X_ENABLE_INIT #define X_ENABLE_INIT ((void)0) - + #undef X_ENABLE_WRITE #define X_ENABLE_WRITE(STATE) {if(STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree();} - + #undef X_ENABLE_READ #define X_ENABLE_READ (stepperX.getStatus() & STATUS_HIZ) - - #undef X_DIR_INIT + + #undef X_DIR_INIT #define X_DIR_INIT ((void)0) - + #undef X_DIR_WRITE #define X_DIR_WRITE(STATE) stepperX.Step_Clock(STATE) - + #undef X_DIR_READ #define X_DIR_READ (stepperX.getStatus() & STATUS_DIR) - + #endif #ifdef X2_IS_L6470 extern L6470 stepperX2; #undef X2_ENABLE_INIT #define X2_ENABLE_INIT ((void)0) - + #undef X2_ENABLE_WRITE #define X2_ENABLE_WRITE(STATE) (if(STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree();) - + #undef X2_ENABLE_READ #define X2_ENABLE_READ (stepperX2.getStatus() & STATUS_HIZ) - - #undef X2_DIR_INIT + + #undef X2_DIR_INIT #define X2_DIR_INIT ((void)0) - + #undef X2_DIR_WRITE #define X2_DIR_WRITE(STATE) stepperX2.Step_Clock(STATE) - + #undef X2_DIR_READ #define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR) #endif @@ -330,161 +330,161 @@ extern L6470 stepperY; #undef Y_ENABLE_INIT #define Y_ENABLE_INIT ((void)0) - + #undef Y_ENABLE_WRITE #define Y_ENABLE_WRITE(STATE) (if(STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree();) - + #undef Y_ENABLE_READ #define Y_ENABLE_READ (stepperY.getStatus() & STATUS_HIZ) - - #undef Y_DIR_INIT + + #undef Y_DIR_INIT #define Y_DIR_INIT ((void)0) - + #undef Y_DIR_WRITE #define Y_DIR_WRITE(STATE) stepperY.Step_Clock(STATE) - + #undef Y_DIR_READ - #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR) + #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR) #endif #ifdef Y2_IS_L6470 extern L6470 stepperY2; #undef Y2_ENABLE_INIT #define Y2_ENABLE_INIT ((void)0) - + #undef Y2_ENABLE_WRITE #define Y2_ENABLE_WRITE(STATE) (if(STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree();) - + #undef Y2_ENABLE_READ #define Y2_ENABLE_READ (stepperY2.getStatus() & STATUS_HIZ) - - #undef Y2_DIR_INIT + + #undef Y2_DIR_INIT #define Y2_DIR_INIT ((void)0) - + #undef Y2_DIR_WRITE #define Y2_DIR_WRITE(STATE) stepperY2.Step_Clock(STATE) - + #undef Y2_DIR_READ - #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR) + #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR) #endif #ifdef Z_IS_L6470 extern L6470 stepperZ; #undef Z_ENABLE_INIT #define Z_ENABLE_INIT ((void)0) - + #undef Z_ENABLE_WRITE #define Z_ENABLE_WRITE(STATE) (if(STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree();) - + #undef Z_ENABLE_READ #define Z_ENABLE_READ (stepperZ.getStatus() & STATUS_HIZ) - - #undef Z_DIR_INIT + + #undef Z_DIR_INIT #define Z_DIR_INIT ((void)0) - + #undef Z_DIR_WRITE #define Z_DIR_WRITE(STATE) stepperZ.Step_Clock(STATE) - + #undef Y_DIR_READ - #define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR) + #define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR) #endif #ifdef Z2_IS_L6470 extern L6470 stepperZ2; #undef Z2_ENABLE_INIT #define Z2_ENABLE_INIT ((void)0) - + #undef Z2_ENABLE_WRITE #define Z2_ENABLE_WRITE(STATE) (if(STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree();) - + #undef Z2_ENABLE_READ #define Z2_ENABLE_READ (stepperZ2.getStatus() & STATUS_HIZ) - - #undef Z2_DIR_INIT + + #undef Z2_DIR_INIT #define Z2_DIR_INIT ((void)0) - + #undef Z2_DIR_WRITE #define Z2_DIR_WRITE(STATE) stepperZ2.Step_Clock(STATE) - + #undef Y2_DIR_READ - #define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR) + #define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR) #endif #ifdef E0_IS_L6470 extern L6470 stepperE0; #undef E0_ENABLE_INIT #define E0_ENABLE_INIT ((void)0) - + #undef E0_ENABLE_WRITE #define E0_ENABLE_WRITE(STATE) (if(STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree();) - + #undef E0_ENABLE_READ #define E0_ENABLE_READ (stepperE0.getStatus() & STATUS_HIZ) - - #undef E0_DIR_INIT + + #undef E0_DIR_INIT #define E0_DIR_INIT ((void)0) - + #undef E0_DIR_WRITE #define E0_DIR_WRITE(STATE) stepperE0.Step_Clock(STATE) - + #undef E0_DIR_READ - #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR) + #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR) #endif #ifdef E1_IS_L6470 extern L6470 stepperE1; #undef E1_ENABLE_INIT #define E1_ENABLE_INIT ((void)0) - + #undef E1_ENABLE_WRITE #define E1_ENABLE_WRITE(STATE) (if(STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree();) - + #undef E1_ENABLE_READ #define E1_ENABLE_READ (stepperE1.getStatus() & STATUS_HIZ) - - #undef E1_DIR_INIT + + #undef E1_DIR_INIT #define E1_DIR_INIT ((void)0) - + #undef E1_DIR_WRITE #define E1_DIR_WRITE(STATE) stepperE1.Step_Clock(STATE) - + #undef E1_DIR_READ - #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR) + #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR) #endif #ifdef E2_IS_L6470 extern L6470 stepperE2; #undef E2_ENABLE_INIT #define E2_ENABLE_INIT ((void)0) - + #undef E2_ENABLE_WRITE #define E2_ENABLE_WRITE(STATE) (if(STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree();) - + #undef E2_ENABLE_READ #define E2_ENABLE_READ (stepperE2.getStatus() & STATUS_HIZ) - - #undef E2_DIR_INIT + + #undef E2_DIR_INIT #define E2_DIR_INIT ((void)0) - + #undef E2_DIR_WRITE #define E2_DIR_WRITE(STATE) stepperE2.Step_Clock(STATE) - + #undef E2_DIR_READ - #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR) + #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR) #endif #ifdef E3_IS_L6470 extern L6470 stepperE3; #undef E3_ENABLE_INIT #define E3_ENABLE_INIT ((void)0) - + #undef E3_ENABLE_WRITE #define E3_ENABLE_WRITE(STATE) (if(STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree();) - + #undef E3_ENABLE_READ #define E3_ENABLE_READ (stepperE3.getStatus() & STATUS_HIZ) - - #undef E3_DIR_INIT + + #undef E3_DIR_INIT #define E3_DIR_INIT ((void)0) - + #undef E3_DIR_WRITE #define E3_DIR_WRITE(STATE) stepperE3.Step_Clock(STATE) - + #undef E3_DIR_READ - #define E3_DIR_READ (stepperE3.getStatus() & STATUS_DIR) + #define E3_DIR_READ (stepperE3.getStatus() & STATUS_DIR) #endif #endif //HAVE_L6470DRIVER diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.cpp index d55ebffd..428c9d6c 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.cpp - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -58,20 +58,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3] = { 0 }; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif #if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED) enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway }; @@ -126,7 +126,7 @@ static volatile bool temp_meas_ready = false; #endif #if HAS_AUTO_FAN static millis_t next_auto_fan_check_ms; -#endif +#endif #ifdef PIDTEMP #ifdef PID_PARAMS_PER_EXTRUDER @@ -217,7 +217,7 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN(MSG_PID_BAD_EXTRUDER_NUM); return; } - + SERIAL_ECHOLN(MSG_PID_AUTOTUNE_START); disable_all_heaters(); // switch off all heaters. @@ -312,7 +312,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min = temp; } - } + } } #define MAX_OVERSHOOT_PID_AUTOTUNE 20 if (input > temp + MAX_OVERSHOOT_PID_AUTOTUNE) { @@ -384,13 +384,13 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if HAS_AUTO_FAN_0 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if HAS_AUTO_FAN_1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; @@ -399,38 +399,38 @@ void checkExtruderAutoFans() } #endif #if HAS_AUTO_FAN_2 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif #if HAS_AUTO_FAN_3 - if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; - else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN) + else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN) fanState |= 4; else fanState |= 8; } #endif - + // update extruder auto fan states #if HAS_AUTO_FAN_0 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if HAS_AUTO_FAN_1 if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if HAS_AUTO_FAN_2 if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) @@ -649,14 +649,14 @@ void manage_heater() { checkExtruderAutoFans(); next_auto_fan_check_ms = ms + 2500; } - #endif + #endif // Control the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR if (filament_sensor) { meas_shift_index = delay_index1 - meas_delay_cm; if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed - + // Get the delayed info and add 100 to reconstitute to a percent of // the nominal filament diameter then square it to get an area meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY); @@ -672,7 +672,7 @@ void manage_heater() { #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_PROTECTION_BED thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS); #endif @@ -722,7 +722,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(MSG_INVALID_EXTRUDER_NUM); kill(PSTR(MSG_KILLED)); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) return 0.25 * raw; @@ -735,8 +735,8 @@ static float analog2temp(int raw, uint8_t e) { for (i = 1; i < heater_ttbllen_map[e]; i++) { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -760,8 +760,8 @@ static float analog2tempBed(int raw) { for (i = 1; i < BEDTEMPTABLE_LEN; i++) { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -818,7 +818,7 @@ static void updateTemperaturesFromRawValues() { if (temp < MEASURED_LOWER_LIMIT) temp = filament_width_nominal; //assume sensor cut out else if (temp > MEASURED_UPPER_LIMIT) temp = MEASURED_UPPER_LIMIT; return filament_width_nominal / temp * 100; - } + } #endif @@ -833,10 +833,10 @@ void tp_init() { MCUCR=BIT(JTD); MCUCR=BIT(JTD); #endif - - // Finish init of mult extruder arrays + + // Finish init of mult extruder arrays for (int e = 0; e < EXTRUDERS; e++) { - // populate with the first value + // populate with the first value maxttemp[e] = maxttemp[0]; #ifdef PIDTEMP temp_iState_min[e] = 0.0; @@ -862,7 +862,7 @@ void tp_init() { #endif #if HAS_HEATER_BED SET_OUTPUT(HEATER_BED_PIN); - #endif + #endif #if HAS_FAN SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN @@ -883,7 +883,7 @@ void tp_init() { pinMode(SS_PIN, OUTPUT); digitalWrite(SS_PIN, HIGH); #endif - + OUT_WRITE(MAX6675_SS,HIGH); #endif //HEATER_0_USES_MAX6675 @@ -918,12 +918,12 @@ void tp_init() { #if HAS_FILAMENT_SENSOR ANALOG_SELECT(FILWIDTH_PIN); #endif - + // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt OCR0B = 128; - TIMSK0 |= BIT(OCIE0B); - + TIMSK0 |= BIT(OCIE0B); + // Wait for temperature measurement to settle delay(250); @@ -1118,7 +1118,7 @@ void disable_all_heaters() { if (ms < next_max6675_ms) return max6675_temp; - + next_max6675_ms = ms + MAX6675_HEAT_INTERVAL; max6675_temp = 0; @@ -1230,7 +1230,7 @@ ISR(TIMER0_COMPB_vect) { static unsigned char state_timer_heater_ ## n = 0 #else #define ISR_STATICS(n) static unsigned char soft_pwm_ ## n - #endif + #endif // Statics per heater ISR_STATICS(0); @@ -1250,7 +1250,7 @@ ISR(TIMER0_COMPB_vect) { #if HAS_FILAMENT_SENSOR static unsigned long raw_filwidth_value = 0; #endif - + #ifndef SLOW_PWM_HEATERS /** * standard PWM modulation @@ -1303,10 +1303,10 @@ ISR(TIMER0_COMPB_vect) { #ifdef FAN_SOFT_PWM if (soft_pwm_fan < pwm_count) WRITE_FAN(0); #endif - + pwm_count += BIT(SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else // SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1392,9 +1392,9 @@ ISR(TIMER0_COMPB_vect) { if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // EXTRUDER 0 - if (state_timer_heater_0 > 0) state_timer_heater_0--; + if (state_timer_heater_0 > 0) state_timer_heater_0--; #if EXTRUDERS > 1 // EXTRUDER 1 if (state_timer_heater_1 > 0) state_timer_heater_1--; #if EXTRUDERS > 2 // EXTRUDER 2 @@ -1408,7 +1408,7 @@ ISR(TIMER0_COMPB_vect) { if (state_timer_heater_BED > 0) state_timer_heater_BED--; #endif } // (pwm_count % 64) == 0 - + #endif // SLOW_PWM_HEATERS #define SET_ADMUX_ADCSRA(pin) ADMUX = BIT(REFS0) | (pin & 0x07); ADCSRA |= BIT(ADSC) @@ -1587,7 +1587,7 @@ ISR(TIMER0_COMPB_vect) { #ifdef BABYSTEPPING for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) { int curTodo = babystepsTodo[axis]; //get rid of volatile for performance - + if (curTodo > 0) { babystep(axis,/*fwd*/true); babystepsTodo[axis]--; //fewer to do next time diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.h index 6ab35d52..1318c641 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef TEMPERATURE_H -#define TEMPERATURE_H +#define TEMPERATURE_H #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[4]; +extern int target_temperature[4]; extern float current_temperature[4]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[4]; @@ -65,7 +65,7 @@ extern float current_temperature_bed; #else extern float Kp, Ki, Kd, Kc; // one param per extruder - saves 20 or 36 bytes of ram (inc array pointer) #define PID_PARAM(param, e) param // use macro to point directly to value - #endif // PID_PARAMS_PER_EXTRUDER + #endif // PID_PARAMS_PER_EXTRUDER float scalePID_i(float i); float scalePID_d(float d); float unscalePID_i(float i); @@ -76,11 +76,11 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/thermistortables.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/thermistortables.h index 61092f00..2da5b5f4 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/thermistortables.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORHEATER_3 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORHEATER_3 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -828,7 +828,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORHEATER_3 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORHEATER_3 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -869,7 +869,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORHEATER_3 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORHEATER_3 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -911,7 +911,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORHEATER_3 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -994,7 +994,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1031,7 +1031,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1043,7 +1043,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORHEATER_3 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1055,7 +1055,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORHEATER_3 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1084,7 +1084,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORHEATER_3 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.cpp index 31bc809e..cd077144 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.cpp @@ -213,7 +213,7 @@ static void lcd_status_screen(); #ifdef REPRAPWORLD_KEYPAD volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values #endif - + #ifdef LCD_HAS_SLOW_BUTTONS volatile uint8_t slow_buttons; // Bits of the pressed buttons. #endif @@ -1305,14 +1305,14 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) void lcd_quick_feedback() { lcdDrawUpdate = 2; next_button_update_ms = millis() + 500; - + #ifdef LCD_USE_I2C_BUZZER #ifndef LCD_FEEDBACK_FREQUENCY_HZ #define LCD_FEEDBACK_FREQUENCY_HZ 100 #endif #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS #define LCD_FEEDBACK_FREQUENCY_DURATION_MS (1000/6) - #endif + #endif lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); #elif defined(BEEPER) && BEEPER >= 0 #ifndef LCD_FEEDBACK_FREQUENCY_HZ @@ -1475,7 +1475,7 @@ void lcd_update() { } } #endif//CARDINSERTED - + millis_t ms = millis(); if (ms > next_lcd_update_ms) { @@ -1502,7 +1502,7 @@ void lcd_update() { int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; if (lastEncoderMovementMillis != 0) { - // Note that the rate is always calculated between to passes through the + // Note that the rate is always calculated between to passes through the // loop and that the abs of the encoderDiff value is tracked. float encoderStepRate = (float)(encoderMovementSteps) / ((float)(ms - lastEncoderMovementMillis)) * 1000.0; @@ -1665,7 +1665,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } #define encrot1 2 #define encrot2 3 #define encrot3 1 - #endif + #endif /** * Read encoder buttons from the hardware registers @@ -1844,7 +1844,7 @@ char *ftostr43(const float &x) { // Convert float to string with 1.23 format char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.h index 956b7282..23be7b27 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd.h @@ -48,7 +48,7 @@ extern int absPreheatFanSpeed; extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern millis_t previous_lcd_status_ms; #endif @@ -94,7 +94,7 @@ #define B_ST BIT(BL_ST) #define EN_B BIT(BLEN_B) #define EN_A BIT(BLEN_A) - + #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST)) #endif//NEWPANEL @@ -125,7 +125,7 @@ char *ftostr31ns(const float &x); // float to string without sign character char *ftostr31(const float &x); char *ftostr32(const float &x); char *ftostr43(const float &x); -char *ftostr12ns(const float &x); +char *ftostr12ns(const float &x); char *ftostr32sp(const float &x); // remove zero-padding from ftostr32 char *ftostr5(const float &x); char *ftostr51(const float &x); diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_implementation_hitachi_HD44780.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_implementation_hitachi_HD44780.h index ca41a6b3..3b14bdd6 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -29,10 +29,10 @@ #if defined(BTN_ENC) && BTN_ENC > -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C BIT(BLEN_C) -#endif - + #define BLEN_C 2 + #define EN_C BIT(BLEN_C) +#endif + // // Setup other button mappings of each panel // @@ -82,7 +82,7 @@ #define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5 #define BLEN_REPRAPWORLD_KEYPAD_DOWN 3 #define BLEN_REPRAPWORLD_KEYPAD_LEFT 7 - + #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values #define EN_REPRAPWORLD_KEYPAD_F3 BIT((BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET)) @@ -119,7 +119,7 @@ #define B_DW BIT(BL_DW) #define B_RI BIT(BL_RI) #define B_ST BIT(BL_ST) - + #define LCD_CLICKED (buttons&(B_MI|B_ST)) #endif @@ -761,7 +761,7 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #ifdef LCD_I2C_VIKI if ((slow_buttons & (B_MI|B_RI)) && millis() < next_button_update_ms) // LCD clicked slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_st7920_u8glib_rrd.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_st7920_u8glib_rrd.h index 3181ea26..fe82e54b 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/ultralcd_st7920_u8glib_rrd.h @@ -28,13 +28,13 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) { WRITE(ST7920_CLK_PIN,0); #if F_CPU == 20000000 - __asm__("nop\n\t"); + __asm__("nop\n\t"); #endif - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); #if F_CPU == 20000000 - __asm__("nop\n\t""nop\n\t"); + __asm__("nop\n\t""nop\n\t"); #endif } } diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/utf_mapper.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/utf_mapper.h index 69e2e5da..33851007 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/utf_mapper.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/utf_mapper.h @@ -68,7 +68,7 @@ // À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, // c39 ÐÑÓÔÕÖ×ØÙÚÛÜÝÞß // Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß - 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, // c3a àáãäåæçèéêëìíîï + 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, // c3a àáãäåæçèéêëìíîï // à á â ã ä å æ ç è é ê ë ì í î ï 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff // c3b ðñóôõö÷øùúûüýþÿ // ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.cpp index 9eb3465f..dc62f431 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.cpp @@ -83,9 +83,9 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); return new_matrix; } @@ -114,8 +114,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) { matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.h b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.h index 0c5938ba..6a7cba81 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.h +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(const char title[]); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/watchdog.cpp b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/watchdog.cpp index d9127c54..4a22388c 100644 --- a/I3pro/Firmware_Marlin/PI3A Pro/Marlin/watchdog.cpp +++ b/I3pro/Firmware_Marlin/PI3A Pro/Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer."); kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display diff --git a/MeCreator2/Firmware_Marlin/BlinkM.cpp b/MeCreator2/Firmware_Marlin/BlinkM.cpp index de604ecd..0ed9ba4b 100644 --- a/MeCreator2/Firmware_Marlin/BlinkM.cpp +++ b/MeCreator2/Firmware_Marlin/BlinkM.cpp @@ -15,7 +15,7 @@ void SendColors(byte red, byte grn, byte blu) { - Wire.begin(); + Wire.begin(); Wire.beginTransmission(0x09); Wire.write('o'); //to disable ongoing script, only needs to be used once Wire.write('n'); diff --git a/MeCreator2/Firmware_Marlin/Configuration.h b/MeCreator2/Firmware_Marlin/Configuration.h index 04de6a79..174f6ce4 100644 --- a/MeCreator2/Firmware_Marlin/Configuration.h +++ b/MeCreator2/Firmware_Marlin/Configuration.h @@ -97,7 +97,7 @@ // 10 is 100k RS thermistor 198-961 (4.7k pullup) // 11 is 100k beta 3950 1% thermistor (4.7k pullup) // 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" +// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" // 20 is the PT100 circuit found in the Ultimainboard V2.x // 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 // @@ -239,15 +239,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua The system will turn the heater on forever, burning up the filament and anything else around. -After the temperature reaches the target for the first time, this feature will -start measuring for how long the current temperature stays below the target +After the temperature reaches the target for the first time, this feature will +start measuring for how long the current temperature stays below the target minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS). If it stays longer than _PERIOD, it means the thermistor temperature cannot catch up with the target, so something *may be* wrong. Then, to be on the safe side, the system will he halt. -Bear in mind the count down will just start AFTER the first time the +Bear in mind the count down will just start AFTER the first time the thermistor temperature is over the target, so you will have no problem if your extruder heater takes 2 minutes to hit the target on heating. @@ -464,9 +464,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #endif #endif - + #endif - + #endif // ENABLE_AUTO_BED_LEVELING @@ -669,7 +669,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of // Shift register panels // --------------------- // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection //#define SAV_3DLCD #ifdef SAV_3DLCD @@ -767,9 +767,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) * Single extruder only at this point (extruder 0) - * + * * Motherboards - * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector + * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards @@ -786,7 +786,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define MAX_MEASUREMENT_DELAY 20 //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM and lower number saves RAM) //defines used in the code -#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +#define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //#define FILAMENT_LCD_DISPLAY diff --git a/MeCreator2/Firmware_Marlin/ConfigurationStore.cpp b/MeCreator2/Firmware_Marlin/ConfigurationStore.cpp index 511119f0..ef81693c 100644 --- a/MeCreator2/Firmware_Marlin/ConfigurationStore.cpp +++ b/MeCreator2/Firmware_Marlin/ConfigurationStore.cpp @@ -43,13 +43,13 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) #define EEPROM_VERSION "V13" #ifdef EEPROM_SETTINGS -void Config_StoreSettings() +void Config_StoreSettings() { char ver[4]= "000"; int i=EEPROM_OFFSET; - EEPROM_WRITE_VAR(i,ver); // invalidate data first + EEPROM_WRITE_VAR(i,ver); // invalidate data first EEPROM_WRITE_VAR(i,axis_steps_per_unit); - EEPROM_WRITE_VAR(i,max_feedrate); + EEPROM_WRITE_VAR(i,max_feedrate); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i,acceleration); EEPROM_WRITE_VAR(i,retract_acceleration); @@ -124,7 +124,7 @@ void Config_StoreSettings() char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_WRITE_VAR(i,ver2); // validate data - + SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Settings Stored"); } @@ -142,7 +142,7 @@ void Config_PrintSettings() SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOPAIR(" E",axis_steps_per_unit[E_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #ifdef SCARA SERIAL_ECHOLNPGM("Scaling factors:"); @@ -151,42 +151,42 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOLN(""); - + SERIAL_ECHO_START; #endif SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]); - SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); - SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); + SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS]); + SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS]); SERIAL_ECHOPAIR(" E", max_feedrate[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); - SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); + SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] ); + SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] ); SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] ); SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M204 S",acceleration ); + SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); - SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); - SERIAL_ECHOPAIR(" B" ,minsegmenttime ); - SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); + SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); + SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); + SERIAL_ECHOPAIR(" B" ,minsegmenttime ); + SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" E" ,max_e_jerk); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Home offset (mm):"); @@ -215,19 +215,19 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M301 P",Kp); - SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); + SERIAL_ECHOPAIR(" M301 P",Kp); + SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #endif #ifdef FWRETRACT SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"); SERIAL_ECHO_START; - SERIAL_ECHOPAIR(" M207 S",retract_length); - SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); + SERIAL_ECHOPAIR(" M207 S",retract_length); + SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" Z" ,retract_zlift); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHO_START; @@ -254,11 +254,11 @@ SERIAL_ECHOLNPGM("Scaling factors:"); SERIAL_ECHOLNPGM("Filament settings:"); SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 D", filament_size[0]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 1 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); #if EXTRUDERS > 2 SERIAL_ECHO_START; SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]); @@ -285,12 +285,12 @@ void Config_RetrieveSettings() { // version number match EEPROM_READ_VAR(i,axis_steps_per_unit); - EEPROM_READ_VAR(i,max_feedrate); + EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); - + // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner) reset_acceleration_rates(); - + EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,minimumfeedrate); @@ -320,7 +320,7 @@ void Config_RetrieveSettings() #ifndef PIDTEMP float Kp,Ki,Kd; #endif - // do not need to scale PID values as the values in EEPROM are already scaled + // do not need to scale PID values as the values in EEPROM are already scaled EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i,Kd); @@ -379,23 +379,23 @@ void Config_ResetDefault() float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; float tmp2[]=DEFAULT_MAX_FEEDRATE; long tmp3[]=DEFAULT_MAX_ACCELERATION; - for (short i=0;i<4;i++) + for (short i=0;i<4;i++) { - axis_steps_per_unit[i]=tmp1[i]; - max_feedrate[i]=tmp2[i]; + axis_steps_per_unit[i]=tmp1[i]; + max_feedrate[i]=tmp2[i]; max_acceleration_units_per_sq_second[i]=tmp3[i]; #ifdef SCARA axis_scaling[i]=1; #endif } - + // steps per sq second need to be updated to agree with the units per sq second reset_acceleration_rates(); - + acceleration=DEFAULT_ACCELERATION; retract_acceleration=DEFAULT_RETRACT_ACCELERATION; minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; - minsegmenttime=DEFAULT_MINSEGMENTTIME; + minsegmenttime=DEFAULT_MINSEGMENTTIME; mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; max_xy_jerk=DEFAULT_XYJERK; max_z_jerk=DEFAULT_ZJERK; @@ -426,10 +426,10 @@ void Config_ResetDefault() Kp = DEFAULT_Kp; Ki = scalePID_i(DEFAULT_Ki); Kd = scalePID_d(DEFAULT_Kd); - + // call updatePID (similar to when we have processed M301) updatePID(); - + #ifdef PID_ADD_EXTRUSION_RATE Kc = DEFAULT_Kc; #endif//PID_ADD_EXTRUSION_RATE diff --git a/MeCreator2/Firmware_Marlin/DOGMbitmaps.h b/MeCreator2/Firmware_Marlin/DOGMbitmaps.h index 5c7f594b..df713bab 100644 --- a/MeCreator2/Firmware_Marlin/DOGMbitmaps.h +++ b/MeCreator2/Firmware_Marlin/DOGMbitmaps.h @@ -1,6 +1,6 @@ // BitMap for splashscreen // Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php -// Please note that using the high-res version takes 402Bytes of PROGMEM. +// Please note that using the high-res version takes 402Bytes of PROGMEM. //#define START_BMPHIGH #ifdef START_BMPHIGH @@ -8,7 +8,7 @@ #define START_BMPHEIGHT 38 #define START_BMPBYTEWIDTH 14 #define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8 - + const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff @@ -49,11 +49,11 @@ ,0x0f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 ,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x80 }; #else - #ifdef GEEETECH_STARTUP_BMP + #ifdef GEEETECH_STARTUP_BMP #define START_BMPWIDTH 128 #define START_BMPHEIGHT 64 #define START_BMPBYTEWIDTH 16 - #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 + #define START_BMPBYTES 1024 // START_BMPWIDTH * START_BMPHEIGHT / 8 const unsigned char start_bmp[START_BMPBYTES] PROGMEM = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -187,7 +187,7 @@ #else - #define START_BMPWIDTH 56 + #define START_BMPWIDTH 56 #define START_BMPHEIGHT 19 #define START_BMPBYTEWIDTH 7 #define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8 @@ -215,10 +215,10 @@ #endif #endif -// Here comes a compile-time operation to match the extruder symbols +// Here comes a compile-time operation to match the extruder symbols // on the info screen to the set number of extruders in configuration.h -// -// When only one extruder is selected, the "1" on the symbol will not +// +// When only one extruder is selected, the "1" on the symbol will not // be displayed. #if EXTRUDERS == 1 @@ -371,6 +371,6 @@ 0x1E,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x01,0xFF,0xFF,0x80,0x7F,0xFF,0xE0, 0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00 }; -#endif // Extruders +#endif // Extruders diff --git a/MeCreator2/Firmware_Marlin/LiquidCrystalRus.cpp b/MeCreator2/Firmware_Marlin/LiquidCrystalRus.cpp index 6ee2c112..f42868a0 100644 --- a/MeCreator2/Firmware_Marlin/LiquidCrystalRus.cpp +++ b/MeCreator2/Firmware_Marlin/LiquidCrystalRus.cpp @@ -13,32 +13,32 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 -const PROGMEM uint8_t utf_recode[] = +const PROGMEM uint8_t utf_recode[] = { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 - }; + }; // When the display powers up, it is configured as follows: // // 1. Display clear -// 2. Function set: -// DL = 1; 8-bit interface data -// N = 0; 1-line display -// F = 0; 5x8 dot character font -// 3. Display on/off control: -// D = 0; Display off -// C = 0; Cursor off -// B = 0; Blinking off -// 4. Entry mode set: -// I/D = 1; Increment by 1 -// S = 0; No shift +// 2. Function set: +// DL = 1; 8-bit interface data +// N = 0; 1-line display +// F = 0; 5x8 dot character font +// 3. Display on/off control: +// D = 0; Display off +// C = 0; Cursor off +// B = 0; Blinking off +// 4. Entry mode set: +// I/D = 1; Increment by 1 +// S = 0; No shift // // Note, however, that resetting the Arduino doesn't reset the LCD, so we // can't assume that it's in that state when a sketch starts (and the // LiquidCrystal constructor is called). -// +// // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ @@ -76,29 +76,29 @@ void LiquidCrystalRus::init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t _rs_pin = rs; _rw_pin = rw; _enable_pin = enable; - + _data_pins[0] = d0; _data_pins[1] = d1; _data_pins[2] = d2; - _data_pins[3] = d3; + _data_pins[3] = d3; _data_pins[4] = d4; _data_pins[5] = d5; _data_pins[6] = d6; - _data_pins[7] = d7; + _data_pins[7] = d7; pinMode(_rs_pin, OUTPUT); // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (_rw_pin != 255) { + if (_rw_pin != 255) { pinMode(_rw_pin, OUTPUT); } pinMode(_enable_pin, OUTPUT); - + if (fourbitmode) _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else + else _displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - - begin(16, 1); + + begin(16, 1); } void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { @@ -116,14 +116,14 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! // according to datasheet, we need at least 40ms after power rises above 2.7V // before sending commands. Arduino can turn on way before 4.5V so we'll wait 50 - delayMicroseconds(50000); + delayMicroseconds(50000); // Now we pull both RS and R/W low to begin commands digitalWrite(_rs_pin, LOW); digitalWrite(_enable_pin, LOW); - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + //put the LCD into 4 bit or 8 bit mode if (! (_displayfunction & LCD_8BITMODE)) { // this is according to the Hitachi HD44780 datasheet @@ -136,13 +136,13 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { // second try writeNbits(0x03,4); delayMicroseconds(4500); // wait min 4.1ms - + // third go! - writeNbits(0x03,4); + writeNbits(0x03,4); delayMicroseconds(150); // finally, set to 8-bit interface - writeNbits(0x02,4); + writeNbits(0x02,4); } else { // this is according to the Hitachi HD44780 datasheet // page 45 figure 23 @@ -160,10 +160,10 @@ void LiquidCrystalRus::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { } // finally, set # lines, font size, etc. - command(LCD_FUNCTIONSET | _displayfunction); + command(LCD_FUNCTIONSET | _displayfunction); // turn the display on with no cursor or blinking default - _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); // clear it off @@ -199,7 +199,7 @@ void LiquidCrystalRus::setCursor(uint8_t col, uint8_t row) if ( row >= _numlines ) { row = _numlines-1; // we count rows starting w/0 } - + command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -289,7 +289,7 @@ inline void LiquidCrystalRus::command(uint8_t value) { { uint8_t out_char=value; - if (_dram_model == LCD_DRAM_WH1601) { + if (_dram_model == LCD_DRAM_WH1601) { uint8_t ac=recv(LOW) & 0x7f; if (ac>7 && ac<0x14) command(LCD_SETDDRAMADDR | (0x40+ac-8)); } @@ -299,16 +299,16 @@ inline void LiquidCrystalRus::command(uint8_t value) { utf_hi_char = value - 0xd0; } else { value &= 0x3f; - if (!utf_hi_char && (value == 1)) + if (!utf_hi_char && (value == 1)) send(0xa2,HIGH); // ╗ - else if ((utf_hi_char == 1) && (value == 0x11)) + else if ((utf_hi_char == 1) && (value == 0x11)) send(0xb5,HIGH); // ╦ - else + else send(pgm_read_byte_near(utf_recode + value + (utf_hi_char<<6) - 0x10), HIGH); - } + } } else send(out_char, HIGH); #if defined(ARDUINO) && ARDUINO >= 100 - return 1; // assume success + return 1; // assume success #endif } @@ -319,12 +319,12 @@ void LiquidCrystalRus::send(uint8_t value, uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, LOW); } - + if (_displayfunction & LCD_8BITMODE) { - writeNbits(value,8); + writeNbits(value,8); } else { writeNbits(value>>4,4); writeNbits(value,4); @@ -337,12 +337,12 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { digitalWrite(_rs_pin, mode); // if there is a RW pin indicated, set it low to Write - if (_rw_pin != 255) { + if (_rw_pin != 255) { digitalWrite(_rw_pin, HIGH); } - + if (_displayfunction & LCD_8BITMODE) { - retval = readNbits(8); + retval = readNbits(8); } else { retval = readNbits(4) << 4; retval |= readNbits(4); @@ -351,7 +351,7 @@ uint8_t LiquidCrystalRus::recv(uint8_t mode) { } void LiquidCrystalRus::pulseEnable() { digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns digitalWrite(_enable_pin, LOW); @@ -374,10 +374,10 @@ uint8_t LiquidCrystalRus::readNbits(uint8_t n) { } digitalWrite(_enable_pin, LOW); - delayMicroseconds(1); + delayMicroseconds(1); digitalWrite(_enable_pin, HIGH); delayMicroseconds(1); // enable pulse must be >450ns - + for (int i = 0; i < n; i++) { retval |= (digitalRead(_data_pins[i]) == HIGH)?(1 << i):0; } diff --git a/MeCreator2/Firmware_Marlin/LiquidCrystalRus.h b/MeCreator2/Firmware_Marlin/LiquidCrystalRus.h index ad85394a..f4891c5e 100644 --- a/MeCreator2/Firmware_Marlin/LiquidCrystalRus.h +++ b/MeCreator2/Firmware_Marlin/LiquidCrystalRus.h @@ -2,7 +2,7 @@ // based on LiquidCrystal library from ArduinoIDE, see http://arduino.cc // modified 27 Jul 2011 // by Ilya V. Danilov http://mk90.ru/ -// +// #ifndef LiquidCrystalRus_h #define LiquidCrystalRus_h @@ -48,7 +48,7 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 -// enum for +// enum for #define LCD_DRAM_Normal 0x00 #define LCD_DRAM_WH1601 0x01 @@ -69,7 +69,7 @@ class LiquidCrystalRus : public Print { void init(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7); - + void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS); void clear(); @@ -90,7 +90,7 @@ class LiquidCrystalRus : public Print { void createChar(uint8_t, uint8_t[]); void setCursor(uint8_t, uint8_t); - + #if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); using Print::write; @@ -106,7 +106,7 @@ class LiquidCrystalRus : public Print { void send(uint8_t, uint8_t); void writeNbits(uint8_t, uint8_t); uint8_t recv(uint8_t); - uint8_t readNbits(uint8_t); + uint8_t readNbits(uint8_t); void pulseEnable(); uint8_t _rs_pin; // LOW: command. HIGH: character. diff --git a/MeCreator2/Firmware_Marlin/MarlinSerial.cpp b/MeCreator2/Firmware_Marlin/MarlinSerial.cpp index e4e73743..145cf8e4 100644 --- a/MeCreator2/Firmware_Marlin/MarlinSerial.cpp +++ b/MeCreator2/Firmware_Marlin/MarlinSerial.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + Modified 23 November 2006 by David A. Mellis Modified 28 September 2010 by Mark Sproul */ @@ -24,7 +24,7 @@ #include "MarlinSerial.h" #ifndef AT90USB -// this next line disables the entire HardwareSerial.cpp, +// this next line disables the entire HardwareSerial.cpp, // this is so I can support Attiny series and any other chip without a UART #if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) @@ -80,7 +80,7 @@ void MarlinSerial::begin(long baud) useU2X = false; } #endif - + if (useU2X) { M_UCSRxA = 1 << M_U2Xx; baud_setting = (F_CPU / 4 / baud - 1) / 2; @@ -102,7 +102,7 @@ void MarlinSerial::end() { cbi(M_UCSRxB, M_RXENx); cbi(M_UCSRxB, M_TXENx); - cbi(M_UCSRxB, M_RXCIEx); + cbi(M_UCSRxB, M_RXCIEx); } @@ -199,7 +199,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { print('\r'); - print('\n'); + print('\n'); } void MarlinSerial::println(const String &s) @@ -260,13 +260,13 @@ void MarlinSerial::println(double n, int digits) void MarlinSerial::printNumber(unsigned long n, uint8_t base) { - unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. + unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. unsigned long i = 0; if (n == 0) { print('0'); return; - } + } while (n > 0) { buf[i++] = n % base; @@ -279,8 +279,8 @@ void MarlinSerial::printNumber(unsigned long n, uint8_t base) 'A' + buf[i - 1] - 10)); } -void MarlinSerial::printFloat(double number, uint8_t digits) -{ +void MarlinSerial::printFloat(double number, uint8_t digits) +{ // Handle negative numbers if (number < 0.0) { @@ -292,7 +292,7 @@ void MarlinSerial::printFloat(double number, uint8_t digits) double rounding = 0.5; for (uint8_t i=0; i 0) - print("."); + print("."); // Extract digits from the remainder one at a time while (digits-- > 0) @@ -310,8 +310,8 @@ void MarlinSerial::printFloat(double number, uint8_t digits) remainder *= 10.0; int toPrint = int(remainder); print(toPrint); - remainder -= toPrint; - } + remainder -= toPrint; + } } // Preinstantiate Objects ////////////////////////////////////////////////////// diff --git a/MeCreator2/Firmware_Marlin/MarlinSerial.h b/MeCreator2/Firmware_Marlin/MarlinSerial.h index 7ccdfd6a..ad850fc6 100644 --- a/MeCreator2/Firmware_Marlin/MarlinSerial.h +++ b/MeCreator2/Firmware_Marlin/MarlinSerial.h @@ -23,15 +23,15 @@ #define MarlinSerial_h #include "Marlin.h" -#if !defined(SERIAL_PORT) +#if !defined(SERIAL_PORT) #define SERIAL_PORT 0 #endif // The presence of the UBRRH register is used to detect a UART. #define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \ (port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \ - (port == 3 && defined(UBRR3H))) - + (port == 3 && defined(UBRR3H))) + // These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor // requires two levels of indirection to expand macro values properly) #define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) @@ -41,15 +41,15 @@ #define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix #endif -// Registers used by MarlinSerial class (these are expanded +// Registers used by MarlinSerial class (these are expanded // depending on selected serial port #define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number -#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) -#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) -#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) -#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) -#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) -#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) +#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) +#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,) +#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,) +#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,) +#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,) +#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,) #define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H) #define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L) #define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,) @@ -94,12 +94,12 @@ class MarlinSerial //: public Stream int peek(void); int read(void); void flush(void); - + FORCE_INLINE int available(void) { return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE; } - + FORCE_INLINE void write(uint8_t c) { while (!((M_UCSRxA) & (1 << M_UDREx))) @@ -107,8 +107,8 @@ class MarlinSerial //: public Stream M_UDRx = c; } - - + + FORCE_INLINE void checkRx(void) { if((M_UCSRxA & (1< Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters -// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder -// M406 - Turn off Filament Sensor extrusion control -// M407 - Displays measured filament diameter +// M405 - Turn on Filament Sensor extrusion control. Optional D to set delay in centimeters between sensor and extruder +// M406 - Turn off Filament Sensor extrusion control +// M407 - Displays measured filament diameter // M500 - stores parameters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -312,9 +312,9 @@ int EtoPPressure=0; // these are the default values, can be overriden with M665 float delta_radius= DELTA_RADIUS; float delta_tower1_x= -SIN_60*delta_radius; // front left tower - float delta_tower1_y= -COS_60*delta_radius; + float delta_tower1_y= -COS_60*delta_radius; float delta_tower2_x= SIN_60*delta_radius; // front right tower - float delta_tower2_y= -COS_60*delta_radius; + float delta_tower2_y= -COS_60*delta_radius; float delta_tower3_x= 0.0; // back middle tower float delta_tower3_y= delta_radius; float delta_diagonal_rod= DELTA_DIAGONAL_ROD; @@ -324,19 +324,19 @@ int EtoPPressure=0; #ifdef SCARA // Build size scaling float axis_scaling[3]={1,1,1}; // Build size scaling, default to 1 -#endif +#endif bool cancel_heatup = false ; #ifdef FILAMENT_SENSOR - //Variables for Filament Sensor input - float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 - bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off - float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter - signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 + //Variables for Filament Sensor input + float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 + bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off + float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter + signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 int delay_index1=0; //index into ring buffer int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized - float delay_dist=0; //delay distance counter + float delay_dist=0; //delay distance counter int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting #endif @@ -616,7 +616,7 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! setup_photpin(); servo_init(); - + lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen @@ -776,7 +776,7 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - + bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; } @@ -951,45 +951,45 @@ static void axis_is_at_home(int axis) { #ifdef SCARA float homeposition[3]; char i; - + if (axis < 2) { - + for (i=0; i<3; i++) { - homeposition[i] = base_home_pos(i); - } + homeposition[i] = base_home_pos(i); + } // SERIAL_ECHOPGM("homeposition[x]= "); SERIAL_ECHO(homeposition[0]); // SERIAL_ECHOPGM("homeposition[y]= "); SERIAL_ECHOLN(homeposition[1]); - // Works out real Homeposition angles using inverse kinematics, + // Works out real Homeposition angles using inverse kinematics, // and calculates homing offset using forward kinematics calculate_delta(homeposition); - + // SERIAL_ECHOPGM("base Theta= "); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + for (i=0; i<2; i++) { delta[i] -= add_homing[i]; - } - + } + // SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); - + calculate_SCARA_forward_Transform(delta); - + // SERIAL_ECHOPGM("Delta X="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" Delta Y="); SERIAL_ECHOLN(delta[Y_AXIS]); - + current_position[axis] = delta[axis]; - - // SCARA home positions are based on configuration since the actual limits are determined by the + + // SCARA home positions are based on configuration since the actual limits are determined by the // inverse kinematic transform. min_pos[axis] = base_min_pos(axis); // + (delta[axis] - base_home_pos(axis)); max_pos[axis] = base_max_pos(axis); // + (delta[axis] - base_home_pos(axis)); - } + } else { current_position[axis] = base_home_pos(axis) + add_homing[axis]; @@ -1317,9 +1317,9 @@ void refresh_cmd_timeout(void) #endif //prepare_move(); if (swapretract) { - current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; } else { - current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; + current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; } plan_set_e_position(current_position[E_AXIS]); float oldFeedrate = feedrate; @@ -1340,7 +1340,7 @@ void refresh_cmd_timeout(void) // static void dock_sled(bool dock, int offset=0) { int z_loc; - + if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -1441,7 +1441,7 @@ void process_commands() retract(false,retracted_swap[active_extruder]); #else retract(false); - #endif + #endif break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time @@ -1874,11 +1874,11 @@ void process_commands() else { #ifdef SCARA if (i == X_AXIS || i == Y_AXIS) { - current_position[i] = code_value(); + current_position[i] = code_value(); } else { - current_position[i] = code_value()+add_homing[i]; - } + current_position[i] = code_value()+add_homing[i]; + } #else current_position[i] = code_value()+add_homing[i]; #endif @@ -2111,7 +2111,7 @@ void process_commands() // M48 Z-Probe repeatability measurement function. // // Usage: M48 -// +// // This function assumes the bed has been homed. Specificaly, that a G28 command // as been issued prior to invoking the M48 Z-Probe repeatability measurement function. // Any information generated by a prior G29 Bed leveling command will be lost and need to be @@ -2123,7 +2123,7 @@ void process_commands() // #ifdef ENABLE_AUTO_BED_LEVELING -#ifdef Z_PROBE_REPEATABILITY_TEST +#ifdef Z_PROBE_REPEATABILITY_TEST case 48: // M48 Z-Probe repeatability { @@ -2131,14 +2131,14 @@ void process_commands() #error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability." #endif - double sum=0.0; - double mean=0.0; + double sum=0.0; + double mean=0.0; double sigma=0.0; double sample_set[50]; int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ; double X_current, Y_current, Z_current; double X_probe_location, Y_probe_location, Z_start_location, ext_position; - + if (code_seen('V') || code_seen('v')) { verbose_level = code_value(); if (verbose_level<0 || verbose_level>4 ) { @@ -2166,7 +2166,7 @@ void process_commands() Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; ext_position = st_get_position_mm(E_AXIS); - if (code_seen('E') || code_seen('e') ) + if (code_seen('E') || code_seen('e') ) engage_probe_for_each_reading++; if (code_seen('X') || code_seen('x') ) { @@ -2187,7 +2187,7 @@ void process_commands() if (code_seen('L') || code_seen('l') ) { n_legs = code_value(); - if ( n_legs==1 ) + if ( n_legs==1 ) n_legs = 2; if ( n_legs<0 || n_legs>15 ) { SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausable.\n"); @@ -2209,10 +2209,10 @@ void process_commands() // // Now get everything to the specified probe point So we can safely do a probe to -// get us close to the bed. If the Z-Axis is far from the bed, we don't want to +// get us close to the bed. If the Z-Axis is far from the bed, we don't want to // use that as a starting point for each probe. // - if (verbose_level > 2) + if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, @@ -2226,12 +2226,12 @@ void process_commands() current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); -// +// // OK, do the inital probe to get us close to the bed. // Then retrace the right amount and use that in subsequent probes // - engage_z_probe(); + engage_z_probe(); setup_for_endstop_move(); run_z_probe(); @@ -2258,7 +2258,7 @@ void process_commands() int rotational_direction, l; rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise - radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go + radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians //SERIAL_ECHOPAIR("starting radius: ",radius); @@ -2301,7 +2301,7 @@ void process_commands() } if (engage_probe_for_each_reading) { - engage_z_probe(); + engage_z_probe(); delay(1000); } @@ -2313,7 +2313,7 @@ void process_commands() // // Get the current mean for the data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + sample_set[j]; } @@ -2323,7 +2323,7 @@ void process_commands() // data points we have so far // - sum=0.0; + sum=0.0; for( j=0; j<=n; j++) { sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean); } @@ -2345,15 +2345,15 @@ void process_commands() SERIAL_PROTOCOL_F(sigma,6); } - if (verbose_level > 0) + if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n"); - plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, + plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); if (engage_probe_for_each_reading) { - retract_z_probe(); + retract_z_probe(); delay(1000); } } @@ -2378,7 +2378,7 @@ SERIAL_PROTOCOLPGM("\n\n"); Sigma_Exit: break; } -#endif // Z_PROBE_REPEATABILITY_TEST +#endif // Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING case 104: // M104 @@ -2566,7 +2566,7 @@ SERIAL_PROTOCOLPGM("\n\n"); CooldownNoWait = false; } codenum = millis(); - + cancel_heatup = false; target_direction = isHeatingBed(); // true if heating, false if cooling @@ -2783,13 +2783,13 @@ SERIAL_PROTOCOLPGM("\n\n"); SERIAL_PROTOCOLPGM(" Psi+Theta:"); SERIAL_PROTOCOL(delta[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta (90):"); SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]); SERIAL_PROTOCOLLN(""); - + SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOL(delta[X_AXIS]/90*axis_steps_per_unit[X_AXIS]); SERIAL_PROTOCOLPGM(" Psi+Theta:"); @@ -2953,7 +2953,7 @@ SERIAL_PROTOCOLPGM("\n\n"); if(code_seen('S')) { delta_segments_per_second= code_value(); } - + recalc_delta_settings(delta_radius, delta_diagonal_rod); break; case 666: // M666 set delta endstop adjustemnt @@ -2997,7 +2997,7 @@ SERIAL_PROTOCOLPGM("\n\n"); int t= code_value() ; switch(t) { - case 0: + case 0: { autoretract_enabled=false; retracted[0]=false; @@ -3008,7 +3008,7 @@ SERIAL_PROTOCOLPGM("\n\n"); retracted[2]=false; #endif }break; - case 1: + case 1: { autoretract_enabled=true; retracted[0]=false; @@ -3258,14 +3258,14 @@ SERIAL_PROTOCOLPGM("\n\n"); case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/ { #ifdef CHDK - + SET_OUTPUT(CHDK); WRITE(CHDK, HIGH); chdkHigh = millis(); chdkActive = true; - + #else - + #if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1 const uint8_t NUM_PULSES=16; const float PULSE_LENGTH=0.01524; @@ -3332,7 +3332,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3350,7 +3350,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3367,7 +3367,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3384,7 +3384,7 @@ SERIAL_PROTOCOLPGM("\n\n"); calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + prepare_move(); //ClearToSend(); return; @@ -3400,21 +3400,21 @@ SERIAL_PROTOCOLPGM("\n\n"); delta[Y_AXIS] = 135; calculate_SCARA_forward_Transform(delta); destination[X_AXIS] = delta[X_AXIS]/axis_scaling[X_AXIS]; - destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; - + destination[Y_AXIS] = delta[Y_AXIS]/axis_scaling[Y_AXIS]; + prepare_move(); //ClearToSend(); return; } break; case 365: // M364 Set SCARA scaling for X Y Z - for(int8_t i=0; i < 3; i++) + for(int8_t i=0; i < 3; i++) { - if(code_seen(axis_codes[i])) + if(code_seen(axis_codes[i])) { - + axis_scaling[i] = code_value(); - + } } break; @@ -3439,64 +3439,64 @@ SERIAL_PROTOCOLPGM("\n\n"); #endif #ifdef FILAMENT_SENSOR -case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width +case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width { - #if (FILWIDTH_PIN > -1) + #if (FILWIDTH_PIN > -1) if(code_seen('N')) filament_width_nominal=code_value(); else{ - SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); - SERIAL_PROTOCOLLN(filament_width_nominal); + SERIAL_PROTOCOLPGM("Filament dia (nominal mm):"); + SERIAL_PROTOCOLLN(filament_width_nominal); } #endif } - break; - - case 405: //M405 Turn on filament sensor for control + break; + + case 405: //M405 Turn on filament sensor for control { - - + + if(code_seen('D')) meas_delay_cm=code_value(); - + if(meas_delay_cm> MAX_MEASUREMENT_DELAY) meas_delay_cm = MAX_MEASUREMENT_DELAY; - + if(delay_index2 == -1) //initialize the ring buffer if it has not been done since startup { - int temp_ratio = widthFil_to_size_ratio(); - + int temp_ratio = widthFil_to_size_ratio(); + for (delay_index1=0; delay_index1<(MAX_MEASUREMENT_DELAY+1); ++delay_index1 ){ measurement_delay[delay_index1]=temp_ratio-100; //subtract 100 to scale within a signed byte } delay_index1=0; - delay_index2=0; + delay_index2=0; } - - filament_sensor = true ; - - //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - //SERIAL_PROTOCOL(filament_width_meas); - //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); - //SERIAL_PROTOCOL(extrudemultiply); - } - break; - - case 406: //M406 Turn off filament sensor for control - { - filament_sensor = false ; - } - break; - - case 407: //M407 Display measured filament diameter - { - - - - SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); - SERIAL_PROTOCOLLN(filament_width_meas); - } - break; + + filament_sensor = true ; + + //SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + //SERIAL_PROTOCOL(filament_width_meas); + //SERIAL_PROTOCOLPGM("Extrusion ratio(%):"); + //SERIAL_PROTOCOL(extrudemultiply); + } + break; + + case 406: //M406 Turn off filament sensor for control + { + filament_sensor = false ; + } + break; + + case 407: //M407 Display measured filament diameter + { + + + + SERIAL_PROTOCOLPGM("Filament dia (measured mm):"); + SERIAL_PROTOCOLLN(filament_width_meas); + } + break; #endif - + @@ -3524,7 +3524,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp Config_RetrieveSettings(); } break; - + case 502: // M502 Revert to default settings { Config_ResetDefault(); @@ -3909,12 +3909,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp // Set the new active extruder and position active_extruder = tmp_extruder; #endif //else DUAL_X_CARRIAGE -#ifdef DELTA +#ifdef DELTA calculate_delta(current_position); // change cartesian kinematic to delta kinematic; //sent position to plan_set_position(); plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS],current_position[E_AXIS]); - + #else plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -4008,13 +4008,13 @@ void clamp_to_software_endstops(float target[3]) if (min_software_endstops) { if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS]; if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS]; - + float negative_z_offset = 0; #ifdef ENABLE_AUTO_BED_LEVELING if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS]; #endif - + if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; } @@ -4029,9 +4029,9 @@ void clamp_to_software_endstops(float target[3]) void recalc_delta_settings(float radius, float diagonal_rod) { delta_tower1_x= -SIN_60*radius; // front left tower - delta_tower1_y= -COS_60*radius; + delta_tower1_y= -COS_60*radius; delta_tower2_x= SIN_60*radius; // front right tower - delta_tower2_y= -COS_60*radius; + delta_tower2_y= -COS_60*radius; delta_tower3_x= 0.0; // back middle tower delta_tower3_y= radius; delta_diagonal_rod_2= sq(diagonal_rod); @@ -4067,7 +4067,7 @@ void prepare_move() { clamp_to_software_endstops(destination); previous_millis_cmd = millis(); - + #ifdef SCARA //for now same as delta-code float difference[NUM_AXIS]; @@ -4091,7 +4091,7 @@ for (int s = 1; s <= steps; s++) { destination[i] = current_position[i] + difference[i] * fraction; } - + calculate_delta(destination); //SERIAL_ECHOPGM("destination[X_AXIS]="); SERIAL_ECHOLN(destination[X_AXIS]); //SERIAL_ECHOPGM("destination[Y_AXIS]="); SERIAL_ECHOLN(destination[Y_AXIS]); @@ -4099,13 +4099,13 @@ for (int s = 1; s <= steps; s++) { //SERIAL_ECHOPGM("delta[X_AXIS]="); SERIAL_ECHOLN(delta[X_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); - + plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } #endif // SCARA - + #ifdef DELTA float difference[NUM_AXIS]; for (int8_t i=0; i < NUM_AXIS; i++) { @@ -4131,7 +4131,7 @@ for (int s = 1; s <= steps; s++) { destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder); } - + #endif // DELTA #ifdef DUAL_X_CARRIAGE @@ -4257,70 +4257,70 @@ void calculate_SCARA_forward_Transform(float f_scara[3]) { // Perform forward kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float x_sin, x_cos, y_sin, y_cos; - + //SERIAL_ECHOPGM("f_delta x="); SERIAL_ECHO(f_scara[X_AXIS]); //SERIAL_ECHOPGM(" y="); SERIAL_ECHO(f_scara[Y_AXIS]); - + x_sin = sin(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; x_cos = cos(f_scara[X_AXIS]/SCARA_RAD2DEG) * Linkage_1; y_sin = sin(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; y_cos = cos(f_scara[Y_AXIS]/SCARA_RAD2DEG) * Linkage_2; - + // SERIAL_ECHOPGM(" x_sin="); SERIAL_ECHO(x_sin); // SERIAL_ECHOPGM(" x_cos="); SERIAL_ECHO(x_cos); // SERIAL_ECHOPGM(" y_sin="); SERIAL_ECHO(y_sin); // SERIAL_ECHOPGM(" y_cos="); SERIAL_ECHOLN(y_cos); - + delta[X_AXIS] = x_cos + y_cos + SCARA_offset_x; //theta delta[Y_AXIS] = x_sin + y_sin + SCARA_offset_y; //theta+phi - + //SERIAL_ECHOPGM(" delta[X_AXIS]="); SERIAL_ECHO(delta[X_AXIS]); //SERIAL_ECHOPGM(" delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); -} +} void calculate_delta(float cartesian[3]){ //reverse kinematics. // Perform reversed kinematics, and place results in delta[3] // The maths and first version has been done by QHARLEY . Integrated into masterbranch 06/2014 and slightly restructured by Joachim Cerny in June 2014 - + float SCARA_pos[2]; - static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; - + static float SCARA_C2, SCARA_S2, SCARA_K1, SCARA_K2, SCARA_theta, SCARA_psi; + SCARA_pos[X_AXIS] = cartesian[X_AXIS] * axis_scaling[X_AXIS] - SCARA_offset_x; //Translate SCARA to standard X Y SCARA_pos[Y_AXIS] = cartesian[Y_AXIS] * axis_scaling[Y_AXIS] - SCARA_offset_y; // With scaling factor. - + #if (Linkage_1 == Linkage_2) SCARA_C2 = ( ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) ) / (2 * (float)L1_2) ) - 1; #else - SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; + SCARA_C2 = ( sq(SCARA_pos[X_AXIS]) + sq(SCARA_pos[Y_AXIS]) - (float)L1_2 - (float)L2_2 ) / 45000; #endif - + SCARA_S2 = sqrt( 1 - sq(SCARA_C2) ); - + SCARA_K1 = Linkage_1 + Linkage_2 * SCARA_C2; SCARA_K2 = Linkage_2 * SCARA_S2; - + SCARA_theta = ( atan2(SCARA_pos[X_AXIS],SCARA_pos[Y_AXIS])-atan2(SCARA_K1, SCARA_K2) ) * -1; SCARA_psi = atan2(SCARA_S2,SCARA_C2); - + delta[X_AXIS] = SCARA_theta * SCARA_RAD2DEG; // Multiply by 180/Pi - theta is support arm angle delta[Y_AXIS] = (SCARA_theta + SCARA_psi) * SCARA_RAD2DEG; // - equal to sub arm angle (inverted motor) delta[Z_AXIS] = cartesian[Z_AXIS]; - + /* SERIAL_ECHOPGM("cartesian x="); SERIAL_ECHO(cartesian[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(cartesian[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(cartesian[Z_AXIS]); - + SERIAL_ECHOPGM("scara x="); SERIAL_ECHO(SCARA_pos[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHOLN(SCARA_pos[Y_AXIS]); - + SERIAL_ECHOPGM("delta x="); SERIAL_ECHO(delta[X_AXIS]); SERIAL_ECHOPGM(" y="); SERIAL_ECHO(delta[Y_AXIS]); SERIAL_ECHOPGM(" z="); SERIAL_ECHOLN(delta[Z_AXIS]); - + SERIAL_ECHOPGM("C2="); SERIAL_ECHO(SCARA_C2); SERIAL_ECHOPGM(" S2="); SERIAL_ECHO(SCARA_S2); SERIAL_ECHOPGM(" Theta="); SERIAL_ECHO(SCARA_theta); @@ -4365,7 +4365,7 @@ void handle_status_leds(void) { void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { - + #if defined(KILL_PIN) && KILL_PIN > -1 static int killCount = 0; // make the inactivity button a bit less responsive const int KILL_DELAY = 10000; @@ -4375,8 +4375,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 10000; #endif - - + + if(buflen < (BUFSIZE-1)) get_command(); @@ -4396,7 +4396,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } } - + #ifdef CHDK //Check if pin should be set to LOW after M240 set it to HIGH if (chdkActive && (millis() - chdkHigh > CHDK_DELAY)) { @@ -4404,9 +4404,9 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s WRITE(CHDK, LOW); } #endif - + #if defined(KILL_PIN) && KILL_PIN > -1 - + // Check if the kill button was pressed and wait just in case it was an accidental // key kill key press // ------------------------------------------------------------------------------- @@ -4448,7 +4448,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } } #endif - + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 controllerFan(); //Check if fan should be turned on to cool stepper drivers down #endif @@ -4505,12 +4505,12 @@ void kill() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_ERR_KILLED); LCD_ALERTMESSAGEPGM(MSG_KILLED); - + // FMC small patch to update the LCD before ending sei(); // enable interrupts for ( int i=5; i--; lcd_update()) { - delay(200); + delay(200); } cli(); // disable interrupts suicide(); diff --git a/MeCreator2/Firmware_Marlin/Sd2Card.h b/MeCreator2/Firmware_Marlin/Sd2Card.h index d6b302bf..f6490387 100644 --- a/MeCreator2/Firmware_Marlin/Sd2Card.h +++ b/MeCreator2/Firmware_Marlin/Sd2Card.h @@ -183,7 +183,7 @@ class Sd2Card { /** * Read a card's CID register. The CID contains card identification * information such as Manufacturer ID, Product name, Product serial - * number and Manufacturing date. + * number and Manufacturing date. * * \param[out] cid pointer to area for returned data. * diff --git a/MeCreator2/Firmware_Marlin/SdBaseFile.cpp b/MeCreator2/Firmware_Marlin/SdBaseFile.cpp index dbcf77fb..dfafe92f 100644 --- a/MeCreator2/Firmware_Marlin/SdBaseFile.cpp +++ b/MeCreator2/Firmware_Marlin/SdBaseFile.cpp @@ -1112,7 +1112,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0X1F & curPosition_)) return -1; - + //If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly. if (longFilename != NULL) { diff --git a/MeCreator2/Firmware_Marlin/SdFatStructs.h b/MeCreator2/Firmware_Marlin/SdFatStructs.h index 38672161..b7bccabd 100644 --- a/MeCreator2/Firmware_Marlin/SdFatStructs.h +++ b/MeCreator2/Firmware_Marlin/SdFatStructs.h @@ -468,29 +468,29 @@ uint32_t const FAT32MASK = 0X0FFFFFFF; * \brief FAT short directory entry * * Short means short 8.3 name, not the entry size. - * - * Date Format. A FAT directory entry date stamp is a 16-bit field that is + * + * Date Format. A FAT directory entry date stamp is a 16-bit field that is * basically a date relative to the MS-DOS epoch of 01/01/1980. Here is the - * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the + * format (bit 0 is the LSB of the 16-bit word, bit 15 is the MSB of the * 16-bit word): - * - * Bits 9-15: Count of years from 1980, valid value range 0-127 + * + * Bits 9-15: Count of years from 1980, valid value range 0-127 * inclusive (1980-2107). - * + * * Bits 5-8: Month of year, 1 = January, valid value range 1-12 inclusive. * * Bits 0-4: Day of month, valid value range 1-31 inclusive. * * Time Format. A FAT directory entry time stamp is a 16-bit field that has - * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the + * a granularity of 2 seconds. Here is the format (bit 0 is the LSB of the * 16-bit word, bit 15 is the MSB of the 16-bit word). - * + * * Bits 11-15: Hours, valid value range 0-23 inclusive. - * + * * Bits 5-10: Minutes, valid value range 0-59 inclusive. - * + * * Bits 0-4: 2-second count, valid value range 0-29 inclusive (0 - 58 seconds). - * + * * The valid time range is from Midnight 00:00:00 to 23:59:58. */ struct directoryEntry { @@ -548,7 +548,7 @@ struct directoryEntry { * * directoryVFATEntries are found in the same list as normal directoryEntry. * But have the attribute field set to DIR_ATT_LONG_NAME. - * + * * Long filenames are saved in multiple directoryVFATEntries. * Each entry containing 13 UTF-16 characters. */ diff --git a/MeCreator2/Firmware_Marlin/SdFile.h b/MeCreator2/Firmware_Marlin/SdFile.h index cbf1bbdb..b0c5a029 100644 --- a/MeCreator2/Firmware_Marlin/SdFile.h +++ b/MeCreator2/Firmware_Marlin/SdFile.h @@ -42,7 +42,7 @@ class SdFile : public SdBaseFile, public Print { #else void write(uint8_t b); #endif - + int16_t write(const void* buf, uint16_t nbyte); void write(const char* str); void write_P(PGM_P str); diff --git a/MeCreator2/Firmware_Marlin/Servo.cpp b/MeCreator2/Firmware_Marlin/Servo.cpp index 5f8c7efe..03b00ffb 100644 --- a/MeCreator2/Firmware_Marlin/Servo.cpp +++ b/MeCreator2/Firmware_Marlin/Servo.cpp @@ -41,7 +41,7 @@ detach() - Stops an attached servos from pulsing its i/o pin. */ -#include "Configuration.h" +#include "Configuration.h" #ifdef NUM_SERVOS #include diff --git a/MeCreator2/Firmware_Marlin/cardreader.cpp b/MeCreator2/Firmware_Marlin/cardreader.cpp index e22f3436..6a1c3aef 100644 --- a/MeCreator2/Firmware_Marlin/cardreader.cpp +++ b/MeCreator2/Firmware_Marlin/cardreader.cpp @@ -26,20 +26,20 @@ CardReader::CardReader() lastnr=0; //power to SD reader #if SDPOWER > -1 - SET_OUTPUT(SDPOWER); + SET_OUTPUT(SDPOWER); WRITE(SDPOWER,HIGH); #endif //SDPOWER - + autostart_atmillis=millis()+5000; } char *createFilename(char *buffer,const dir_t &p) //buffer>12characters { char *pos=buffer; - for (uint8_t i = 0; i < 11; i++) + for (uint8_t i = 0; i < 11; i++) { if (p.name[i] == ' ')continue; - if (i == 8) + if (i == 8) { *pos++='.'; } @@ -54,7 +54,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m { dir_t p; uint8_t cnt=0; - + while (parent.readDir(p, longFilename) > 0) { if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint @@ -63,7 +63,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m char path[13*2]; char lfilename[13]; createFilename(lfilename,p); - + path[0]=0; if(strlen(prepend)==0) //avoid leading / if already in prepend { @@ -72,9 +72,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m strcat(path,prepend); strcat(path,lfilename); strcat(path,"/"); - + //Serial.print(path); - + SdFile dir; if(!dir.open(parent,lfilename, O_READ)) { @@ -88,7 +88,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m lsDive(path,dir); //close done automatically by destructor of SdFile - + } else { @@ -100,8 +100,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); - - + + if(!filenameIsDir) { if(p.name[8]!='G') continue; @@ -117,7 +117,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m else if(lsAction==LS_Count) { nrFiles++; - } + } else if(lsAction==LS_GetFilename) { if (match != NULL) { @@ -125,13 +125,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } else if (cnt == nrFiles) return; cnt++; - + } } } } -void CardReader::ls() +void CardReader::ls() { lsAction=LS_SerialPrint; if(lsAction==LS_Count) @@ -170,12 +170,12 @@ void CardReader::initsd() SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_VOL_INIT_FAIL); } - else if (!root.openRoot(&volume)) + else if (!root.openRoot(&volume)) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL); } - else + else { cardOK = true; SERIAL_ECHO_START; @@ -189,7 +189,7 @@ void CardReader::initsd() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); } */ - + } void CardReader::setroot() @@ -199,7 +199,7 @@ void CardReader::setroot() SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL); }*/ workDir=root; - + curDir=&workDir; } void CardReader::release() @@ -238,7 +238,7 @@ void CardReader::getAbsFilename(char *t) for(uint8_t i=0;i 0) + while (root.readDir(p, NULL) > 0) { for(int8_t i=0;i<(int8_t)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); @@ -546,17 +546,17 @@ void CardReader::closefile(bool store_location) { file.sync(); file.close(); - saving = false; + saving = false; logging = false; - + if(store_location) { //future: store printer state, filename and position for continuing a stopped print // so one can unplug the printer and continue printing the next day. - + } - + } void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) @@ -566,7 +566,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) nrFiles=nr; curDir->rewind(); lsDive("",*curDir,match); - + } uint16_t CardReader::getnrfilenames() @@ -584,10 +584,10 @@ void CardReader::chdir(const char * relpath) { SdFile newfile; SdFile *parent=&root; - + if(workDir.isOpen()) parent=&workDir; - + if(!newfile.open(*parent,relpath, O_READ)) { SERIAL_ECHO_START; diff --git a/MeCreator2/Firmware_Marlin/cardreader.h b/MeCreator2/Firmware_Marlin/cardreader.h index e513dc06..312dd956 100644 --- a/MeCreator2/Firmware_Marlin/cardreader.h +++ b/MeCreator2/Firmware_Marlin/cardreader.h @@ -11,13 +11,13 @@ class CardReader { public: CardReader(); - + void initsd(); void write_command(char *buf); //files auto[0-9].g on the sd card are performed in a row //this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset - void checkautostart(bool x); + void checkautostart(bool x); void openFile(char* name,bool read,bool replace_current=true); void openLogFile(char* name); void removeFile(char* name); @@ -30,9 +30,9 @@ class CardReader void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); - + void getAbsFilename(char *t); - + void ls(); void chdir(const char * relpath); @@ -50,7 +50,7 @@ class CardReader public: bool saving; bool logging; - bool sdprinting ; + bool sdprinting ; bool cardOK ; char filename[13]; char longFilename[LONG_FILENAME_LENGTH]; @@ -73,7 +73,7 @@ class CardReader uint32_t sdpos ; bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. - + LsAction lsAction; //stored for recursion. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; @@ -83,7 +83,7 @@ extern CardReader card; #define IS_SD_PRINTING (card.sdprinting) #if (SDCARDDETECT > -1) -# ifdef SDCARDDETECTINVERTED +# ifdef SDCARDDETECTINVERTED # define IS_SD_INSERTED (READ(SDCARDDETECT)!=0) # else # define IS_SD_INSERTED (READ(SDCARDDETECT)==0) diff --git a/MeCreator2/Firmware_Marlin/dogm_font_data_marlin.h b/MeCreator2/Firmware_Marlin/dogm_font_data_marlin.h index 6b83903c..593d400f 100644 --- a/MeCreator2/Firmware_Marlin/dogm_font_data_marlin.h +++ b/MeCreator2/Firmware_Marlin/dogm_font_data_marlin.h @@ -334,4 +334,4 @@ const u8g_fntpgm_uint8_t u8g_font_6x10_marlin[2617] U8G_SECTION(".progmem.u8g_fo 255,224,128,192,176,168,168,48,40,40,5,9,9,6,0,255, 248,168,136,136,136,136,136,168,248,5,10,10,6,0,254,32, 80,80,80,80,136,168,168,136,112}; - + diff --git a/MeCreator2/Firmware_Marlin/dogm_lcd_implementation.h b/MeCreator2/Firmware_Marlin/dogm_lcd_implementation.h index 1d9f1636..720b09f6 100644 --- a/MeCreator2/Firmware_Marlin/dogm_lcd_implementation.h +++ b/MeCreator2/Firmware_Marlin/dogm_lcd_implementation.h @@ -92,11 +92,11 @@ static void lcd_implementation_init() digitalWrite(LCD_PIN_BL, HIGH); #endif - u8g.setContrast(lcd_contrast); + u8g.setContrast(lcd_contrast); // Uncomment this if you have the first generation (V1.10) of STBs board // pinMode(17, OUTPUT); // Enable LCD backlight // digitalWrite(17, HIGH); - + u8g.firstPage(); do { u8g.setFont(u8g_font_6x10_marlin); @@ -117,17 +117,17 @@ static void lcd_implementation_init() u8g.setRot270(); // Rotate screen by 270° #endif - + u8g.firstPage(); do { // RepRap init bmp #ifdef GEEETECH_STARTUP_BMP - u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); + u8g.drawBitmapP(0, 0, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp); #else u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp); // Welcome message u8g.setFont(u8g_font_6x10_marlin); - u8g.drawStr(62,10,"MARLIN"); + u8g.drawStr(62,10,"MARLIN"); u8g.setFont(u8g_font_5x8); u8g.drawStr(62,19,"V1.0.2"); u8g.setFont(u8g_font_6x10_marlin); @@ -151,7 +151,7 @@ static void lcd_implementation_clear() // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2 // // u8g.firstPage(); -// do { +// do { // u8g.setColorIndex(0); // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight()); // u8g.setColorIndex(1); @@ -192,12 +192,12 @@ static void lcd_implementation_status_screen() { static unsigned char fan_rot = 0; - + u8g.setColorIndex(1); // black on white - + // Symbols menu graphics, animated fan u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); - + #ifdef SDSUPPORT //SD Card Symbol u8g.drawBox(42,42,8,7); @@ -206,10 +206,10 @@ static void lcd_implementation_status_screen() u8g.drawPixel(50,43); // Progress bar u8g.drawFrame(54,49,73,4); - + // SD Card Progress bar and clock u8g.setFont(FONT_STATUSMENU); - + if (IS_SD_PRINTING) { // Progress bar @@ -218,7 +218,7 @@ static void lcd_implementation_status_screen() else { // do nothing } - + u8g.setPrintPos(80,47); if(starttime != 0) { @@ -231,7 +231,7 @@ static void lcd_implementation_status_screen() lcd_printPGM(PSTR("--:--")); } #endif - + // Extruders _draw_heater_status(6, 0); #if EXTRUDERS > 1 @@ -243,7 +243,7 @@ static void lcd_implementation_status_screen() // Heatbed _draw_heater_status(81, -1); - + // Fan u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(104,27); @@ -253,8 +253,8 @@ static void lcd_implementation_status_screen() #else u8g.print("---"); #endif - - + + // X, Y, Z-Coordinates u8g.setFont(FONT_STATUSMENU); u8g.drawBox(0,29,128,10); @@ -278,7 +278,7 @@ static void lcd_implementation_status_screen() u8g.setPrintPos(91,37); u8g.print(ftostr31(current_position[Z_AXIS])); u8g.setColorIndex(1); // black on white - + // Feedrate u8g.setFont(u8g_font_6x10_marlin); u8g.setPrintPos(3,49); @@ -305,23 +305,23 @@ static void lcd_implementation_status_screen() u8g.print(itostr3(extrudemultiply)); u8g.print('%'); } - #endif + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { char c; - + uint8_t n = LCD_WIDTH - 1 - 2; - + if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] )) { u8g.setColorIndex(1); // black on white u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT); u8g.setColorIndex(0); // following text must be white on black } else u8g.setColorIndex(1); // unmarked text is black on white - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char == '>' ? ' ' : pre_char); // Row selector is obsolete @@ -335,7 +335,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c while(n--){ u8g.print(' '); } - + u8g.print(post_char); u8g.print(' '); u8g.setColorIndex(1); // restore settings to black on white @@ -344,7 +344,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); - + u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT); u8g.print(pre_char); diff --git a/MeCreator2/Firmware_Marlin/fastio.h b/MeCreator2/Firmware_Marlin/fastio.h index 53f8221d..9ee92ed1 100644 --- a/MeCreator2/Firmware_Marlin/fastio.h +++ b/MeCreator2/Firmware_Marlin/fastio.h @@ -2036,7 +2036,7 @@ pins pins */ -//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments +//#define AT90USBxx_TEENSYPP_ASSIGNMENTS // Use Teensy++ 2.0 assignments #ifndef AT90USBxx_TEENSYPP_ASSIGNMENTS // Use traditional Marlin pin assignments #define DIO0_PIN PINA0 @@ -2676,8 +2676,8 @@ pins /* -AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 -Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 +AT90USB 51 50 49 48 47 46 45 44 10 11 12 13 14 15 16 17 35 36 37 38 39 40 41 42 25 26 27 28 29 30 31 32 33 34 43 09 18 19 01 02 61 60 59 58 57 56 55 54 +Port A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 Marlin 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 Teensy 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 The pins 46 and 47 are not supported by Teensyduino, but are supported below. diff --git a/MeCreator2/Firmware_Marlin/language.h b/MeCreator2/Firmware_Marlin/language.h index 4a034b1d..05c06056 100644 --- a/MeCreator2/Firmware_Marlin/language.h +++ b/MeCreator2/Firmware_Marlin/language.h @@ -109,7 +109,7 @@ #define MSG_HEATING_COMPLETE "Heating done." #define MSG_BED_HEATING "Bed Heating." #define MSG_BED_DONE "Bed done." -#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" +#define MSG_M115_REPORT "FIRMWARE_NAME:" VERSION_STRING " Sprinter/grbl mashup for gen6 FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" #define MSG_COUNT_X " Count X: " #define MSG_ERR_KILLED "Printer halted. kill() called!" #define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)" diff --git a/MeCreator2/Firmware_Marlin/motion_control.cpp b/MeCreator2/Firmware_Marlin/motion_control.cpp index b26cbafc..43b16a84 100644 --- a/MeCreator2/Firmware_Marlin/motion_control.cpp +++ b/MeCreator2/Firmware_Marlin/motion_control.cpp @@ -4,7 +4,7 @@ Copyright (c) 2009-2011 Simen Svale Skogsrud Copyright (c) 2011 Sungeun K. Jeon - + Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or @@ -23,11 +23,11 @@ #include "stepper.h" #include "planner.h" -// The arc is approximated by generating a huge number of tiny, linear segments. The length of each -// segment is configured in settings.mm_per_arc_segment. -void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, +// The arc is approximated by generating a huge number of tiny, linear segments. The length of each +// segment is configured in settings.mm_per_arc_segment. +void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) -{ +{ // int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled(); // plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc float center_axis0 = position[axis_0] + offset[axis_0]; @@ -38,12 +38,12 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 float r_axis1 = -offset[axis_1]; float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; - + // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel = atan2(r_axis0*rt_axis1-r_axis1*rt_axis0, r_axis0*rt_axis0+r_axis1*rt_axis1); if (angular_travel < 0) { angular_travel += 2*M_PI; } if (isclockwise) { angular_travel -= 2*M_PI; } - + //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi if (position[axis_0] == target[axis_0] && position[axis_1] == target[axis_1] && angular_travel == 0) @@ -51,51 +51,51 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 angular_travel += 2*M_PI; } //end fix G03 - + float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel)); if (millimeters_of_travel < 0.001) { return; } uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT); if(segments == 0) segments = 1; - - /* + + /* // Multiply inverse feed_rate to compensate for the fact that this movement is approximated - // by a number of discrete segments. The inverse feed_rate should be correct for the sum of + // by a number of discrete segments. The inverse feed_rate should be correct for the sum of // all segments. if (invert_feed_rate) { feed_rate *= segments; } */ float theta_per_segment = angular_travel/segments; float linear_per_segment = linear_travel/segments; float extruder_per_segment = extruder_travel/segments; - + /* Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, and phi is the angle of rotation. Based on the solution approach by Jens Geisler. r_T = [cos(phi) -sin(phi); sin(phi) cos(phi] * r ; - - For arc generation, the center of the circle is the axis of rotation and the radius vector is + + For arc generation, the center of the circle is the axis of rotation and the radius vector is defined from the circle center to the initial position. Each line segment is formed by successive vector rotations. This requires only two cos() and sin() computations to form the rotation matrix for the duration of the entire arc. Error may accumulate from numerical round-off, since all double numbers are single precision on the Arduino. (True double precision will not have round off issues for CNC applications.) Single precision error can accumulate to be greater than - tool precision in some cases. Therefore, arc path correction is implemented. + tool precision in some cases. Therefore, arc path correction is implemented. Small angle approximation may be used to reduce computation overhead further. This approximation holds for everything, but very small circles and large mm_per_arc_segment values. In other words, theta_per_segment would need to be greater than 0.1 rad and N_ARC_CORRECTION would need to be large - to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for + to cause an appreciable drift error. N_ARC_CORRECTION~=25 is more than small enough to correct for numerical drift error. N_ARC_CORRECTION may be on the order a hundred(s) before error becomes an issue for CNC machines with the single precision Arduino calculations. - - This approximation also allows mc_arc to immediately insert a line segment into the planner + + This approximation also allows mc_arc to immediately insert a line segment into the planner without the initial overhead of computing cos() or sin(). By the time the arc needs to be applied - a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. - This is important when there are successive arc motions. + a correction, the planner should have caught up to the lag caused by the initial mc_arc overhead. + This is important when there are successive arc motions. */ // Vector rotation matrix values float cos_T = 1-0.5*theta_per_segment*theta_per_segment; // Small angle approximation float sin_T = theta_per_segment; - + float arc_target[4]; float sin_Ti; float cos_Ti; @@ -105,14 +105,14 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8 // Initialize the linear axis arc_target[axis_linear] = position[axis_linear]; - + // Initialize the extruder axis arc_target[E_AXIS] = position[E_AXIS]; for (i = 1; i. */ /* The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. */ -/* +/* Reasoning behind the mathematics in this module (in the key of 'Mathematica'): - + s == speed, a == acceleration, t == time, d == distance - + Basic definitions: - - Speed[s_, a_, t_] := s + (a*t) + + Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t] - + Distance to reach a specific speed with a constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() - + Speed after a given distance of travel with constant acceleration: - + Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] - m -> Sqrt[2 a d + s^2] - + m -> Sqrt[2 a d + s^2] + DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] - + When to start braking (di) to reach a specified destionation speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: - + Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() - + IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) */ @@ -129,8 +129,8 @@ static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. static int8_t next_block_index(int8_t block_index) { block_index++; - if (block_index == BLOCK_BUFFER_SIZE) { - block_index = 0; + if (block_index == BLOCK_BUFFER_SIZE) { + block_index = 0; } return(block_index); } @@ -138,8 +138,8 @@ static int8_t next_block_index(int8_t block_index) { // Returns the index of the previous block in the ring buffer static int8_t prev_block_index(int8_t block_index) { - if (block_index == 0) { - block_index = BLOCK_BUFFER_SIZE; + if (block_index == 0) { + block_index = BLOCK_BUFFER_SIZE; } block_index--; return(block_index); @@ -149,7 +149,7 @@ static int8_t prev_block_index(int8_t block_index) { //=============================functions ============================ //=========================================================================== -// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the +// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // given acceleration: FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { @@ -162,12 +162,12 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ } } -// This function gives you the point at which you must start braking (at the rate of -acceleration) if +// This function gives you the point at which you must start braking (at the rate of -acceleration) if // you started at speed initial_rate and accelerated until this point and want to end at the final_rate after // a total travel of distance. This can be used to compute the intersection point between acceleration and // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) -FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) +FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { if (acceleration!=0) { return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ @@ -186,10 +186,10 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi // Limit minimal step rate (Otherwise the timer will overflow.) if(initial_rate <120) { - initial_rate=120; + initial_rate=120; } if(final_rate < 120) { - final_rate=120; + final_rate=120; } long acceleration = block->acceleration_st; @@ -212,7 +212,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi } #ifdef ADVANCE - volatile long initial_advance = block->advance*entry_factor*entry_factor; + volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long final_advance = block->advance*exit_factor*exit_factor; #endif // ADVANCE @@ -230,16 +230,16 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi #endif //ADVANCE } CRITICAL_SECTION_END; -} +} -// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the +// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // acceleration within the allotted distance. FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { return sqrt(target_velocity*target_velocity-2*acceleration*distance); } // "Junction jerk" in this context is the immediate change in speed at the junction of two blocks. -// This method will calculate the junction jerk as the euclidean distance between the nominal +// This method will calculate the junction jerk as the euclidean distance between the nominal // velocities of the respective blocks. //inline float junction_jerk(block_t *before, block_t *after) { // return sqrt( @@ -249,8 +249,8 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity // The kernel called by planner_recalculate() when scanning the plan from last to first entry. void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!current) { - return; + if(!current) { + return; } if (next) { @@ -264,7 +264,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { current->entry_speed = min( current->max_entry_speed, max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); - } + } else { current->entry_speed = current->max_entry_speed; } @@ -274,22 +274,22 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n } // Skip last block. Already initialized and set for recalculation. } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the reverse pass. void planner_reverse_pass() { uint8_t block_index = block_buffer_head; - + //Make a local copy of block_buffer_tail, because the interrupt can alter it CRITICAL_SECTION_START; unsigned char tail = block_buffer_tail; CRITICAL_SECTION_END - + if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; - while(block_index != tail) { - block_index = prev_block_index(block_index); + while(block_index != tail) { + block_index = prev_block_index(block_index); block[2]= block[1]; block[1]= block[0]; block[0] = &block_buffer[block_index]; @@ -300,8 +300,8 @@ void planner_reverse_pass() { // The kernel called by planner_recalculate() when scanning the plan from first to last entry. void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { - if(!previous) { - return; + if(!previous) { + return; } // If the previous block is an acceleration block, but it is not long enough to complete the @@ -322,11 +322,11 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n } } -// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This +// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This // implements the forward pass. void planner_forward_pass() { uint8_t block_index = block_buffer_tail; - block_t *block[3] = { + block_t *block[3] = { NULL, NULL, NULL }; while(block_index != block_buffer_head) { @@ -339,8 +339,8 @@ void planner_forward_pass() { planner_forward_pass_kernel(block[1], block[2], NULL); } -// Recalculates the trapezoid speed profiles for all blocks in the plan according to the -// entry_factor for each junction. Must be called by planner_recalculate() after +// Recalculates the trapezoid speed profiles for all blocks in the plan according to the +// entry_factor for each junction. Must be called by planner_recalculate() after // updating the blocks. void planner_recalculate_trapezoids() { int8_t block_index = block_buffer_tail; @@ -371,22 +371,22 @@ void planner_recalculate_trapezoids() { // Recalculates the motion plan according to the following algorithm: // -// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) +// 1. Go over every block in reverse order and calculate a junction speed reduction (i.e. block_t.entry_factor) // so that: // a. The junction jerk is within the set limit -// b. No speed reduction within one block requires faster deceleration than the one, true constant +// b. No speed reduction within one block requires faster deceleration than the one, true constant // acceleration. -// 2. Go over every block in chronological order and dial down junction speed reduction values if -// a. The speed increase within one block would require faster accelleration than the one, true +// 2. Go over every block in chronological order and dial down junction speed reduction values if +// a. The speed increase within one block would require faster accelleration than the one, true // constant acceleration. // -// When these stages are complete all blocks have an entry_factor that will allow all speed changes to -// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than +// When these stages are complete all blocks have an entry_factor that will allow all speed changes to +// be performed using only the one, true constant acceleration, and where no junction jerk is jerkier than // the set limit. Finally it will: // // 3. Recalculate trapezoids for all blocks. -void planner_recalculate() { +void planner_recalculate() { planner_reverse_pass(); planner_forward_pass(); planner_recalculate_trapezoids(); @@ -452,7 +452,7 @@ void getHighESpeed() void check_axes_activity() { unsigned char x_active = 0; - unsigned char y_active = 0; + unsigned char y_active = 0; unsigned char z_active = 0; unsigned char e_active = 0; unsigned char tail_fan_speed = fanSpeed; @@ -487,7 +487,7 @@ void check_axes_activity() { disable_e0(); disable_e1(); - disable_e2(); + disable_e2(); } #if defined(FAN_PIN) && FAN_PIN > -1 #ifdef FAN_KICKSTART_TIME @@ -527,7 +527,7 @@ void check_axes_activity() float junction_deviation = 0.1; -// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in +// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // calculation the caller must also provide the physical length of the line in millimeters. #ifdef ENABLE_AUTO_BED_LEVELING @@ -539,12 +539,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa // Calculate the buffer head after we push this byte int next_buffer_head = next_block_index(block_buffer_head); - // If the buffer is full: good! That means we are well ahead of the robot. + // If the buffer is full: good! That means we are well ahead of the robot. // Rest here until there is room in the buffer. while(block_buffer_tail == next_buffer_head) { - manage_heater(); - manage_inactivity(); + manage_heater(); + manage_inactivity(); lcd_update(); } @@ -558,7 +558,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa long target[4]; target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); #ifdef PREVENT_DANGEROUS_EXTRUDE @@ -570,7 +570,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa SERIAL_ECHO_START; SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); } - + #ifdef PREVENT_LENGTHY_EXTRUDE if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) { @@ -608,8 +608,8 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi // Bail if this is a zero-length block if (block->step_event_count <= dropsegments) - { - return; + { + return; } block->fan_speed = fanSpeed; @@ -618,34 +618,34 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi block->e_to_p_pressure = EtoPPressure; #endif - // Compute direction bits for this block + // Compute direction bits for this block block->direction_bits = 0; #ifndef COREXY if (target[X_AXIS] < position[X_AXIS]) { - block->direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; @@ -674,37 +674,37 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--; - + switch(extruder) { - case 0: - enable_e0(); + case 0: + enable_e0(); g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 1: - enable_e1(); + enable_e1(); g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[2] == 0) disable_e2(); + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[2] == 0) disable_e2(); break; case 2: - enable_e2(); + enable_e2(); g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; - - if(g_uc_extruder_last_move[0] == 0) disable_e0(); - if(g_uc_extruder_last_move[1] == 0) disable_e1(); - break; + + if(g_uc_extruder_last_move[0] == 0) disable_e0(); + if(g_uc_extruder_last_move[1] == 0) disable_e1(); + break; } } else //enable all { enable_e0(); enable_e1(); - enable_e2(); + enable_e2(); } } @@ -715,15 +715,15 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi else { if(feed_ratesteps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); - } + } else { #ifndef COREXY block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); #else block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); - #endif + #endif } - float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides + float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; @@ -759,7 +759,7 @@ Having the real displacement of the head, we can calculate the total movement le // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef OLD_SLOWDOWN if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) - feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); + feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); #endif #ifdef SLOWDOWN @@ -776,7 +776,7 @@ Having the real displacement of the head, we can calculate the total movement le } } #endif - // END OF SLOW DOWN SECTION + // END OF SLOW DOWN SECTION block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 @@ -784,25 +784,25 @@ Having the real displacement of the head, we can calculate the total movement le #ifdef FILAMENT_SENSOR //FMM update ring buffer used for delay with filament measurements - - + + if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized { delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis - + while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer while (delay_dist<0) delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer - + delay_index1=delay_dist/10.0; //calculate index - + //ensure the number is within range of the array after converting from floating point if(delay_index1<0) delay_index1=0; else if (delay_index1>MAX_MEASUREMENT_DELAY) delay_index1=MAX_MEASUREMENT_DELAY; - + if(delay_index1 != delay_index2) //moved index { meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char @@ -815,12 +815,12 @@ Having the real displacement of the head, we can calculate the total movement le if(delay_index2<0) delay_index2=0; else if (delay_index2>MAX_MEASUREMENT_DELAY) - delay_index2=MAX_MEASUREMENT_DELAY; - + delay_index2=MAX_MEASUREMENT_DELAY; + measurement_delay[delay_index2]=meas_sample; } - - + + } #endif @@ -842,7 +842,7 @@ Having the real displacement of the head, we can calculate the total movement le unsigned char direction_change = block->direction_bits ^ old_direction_bits; old_direction_bits = block->direction_bits; segment_time = lround((float)segment_time / speed_factor); - + if((direction_change & (1<nominal_rate *= speed_factor; } - // Compute and limit the acceleration rate for the trapezoid generator. + // Compute and limit the acceleration rate for the trapezoid generator. float steps_per_mm = block->step_event_count/block->millimeters; if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) { @@ -944,11 +944,11 @@ Having the real displacement of the head, we can calculate the total movement le } #endif // Start with a safe speed - float vmax_junction = max_xy_jerk/2; - float vmax_junction_factor = 1.0; - if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) + float vmax_junction = max_xy_jerk/2; + float vmax_junction_factor = 1.0; + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = min(vmax_junction, max_z_jerk/2); - if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); vmax_junction = min(vmax_junction, block->nominal_speed); float safe_speed = vmax_junction; @@ -960,13 +960,13 @@ Having the real displacement of the head, we can calculate the total movement le // } if (jerk > max_xy_jerk) { vmax_junction_factor = (max_xy_jerk/jerk); - } + } if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { vmax_junction_factor= min(vmax_junction_factor, (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]))); - } + } if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { vmax_junction_factor = min(vmax_junction_factor, (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]))); - } + } vmax_junction = min(previous_nominal_speed, vmax_junction * vmax_junction_factor); // Limit speed to max previous speed } block->max_entry_speed = vmax_junction; @@ -983,11 +983,11 @@ Having the real displacement of the head, we can calculate the total movement le // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - if (block->nominal_speed <= v_allowable) { - block->nominal_length_flag = true; + if (block->nominal_speed <= v_allowable) { + block->nominal_length_flag = true; } - else { - block->nominal_length_flag = false; + else { + block->nominal_length_flag = false; } block->recalculate_flag = true; // Always calculate trapezoid for new block @@ -1004,12 +1004,12 @@ Having the real displacement of the head, we can calculate the total movement le } else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); - float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * + float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUSION_AREA * EXTRUSION_AREA)*256; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; - } + } else { block->advance_rate = advance / (float)acc_dist; } @@ -1063,8 +1063,8 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); - position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_speed[0] = 0.0; @@ -1075,7 +1075,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo void plan_set_e_position(const float &e) { - position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); st_set_e_position(position[E_AXIS]); } diff --git a/MeCreator2/Firmware_Marlin/planner.h b/MeCreator2/Firmware_Marlin/planner.h index 0952b9dd..7b2d8d9f 100644 --- a/MeCreator2/Firmware_Marlin/planner.h +++ b/MeCreator2/Firmware_Marlin/planner.h @@ -18,7 +18,7 @@ along with Grbl. If not, see . */ -// This module is to be considered a sub-module of stepper.c. Please don't include +// This module is to be considered a sub-module of stepper.c. Please don't include // this file from any other module. #ifndef planner_h @@ -30,7 +30,7 @@ #include "vector_3.h" #endif // ENABLE_AUTO_BED_LEVELING -// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in +// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // the source g-code and may never actually be reached if acceleration management is active. typedef struct { // Fields used by the bresenham algorithm for tracing the line @@ -50,7 +50,7 @@ typedef struct { // Fields used by the motion planner to manage acceleration // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis - float nominal_speed; // The nominal speed for this block in mm/sec + float nominal_speed; // The nominal speed for this block in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm @@ -59,8 +59,8 @@ typedef struct { unsigned char nominal_length_flag; // Planner flag for nominal speed always reached // Settings for the trapezoid generator - unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec - unsigned long initial_rate; // The jerk-adjusted step rate at start of block + unsigned long nominal_rate; // The nominal step rate for this block in step_events/sec + unsigned long initial_rate; // The jerk-adjusted step rate at start of block unsigned long final_rate; // The minimal rate at exit unsigned long acceleration_st; // acceleration steps/sec^2 unsigned long fan_speed; @@ -76,10 +76,10 @@ typedef struct { extern matrix_3x3 plan_bed_level_matrix; #endif // #ifdef ENABLE_AUTO_BED_LEVELING -// Initialize the motion plan subsystem +// Initialize the motion plan subsystem void plan_init(); -// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in +// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in // millimaters. Feed rate specifies the speed of the motion. #ifdef ENABLE_AUTO_BED_LEVELING @@ -125,26 +125,26 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS]; extern float autotemp_factor; #endif - + extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed -extern volatile unsigned char block_buffer_tail; +extern volatile unsigned char block_buffer_tail; // Called when the current block is no longer needed. Discards the block and makes the memory -// availible for new blocks. -FORCE_INLINE void plan_discard_current_block() +// availible for new blocks. +FORCE_INLINE void plan_discard_current_block() { if (block_buffer_head != block_buffer_tail) { - block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); + block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); } } // Gets the current block. Returns NULL if buffer empty -FORCE_INLINE block_t *plan_get_current_block() +FORCE_INLINE block_t *plan_get_current_block() { - if (block_buffer_head == block_buffer_tail) { - return(NULL); + if (block_buffer_head == block_buffer_tail) { + return(NULL); } block_t *block = &block_buffer[block_buffer_tail]; block->busy = true; diff --git a/MeCreator2/Firmware_Marlin/qr_solve.cpp b/MeCreator2/Firmware_Marlin/qr_solve.cpp index f19d989d..b8f2fdb3 100644 --- a/MeCreator2/Firmware_Marlin/qr_solve.cpp +++ b/MeCreator2/Firmware_Marlin/qr_solve.cpp @@ -327,7 +327,7 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -345,8 +345,8 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -448,7 +448,7 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -466,8 +466,8 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -543,10 +543,10 @@ double ddot ( int n, double dx[], int incx, double dy[], int incy ) for ( i = m; i < n; i = i + 5 ) { - dtemp = dtemp + dx[i ] * dy[i ] - + dx[i+1] * dy[i+1] - + dx[i+2] * dy[i+2] - + dx[i+3] * dy[i+3] + dtemp = dtemp + dx[i ] * dy[i ] + + dx[i+1] * dy[i+1] + + dx[i+2] * dy[i+2] + + dx[i+3] * dy[i+3] + dx[i+4] * dy[i+4]; } } @@ -568,7 +568,7 @@ double dnrm2 ( int n, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -648,7 +648,7 @@ double dnrm2 ( int n, double x[], int incx ) } /******************************************************************************/ -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ) /******************************************************************************/ @@ -673,7 +673,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -757,7 +757,7 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, } /******************************************************************************/ -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ) /******************************************************************************/ @@ -775,7 +775,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -969,7 +969,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], */ for ( j = l + 1; j <= p; j++ ) { - t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) + t = -ddot ( n-l+1, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ) / a[l-1+(l-1)*lda]; daxpy ( n-l+1, t, a+l-1+(l-1)*lda, 1, a+l-1+(j-1)*lda, 1 ); @@ -1006,7 +1006,7 @@ void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], } /******************************************************************************/ -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ) /******************************************************************************/ @@ -1042,7 +1042,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1160,7 +1160,7 @@ int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], } /******************************************************************************/ -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ) /******************************************************************************/ @@ -1190,7 +1190,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1278,7 +1278,7 @@ void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], } /******************************************************************************/ -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ) /******************************************************************************/ @@ -1344,7 +1344,7 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1617,14 +1617,14 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], if ( cr ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, rsd+j-1, 1 ); } if ( cab ) { - t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) + t = -ddot ( n-j+1, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ) / a[j-1+(j-1)*lda]; daxpy ( n-j+1, t, a+j-1+(j-1)*lda, 1, ab+j-1, 1 ); } @@ -1649,7 +1649,7 @@ void dscal ( int n, double sa, double x[], int incx ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1739,7 +1739,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Licensing: - This code is distributed under the GNU LGPL license. + This code is distributed under the GNU LGPL license. Modified: @@ -1757,8 +1757,8 @@ void dswap ( int n, double x[], int incx, double y[], int incy ) Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, Basic Linear Algebra Subprograms for Fortran Usage, - Algorithm 539, - ACM Transactions on Mathematical Software, + Algorithm 539, + ACM Transactions on Mathematical Software, Volume 5, Number 3, September 1979, pages 308-323. Parameters: @@ -1920,7 +1920,7 @@ double *qr_solve ( int m, int n, double a[], double b[] ) free ( a_qr ); free ( jpvt ); - free ( qraux ); + free ( qraux ); free ( r ); return x; diff --git a/MeCreator2/Firmware_Marlin/qr_solve.h b/MeCreator2/Firmware_Marlin/qr_solve.h index b38086aa..a16850a6 100644 --- a/MeCreator2/Firmware_Marlin/qr_solve.h +++ b/MeCreator2/Firmware_Marlin/qr_solve.h @@ -5,15 +5,15 @@ void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); double ddot ( int n, double dx[], int incx, double dy[], int incy ); double dnrm2 ( int n, double x[], int incx ); -void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, +void dqrank ( double a[], int lda, int m, int n, double tol, int *kr, int jpvt[], double qraux[] ); -void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], +void dqrdc ( double a[], int lda, int n, int p, double qraux[], int jpvt[], double work[], int job ); -int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], +int dqrls ( double a[], int lda, int m, int n, double tol, int *kr, double b[], double x[], double rsd[], int jpvt[], double qraux[], int itask ); -void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], +void dqrlss ( double a[], int lda, int m, int n, int kr, double b[], double x[], double rsd[], int jpvt[], double qraux[] ); -int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], +int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[], double qy[], double qty[], double b[], double rsd[], double ab[], int job ); void dscal ( int n, double sa, double x[], int incx ); void dswap ( int n, double x[], int incx, double y[], int incy ); diff --git a/MeCreator2/Firmware_Marlin/speed_lookuptable.h b/MeCreator2/Firmware_Marlin/speed_lookuptable.h index b7c00f1a..2bcd106b 100644 --- a/MeCreator2/Firmware_Marlin/speed_lookuptable.h +++ b/MeCreator2/Firmware_Marlin/speed_lookuptable.h @@ -6,72 +6,72 @@ #if F_CPU == 16000000 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\ -{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, -{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, -{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, -{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, -{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, -{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, -{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, -{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, -{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, -{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, -{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, -{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, -{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, -{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, -{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, -{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, -{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, -{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, -{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, -{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, -{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, -{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, -{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, -{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, -{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, -{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, -{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, -{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, -{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, -{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, -{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, +{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, +{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, +{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14}, +{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8}, +{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5}, +{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3}, +{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2}, +{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2}, +{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1}, +{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1}, +{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1}, +{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1}, +{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0}, +{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1}, +{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0}, +{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1}, +{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0}, +{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0}, +{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0}, +{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1}, +{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0}, +{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0}, +{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0}, +{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0}, +{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0}, +{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0}, +{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0}, +{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1}, +{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0}, +{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0}, +{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0} }; const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\ -{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, -{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, -{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, -{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, -{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, -{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, -{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, -{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, -{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, -{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, -{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, -{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, -{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, -{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, -{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, -{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, -{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, -{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, -{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, -{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, -{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, -{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, -{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, -{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, -{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, -{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, -{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, -{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, -{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, -{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, -{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, +{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894}, +{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657}, +{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331}, +{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198}, +{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132}, +{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94}, +{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71}, +{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55}, +{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44}, +{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36}, +{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30}, +{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25}, +{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22}, +{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18}, +{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16}, +{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15}, +{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13}, +{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11}, +{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10}, +{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9}, +{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8}, +{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8}, +{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7}, +{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7}, +{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6}, +{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5}, +{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5}, +{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5}, +{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4}, +{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4}, +{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4}, { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3} }; diff --git a/MeCreator2/Firmware_Marlin/stepper.cpp b/MeCreator2/Firmware_Marlin/stepper.cpp index b2e7d120..1a31be70 100644 --- a/MeCreator2/Firmware_Marlin/stepper.cpp +++ b/MeCreator2/Firmware_Marlin/stepper.cpp @@ -364,7 +364,7 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=-1; } else{ @@ -381,25 +381,25 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_DIR_PIN, !INVERT_X_DIR); - #endif + #endif count_direction[X_AXIS]=1; } if((out_bits & (1<active_extruder == 0 && X_HOME_DIR == -1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) - #endif + #endif { #if defined(X_MIN_PIN) && X_MIN_PIN > -1 bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); @@ -434,9 +434,9 @@ ISR(TIMER1_COMPA_vect) { #ifdef DUAL_X_CARRIAGE // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder - if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) + if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) - #endif + #endif { #if defined(X_MAX_PIN) && X_MAX_PIN > -1 bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); @@ -486,7 +486,7 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1< 0) { WRITE(X_STEP_PIN, HIGH); } @@ -587,7 +587,7 @@ ISR(TIMER1_COMPA_vect) if (counter_x > 0) { counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; WRITE(X_STEP_PIN, LOW); } @@ -625,9 +625,9 @@ ISR(TIMER1_COMPA_vect) } #else WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - #endif + #endif counter_x -= current_block->step_event_count; - count_position[X_AXIS]+=count_direction[X_AXIS]; + count_position[X_AXIS]+=count_direction[X_AXIS]; #ifdef DUAL_X_CARRIAGE if (extruder_duplication_enabled){ WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); @@ -647,15 +647,15 @@ ISR(TIMER1_COMPA_vect) counter_y += current_block->steps_y; if (counter_y > 0) { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif - + counter_y -= current_block->step_event_count; count_position[Y_AXIS]+=count_direction[Y_AXIS]; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); - + #ifdef Y_DUAL_STEPPER_DRIVERS WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); #endif @@ -664,7 +664,7 @@ ISR(TIMER1_COMPA_vect) counter_z += current_block->steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -672,7 +672,7 @@ ISR(TIMER1_COMPA_vect) counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); - + #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); #endif @@ -831,7 +831,7 @@ void st_init() #endif #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 SET_OUTPUT(Y_DIR_PIN); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) SET_OUTPUT(Y2_DIR_PIN); #endif @@ -866,7 +866,7 @@ void st_init() #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 SET_OUTPUT(Y_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); - + #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) SET_OUTPUT(Y2_ENABLE_PIN); if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); @@ -1096,17 +1096,17 @@ void babystep(const uint8_t axis,const bool direction) { case X_AXIS: { - enable_x(); + enable_x(); uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); #ifdef DUAL_X_CARRIAGE WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); #endif - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); #ifdef DUAL_X_CARRIAGE WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); #endif @@ -1128,17 +1128,17 @@ void babystep(const uint8_t axis,const bool direction) break; case Y_AXIS: { - enable_y(); + enable_y(); uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - + //setup new step WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); #endif - - //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + + //perform step + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); #ifdef DUAL_Y_CARRIAGE WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); #endif @@ -1158,7 +1158,7 @@ void babystep(const uint8_t axis,const bool direction) } break; - + #ifndef DELTA case Z_AXIS: { @@ -1169,8 +1169,8 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif - //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //perform step + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); #ifdef Z_DUAL_STEPPER_DRIVERS WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); #endif @@ -1197,25 +1197,25 @@ void babystep(const uint8_t axis,const bool direction) enable_x(); enable_y(); enable_z(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); + uint8_t old_x_dir_pin= READ(X_DIR_PIN); + uint8_t old_y_dir_pin= READ(Y_DIR_PIN); + uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //setup new step WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - - //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); - + + //perform step + WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + //wait a tiny bit { float x=1./float(axis+1); //absolutely useless } - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); //get old pin state back. @@ -1226,7 +1226,7 @@ void babystep(const uint8_t axis,const bool direction) } break; #endif - + default: break; } } @@ -1285,12 +1285,12 @@ void microstep_init() #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1 pinMode(E1_MS1_PIN,OUTPUT); - pinMode(E1_MS2_PIN,OUTPUT); + pinMode(E1_MS2_PIN,OUTPUT); #endif #if defined(X_MS1_PIN) && X_MS1_PIN > -1 pinMode(X_MS1_PIN,OUTPUT); - pinMode(X_MS2_PIN,OUTPUT); + pinMode(X_MS2_PIN,OUTPUT); pinMode(Y_MS1_PIN,OUTPUT); pinMode(Y_MS2_PIN,OUTPUT); pinMode(Z_MS1_PIN,OUTPUT); diff --git a/MeCreator2/Firmware_Marlin/stepper.h b/MeCreator2/Firmware_Marlin/stepper.h index 1477a6e0..9b2861d4 100644 --- a/MeCreator2/Firmware_Marlin/stepper.h +++ b/MeCreator2/Firmware_Marlin/stepper.h @@ -19,7 +19,7 @@ */ #ifndef stepper_h -#define stepper_h +#define stepper_h #include "planner.h" @@ -37,7 +37,7 @@ #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} - #endif + #endif #else #define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) @@ -70,7 +70,7 @@ float st_get_position_mm(uint8_t axis); // to notify the subsystem that it is time to go to work. void st_wake_up(); - + void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops(); @@ -95,7 +95,7 @@ void microstep_readings(); #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention #endif - + #endif diff --git a/MeCreator2/Firmware_Marlin/temperature.cpp b/MeCreator2/Firmware_Marlin/temperature.cpp index 0b5599fa..b42cd52a 100644 --- a/MeCreator2/Firmware_Marlin/temperature.cpp +++ b/MeCreator2/Firmware_Marlin/temperature.cpp @@ -1,19 +1,19 @@ /* temperature.c - temperature control Part of Marlin - + Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -22,8 +22,8 @@ This firmware is a mashup between Sprinter and grbl. (https://github.com/kliment/Sprinter) (https://github.com/simen/grbl/tree) - - It has preliminary support for Matthew Roberts advance algorithm + + It has preliminary support for Matthew Roberts advance algorithm http://reprap.org/pipermail/reprap-dev/2011-May/003323.html */ @@ -64,20 +64,20 @@ float current_temperature_bed = 0.0; float bedKi=(DEFAULT_bedKi*PID_dT); float bedKd=(DEFAULT_bedKd/PID_dT); #endif //PIDTEMPBED - + #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; #endif unsigned char soft_pwm_bed; - + #ifdef BABYSTEPPING volatile int babystepsTodo[3]={0,0,0}; #endif #ifdef FILAMENT_SENSOR int current_raw_filwidth = 0; //Holds measured filament diameter - one extruder only -#endif +#endif //=========================================================================== //=============================private variables============================ //=========================================================================== @@ -121,7 +121,7 @@ static volatile bool temp_meas_ready = false; (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) static unsigned long extruder_autofan_last_check; -#endif +#endif #if EXTRUDERS > 3 # error Unsupported number of extruders @@ -202,9 +202,9 @@ void PID_autotune(float temp, int extruder, int ncycles) SERIAL_ECHOLN("PID Autotune failed. Bad extruder number."); return; } - + SERIAL_ECHOLN("PID Autotune start"); - + disable_heater(); // switch off all heaters. if (extruder<0) @@ -241,7 +241,7 @@ void PID_autotune(float temp, int extruder, int ncycles) #endif if(heating == true && input > temp) { - if(millis() - t2 > 5000) { + if(millis() - t2 > 5000) { heating=false; if (extruder<0) soft_pwm_bed = (bias - d) >> 1; @@ -304,7 +304,7 @@ void PID_autotune(float temp, int extruder, int ncycles) cycles++; min=temp; } - } + } } if(input > (temp + 20)) { SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature too high"); @@ -313,16 +313,16 @@ void PID_autotune(float temp, int extruder, int ncycles) if(millis() - temp_millis > 2000) { int p; if (extruder<0){ - p=soft_pwm_bed; + p=soft_pwm_bed; SERIAL_PROTOCOLPGM("ok B:"); }else{ - p=soft_pwm[extruder]; + p=soft_pwm[extruder]; SERIAL_PROTOCOLPGM("ok T:"); } - - SERIAL_PROTOCOL(input); + + SERIAL_PROTOCOL(input); SERIAL_PROTOCOLPGM(" @:"); - SERIAL_PROTOCOLLN(p); + SERIAL_PROTOCOLLN(p); temp_millis = millis(); } @@ -341,15 +341,15 @@ void PID_autotune(float temp, int extruder, int ncycles) void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { - temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; + for(int e = 0; e < EXTRUDERS; e++) { + temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; #endif } - + int getHeaterPower(int heater) { if (heater<0) return soft_pwm_bed; @@ -361,16 +361,16 @@ int getHeaterPower(int heater) { (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) #if defined(FAN_PIN) && FAN_PIN > -1 - #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #endif - #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN + #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #endif - #endif + #endif void setExtruderAutoFanState(int pin, bool state) { @@ -385,45 +385,45 @@ void checkExtruderAutoFans() { uint8_t fanState = 0; - // which fan pins need to be turned on? + // which fan pins need to be turned on? #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 - if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fanState |= 1; #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; else fanState |= 2; } #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) + if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) { - if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) fanState |= 1; - else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) + else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2; else fanState |= 4; } #endif - + // update extruder auto fan states #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); - #endif + #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); - #endif + #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); - #endif + #endif } #endif // any extruder auto fan pins set @@ -434,11 +434,11 @@ void manage_heater() float pid_output; if(temp_meas_ready != true) //better readability - return; + return; updateTemperaturesFromRawValues(); - for(int e = 0; e < EXTRUDERS; e++) + for(int e = 0; e < EXTRUDERS; e++) { #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 @@ -481,7 +481,7 @@ void manage_heater() } } temp_dState[e] = pid_input; - #else + #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP #ifdef PID_DEBUG @@ -507,7 +507,7 @@ void manage_heater() #endif // Check if temperature is within the correct range - if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) + if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) { soft_pwm[e] = (int)pid_output >> 1; } @@ -551,9 +551,9 @@ void manage_heater() { checkExtruderAutoFans(); extruder_autofan_last_check = millis(); - } - #endif - + } + #endif + #ifndef PIDTEMPBED if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; @@ -561,7 +561,7 @@ void manage_heater() #endif #if TEMP_SENSOR_BED != 0 - + #ifdef THERMAL_RUNAWAY_PROTECTION_BED_PERIOD && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); #endif @@ -590,11 +590,11 @@ void manage_heater() pid_output=0; } - #else + #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER); #endif //PID_OPENLOOP - if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { soft_pwm_bed = (int)pid_output >> 1; } @@ -610,7 +610,7 @@ void manage_heater() { soft_pwm_bed = 0; } - else + else { soft_pwm_bed = MAX_BED_POWER>>1; } @@ -640,23 +640,23 @@ void manage_heater() } #endif #endif - -//code for controlling the extruder rate based on the width sensor + +//code for controlling the extruder rate based on the width sensor #ifdef FILAMENT_SENSOR - if(filament_sensor) + if(filament_sensor) { meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed - + //get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area - + if(meas_shift_index<0) meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY; - + volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; @@ -679,7 +679,7 @@ static float analog2temp(int raw, uint8_t e) { SERIAL_ERRORLNPGM(" - Invalid extruder number !"); kill(); return 0.0; - } + } #ifdef HEATER_0_USES_MAX6675 if (e == 0) { @@ -697,8 +697,8 @@ static float analog2temp(int raw, uint8_t e) { { if (PGM_RD_W((*tt)[i][0]) > raw) { - celsius = PGM_RD_W((*tt)[i-1][1]) + - (raw - PGM_RD_W((*tt)[i-1][0])) * + celsius = PGM_RD_W((*tt)[i-1][1]) + + (raw - PGM_RD_W((*tt)[i-1][0])) * (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); break; @@ -724,8 +724,8 @@ static float analog2tempBed(int raw) { { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { - celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + - (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + + (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); break; @@ -755,9 +755,9 @@ static void updateTemperaturesFromRawValues() #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif - #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported + #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported filament_width_meas = analog2widthFil(); - #endif + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -767,18 +767,18 @@ static void updateTemperaturesFromRawValues() } -// For converting raw Filament Width to milimeters +// For converting raw Filament Width to milimeters #ifdef FILAMENT_SENSOR -float analog2widthFil() { -return current_raw_filwidth/16383.0*5.0; -//return current_raw_filwidth; -} - -// For converting raw Filament Width to a ratio -int widthFil_to_size_ratio() { - -float temp; - +float analog2widthFil() { +return current_raw_filwidth/16383.0*5.0; +//return current_raw_filwidth; +} + +// For converting raw Filament Width to a ratio +int widthFil_to_size_ratio() { + +float temp; + temp=filament_width_meas; if(filament_width_measMEASURED_UPPER_LIMIT) temp= MEASURED_UPPER_LIMIT; -return(filament_width_nominal/temp*100); +return(filament_width_nominal/temp*100); -} +} #endif @@ -800,13 +800,13 @@ void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector - MCUCR=(1< -1) + #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) SET_OUTPUT(HEATER_0_PIN); - #endif - #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) + #endif + #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) SET_OUTPUT(HEATER_1_PIN); - #endif - #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) + #endif + #if defined(HEATER_2_PIN) && (HEATER_2_PIN > -1) SET_OUTPUT(HEATER_2_PIN); - #endif - #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) + #endif + #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) SET_OUTPUT(HEATER_BED_PIN); - #endif - #if defined(FAN_PIN) && (FAN_PIN > -1) + #endif + #if defined(FAN_PIN) && (FAN_PIN > -1) SET_OUTPUT(FAN_PIN); #ifdef FAST_PWM_FAN setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 @@ -838,24 +838,24 @@ void tp_init() #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; #endif - #endif + #endif #ifdef HEATER_0_USES_MAX6675 #ifndef SDSUPPORT SET_OUTPUT(SCK_PIN); WRITE(SCK_PIN,0); - + SET_OUTPUT(MOSI_PIN); WRITE(MOSI_PIN,1); - + SET_INPUT(MISO_PIN); WRITE(MISO_PIN,1); #endif /* Using pinMode and digitalWrite, as that was the only way I could get it to compile */ - + //Have to toggle SD card CS pin to low first, to enable firmware to talk with SD card pinMode(SS_PIN, OUTPUT); - digitalWrite(SS_PIN,0); + digitalWrite(SS_PIN,0); pinMode(MAX6675_SS, OUTPUT); digitalWrite(MAX6675_SS,1); #endif @@ -868,49 +868,49 @@ void tp_init() #endif #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if TEMP_0_PIN < 8 - DIDR0 |= 1 << TEMP_0_PIN; + DIDR0 |= 1 << TEMP_0_PIN; #else - DIDR2 |= 1<<(TEMP_0_PIN - 8); + DIDR2 |= 1<<(TEMP_0_PIN - 8); #endif #endif #if defined(TEMP_1_PIN) && (TEMP_1_PIN > -1) #if TEMP_1_PIN < 8 - DIDR0 |= 1< -1) #if TEMP_2_PIN < 8 - DIDR0 |= 1 << TEMP_2_PIN; + DIDR0 |= 1 << TEMP_2_PIN; #else - DIDR2 |= 1<<(TEMP_2_PIN - 8); + DIDR2 |= 1<<(TEMP_2_PIN - 8); #endif #endif #if defined(TEMP_BED_PIN) && (TEMP_BED_PIN > -1) #if TEMP_BED_PIN < 8 - DIDR0 |= 1< -1) - #if FILWIDTH_PIN < 8 - DIDR0 |= 1< -1) + #if FILWIDTH_PIN < 8 + DIDR0 |= 1< 0) || (defined (THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0) @@ -1028,7 +1028,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat SERIAL_ECHO(temperature); SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(target_temperature); - SERIAL_ECHOLN(""); + SERIAL_ECHOLN(""); */ if ((target_temperature == 0) || thermal_runaway) { @@ -1048,7 +1048,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat if (temperature >= (target_temperature - hysteresis_degc)) { *timer = millis(); - } + } else if ( (millis() - *timer) > ((unsigned long) period_seconds) * 1000) { SERIAL_ERROR_START; @@ -1082,34 +1082,34 @@ void disable_heater() #if defined(TEMP_0_PIN) && TEMP_0_PIN > -1 target_temperature[0]=0; soft_pwm[0]=0; - #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 + #if defined(HEATER_0_PIN) && HEATER_0_PIN > -1 WRITE(HEATER_0_PIN,LOW); #endif #endif - + #if defined(TEMP_1_PIN) && TEMP_1_PIN > -1 && EXTRUDERS > 1 target_temperature[1]=0; soft_pwm[1]=0; - #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 + #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 WRITE(HEATER_1_PIN,LOW); #endif #endif - + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 && EXTRUDERS > 2 target_temperature[2]=0; soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 WRITE(HEATER_2_PIN,LOW); #endif - #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; soft_pwm_bed=0; - #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif - #endif + #endif } void max_temp_error(uint8_t e) { @@ -1159,47 +1159,47 @@ int max6675_temp = 2000; int read_max6675() { - if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) + if (millis() - max6675_previous_millis < MAX6675_HEAT_INTERVAL) return max6675_temp; - + max6675_previous_millis = millis(); max6675_temp = 0; - + #ifdef PRR PRR &= ~(1<> 3; } @@ -1225,46 +1225,46 @@ ISR(TIMER0_COMPB_vect) static unsigned char slow_pwm_count = 0; static unsigned char state_heater_0 = 0; static unsigned char state_timer_heater_0 = 0; -#endif +#endif #if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) static unsigned char soft_pwm_1; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_1 = 0; static unsigned char state_timer_heater_1 = 0; -#endif +#endif #endif #if EXTRUDERS > 2 static unsigned char soft_pwm_2; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_2 = 0; static unsigned char state_timer_heater_2 = 0; -#endif +#endif #endif #if HEATER_BED_PIN > -1 static unsigned char soft_pwm_b; #ifdef SLOW_PWM_HEATERS static unsigned char state_heater_b = 0; static unsigned char state_timer_heater_b = 0; -#endif #endif - +#endif + #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) static unsigned long raw_filwidth_value = 0; //added for filament width sensor #endif - + #ifndef SLOW_PWM_HEATERS /* * standard PWM modulation */ if(pwm_count == 0){ soft_pwm_0 = soft_pwm[0]; - if(soft_pwm_0 > 0) { + if(soft_pwm_0 > 0) { WRITE(HEATER_0_PIN,1); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,1); #endif } else WRITE(HEATER_0_PIN,0); - + #if EXTRUDERS > 1 soft_pwm_1 = soft_pwm[1]; if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); @@ -1282,7 +1282,7 @@ ISR(TIMER0_COMPB_vect) if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); #endif } - if(soft_pwm_0 < pwm_count) { + if(soft_pwm_0 < pwm_count) { WRITE(HEATER_0_PIN,0); #ifdef HEATERS_PARALLEL WRITE(HEATER_1_PIN,0); @@ -1300,10 +1300,10 @@ ISR(TIMER0_COMPB_vect) #ifdef FAN_SOFT_PWM if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + #else //ifndef SLOW_PWM_HEATERS /* * SLOW PWM HEATERS @@ -1314,12 +1314,12 @@ ISR(TIMER0_COMPB_vect) #define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds #endif if (slow_pwm_count == 0) { - // EXTRUDER 0 + // EXTRUDER 0 soft_pwm_0 = soft_pwm[0]; if (soft_pwm_0 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 0) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1330,9 +1330,9 @@ ISR(TIMER0_COMPB_vect) #endif } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_0 == 0) { - // if change state set timer + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1343,14 +1343,14 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 // EXTRUDER 1 soft_pwm_1 = soft_pwm[1]; if (soft_pwm_1 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 0) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1358,9 +1358,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_1_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_1 == 0) { - // if change state set timer + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1369,14 +1369,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 soft_pwm_2 = soft_pwm[2]; if (soft_pwm_2 > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 0) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1384,9 +1384,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_2_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_2 == 0) { - // if change state set timer + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1395,14 +1395,14 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED soft_pwm_b = soft_pwm_bed; if (soft_pwm_b > 0) { - // turn ON heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn ON heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 0) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1410,9 +1410,9 @@ ISR(TIMER0_COMPB_vect) WRITE(HEATER_BED_PIN, 1); } } else { - // turn OFF heather only if the minimum time is up + // turn OFF heather only if the minimum time is up if (state_timer_heater_b == 0) { - // if change state set timer + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1422,12 +1422,12 @@ ISR(TIMER0_COMPB_vect) } #endif } // if (slow_pwm_count == 0) - - // EXTRUDER 0 + + // EXTRUDER 0 if (soft_pwm_0 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_0 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_0 == 0) { + // if change state set timer if (state_heater_0 == 1) { state_timer_heater_0 = MIN_STATE_TIME; } @@ -1438,13 +1438,13 @@ ISR(TIMER0_COMPB_vect) #endif } } - + #if EXTRUDERS > 1 - // EXTRUDER 1 + // EXTRUDER 1 if (soft_pwm_1 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_1 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_1 == 0) { + // if change state set timer if (state_heater_1 == 1) { state_timer_heater_1 = MIN_STATE_TIME; } @@ -1453,13 +1453,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if EXTRUDERS > 2 // EXTRUDER 2 if (soft_pwm_2 < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_2 == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_2 == 0) { + // if change state set timer if (state_heater_2 == 1) { state_timer_heater_2 = MIN_STATE_TIME; } @@ -1468,13 +1468,13 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 // BED if (soft_pwm_b < slow_pwm_count) { - // turn OFF heather only if the minimum time is up - if (state_timer_heater_b == 0) { - // if change state set timer + // turn OFF heather only if the minimum time is up + if (state_timer_heater_b == 0) { + // if change state set timer if (state_heater_b == 1) { state_timer_heater_b = MIN_STATE_TIME; } @@ -1483,7 +1483,7 @@ ISR(TIMER0_COMPB_vect) } } #endif - + #ifdef FAN_SOFT_PWM if (pwm_count == 0){ soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1491,41 +1491,41 @@ ISR(TIMER0_COMPB_vect) } if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); #endif - + pwm_count += (1 << SOFT_PWM_SCALE); pwm_count &= 0x7f; - + // increment slow_pwm_count only every 64 pwm_count circa 65.5ms if ((pwm_count % 64) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7f; - + // Extruder 0 if (state_timer_heater_0 > 0) { state_timer_heater_0--; - } - + } + #if EXTRUDERS > 1 // Extruder 1 - if (state_timer_heater_1 > 0) + if (state_timer_heater_1 > 0) state_timer_heater_1--; #endif - + #if EXTRUDERS > 2 // Extruder 2 - if (state_timer_heater_2 > 0) + if (state_timer_heater_2 > 0) state_timer_heater_2--; #endif - + #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 - // Bed - if (state_timer_heater_b > 0) + // Bed + if (state_timer_heater_b > 0) state_timer_heater_b--; #endif } //if ((pwm_count % 64) == 0) { - + #endif //ifndef SLOW_PWM_HEATERS - + switch(temp_state) { case 0: // Prepare TEMP_0 #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) @@ -1605,37 +1605,37 @@ ISR(TIMER0_COMPB_vect) raw_temp_2_value += ADC; #endif temp_state = 8;//change so that Filament Width is also measured - + break; - case 8: //Prepare FILWIDTH - #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) - #if FILWIDTH_PIN>7 + case 8: //Prepare FILWIDTH + #if defined(FILWIDTH_PIN) && (FILWIDTH_PIN> -1) + #if FILWIDTH_PIN>7 ADCSRB = 1< -1) - //raw_filwidth_value += ADC; //remove to use an IIR filter approach + ADCSRB = 0; + #endif + ADMUX = ((1 << REFS0) | (FILWIDTH_PIN & 0x07)); + ADCSRA |= 1< -1) + //raw_filwidth_value += ADC; //remove to use an IIR filter approach if(ADC>102) //check that ADC is reading a voltage > 0.5 volts, otherwise don't take in the data. { raw_filwidth_value= raw_filwidth_value-(raw_filwidth_value>>7); //multipliy raw_filwidth_value by 127/128 - - raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading + + raw_filwidth_value= raw_filwidth_value + ((unsigned long)ADC<<7); //add new ADC reading } - #endif - temp_state = 0; - + #endif + temp_state = 0; + temp_count++; - break; - - + break; + + case 10: //Startup, delay initial temp reading a tiny bit so the hardware can settle. temp_state = 0; break; @@ -1644,7 +1644,7 @@ ISR(TIMER0_COMPB_vect) // SERIAL_ERRORLNPGM("Temp measurement error!"); // break; } - + if(temp_count >= OVERSAMPLENR) // 10 * 16 * 1/(16000000/64/256) = 164ms. { if (!temp_meas_ready) //Only update the raw values if they have been read. Else we could be updating them during reading. @@ -1662,12 +1662,12 @@ ISR(TIMER0_COMPB_vect) current_temperature_bed_raw = raw_temp_bed_value; } -//Add similar code for Filament Sensor - can be read any time since IIR filtering is used +//Add similar code for Filament Sensor - can be read any time since IIR filtering is used #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) - current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach + current_raw_filwidth = raw_filwidth_value>>10; //need to divide to get to 0-16384 range since we used 1/128 IIR filter approach #endif - - + + temp_meas_ready = true; temp_count = 0; raw_temp_0_value = 0; @@ -1721,7 +1721,7 @@ ISR(TIMER0_COMPB_vect) min_temp_error(2); } #endif - + /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP @@ -1734,12 +1734,12 @@ ISR(TIMER0_COMPB_vect) } #endif } - + #ifdef BABYSTEPPING for(uint8_t axis=0;axis<3;axis++) { int curTodo=babystepsTodo[axis]; //get rid of volatile for performance - + if(curTodo>0) { babystep(axis,/*fwd*/true); diff --git a/MeCreator2/Firmware_Marlin/temperature.h b/MeCreator2/Firmware_Marlin/temperature.h index e63910a3..b74ca41b 100644 --- a/MeCreator2/Firmware_Marlin/temperature.h +++ b/MeCreator2/Firmware_Marlin/temperature.h @@ -19,7 +19,7 @@ */ #ifndef temperature_h -#define temperature_h +#define temperature_h #include "Marlin.h" #include "planner.h" @@ -32,16 +32,16 @@ void tp_init(); //initialize the heating void manage_heater(); //it is critical that this is called periodically. #ifdef FILAMENT_SENSOR -// For converting raw Filament Width to milimeters - float analog2widthFil(); - -// For converting raw Filament Width to an extrusion ratio +// For converting raw Filament Width to milimeters + float analog2widthFil(); + +// For converting raw Filament Width to an extrusion ratio int widthFil_to_size_ratio(); #endif // low level conversion routines // do not use these routines and variables outside of temperature.cpp -extern int target_temperature[EXTRUDERS]; +extern int target_temperature[EXTRUDERS]; extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[EXTRUDERS]; @@ -68,26 +68,26 @@ extern float current_temperature_bed; #ifdef PIDTEMPBED extern float bedKp,bedKi,bedKd; #endif - - + + #ifdef BABYSTEPPING extern volatile int babystepsTodo[3]; #endif - + //high level conversion routines, for use outside of temperature.cpp //inline so that there is no performance decrease. //deg=degreeCelsius -FORCE_INLINE float degHotend(uint8_t extruder) { +FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; #ifdef SHOW_TEMP_ADC_VALUES - FORCE_INLINE float rawHotendTemp(uint8_t extruder) { + FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }; - FORCE_INLINE float rawBedTemp() { + FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }; #endif @@ -96,23 +96,23 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; -FORCE_INLINE float degTargetHotend(uint8_t extruder) { +FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; -FORCE_INLINE float degTargetBed() { +FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; -FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { +FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; }; -FORCE_INLINE void setTargetBed(const float &celsius) { +FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }; -FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ +FORCE_INLINE bool isHeatingHotend(uint8_t extruder){ return target_temperature[extruder] > current_temperature[extruder]; }; @@ -120,7 +120,7 @@ FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; -FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { +FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; diff --git a/MeCreator2/Firmware_Marlin/thermistortables.h b/MeCreator2/Firmware_Marlin/thermistortables.h index ac1dea73..b2acbb9f 100644 --- a/MeCreator2/Firmware_Marlin/thermistortables.h +++ b/MeCreator2/Firmware_Marlin/thermistortables.h @@ -564,7 +564,7 @@ const short temptable_10[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) +#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORBED == 11) // QU-BD silicone bed QWG-104F-3950 thermistor const short temptable_11[][2] PROGMEM = { @@ -824,7 +824,7 @@ const short temptable_51[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) +#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORBED == 52) // 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -865,7 +865,7 @@ const short temptable_52[][2] PROGMEM = { }; #endif -#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) +#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORBED == 55) // 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance @@ -907,7 +907,7 @@ const short temptable_55[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 60) || (THERMISTORHEATER_1 == 60) || (THERMISTORHEATER_2 == 60) || (THERMISTORBED == 60) // Maker's Tool Works Kapton Bed Thermister -// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 +// ./createTemperatureLookup.py --r0=100000 --t0=25 --r1=0 --r2=4700 --beta=3950 // r0: 100000 // t0: 25 // r1: 0 (parallel with rTherm) @@ -990,7 +990,7 @@ const short temptable_60[][2] PROGMEM = { {1008*OVERSAMPLENR, 0}, }; #endif -#if (THERMISTORBED == 12) +#if (THERMISTORBED == 12) //100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) const short temptable_12[][2] PROGMEM = { {35*OVERSAMPLENR, 180}, //top rating 180C @@ -1027,7 +1027,7 @@ const short temptable_12[][2] PROGMEM = { #endif // Pt1000 and Pt100 handling -// +// // Rt=R0*(1+a*T+b*T*T) [for T>0] // a=3.9083E-3, b=-5.775E-7 @@ -1039,7 +1039,7 @@ const short temptable_12[][2] PROGMEM = { #if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup const short temptable_110[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,1000) PtLine(50,100,1000) PtLine(100,100,1000) @@ -1051,7 +1051,7 @@ const short temptable_110[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup const short temptable_147[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,100,4700) PtLine(50,100,4700) PtLine(100,100,4700) @@ -1080,7 +1080,7 @@ const short temptable_1010[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup const short temptable_1047[][2] PROGMEM = { -// only few values are needed as the curve is very flat +// only few values are needed as the curve is very flat PtLine(0,1000,4700) PtLine(50,1000,4700) PtLine(100,1000,4700) diff --git a/MeCreator2/Firmware_Marlin/ultralcd.cpp b/MeCreator2/Firmware_Marlin/ultralcd.cpp index 39a9c986..ec970f5a 100644 --- a/MeCreator2/Firmware_Marlin/ultralcd.cpp +++ b/MeCreator2/Firmware_Marlin/ultralcd.cpp @@ -351,14 +351,14 @@ static void lcd_about_menu() else { lcd.print("HW Ver:"); - lcd.setCursor(8,1); + lcd.setCursor(8,1); lcd.print(uuid_hw); } - - ////////////// + + ////////////// lcd.setCursor(1,2); lcd.print("SW Ver:" VERSION_STRING); - + //LCD_MESSAGEPGM("3243233");//uuid_sn lcd.setCursor(1, 3); // lcd_printPGM(PSTR("SD")); @@ -366,12 +366,12 @@ static void lcd_about_menu() lcd.print("No SN"); else { - + lcd.print("SN:"); lcd.setCursor(4,4); lcd.print(uuid_sn); } - + END_MENU(); } @@ -416,13 +416,13 @@ static void lcd_main_menu() } #endif #ifdef LIGHT_SUPPORT - if(light_level>0) - { + if(light_level>0) + { light_level = 0; MENU_ITEM(function, MSG_LIGHT_OFF, light_ctrl); light_level = LIGHT_LEVEL; } - else + else { light_level = LIGHT_LEVEL; MENU_ITEM(function, MSG_LIGHT_ON, light_ctrl); @@ -1597,7 +1597,7 @@ char *ftostr43(const float &x) char *ftostr12ns(const float &x) { long xx=x*100; - + xx=abs(xx); conv[0]=(xx/100)%10+'0'; conv[1]='.'; diff --git a/MeCreator2/Firmware_Marlin/ultralcd.h b/MeCreator2/Firmware_Marlin/ultralcd.h index a175f4a7..e377c4bb 100644 --- a/MeCreator2/Firmware_Marlin/ultralcd.h +++ b/MeCreator2/Firmware_Marlin/ultralcd.h @@ -43,13 +43,13 @@ extern int absPreheatHotendTemp; extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - + extern bool cancel_heatup; - + #ifdef FILAMENT_LCD_DISPLAY extern unsigned long message_millis; #endif - + void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -90,7 +90,7 @@ #define B_ST (1< -1 // encoder click is directly connected - #define BLEN_C 2 - #define EN_C (1< -1 + #if defined(BTN_ENC) && BTN_ENC > -1 // the pause/stop/restart button is connected to BTN_ENC when used - #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #else #define LCD_CLICKED (buttons&(B_MI|B_RI)) - #endif + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) // encoder click can be read through I2C if not directly connected - #if BTN_ENC <= 0 + #if BTN_ENC <= 0 #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - + #define B_MI (PANELOLU2_ENCODER_C< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); - + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 @@ -171,7 +171,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #else LCD_CLASS lcd(LCD_I2C_ADDRESS); #endif - + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include @@ -186,9 +186,9 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #include #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); - + // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } @@ -202,10 +202,10 @@ extern volatile uint16_t buttons; //an extended version of the last checked but #ifdef LANGUAGE_RU #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus - #else + #else #include #define LCD_CLASS LiquidCrystal - #endif + #endif LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -386,12 +386,12 @@ static void lcd_implementation_init( lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklight(HIGH); #endif - + #elif defined(LCD_I2C_TYPE_MCP23017) lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with - + #elif defined(LCD_I2C_TYPE_MCP23008) lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); @@ -399,7 +399,7 @@ static void lcd_implementation_init( #elif defined(LCD_I2C_TYPE_PCA8574) lcd.init(); lcd.backlight(); - + #else lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif @@ -864,13 +864,13 @@ static void lcd_implementation_quick_feedback() static void lcd_implementation_update_indicators() { #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) - //set the LEDS - referred to as backlights by the LiquidTWI2 library + //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; - #if EXTRUDERS > 1 + #if EXTRUDERS > 1 if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { @@ -890,7 +890,7 @@ static uint8_t lcd_implementation_read_slow_buttons() uint8_t slow_buttons; // Reading these buttons this is likely to be too slow to call inside interrupt context // so they are called during normal lcd_update - slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; + slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; #if defined(LCD_I2C_VIKI) if(slow_buttons & (B_MI|B_RI)) { //LCD clicked if(blocking_enc > millis()) { @@ -898,7 +898,7 @@ static uint8_t lcd_implementation_read_slow_buttons() } } #endif - return slow_buttons; + return slow_buttons; #endif } #endif diff --git a/MeCreator2/Firmware_Marlin/ultralcd_st7920_u8glib_rrd.h b/MeCreator2/Firmware_Marlin/ultralcd_st7920_u8glib_rrd.h index 386e312e..d0dae7bd 100644 --- a/MeCreator2/Firmware_Marlin/ultralcd_st7920_u8glib_rrd.h +++ b/MeCreator2/Firmware_Marlin/ultralcd_st7920_u8glib_rrd.h @@ -27,7 +27,7 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) for( i=0; i<8; i++ ) { WRITE(ST7920_CLK_PIN,0); - WRITE(ST7920_DAT_PIN,val&0x80); + WRITE(ST7920_DAT_PIN,val&0x80); val<<=1; WRITE(ST7920_CLK_PIN,1); } diff --git a/MeCreator2/Firmware_Marlin/vector_3.cpp b/MeCreator2/Firmware_Marlin/vector_3.cpp index 5f1c294e..719ca51a 100644 --- a/MeCreator2/Firmware_Marlin/vector_3.cpp +++ b/MeCreator2/Firmware_Marlin/vector_3.cpp @@ -33,29 +33,29 @@ vector_3 vector_3::cross(vector_3 left, vector_3 right) left.x * right.y - left.y * right.x); } -vector_3 vector_3::operator+(vector_3 v) +vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } -vector_3 vector_3::operator-(vector_3 v) +vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } -vector_3 vector_3::get_normal() +vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } -float vector_3::get_length() +float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } - + void vector_3::normalize() { float length = get_length(); @@ -102,11 +102,11 @@ matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; - new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; - new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; - new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; + new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; + new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; + new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); - + return new_matrix; } @@ -127,7 +127,7 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) // y_row.debug("y_row"); // z_row.debug("z_row"); - + // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); @@ -139,8 +139,8 @@ matrix_3x3 matrix_3x3::create_look_at(vector_3 target) matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; - new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; - new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; + new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; + new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } diff --git a/MeCreator2/Firmware_Marlin/vector_3.h b/MeCreator2/Firmware_Marlin/vector_3.h index 0b9decaf..7afbfefd 100644 --- a/MeCreator2/Firmware_Marlin/vector_3.h +++ b/MeCreator2/Firmware_Marlin/vector_3.h @@ -38,7 +38,7 @@ struct vector_3 vector_3 get_normal(); void debug(char* title); - + void apply_rotation(matrix_3x3 matrix); }; diff --git a/MeCreator2/Firmware_Marlin/watchdog.cpp b/MeCreator2/Firmware_Marlin/watchdog.cpp index b378ca70..ba61ae5e 100644 --- a/MeCreator2/Firmware_Marlin/watchdog.cpp +++ b/MeCreator2/Firmware_Marlin/watchdog.cpp @@ -30,7 +30,7 @@ void watchdog_init() } /// reset watchdog. MUST be called every 1s after init or avr will reset. -void watchdog_reset() +void watchdog_reset() { wdt_reset(); } @@ -42,7 +42,7 @@ void watchdog_reset() //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. #ifdef WATCHDOG_RESET_MANUAL ISR(WDT_vect) -{ +{ //TODO: This message gets overwritten by the kill() call LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display lcd_update();