Browse Source

made ultralcd compatible with folders.

Bernhard Kubicek 13 years ago
parent
commit
b21d5193f2
4 changed files with 339 additions and 195 deletions
  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 View File

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

+ 80
- 35
Marlin/cardreader.pde View File

1
 #include "cardreader.h"
1
 #include "cardreader.h"
2
+//#include <unistd.h>
2
 #ifdef SDSUPPORT
3
 #ifdef SDSUPPORT
3
 
4
 
4
 CardReader::CardReader()
5
 CardReader::CardReader()
36
   return buffer;
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
 void  CardReader::lsDive(char *prepend,SdFile parent)
41
 void  CardReader::lsDive(char *prepend,SdFile parent)
45
 {
42
 {
46
   dir_t p;
43
   dir_t p;
85
     {
82
     {
86
       if (p.name[0] == DIR_NAME_FREE) break;
83
       if (p.name[0] == DIR_NAME_FREE) break;
87
       if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue;
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
       if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
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
       //if(cnt++!=nr) continue;
98
       //if(cnt++!=nr) continue;
94
       createFilename(filename,p);
99
       createFilename(filename,p);
95
       if(lsAction==LS_SerialPrint)
100
       if(lsAction==LS_SerialPrint)
126
 void CardReader::initsd()
131
 void CardReader::initsd()
127
 {
132
 {
128
   cardOK = false;
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
 void CardReader::release()
164
 void CardReader::release()
158
 {
165
 {
229
       
236
       
230
     }
237
     }
231
   }
238
   }
239
+  else //relative path
240
+  {
241
+    curDir=&workDir;
242
+  }
232
   if(read)
243
   if(read)
233
   {
244
   {
234
     if (file.open(curDir, fname, O_READ)) 
245
     if (file.open(curDir, fname, O_READ)) 
362
 
373
 
363
 void CardReader::getfilename(const uint8_t nr)
374
 void CardReader::getfilename(const uint8_t nr)
364
 {
375
 {
376
+  curDir=&workDir;
365
   lsAction=LS_GetFilename;
377
   lsAction=LS_GetFilename;
366
   nrFiles=nr;
378
   nrFiles=nr;
367
   curDir->rewind();
379
   curDir->rewind();
371
 
383
 
372
 uint16_t CardReader::getnrfilenames()
384
 uint16_t CardReader::getnrfilenames()
373
 {
385
 {
386
+  curDir=&workDir;
374
   lsAction=LS_Count;
387
   lsAction=LS_Count;
375
   nrFiles=0;
388
   nrFiles=0;
376
   curDir->rewind();
389
   curDir->rewind();
377
   lsDive("",*curDir);
390
   lsDive("",*curDir);
391
+  //SERIAL_ECHOLN(nrFiles);
378
   return nrFiles;
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
 #endif //SDSUPPORT
427
 #endif //SDSUPPORT

+ 4
- 2
Marlin/ultralcd.h View File

51
   #define blocktime 500
51
   #define blocktime 500
52
   #define lcdslow 5
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
   class MainMenu{
56
   class MainMenu{
57
   public:
57
   public:
58
     MainMenu();
58
     MainMenu();
59
     void update();
59
     void update();
60
-    uint8_t activeline;
60
+    int8_t activeline;
61
     MainStatus status;
61
     MainStatus status;
62
     uint8_t displayStartingRow;
62
     uint8_t displayStartingRow;
63
     
63
     
65
     void showMainMenu();
65
     void showMainMenu();
66
     void showPrepare();
66
     void showPrepare();
67
     void showControl();
67
     void showControl();
68
+    void showControlMotion();
69
+    void showControlTemp();
68
     void showSD();
70
     void showSD();
69
     bool force_lcd_update;
71
     bool force_lcd_update;
70
     int lastencoderpos;
72
     int lastencoderpos;

+ 251
- 156
Marlin/ultralcd.pde View File

114
   };
114
   };
115
   byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
115
   byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
116
   byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
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
   lcd.begin(LCD_WIDTH, LCD_HEIGHT);
118
   lcd.begin(LCD_WIDTH, LCD_HEIGHT);
118
   lcd.createChar(1,Degree);
119
   lcd.createChar(1,Degree);
119
   lcd.createChar(2,Thermometer);
120
   lcd.createChar(2,Thermometer);
120
   lcd.createChar(3,uplevel);
121
   lcd.createChar(3,uplevel);
121
   lcd.createChar(4,refresh);
122
   lcd.createChar(4,refresh);
123
+  lcd.createChar(5,folder);
122
   LCD_MESSAGEPGM("UltiMarlin ready.");
124
   LCD_MESSAGEPGM("UltiMarlin ready.");
123
 }
125
 }
124
 
126
 
224
     buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
226
     buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
225
   #endif
227
   #endif
226
   
228
   
229
+  //manage encoder rotation
227
   char enc=0;
230
   char enc=0;
228
   if(buttons&EN_A)
231
   if(buttons&EN_A)
229
     enc|=(1<<0);
232
     enc|=(1<<0);
311
     oldtargetHotEnd0=ttHotEnd0;
314
     oldtargetHotEnd0=ttHotEnd0;
312
   }
315
   }
313
   #if defined BED_USES_THERMISTOR || defined BED_USES_AD595 
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
   #endif
333
   #endif
331
   //starttime=2;
334
   //starttime=2;
332
   static uint16_t oldtime=0;
335
   static uint16_t oldtime=0;
421
   }
424
   }
422
 
425
 
423
 #endif
426
 #endif
427
+  force_lcd_update=false;
424
 }
428
 }
425
 
429
 
426
 enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
430
 enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
466
  }
470
  }
467
  updateActiveLines(ItemP_disstep,encoderpos);
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
 //does not work
475
 //does not work
481
 // #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
476
 // #define MENUCHANGEITEM(repaint_action,  enter_action, accept_action,  change_action) \
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
  clearIfNecessary();
500
  clearIfNecessary();
502
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
501
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
503
  {
502
  {
504
   switch(i)
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
       break;
507
       break;
509
-    case ItemC_nozzle:
508
+    case ItemCT_nozzle:
510
       {
509
       {
511
         if(force_lcd_update)
510
         if(force_lcd_update)
512
         {
511
         {
540
         }
539
         }
541
       }break;
540
       }break;
542
       
541
       
543
-      case ItemC_fan:
542
+      case ItemCT_fan:
544
       {
543
       {
545
         if(force_lcd_update)
544
         if(force_lcd_update)
546
         {
545
         {
577
           }
576
           }
578
         }
577
         }
579
       }break;
578
       }break;
580
-    case ItemC_acc:
581
-    {
579
+      case ItemCT_PID_P: 
580
+      {
582
       if(force_lcd_update)
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
         if((activeline==line) )
587
         if((activeline==line) )
592
             linechanging=!linechanging;
591
             linechanging=!linechanging;
593
             if(linechanging)
592
             if(linechanging)
594
             {
593
             {
595
-               encoderpos=(int)acceleration/100;
594
+               encoderpos=(int)Kp/5;
596
             }
595
             }
597
             else
596
             else
598
             {
597
             {
599
-              acceleration= encoderpos*100;
598
+              Kp= encoderpos*5;
600
               encoderpos=activeline*lcdslow;
599
               encoderpos=activeline*lcdslow;
600
+                
601
             }
601
             }
602
             BLOCK;
602
             BLOCK;
603
             beepshort();
603
             beepshort();
604
           }
604
           }
605
           if(linechanging)
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
       }break;
612
       }break;
613
-    case ItemC_xyjerk: //max_xy_jerk
613
+    case ItemCT_PID_I: 
614
       {
614
       {
615
       if(force_lcd_update)
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
         if((activeline==line) )
621
         if((activeline==line) )
625
             linechanging=!linechanging;
625
             linechanging=!linechanging;
626
             if(linechanging)
626
             if(linechanging)
627
             {
627
             {
628
-               encoderpos=(int)max_xy_jerk;
628
+               encoderpos=(int)(Ki*10);
629
             }
629
             }
630
             else
630
             else
631
             {
631
             {
632
-              max_xy_jerk= encoderpos;
632
+              Ki= encoderpos/10.;
633
               encoderpos=activeline*lcdslow;
633
               encoderpos=activeline*lcdslow;
634
                 
634
                 
635
             }
635
             }
638
           }
638
           }
639
           if(linechanging)
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
       }break;
646
       }break;
647
-      case ItemC_PID_P: 
647
+      case ItemCT_PID_D: 
648
       {
648
       {
649
       if(force_lcd_update)
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
         if((activeline==line) )
655
         if((activeline==line) )
659
             linechanging=!linechanging;
659
             linechanging=!linechanging;
660
             if(linechanging)
660
             if(linechanging)
661
             {
661
             {
662
-               encoderpos=(int)Kp/5;
662
+               encoderpos=(int)Kd/5;
663
             }
663
             }
664
             else
664
             else
665
             {
665
             {
666
-              Kp= encoderpos*5;
666
+              Kd= encoderpos*5;
667
               encoderpos=activeline*lcdslow;
667
               encoderpos=activeline*lcdslow;
668
                 
668
                 
669
             }
669
             }
672
           }
672
           }
673
           if(linechanging)
673
           if(linechanging)
674
           {
674
           {
675
-            if(encoderpos<1) encoderpos=1;
675
+            if(encoderpos<0) encoderpos=0;
676
             if(encoderpos>9990/5) encoderpos=9990/5;
676
             if(encoderpos>9990/5) encoderpos=9990/5;
677
             lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
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
       if(force_lcd_update)
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
         if((activeline==line) )
690
         if((activeline==line) )
693
             linechanging=!linechanging;
694
             linechanging=!linechanging;
694
             if(linechanging)
695
             if(linechanging)
695
             {
696
             {
696
-               encoderpos=(int)(Ki*10);
697
+               encoderpos=(int)Kc;
697
             }
698
             }
698
             else
699
             else
699
             {
700
             {
700
-              Ki= encoderpos/10.;
701
+              Kc= encoderpos;
701
               encoderpos=activeline*lcdslow;
702
               encoderpos=activeline*lcdslow;
702
                 
703
                 
703
             }
704
             }
707
           if(linechanging)
708
           if(linechanging)
708
           {
709
           {
709
             if(encoderpos<0) encoderpos=0;
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
       if(force_lcd_update)
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
         if((activeline==line) )
761
         if((activeline==line) )
727
             linechanging=!linechanging;
765
             linechanging=!linechanging;
728
             if(linechanging)
766
             if(linechanging)
729
             {
767
             {
730
-               encoderpos=(int)Kd/5;
768
+               encoderpos=(int)acceleration/100;
731
             }
769
             }
732
             else
770
             else
733
             {
771
             {
734
-              Kd= encoderpos*5;
772
+              acceleration= encoderpos*100;
735
               encoderpos=activeline*lcdslow;
773
               encoderpos=activeline*lcdslow;
736
-                
737
             }
774
             }
738
             BLOCK;
775
             BLOCK;
739
             beepshort();
776
             beepshort();
740
           }
777
           }
741
           if(linechanging)
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
       }break;
785
       }break;
749
-    
750
-    
751
-      
752
-    case ItemC_PID_C: 
786
+    case ItemCM_xyjerk: //max_xy_jerk
753
       {
787
       {
754
       if(force_lcd_update)
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
         if((activeline==line) )
794
         if((activeline==line) )
764
             linechanging=!linechanging;
798
             linechanging=!linechanging;
765
             if(linechanging)
799
             if(linechanging)
766
             {
800
             {
767
-               encoderpos=(int)Kc;
801
+               encoderpos=(int)max_xy_jerk;
768
             }
802
             }
769
             else
803
             else
770
             {
804
             {
771
-              Kc= encoderpos;
805
+              max_xy_jerk= encoderpos;
772
               encoderpos=activeline*lcdslow;
806
               encoderpos=activeline*lcdslow;
773
                 
807
                 
774
             }
808
             }
777
           }
811
           }
778
           if(linechanging)
812
           if(linechanging)
779
           {
813
           {
780
-            if(encoderpos<0) encoderpos=0;
814
+            if(encoderpos<1) encoderpos=1;
781
             if(encoderpos>990) encoderpos=990;
815
             if(encoderpos>990) encoderpos=990;
782
             lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
816
             lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
783
           }
817
           }
784
         }
818
         }
785
       }break;
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
       if(force_lcd_update)
826
       if(force_lcd_update)
792
         {
827
         {
793
           lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
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
         if((activeline==line) )
836
         if((activeline==line) )
805
             linechanging=!linechanging;
840
             linechanging=!linechanging;
806
             if(linechanging)
841
             if(linechanging)
807
             {
842
             {
808
-               encoderpos=(int)max_feedrate[i-ItemC_vmaxx];
843
+               encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
809
             }
844
             }
810
             else
845
             else
811
             {
846
             {
812
-              max_feedrate[i-ItemC_vmaxx]= encoderpos;
847
+              max_feedrate[i-ItemCM_vmaxx]= encoderpos;
813
               encoderpos=activeline*lcdslow;
848
               encoderpos=activeline*lcdslow;
814
                 
849
                 
815
             }
850
             }
825
         }
860
         }
826
       }break;
861
       }break;
827
     
862
     
828
-    case ItemC_vmin:
863
+    case ItemCM_vmin:
829
     {
864
     {
830
       if(force_lcd_update)
865
       if(force_lcd_update)
831
         {
866
         {
859
           }
894
           }
860
         }
895
         }
861
       }break;
896
       }break;
862
-    case ItemC_vtravmin:
897
+    case ItemCM_vtravmin:
863
     {
898
     {
864
       if(force_lcd_update)
899
       if(force_lcd_update)
865
         {
900
         {
894
         }
929
         }
895
       }break;
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
       if(force_lcd_update)
937
       if(force_lcd_update)
903
         {
938
         {
904
           lcd.setCursor(0,line);lcdprintPGM(" Amax ");
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
         if((activeline==line) )
947
         if((activeline==line) )
916
             linechanging=!linechanging;
951
             linechanging=!linechanging;
917
             if(linechanging)
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
             else
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
               encoderpos=activeline*lcdslow;
959
               encoderpos=activeline*lcdslow;
925
             }
960
             }
926
             BLOCK;
961
             BLOCK;
934
           }
969
           }
935
         }
970
         }
936
       }break;
971
       }break;
937
-    case ItemC_aret://float retract_acceleration = 7000;
972
+    case ItemCM_aret://float retract_acceleration = 7000;
938
     {
973
     {
939
         if(force_lcd_update)
974
         if(force_lcd_update)
940
         {
975
         {
968
           }
1003
           }
969
         }
1004
         }
970
       }break;
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
       if(force_lcd_update)
1008
       if(force_lcd_update)
974
         {
1009
         {
1005
           }
1040
           }
1006
         }
1041
         }
1007
       }break; 
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
     case ItemC_store:
1074
     case ItemC_store:
1009
     {
1075
     {
1010
       if(force_lcd_update)
1076
       if(force_lcd_update)
1059
 
1125
 
1060
 
1126
 
1061
 
1127
 
1062
-
1063
 void MainMenu::showSD()
1128
 void MainMenu::showSD()
1064
 {
1129
 {
1065
 #ifdef SDSUPPORT
1130
 #ifdef SDSUPPORT
1069
  static uint8_t nrfiles=0;
1134
  static uint8_t nrfiles=0;
1070
  if(force_lcd_update)
1135
  if(force_lcd_update)
1071
  {
1136
  {
1072
-  clear();
1073
   if(card.cardOK)
1137
   if(card.cardOK)
1074
   {
1138
   {
1075
     nrfiles=card.getnrfilenames();
1139
     nrfiles=card.getnrfilenames();
1080
     lineoffset=0;
1144
     lineoffset=0;
1081
   }
1145
   }
1082
  }
1146
  }
1083
- 
1147
+ bool enforceupdate=false;
1084
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
1148
  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
1085
  {
1149
  {
1086
   switch(i)
1150
   switch(i)
1088
     case 0:
1152
     case 0:
1089
       MENUITEM(  lcdprintPGM(" File")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
1153
       MENUITEM(  lcdprintPGM(" File")  ,  BLOCK;status=Main_Menu;beepshort(); ) ;
1090
       break;
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
     case 1:
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
     default:
1187
     default:
1120
     {
1188
     {
1121
-      if(i-2<nrfiles)
1189
+      #define FIRSTITEM 2
1190
+      if(i-FIRSTITEM<nrfiles)
1122
       {
1191
       {
1123
         if(force_lcd_update)
1192
         if(force_lcd_update)
1124
         {
1193
         {
1125
-          card.getfilename(i-2);
1194
+          card.getfilename(i-FIRSTITEM);
1126
           //Serial.print("Filenr:");Serial.println(i-2);
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
         if((activeline==line) && CLICKED)
1200
         if((activeline==line) && CLICKED)
1130
         {
1201
         {
1131
           BLOCK
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
   }
1230
   }
1149
   line++;
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
 #endif
1239
 #endif
1153
 }
1240
 }
1154
 
1241
 
1282
       {
1369
       {
1283
         showControl(); 
1370
         showControl(); 
1284
       }break;
1371
       }break;
1372
+      case Sub_MotionControl:
1373
+      {
1374
+        showControlMotion(); 
1375
+      }break;
1376
+      case Sub_TempControl:
1377
+      {
1378
+        showControlTemp(); 
1379
+      }break;
1285
       case Main_SD: 
1380
       case Main_SD: 
1286
       {
1381
       {
1287
         showSD();
1382
         showSD();
1290
   
1385
   
1291
   if(timeoutToStatus<millis())
1386
   if(timeoutToStatus<millis())
1292
     status=Main_Status;
1387
     status=Main_Status;
1293
-  force_lcd_update=false;
1388
+  //force_lcd_update=false;
1294
   lastencoderpos=encoderpos;
1389
   lastencoderpos=encoderpos;
1295
 }
1390
 }
1296
 
1391
 

Loading…
Cancel
Save