Browse Source

make tuneing sub-menu.

Bernhard Kubicek 13 years ago
parent
commit
379ea642e1
5 changed files with 216 additions and 37 deletions
  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 View File

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

+ 4
- 0
Marlin/planner.cpp View File

762
   previous_speed[3] = 0.0;
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 View File

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

+ 8
- 5
Marlin/ultralcd.h View File

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

+ 200
- 31
Marlin/ultralcd.pde View File

65
 void lcd_status(const char* message)
65
 void lcd_status(const char* message)
66
 {
66
 {
67
   strncpy(messagetext,message,LCD_WIDTH);
67
   strncpy(messagetext,message,LCD_WIDTH);
68
+  messagetext[strlen(message)]=0;
68
 }
69
 }
69
 
70
 
70
 void lcd_statuspgm(const char* message)
71
 void lcd_statuspgm(const char* message)
79
     cnt++;
80
     cnt++;
80
     ch=pgm_read_byte(++message);
81
     ch=pgm_read_byte(++message);
81
   }
82
   }
83
+  *target=0;
82
 }
84
 }
83
 
85
 
84
 inline void clear()
86
 inline void clear()
280
   #endif
282
   #endif
281
   lcd_init();
283
   lcd_init();
282
   linechanging=false;
284
   linechanging=false;
285
+  tune=false;
283
 }
286
 }
284
 
287
 
285
 void MainMenu::showStatus()
288
 void MainMenu::showStatus()
373
   if(messagetext[0]!='\0')
376
   if(messagetext[0]!='\0')
374
   {
377
   {
375
     lcd.setCursor(0,LCD_HEIGHT-1);
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
     messagetext[0]='\0';
384
     messagetext[0]='\0';
378
   }
385
   }
379
   
386
   
419
   if(messagetext[0]!='\0')
426
   if(messagetext[0]!='\0')
420
   {
427
   {
421
     lcd.setCursor(0,LCD_HEIGHT-1);
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
     messagetext[0]='\0';
433
     messagetext[0]='\0';
424
   }
434
   }
425
 
435
 
471
  updateActiveLines(ItemP_disstep,encoderpos);
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
 //does not work
645
 //does not work
476
 // #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
646
 // #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
510
         if(force_lcd_update)
680
         if(force_lcd_update)
511
         {
681
         {
512
           lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
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
         if((activeline==line) )
686
         if((activeline==line) )
520
             linechanging=!linechanging;
690
             linechanging=!linechanging;
521
             if(linechanging)
691
             if(linechanging)
522
             {
692
             {
523
-               encoderpos=intround(degHotend0());
693
+               encoderpos=intround(degTargetHotend0());
524
             }
694
             }
525
             else
695
             else
526
             {
696
             {
558
             }
728
             }
559
             else
729
             else
560
             {
730
             {
561
-              fanpwm = constrain(encoderpos,0,255);
562
-              encoderpos=fanpwm;
563
-              analogWrite(FAN_PIN,  fanpwm);
564
-
731
+              encoderpos=activeline*lcdslow;
565
               beepshort();
732
               beepshort();
566
             }
733
             }
567
             BLOCK;
734
             BLOCK;
1246
   #ifndef ULTIPANEL
1413
   #ifndef ULTIPANEL
1247
     force_lcd_update=false;
1414
     force_lcd_update=false;
1248
   #endif
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
   clearIfNecessary();
1432
   clearIfNecessary();
1251
   for(int8_t line=0;line<LCD_HEIGHT;line++)
1433
   for(int8_t line=0;line<LCD_HEIGHT;line++)
1252
   {
1434
   {
1256
         MENUITEM(  lcdprintPGM(" Watch")  ,  BLOCK;status=Main_Status;beepshort(); ) ;
1438
         MENUITEM(  lcdprintPGM(" Watch")  ,  BLOCK;status=Main_Status;beepshort(); ) ;
1257
        break;
1439
        break;
1258
       case ItemM_prepare:
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
       break;
1442
       break;
1261
        
1443
        
1262
       case ItemM_control:
1444
       case ItemM_control:
1363
       }break;
1545
       }break;
1364
       case Main_Prepare: 
1546
       case Main_Prepare: 
1365
       {
1547
       {
1366
-        showPrepare(); 
1548
+        if(tune)
1549
+        {
1550
+          showTune();
1551
+        }
1552
+        else
1553
+        {
1554
+          showPrepare(); 
1555
+        }
1367
       }break;
1556
       }break;
1368
       case Main_Control:
1557
       case Main_Control:
1369
       {
1558
       {
1478
   return conv;
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
 #endif //ULTRA_LCD
1671
 #endif //ULTRA_LCD
1503
 
1672
 

Loading…
Cancel
Save