New ML support - lcd optimalization

lcd_puts_P and lcd_printf_P functions
LineFeed implemented in LiquidCrystal_Prusa
This commit is contained in:
Robert Pelnar 2018-06-10 22:06:00 +02:00
parent 0f75bcb442
commit 0cf7d12ae3
4 changed files with 36 additions and 10 deletions

View file

@ -273,7 +273,7 @@ void LiquidCrystal_Prusa::setCursor(uint8_t col, uint8_t row)
if ( row >= _numlines ) { if ( row >= _numlines ) {
row = _numlines-1; // we count rows starting w/0 row = _numlines-1; // we count rows starting w/0
} }
_currline = row;
command(LCD_SETDDRAMADDR | (col + row_offsets[row])); command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
} }
@ -356,6 +356,12 @@ inline void LiquidCrystal_Prusa::command(uint8_t value) {
} }
inline size_t LiquidCrystal_Prusa::write(uint8_t value) { inline size_t LiquidCrystal_Prusa::write(uint8_t value) {
if (value == '\n')
{
if (_currline > 3) _currline = -1;
setCursor(0, _currline + 1); // LF
return 1;
}
if (_escape[0] || (value == 0x1b)) if (_escape[0] || (value == 0x1b))
return escape_write(value); return escape_write(value);
send(value, HIGH); send(value, HIGH);
@ -421,7 +427,7 @@ inline size_t LiquidCrystal_Prusa::escape_write(uint8_t chr)
break; break;
case '2': case '2':
if (chr == 'J') // escape = "\x1b[2J" if (chr == 'J') // escape = "\x1b[2J"
{ clear(); break; } // EraseScreen { clear(); _currline = 0; break; } // EraseScreen
default: default:
if (e_2_is_num && // escape = "\x1b[%1d" if (e_2_is_num && // escape = "\x1b[%1d"
((chr == ';') || // escape = "\x1b[%1d;" ((chr == ';') || // escape = "\x1b[%1d;"

View file

@ -903,14 +903,18 @@ int uart_putchar(char c, FILE *stream)
return 0; return 0;
} }
void lcd_splash() void lcd_splash()
{ {
// lcd_print_at_PGM(0, 1, PSTR(" Original Prusa ")); // lcd_print_at_PGM(0, 1, PSTR(" Original Prusa "));
// lcd_print_at_PGM(0, 2, PSTR(" 3D Printers ")); // lcd_print_at_PGM(0, 2, PSTR(" 3D Printers "));
// lcd.print_P(PSTR("\x1b[1;3HOriginal Prusa\x1b[2;4H3D Printers")); // lcd.print_P(PSTR("\x1b[1;3HOriginal Prusa\x1b[2;4H3D Printers"));
fputs_P(PSTR(ESC_2J ESC_H(1,1) "Original Prusa i3" ESC_H(3,2) "Prusa Research"), lcdout); // fputs_P(PSTR(ESC_2J ESC_H(1,1) "Original Prusa i3" ESC_H(3,2) "Prusa Research"), lcdout);
lcd_puts_P(PSTR(ESC_2J ESC_H(1,1) "Original Prusa i3" ESC_H(3,2) "Prusa Research"));
// lcd_printf_P(_N(ESC_2J "x:%.3f\ny:%.3f\nz:%.3f\ne:%.3f"), _x, _y, _z, _e);
} }
void factory_reset() void factory_reset()
{ {
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -1169,6 +1173,7 @@ void setup()
SERIAL_ECHO_START; SERIAL_ECHO_START;
printf_P(PSTR(" " FW_VERSION_FULL "\n")); printf_P(PSTR(" " FW_VERSION_FULL "\n"));
#ifdef DEBUG_SEC_LANG #ifdef DEBUG_SEC_LANG
lang_table_header_t header; lang_table_header_t header;
uint32_t src_addr = 0x00000; uint32_t src_addr = 0x00000;

View file

@ -26,7 +26,22 @@
#include "tmc2130.h" #include "tmc2130.h"
#endif //TMC2130 #endif //TMC2130
#define _STRINGIFY(s) #s
#include <stdarg.h>
int lcd_puts_P(const char* str)
{
return fputs_P(str, lcdout);
}
int lcd_printf_P(const char* format, ...)
{
va_list args;
va_start(args, format);
int ret = vfprintf_P(lcdout, format, args);
va_end(args);
return ret;
}
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
@ -4058,8 +4073,7 @@ void lcd_wizard(int state) {
} }
} }
SERIAL_ECHOPGM("State: "); printf_P(_N("State: %d\n"), state);
MYSERIAL.println(state);
switch (state) { //final message switch (state) { //final message
case 0: //user dont want to use wizard case 0: //user dont want to use wizard
msg = _T(MSG_WIZARD_QUIT); msg = _T(MSG_WIZARD_QUIT);
@ -6370,8 +6384,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
//end of second measurement, now check for possible errors: //end of second measurement, now check for possible errors:
for(int i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length for(int i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length
SERIAL_ECHOPGM("Measured axis length:"); printf_P(_N("Measured axis length:%.3f\n"), measured_axis_length[i]);
MYSERIAL.println(measured_axis_length[i]);
if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { if (abs(measured_axis_length[i] - axis_length) > max_error_mm) {
enable_endstops(false); enable_endstops(false);
@ -6390,8 +6403,7 @@ static bool lcd_selfcheck_axis_sg(char axis) {
} }
} }
SERIAL_ECHOPGM("Axis length difference:"); printf_P(_N("Axis length difference:%.3f\n"), abs(measured_axis_length[0] - measured_axis_length[1]));
MYSERIAL.println(abs(measured_axis_length[0] - measured_axis_length[1]));
if (abs(measured_axis_length[0] - measured_axis_length[1]) > 1) { //check if difference between first and second measurement is low if (abs(measured_axis_length[0] - measured_axis_length[1]) > 1) { //check if difference between first and second measurement is low
//loose pulleys //loose pulleys

View file

@ -4,6 +4,9 @@
#include "Marlin.h" #include "Marlin.h"
#include "mesh_bed_calibration.h" #include "mesh_bed_calibration.h"
extern int lcd_puts_P(const char* str);
extern int lcd_printf_P(const char* format, ...);
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
static void lcd_language_menu(); static void lcd_language_menu();