|
@@ -65,6 +65,7 @@ inline int intround(const float &x){return int(0.5+x);}
|
65
|
65
|
void lcd_status(const char* message)
|
66
|
66
|
{
|
67
|
67
|
strncpy(messagetext,message,LCD_WIDTH);
|
|
68
|
+ messagetext[strlen(message)]=0;
|
68
|
69
|
}
|
69
|
70
|
|
70
|
71
|
void lcd_statuspgm(const char* message)
|
|
@@ -79,6 +80,7 @@ void lcd_statuspgm(const char* message)
|
79
|
80
|
cnt++;
|
80
|
81
|
ch=pgm_read_byte(++message);
|
81
|
82
|
}
|
|
83
|
+ *target=0;
|
82
|
84
|
}
|
83
|
85
|
|
84
|
86
|
inline void clear()
|
|
@@ -280,6 +282,7 @@ MainMenu::MainMenu()
|
280
|
282
|
#endif
|
281
|
283
|
lcd_init();
|
282
|
284
|
linechanging=false;
|
|
285
|
+ tune=false;
|
283
|
286
|
}
|
284
|
287
|
|
285
|
288
|
void MainMenu::showStatus()
|
|
@@ -373,7 +376,11 @@ void MainMenu::showStatus()
|
373
|
376
|
if(messagetext[0]!='\0')
|
374
|
377
|
{
|
375
|
378
|
lcd.setCursor(0,LCD_HEIGHT-1);
|
376
|
|
- lcd.print(fillto(LCD_WIDTH,messagetext));
|
|
379
|
+ lcd.print(messagetext);
|
|
380
|
+ uint8_t n=strlen(messagetext);
|
|
381
|
+ for(int8_t i=0;i<LCD_WIDTH-n;i++)
|
|
382
|
+ lcd.print(" ");
|
|
383
|
+
|
377
|
384
|
messagetext[0]='\0';
|
378
|
385
|
}
|
379
|
386
|
|
|
@@ -419,7 +426,10 @@ void MainMenu::showStatus()
|
419
|
426
|
if(messagetext[0]!='\0')
|
420
|
427
|
{
|
421
|
428
|
lcd.setCursor(0,LCD_HEIGHT-1);
|
422
|
|
- lcd.print(fillto(LCD_WIDTH,messagetext));
|
|
429
|
+ lcd.print(messagetext);
|
|
430
|
+ uint8_t n=strlen(messagetext);
|
|
431
|
+ for(int8_t i=0;i<LCD_WIDTH-n;i++)
|
|
432
|
+ lcd.print(" ");
|
423
|
433
|
messagetext[0]='\0';
|
424
|
434
|
}
|
425
|
435
|
|
|
@@ -471,6 +481,166 @@ void MainMenu::showPrepare()
|
471
|
481
|
updateActiveLines(ItemP_disstep,encoderpos);
|
472
|
482
|
}
|
473
|
483
|
|
|
484
|
+enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan};
|
|
485
|
+
|
|
486
|
+void MainMenu::showTune()
|
|
487
|
+{
|
|
488
|
+ uint8_t line=0;
|
|
489
|
+ clearIfNecessary();
|
|
490
|
+ for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
|
|
491
|
+ {
|
|
492
|
+ //Serial.println((int)(line-lineoffset));
|
|
493
|
+ switch(i)
|
|
494
|
+ {
|
|
495
|
+ case ItemT_exit:
|
|
496
|
+ MENUITEM( lcdprintPGM(" Tune") , BLOCK;status=Main_Menu;beepshort(); ) ;
|
|
497
|
+ break;
|
|
498
|
+ case ItemT_speed:
|
|
499
|
+ {
|
|
500
|
+ if(force_lcd_update)
|
|
501
|
+ {
|
|
502
|
+ lcd.setCursor(0,line);lcdprintPGM(" Speed:");
|
|
503
|
+ lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
|
|
504
|
+ }
|
|
505
|
+
|
|
506
|
+ if((activeline==line) )
|
|
507
|
+ {
|
|
508
|
+ if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
|
|
509
|
+ {
|
|
510
|
+ linechanging=!linechanging;
|
|
511
|
+ if(linechanging)
|
|
512
|
+ {
|
|
513
|
+ encoderpos=feedmultiply;
|
|
514
|
+ }
|
|
515
|
+ else
|
|
516
|
+ {
|
|
517
|
+ encoderpos=activeline*lcdslow;
|
|
518
|
+ beepshort();
|
|
519
|
+ }
|
|
520
|
+ BLOCK;
|
|
521
|
+ }
|
|
522
|
+ if(linechanging)
|
|
523
|
+ {
|
|
524
|
+ if(encoderpos<1) encoderpos=1;
|
|
525
|
+ if(encoderpos>400) encoderpos=400;
|
|
526
|
+ feedmultiply = encoderpos;
|
|
527
|
+ feedmultiplychanged=true;
|
|
528
|
+ lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
529
|
+ }
|
|
530
|
+ }
|
|
531
|
+ }break;
|
|
532
|
+ case ItemT_nozzle:
|
|
533
|
+ {
|
|
534
|
+ if(force_lcd_update)
|
|
535
|
+ {
|
|
536
|
+ lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
|
|
537
|
+ lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
|
|
538
|
+ }
|
|
539
|
+
|
|
540
|
+ if((activeline==line) )
|
|
541
|
+ {
|
|
542
|
+ if(CLICKED)
|
|
543
|
+ {
|
|
544
|
+ linechanging=!linechanging;
|
|
545
|
+ if(linechanging)
|
|
546
|
+ {
|
|
547
|
+ encoderpos=intround(degTargetHotend0());
|
|
548
|
+ }
|
|
549
|
+ else
|
|
550
|
+ {
|
|
551
|
+ setTargetHotend0(encoderpos);
|
|
552
|
+ encoderpos=activeline*lcdslow;
|
|
553
|
+ beepshort();
|
|
554
|
+ }
|
|
555
|
+ BLOCK;
|
|
556
|
+ }
|
|
557
|
+ if(linechanging)
|
|
558
|
+ {
|
|
559
|
+ if(encoderpos<0) encoderpos=0;
|
|
560
|
+ if(encoderpos>260) encoderpos=260;
|
|
561
|
+ lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
562
|
+ }
|
|
563
|
+ }
|
|
564
|
+ }break;
|
|
565
|
+
|
|
566
|
+ case ItemT_fan:
|
|
567
|
+ {
|
|
568
|
+ if(force_lcd_update)
|
|
569
|
+ {
|
|
570
|
+ lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
|
|
571
|
+ lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ if((activeline==line) )
|
|
575
|
+ {
|
|
576
|
+ if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
|
|
577
|
+ {
|
|
578
|
+ linechanging=!linechanging;
|
|
579
|
+ if(linechanging)
|
|
580
|
+ {
|
|
581
|
+ encoderpos=fanpwm;
|
|
582
|
+ }
|
|
583
|
+ else
|
|
584
|
+ {
|
|
585
|
+ encoderpos=activeline*lcdslow;
|
|
586
|
+ beepshort();
|
|
587
|
+ }
|
|
588
|
+ BLOCK;
|
|
589
|
+ }
|
|
590
|
+ if(linechanging)
|
|
591
|
+ {
|
|
592
|
+ if(encoderpos<0) encoderpos=0;
|
|
593
|
+ if(encoderpos>255) encoderpos=255;
|
|
594
|
+ fanpwm=encoderpos;
|
|
595
|
+ analogWrite(FAN_PIN, fanpwm);
|
|
596
|
+ lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
|
|
597
|
+ }
|
|
598
|
+ }
|
|
599
|
+ }break;
|
|
600
|
+ case ItemT_flow://axis_steps_per_unit[i] = code_value();
|
|
601
|
+ {
|
|
602
|
+ if(force_lcd_update)
|
|
603
|
+ {
|
|
604
|
+ lcd.setCursor(0,line);lcdprintPGM(" Flow:");
|
|
605
|
+ lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
|
|
606
|
+ }
|
|
607
|
+
|
|
608
|
+ if((activeline==line) )
|
|
609
|
+ {
|
|
610
|
+ if(CLICKED)
|
|
611
|
+ {
|
|
612
|
+ linechanging=!linechanging;
|
|
613
|
+ if(linechanging)
|
|
614
|
+ {
|
|
615
|
+ encoderpos=(int)axis_steps_per_unit[3];
|
|
616
|
+ }
|
|
617
|
+ else
|
|
618
|
+ {
|
|
619
|
+ float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
|
|
620
|
+ position[E_AXIS]=lround(position[E_AXIS]*factor);
|
|
621
|
+ //current_position[3]*=factor;
|
|
622
|
+ axis_steps_per_unit[E_AXIS]= encoderpos;
|
|
623
|
+ encoderpos=activeline*lcdslow;
|
|
624
|
+
|
|
625
|
+ }
|
|
626
|
+ BLOCK;
|
|
627
|
+ beepshort();
|
|
628
|
+ }
|
|
629
|
+ if(linechanging)
|
|
630
|
+ {
|
|
631
|
+ if(encoderpos<5) encoderpos=5;
|
|
632
|
+ if(encoderpos>9999) encoderpos=9999;
|
|
633
|
+ lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
|
|
634
|
+ }
|
|
635
|
+ }
|
|
636
|
+ }break;
|
|
637
|
+ default:
|
|
638
|
+ break;
|
|
639
|
+ }
|
|
640
|
+ line++;
|
|
641
|
+ }
|
|
642
|
+ updateActiveLines(ItemT_fan,encoderpos);
|
|
643
|
+}
|
474
|
644
|
|
475
|
645
|
//does not work
|
476
|
646
|
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
|
|
@@ -510,7 +680,7 @@ void MainMenu::showControlTemp()
|
510
|
680
|
if(force_lcd_update)
|
511
|
681
|
{
|
512
|
682
|
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
|
513
|
|
- lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0())));
|
|
683
|
+ lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
|
514
|
684
|
}
|
515
|
685
|
|
516
|
686
|
if((activeline==line) )
|
|
@@ -520,7 +690,7 @@ void MainMenu::showControlTemp()
|
520
|
690
|
linechanging=!linechanging;
|
521
|
691
|
if(linechanging)
|
522
|
692
|
{
|
523
|
|
- encoderpos=intround(degHotend0());
|
|
693
|
+ encoderpos=intround(degTargetHotend0());
|
524
|
694
|
}
|
525
|
695
|
else
|
526
|
696
|
{
|
|
@@ -558,10 +728,7 @@ void MainMenu::showControlTemp()
|
558
|
728
|
}
|
559
|
729
|
else
|
560
|
730
|
{
|
561
|
|
- fanpwm = constrain(encoderpos,0,255);
|
562
|
|
- encoderpos=fanpwm;
|
563
|
|
- analogWrite(FAN_PIN, fanpwm);
|
564
|
|
-
|
|
731
|
+ encoderpos=activeline*lcdslow;
|
565
|
732
|
beepshort();
|
566
|
733
|
}
|
567
|
734
|
BLOCK;
|
|
@@ -1246,7 +1413,22 @@ void MainMenu::showMainMenu()
|
1246
|
1413
|
#ifndef ULTIPANEL
|
1247
|
1414
|
force_lcd_update=false;
|
1248
|
1415
|
#endif
|
1249
|
|
-
|
|
1416
|
+ if(tune)
|
|
1417
|
+ {
|
|
1418
|
+ if(!(movesplanned() ||card.sdprinting))
|
|
1419
|
+ {
|
|
1420
|
+ force_lcd_update=true;
|
|
1421
|
+ tune=false;
|
|
1422
|
+ }
|
|
1423
|
+ }
|
|
1424
|
+ else
|
|
1425
|
+ {
|
|
1426
|
+ if(movesplanned() ||card.sdprinting)
|
|
1427
|
+ {
|
|
1428
|
+ force_lcd_update=true;
|
|
1429
|
+ tune=true;
|
|
1430
|
+ }
|
|
1431
|
+ }
|
1250
|
1432
|
clearIfNecessary();
|
1251
|
1433
|
for(int8_t line=0;line<LCD_HEIGHT;line++)
|
1252
|
1434
|
{
|
|
@@ -1256,7 +1438,7 @@ void MainMenu::showMainMenu()
|
1256
|
1438
|
MENUITEM( lcdprintPGM(" Watch") , BLOCK;status=Main_Status;beepshort(); ) ;
|
1257
|
1439
|
break;
|
1258
|
1440
|
case ItemM_prepare:
|
1259
|
|
- MENUITEM( lcdprintPGM(" Prepare \x7E") , BLOCK;status=Main_Prepare;beepshort(); ) ;
|
|
1441
|
+ MENUITEM( if(!tune) lcdprintPGM(" Prepare \x7E");else lcdprintPGM(" Tune \x7E"); , BLOCK;status=Main_Prepare;beepshort(); ) ;
|
1260
|
1442
|
break;
|
1261
|
1443
|
|
1262
|
1444
|
case ItemM_control:
|
|
@@ -1363,7 +1545,14 @@ void MainMenu::update()
|
1363
|
1545
|
}break;
|
1364
|
1546
|
case Main_Prepare:
|
1365
|
1547
|
{
|
1366
|
|
- showPrepare();
|
|
1548
|
+ if(tune)
|
|
1549
|
+ {
|
|
1550
|
+ showTune();
|
|
1551
|
+ }
|
|
1552
|
+ else
|
|
1553
|
+ {
|
|
1554
|
+ showPrepare();
|
|
1555
|
+ }
|
1367
|
1556
|
}break;
|
1368
|
1557
|
case Main_Control:
|
1369
|
1558
|
{
|
|
@@ -1478,26 +1667,6 @@ char *ftostr51(const float &x)
|
1478
|
1667
|
return conv;
|
1479
|
1668
|
}
|
1480
|
1669
|
|
1481
|
|
-char *fillto(int8_t n,char *c)
|
1482
|
|
-{
|
1483
|
|
- static char ret[25];
|
1484
|
|
- bool endfound=false;
|
1485
|
|
- for(int8_t i=0;i<n;i++)
|
1486
|
|
- {
|
1487
|
|
- ret[i]=c[i];
|
1488
|
|
- if(c[i]==0)
|
1489
|
|
- {
|
1490
|
|
- endfound=true;
|
1491
|
|
- }
|
1492
|
|
- if(endfound)
|
1493
|
|
- {
|
1494
|
|
- ret[i]=' ';
|
1495
|
|
- }
|
1496
|
|
- }
|
1497
|
|
- ret[n]=0;
|
1498
|
|
- return ret;
|
1499
|
|
-}
|
1500
|
|
-
|
1501
|
1670
|
|
1502
|
1671
|
#endif //ULTRA_LCD
|
1503
|
1672
|
|