Selaa lähdekoodia

make tuneing sub-menu.

Bernhard Kubicek 13 vuotta sitten
vanhempi
commit
379ea642e1
5 muutettua tiedostoa jossa 216 lisäystä ja 37 poistoa
  1. 3
    1
      Marlin/cardreader.pde
  2. 4
    0
      Marlin/planner.cpp
  3. 1
    0
      Marlin/planner.h
  4. 8
    5
      Marlin/ultralcd.h
  5. 200
    31
      Marlin/ultralcd.pde

+ 3
- 1
Marlin/cardreader.pde Näytä tiedosto

@@ -252,10 +252,11 @@ void CardReader::openFile(char* name,bool read)
252 252
       sdpos = 0;
253 253
       
254 254
       SERIAL_PROTOCOLLNPGM("File selected");
255
+      LCD_MESSAGE(fname);
255 256
     }
256 257
     else
257 258
     {
258
-     SERIAL_PROTOCOLPGM("open failed, File: ");
259
+      SERIAL_PROTOCOLPGM("open failed, File: ");
259 260
       SERIAL_PROTOCOL(fname);
260 261
       SERIAL_PROTOCOLLNPGM(".");
261 262
     }
@@ -273,6 +274,7 @@ void CardReader::openFile(char* name,bool read)
273 274
       saving = true;
274 275
       SERIAL_PROTOCOLPGM("Writing to file: ");
275 276
       SERIAL_PROTOCOLLN(name);
277
+      LCD_MESSAGE(fname);
276 278
     }
277 279
   }
278 280
   

+ 4
- 0
Marlin/planner.cpp Näytä tiedosto

@@ -762,3 +762,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
762 762
   previous_speed[3] = 0.0;
763 763
 }
764 764
 
765
+uint8_t movesplanned()
766
+{
767
+ return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
768
+}

+ 1
- 0
Marlin/planner.h Näytä tiedosto

@@ -80,6 +80,7 @@ void plan_discard_current_block();
80 80
 block_t *plan_get_current_block();
81 81
 
82 82
 void check_axes_activity();
83
+uint8_t movesplanned();
83 84
 
84 85
 extern unsigned long minsegmenttime;
85 86
 extern float max_feedrate[4]; // set the max speeds

+ 8
- 5
Marlin/ultralcd.h Näytä tiedosto

@@ -64,6 +64,7 @@
64 64
     void showStatus();
65 65
     void showMainMenu();
66 66
     void showPrepare();
67
+    void showTune();
67 68
     void showControl();
68 69
     void showControlMotion();
69 70
     void showControlTemp();
@@ -75,6 +76,8 @@
75 76
     
76 77
     bool linechanging;
77 78
     
79
+    bool tune;
80
+    
78 81
   private:
79 82
     inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
80 83
     {
@@ -89,8 +92,7 @@
89 92
         {  
90 93
           lineoffset--; 
91 94
           if(lineoffset<0) lineoffset=0; 
92
-          curencoderpos=lcdslow-1; 
93
-          force_lcd_update=true; 
95
+          curencoderpos=lcdslow-1;
94 96
         } 
95 97
         if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow) 
96 98
         { 
@@ -100,9 +102,9 @@
100 102
             lineoffset=maxlines+1-LCD_HEIGHT; 
101 103
           if(curencoderpos>maxlines*lcdslow) 
102 104
             curencoderpos=maxlines*lcdslow; 
103
-          force_lcd_update=true; 
104 105
         } 
105
-        lastencoderpos=encoderpos=curencoderpos; 
106
+        lastencoderpos=encoderpos=curencoderpos;
107
+        int lastactiveline=activeline;
106 108
         activeline=curencoderpos/lcdslow;
107 109
         if(activeline<0) activeline=0;
108 110
         if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
@@ -111,6 +113,8 @@
111 113
           activeline=maxlines;
112 114
           curencoderpos=maxlines*lcdslow;
113 115
         }
116
+        if(lastactiveline!=activeline ||lastlineoffset!=lineoffset)
117
+          force_lcd_update=true;
114 118
         lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');    
115 119
       } 
116 120
     }
@@ -126,7 +130,6 @@
126 130
   };
127 131
 
128 132
   //conversion routines, could need some overworking
129
-  char *fillto(int8_t n,char *c);
130 133
   char *ftostr51(const float &x);
131 134
   char *ftostr31(const float &x);
132 135
   char *ftostr3(const float &x);

+ 200
- 31
Marlin/ultralcd.pde Näytä tiedosto

@@ -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
 

Loading…
Peruuta
Tallenna