Merge pull request #159 from MaikStohn/Marlin_v1

Marlin v1 - BUG FIXES / CORRECTIONS
2.0.x
ErikZalm 13 years ago
commit b2a9ccdb97

@ -300,6 +300,8 @@ void setup()
st_init(); // Initialize stepper; st_init(); // Initialize stepper;
wd_init(); wd_init();
setup_photpin(); setup_photpin();
LCD_INIT;
} }
@ -687,7 +689,6 @@ void process_commands()
st_synchronize(); st_synchronize();
for(int8_t i=0; i < NUM_AXIS; i++) { for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) { if(code_seen(axis_codes[i])) {
current_position[i] = code_value()+add_homeing[i];
if(i == E_AXIS) { if(i == E_AXIS) {
current_position[i] = code_value(); current_position[i] = code_value();
plan_set_e_position(current_position[E_AXIS]); plan_set_e_position(current_position[E_AXIS]);
@ -1246,7 +1247,7 @@ void process_commands()
} }
break; break;
case 302: // finish all moves case 302: // allow cold extrudes
{ {
allow_cold_extrudes(true); allow_cold_extrudes(true);
} }

@ -7,6 +7,7 @@
void lcd_init(); void lcd_init();
void lcd_status(const char* message); void lcd_status(const char* message);
void beep(); void beep();
void buttons_init();
void buttons_check(); void buttons_check();
#define LCD_UPDATE_INTERVAL 100 #define LCD_UPDATE_INTERVAL 100
@ -69,7 +70,7 @@
void showAxisMove(); void showAxisMove();
void showSD(); void showSD();
bool force_lcd_update; bool force_lcd_update;
int lastencoderpos; long lastencoderpos;
int8_t lineoffset; int8_t lineoffset;
int8_t lastlineoffset; int8_t lastlineoffset;
@ -78,11 +79,11 @@
bool tune; bool tune;
private: private:
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos) FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
{ {
if(linechanging) return; // an item is changint its value, do not switch lines hence if(linechanging) return; // an item is changint its value, do not switch lines hence
lastlineoffset=lineoffset; lastlineoffset=lineoffset;
int curencoderpos=encoderpos; long curencoderpos=encoderpos;
force_lcd_update=false; force_lcd_update=false;
if( (abs(curencoderpos-lastencoderpos)<lcdslow) ) if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
{ {
@ -134,11 +135,12 @@
char *ftostr3(const float &x); char *ftostr3(const float &x);
#define LCD_INIT lcd_init();
#define LCD_MESSAGE(x) lcd_status(x); #define LCD_MESSAGE(x) lcd_status(x);
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x)); #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
#define LCD_STATUS lcd_status() #define LCD_STATUS lcd_status()
#else //no lcd #else //no lcd
#define LCD_INIT
#define LCD_STATUS #define LCD_STATUS
#define LCD_MESSAGE(x) #define LCD_MESSAGE(x)
#define LCD_MESSAGEPGM(x) #define LCD_MESSAGEPGM(x)

@ -1,6 +1,9 @@
#include "ultralcd.h" #include "ultralcd.h"
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
#include "Marlin.h" #include "Marlin.h"
#include "language.h"
#include "temperature.h"
#include "EEPROMwrite.h"
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
//=========================================================================== //===========================================================================
//=============================imported variables============================ //=============================imported variables============================
@ -13,6 +16,7 @@ extern volatile int extrudemultiply;
extern long position[4]; extern long position[4];
#ifdef SDSUPPORT #ifdef SDSUPPORT
#include "cardreader.h"
extern CardReader card; extern CardReader card;
#endif #endif
@ -20,7 +24,7 @@ extern CardReader card;
//=============================public variables============================ //=============================public variables============================
//=========================================================================== //===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array. volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0; long encoderpos=0;
short lastenc=0; short lastenc=0;
@ -95,6 +99,9 @@ FORCE_INLINE void clear()
void lcd_init() void lcd_init()
{ {
//beep(); //beep();
#ifdef ULTIPANEL
buttons_init();
#endif
byte Degree[8] = byte Degree[8] =
{ {
@ -302,10 +309,6 @@ MainMenu::MainMenu()
displayStartingRow=0; displayStartingRow=0;
activeline=0; activeline=0;
force_lcd_update=true; force_lcd_update=true;
#ifdef ULTIPANEL
buttons_init();
#endif
lcd_init();
linechanging=false; linechanging=false;
tune=false; tune=false;
} }
@ -881,7 +884,7 @@ void MainMenu::showTune()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW); lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3])); lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
} }
if((activeline!=line) ) if((activeline!=line) )
@ -892,14 +895,14 @@ void MainMenu::showTune()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)axis_steps_per_unit[3]; encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
} }
else else
{ {
float factor=float(encoderpos)/float(axis_steps_per_unit[3]); float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
position[E_AXIS]=lround(position[E_AXIS]*factor); position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor; //current_position[E_AXIS]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos; axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
} }
@ -909,8 +912,8 @@ void MainMenu::showTune()
if(linechanging) if(linechanging)
{ {
if(encoderpos<5) encoderpos=5; if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999; if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos)); lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
} }
}break; }break;
@ -1293,7 +1296,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)Kp; encoderpos=(long)Kp;
} }
else else
{ {
@ -1328,7 +1331,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(Ki*10/PID_dT); encoderpos=(long)(Ki*10/PID_dT);
} }
else else
{ {
@ -1364,7 +1367,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(Kd/5./PID_dT); encoderpos=(long)(Kd/5./PID_dT);
} }
else else
{ {
@ -1400,7 +1403,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)Kc; encoderpos=(long)Kc;
} }
else else
{ {
@ -1473,7 +1476,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)acceleration/100; encoderpos=(long)acceleration/100;
} }
else else
{ {
@ -1507,7 +1510,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)max_xy_jerk; encoderpos=(long)max_xy_jerk;
} }
else else
{ {
@ -1550,7 +1553,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)max_feedrate[i-ItemCM_vmaxx]; encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
} }
else else
{ {
@ -1586,7 +1589,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(minimumfeedrate); encoderpos=(long)(minimumfeedrate);
} }
else else
{ {
@ -1621,7 +1624,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)mintravelfeedrate; encoderpos=(long)mintravelfeedrate;
} }
else else
{ {
@ -1664,7 +1667,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100; encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
} }
else else
{ {
@ -1698,7 +1701,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)retract_acceleration/100; encoderpos=(long)retract_acceleration/100;
} }
else else
{ {
@ -1722,7 +1725,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS); lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0])); lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
} }
if((activeline!=line) ) if((activeline!=line) )
@ -1733,13 +1736,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(axis_steps_per_unit[0]*100.0); encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
} }
else else
{ {
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]); float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
position[X_AXIS]=lround(position[X_AXIS]*factor); position[X_AXIS]=lround(position[X_AXIS]*factor);
//current_position[3]*=factor; //current_position[X_AXIS]*=factor;
axis_steps_per_unit[X_AXIS]= encoderpos/100.0; axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
} }
@ -1749,7 +1752,7 @@ void MainMenu::showControlMotion()
if(linechanging) if(linechanging)
{ {
if(encoderpos<5) encoderpos=5; if(encoderpos<5) encoderpos=5;
if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800 if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
} }
@ -1759,7 +1762,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS); lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1])); lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
} }
if((activeline!=line) ) if((activeline!=line) )
@ -1770,13 +1773,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(axis_steps_per_unit[1]*100.0); encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
} }
else else
{ {
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]); float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
position[Y_AXIS]=lround(position[Y_AXIS]*factor); position[Y_AXIS]=lround(position[Y_AXIS]*factor);
//current_position[3]*=factor; //current_position[Y_AXIS]*=factor;
axis_steps_per_unit[Y_AXIS]= encoderpos/100.0; axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
@ -1787,7 +1790,7 @@ void MainMenu::showControlMotion()
if(linechanging) if(linechanging)
{ {
if(encoderpos<5) encoderpos=5; if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999; if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
} }
@ -1797,7 +1800,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS); lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2])); lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS]));
} }
if((activeline!=line) ) if((activeline!=line) )
@ -1808,13 +1811,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(axis_steps_per_unit[2]*100.0); encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
} }
else else
{ {
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]); float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
position[Z_AXIS]=lround(position[Z_AXIS]*factor); position[Z_AXIS]=lround(position[Z_AXIS]*factor);
//current_position[3]*=factor; //current_position[Z_AXIS]*=factor;
axis_steps_per_unit[Z_AXIS]= encoderpos/100.0; axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
@ -1825,7 +1828,7 @@ void MainMenu::showControlMotion()
if(linechanging) if(linechanging)
{ {
if(encoderpos<5) encoderpos=5; if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999; if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
} }
@ -1836,7 +1839,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS); lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3])); lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
} }
if((activeline!=line) ) if((activeline!=line) )
@ -1847,13 +1850,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=(int)(axis_steps_per_unit[3]*100.0); encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
} }
else else
{ {
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]); float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
position[E_AXIS]=lround(position[E_AXIS]*factor); position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor; //current_position[E_AXIS]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos/100.0; axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow; encoderpos=activeline*lcdslow;
@ -1864,7 +1867,7 @@ void MainMenu::showControlMotion()
if(linechanging) if(linechanging)
{ {
if(encoderpos<5) encoderpos=5; if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999; if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
} }
@ -2105,9 +2108,10 @@ void MainMenu::showMainMenu()
} }
} }
clearIfNecessary(); clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++) uint8_t line=0;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{ {
switch(line) switch(i)
{ {
case ItemM_watch: case ItemM_watch:
MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ; MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
@ -2161,6 +2165,7 @@ void MainMenu::showMainMenu()
SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE); SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
break; break;
} }
line++;
} }
updateActiveLines(3,encoderpos); updateActiveLines(3,encoderpos);
} }
@ -2378,4 +2383,4 @@ char *ftostr52(const float &x)
#endif //ULTRA_LCD #endif //ULTRA_LCD

Loading…
Cancel
Save