{"action":"created","issue":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5262","repository_url":"https://api.github.com/repos/MarlinFirmware/Marlin","labels_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5262/labels{/name}","comments_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5262/comments","events_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5262/events","html_url":"https://github.com/MarlinFirmware/Marlin/issues/5262","id":190575839,"number":5262,"title":"New feature - Change filament from the menu when not printing","user":{"login":"stigjoergensen","id":23189291,"avatar_url":"https://avatars.githubusercontent.com/u/23189291?v=3","gravatar_id":"","url":"https://api.github.com/users/stigjoergensen","html_url":"https://github.com/stigjoergensen","followers_url":"https://api.github.com/users/stigjoergensen/followers","following_url":"https://api.github.com/users/stigjoergensen/following{/other_user}","gists_url":"https://api.github.com/users/stigjoergensen/gists{/gist_id}","starred_url":"https://api.github.com/users/stigjoergensen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stigjoergensen/subscriptions","organizations_url":"https://api.github.com/users/stigjoergensen/orgs","repos_url":"https://api.github.com/users/stigjoergensen/repos","events_url":"https://api.github.com/users/stigjoergensen/events{/privacy}","received_events_url":"https://api.github.com/users/stigjoergensen/received_events","type":"User","site_admin":false},"labels":[{"id":91737852,"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/Feature%20Request","name":"Feature Request","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-20T18:55:57Z","updated_at":"2016-11-21T09:15:49Z","closed_at":null,"body":"Hi Gang\r\n\r\nThis is my first attempt to do anything remotely usefull, but a good place to start i think...\r\n\r\nI have created - in my own fork:\r\nhttps://github.com/stigjoergensen/Marlin\r\n\r\na menu method to change filament when not printing...\r\n\r\nThe menu looks sort of like this:\r\n\r\n- Select extruder\r\n- - Select Temperature\r\n- - - Load filament\r\n- - - - Heating\r\n- - - - Cancel\r\n- - - UnLoad filament\r\n- - - - Heating\r\n- - - - Cancel\r\n- - Back\r\n- Back\r\n\r\nI have included the changes in this mail (i know this is not the right way of doing this, but as this is my first attempt i thought it would be better - and hense my next question)\r\n\r\nWhat would be the best way of doing this? create a pull request from MarlinFirmware/Marlin/RCBugFix - but what happens next?\r\nI can all ready see that there is a change made that i dont have in my copy (even though its a sync pull from 3-4 hours ago ;)... how is that handled?\r\n\r\nand i would love to get comments on the code - this is my very arduino code, my first c++ and my first use of github - what a mouth full eh?\r\n\r\n\r\nIt consist of the following changes:\r\n\r\nconfiguration.h:\r\n```\r\n//\r\n// Change filament menu wizard\r\n//\r\n// add the posibility to change filament on a \"cold\" extruder\r\n//\r\n#define LCD_FILAMENT_CHANGE_FEATURE\r\n#ifdef LCD_FILAMENT_CHANGE_FEATURE\r\n  #define lcd_filament_change_min_temperature 190\r\n  #define lcd_filament_change_max_temperature 250\r\n  #define lcd_filament_change_unload_length 50\r\n  #define lcd_filament_change_load_length 50\r\n  #define lcd_filament_change_speed 200\r\n#endif\r\n\r\n```\r\n\r\nlanguage_en.h\r\n```\r\n#ifndef MSG_FILAMENT_CHANGE_Extruder\r\n  #define MSG_FILAMENT_CHANGE_Extruder  \"Extruder\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_Temperature\r\n  #define MSG_FILAMENT_CHANGE_Temperature \"Temperature\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_Load\r\n  #define MSG_FILAMENT_CHANGE_Load \"Load Filament\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_UnLoad    \r\n  #define MSG_FILAMENT_CHANGE_UnLoad \"Unload Filament\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_Cancel\r\n  #define MSG_FILAMENT_CHANGE_Cancel \"Cancel\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_Wait\r\n  #define MSG_FILAMENT_CHANGE_Wait \"Please wait.\"\r\n#endif\r\n#ifndef MSG_FILAMENT_CHANGE_Heating\r\n  #define MSG_FILAMENT_CHANGE_Heating \"Heating\"\r\n#endif\r\n\r\n```\r\n\r\nand ultralcd.cpp\r\nin top (line 120 or there about)\r\n\r\n```\r\n  #ifdef LCD_FILAMENT_CHANGE_FEATURE\r\n    static void lcd_filament_change_menu();\r\n  #endif\r\n\r\n```\r\n\r\nand later from line 639\r\n```\r\n  /**\r\n   *  \r\n   *  change filament sub menu\r\n   *  by stig.joergensen\r\n   *\r\n   *  Select extruder       MSG_FILAMENT_CHANGE_Extruder\r\n   *    Select Temperature  MSG_FILAMENT_CHANGE_Temperature\r\n   *      Load filament     MSG_FILAMENT_CHANGE_Load\r\n   *        Heating\r\n   *        Cancel          MSG_FILAMENT_CHANGE_Cancel\r\n   *      UnLoad filament   MSG_FILAMENT_CHANGE_UnLoad\r\n   *        Heating\r\n   *        Cancel          MSG_FILAMENT_CHANGE_Cancel\r\n   *      Back\r\n   *    Back\r\n   */\r\n    byte lcd_filament_change_state = 0;\r\n    int16_t lcd_filament_change_temp;\r\n    int16_t lcd_filament_change_extruder;\r\n\r\n    static void lcd_filament_change_heat() {  // lets heat the choosen hotend\r\n      char buffer[8];  // \"###/###o\"\r\n      thermalManager.setTargetHotend(lcd_filament_change_temp, lcd_filament_change_extruder);\r\n      safe_delay(250);\r\n      bool menuclick = false; // lcd_clicked is not updated in this busy wait loop, so we get it our self\r\n      while(thermalManager.isHeatingHotend(lcd_filament_change_extruder) && !menuclick) { \r\n        START_MENU();\r\n        #if LCD_HEIGHT > 2\r\n          STATIC_ITEM(MSG_FILAMENT_CHANGE_Wait, true, false);\r\n        #endif\r\n        sprintf_P(buffer, PSTR(\"%i/%i\" LCD_STR_DEGREE ), int(thermalManager.current_temperature[lcd_filament_change_extruder]), int(thermalManager.target_temperature[lcd_filament_change_extruder]));\r\n\r\n        STATIC_ITEM(MSG_FILAMENT_CHANGE_Heating \": \", true, false, buffer);\r\n        STATIC_ITEM(\">\" MSG_FILAMENT_CHANGE_Cancel,false,false);  // simulate a menu item\r\n        END_MENU();\r\n        menuclick = LCD_CLICKED;\r\n        safe_delay(250);  // wait a 1/4 sec before we update the display again in the loop, or we exit due to cancel\r\n      }\r\n      if(menuclick) {  // we got a click on our simulated cancel menu item\r\n        defer_return_to_status = false;  // revert to normal menu behaivour if we canceled the operation\r\n        lcd_quick_feedback();  // do audio feed back on the click\r\n        thermalManager.setTargetHotend(0, lcd_filament_change_extruder);\r\n        lcd_filament_change_state = 0;   // Revert to Change filament menu\r\n      } else {\r\n        lcd_buzz(800,2000);\r\n      }\r\n      lcd_clicked=false; // reset the lcd clicked just in case we actually got it from our manual menu_item\r\n      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;\r\n    }\r\n\r\n    static void lcd_filament_change_unload() {\r\n      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;\r\n      lcd_filament_change_heat();\r\n      if (lcd_filament_change_state != 0) {\r\n        // I wonder if the last parameter buffer_line_kinematic should be the extuder choosen, and if i need to change extruder with T?? or should i set active_extruder?\r\n        enqueue_and_echo_commands_P(PSTR(\"T\" STRINGIFY(lcd_filament_change_extruder)));\r\n        current_position[E_AXIS] -= lcd_filament_change_unload_length;\r\n        planner.buffer_line_kinematic(current_position, MMM_TO_MMS(lcd_filament_change_speed), lcd_filament_change_extruder);  \r\n      }\r\n    }\r\n    \r\n    static void lcd_filament_change_load() {\r\n      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;\r\n      lcd_filament_change_heat();\r\n      if (lcd_filament_change_state != 0) {\r\n        // I wonder if the last parameter buffer_line_kinematic should be the extuder choosen, and if i need to change extruder with T?? or should i set active_extruder?\r\n        enqueue_and_echo_commands_P(PSTR(\"T\" STRINGIFY(lcd_filament_change_extruder)));\r\n        current_position[E_AXIS] += lcd_filament_change_load_length;\r\n        planner.buffer_line_kinematic(current_position, MMM_TO_MMS(lcd_filament_change_speed), lcd_filament_change_extruder); \r\n      }\r\n    }\r\n\r\n    static void lcd_filament_change_setTemperature() {\r\n      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;\r\n      lcd_filament_change_state = 2;\r\n    }\r\n  \r\n    static void lcd_filament_change_setExtruder() {\r\n      defer_return_to_status = true;  // make sure we dont go to status screen while we are chaning filament\r\n      lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;\r\n      lcd_filament_change_state = 1;\r\n    }\r\n\r\n    static void lcd_filament_change_done() {\r\n      lcd_goto_previous_menu();\r\n      defer_return_to_status = false;  // revert to normal menu behaivour if we canceled the operation\r\n      thermalManager.setTargetHotend(0, lcd_filament_change_extruder);\r\n      lcd_filament_change_state = 0;   // Revert to Change filament menu\r\n    }\r\n\r\n  static void lcd_filament_change_menu() {\r\n    START_MENU();\r\n    switch(lcd_filament_change_state) {\r\n      case 0:\r\n        MENU_ITEM_EDIT_CALLBACK(int3, MSG_FILAMENT_CHANGE_Extruder, &lcd_filament_change_extruder, 0, EXTRUDERS-1, lcd_filament_change_setExtruder);\r\n        MENU_BACK(MSG_MAIN);\r\n      break;\r\n      case 1:\r\n        MENU_ITEM_EDIT_CALLBACK(int3, MSG_FILAMENT_CHANGE_Temperature, &lcd_filament_change_temp, lcd_filament_change_min_temperature, lcd_filament_change_max_temperature, lcd_filament_change_setTemperature);\r\n        MENU_BACK(MSG_MAIN);\r\n      break;\r\n      case 2:\r\n        MENU_ITEM(function,MSG_FILAMENT_CHANGE_UnLoad,lcd_filament_change_unload);\r\n        MENU_ITEM(function,MSG_FILAMENT_CHANGE_Load,lcd_filament_change_load);\r\n        MENU_ITEM(function,MSG_MAIN,lcd_filament_change_done);\r\n      break;\r\n    }\r\n    END_MENU();\r\n  } // lcd_filament_change()\r\n\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/comments/261884231","html_url":"https://github.com/MarlinFirmware/Marlin/issues/5262#issuecomment-261884231","issue_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/5262","id":261884231,"user":{"login":"stigjoergensen","id":23189291,"avatar_url":"https://avatars.githubusercontent.com/u/23189291?v=3","gravatar_id":"","url":"https://api.github.com/users/stigjoergensen","html_url":"https://github.com/stigjoergensen","followers_url":"https://api.github.com/users/stigjoergensen/followers","following_url":"https://api.github.com/users/stigjoergensen/following{/other_user}","gists_url":"https://api.github.com/users/stigjoergensen/gists{/gist_id}","starred_url":"https://api.github.com/users/stigjoergensen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stigjoergensen/subscriptions","organizations_url":"https://api.github.com/users/stigjoergensen/orgs","repos_url":"https://api.github.com/users/stigjoergensen/repos","events_url":"https://api.github.com/users/stigjoergensen/events{/privacy}","received_events_url":"https://api.github.com/users/stigjoergensen/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T09:15:49Z","updated_at":"2016-11-21T09:15:49Z","body":"This is actually a part of a bigger plan... doing filament/spool tracking.\r\n\r\nI see the idea about using gcodes files from the SD card... but that means keep the same set of files on multiple cards. \r\n\r\n@Blue-Marlin - well, that could be said of about 50% of the menu already... so i dont think it bloating.\r\n@thinkyhead - cool scripts.\r\n\r\nbut i really wish that you would comment on the codeing and the implementation of the idea rather than just the idea... that was my biggest wish. and alsp on how to get this into marlin - if it should get there."}}
{"actor":{"display_login":"stigjoergensen"}}