Add Extruder screen to panel
authorJim Morris <morris@wolfman.com>
Tue, 25 Jun 2013 08:55:55 +0000 (01:55 -0700)
committerJim Morris <morris@wolfman.com>
Tue, 25 Jun 2013 08:57:23 +0000 (01:57 -0700)
src/modules/utils/panel/screens/ExtruderScreen.cpp [new file with mode: 0644]
src/modules/utils/panel/screens/ExtruderScreen.h [new file with mode: 0644]
src/modules/utils/panel/screens/PrepareScreen.cpp

diff --git a/src/modules/utils/panel/screens/ExtruderScreen.cpp b/src/modules/utils/panel/screens/ExtruderScreen.cpp
new file mode 100644 (file)
index 0000000..d9dc3eb
--- /dev/null
@@ -0,0 +1,64 @@
+/*  
+      This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
+      Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+      Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+      You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 
+*/
+
+#include "libs/Kernel.h"
+#include "libs/SerialMessage.h"
+#include "Panel.h"
+#include "PanelScreen.h"
+#include "ExtruderScreen.h"
+#include "libs/nuts_bolts.h"
+#include "libs/utils.h"
+#include <string>
+
+using namespace std;
+
+
+ExtruderScreen::ExtruderScreen(){
+}
+
+void ExtruderScreen::on_enter(){
+    this->panel->enter_menu_mode();
+    this->panel->setup_menu(3, 4);  // 3 menu items, 4 lines
+    this->refresh_screen();
+}
+
+void ExtruderScreen::on_refresh(){
+    if( this->panel->menu_change() ){
+        this->refresh_screen();
+    }
+    if( this->panel->click() ){
+        this->clicked_menu_entry(this->panel->menu_current_line());
+    }
+}
+
+void ExtruderScreen::refresh_screen(){
+    this->refresh_menu();
+}
+
+void ExtruderScreen::display_menu_line(uint16_t line){
+    switch( line ){
+        case 0: this->panel->lcd->printf("Back");  break;  
+        case 1: this->panel->lcd->printf("Extrude 5mm"); break;  
+        case 2: this->panel->lcd->printf("Retract 5mm");  break;  
+    }
+}
+
+void ExtruderScreen::clicked_menu_entry(uint16_t line){
+    switch( line ){
+        case 0: this->panel->enter_screen(this->parent); return;
+        case 1: send_gcode("G91"); send_gcode("G1 E5");  send_gcode("G90"); break;
+        case 2: send_gcode("G91"); send_gcode("G1 E-5"); send_gcode("G90"); break;
+    }
+}
+
+void ExtruderScreen::send_gcode(const char* gcstr) {
+    string gcode(gcstr);
+    struct SerialMessage message;
+    message.message = gcode;
+    message.stream = &(StreamOutput::NullStream);
+    THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+}
diff --git a/src/modules/utils/panel/screens/ExtruderScreen.h b/src/modules/utils/panel/screens/ExtruderScreen.h
new file mode 100644 (file)
index 0000000..b32f884
--- /dev/null
@@ -0,0 +1,33 @@
+/*  
+      This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
+      Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+      Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+      You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 
+*/
+
+#ifndef EXTRUDERSCREEN_H
+#define EXTRUDERSCREEN_H
+
+#include "libs/Kernel.h"
+#include "libs/nuts_bolts.h"
+#include "libs/utils.h"
+#include "libs/Pin.h"
+#include "LcdBase.h"
+#include "Panel.h"
+#include "PanelScreen.h"
+
+
+class ExtruderScreen : public PanelScreen {
+    public:
+        ExtruderScreen();
+        void on_refresh();
+        void on_enter();
+        void refresh_screen(); 
+        void display_menu_line(uint16_t line);
+        void clicked_menu_entry(uint16_t line);
+
+    private:
+        void send_gcode(const char* gcstr);
+};
+
+#endif
index 3f67641..b5bc248 100644 (file)
@@ -9,6 +9,7 @@
 #include "Panel.h"
 #include "PanelScreen.h"
 #include "PrepareScreen.h"
+#include "ExtruderScreen.h"
 #include "libs/nuts_bolts.h"
 #include "libs/utils.h"
 #include "libs/SerialMessage.h"
@@ -20,13 +21,13 @@ using namespace std;
 
 PrepareScreen::PrepareScreen(){
     // Children screens
-//    this->extruder_screen = (new ExtruderScreen()  )->set_parent(this);
+    this->extruder_screen = (new ExtruderScreen()  )->set_parent(this);
 //    this->temp_screen     = (new TempScreen()      )->set_parent(this);
 }
 
 void PrepareScreen::on_enter(){
     this->panel->enter_menu_mode();
-    this->panel->setup_menu(5, 4);  // 7 menu items, 4 lines
+    this->panel->setup_menu(6, 4);  // 7 menu items, 4 lines
     this->refresh_screen();
 }
 
@@ -50,19 +51,19 @@ void PrepareScreen::display_menu_line(uint16_t line){
         case 2: this->panel->lcd->printf("Set Home"       ); break; 
         case 3: this->panel->lcd->printf("Pre Heat"       ); break; 
         case 4: this->panel->lcd->printf("Cool Down"      ); break; 
-        //case 5: this->panel->lcd->printf("Extrude"        ); break; 
+        case 5: this->panel->lcd->printf("Extrude"        ); break; 
         //case 6: this->panel->lcd->printf("Set Temperature"); break; 
     }
 }
 
 void PrepareScreen::clicked_menu_entry(uint16_t line){
     switch( line ){
-        case 0: this->panel->enter_screen(this->parent           ); break;
+        case 0: this->panel->enter_screen(this->parent); break;
         case 1: send_gcode("G28"); break;
         case 2: send_gcode("G92 X0 Y0 Z0"); break;
         case 3: this->preheat(); break;
         case 4: this->cooldown(); break;
-        //case 5: this->panel->enter_screen(this->extruder_screen  ); break;
+        case 5: this->panel->enter_screen(this->extruder_screen); break;
         //case 6: this->panel->enter_screen(this->temp_screen      ); break;
     }