Sfoglia il codice sorgente

made ultralcd compatible with folders.

Bernhard Kubicek 12 anni fa
parent
commit
b21d5193f2
4 ha cambiato i file con 339 aggiunte e 195 eliminazioni
  1. 4
    2
      Marlin/cardreader.h
  2. 80
    35
      Marlin/cardreader.pde
  3. 4
    2
      Marlin/ultralcd.h
  4. 251
    156
      Marlin/ultralcd.pde

+ 4
- 2
Marlin/cardreader.h Vedi File

@@ -28,7 +28,8 @@ public:
28 28
   
29 29
 
30 30
   void ls();
31
-  
31
+  void chdir(const char * relpath);
32
+  void updir();
32 33
 
33 34
   inline bool eof() { return sdpos>=filesize ;};
34 35
   inline int16_t get() {  sdpos = file.curPosition();return (int16_t)file.read();};
@@ -40,8 +41,9 @@ public:
40 41
   bool sdprinting ;  
41 42
   bool cardOK ;
42 43
   char filename[11];
44
+  bool filenameIsDir;
43 45
 private:
44
-  SdFile root,*curDir;
46
+  SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
45 47
   Sd2Card card;
46 48
   SdVolume volume;
47 49
   SdFile file;

+ 80
- 35
Marlin/cardreader.pde Vedi File

@@ -1,4 +1,5 @@
1 1
 #include "cardreader.h"
2
+//#include <unistd.h>
2 3
 #ifdef SDSUPPORT
3 4
 
4 5
 CardReader::CardReader()
@@ -36,11 +37,7 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
36 37
   return buffer;
37 38
 }
38 39
 
39
-// bool SdFat::chdir(bool set_cwd) {
40
-//   if (set_cwd) SdBaseFile::cwd_ = &vwd_;
41
-//   vwd_.close();
42
-//   return vwd_.openRoot(&vol_);
43
-// }
40
+
44 41
 void  CardReader::lsDive(char *prepend,SdFile parent)
45 42
 {
46 43
   dir_t p;
@@ -85,11 +82,19 @@ void  CardReader::lsDive(char *prepend,SdFile parent)
85 82
     {
86 83
       if (p.name[0] == DIR_NAME_FREE) break;
87 84
       if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
85
+      if ( p.name[0] == '.')
86
+      {
87
+        if ( p.name[1] != '.')
88
+        continue;
89
+      }
88 90
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
91
+      filenameIsDir=DIR_IS_SUBDIR(&p);
89 92
       
90
-      
91
-      if(p.name[8]!='G') continue;
92
-      if(p.name[9]=='~') continue;
93
+      if(!filenameIsDir)
94
+      {
95
+        if(p.name[8]!='G') continue;
96
+        if(p.name[9]=='~') continue;
97
+      }
93 98
       //if(cnt++!=nr) continue;
94 99
       createFilename(filename,p);
95 100
       if(lsAction==LS_SerialPrint)
@@ -126,33 +131,35 @@ void CardReader::ls()
126 131
 void CardReader::initsd()
127 132
 {
128 133
   cardOK = false;
129
-  #if SDSS >- 1
130
-    if(root.isOpen())
131
-      root.close();
132
-    if (!card.init(SPI_FULL_SPEED,SDSS))
133
-    {
134
-      //if (!card.init(SPI_HALF_SPEED,SDSS))
135
-      SERIAL_ECHO_START;
136
-      SERIAL_ECHOLNPGM("SD init fail");
137
-    }
138
-    else if (!volume.init(&card))
139
-    {
140
-      SERIAL_ERROR_START;
141
-      SERIAL_ERRORLNPGM("volume.init failed");
142
-    }
143
-    else if (!root.openRoot(&volume)) 
144
-    {
145
-      SERIAL_ERROR_START;
146
-      SERIAL_ERRORLNPGM("openRoot failed");
147
-    }
148
-    else 
149
-    {
150
-      cardOK = true;
151
-      SERIAL_ECHO_START;
152
-      SERIAL_ECHOLNPGM("SD card ok");
153
-    }
154
-    curDir=&root;
155
-  #endif //SDSS
134
+  if(root.isOpen())
135
+    root.close();
136
+  if (!card.init(SPI_FULL_SPEED,SDSS))
137
+  {
138
+    //if (!card.init(SPI_HALF_SPEED,SDSS))
139
+    SERIAL_ECHO_START;
140
+    SERIAL_ECHOLNPGM("SD init fail");
141
+  }
142
+  else if (!volume.init(&card))
143
+  {
144
+    SERIAL_ERROR_START;
145
+    SERIAL_ERRORLNPGM("volume.init failed");
146
+  }
147
+  else if (!root.openRoot(&volume)) 
148
+  {
149
+    SERIAL_ERROR_START;
150
+    SERIAL_ERRORLNPGM("openRoot failed");
151
+  }
152
+  else 
153
+  {
154
+    cardOK = true;
155
+    SERIAL_ECHO_START;
156
+    SERIAL_ECHOLNPGM("SD card ok");
157
+  }
158
+  curDir=&root;
159
+  if(!workDir.openRoot(&volume))
160
+  {
161
+    SERIAL_ECHOLNPGM("workDir open failed");
162
+  }
156 163
 }
157 164
 void CardReader::release()
158 165
 {
@@ -229,6 +236,10 @@ void CardReader::openFile(char* name,bool read)
229 236
       
230 237
     }
231 238
   }
239
+  else //relative path
240
+  {
241
+    curDir=&workDir;
242
+  }
232 243
   if(read)
233 244
   {
234 245
     if (file.open(curDir, fname, O_READ)) 
@@ -362,6 +373,7 @@ void CardReader::closefile()
362 373
 
363 374
 void CardReader::getfilename(const uint8_t nr)
364 375
 {
376
+  curDir=&workDir;
365 377
   lsAction=LS_GetFilename;
366 378
   nrFiles=nr;
367 379
   curDir->rewind();
@@ -371,12 +383,45 @@ void CardReader::getfilename(const uint8_t nr)
371 383
 
372 384
 uint16_t CardReader::getnrfilenames()
373 385
 {
386
+  curDir=&workDir;
374 387
   lsAction=LS_Count;
375 388
   nrFiles=0;
376 389
   curDir->rewind();
377 390
   lsDive("",*curDir);
391
+  //SERIAL_ECHOLN(nrFiles);
378 392
   return nrFiles;
379 393
 }
380 394
 
395
+void CardReader::chdir(const char * relpath)
396
+{
397
+  SdFile newfile;
398
+  SdFile *parent=&root;
399
+  
400
+  if(workDir.isOpen())
401
+    parent=&workDir;
402
+  
403
+  if(!newfile.open(*parent,relpath, O_READ))
404
+  {
405
+   SERIAL_ECHO_START;
406
+   SERIAL_ECHOPGM("Cannot enter subdir:");
407
+   SERIAL_ECHOLN(relpath);
408
+  }
409
+  else
410
+  {
411
+    workDirParentParent=workDirParent;
412
+    workDirParent=*parent;
413
+    
414
+    workDir=newfile;
415
+  }
416
+}
417
+
418
+void CardReader::updir()
419
+{
420
+  if(!workDir.isRoot())
421
+  {
422
+    workDir=workDirParent;
423
+    workDirParent=workDirParentParent;
424
+  }
425
+}
381 426
 
382 427
 #endif //SDSUPPORT

+ 4
- 2
Marlin/ultralcd.h Vedi File

@@ -51,13 +51,13 @@
51 51
   #define blocktime 500
52 52
   #define lcdslow 5
53 53
     
54
-  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};
54
+  enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
55 55
 
56 56
   class MainMenu{
57 57
   public:
58 58
     MainMenu();
59 59
     void update();
60
-    uint8_t activeline;
60
+    int8_t activeline;
61 61
     MainStatus status;
62 62
     uint8_t displayStartingRow;
63 63
     
@@ -65,6 +65,8 @@
65 65
     void showMainMenu();
66 66
     void showPrepare();
67 67
     void showControl();
68
+    void showControlMotion();
69
+    void showControlTemp();
68 70
     void showSD();
69 71
     bool force_lcd_update;
70 72
     int lastencoderpos;

+ 251
- 156
Marlin/ultralcd.pde Vedi File

@@ -114,11 +114,13 @@ void lcd_init()
114 114
   };
115 115
   byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
116 116
   byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
117
+  byte folder [8]={0x00, 0x1c, 0x1f, 0x11, 0x11, 0x1f, 0x00, 0x00}; //thanks joris
117 118
   lcd.begin(LCD_WIDTH, LCD_HEIGHT);
118 119
   lcd.createChar(1,Degree);
119 120
   lcd.createChar(2,Thermometer);
120 121
   lcd.createChar(3,uplevel);
121 122
   lcd.createChar(4,refresh);
123
+  lcd.createChar(5,folder);
122 124
   LCD_MESSAGEPGM("UltiMarlin ready.");
123 125
 }
124 126
 
@@ -224,6 +226,7 @@ void buttons_check()
224 226
     buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
225 227
   #endif
226 228
   
229
+  //manage encoder rotation
227 230
   char enc=0;
228 231
   if(buttons&EN_A)
229 232
     enc|=(1<<0);
@@ -311,22 +314,22 @@ void MainMenu::showStatus()
311 314
     oldtargetHotEnd0=ttHotEnd0;
312 315
   }
313 316
   #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
314
-  static int oldtBed=-1;
315
-  static int oldtargetBed=-1; 
316
-  int tBed=intround(degBed());
317
-  if((tBed!=oldtBed)||force_lcd_update)
318
-  {
319
-    lcd.setCursor(1,0);
320
-    lcd.print(ftostr3(tBed));
321
-    olddegHotEnd0=tBed;
322
-  }
323
-  int targetBed=intround(degTargetBed());
324
-  if((targetBed!=oldtargetBed)||force_lcd_update)
325
-  {
326
-    lcd.setCursor(5,0);
327
-    lcd.print(ftostr3(targetBed));
328
-    oldtargetBed=targetBed;
329
-  }
317
+    static int oldtBed=-1;
318
+    static int oldtargetBed=-1; 
319
+    int tBed=intround(degBed());
320
+    if((tBed!=oldtBed)||force_lcd_update)
321
+    {
322
+      lcd.setCursor(1,0);
323
+      lcd.print(ftostr3(tBed));
324
+      oldtBed=tBed;
325
+    }
326
+    int targetBed=intround(degTargetBed());
327
+    if((targetBed!=oldtargetBed)||force_lcd_update)
328
+    {
329
+      lcd.setCursor(5,0);
330
+      lcd.print(ftostr3(targetBed));
331
+      oldtargetBed=targetBed;
332
+    }
330 333
   #endif
331 334
   //starttime=2;
332 335
   static uint16_t oldtime=0;
@@ -421,6 +424,7 @@ void MainMenu::showStatus()
421 424
   }
422 425
 
423 426
 #endif
427
+  force_lcd_update=false;
424 428
 }
425 429
 
426 430
 enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
@@ -466,16 +470,7 @@ void MainMenu::showPrepare()
466 470
  }
467 471
  updateActiveLines(ItemP_disstep,encoderpos);
468 472
 }
469
-enum {
470
-  ItemC_exit, ItemC_nozzle, 
471
-  ItemC_PID_P,ItemC_PID_I,ItemC_PID_D,ItemC_PID_C,
472
-  ItemC_fan, 
473
-  ItemC_acc, ItemC_xyjerk, 
474
-  ItemC_vmaxx, ItemC_vmaxy, ItemC_vmaxz, ItemC_vmaxe, 
475
-  ItemC_vtravmin,ItemC_vmin,  
476
-  ItemC_amaxx, ItemC_amaxy, ItemC_amaxz, ItemC_amaxe, 
477
-  ItemC_aret,ItemC_esteps, ItemC_store, ItemC_load,ItemC_failsafe
478
-};
473
+
479 474
 
480 475
 //does not work
481 476
 // #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
@@ -494,19 +489,23 @@ enum {
494 489
 //   }
495 490
 //   
496 491
 
497
-  
498
-void MainMenu::showControl()
492
+enum {
493
+  ItemCT_exit, ItemCT_nozzle, ItemCT_fan,
494
+  ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
495
+};
496
+
497
+void MainMenu::showControlTemp()
499 498
 {
500
- uint8_t line=0;
499
+  uint8_t line=0;
501 500
  clearIfNecessary();
502 501
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
503 502
  {
504 503
   switch(i)
505 504
   {
506
-    case ItemC_exit:
507
-      MENUITEM(  lcdprintPGM(" Control")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
505
+    case ItemCT_exit:
506
+      MENUITEM(  lcdprintPGM(" Temperature")  ,  BLOCK;status=Main_Control;beepshort(); ) ;
508 507
       break;
509
-    case ItemC_nozzle:
508
+    case ItemCT_nozzle:
510 509
       {
511 510
         if(force_lcd_update)
512 511
         {
@@ -540,7 +539,7 @@ void MainMenu::showControl()
540 539
         }
541 540
       }break;
542 541
       
543
-      case ItemC_fan:
542
+      case ItemCT_fan:
544 543
       {
545 544
         if(force_lcd_update)
546 545
         {
@@ -577,12 +576,12 @@ void MainMenu::showControl()
577 576
           }
578 577
         }
579 578
       }break;
580
-    case ItemC_acc:
581
-    {
579
+      case ItemCT_PID_P: 
580
+      {
582 581
       if(force_lcd_update)
583 582
         {
584
-          lcd.setCursor(0,line);lcdprintPGM(" Acc:");
585
-          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
583
+          lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
584
+          lcd.setCursor(13,line);lcd.print(itostr4(Kp));
586 585
         }
587 586
         
588 587
         if((activeline==line) )
@@ -592,30 +591,31 @@ void MainMenu::showControl()
592 591
             linechanging=!linechanging;
593 592
             if(linechanging)
594 593
             {
595
-               encoderpos=(int)acceleration/100;
594
+               encoderpos=(int)Kp/5;
596 595
             }
597 596
             else
598 597
             {
599
-              acceleration= encoderpos*100;
598
+              Kp= encoderpos*5;
600 599
               encoderpos=activeline*lcdslow;
600
+                
601 601
             }
602 602
             BLOCK;
603 603
             beepshort();
604 604
           }
605 605
           if(linechanging)
606 606
           {
607
-            if(encoderpos<5) encoderpos=5;
608
-            if(encoderpos>990) encoderpos=990;
609
-            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
607
+            if(encoderpos<1) encoderpos=1;
608
+            if(encoderpos>9990/5) encoderpos=9990/5;
609
+            lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
610 610
           }
611 611
         }
612 612
       }break;
613
-    case ItemC_xyjerk: //max_xy_jerk
613
+    case ItemCT_PID_I: 
614 614
       {
615 615
       if(force_lcd_update)
616 616
         {
617
-          lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
618
-          lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
617
+          lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
618
+          lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
619 619
         }
620 620
         
621 621
         if((activeline==line) )
@@ -625,11 +625,11 @@ void MainMenu::showControl()
625 625
             linechanging=!linechanging;
626 626
             if(linechanging)
627 627
             {
628
-               encoderpos=(int)max_xy_jerk;
628
+               encoderpos=(int)(Ki*10);
629 629
             }
630 630
             else
631 631
             {
632
-              max_xy_jerk= encoderpos;
632
+              Ki= encoderpos/10.;
633 633
               encoderpos=activeline*lcdslow;
634 634
                 
635 635
             }
@@ -638,18 +638,18 @@ void MainMenu::showControl()
638 638
           }
639 639
           if(linechanging)
640 640
           {
641
-            if(encoderpos<1) encoderpos=1;
642
-            if(encoderpos>990) encoderpos=990;
643
-            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
641
+            if(encoderpos<0) encoderpos=0;
642
+            if(encoderpos>9990) encoderpos=9990;
643
+            lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
644 644
           }
645 645
         }
646 646
       }break;
647
-      case ItemC_PID_P: 
647
+      case ItemCT_PID_D: 
648 648
       {
649 649
       if(force_lcd_update)
650 650
         {
651
-          lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
652
-          lcd.setCursor(13,line);lcd.print(itostr4(Kp));
651
+          lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
652
+          lcd.setCursor(13,line);lcd.print(itostr4(Kd));
653 653
         }
654 654
         
655 655
         if((activeline==line) )
@@ -659,11 +659,11 @@ void MainMenu::showControl()
659 659
             linechanging=!linechanging;
660 660
             if(linechanging)
661 661
             {
662
-               encoderpos=(int)Kp/5;
662
+               encoderpos=(int)Kd/5;
663 663
             }
664 664
             else
665 665
             {
666
-              Kp= encoderpos*5;
666
+              Kd= encoderpos*5;
667 667
               encoderpos=activeline*lcdslow;
668 668
                 
669 669
             }
@@ -672,18 +672,19 @@ void MainMenu::showControl()
672 672
           }
673 673
           if(linechanging)
674 674
           {
675
-            if(encoderpos<1) encoderpos=1;
675
+            if(encoderpos<0) encoderpos=0;
676 676
             if(encoderpos>9990/5) encoderpos=9990/5;
677 677
             lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
678 678
           }
679 679
         }
680
-      }break;
681
-    case ItemC_PID_I: 
680
+      }break;   
681
+    case ItemCT_PID_C: 
682
+      #ifdef PID_ADD_EXTRUSION_RATE
682 683
       {
683 684
       if(force_lcd_update)
684 685
         {
685
-          lcd.setCursor(0,line);lcdprintPGM(" PID-I: ");
686
-          lcd.setCursor(13,line);lcd.print(ftostr51(Ki));
686
+          lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
687
+          lcd.setCursor(13,line);lcd.print(itostr3(Kc));
687 688
         }
688 689
         
689 690
         if((activeline==line) )
@@ -693,11 +694,11 @@ void MainMenu::showControl()
693 694
             linechanging=!linechanging;
694 695
             if(linechanging)
695 696
             {
696
-               encoderpos=(int)(Ki*10);
697
+               encoderpos=(int)Kc;
697 698
             }
698 699
             else
699 700
             {
700
-              Ki= encoderpos/10.;
701
+              Kc= encoderpos;
701 702
               encoderpos=activeline*lcdslow;
702 703
                 
703 704
             }
@@ -707,17 +708,54 @@ void MainMenu::showControl()
707 708
           if(linechanging)
708 709
           {
709 710
             if(encoderpos<0) encoderpos=0;
710
-            if(encoderpos>9990) encoderpos=9990;
711
-            lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10.));
711
+            if(encoderpos>990) encoderpos=990;
712
+            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
712 713
           }
713 714
         }
714
-      }break;
715
-      case ItemC_PID_D: 
716
-      {
715
+      }
716
+      #endif
717
+      break;
718
+    default:   
719
+      break;
720
+  }
721
+  line++;
722
+ }
723
+ #ifdef PID_ADD_EXTRUSION_RATE
724
+  updateActiveLines(ItemCT_PID_C,encoderpos);
725
+ #else
726
+  updateActiveLines(ItemCT_PID_D,encoderpos);
727
+ #endif
728
+}
729
+
730
+
731
+enum {
732
+  ItemCM_exit, 
733
+  ItemCM_acc, ItemCM_xyjerk, 
734
+  ItemCM_vmaxx, ItemCM_vmaxy, ItemCM_vmaxz, ItemCM_vmaxe, 
735
+  ItemCM_vtravmin,ItemCM_vmin,  
736
+  ItemCM_amaxx, ItemCM_amaxy, ItemCM_amaxz, ItemCM_amaxe, 
737
+  ItemCM_aret,ItemCM_esteps
738
+};
739
+
740
+
741
+
742
+void MainMenu::showControlMotion()
743
+{
744
+ uint8_t line=0;
745
+ clearIfNecessary();
746
+ for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
747
+ {
748
+  switch(i)
749
+  {
750
+    case ItemCM_exit:
751
+      MENUITEM(  lcdprintPGM(" Motion")  ,  BLOCK;status=Main_Control;beepshort(); ) ;
752
+      break;
753
+    case ItemCM_acc:
754
+    {
717 755
       if(force_lcd_update)
718 756
         {
719
-          lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
720
-          lcd.setCursor(13,line);lcd.print(itostr4(Kd));
757
+          lcd.setCursor(0,line);lcdprintPGM(" Acc:");
758
+          lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
721 759
         }
722 760
         
723 761
         if((activeline==line) )
@@ -727,34 +765,30 @@ void MainMenu::showControl()
727 765
             linechanging=!linechanging;
728 766
             if(linechanging)
729 767
             {
730
-               encoderpos=(int)Kd/5;
768
+               encoderpos=(int)acceleration/100;
731 769
             }
732 770
             else
733 771
             {
734
-              Kd= encoderpos*5;
772
+              acceleration= encoderpos*100;
735 773
               encoderpos=activeline*lcdslow;
736
-                
737 774
             }
738 775
             BLOCK;
739 776
             beepshort();
740 777
           }
741 778
           if(linechanging)
742 779
           {
743
-            if(encoderpos<0) encoderpos=0;
744
-            if(encoderpos>9990/5) encoderpos=9990/5;
745
-            lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
780
+            if(encoderpos<5) encoderpos=5;
781
+            if(encoderpos>990) encoderpos=990;
782
+            lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
746 783
           }
747 784
         }
748 785
       }break;
749
-    
750
-    
751
-      
752
-    case ItemC_PID_C: 
786
+    case ItemCM_xyjerk: //max_xy_jerk
753 787
       {
754 788
       if(force_lcd_update)
755 789
         {
756
-          lcd.setCursor(0,line);lcdprintPGM(" PID-C: ");
757
-          lcd.setCursor(13,line);lcd.print(itostr3(Kc));
790
+          lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk: ");
791
+          lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
758 792
         }
759 793
         
760 794
         if((activeline==line) )
@@ -764,11 +798,11 @@ void MainMenu::showControl()
764 798
             linechanging=!linechanging;
765 799
             if(linechanging)
766 800
             {
767
-               encoderpos=(int)Kc;
801
+               encoderpos=(int)max_xy_jerk;
768 802
             }
769 803
             else
770 804
             {
771
-              Kc= encoderpos;
805
+              max_xy_jerk= encoderpos;
772 806
               encoderpos=activeline*lcdslow;
773 807
                 
774 808
             }
@@ -777,25 +811,26 @@ void MainMenu::showControl()
777 811
           }
778 812
           if(linechanging)
779 813
           {
780
-            if(encoderpos<0) encoderpos=0;
814
+            if(encoderpos<1) encoderpos=1;
781 815
             if(encoderpos>990) encoderpos=990;
782 816
             lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
783 817
           }
784 818
         }
785 819
       }break;
786
-    case ItemC_vmaxx:
787
-    case ItemC_vmaxy:
788
-    case ItemC_vmaxz:
789
-    case ItemC_vmaxe:
820
+      
821
+    case ItemCM_vmaxx:
822
+    case ItemCM_vmaxy:
823
+    case ItemCM_vmaxz:
824
+    case ItemCM_vmaxe:
790 825
       {
791 826
       if(force_lcd_update)
792 827
         {
793 828
           lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
794
-          if(i==ItemC_vmaxx)lcdprintPGM("x:");
795
-          if(i==ItemC_vmaxy)lcdprintPGM("y:");
796
-          if(i==ItemC_vmaxz)lcdprintPGM("z:");
797
-          if(i==ItemC_vmaxe)lcdprintPGM("e:");
798
-          lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemC_vmaxx]));
829
+          if(i==ItemCM_vmaxx)lcdprintPGM("x:");
830
+          if(i==ItemCM_vmaxy)lcdprintPGM("y:");
831
+          if(i==ItemCM_vmaxz)lcdprintPGM("z:");
832
+          if(i==ItemCM_vmaxe)lcdprintPGM("e:");
833
+          lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
799 834
         }
800 835
         
801 836
         if((activeline==line) )
@@ -805,11 +840,11 @@ void MainMenu::showControl()
805 840
             linechanging=!linechanging;
806 841
             if(linechanging)
807 842
             {
808
-               encoderpos=(int)max_feedrate[i-ItemC_vmaxx];
843
+               encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
809 844
             }
810 845
             else
811 846
             {
812
-              max_feedrate[i-ItemC_vmaxx]= encoderpos;
847
+              max_feedrate[i-ItemCM_vmaxx]= encoderpos;
813 848
               encoderpos=activeline*lcdslow;
814 849
                 
815 850
             }
@@ -825,7 +860,7 @@ void MainMenu::showControl()
825 860
         }
826 861
       }break;
827 862
     
828
-    case ItemC_vmin:
863
+    case ItemCM_vmin:
829 864
     {
830 865
       if(force_lcd_update)
831 866
         {
@@ -859,7 +894,7 @@ void MainMenu::showControl()
859 894
           }
860 895
         }
861 896
       }break;
862
-    case ItemC_vtravmin:
897
+    case ItemCM_vtravmin:
863 898
     {
864 899
       if(force_lcd_update)
865 900
         {
@@ -894,19 +929,19 @@ void MainMenu::showControl()
894 929
         }
895 930
       }break;
896 931
     
897
-    case ItemC_amaxx:      
898
-    case ItemC_amaxy:
899
-    case ItemC_amaxz:
900
-    case ItemC_amaxe:
932
+    case ItemCM_amaxx:      
933
+    case ItemCM_amaxy:
934
+    case ItemCM_amaxz:
935
+    case ItemCM_amaxe:
901 936
     {
902 937
       if(force_lcd_update)
903 938
         {
904 939
           lcd.setCursor(0,line);lcdprintPGM(" Amax ");
905
-          if(i==ItemC_amaxx)lcdprintPGM("x:");
906
-          if(i==ItemC_amaxy)lcdprintPGM("y:");
907
-          if(i==ItemC_amaxz)lcdprintPGM("z:");
908
-          if(i==ItemC_amaxe)lcdprintPGM("e:");
909
-          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100));lcdprintPGM("00");
940
+          if(i==ItemCM_amaxx)lcdprintPGM("x:");
941
+          if(i==ItemCM_amaxy)lcdprintPGM("y:");
942
+          if(i==ItemCM_amaxz)lcdprintPGM("z:");
943
+          if(i==ItemCM_amaxe)lcdprintPGM("e:");
944
+          lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
910 945
         }
911 946
         
912 947
         if((activeline==line) )
@@ -916,11 +951,11 @@ void MainMenu::showControl()
916 951
             linechanging=!linechanging;
917 952
             if(linechanging)
918 953
             {
919
-               encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100;
954
+               encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
920 955
             }
921 956
             else
922 957
             {
923
-              max_acceleration_units_per_sq_second[i-ItemC_amaxx]= encoderpos*100;
958
+              max_acceleration_units_per_sq_second[i-ItemCM_amaxx]= encoderpos*100;
924 959
               encoderpos=activeline*lcdslow;
925 960
             }
926 961
             BLOCK;
@@ -934,7 +969,7 @@ void MainMenu::showControl()
934 969
           }
935 970
         }
936 971
       }break;
937
-    case ItemC_aret://float retract_acceleration = 7000;
972
+    case ItemCM_aret://float retract_acceleration = 7000;
938 973
     {
939 974
         if(force_lcd_update)
940 975
         {
@@ -968,7 +1003,7 @@ void MainMenu::showControl()
968 1003
           }
969 1004
         }
970 1005
       }break;
971
-    case ItemC_esteps://axis_steps_per_unit[i] = code_value();
1006
+    case ItemCM_esteps://axis_steps_per_unit[i] = code_value();
972 1007
          {
973 1008
       if(force_lcd_update)
974 1009
         {
@@ -1005,6 +1040,37 @@ void MainMenu::showControl()
1005 1040
           }
1006 1041
         }
1007 1042
       }break; 
1043
+    default:   
1044
+      break;
1045
+  }
1046
+  line++;
1047
+ }
1048
+ updateActiveLines(ItemCM_esteps,encoderpos);
1049
+}
1050
+
1051
+
1052
+enum {
1053
+  ItemC_exit,ItemC_temp,ItemC_move,
1054
+  ItemC_store, ItemC_load,ItemC_failsafe
1055
+};
1056
+
1057
+void MainMenu::showControl()
1058
+{
1059
+ uint8_t line=0;
1060
+ clearIfNecessary();
1061
+ for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
1062
+ {
1063
+  switch(i)
1064
+  {
1065
+    case ItemC_exit:
1066
+      MENUITEM(  lcdprintPGM(" Control     \x7E")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
1067
+      break;
1068
+    case ItemC_temp:
1069
+      MENUITEM(  lcdprintPGM(" Temperature \x7E")  ,  BLOCK;status=Sub_TempControl;beepshort(); ) ;
1070
+      break;
1071
+   case ItemC_move:
1072
+      MENUITEM(  lcdprintPGM(" Motion      \x7E")  ,  BLOCK;status=Sub_MotionControl;beepshort(); ) ;
1073
+      break;
1008 1074
     case ItemC_store:
1009 1075
     {
1010 1076
       if(force_lcd_update)
@@ -1059,7 +1125,6 @@ void MainMenu::showControl()
1059 1125
 
1060 1126
 
1061 1127
 
1062
-
1063 1128
 void MainMenu::showSD()
1064 1129
 {
1065 1130
 #ifdef SDSUPPORT
@@ -1069,7 +1134,6 @@ void MainMenu::showSD()
1069 1134
  static uint8_t nrfiles=0;
1070 1135
  if(force_lcd_update)
1071 1136
  {
1072
-  clear();
1073 1137
   if(card.cardOK)
1074 1138
   {
1075 1139
     nrfiles=card.getnrfilenames();
@@ -1080,7 +1144,7 @@ void MainMenu::showSD()
1080 1144
     lineoffset=0;
1081 1145
   }
1082 1146
  }
1083
- 
1147
+ bool enforceupdate=false;
1084 1148
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
1085 1149
  {
1086 1150
   switch(i)
@@ -1088,58 +1152,76 @@ void MainMenu::showSD()
1088 1152
     case 0:
1089 1153
       MENUITEM(  lcdprintPGM(" File")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
1090 1154
       break;
1155
+//     case 1:
1156
+//       {
1157
+//         if(force_lcd_update)
1158
+//         {
1159
+//           lcd.setCursor(0,line);
1160
+//            #ifdef CARDINSERTED
1161
+//           if(CARDINSERTED)
1162
+//           #else
1163
+//           if(true)
1164
+//           #endif
1165
+//           {
1166
+//             lcdprintPGM(" \004Refresh");
1167
+//           }
1168
+//           else
1169
+//           {
1170
+//             lcdprintPGM(" \004Insert Card");
1171
+//           }
1172
+//           
1173
+//         }
1174
+//         if((activeline==line) && CLICKED)
1175
+//         {
1176
+//           BLOCK;
1177
+//           beepshort();
1178
+//           card.initsd();
1179
+//           force_lcd_update=true;
1180
+//            nrfiles=card.getnrfilenames();
1181
+//         }
1182
+//       }break;
1091 1183
     case 1:
1092
-      {
1093
-        if(force_lcd_update)
1094
-        {
1095
-          lcd.setCursor(0,line);
1096
-           #ifdef CARDINSERTED
1097
-          if(CARDINSERTED)
1098
-          #else
1099
-          if(true)
1100
-          #endif
1101
-          {
1102
-            lcdprintPGM(" \004Refresh");
1103
-          }
1104
-          else
1105
-          {
1106
-            lcdprintPGM(" \004Insert Card");
1107
-          }
1108
-          
1109
-        }
1110
-        if((activeline==line) && CLICKED)
1111
-        {
1112
-          BLOCK;
1113
-          beepshort();
1114
-          card.initsd();
1115
-          force_lcd_update=true;
1116
-           nrfiles=card.getnrfilenames();
1117
-        }
1118
-      }break;
1184
+      MENUITEM(  lcdprintPGM(" ..")  ,  BLOCK;card.updir();enforceupdate=true;lineoffset=0;beepshort(); ) ;
1185
+      
1186
+      break;
1119 1187
     default:
1120 1188
     {
1121
-      if(i-2<nrfiles)
1189
+      #define FIRSTITEM 2
1190
+      if(i-FIRSTITEM<nrfiles)
1122 1191
       {
1123 1192
         if(force_lcd_update)
1124 1193
         {
1125
-          card.getfilename(i-2);
1194
+          card.getfilename(i-FIRSTITEM);
1126 1195
           //Serial.print("Filenr:");Serial.println(i-2);
1127
-          lcd.setCursor(0,line);lcdprintPGM(" ");lcd.print(card.filename);
1196
+          lcd.setCursor(0,line);lcdprintPGM(" ");
1197
+          if(card.filenameIsDir) lcd.print("\005");
1198
+          lcd.print(card.filename);
1128 1199
         }
1129 1200
         if((activeline==line) && CLICKED)
1130 1201
         {
1131 1202
           BLOCK
1132
-          card.getfilename(i-2);
1133
-          char cmd[30];
1134
-          for(int8_t i=0;i<strlen(card.filename);i++)
1135
-            card.filename[i]=tolower(card.filename[i]);
1136
-          sprintf(cmd,"M23 %s",card.filename);
1137
-          //sprintf(cmd,"M115");
1138
-          enquecommand(cmd);
1139
-          enquecommand("M24");
1140
-          beep(); 
1141
-          status=Main_Status;
1142
-          lcd_status(card.filename);
1203
+          card.getfilename(i-FIRSTITEM);
1204
+          if(card.filenameIsDir)
1205
+          {
1206
+            for(int8_t i=0;i<strlen(card.filename);i++)
1207
+              card.filename[i]=tolower(card.filename[i]);
1208
+            card.chdir(card.filename);
1209
+            lineoffset=0;
1210
+            enforceupdate=true;
1211
+          }
1212
+          else
1213
+          {
1214
+            char cmd[30];
1215
+            for(int8_t i=0;i<strlen(card.filename);i++)
1216
+              card.filename[i]=tolower(card.filename[i]);
1217
+            sprintf(cmd,"M23 %s",card.filename);
1218
+            //sprintf(cmd,"M115");
1219
+            enquecommand(cmd);
1220
+            enquecommand("M24");
1221
+            beep(); 
1222
+            status=Main_Status;
1223
+            lcd_status(card.filename);
1224
+          }
1143 1225
         }
1144 1226
       }
1145 1227
       
@@ -1148,7 +1230,12 @@ void MainMenu::showSD()
1148 1230
   }
1149 1231
   line++;
1150 1232
  }
1151
- updateActiveLines(1+nrfiles,encoderpos);
1233
+ updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
1234
+ if(enforceupdate)
1235
+ {
1236
+   force_lcd_update=true;
1237
+   enforceupdate=false;
1238
+ }
1152 1239
 #endif
1153 1240
 }
1154 1241
 
@@ -1282,6 +1369,14 @@ void MainMenu::update()
1282 1369
       {
1283 1370
         showControl(); 
1284 1371
       }break;
1372
+      case Sub_MotionControl:
1373
+      {
1374
+        showControlMotion(); 
1375
+      }break;
1376
+      case Sub_TempControl:
1377
+      {
1378
+        showControlTemp(); 
1379
+      }break;
1285 1380
       case Main_SD: 
1286 1381
       {
1287 1382
         showSD();
@@ -1290,7 +1385,7 @@ void MainMenu::update()
1290 1385
   
1291 1386
   if(timeoutToStatus<millis())
1292 1387
     status=Main_Status;
1293
-  force_lcd_update=false;
1388
+  //force_lcd_update=false;
1294 1389
   lastencoderpos=encoderpos;
1295 1390
 }
1296 1391
 

Loading…
Annulla
Salva