Skip to content

Commit

Permalink
strange lcd problem with newpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
bkubicek committed Oct 15, 2011
1 parent e7cc585 commit b3f5d1e
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 61 deletions.
4 changes: 2 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#define LCD_WIDTH 16
#define LCD_HEIGHT 2

//#define ULTIPANEL
#define ULTIPANEL
#ifdef ULTIPANEL
#define SDSUPPORT
#define ULTRA_LCD
Expand All @@ -51,7 +51,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#endif


//#define SDSUPPORT // Enable SD Card Support in Hardware Console
#define SDSUPPORT // Enable SD Card Support in Hardware Console



Expand Down
66 changes: 33 additions & 33 deletions Marlin/EEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
Serial.print("Version: [");Serial.print(ver);Serial.print("] Stored version: [");Serial.print(stored_ver);Serial.println("]");
//Serial.print("Version: [");Serial.print(ver);Serial.print("] Stored version: [");Serial.print(stored_ver);Serial.println("]");
if ((!def)&&(strncmp(ver,stored_ver,3)==0)) { // version number match
EEPROM_readAnything(i,axis_steps_per_unit);
EEPROM_readAnything(i,max_feedrate);
Expand All @@ -64,7 +64,7 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
Serial.println("Stored settings retreived:");
//Serial.println("Stored settings retreived:");
}
else {
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
Expand All @@ -82,38 +82,38 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
Serial.println("Using Default settings:");
//Serial.println("Using Default settings:");
}
Serial.println("Steps per unit:");
Serial.print(" M92");
Serial.print(" X");Serial.print(axis_steps_per_unit[0]);
Serial.print(" Y");Serial.print(axis_steps_per_unit[1]);
Serial.print(" Z");Serial.print(axis_steps_per_unit[2]);
Serial.print(" E");Serial.println(axis_steps_per_unit[3]);
Serial.println("Maximum feedrates (mm/s):");
Serial.print (" M203");
Serial.print(" X");Serial.print(max_feedrate[0]/60);
Serial.print(" Y");Serial.print(max_feedrate[1]/60);
Serial.print(" Z");Serial.print(max_feedrate[2]/60);
Serial.print(" E");Serial.println(max_feedrate[3]/60);
Serial.println("Maximum Acceleration (mm/s2):");
Serial.print(" M201");
Serial.print(" X");Serial.print(max_acceleration_units_per_sq_second[0]);
Serial.print(" Y");Serial.print(max_acceleration_units_per_sq_second[1]);
Serial.print(" Z");Serial.print(max_acceleration_units_per_sq_second[2]);
Serial.print(" E");Serial.println(max_acceleration_units_per_sq_second[3]);
Serial.println("Acceleration: S=acceleration, T=retract acceleration");
Serial.print(" M204");
Serial.print(" S");Serial.print(acceleration);
Serial.print(" T");Serial.println(retract_acceleration);
Serial.println("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)");
Serial.print(" M205");
Serial.print(" S");Serial.print(minimumfeedrate/60);
Serial.print(" T");Serial.print(mintravelfeedrate/60);
Serial.print(" B");Serial.print(minsegmenttime);
Serial.print(" X");Serial.print(max_xy_jerk/60);
Serial.print(" Z");Serial.println(max_z_jerk/60);

//Serial.println("Steps per unit:");
//Serial.print(" M92");
//Serial.print(" X");Serial.print(axis_steps_per_unit[0]);
//Serial.print(" Y");Serial.print(axis_steps_per_unit[1]);
//Serial.print(" Z");Serial.print(axis_steps_per_unit[2]);
//Serial.print(" E");Serial.println(axis_steps_per_unit[3]);
//Serial.println("Maximum feedrates (mm/s):");
//Serial.print (" M203");
// Serial.print(" X");Serial.print(max_feedrate[0]/60);
// Serial.print(" Y");Serial.print(max_feedrate[1]/60);
// Serial.print(" Z");Serial.print(max_feedrate[2]/60);
// Serial.print(" E");Serial.println(max_feedrate[3]/60);
// Serial.println("Maximum Acceleration (mm/s2):");
// Serial.print(" M201");
// Serial.print(" X");Serial.print(max_acceleration_units_per_sq_second[0]);
// Serial.print(" Y");Serial.print(max_acceleration_units_per_sq_second[1]);
// Serial.print(" Z");Serial.print(max_acceleration_units_per_sq_second[2]);
// Serial.print(" E");Serial.println(max_acceleration_units_per_sq_second[3]);
// Serial.println("Acceleration: S=acceleration, T=retract acceleration");
// Serial.print(" M204");
// Serial.print(" S");Serial.print(acceleration);
// Serial.print(" T");Serial.println(retract_acceleration);
// Serial.println("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)");
// Serial.print(" M205");
// Serial.print(" S");Serial.print(minimumfeedrate/60);
// Serial.print(" T");Serial.print(mintravelfeedrate/60);
// Serial.print(" B");Serial.print(minsegmenttime);
// Serial.print(" X");Serial.print(max_xy_jerk/60);
// Serial.print(" Z");Serial.println(max_z_jerk/60);
//
}


7 changes: 1 addition & 6 deletions Marlin/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,7 @@
#define EXTRUDER_1_HEATER_PIN 3
#define EXTRUDER_1_TEMPERATURE_PIN 10

#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 5
#define LCD_PINS_D4 6
#define LCD_PINS_D5 21
#define LCD_PINS_D6 20
#define LCD_PINS_D7 19


#define E_STEP_PIN EXTRUDER_0_STEP_PIN
#define E_DIR_PIN EXTRUDER_0_DIR_PIN
Expand Down
59 changes: 49 additions & 10 deletions Marlin/ultralcd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef __ULTRALCDH
#define __ULTRALCDH
//#define NEWPANEL


#ifdef ULTRA_LCD
Expand All @@ -20,7 +21,40 @@

//lcd display size

#ifdef NEWPANEL
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18

#define LCD_PINS_RS 20
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 16
#define LCD_PINS_D5 21
#define LCD_PINS_D6 5
#define LCD_PINS_D7 6

//buttons are directly attached
#define BTN_EN1 40
#define BTN_EN2 42
#define BTN_ENC 19 //the click

#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0

#define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)

//encoder rotation values
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1
#define CLICKED (buttons&EN_C)
#define BLOCK {blocking=millis()+blocktime;}


#else
//arduino pin witch triggers an piezzo beeper
#define BEEPER 18

Expand All @@ -29,14 +63,15 @@
#define SHIFT_LD 42
#define SHIFT_OUT 40
#define SHIFT_EN 17

// blocking time for recognizing a new keypress of one key, ms
#define blocktime 500
#define lcdslow 5
#ifdef ULTIPANEL


//bits in the shift register that carry the buttons for:

#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 5
#define LCD_PINS_D4 6
#define LCD_PINS_D5 21
#define LCD_PINS_D6 20
#define LCD_PINS_D7 19

//bits in the shift register that carry the buttons for:
// left up center down right red
#define BL_LE 7
#define BL_UP 6
Expand Down Expand Up @@ -64,9 +99,13 @@
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)

#define CLICKED ((buttons&B_MI)||(buttons&B_ST))
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
#define CLICKED ((buttons&B_MI)||(buttons&B_ST))
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}

#endif
// blocking time for recognizing a new keypress of one key, ms
#define blocktime 500
#define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};

class MainMenu{
Expand Down
58 changes: 48 additions & 10 deletions Marlin/ultralcd.pde
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@ unsigned long previous_millis_lcd=0;
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
short lastenc=0;
#ifdef NEWPANEL

long blocking=0;
#else
long blocking[8]={
0,0,0,0,0,0,0,0};
#endif
MainMenu menu;

void lcd_status(const char* message)
{
strncpy(messagetext,message,LCD_WIDTH);
}

void clear()
{
//lcd.setCursor(0,0);
lcd.clear();
delay(1);
}
long previous_millis_buttons=0;

void lcd_init()
Expand Down Expand Up @@ -64,6 +75,7 @@ void lcd_init()

void beep()
{
return;
#ifdef ULTIPANEL
// [ErikDeBruijn] changed to two short beeps, more friendly
pinMode(BEEPER,OUTPUT);
Expand All @@ -77,6 +89,7 @@ void beep()
}
void beepshort()
{
return;
#ifdef ULTIPANEL
// [ErikDeBruijn] changed to two short beeps, more friendly
pinMode(BEEPER,OUTPUT);
Expand All @@ -91,10 +104,11 @@ void beepshort()
void lcd_status()
{
#ifdef ULTIPANEL
static uint8_t oldbuttons=0;
static long previous_millis_buttons=0;
buttons_check();
//previous_millis_buttons=millis();
static uint8_t oldbuttons=0;

if((buttons==oldbuttons) && ((millis() - previous_millis_lcd) < LCD_UPDATE_INTERVAL) )
return;
oldbuttons=buttons;
Expand All @@ -110,18 +124,36 @@ void lcd_status()
#ifdef ULTIPANEL
void buttons_init()
{
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
#ifdef NEWPANEL
pinMode(BTN_EN1,OUTPUT);
pinMode(BTN_EN2,OUTPUT);
pinMode(BTN_ENC,OUTPUT);
digitalWrite(BTN_EN1,HIGH);
digitalWrite(BTN_EN2,HIGH);
digitalWrite(BTN_ENC,HIGH);
#else
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_EN,OUTPUT);
pinMode(SHIFT_OUT,INPUT);
pinMode(SHIFT_OUT,INPUT);
digitalWrite(SHIFT_OUT,HIGH);
digitalWrite(SHIFT_LD,HIGH); //load has inverse logic
digitalWrite(SHIFT_EN,LOW); //low active
digitalWrite(SHIFT_LD,HIGH); //load has inverse logic
digitalWrite(SHIFT_EN,LOW); //low active
#endif
}


void buttons_check()
{
#ifdef NEWPANEL
uint8_t newbutton=0;
if(digitalRead(BTN_EN1)==0) newbutton|=EN_A;
if(digitalRead(BTN_EN2)==0) newbutton|=EN_B;
if((blocking<millis()) &&(digitalRead(BTN_ENC)==0))
newbutton|=EN_C;
buttons=newbutton;
Serial.println((int)newbutton);
#else
//read it from the shift register
volatile static bool busy=false;
if(busy)
Expand All @@ -148,6 +180,7 @@ void buttons_check()
delayMicroseconds(5);
}
buttons=~buttons; //invert it, because a pressed switch produces a logical 0
#endif
char enc=0;
if(buttons&EN_A)
enc|=(1<<0);
Expand Down Expand Up @@ -213,6 +246,7 @@ void MainMenu::showStatus()
#if LCD_HEIGHT==4
static int oldcurrentraw=-1;
static int oldtargetraw=-1;
//force_lcd_update=true;
if(force_lcd_update) //initial display of content
{
encoderpos=feedmultiply;
Expand Down Expand Up @@ -340,7 +374,8 @@ void MainMenu::showPrepare()
if(lastlineoffset!=lineoffset)
{
force_lcd_update=true;
lcd.clear();
clear();
delay(1);
}
for(uint8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
Expand Down Expand Up @@ -474,7 +509,8 @@ void MainMenu::showControl()
if(lastlineoffset!=lineoffset)
{
force_lcd_update=true;
lcd.clear();
clear();
delay(1);
}
for(uint8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
Expand Down Expand Up @@ -914,7 +950,8 @@ void MainMenu::showSD()
if(lastlineoffset!=lineoffset)
{
force_lcd_update=true;
lcd.clear();
clear();
delay(1);
}
static uint8_t nrfiles=0;
if(force_lcd_update)
Expand Down Expand Up @@ -1126,7 +1163,8 @@ void MainMenu::update()
if(status!=oldstatus)
{
//Serial.println(status);
lcd.clear();
clear();
delay(1);
force_lcd_update=true;
encoderpos=0;
lineoffset=0;
Expand Down

0 comments on commit b3f5d1e

Please sign in to comment.