Keep "astyled" elements in ultralcd-related files
This commit is contained in:
@@ -28,7 +28,7 @@ int absPreheatFanSpeed;
|
||||
typedef void (*menuFunc_t)();
|
||||
|
||||
uint8_t lcd_status_message_level;
|
||||
char lcd_status_message[3*LCD_WIDTH+1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
|
||||
char lcd_status_message[3 * LCD_WIDTH + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
|
||||
|
||||
#if ENABLED(DOGLCD)
|
||||
#include "dogm_lcd_implementation.h"
|
||||
@@ -254,7 +254,7 @@ float raw_Ki, raw_Kd;
|
||||
/**
|
||||
* General function to go directly to a menu
|
||||
*/
|
||||
static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) {
|
||||
static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const uint32_t encoder = 0) {
|
||||
if (currentMenu != menu) {
|
||||
currentMenu = menu;
|
||||
#if ENABLED(NEWPANEL)
|
||||
@@ -276,7 +276,7 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint
|
||||
*/
|
||||
|
||||
static void lcd_status_screen() {
|
||||
encoderRateMultiplierEnabled = false;
|
||||
encoderRateMultiplierEnabled = false;
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
millis_t ms = millis();
|
||||
@@ -346,7 +346,7 @@ static void lcd_status_screen() {
|
||||
#if ENABLED(ULTIPANEL_FEEDMULTIPLY)
|
||||
// Dead zone at 100% feedrate
|
||||
if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) ||
|
||||
(feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) {
|
||||
(feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) {
|
||||
encoderPosition = 0;
|
||||
feedrate_multiplier = 100;
|
||||
}
|
||||
@@ -459,7 +459,7 @@ void lcd_set_home_offsets() {
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
|
||||
static void _lcd_babystep(int axis, const char *msg) {
|
||||
static void _lcd_babystep(int axis, const char* msg) {
|
||||
if (encoderPosition != 0) {
|
||||
babystepsTodo[axis] += (int)encoderPosition;
|
||||
encoderPosition = 0;
|
||||
@@ -800,7 +800,7 @@ inline void line_to_current(AxisEnum axis) {
|
||||
float move_menu_scale;
|
||||
static void lcd_move_menu_axis();
|
||||
|
||||
static void _lcd_move(const char *name, AxisEnum axis, int min, int max) {
|
||||
static void _lcd_move(const char* name, AxisEnum axis, int min, int max) {
|
||||
if (encoderPosition != 0) {
|
||||
refresh_cmd_timeout();
|
||||
current_position[axis] += float((int)encoderPosition) * move_menu_scale;
|
||||
@@ -1179,8 +1179,8 @@ static void lcd_control_motion_menu() {
|
||||
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &abort_on_endstop_hit);
|
||||
#endif
|
||||
#if ENABLED(SCARA)
|
||||
MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS],0.5,2);
|
||||
MENU_ITEM_EDIT(float74, MSG_YSCALE, &axis_scaling[Y_AXIS],0.5,2);
|
||||
MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS], 0.5, 2);
|
||||
MENU_ITEM_EDIT(float74, MSG_YSCALE, &axis_scaling[Y_AXIS], 0.5, 2);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
@@ -1289,7 +1289,7 @@ static void lcd_control_volumetric_menu() {
|
||||
*
|
||||
*/
|
||||
void lcd_sdcard_menu() {
|
||||
if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
|
||||
if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
|
||||
uint16_t fileCnt = card.getnrfilenames();
|
||||
START_MENU();
|
||||
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
|
||||
@@ -1323,7 +1323,7 @@ static void lcd_control_volumetric_menu() {
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif //SDSUPPORT
|
||||
#endif //SDSUPPORT
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1336,7 +1336,7 @@ static void lcd_control_volumetric_menu() {
|
||||
if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
|
||||
if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
|
||||
if (lcdDrawUpdate) \
|
||||
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
|
||||
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
|
||||
if (isClicked) { \
|
||||
*((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
|
||||
lcd_goto_menu(prevMenu, prevEncoderPosition); \
|
||||
@@ -1348,10 +1348,10 @@ static void lcd_control_volumetric_menu() {
|
||||
static void _menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
|
||||
prevMenu = currentMenu; \
|
||||
prevEncoderPosition = encoderPosition; \
|
||||
\
|
||||
\
|
||||
lcdDrawUpdate = 2; \
|
||||
currentMenu = menu_edit_ ## _name; \
|
||||
\
|
||||
\
|
||||
editLabel = pstr; \
|
||||
editValue = ptr; \
|
||||
minEditValue = minValue * scale; \
|
||||
@@ -1474,7 +1474,7 @@ static void menu_action_function(menuFunc_t func) { (*func)(); }
|
||||
char cmd[30];
|
||||
char* c;
|
||||
sprintf_P(cmd, PSTR("M23 %s"), filename);
|
||||
for(c = &cmd[4]; *c; c++) *c = tolower(*c);
|
||||
for (c = &cmd[4]; *c; c++) *c = tolower(*c);
|
||||
enqueuecommand(cmd);
|
||||
enqueuecommands_P(PSTR("M24"));
|
||||
lcd_return_to_status();
|
||||
@@ -1497,39 +1497,45 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr,
|
||||
|
||||
/** LCD API **/
|
||||
void lcd_init() {
|
||||
|
||||
lcd_implementation_init();
|
||||
|
||||
#if ENABLED(NEWPANEL)
|
||||
|
||||
SET_INPUT(BTN_EN1);
|
||||
SET_INPUT(BTN_EN2);
|
||||
WRITE(BTN_EN1,HIGH);
|
||||
WRITE(BTN_EN2,HIGH);
|
||||
#if BTN_ENC > 0
|
||||
SET_INPUT(BTN_ENC);
|
||||
WRITE(BTN_ENC,HIGH);
|
||||
#endif
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
pinMode(SHIFT_CLK,OUTPUT);
|
||||
pinMode(SHIFT_LD,OUTPUT);
|
||||
pinMode(SHIFT_OUT,INPUT);
|
||||
WRITE(SHIFT_OUT,HIGH);
|
||||
WRITE(SHIFT_LD,HIGH);
|
||||
#endif
|
||||
#else // Not NEWPANEL
|
||||
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
|
||||
pinMode (SR_DATA_PIN, OUTPUT);
|
||||
pinMode (SR_CLK_PIN, OUTPUT);
|
||||
#elif defined(SHIFT_CLK)
|
||||
pinMode(SHIFT_CLK,OUTPUT);
|
||||
pinMode(SHIFT_LD,OUTPUT);
|
||||
pinMode(SHIFT_EN,OUTPUT);
|
||||
pinMode(SHIFT_OUT,INPUT);
|
||||
WRITE(SHIFT_OUT,HIGH);
|
||||
WRITE(SHIFT_LD,HIGH);
|
||||
WRITE(SHIFT_EN,LOW);
|
||||
#endif // SR_LCD_2W_NL
|
||||
#endif//!NEWPANEL
|
||||
WRITE(BTN_EN1, HIGH);
|
||||
WRITE(BTN_EN2, HIGH);
|
||||
|
||||
#if BTN_ENC > 0
|
||||
SET_INPUT(BTN_ENC);
|
||||
WRITE(BTN_ENC, HIGH);
|
||||
#endif
|
||||
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
pinMode(SHIFT_CLK, OUTPUT);
|
||||
pinMode(SHIFT_LD, OUTPUT);
|
||||
pinMode(SHIFT_OUT, INPUT);
|
||||
WRITE(SHIFT_OUT, HIGH);
|
||||
WRITE(SHIFT_LD, HIGH);
|
||||
#endif
|
||||
|
||||
#else // Not NEWPANEL
|
||||
|
||||
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
|
||||
pinMode(SR_DATA_PIN, OUTPUT);
|
||||
pinMode(SR_CLK_PIN, OUTPUT);
|
||||
#elif defined(SHIFT_CLK)
|
||||
pinMode(SHIFT_CLK, OUTPUT);
|
||||
pinMode(SHIFT_LD, OUTPUT);
|
||||
pinMode(SHIFT_EN, OUTPUT);
|
||||
pinMode(SHIFT_OUT, INPUT);
|
||||
WRITE(SHIFT_OUT, HIGH);
|
||||
WRITE(SHIFT_LD, HIGH);
|
||||
WRITE(SHIFT_EN, LOW);
|
||||
#endif // SR_LCD_2W_NL
|
||||
|
||||
#endif//!NEWPANEL
|
||||
|
||||
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
|
||||
pinMode(SD_DETECT_PIN, INPUT);
|
||||
@@ -1548,7 +1554,7 @@ void lcd_init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int lcd_strlen(char *s) {
|
||||
int lcd_strlen(char* s) {
|
||||
int i = 0, j = 0;
|
||||
while (s[i]) {
|
||||
if ((s[i] & 0xc0) != 0x80) j++;
|
||||
@@ -1557,7 +1563,7 @@ int lcd_strlen(char *s) {
|
||||
return j;
|
||||
}
|
||||
|
||||
int lcd_strlen_P(const char *s) {
|
||||
int lcd_strlen_P(const char* s) {
|
||||
int j = 0;
|
||||
while (pgm_read_byte(s)) {
|
||||
if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
|
||||
@@ -1683,18 +1689,18 @@ void lcd_update() {
|
||||
}
|
||||
}
|
||||
#if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display
|
||||
if (lcdDrawUpdate) {
|
||||
blink++; // Variable for fan animation and alive dot
|
||||
u8g.firstPage();
|
||||
do {
|
||||
lcd_setFont(FONT_MENU);
|
||||
u8g.setPrintPos(125, 0);
|
||||
if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
|
||||
u8g.drawPixel(127, 63); // draw alive dot
|
||||
u8g.setColorIndex(1); // black on white
|
||||
(*currentMenu)();
|
||||
} while( u8g.nextPage() );
|
||||
}
|
||||
if (lcdDrawUpdate) {
|
||||
blink++; // Variable for fan animation and alive dot
|
||||
u8g.firstPage();
|
||||
do {
|
||||
lcd_setFont(FONT_MENU);
|
||||
u8g.setPrintPos(125, 0);
|
||||
if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
|
||||
u8g.drawPixel(127, 63); // draw alive dot
|
||||
u8g.setColorIndex(1); // black on white
|
||||
(*currentMenu)();
|
||||
} while (u8g.nextPage());
|
||||
}
|
||||
#else
|
||||
if (lcdDrawUpdate)
|
||||
(*currentMenu)();
|
||||
@@ -1749,7 +1755,7 @@ void lcd_finishstatus(bool persist=false) {
|
||||
void dontExpireStatus() { expire_status_ms = 0; }
|
||||
#endif
|
||||
|
||||
void set_utf_strlen(char *s, uint8_t n) {
|
||||
void set_utf_strlen(char* s, uint8_t n) {
|
||||
uint8_t i = 0, j = 0;
|
||||
while (s[i] && (j < n)) {
|
||||
if ((s[i] & 0xc0u) != 0x80u) j++;
|
||||
@@ -1763,14 +1769,14 @@ bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
|
||||
|
||||
void lcd_setstatus(const char* message, bool persist) {
|
||||
if (lcd_status_message_level > 0) return;
|
||||
strncpy(lcd_status_message, message, 3*LCD_WIDTH);
|
||||
strncpy(lcd_status_message, message, 3 * LCD_WIDTH);
|
||||
set_utf_strlen(lcd_status_message, LCD_WIDTH);
|
||||
lcd_finishstatus(persist);
|
||||
}
|
||||
|
||||
void lcd_setstatuspgm(const char* message, uint8_t level) {
|
||||
if (level >= lcd_status_message_level) {
|
||||
strncpy_P(lcd_status_message, message, 3*LCD_WIDTH);
|
||||
strncpy_P(lcd_status_message, message, 3 * LCD_WIDTH);
|
||||
set_utf_strlen(lcd_status_message, LCD_WIDTH);
|
||||
lcd_status_message_level = level;
|
||||
lcd_finishstatus(level > 0);
|
||||
@@ -1825,23 +1831,23 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
||||
#endif
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
// for the reprapworld_keypad
|
||||
uint8_t newbutton_reprapworld_keypad=0;
|
||||
uint8_t newbutton_reprapworld_keypad = 0;
|
||||
WRITE(SHIFT_LD, LOW);
|
||||
WRITE(SHIFT_LD, HIGH);
|
||||
for(int8_t i = 0; i < 8; i++) {
|
||||
for (int8_t i = 0; i < 8; i++) {
|
||||
newbutton_reprapworld_keypad >>= 1;
|
||||
if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
|
||||
WRITE(SHIFT_CLK, HIGH);
|
||||
WRITE(SHIFT_CLK, LOW);
|
||||
}
|
||||
buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
|
||||
buttons_reprapworld_keypad = ~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
|
||||
#endif
|
||||
#else //read it from the shift register
|
||||
uint8_t newbutton = 0;
|
||||
WRITE(SHIFT_LD, LOW);
|
||||
WRITE(SHIFT_LD, HIGH);
|
||||
unsigned char tmp_buttons = 0;
|
||||
for(int8_t i=0; i<8; i++) {
|
||||
for (int8_t i = 0; i < 8; i++) {
|
||||
newbutton >>= 1;
|
||||
if (READ(SHIFT_OUT)) newbutton |= BIT(7);
|
||||
WRITE(SHIFT_CLK, HIGH);
|
||||
@@ -1851,26 +1857,26 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
||||
#endif //!NEWPANEL
|
||||
|
||||
//manage encoder rotation
|
||||
uint8_t enc=0;
|
||||
uint8_t enc = 0;
|
||||
if (buttons & EN_A) enc |= B01;
|
||||
if (buttons & EN_B) enc |= B10;
|
||||
if (enc != lastEncoderBits) {
|
||||
switch(enc) {
|
||||
switch (enc) {
|
||||
case encrot0:
|
||||
if (lastEncoderBits==encrot3) encoderDiff++;
|
||||
else if (lastEncoderBits==encrot1) encoderDiff--;
|
||||
if (lastEncoderBits == encrot3) encoderDiff++;
|
||||
else if (lastEncoderBits == encrot1) encoderDiff--;
|
||||
break;
|
||||
case encrot1:
|
||||
if (lastEncoderBits==encrot0) encoderDiff++;
|
||||
else if (lastEncoderBits==encrot2) encoderDiff--;
|
||||
if (lastEncoderBits == encrot0) encoderDiff++;
|
||||
else if (lastEncoderBits == encrot2) encoderDiff--;
|
||||
break;
|
||||
case encrot2:
|
||||
if (lastEncoderBits==encrot1) encoderDiff++;
|
||||
else if (lastEncoderBits==encrot3) encoderDiff--;
|
||||
if (lastEncoderBits == encrot1) encoderDiff++;
|
||||
else if (lastEncoderBits == encrot3) encoderDiff--;
|
||||
break;
|
||||
case encrot3:
|
||||
if (lastEncoderBits==encrot2) encoderDiff++;
|
||||
else if (lastEncoderBits==encrot0) encoderDiff--;
|
||||
if (lastEncoderBits == encrot2) encoderDiff++;
|
||||
else if (lastEncoderBits == encrot0) encoderDiff--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1896,12 +1902,12 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
|
||||
char conv[8];
|
||||
|
||||
// Convert float to string with +123.4 format
|
||||
char *ftostr3(const float &x) {
|
||||
char* ftostr3(const float& x) {
|
||||
return itostr3((int)x);
|
||||
}
|
||||
|
||||
// Convert int to string with 12 format
|
||||
char *itostr2(const uint8_t &x) {
|
||||
char* itostr2(const uint8_t& x) {
|
||||
//sprintf(conv,"%5.1f",x);
|
||||
int xx = x;
|
||||
conv[0] = (xx / 10) % 10 + '0';
|
||||
@@ -1911,7 +1917,7 @@ char *itostr2(const uint8_t &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with +123.4 format
|
||||
char *ftostr31(const float &x) {
|
||||
char* ftostr31(const float& x) {
|
||||
int xx = abs(x * 10);
|
||||
conv[0] = (x >= 0) ? '+' : '-';
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
@@ -1924,7 +1930,7 @@ char *ftostr31(const float &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with 123.4 format, dropping sign
|
||||
char *ftostr31ns(const float &x) {
|
||||
char* ftostr31ns(const float& x) {
|
||||
int xx = abs(x * 10);
|
||||
conv[0] = (xx / 1000) % 10 + '0';
|
||||
conv[1] = (xx / 100) % 10 + '0';
|
||||
@@ -1936,7 +1942,7 @@ char *ftostr31ns(const float &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with 123.4 format
|
||||
char *ftostr32(const float &x) {
|
||||
char* ftostr32(const float& x) {
|
||||
long xx = abs(x * 100);
|
||||
conv[0] = x >= 0 ? (xx / 10000) % 10 + '0' : '-';
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
@@ -1949,39 +1955,37 @@ char *ftostr32(const float &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with 1.234 format
|
||||
char *ftostr43(const float &x) {
|
||||
long xx = x * 1000;
|
||||
if (xx >= 0)
|
||||
conv[0] = (xx / 1000) % 10 + '0';
|
||||
else
|
||||
conv[0] = '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = '.';
|
||||
conv[2] = (xx / 100) % 10 + '0';
|
||||
conv[3] = (xx / 10) % 10 + '0';
|
||||
conv[4] = (xx) % 10 + '0';
|
||||
conv[5] = 0;
|
||||
return conv;
|
||||
char* ftostr43(const float& x) {
|
||||
long xx = x * 1000;
|
||||
if (xx >= 0)
|
||||
conv[0] = (xx / 1000) % 10 + '0';
|
||||
else
|
||||
conv[0] = '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = '.';
|
||||
conv[2] = (xx / 100) % 10 + '0';
|
||||
conv[3] = (xx / 10) % 10 + '0';
|
||||
conv[4] = (xx) % 10 + '0';
|
||||
conv[5] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// 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]='.';
|
||||
conv[2]=(xx/10)%10+'0';
|
||||
conv[3]=(xx)%10+'0';
|
||||
conv[4]=0;
|
||||
char* ftostr12ns(const float& x) {
|
||||
long xx = x * 100;
|
||||
xx = abs(xx);
|
||||
conv[0] = (xx / 100) % 10 + '0';
|
||||
conv[1] = '.';
|
||||
conv[2] = (xx / 10) % 10 + '0';
|
||||
conv[3] = (xx) % 10 + '0';
|
||||
conv[4] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to space-padded string with -_23.4_ format
|
||||
char *ftostr32sp(const float &x) {
|
||||
char* ftostr32sp(const float& x) {
|
||||
long xx = abs(x * 100);
|
||||
uint8_t dig;
|
||||
|
||||
if (x < 0) { // negative val = -_0
|
||||
conv[0] = '-';
|
||||
dig = (xx / 1000) % 10;
|
||||
@@ -2024,7 +2028,7 @@ char *ftostr32sp(const float &x) {
|
||||
}
|
||||
|
||||
// Convert int to lj string with +123.0 format
|
||||
char *itostr31(const int &x) {
|
||||
char* itostr31(const int& x) {
|
||||
conv[0] = x >= 0 ? '+' : '-';
|
||||
int xx = abs(x);
|
||||
conv[1] = (xx / 100) % 10 + '0';
|
||||
@@ -2037,11 +2041,11 @@ char *itostr31(const int &x) {
|
||||
}
|
||||
|
||||
// Convert int to rj string with 123 or -12 format
|
||||
char *itostr3(const int &x) {
|
||||
char* itostr3(const int& x) {
|
||||
int xx = x;
|
||||
if (xx < 0) {
|
||||
conv[0] = '-';
|
||||
xx = -xx;
|
||||
conv[0] = '-';
|
||||
xx = -xx;
|
||||
}
|
||||
else
|
||||
conv[0] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
|
||||
@@ -2053,7 +2057,7 @@ char *itostr3(const int &x) {
|
||||
}
|
||||
|
||||
// Convert int to lj string with 123 format
|
||||
char *itostr3left(const int &xx) {
|
||||
char* itostr3left(const int& xx) {
|
||||
if (xx >= 100) {
|
||||
conv[0] = (xx / 100) % 10 + '0';
|
||||
conv[1] = (xx / 10) % 10 + '0';
|
||||
@@ -2073,7 +2077,7 @@ char *itostr3left(const int &xx) {
|
||||
}
|
||||
|
||||
// Convert int to rj string with 1234 format
|
||||
char *itostr4(const int &xx) {
|
||||
char* itostr4(const int& xx) {
|
||||
conv[0] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
|
||||
conv[1] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
|
||||
conv[2] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
|
||||
@@ -2083,7 +2087,7 @@ char *itostr4(const int &xx) {
|
||||
}
|
||||
|
||||
// Convert float to rj string with 12345 format
|
||||
char *ftostr5(const float &x) {
|
||||
char* ftostr5(const float& x) {
|
||||
long xx = abs(x);
|
||||
conv[0] = xx >= 10000 ? (xx / 10000) % 10 + '0' : ' ';
|
||||
conv[1] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
|
||||
@@ -2095,7 +2099,7 @@ char *ftostr5(const float &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with +1234.5 format
|
||||
char *ftostr51(const float &x) {
|
||||
char* ftostr51(const float& x) {
|
||||
long xx = abs(x * 10);
|
||||
conv[0] = (x >= 0) ? '+' : '-';
|
||||
conv[1] = (xx / 10000) % 10 + '0';
|
||||
@@ -2109,7 +2113,7 @@ char *ftostr51(const float &x) {
|
||||
}
|
||||
|
||||
// Convert float to string with +123.45 format
|
||||
char *ftostr52(const float &x) {
|
||||
char* ftostr52(const float& x) {
|
||||
conv[0] = (x >= 0) ? '+' : '-';
|
||||
long xx = abs(x * 100);
|
||||
conv[1] = (xx / 10000) % 10 + '0';
|
||||
@@ -2151,7 +2155,7 @@ char *ftostr52(const float &x) {
|
||||
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
|
||||
mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
||||
_lcd_level_bed_position++;
|
||||
if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) {
|
||||
if (_lcd_level_bed_position == MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS) {
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
||||
line_to_current(Z_AXIS);
|
||||
mbl.active = 1;
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#if ENABLED(ULTRA_LCD)
|
||||
#include "buzzer.h"
|
||||
|
||||
int lcd_strlen(char *s);
|
||||
int lcd_strlen_P(const char *s);
|
||||
int lcd_strlen(char* s);
|
||||
int lcd_strlen_P(const char* s);
|
||||
void lcd_update();
|
||||
void lcd_init();
|
||||
bool lcd_hasstatus();
|
||||
@@ -69,23 +69,23 @@
|
||||
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
#define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F1 (BIT(BLEN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define EN_REPRAPWORLD_KEYPAD_UP (BIT(BLEN_REPRAPWORLD_KEYPAD_UP))
|
||||
#define EN_REPRAPWORLD_KEYPAD_RIGHT (BIT(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
|
||||
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (BIT(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
|
||||
#define EN_REPRAPWORLD_KEYPAD_DOWN (BIT(BLEN_REPRAPWORLD_KEYPAD_DOWN))
|
||||
#define EN_REPRAPWORLD_KEYPAD_LEFT (BIT(BLEN_REPRAPWORLD_KEYPAD_LEFT))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F1 (BIT(BLEN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define EN_REPRAPWORLD_KEYPAD_UP (BIT(BLEN_REPRAPWORLD_KEYPAD_UP))
|
||||
#define EN_REPRAPWORLD_KEYPAD_RIGHT (BIT(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
|
||||
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (BIT(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
|
||||
#define EN_REPRAPWORLD_KEYPAD_DOWN (BIT(BLEN_REPRAPWORLD_KEYPAD_DOWN))
|
||||
#define EN_REPRAPWORLD_KEYPAD_LEFT (BIT(BLEN_REPRAPWORLD_KEYPAD_LEFT))
|
||||
|
||||
#define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F3)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_LEFT)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_RIGHT)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
|
||||
#define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F3)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_LEFT)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_RIGHT)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
|
||||
#endif //REPRAPWORLD_KEYPAD
|
||||
#else
|
||||
//atomic, do not change
|
||||
@@ -116,21 +116,21 @@
|
||||
|
||||
#endif //ULTRA_LCD
|
||||
|
||||
char *itostr2(const uint8_t &x);
|
||||
char *itostr31(const int &xx);
|
||||
char *itostr3(const int &xx);
|
||||
char *itostr3left(const int &xx);
|
||||
char *itostr4(const int &xx);
|
||||
char* itostr2(const uint8_t& x);
|
||||
char* itostr31(const int& xx);
|
||||
char* itostr3(const int& xx);
|
||||
char* itostr3left(const int& xx);
|
||||
char* itostr4(const int& xx);
|
||||
|
||||
char *ftostr3(const float &x);
|
||||
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 *ftostr32sp(const float &x); // remove zero-padding from ftostr32
|
||||
char *ftostr5(const float &x);
|
||||
char *ftostr51(const float &x);
|
||||
char *ftostr52(const float &x);
|
||||
char* ftostr3(const float& x);
|
||||
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* ftostr32sp(const float& x); // remove zero-padding from ftostr32
|
||||
char* ftostr5(const float& x);
|
||||
char* ftostr51(const float& x);
|
||||
char* ftostr52(const float& x);
|
||||
|
||||
#endif //ULTRALCD_H
|
||||
|
@@ -20,59 +20,59 @@
|
||||
// via a shift/i2c register.
|
||||
|
||||
#if ENABLED(ULTIPANEL)
|
||||
// All UltiPanels might have an encoder - so this is always be mapped onto first two bits
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
// All UltiPanels might have an encoder - so this is always be mapped onto first two bits
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
|
||||
#define EN_A BIT(BLEN_A)
|
||||
|
||||
#if defined(BTN_ENC) && BTN_ENC > -1
|
||||
// encoder click is directly connected
|
||||
#define BLEN_C 2
|
||||
#define EN_C BIT(BLEN_C)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Setup other button mappings of each panel
|
||||
//
|
||||
#if ENABLED(LCD_I2C_VIKI)
|
||||
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
||||
|
||||
// button and encoder bit positions within 'buttons'
|
||||
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
||||
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
|
||||
#define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
|
||||
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
|
||||
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
|
||||
#define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
|
||||
#define EN_A BIT(BLEN_A)
|
||||
|
||||
#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 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))
|
||||
// encoder click is directly connected
|
||||
#define BLEN_C 2
|
||||
#define EN_C BIT(BLEN_C)
|
||||
#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 ENABLED(LCD_I2C_PANELOLU2)
|
||||
// encoder click can be read through I2C if not directly connected
|
||||
#if BTN_ENC <= 0
|
||||
//
|
||||
// Setup other button mappings of each panel
|
||||
//
|
||||
#if ENABLED(LCD_I2C_VIKI)
|
||||
#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<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
||||
// button and encoder bit positions within 'buttons'
|
||||
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
||||
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
|
||||
#define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
|
||||
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
|
||||
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
|
||||
|
||||
#define LCD_CLICKED (buttons&B_MI)
|
||||
#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 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
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
#else
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#endif
|
||||
|
||||
#elif ENABLED(REPRAPWORLD_KEYPAD)
|
||||
#elif ENABLED(LCD_I2C_PANELOLU2)
|
||||
// encoder click can be read through I2C if not directly connected
|
||||
#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<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
||||
|
||||
#define LCD_CLICKED (buttons&B_MI)
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
#else
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#endif
|
||||
|
||||
#elif ENABLED(REPRAPWORLD_KEYPAD)
|
||||
// define register bit values, don't change it
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
|
||||
@@ -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))
|
||||
@@ -99,29 +99,29 @@
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
|
||||
|
||||
#elif ENABLED(NEWPANEL)
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#elif ENABLED(NEWPANEL)
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
|
||||
#else // old style ULTIPANEL
|
||||
//bits in the shift register that carry the buttons for:
|
||||
// left up center down right red(stop)
|
||||
#define BL_LE 7
|
||||
#define BL_UP 6
|
||||
#define BL_MI 5
|
||||
#define BL_DW 4
|
||||
#define BL_RI 3
|
||||
#define BL_ST 2
|
||||
#else // old style ULTIPANEL
|
||||
//bits in the shift register that carry the buttons for:
|
||||
// left up center down right red(stop)
|
||||
#define BL_LE 7
|
||||
#define BL_UP 6
|
||||
#define BL_MI 5
|
||||
#define BL_DW 4
|
||||
#define BL_RI 3
|
||||
#define BL_ST 2
|
||||
|
||||
//automatic, do not change
|
||||
#define B_LE BIT(BL_LE)
|
||||
#define B_UP BIT(BL_UP)
|
||||
#define B_MI BIT(BL_MI)
|
||||
#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
|
||||
//automatic, do not change
|
||||
#define B_LE BIT(BL_LE)
|
||||
#define B_UP BIT(BL_UP)
|
||||
#define B_MI BIT(BL_MI)
|
||||
#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
|
||||
|
||||
#endif //ULTIPANEL
|
||||
|
||||
@@ -137,12 +137,12 @@
|
||||
#define LCD_I2C_PIN_D5 5
|
||||
#define LCD_I2C_PIN_D6 6
|
||||
#define LCD_I2C_PIN_D7 7
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
#include <LCD.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#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);
|
||||
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 ENABLED(LCD_I2C_TYPE_MCP23017)
|
||||
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
|
||||
@@ -172,9 +172,9 @@
|
||||
#endif
|
||||
|
||||
#elif ENABLED(LCD_I2C_TYPE_PCA8574)
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#define LCD_CLASS LiquidCrystal_I2C
|
||||
LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT);
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#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
|
||||
@@ -188,7 +188,7 @@
|
||||
// Standard directly connected LCD implementations
|
||||
#include <LiquidCrystal.h>
|
||||
#define LCD_CLASS LiquidCrystal
|
||||
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
|
||||
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
|
||||
|
||||
#include "utf_mapper.h"
|
||||
@@ -208,7 +208,7 @@
|
||||
|
||||
static void lcd_set_custom_characters(
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
bool progress_bar_set=true
|
||||
bool progress_bar_set = true
|
||||
#endif
|
||||
) {
|
||||
byte bedTemp[8] = {
|
||||
@@ -331,7 +331,7 @@ static void lcd_set_custom_characters(
|
||||
lcd.createChar(LCD_STR_CLOCK[0], clock);
|
||||
if (progress_bar_set) {
|
||||
// Progress bar characters for info screen
|
||||
for (int i=3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
|
||||
for (int i = 3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
|
||||
}
|
||||
else {
|
||||
// Custom characters for submenus
|
||||
@@ -354,7 +354,7 @@ static void lcd_set_custom_characters(
|
||||
|
||||
static void lcd_implementation_init(
|
||||
#if ENABLED(LCD_PROGRESS_BAR)
|
||||
bool progress_bar_set=true
|
||||
bool progress_bar_set = true
|
||||
#endif
|
||||
) {
|
||||
|
||||
@@ -416,16 +416,16 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
void lcd_erase_line(int line) {
|
||||
lcd.setCursor(0, 3);
|
||||
for (int i=0; i < LCD_WIDTH; i++)
|
||||
for (int i = 0; i < LCD_WIDTH; i++)
|
||||
lcd_print(' ');
|
||||
}
|
||||
|
||||
// scrol the PSTR'text' in a 'len' wide field for 'time' milliseconds at position col,line
|
||||
void lcd_scroll(int col, int line, const char * text, int len, int time) {
|
||||
char tmp[LCD_WIDTH+1] = {0};
|
||||
// Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
|
||||
void lcd_scroll(int col, int line, const char* text, int len, int time) {
|
||||
char tmp[LCD_WIDTH + 1] = {0};
|
||||
int n = max(lcd_strlen_P(text) - len, 0);
|
||||
for (int i = 0; i <= n; i++) {
|
||||
strncpy_P(tmp, text+i, min(len, LCD_WIDTH));
|
||||
strncpy_P(tmp, text + i, min(len, LCD_WIDTH));
|
||||
lcd.setCursor(col, line);
|
||||
lcd_print(tmp);
|
||||
delay(time / max(n, 1));
|
||||
@@ -667,10 +667,10 @@ static void lcd_implementation_status_screen() {
|
||||
lcd.setCursor(LCD_WIDTH - 6, 2);
|
||||
lcd.print(LCD_STR_CLOCK[0]);
|
||||
if (print_job_start_ms != 0) {
|
||||
uint16_t time = millis()/60000 - print_job_start_ms/60000;
|
||||
lcd.print(itostr2(time/60));
|
||||
uint16_t time = millis() / 60000 - print_job_start_ms / 60000;
|
||||
lcd.print(itostr2(time / 60));
|
||||
lcd.print(':');
|
||||
lcd.print(itostr2(time%60));
|
||||
lcd.print(itostr2(time % 60));
|
||||
}
|
||||
else {
|
||||
lcd_printPGM(PSTR("--:--"));
|
||||
@@ -693,13 +693,13 @@ static void lcd_implementation_status_screen() {
|
||||
if (millis() >= progress_bar_ms + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
|
||||
int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100,
|
||||
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
|
||||
char msg[LCD_WIDTH+1], b = ' ';
|
||||
char msg[LCD_WIDTH + 1], b = ' ';
|
||||
msg[i] = '\0';
|
||||
while (i--) {
|
||||
if (i == cel - 1)
|
||||
b = LCD_STR_PROGRESS[2];
|
||||
else if (i == cel && rem != 0)
|
||||
b = LCD_STR_PROGRESS[rem-1];
|
||||
b = LCD_STR_PROGRESS[rem - 1];
|
||||
msg[i] = b;
|
||||
}
|
||||
lcd.print(msg);
|
||||
@@ -715,7 +715,7 @@ static void lcd_implementation_status_screen() {
|
||||
lcd_printPGM(PSTR("Dia "));
|
||||
lcd.print(ftostr12ns(filament_width_meas));
|
||||
lcd_printPGM(PSTR(" V"));
|
||||
lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
|
||||
lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
|
||||
lcd.print('%');
|
||||
return;
|
||||
}
|
||||
@@ -734,7 +734,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha
|
||||
n -= lcd_print(c);
|
||||
pstr++;
|
||||
}
|
||||
while(n--) lcd.print(' ');
|
||||
while (n--) lcd.print(' ');
|
||||
lcd.print(post_char);
|
||||
}
|
||||
|
||||
@@ -859,10 +859,10 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
|
||||
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 ENABLED(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
|
||||
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
|
||||
#endif
|
||||
return slow_buttons;
|
||||
#endif
|
||||
|
@@ -21,11 +21,9 @@
|
||||
|
||||
#include <U8glib.h>
|
||||
|
||||
static void ST7920_SWSPI_SND_8BIT(uint8_t val)
|
||||
{
|
||||
static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
|
||||
uint8_t i;
|
||||
for( i=0; i<8; i++ )
|
||||
{
|
||||
for (i = 0; i < 8; i++) {
|
||||
WRITE(ST7920_CLK_PIN,0);
|
||||
#if F_CPU == 20000000
|
||||
__asm__("nop\n\t");
|
||||
@@ -46,69 +44,59 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
|
||||
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
|
||||
#define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
|
||||
|
||||
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
uint8_t i,y;
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
{
|
||||
OUT_WRITE(ST7920_CS_PIN,LOW);
|
||||
OUT_WRITE(ST7920_DAT_PIN,LOW);
|
||||
OUT_WRITE(ST7920_CLK_PIN,HIGH);
|
||||
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
||||
uint8_t i, y;
|
||||
switch (msg) {
|
||||
case U8G_DEV_MSG_INIT: {
|
||||
OUT_WRITE(ST7920_CS_PIN, LOW);
|
||||
OUT_WRITE(ST7920_DAT_PIN, LOW);
|
||||
OUT_WRITE(ST7920_CLK_PIN, HIGH);
|
||||
|
||||
ST7920_CS();
|
||||
u8g_Delay(120); //initial delay for boot up
|
||||
ST7920_CS();
|
||||
u8g_Delay(120); //initial delay for boot up
|
||||
ST7920_SET_CMD();
|
||||
ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
|
||||
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
|
||||
u8g_Delay(15); //delay for CGRAM clear
|
||||
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
|
||||
for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
|
||||
ST7920_WRITE_BYTE(0x80 | y); //set y
|
||||
ST7920_WRITE_BYTE(0x80); //set x = 0
|
||||
ST7920_SET_DAT();
|
||||
for (i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
|
||||
ST7920_WRITE_BYTE(0);
|
||||
ST7920_SET_CMD();
|
||||
ST7920_WRITE_BYTE(0x08); //display off, cursor+blink off
|
||||
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
|
||||
u8g_Delay(15); //delay for CGRAM clear
|
||||
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
|
||||
for(y=0;y<LCD_PIXEL_HEIGHT/2;y++) //clear GDRAM
|
||||
{
|
||||
ST7920_WRITE_BYTE(0x80|y); //set y
|
||||
ST7920_WRITE_BYTE(0x80); //set x = 0
|
||||
ST7920_SET_DAT();
|
||||
for(i=0;i<2*LCD_PIXEL_WIDTH/8;i++) //2x width clears both segments
|
||||
ST7920_WRITE_BYTE(0);
|
||||
ST7920_SET_CMD();
|
||||
}
|
||||
ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off
|
||||
ST7920_NCS();
|
||||
}
|
||||
break;
|
||||
|
||||
ST7920_WRITE_BYTE(0x0C); //display on, cursor+blink off
|
||||
ST7920_NCS();
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
y = pb->p.page_y0;
|
||||
ptr = (uint8_t*)pb->buf;
|
||||
case U8G_DEV_MSG_PAGE_NEXT: {
|
||||
uint8_t* ptr;
|
||||
u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
|
||||
y = pb->p.page_y0;
|
||||
ptr = (uint8_t*)pb->buf;
|
||||
|
||||
ST7920_CS();
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
ST7920_SET_CMD();
|
||||
if ( y < 32 )
|
||||
{
|
||||
ST7920_WRITE_BYTE(0x80 | y); //y
|
||||
ST7920_WRITE_BYTE(0x80); //x=0
|
||||
}
|
||||
else
|
||||
{
|
||||
ST7920_WRITE_BYTE(0x80 | (y-32)); //y
|
||||
ST7920_WRITE_BYTE(0x80 | 8); //x=64
|
||||
}
|
||||
|
||||
ST7920_SET_DAT();
|
||||
ST7920_WRITE_BYTES(ptr,LCD_PIXEL_WIDTH/8); //ptr is incremented inside of macro
|
||||
y++;
|
||||
ST7920_CS();
|
||||
for (i = 0; i < PAGE_HEIGHT; i ++) {
|
||||
ST7920_SET_CMD();
|
||||
if (y < 32) {
|
||||
ST7920_WRITE_BYTE(0x80 | y); //y
|
||||
ST7920_WRITE_BYTE(0x80); //x=0
|
||||
}
|
||||
ST7920_NCS();
|
||||
else {
|
||||
ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
|
||||
ST7920_WRITE_BYTE(0x80 | 8); //x=64
|
||||
}
|
||||
ST7920_SET_DAT();
|
||||
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
|
||||
y++;
|
||||
}
|
||||
break;
|
||||
ST7920_NCS();
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if PAGE_HEIGHT == 8
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
@@ -119,14 +107,13 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH*(PAGE_HEIGHT/8)] U8G_NOCOMMON;
|
||||
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT,LCD_PIXEL_HEIGHT,0,0,0},LCD_PIXEL_WIDTH,u8g_dev_st7920_128x64_rrd_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn,&u8g_dev_st7920_128x64_rrd_pb,&u8g_com_null_fn};
|
||||
uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH * (PAGE_HEIGHT / 8)] U8G_NOCOMMON;
|
||||
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
|
||||
|
||||
class U8GLIB_ST7920_128X64_RRD : public U8GLIB
|
||||
{
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
|
||||
class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
|
||||
public:
|
||||
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user