-
Notifications
You must be signed in to change notification settings - Fork 0
/
ultralcd.cpp
4897 lines (4107 loc) · 128 KB
/
ultralcd.cpp
1
2
3
4
5
6
7
8
9
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "temperature.h"
#include "ultralcd.h"
#ifdef ULTRA_LCD
#include "Marlin.h"
#include "language.h"
#include "cardreader.h"
#include "temperature.h"
#include "stepper.h"
#include "ConfigurationStore.h"
#include <string.h>
#include "util.h"
#include "mesh_bed_leveling.h"
//#include "Configuration.h"
#include "SdFatUtil.h"
#define _STRINGIFY(s) #s
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
extern int lcd_change_fil_state;
//Function pointer to menu functions.
typedef void (*menuFunc_t)();
static void lcd_sd_updir();
struct EditMenuParentState
{
//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
menuFunc_t prevMenu;
uint16_t prevEncoderPosition;
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue, maxEditValue;
// menuFunc_t callbackFunc;
};
union MenuData
{
struct BabyStep
{
// 29B total
int8_t status;
int babystepMem[3];
float babystepMemMM[3];
} babyStep;
struct SupportMenu
{
// 6B+16B=22B total
int8_t status;
bool is_flash_air;
uint8_t ip[4];
char ip_str[3*4+3+1];
} supportMenu;
struct AdjustBed
{
// 6+13+16=35B
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
int8_t status;
int8_t left;
int8_t right;
int8_t front;
int8_t rear;
int left2;
int right2;
int front2;
int rear2;
} adjustBed;
// editMenuParentState is used when an edit menu is entered, so it knows
// the return menu and encoder state.
struct EditMenuParentState editMenuParentState;
};
// State of the currently active menu.
// C Union manages sharing of the static memory by all the menus.
union MenuData menuData = { 0 };
union Data
{
byte b[2];
int value;
};
int8_t ReInitLCD = 0;
int8_t SDscrool = 0;
int8_t SilentModeMenu = 0;
int lcd_commands_type=LCD_COMMAND_IDLE;
int lcd_commands_step=0;
bool isPrintPaused = false;
bool farm_mode = false;
int farm_no = 0;
int farm_timer = 30;
int farm_status = 0;
bool menuExiting = false;
#ifdef FILAMENT_LCD_DISPLAY
unsigned long message_millis = 0;
#endif
#ifdef ULTIPANEL
static float manual_feedrate[] = MANUAL_FEEDRATE;
#endif // ULTIPANEL
/* !Configuration settings */
uint8_t lcd_status_message_level;
char lcd_status_message[LCD_WIDTH + 1] = ""; //////WELCOME!
unsigned char firstrun = 1;
#ifdef DOGLCD
#include "dogm_lcd_implementation.h"
#else
#include "ultralcd_implementation_hitachi_HD44780.h"
#endif
/** forward declarations **/
// void copy_and_scalePID_i();
// void copy_and_scalePID_d();
/* Different menus */
static void lcd_status_screen();
#ifdef ULTIPANEL
extern bool powersupply;
static void lcd_main_menu();
static void lcd_tune_menu();
static void lcd_prepare_menu();
static void lcd_move_menu();
static void lcd_settings_menu();
static void lcd_calibration_menu();
static void lcd_language_menu();
static void lcd_control_temperature_menu();
static void lcd_control_temperature_preheat_pla_settings_menu();
static void lcd_control_temperature_preheat_abs_settings_menu();
static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu();
static void prusa_stat_printerstatus(int _status);
static void prusa_stat_temperatures();
static void prusa_stat_printinfo();
static void lcd_farm_no();
#ifdef DOGLCD
static void lcd_set_contrast();
#endif
static void lcd_control_retract_menu();
static void lcd_sdcard_menu();
#ifdef DELTA_CALIBRATION_MENU
static void lcd_delta_calibrate_menu();
#endif // DELTA_CALIBRATION_MENU
static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
/* Different types of actions that can be used in menu items. */
static void menu_action_back(menuFunc_t data);
#define menu_action_back_RAM menu_action_back
static void menu_action_submenu(menuFunc_t data);
static void menu_action_gcode(const char* pgcode);
static void menu_action_function(menuFunc_t data);
static void menu_action_setlang(unsigned char lang);
static void menu_action_sdfile(const char* filename, char* longFilename);
static void menu_action_sddirectory(const char* filename, char* longFilename);
static void menu_action_setting_edit_bool(const char* pstr, bool* ptr);
static void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
static void menu_action_setting_edit_float3(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_float32(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_float43(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_float5(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_float51(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_float52(const char* pstr, float* ptr, float minValue, float maxValue);
static void menu_action_setting_edit_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue);
/*
static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_int3(const char* pstr, int* ptr, int minValue, int maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float3(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float32(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float43(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float5(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float51(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
*/
#define ENCODER_FEEDRATE_DEADZONE 10
#if !defined(LCD_I2C_VIKI)
#ifndef ENCODER_STEPS_PER_MENU_ITEM
#define ENCODER_STEPS_PER_MENU_ITEM 5
#endif
#ifndef ENCODER_PULSES_PER_STEP
#define ENCODER_PULSES_PER_STEP 1
#endif
#else
#ifndef ENCODER_STEPS_PER_MENU_ITEM
#define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
#endif
#ifndef ENCODER_PULSES_PER_STEP
#define ENCODER_PULSES_PER_STEP 1
#endif
#endif
/* Helper macros for menus */
#define START_MENU() do { \
if (encoderPosition > 0x8000) encoderPosition = 0; \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
bool wasClicked = LCD_CLICKED;\
for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
_menuItemNr = 0;
#define MENU_ITEM(type, label, args...) do { \
if (_menuItemNr == _lineNr) { \
if (lcdDrawUpdate) { \
const char* _label_pstr = (label); \
if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
}else{\
lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
}\
}\
if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\
lcd_quick_feedback(); \
menu_action_ ## type ( args ); \
return;\
}\
}\
_menuItemNr++;\
} while(0)
#define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, (label) , ## args )
#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, (label) , ## args )
#define END_MENU() \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
} } while(0)
/** Used variables to keep track of the menu */
#ifndef REPRAPWORLD_KEYPAD
volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
#else
volatile uint8_t buttons_reprapworld_keypad; // to store the reprapworld_keypad shift register values
#endif
#ifdef LCD_HAS_SLOW_BUTTONS
volatile uint8_t slow_buttons;//Contains the bits of the currently pressed buttons.
#endif
uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
uint32_t blocking_enc;
uint8_t lastEncoderBits;
uint32_t encoderPosition;
#if (SDCARDDETECT > 0)
bool lcd_oldcardstatus;
#endif
#endif //ULTIPANEL
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
uint32_t lcd_next_update_millis;
uint8_t lcd_status_update_delay;
bool ignore_click = false;
bool wait_for_unclick;
uint8_t lcdDrawUpdate = 2; /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */
// place-holders for Ki and Kd edits
#ifdef PIDTEMP
// float raw_Ki, raw_Kd;
#endif
static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder = 0, const bool feedback = true, bool reset_menu_state = true) {
if (currentMenu != menu) {
currentMenu = menu;
encoderPosition = encoder;
if (reset_menu_state) {
// Resets the global shared C union.
// This ensures, that the menu entered will find out, that it shall initialize itself.
memset(&menuData, 0, sizeof(menuData));
}
if (feedback) lcd_quick_feedback();
// For LCD_PROGRESS_BAR re-initialize the custom characters
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
lcd_set_custom_characters(menu == lcd_status_screen);
#endif
}
}
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
// Language selection dialog not active.
#define LANGSEL_OFF 0
// Language selection dialog modal, entered from the info screen. This is the case on firmware boot up,
// if the language index stored in the EEPROM is not valid.
#define LANGSEL_MODAL 1
// Language selection dialog entered from the Setup menu.
#define LANGSEL_ACTIVE 2
// Language selection dialog status
unsigned char langsel = LANGSEL_OFF;
void set_language_from_EEPROM() {
unsigned char eep = eeprom_read_byte((unsigned char*)EEPROM_LANG);
if (eep < LANG_NUM)
{
lang_selected = eep;
// Language is valid, no need to enter the language selection screen.
langsel = LANGSEL_OFF;
}
else
{
lang_selected = LANG_ID_DEFAULT;
// Invalid language, enter the language selection screen in a modal mode.
langsel = LANGSEL_MODAL;
}
}
static void lcd_status_screen()
{
if (firstrun == 1)
{
firstrun = 0;
set_language_from_EEPROM();
if(lcd_status_message_level == 0){
strncpy_P(lcd_status_message, WELCOME_MSG, LCD_WIDTH);
}
if (eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 1) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 2) == 255 && eeprom_read_byte((uint8_t *)EEPROM_TOTALTIME + 3) == 255)
{
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
}
if (langsel) {
//strncpy_P(lcd_status_message, PSTR(">>>>>>>>>>>> PRESS v"), LCD_WIDTH);
// Entering the language selection screen in a modal mode.
}
}
if (lcd_status_update_delay)
lcd_status_update_delay--;
else
lcdDrawUpdate = 1;
if (lcdDrawUpdate)
{
ReInitLCD++;
if (ReInitLCD == 30) {
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
currentMenu == lcd_status_screen
#endif
);
ReInitLCD = 0 ;
} else {
if ((ReInitLCD % 10) == 0) {
//lcd_implementation_nodisplay();
lcd_implementation_init_noclear( // to maybe revive the LCD if static electricity killed it.
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
currentMenu == lcd_status_screen
#endif
);
}
}
//lcd_implementation_display();
lcd_implementation_status_screen();
//lcd_implementation_clear();
if (farm_mode)
{
farm_timer--;
if (farm_timer < 1)
{
farm_timer = 180;
prusa_statistics(0);
}
switch (farm_timer)
{
case 45:
prusa_statistics(21);
break;
case 10:
if (IS_SD_PRINTING)
{
prusa_statistics(20);
}
break;
}
} // end of farm_mode
lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
if (lcd_commands_type != LCD_COMMAND_IDLE)
{
lcd_commands();
}
} // end of lcdDrawUpdate
#ifdef ULTIPANEL
bool current_click = LCD_CLICKED;
if (ignore_click) {
if (wait_for_unclick) {
if (!current_click) {
ignore_click = wait_for_unclick = false;
}
else {
current_click = false;
}
}
else if (current_click) {
lcd_quick_feedback();
wait_for_unclick = true;
current_click = false;
}
}
//if (--langsel ==0) {langsel=1;current_click=true;}
if (current_click && (lcd_commands_type != LCD_COMMAND_STOP_PRINT)) //click is aborted unless stop print finishes
{
lcd_goto_menu(lcd_main_menu);
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
currentMenu == lcd_status_screen
#endif
);
#ifdef FILAMENT_LCD_DISPLAY
message_millis = millis(); // get status message to show up for a while
#endif
}
#ifdef ULTIPANEL_FEEDMULTIPLY
// Dead zone at 100% feedrate
if ((feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100) ||
(feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100))
{
encoderPosition = 0;
feedmultiply = 100;
}
if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE)
{
feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
encoderPosition = 0;
}
else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
{
feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
encoderPosition = 0;
}
else if (feedmultiply != 100)
{
feedmultiply += int(encoderPosition);
encoderPosition = 0;
}
#endif //ULTIPANEL_FEEDMULTIPLY
if (feedmultiply < 10)
feedmultiply = 10;
else if (feedmultiply > 999)
feedmultiply = 999;
#endif //ULTIPANEL
}
#ifdef ULTIPANEL
void lcd_commands()
{
if (lcd_commands_type == LCD_COMMAND_STOP_PRINT) /// stop print
{
if (lcd_commands_step == 0) { lcd_commands_step = 6; custom_message = true; }
if (lcd_commands_step == 1 && !blocks_queued())
{
lcd_commands_step = 0;
lcd_commands_type = 0;
lcd_setstatuspgm(WELCOME_MSG);
custom_message_type = 0;
custom_message = false;
isPrintPaused = false;
}
if (lcd_commands_step == 2 && !blocks_queued())
{
setTargetBed(0);
setTargetHotend(0, 0);
setTargetHotend(0, 1);
setTargetHotend(0, 2);
manage_heater();
lcd_setstatuspgm(WELCOME_MSG);
cancel_heatup = false;
lcd_commands_step = 1;
}
if (lcd_commands_step == 3 && !blocks_queued())
{
// M84: Disable steppers.
enquecommand_P(PSTR("M84"));
#ifdef SNMM
enquecommand_P(PSTR("PRUSA ResF")); //resets flag at the end of the print (used for SNMM)
#endif
autotempShutdown();
lcd_commands_step = 2;
}
if (lcd_commands_step == 4 && !blocks_queued())
{
lcd_setstatuspgm(MSG_PLEASE_WAIT);
// G90: Absolute positioning.
enquecommand_P(PSTR("G90"));
// M83: Set extruder to relative mode.
enquecommand_P(PSTR("M83"));
#ifdef X_CANCEL_POS
enquecommand_P(PSTR("G1 X" STRINGIFY(X_CANCEL_POS) " Y" STRINGIFY(Y_CANCEL_POS) " E0 F7000"));
#else
enquecommand_P(PSTR("G1 X50 Y" STRINGIFY(Y_MAX_POS) " E0 F7000"));
#endif
lcd_ignore_click(false);
#ifdef SNMM
lcd_commands_step = 7;
#else
lcd_commands_step = 3;
#endif
}
if (lcd_commands_step == 5 && !blocks_queued())
{
lcd_setstatuspgm(MSG_PRINT_ABORTED);
// G91: Set to relative positioning.
enquecommand_P(PSTR("G91"));
// Lift up.
enquecommand_P(PSTR("G1 Z15 F1500"));
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) lcd_commands_step = 4;
else lcd_commands_step = 3;
}
if (lcd_commands_step == 6 && !blocks_queued())
{
lcd_setstatuspgm(MSG_PRINT_ABORTED);
cancel_heatup = true;
setTargetBed(0);
#ifndef SNMM
setTargetHotend(0, 0); //to heating when changing filament for multicolor
setTargetHotend(0, 1);
setTargetHotend(0, 2);
#endif
manage_heater();
custom_message = true;
custom_message_type = 2;
lcd_commands_step = 5;
}
if (lcd_commands_step == 7 && !blocks_queued()) {
/*ramming();
st_synchronize();
change_extr(0);*/
st_synchronize();
enquecommand_P(PSTR("M907 E700")); //set extruder current higher
enquecommand_P(PSTR("M203 E50"));
st_synchronize();
if (current_temperature[0] < 230) {
// PLA
//enquecommand_P(PSTR("G1 E-8 F2100.000000"));
//enquecommand_P(PSTR("G1 E8 F2100.000000"));
enquecommand_P(PSTR("G1 E5.4 F2800.000000"));
enquecommand_P(PSTR("G1 E3.2 F3000.000000"));
enquecommand_P(PSTR("G1 E3 F3400.000000"));
enquecommand_P(PSTR("M203 E80"));
st_synchronize();
enquecommand_P(PSTR("G1 E-82 F9500.000000"));
enquecommand_P(PSTR("M203 E50"));
enquecommand_P(PSTR("G1 E-20 F1200.000000"));
enquecommand_P(PSTR("G1 E5 F400.000000"));
enquecommand_P(PSTR("G1 E5 F600.000000"));
st_synchronize();
enquecommand_P(PSTR("G1 E-10 F600.000000"));
enquecommand_P(PSTR("G1 E+10 F600.000000"));
enquecommand_P(PSTR("G1 E-10 F800.000000"));
enquecommand_P(PSTR("G1 E+10 F800.000000"));
enquecommand_P(PSTR("G1 E-10 F800.000000"));
st_synchronize();
}else {
// ABS
//enquecommand_P(PSTR("G1 E-8 F2100.000000"));
//enquecommand_P(PSTR("G1 E8 F2100.000000"));
enquecommand_P(PSTR("G1 E3.1 F2000.000000"));
enquecommand_P(PSTR("G1 E3.1 F2500.000000"));
enquecommand_P(PSTR("G1 E4 F3000.000000"));
st_synchronize();
enquecommand_P(PSTR("G4 P4700"));
enquecommand_P(PSTR("M203 E80"));
enquecommand_P(PSTR("G1 E-92 F9900.000000"));
enquecommand_P(PSTR("M203 E50"));
enquecommand_P(PSTR("G1 E-5 F800.000000"));
enquecommand_P(PSTR("G1 E5 F400.000000"));
st_synchronize();
enquecommand_P(PSTR("G1 E-5 F600.000000"));
enquecommand_P(PSTR("G1 E5 F600.000000"));
enquecommand_P(PSTR("G1 E-5 F600.000000"));
enquecommand_P(PSTR("G1 E5 F600.000000"));
enquecommand_P(PSTR("G1 E5 F600.000000"));
st_synchronize();
}
enquecommand_P(PSTR("T0"));
enquecommand_P(PSTR("M907 E550")); //set extruder current to 500
//digipot_init();
lcd_commands_step = 3;
}
}
if (lcd_commands_type == 3)
{
lcd_commands_type = 0;
}
if (lcd_commands_type == LCD_COMMAND_FARM_MODE_CONFIRM) /// farm mode confirm
{
if (lcd_commands_step == 0) { lcd_commands_step = 6; custom_message = true; }
if (lcd_commands_step == 1 && !blocks_queued())
{
lcd_confirm_print();
lcd_commands_step = 0;
lcd_commands_type = 0;
}
if (lcd_commands_step == 2 && !blocks_queued())
{
lcd_commands_step = 1;
}
if (lcd_commands_step == 3 && !blocks_queued())
{
lcd_commands_step = 2;
}
if (lcd_commands_step == 4 && !blocks_queued())
{
enquecommand_P(PSTR("G90"));
enquecommand_P(PSTR("G1 X" STRINGIFY(X_CANCEL_POS) " Y" STRINGIFY(Y_CANCEL_POS) " E0 F7000"));
lcd_commands_step = 3;
}
if (lcd_commands_step == 5 && !blocks_queued())
{
lcd_commands_step = 4;
}
if (lcd_commands_step == 6 && !blocks_queued())
{
enquecommand_P(PSTR("G91"));
enquecommand_P(PSTR("G1 Z15 F1500"));
st_synchronize();
#ifdef SNMM
lcd_commands_step = 7;
#else
lcd_commands_step = 5;
#endif
}
}
}
static void lcd_return_to_status() {
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
currentMenu == lcd_status_screen
#endif
);
lcd_goto_menu(lcd_status_screen, 0, false);
}
static void lcd_sdcard_pause() {
card.pauseSDPrint();
isPrintPaused = true;
lcdDrawUpdate = 3;
}
static void lcd_sdcard_resume() {
card.startFileprint();
isPrintPaused = false;
lcdDrawUpdate = 3;
}
float move_menu_scale;
static void lcd_move_menu_axis();
/* Menu implementation */
void lcd_preheat_pla()
{
setTargetHotend0(PLA_PREHEAT_HOTEND_TEMP);
setTargetBed(PLA_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_abs()
{
setTargetHotend0(ABS_PREHEAT_HOTEND_TEMP);
setTargetBed(ABS_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_pp()
{
setTargetHotend0(PP_PREHEAT_HOTEND_TEMP);
setTargetBed(PP_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_pet()
{
setTargetHotend0(PET_PREHEAT_HOTEND_TEMP);
setTargetBed(PET_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_hips()
{
setTargetHotend0(HIPS_PREHEAT_HOTEND_TEMP);
setTargetBed(HIPS_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_flex()
{
setTargetHotend0(FLEX_PREHEAT_HOTEND_TEMP);
setTargetBed(FLEX_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_cooldown()
{
setTargetHotend0(0);
setTargetHotend1(0);
setTargetHotend2(0);
setTargetBed(0);
fanSpeed = 0;
lcd_return_to_status();
}
static void lcd_preheat_menu()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(function, PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs);
MENU_ITEM(function, PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)), lcd_preheat_pla);
MENU_ITEM(function, PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)), lcd_preheat_pet);
MENU_ITEM(function, PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)), lcd_preheat_hips);
MENU_ITEM(function, PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)), lcd_preheat_pp);
MENU_ITEM(function, PSTR("FLEX - " STRINGIFY(FLEX_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FLEX_PREHEAT_HPB_TEMP)), lcd_preheat_flex);
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
END_MENU();
}
static void lcd_support_menu()
{
if (menuData.supportMenu.status == 0 || lcdDrawUpdate == 2) {
// Menu was entered or SD card status has changed (plugged in or removed).
// Initialize its status.
menuData.supportMenu.status = 1;
menuData.supportMenu.is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(menuData.supportMenu.ip);
if (menuData.supportMenu.is_flash_air)
sprintf_P(menuData.supportMenu.ip_str, PSTR("%d.%d.%d.%d"),
menuData.supportMenu.ip[0], menuData.supportMenu.ip[1],
menuData.supportMenu.ip[2], menuData.supportMenu.ip[3]);
} else if (menuData.supportMenu.is_flash_air &&
menuData.supportMenu.ip[0] == 0 && menuData.supportMenu.ip[1] == 0 &&
menuData.supportMenu.ip[2] == 0 && menuData.supportMenu.ip[3] == 0 &&
++ menuData.supportMenu.status == 16) {
// Waiting for the FlashAir card to get an IP address from a router. Force an update.
menuData.supportMenu.status = 0;
}
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
// Ideally this block would be optimized out by the compiler.
const uint8_t fw_string_len = strlen_P(FW_VERSION_STR_P());
if (fw_string_len < 6) {
MENU_ITEM(back, PSTR(MSG_FW_VERSION " - " FW_version), lcd_main_menu);
} else {
MENU_ITEM(back, PSTR("FW - " FW_version), lcd_main_menu);
}
MENU_ITEM(back, MSG_PRUSA3D, lcd_main_menu);
MENU_ITEM(back, MSG_PRUSA3D_FORUM, lcd_main_menu);
MENU_ITEM(back, MSG_PRUSA3D_HOWTO, lcd_main_menu);
MENU_ITEM(back, PSTR("------------"), lcd_main_menu);
MENU_ITEM(back, PSTR(FILAMENT_SIZE), lcd_main_menu);
MENU_ITEM(back, PSTR(ELECTRONICS),lcd_main_menu);
MENU_ITEM(back, PSTR(NOZZLE_TYPE),lcd_main_menu);
MENU_ITEM(back, PSTR("------------"), lcd_main_menu);
MENU_ITEM(back, PSTR("Date: "), lcd_main_menu);
MENU_ITEM(back, PSTR(__DATE__), lcd_main_menu);
// Show the FlashAir IP address, if the card is available.
if (menuData.supportMenu.is_flash_air) {
MENU_ITEM(back, PSTR("------------"), lcd_main_menu);
MENU_ITEM(back, PSTR("FlashAir IP Addr:"), lcd_main_menu);
MENU_ITEM(back_RAM, menuData.supportMenu.ip_str, lcd_main_menu);
}
END_MENU();
}
void lcd_unLoadFilament()
{
if (degHotend0() > EXTRUDE_MINTEMP) {
enquecommand_P(PSTR("M702")); //unload filament
} else {
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd_printPGM(MSG_ERROR);
lcd.setCursor(0, 2);
lcd_printPGM(MSG_PREHEAT_NOZZLE);
delay(2000);
lcd_implementation_clear();
}
lcd_return_to_status();
}
void lcd_change_filament() {
lcd_implementation_clear();
lcd.setCursor(0, 1);
lcd_printPGM(MSG_CHANGING_FILAMENT);
}
void lcd_wait_interact() {
lcd_implementation_clear();
lcd.setCursor(0, 1);
lcd_printPGM(MSG_INSERT_FILAMENT);
lcd.setCursor(0, 2);
lcd_printPGM(MSG_PRESS);
}
void lcd_change_success() {
lcd_implementation_clear();
lcd.setCursor(0, 2);
lcd_printPGM(MSG_CHANGE_SUCCESS);
}
void lcd_loading_color() {
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd_printPGM(MSG_LOADING_COLOR);
lcd.setCursor(0, 2);
lcd_printPGM(MSG_PLEASE_WAIT);
for (int i = 0; i < 20; i++) {
lcd.setCursor(i, 3);
lcd.print(".");
for (int j = 0; j < 10 ; j++) {
manage_heater();
manage_inactivity(true);
delay(85);
}
}
}
void lcd_loading_filament() {
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd_printPGM(MSG_LOADING_FILAMENT);
lcd.setCursor(0, 2);
lcd_printPGM(MSG_PLEASE_WAIT);
for (int i = 0; i < 20; i++) {
lcd.setCursor(i, 3);
lcd.print(".");
for (int j = 0; j < 10 ; j++) {
manage_heater();
manage_inactivity(true);
delay(110);
}
}
}
void lcd_alright() {
int enc_dif = 0;
int cursor_pos = 1;
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd_printPGM(MSG_CORRECTLY);
lcd.setCursor(1, 1);
lcd_printPGM(MSG_YES);
lcd.setCursor(1, 2);
lcd_printPGM(MSG_NOT_LOADED);
lcd.setCursor(1, 3);
lcd_printPGM(MSG_NOT_COLOR);