From 6cdcd6c6d164882af0cba47b2da5d6a60d80bf25 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 16 Feb 2015 13:53:58 +0100 Subject: [PATCH 01/17] Fix iss#1492 Introduced lcd_strlen() and lcd_strlen_P(). Replaced the old functions where necessary. Reworked language_ru.h. Speeded up test for zero length string in cardreader.cpp --- Marlin/LiquidCrystalRus.cpp | 12 +++++--- Marlin/cardreader.cpp | 2 +- Marlin/dogm_lcd_implementation.h | 10 +++---- Marlin/language_ru.h | 30 +++++++++---------- Marlin/ultralcd.cpp | 22 +++++++++++++- Marlin/ultralcd.h | 3 +- .../ultralcd_implementation_hitachi_HD44780.h | 18 +++++------ 7 files changed, 61 insertions(+), 36 deletions(-) diff --git a/Marlin/LiquidCrystalRus.cpp b/Marlin/LiquidCrystalRus.cpp index 6ee2c112e..c74146236 100644 --- a/Marlin/LiquidCrystalRus.cpp +++ b/Marlin/LiquidCrystalRus.cpp @@ -14,10 +14,14 @@ // it is a Russian alphabet translation // except 0401 --> 0xa2 = ╗, 0451 --> 0xb5 const PROGMEM uint8_t utf_recode[] = - { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f, - 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, - 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f, - 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 + { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4, + 0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,0xa8, + 0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab, + 0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1, + 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7, + 0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,0xbe, + 0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0, + 0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7 }; // When the display powers up, it is configured as follows: diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 498a654c5..a2dd67831 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -65,7 +65,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m createFilename(lfilename,p); path[0]=0; - if(strlen(prepend)==0) //avoid leading / if already in prepend + if(prepend[0]==0) //avoid leading / if already in prepend { strcat(path,"/"); } diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index f512d3295..c7df306b3 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -315,7 +315,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) { char c; - uint8_t n = LCD_WIDTH - 2 - (pgm ? strlen_P(data) : (strlen(data))); + uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data))); lcd_implementation_mark_as_selected(row, pre_char); @@ -377,18 +377,18 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { uint8_t char_width = DOG_CHAR_WIDTH; #ifdef USE_BIG_EDIT_FONT - if (strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) { + if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) { u8g.setFont(FONT_MENU_EDIT); lcd_width = LCD_WIDTH_EDIT + 1; char_width = DOG_CHAR_WIDTH_EDIT; - if (strlen_P(pstr) >= LCD_WIDTH_EDIT - strlen(value)) rows = 2; + if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - lcd_strlen(value)) rows = 2; } else { u8g.setFont(FONT_MENU); } #endif - if (strlen_P(pstr) > LCD_WIDTH - 2 - strlen(value)) rows = 2; + if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - lcd_strlen(value)) rows = 2; const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2; float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3 @@ -396,7 +396,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { u8g.setPrintPos(0, rowHeight + kHalfChar); lcd_printPGM(pstr); u8g.print(':'); - u8g.setPrintPos((lcd_width-1-strlen(value)) * char_width, rows * rowHeight + kHalfChar); + u8g.setPrintPos((lcd_width-1-lcd_strlen(value)) * char_width, rows * rowHeight + kHalfChar); u8g.print(value); } diff --git a/Marlin/language_ru.h b/Marlin/language_ru.h index 03ea77851..bcab50b79 100644 --- a/Marlin/language_ru.h +++ b/Marlin/language_ru.h @@ -13,7 +13,7 @@ #define WELCOME_MSG MACHINE_NAME " Готов." #define MSG_SD_INSERTED "Карта вставлена" #define MSG_SD_REMOVED "Карта извлечена" -#define MSG_MAIN "Меню \003" +#define MSG_MAIN "Меню" #define MSG_AUTOSTART "Автостарт" #define MSG_DISABLE_STEPPERS "Выкл. двигатели" #define MSG_AUTO_HOME "Парковка" @@ -43,14 +43,14 @@ #define MSG_MOVE_1MM "Move 1mm" #define MSG_MOVE_10MM "Move 10mm" #define MSG_SPEED "Скорость" -#define MSG_NOZZLE "\002 Фильера" -#define MSG_BED "\002 Кровать" +#define MSG_NOZZLE LCD_STR_THERMOMETER " Фильера" +#define MSG_BED LCD_STR_THERMOMETER " Кровать" #define MSG_FAN_SPEED "Куллер" #define MSG_FLOW "Поток" -#define MSG_CONTROL "Настройки \003" -#define MSG_MIN "\002 Минимум" -#define MSG_MAX "\002 Максимум" -#define MSG_FACTOR "\002 Фактор" +#define MSG_CONTROL "Настройки" +#define MSG_MIN LCD_STR_THERMOMETER " Минимум" +#define MSG_MAX LCD_STR_THERMOMETER " Максимум" +#define MSG_FACTOR LCD_STR_THERMOMETER " Фактор" #define MSG_AUTOTEMP "Autotemp" #define MSG_ON "Вкл. " #define MSG_OFF "Выкл. " @@ -75,10 +75,10 @@ #define MSG_YSTEPS "Y шаг/mm" #define MSG_ZSTEPS "Z шаг/mm" #define MSG_ESTEPS "E шаг/mm" -#define MSG_TEMPERATURE "Температура \x7E" -#define MSG_MOTION "Скорости \x7E" +#define MSG_TEMPERATURE "Температура" +#define MSG_MOTION "Скорости" #define MSG_VOLUMETRIC "Filament" -#define MSG_VOLUMETRIC_ENABLED "E in mm3" +#define MSG_VOLUMETRIC_ENABLED "E in mm3" #define MSG_FILAMENT_SIZE_EXTRUDER_0 "Fil. Dia. 1" #define MSG_FILAMENT_SIZE_EXTRUDER_1 "Fil. Dia. 2" #define MSG_FILAMENT_SIZE_EXTRUDER_2 "Fil. Dia. 3" @@ -86,14 +86,14 @@ #define MSG_STORE_EPROM "Сохранить в EPROM" #define MSG_LOAD_EPROM "Загруз. из EPROM" #define MSG_RESTORE_FAILSAFE "Сброс настроек" -#define MSG_REFRESH "\004Обновить" -#define MSG_WATCH "Обзор \003" -#define MSG_PREPARE "Действия \x7E" -#define MSG_TUNE "Настройки \x7E" +#define MSG_REFRESH LCD_STR_REFRESH "Обновить" +#define MSG_WATCH "Обзор" +#define MSG_PREPARE "Действия" +#define MSG_TUNE "Настройки" #define MSG_PAUSE_PRINT "Продолжить печать" #define MSG_RESUME_PRINT "возобн. печать" #define MSG_STOP_PRINT "Остановить печать" -#define MSG_CARD_MENU "Меню карты \x7E" +#define MSG_CARD_MENU "Меню карты" #define MSG_NO_CARD "Нет карты" #define MSG_DWELL "Сон..." #define MSG_USERWAIT "Ожиданиие" diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 3773ad324..c9cd33883 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1260,6 +1260,26 @@ void lcd_init() #endif } +int lcd_strlen(char *s) { + int i = 0, j = 0; + while (s[i]) { + if ((s[i] & 0xc0) != 0x80) j++; + i++; + } + return j; +} + +int lcd_strlen_P(const char *s) { + int j = 0; + while (pgm_read_byte(s)) { + if ((pgm_read_byte(s) & 0xc0) != 0x80) j++; + s++; + } + return j; +} + + + void lcd_update() { static unsigned long timeoutToStatus = 0; @@ -1372,7 +1392,7 @@ void lcd_ignore_click(bool b) } void lcd_finishstatus() { - int len = strlen(lcd_status_message); + int len = lcd_strlen(lcd_status_message); if (len > 0) { while (len < LCD_WIDTH) { lcd_status_message[len++] = ' '; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 30175be39..d861e9d73 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -4,7 +4,8 @@ #include "Marlin.h" #ifdef ULTRA_LCD - + int lcd_strlen(char *s); + int lcd_strlen_P(const char *s); void lcd_update(); void lcd_init(); void lcd_setstatus(const char* message); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 9eeee1e15..1628bf8f4 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -636,7 +636,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c { lcd.print(c); pstr++; - n--; + if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--; } while(n--) lcd.print(' '); @@ -648,9 +648,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char c; //Use all characters in narrow LCDs #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); + uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen(data); #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); + uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen(data); #endif lcd.setCursor(0, row); lcd.print(pre_char); @@ -658,7 +658,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const { lcd.print(c); pstr++; - n--; + if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--; } lcd.print(':'); while(n--) @@ -670,9 +670,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons char c; //Use all characters in narrow LCDs #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); + uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen_P(data); #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); + uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen_P(data); #endif lcd.setCursor(0, row); lcd.print(pre_char); @@ -680,7 +680,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons { lcd.print(c); pstr++; - n--; + if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--; } lcd.print(':'); while(n--) @@ -733,9 +733,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value) lcd_printPGM(pstr); lcd.print(':'); #if LCD_WIDTH < 20 - lcd.setCursor(LCD_WIDTH - strlen(value), 1); + lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1); #else - lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); + lcd.setCursor(LCD_WIDTH -1 - lcd_strlen(value), 1); #endif lcd.print(value); } From 15b73386b52721b38e53c32cd6601b700b817f1c Mon Sep 17 00:00:00 2001 From: domonoky Date: Thu, 19 Feb 2015 11:53:31 +0100 Subject: [PATCH 02/17] Add pin definitions for the Boards BAM&DICE + BAM&DICE Due --- Marlin/boards.h | 4 +- Marlin/pins.h | 2 + Marlin/pins_BAM_DICE_DUE.h | 183 +++++++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 Marlin/pins_BAM_DICE_DUE.h diff --git a/Marlin/boards.h b/Marlin/boards.h index c6997fe87..c63651950 100644 --- a/Marlin/boards.h +++ b/Marlin/boards.h @@ -50,10 +50,12 @@ #define BOARD_LEAPFROG 999 // Leapfrog #define BOARD_WITBOX 41 // bq WITBOX #define BOARD_HEPHESTOS 42 // bq Prusa i3 Hephestos +#define BOARD_BAM_DICE 401 // 2PrintBeta BAM&DICE with STK drivers +#define BOARD_BAM_DICE_DUE 402 // 2PrintBeta BAM&DICE Due with STK drivers and Arduino Mega #define BOARD_99 99 // This is in pins.h but...? #define MB(board) (MOTHERBOARD==BOARD_##board) -#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF)) +#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) || MB(BAM_DICE) ) #endif //__BOARDS_H diff --git a/Marlin/pins.h b/Marlin/pins.h index ea8f96c48..ecee6c0ac 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -110,6 +110,8 @@ #include "pins_WITBOX.h" #elif MB(HEPHESTOS) #include "pins_HEPHESTOS.h" +#elif MB(BAM_DICE_DUE) + #include "pins_BAM_DICE_DUE.h" #elif MB(99) #include "pins_99.h" #else diff --git a/Marlin/pins_BAM_DICE_DUE.h b/Marlin/pins_BAM_DICE_DUE.h new file mode 100644 index 000000000..f9ca27ef7 --- /dev/null +++ b/Marlin/pins_BAM_DICE_DUE.h @@ -0,0 +1,183 @@ +/** + * Arduino Mega with BAM&DICE DUE pin assignments + * + * Applies to the following boards: + * + * BAM&DICE Due with Arduino Mega + */ + +#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) + #error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu. +#endif + +#define LARGE_FLASH true + +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +#define Y2_STEP_PIN 36 +#define Y2_DIR_PIN 34 +#define Y2_ENABLE_PIN 30 + +#define Z2_STEP_PIN 36 +#define Z2_DIR_PIN 34 +#define Z2_ENABLE_PIN 30 + +#define E0_STEP_PIN 26 +#define E0_DIR_PIN 28 +#define E0_ENABLE_PIN 24 + +#define E1_STEP_PIN 36 +#define E1_DIR_PIN 34 +#define E1_ENABLE_PIN 30 + +#define SDPOWER -1 +#define SDSS 53 +#define LED_PIN 13 + +#define FAN_PIN 9 // (Sprinter config) + +#define PS_ON_PIN 12 + +#if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL) + #define KILL_PIN 41 +#else + #define KILL_PIN -1 +#endif + +#define HEATER_0_PIN 10 + +#define HEATER_1_PIN -1 + +#define HEATER_2_PIN -1 + +#define TEMP_0_PIN 9 // ANALOG NUMBERING +#define TEMP_1_PIN 11 // ANALOG NUMBERING +#define TEMP_2_PIN -1 // ANALOG NUMBERING + +#define HEATER_BED_PIN 8 // BED + +#define TEMP_BED_PIN 14 // ANALOG NUMBERING + +#ifdef NUM_SERVOS + #define SERVO0_PIN 11 + + #if NUM_SERVOS > 1 + #define SERVO1_PIN 6 + #endif + + #if NUM_SERVOS > 2 + #define SERVO2_PIN 5 + #endif + + #if NUM_SERVOS > 3 + #define SERVO3_PIN 4 + #endif +#endif + + +#ifdef ULTRA_LCD + + #ifdef NEWPANEL + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + + #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER + #define BEEPER 37 + + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + + #define SDCARDDETECT 49 + #elif defined(LCD_I2C_PANELOLU2) + #define BTN_EN1 47 // reverse if the encoder turns the wrong way. + #define BTN_EN2 43 + #define BTN_ENC 32 + #define LCD_SDSS 53 + #define SDCARDDETECT -1 + #define KILL_PIN 41 + #elif defined(LCD_I2C_VIKI) + #define BTN_EN1 22 // reverse if the encoder turns the wrong way. + #define BTN_EN2 7 + #define BTN_ENC -1 + #define LCD_SDSS 53 + #define SDCARDDETECT 49 + #else + // arduino pin which triggers an piezzo beeper + #define BEEPER 33 // Beeper on AUX-4 + + // buttons are directly attached using AUX-2 + #ifdef REPRAPWORLD_KEYPAD + #define BTN_EN1 64 // encoder + #define BTN_EN2 59 // encoder + #define BTN_ENC 63 // enter button + #define SHIFT_OUT 40 // shift register + #define SHIFT_CLK 44 // shift register + #define SHIFT_LD 42 // shift register + #else + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 // the click + #endif + + #ifdef G3D_PANEL + #define SDCARDDETECT 49 + #else + #define SDCARDDETECT -1 // Ramps does not use this port + #endif + + #endif + + #else // Old-style panel with shift register + // Arduino pin witch triggers an piezzo beeper + #define BEEPER 33 // No Beeper added + + // Buttons are attached to a shift register + // Not wired yet + // #define SHIFT_CLK 38 + // #define SHIFT_LD 42 + // #define SHIFT_OUT 40 + // #define SHIFT_EN 17 + + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #endif +#endif // ULTRA_LCD + +// SPI for Max6675 Thermocouple +#ifndef SDSUPPORT + #define MAX6675_SS 66 // Do not use pin 53 if there is even the remote possibility of using Display/SD card +#else + #define MAX6675_SS 66 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present +#endif + +#ifndef SDSUPPORT + // these pins are defined in the SD library if building with SD support + #define SCK_PIN 52 + #define MISO_PIN 50 + #define MOSI_PIN 51 +#endif From 7891eacf214959cfdd67815f71ef3cadecf84c94 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 19 Feb 2015 17:26:22 -0800 Subject: [PATCH 03/17] Merge branch 'Development' into fixup_ramps_boards - Also apply cleanup for #1514 --- Marlin/boards.h | 3 ++- Marlin/pins.h | 6 +++++- Marlin/pins_AZTEEG_X3.h | 5 ----- Marlin/pins_AZTEEG_X3_PRO.h | 14 +++++++++----- Marlin/pins_BAM_DICE_DUE.h | 11 +++++++++++ Marlin/pins_HEPHESTOS.h | 3 +++ Marlin/pins_RAMPS_13.h | 38 +++++++++++-------------------------- Marlin/pins_WITBOX.h | 3 +++ 8 files changed, 44 insertions(+), 39 deletions(-) delete mode 100644 Marlin/pins_AZTEEG_X3.h create mode 100644 Marlin/pins_BAM_DICE_DUE.h diff --git a/Marlin/boards.h b/Marlin/boards.h index c6997fe87..2f1107b45 100644 --- a/Marlin/boards.h +++ b/Marlin/boards.h @@ -50,10 +50,11 @@ #define BOARD_LEAPFROG 999 // Leapfrog #define BOARD_WITBOX 41 // bq WITBOX #define BOARD_HEPHESTOS 42 // bq Prusa i3 Hephestos +#define BOARD_BAM_DICE 401 // 2PrintBeta BAM&DICE with STK drivers +#define BOARD_BAM_DICE_DUE 402 // 2PrintBeta BAM&DICE Due with STK drivers #define BOARD_99 99 // This is in pins.h but...? #define MB(board) (MOTHERBOARD==BOARD_##board) -#define IS_RAMPS (MB(RAMPS_OLD) || MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF)) #endif //__BOARDS_H diff --git a/Marlin/pins.h b/Marlin/pins.h index ea8f96c48..c33fa24e0 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -36,7 +36,7 @@ #include "pins_SETHI.h" #elif MB(RAMPS_OLD) #include "pins_RAMPS_OLD.h" -#elif IS_RAMPS +#elif MB(RAMPS_13_EFB) || MB(RAMPS_13_EEB) || MB(RAMPS_13_EFF) || MB(RAMPS_13_EEF) #include "pins_RAMPS_13.h" #elif MB(DUEMILANOVE_328P) #include "pins_DUEMILANOVE_328P.h" @@ -110,6 +110,10 @@ #include "pins_WITBOX.h" #elif MB(HEPHESTOS) #include "pins_HEPHESTOS.h" +#elif MB(BAM_DICE) + #include "pins_RAMPS_13.h" +#elif MB(BAM_DICE_DUE) + #include "pins_BAM_DICE_DUE.h" #elif MB(99) #include "pins_99.h" #else diff --git a/Marlin/pins_AZTEEG_X3.h b/Marlin/pins_AZTEEG_X3.h deleted file mode 100644 index 7eb8eae49..000000000 --- a/Marlin/pins_AZTEEG_X3.h +++ /dev/null @@ -1,5 +0,0 @@ -/** - * AZTEEG_X3 Arduino Mega with RAMPS v1.3 pin assignments - */ - -#include "pins_RAMPS_13.h" diff --git a/Marlin/pins_AZTEEG_X3_PRO.h b/Marlin/pins_AZTEEG_X3_PRO.h index ddb055ad9..5d0d70db6 100644 --- a/Marlin/pins_AZTEEG_X3_PRO.h +++ b/Marlin/pins_AZTEEG_X3_PRO.h @@ -4,6 +4,9 @@ #include "pins_RAMPS_13.h" +#define FAN_PIN 9 // (Sprinter config) +#define BEEPER 33 + #define E2_STEP_PIN 23 #define E2_DIR_PIN 25 #define E2_ENABLE_PIN 40 @@ -16,15 +19,16 @@ #define E4_DIR_PIN 37 #define E4_ENABLE_PIN 42 +#define HEATER_1_PIN -1 #define HEATER_2_PIN 16 #define HEATER_3_PIN 17 -#define HEATER_4_PIN 4 -#define HEATER_5_PIN 5 -#define HEATER_6_PIN 6 +#define HEATER_4_PIN 4 +#define HEATER_5_PIN 5 +#define HEATER_6_PIN 6 #define HEATER_7_PIN 11 #define TEMP_2_PIN 12 // ANALOG NUMBERING #define TEMP_3_PIN 11 // ANALOG NUMBERING #define TEMP_4_PIN 10 // ANALOG NUMBERING -#define TC1 4 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro -#define TC2 5 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro +#define TC1 4 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro +#define TC2 5 // ANALOG NUMBERING Thermo couple on Azteeg X3Pro diff --git a/Marlin/pins_BAM_DICE_DUE.h b/Marlin/pins_BAM_DICE_DUE.h new file mode 100644 index 000000000..c3123d043 --- /dev/null +++ b/Marlin/pins_BAM_DICE_DUE.h @@ -0,0 +1,11 @@ +/** + * BAM&DICE Due (Arduino Mega) pin assignments + */ + +#include "pins_RAMPS_13.h" + +#define FAN_PIN 9 // (Sprinter config) +#define HEATER_1_PIN -1 + +#define TEMP_0_PIN 9 // ANALOG NUMBERING +#define TEMP_1_PIN 11 // ANALOG NUMBERING diff --git a/Marlin/pins_HEPHESTOS.h b/Marlin/pins_HEPHESTOS.h index c5b7bcf79..8fc5ba643 100644 --- a/Marlin/pins_HEPHESTOS.h +++ b/Marlin/pins_HEPHESTOS.h @@ -3,3 +3,6 @@ */ #include "pins_RAMPS_13.h" + +#define FAN_PIN 9 // (Sprinter config) +#define HEATER_1_PIN -1 diff --git a/Marlin/pins_RAMPS_13.h b/Marlin/pins_RAMPS_13.h index e2f74fc83..840804a9d 100644 --- a/Marlin/pins_RAMPS_13.h +++ b/Marlin/pins_RAMPS_13.h @@ -7,10 +7,8 @@ * RAMPS_13_EEB (Extruder, Extruder, Bed) * RAMPS_13_EFF (Extruder, Fan, Fan) * RAMPS_13_EEF (Extruder, Extruder, Fan) - * 3DRAG - * K8200 - * AZTEEG_X3 - * AZTEEG_X3_PRO + * + * Other pins_MYBOARD.h files may override these defaults */ #if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) @@ -63,7 +61,7 @@ #define FILWIDTH_PIN 5 #endif -#if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF) || MB(AZTEEG_X3) || MB(AZTEEG_X3_PRO) || MB(WITBOX) || MB(HEPHESTOS) +#if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF) #define FAN_PIN 9 // (Sprinter config) #if MB(RAMPS_13_EFF) #define CONTROLLERFAN_PIN -1 // Pin used for the fan to cool controller @@ -88,7 +86,7 @@ #define HEATER_0_PIN 10 // EXTRUDER 1 #endif -#if MB(RAMPS_13_EFB) || MB(AZTEEG_X3) || MB(WITBOX) || MB(HEPHESTOS) +#if MB(RAMPS_13_EFB) #define HEATER_1_PIN -1 #else #define HEATER_1_PIN 9 // EXTRUDER 2 (FAN On Sprinter) @@ -110,28 +108,14 @@ #ifdef NUM_SERVOS #define SERVO0_PIN 11 - #if NUM_SERVOS > 1 - #define SERVO1_PIN 6 - #endif - - #if NUM_SERVOS > 2 - #define SERVO2_PIN 5 - #endif - - #if NUM_SERVOS > 3 - #define SERVO3_PIN 4 - #endif -#endif - -#if MB(AZTEEG_X3_PRO) - #define BEEPER 33 -#endif - -#ifdef TEMP_STAT_LEDS - #if MB(AZTEEG_X3) - #define STAT_LED_RED 6 - #define STAT_LED_BLUE 11 + #define SERVO1_PIN 6 + #if NUM_SERVOS > 2 + #define SERVO2_PIN 5 + #if NUM_SERVOS > 3 + #define SERVO3_PIN 4 + #endif + #endif #endif #endif diff --git a/Marlin/pins_WITBOX.h b/Marlin/pins_WITBOX.h index 4deda2cba..a4eb0e313 100644 --- a/Marlin/pins_WITBOX.h +++ b/Marlin/pins_WITBOX.h @@ -3,3 +3,6 @@ */ #include "pins_RAMPS_13.h" + +#define FAN_PIN 9 // (Sprinter config) +#define HEATER_1_PIN -1 From 859c8d3fefb2e8f4e41d07c06d49d8981cfd84a5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 19 Feb 2015 17:28:38 -0800 Subject: [PATCH 04/17] Azteeg X3 overrides too --- Marlin/pins_AZTEEG_X3.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Marlin/pins_AZTEEG_X3.h diff --git a/Marlin/pins_AZTEEG_X3.h b/Marlin/pins_AZTEEG_X3.h new file mode 100644 index 000000000..d346e0bd2 --- /dev/null +++ b/Marlin/pins_AZTEEG_X3.h @@ -0,0 +1,13 @@ +/** + * AZTEEG_X3 Arduino Mega with RAMPS v1.3 pin assignments + */ + +#include "pins_RAMPS_13.h" + +#define FAN_PIN 9 // (Sprinter config) +#define HEATER_1_PIN -1 + +#ifdef TEMP_STAT_LEDS + #define STAT_LED_RED 6 + #define STAT_LED_BLUE 11 +#endif From 65e1fc71be81406e58c0fa2bea324c504192afb6 Mon Sep 17 00:00:00 2001 From: wgm4321 Date: Thu, 19 Feb 2015 21:42:57 -0500 Subject: [PATCH 05/17] Add encoder rate multiplier --- Marlin/Configuration_adv.h | 5 ++ Marlin/ultralcd.cpp | 131 +++++++++++++++++++++++++++++-------- 2 files changed, 107 insertions(+), 29 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 4d3579d24..890cca91d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -284,6 +284,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 3773ad324..c9c357a84 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -10,6 +10,9 @@ int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ +bool encoderRateMultiplierEnabled; +int32_t lastEncoderMovementMillis; + /* Configuration settings */ int plaPreheatHotendTemp; int plaPreheatHPBTemp; @@ -101,24 +104,25 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l #define ENCODER_FEEDRATE_DEADZONE 10 #if !defined(LCD_I2C_VIKI) - #ifndef ENCODER_STEPS_PER_MENU_ITEM - #define ENCODER_STEPS_PER_MENU_ITEM 5 - #endif - #ifndef ENCODER_PULSES_PER_STEP - #define ENCODER_PULSES_PER_STEP 1 - #endif +#ifndef ENCODER_STEPS_PER_MENU_ITEM +#define ENCODER_STEPS_PER_MENU_ITEM 5 +#endif +#ifndef ENCODER_PULSES_PER_STEP +#define ENCODER_PULSES_PER_STEP 1 +#endif #else - #ifndef ENCODER_STEPS_PER_MENU_ITEM - #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation - #endif - #ifndef ENCODER_PULSES_PER_STEP - #define ENCODER_PULSES_PER_STEP 1 - #endif +#ifndef ENCODER_STEPS_PER_MENU_ITEM +#define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation +#endif +#ifndef ENCODER_PULSES_PER_STEP +#define ENCODER_PULSES_PER_STEP 1 +#endif #endif /* Helper macros for menus */ #define START_MENU() do { \ + encoderRateMultiplierEnabled = false; \ if (encoderPosition > 0x8000) encoderPosition = 0; \ if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\ uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \ @@ -143,9 +147,38 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l }\ _menuItemNr++;\ } while(0) +#ifdef ENCODER_RATE_MULTIPLIER +#define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ + if (_menuItemNr == _lineNr) { \ + if (lcdDrawUpdate) { \ + const char* _label_pstr = PSTR(label); \ + if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ + lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ + }else{\ + lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ + }\ + }\ + if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ + lcd_quick_feedback(); \ + encoderRateMultiplierEnabled = true; \ + lastEncoderMovementMillis = 0; \ + menu_action_ ## type ( args ); \ + return;\ + }\ + }\ + _menuItemNr++;\ +} while(0) +#endif #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0) #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#ifdef ENCODER_RATE_MULTIPLIER +#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) +#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#else +#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) +#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#endif #define END_MENU() \ if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \ if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \ @@ -205,6 +238,7 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool /* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ static void lcd_status_screen() { + encoderRateMultiplierEnabled = false; #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD) uint16_t mil = millis(); #ifndef PROGRESS_MSG_ONCE @@ -423,23 +457,23 @@ static void lcd_tune_menu() MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999); #if TEMP_SENSOR_0 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); #endif #if TEMP_SENSOR_1 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); #endif #if TEMP_SENSOR_2 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); #endif #if TEMP_SENSOR_3 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); #endif #if TEMP_SENSOR_BED != 0 - MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); #endif - MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiply[0], 10, 999); #if TEMP_SENSOR_1 != 0 @@ -816,21 +850,21 @@ static void lcd_control_temperature_menu() START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); #if TEMP_SENSOR_0 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); #endif #if TEMP_SENSOR_1 != 0 && EXTRUDERS > 1 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); #endif #if TEMP_SENSOR_2 != 0 && EXTRUDERS > 2 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); #endif #if TEMP_SENSOR_3 != 0 && EXTRUDERS > 3 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); #endif #if TEMP_SENSOR_BED != 0 - MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); #endif - MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); #if defined AUTOTEMP && (TEMP_SENSOR_0 != 0) MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled); MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15); @@ -961,13 +995,13 @@ static void lcd_control_volumetric_menu() MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers); if (volumetric_enabled) { - MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers); #if EXTRUDERS > 1 - MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers); #if EXTRUDERS > 2 - MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers); #if EXTRUDERS > 3 - MENU_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers); + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers); #endif //EXTRUDERS > 3 #endif //EXTRUDERS > 2 #endif //EXTRUDERS > 1 @@ -1322,8 +1356,47 @@ void lcd_update() #endif if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) { + int32_t encoderMultiplier = 1; + +#ifdef ENCODER_RATE_MULTIPLIER + if (encoderRateMultiplierEnabled) + { + int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; + + if (lastEncoderMovementMillis != 0) + { + // Note that the rate is always calculated between to passes through the + // loop and that the abs of the encoderDiff value is tracked. + float encoderStepRate = + (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0; + + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) + { + encoderMultiplier = 100; + } + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) + { + encoderMultiplier = 10; + } + +#ifdef ENCODER_RATE_MULTIPLIER_DEBUG + SERIAL_ECHO_START; + SERIAL_ECHO("Enc Step Rate: "); + SERIAL_ECHO(encoderStepRate); + SERIAL_ECHO(" Multiplier: "); + SERIAL_ECHO(encoderMultiplier); + SERIAL_ECHO(" ENCODER_10X_STEPS_PER_SEC: "); + SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC); + SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: "); + SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC); +#endif + } + + lastEncoderMovementMillis = millis(); + } +#endif lcdDrawUpdate = 1; - encoderPosition += encoderDiff / ENCODER_PULSES_PER_STEP; + encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; encoderDiff = 0; timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; } From b8e79dce897c970afb9c7721f93943046b1410b9 Mon Sep 17 00:00:00 2001 From: wgm4321 Date: Thu, 19 Feb 2015 21:51:23 -0500 Subject: [PATCH 06/17] Fix compilation errors when encoder multiplier is disabled --- Marlin/Configuration_adv.h | 2 +- Marlin/ultralcd.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 890cca91d..d3795074a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -287,7 +287,7 @@ #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value -#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index c9c357a84..ec9a435d8 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -176,8 +176,8 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #else -#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) -#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) +#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #endif #define END_MENU() \ if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \ From 2d6fa9ce809f60ab8e1a8429f14d06dc3dbf60a8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 19 Feb 2015 23:54:06 -0800 Subject: [PATCH 07/17] Proper implementation of PID menu items - Make this work per #1344 --- Marlin/ultralcd.cpp | 198 ++++++++++++++++++++++++-------------------- 1 file changed, 108 insertions(+), 90 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 3773ad324..dd758724d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -41,11 +41,6 @@ char lcd_status_message[LCD_WIDTH+1] = WELCOME_MSG; #include "ultralcd_implementation_hitachi_HD44780.h" #endif -/** forward declarations **/ - -void copy_and_scalePID_i(); -void copy_and_scalePID_d(); - /* Different menus */ static void lcd_status_screen(); #ifdef ULTIPANEL @@ -185,9 +180,8 @@ void* editValue; int32_t minEditValue, maxEditValue; menuFunc_t callbackFunc; -// place-holders for Ki and Kd edits, and the extruder # being edited +// place-holders for Ki and Kd edits float raw_Ki, raw_Kd; -int pid_current_extruder; static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool feedback=true) { if (currentMenu != menu) { @@ -811,76 +805,120 @@ static void lcd_control_menu() END_MENU(); } +#ifdef PIDTEMP + // Helpers for editing PID Ki & Kd values + // grab the PID value out of the temp variable; scale it; then update the PID driver + void copy_and_scalePID_i(int e) { + PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + updatePID(); + } + void copy_and_scalePID_d(int e) { + PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + updatePID(); + } + void copy_and_scalePID_i_E1() { copy_and_scalePID_i(0); } + void copy_and_scalePID_d_E1() { copy_and_scalePID_d(0); } + #if EXTRUDERS > 1 + void copy_and_scalePID_i_E2() { copy_and_scalePID_i(1); } + void copy_and_scalePID_d_E2() { copy_and_scalePID_d(1); } + #if EXTRUDERS > 2 + void copy_and_scalePID_i_E3() { copy_and_scalePID_i(2); } + void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); } + #if EXTRUDERS > 3 + void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); } + void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); } + #endif + #endif + #endif +#endif + static void lcd_control_temperature_menu() { START_MENU(); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); -#if TEMP_SENSOR_0 != 0 - MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); -#endif -#if TEMP_SENSOR_1 != 0 && EXTRUDERS > 1 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); -#endif -#if TEMP_SENSOR_2 != 0 && EXTRUDERS > 2 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); -#endif -#if TEMP_SENSOR_3 != 0 && EXTRUDERS > 3 - MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); -#endif -#if TEMP_SENSOR_BED != 0 - MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); -#endif - MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); -#if defined AUTOTEMP && (TEMP_SENSOR_0 != 0) - MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled); - MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15); - MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15); - MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0); -#endif -#ifdef PIDTEMP - // set up temp variables - undo the default scaling - pid_current_extruder = 0; - raw_Ki = unscalePID_i(PID_PARAM(Ki,0)); - raw_Kd = unscalePID_d(PID_PARAM(Kd,0)); - MENU_ITEM_EDIT(float52, MSG_PID_P, &PID_PARAM(Kp,0), 1, 9990); - // i is typically a small value so allows values below 1 - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i); - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d); - #ifdef PID_ADD_EXTRUSION_RATE - MENU_ITEM_EDIT(float3, MSG_PID_C, &PID_PARAM(Kc,0), 1, 9990); - #endif//PID_ADD_EXTRUSION_RATE -#ifdef PID_PARAMS_PER_EXTRUDER + #if TEMP_SENSOR_0 != 0 + MENU_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); + #endif #if EXTRUDERS > 1 - // set up temp variables - undo the default scaling - pid_current_extruder = 0; - raw_Ki = unscalePID_i(PID_PARAM(Ki,1)); - raw_Kd = unscalePID_d(PID_PARAM(Kd,1)); - MENU_ITEM_EDIT(float52, MSG_PID_P " E2", &PID_PARAM(Kp,1), 1, 9990); - // i is typically a small value so allows values below 1 - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E2", &raw_Ki, 0.01, 9990, copy_and_scalePID_i); - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E2", &raw_Kd, 1, 9990, copy_and_scalePID_d); - #ifdef PID_ADD_EXTRUSION_RATE - MENU_ITEM_EDIT(float3, MSG_PID_C " E2", &PID_PARAM(Kc,1), 1, 9990); - #endif//PID_ADD_EXTRUSION_RATE - #endif//EXTRUDERS > 1 - #if EXTRUDERS > 2 - // set up temp variables - undo the default scaling - pid_current_extruder = 0; - raw_Ki = unscalePID_i(PID_PARAM(Ki,2)); - raw_Kd = unscalePID_d(PID_PARAM(Kd,2)); - MENU_ITEM_EDIT(float52, MSG_PID_P " E3", &PID_PARAM(Kp,2), 1, 9990); - // i is typically a small value so allows values below 1 - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E3", &raw_Ki, 0.01, 9990, copy_and_scalePID_i); - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E3", &raw_Kd, 1, 9990, copy_and_scalePID_d); + #if TEMP_SENSOR_1 != 0 + MENU_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); + #endif + #if EXTRUDERS > 2 + #if TEMP_SENSOR_2 != 0 + MENU_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); + #endif + #if EXTRUDERS > 2 + #if TEMP_SENSOR_3 != 0 + MENU_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); + #endif + #endif + #endif + #endif + #if TEMP_SENSOR_BED != 0 + MENU_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); + #endif + MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + #if defined AUTOTEMP && (TEMP_SENSOR_0 != 0) + MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled); + MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15); + MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15); + MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0); + #endif + #ifdef PIDTEMP + // set up temp variables - undo the default scaling + raw_Ki = unscalePID_i(PID_PARAM(Ki,0)); + raw_Kd = unscalePID_d(PID_PARAM(Kd,0)); + MENU_ITEM_EDIT(float52, MSG_PID_P, &PID_PARAM(Kp,0), 1, 9990); + // i is typically a small value so allows values below 1 + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E1); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d_E1); + #ifdef PID_ADD_EXTRUSION_RATE + MENU_ITEM_EDIT(float3, MSG_PID_C, &PID_PARAM(Kc,0), 1, 9990); + #endif//PID_ADD_EXTRUSION_RATE + #ifdef PID_PARAMS_PER_EXTRUDER + #if EXTRUDERS > 1 + // set up temp variables - undo the default scaling + raw_Ki = unscalePID_i(PID_PARAM(Ki,1)); + raw_Kd = unscalePID_d(PID_PARAM(Kd,1)); + MENU_ITEM_EDIT(float52, MSG_PID_P " E2", &PID_PARAM(Kp,1), 1, 9990); + // i is typically a small value so allows values below 1 + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E2", &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E2); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E2", &raw_Kd, 1, 9990, copy_and_scalePID_d_E2); #ifdef PID_ADD_EXTRUSION_RATE - MENU_ITEM_EDIT(float3, MSG_PID_C " E3", &PID_PARAM(Kc,2), 1, 9990); + MENU_ITEM_EDIT(float3, MSG_PID_C " E2", &PID_PARAM(Kc,1), 1, 9990); #endif//PID_ADD_EXTRUSION_RATE - #endif//EXTRUDERS > 2 -#endif // PID_PARAMS_PER_EXTRUDER -#endif//PIDTEMP - MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu); - MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu); - END_MENU(); + + #if EXTRUDERS > 2 + // set up temp variables - undo the default scaling + raw_Ki = unscalePID_i(PID_PARAM(Ki,2)); + raw_Kd = unscalePID_d(PID_PARAM(Kd,2)); + MENU_ITEM_EDIT(float52, MSG_PID_P " E3", &PID_PARAM(Kp,2), 1, 9990); + // i is typically a small value so allows values below 1 + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E3", &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E3); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E3", &raw_Kd, 1, 9990, copy_and_scalePID_d_E3); + #ifdef PID_ADD_EXTRUSION_RATE + MENU_ITEM_EDIT(float3, MSG_PID_C " E3", &PID_PARAM(Kc,2), 1, 9990); + #endif//PID_ADD_EXTRUSION_RATE + + #if EXTRUDERS > 3 + // set up temp variables - undo the default scaling + raw_Ki = unscalePID_i(PID_PARAM(Ki,3)); + raw_Kd = unscalePID_d(PID_PARAM(Kd,3)); + MENU_ITEM_EDIT(float52, MSG_PID_P " E4", &PID_PARAM(Kp,3), 1, 9990); + // i is typically a small value so allows values below 1 + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E4", &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E4); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E4", &raw_Kd, 1, 9990, copy_and_scalePID_d_E4); + #ifdef PID_ADD_EXTRUSION_RATE + MENU_ITEM_EDIT(float3, MSG_PID_C " E4", &PID_PARAM(Kc,3), 1, 9990); + #endif//PID_ADD_EXTRUSION_RATE + #endif//EXTRUDERS > 3 + #endif//EXTRUDERS > 2 + #endif//EXTRUDERS > 1 + #endif //PID_PARAMS_PER_EXTRUDER + #endif//PIDTEMP + MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu); + MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu); + END_MENU(); } static void lcd_control_temperature_preheat_pla_settings_menu() @@ -1785,24 +1823,4 @@ char *ftostr52(const float &x) return conv; } -// Callback for after editing PID i value -// grab the PID i value out of the temp variable; scale it; then update the PID driver -void copy_and_scalePID_i() -{ -#ifdef PIDTEMP - PID_PARAM(Ki, pid_current_extruder) = scalePID_i(raw_Ki); - updatePID(); -#endif -} - -// Callback for after editing PID d value -// grab the PID d value out of the temp variable; scale it; then update the PID driver -void copy_and_scalePID_d() -{ -#ifdef PIDTEMP - PID_PARAM(Kd, pid_current_extruder) = scalePID_d(raw_Kd); - updatePID(); -#endif -} - #endif //ULTRA_LCD From c610471b0c8b2dc8c14ec84a25387ea15d6c4cd5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 Feb 2015 00:00:19 -0800 Subject: [PATCH 08/17] Add PID_PARAMS_PER_EXTRUDER conditional --- Marlin/ultralcd.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index dd758724d..99108fee3 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -806,6 +806,7 @@ static void lcd_control_menu() } #ifdef PIDTEMP + // Helpers for editing PID Ki & Kd values // grab the PID value out of the temp variable; scale it; then update the PID driver void copy_and_scalePID_i(int e) { @@ -818,19 +819,22 @@ static void lcd_control_menu() } void copy_and_scalePID_i_E1() { copy_and_scalePID_i(0); } void copy_and_scalePID_d_E1() { copy_and_scalePID_d(0); } - #if EXTRUDERS > 1 - void copy_and_scalePID_i_E2() { copy_and_scalePID_i(1); } - void copy_and_scalePID_d_E2() { copy_and_scalePID_d(1); } - #if EXTRUDERS > 2 - void copy_and_scalePID_i_E3() { copy_and_scalePID_i(2); } - void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); } - #if EXTRUDERS > 3 - void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); } - void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); } - #endif - #endif - #endif -#endif + #ifdef PID_PARAMS_PER_EXTRUDER + #if EXTRUDERS > 1 + void copy_and_scalePID_i_E2() { copy_and_scalePID_i(1); } + void copy_and_scalePID_d_E2() { copy_and_scalePID_d(1); } + #if EXTRUDERS > 2 + void copy_and_scalePID_i_E3() { copy_and_scalePID_i(2); } + void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); } + #if EXTRUDERS > 3 + void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); } + void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); } + #endif //EXTRUDERS > 3 + #endif //EXTRUDERS > 2 + #endif //EXTRUDERS > 1 + #endif //PID_PARAMS_PER_EXTRUDER + +#endif //PIDTEMP static void lcd_control_temperature_menu() { From e3fd3e8fa4476b192a49f74a1fd7004237d2fb38 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 Feb 2015 00:08:59 -0800 Subject: [PATCH 09/17] Fix typos in checkExtruderAutoFans --- Marlin/temperature.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index d5bd2d63d..d50c4265b 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -455,19 +455,17 @@ void checkExtruderAutoFans() setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); #endif #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 - if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); #endif #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 - if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN - && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) + if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN && EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); #endif #if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1 - if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN - && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) - && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) + if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN + && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN) setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0); #endif From 09e09b308e3edb16fb383fe30c14a5b40c08e27e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 Feb 2015 01:22:56 -0800 Subject: [PATCH 10/17] Tweaky spacing adjustments --- Marlin/ultralcd.cpp | 108 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index ec9a435d8..387437d27 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -154,18 +154,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l const char* _label_pstr = PSTR(label); \ if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ - }else{\ + }else{\ lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ - }\ - }\ + }\ + }\ if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ lcd_quick_feedback(); \ - encoderRateMultiplierEnabled = true; \ - lastEncoderMovementMillis = 0; \ + encoderRateMultiplierEnabled = true; \ + lastEncoderMovementMillis = 0; \ menu_action_ ## type ( args ); \ return;\ - }\ - }\ + }\ + }\ _menuItemNr++;\ } while(0) #endif @@ -460,20 +460,20 @@ static void lcd_tune_menu() MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); #endif #if TEMP_SENSOR_1 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); #endif #if TEMP_SENSOR_2 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); #endif #if TEMP_SENSOR_3 != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); #endif #if TEMP_SENSOR_BED != 0 - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); #endif - MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); + MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiply[0], 10, 999); #if TEMP_SENSOR_1 != 0 @@ -650,7 +650,7 @@ static void lcd_preheat_abs_menu() MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(function, MSG_PREHEAT_ABS_N "1", lcd_preheat_abs0); #if TEMP_SENSOR_1 != 0 //2 extruder preheat - MENU_ITEM(function, MSG_PREHEAT_ABS_N "2", lcd_preheat_abs1); + MENU_ITEM(function, MSG_PREHEAT_ABS_N "2", lcd_preheat_abs1); #endif //2 extruder preheat #if TEMP_SENSOR_2 != 0 //3 extruder preheat MENU_ITEM(function, MSG_PREHEAT_ABS_N "3", lcd_preheat_abs2); @@ -995,16 +995,16 @@ static void lcd_control_volumetric_menu() MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers); if (volumetric_enabled) { - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers); -#if EXTRUDERS > 1 - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers); -#if EXTRUDERS > 2 - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers); -#if EXTRUDERS > 3 - MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers); -#endif //EXTRUDERS > 3 -#endif //EXTRUDERS > 2 -#endif //EXTRUDERS > 1 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_0, &filament_size[0], 1.5, 3.25, calculate_volumetric_multipliers); + #if EXTRUDERS > 1 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_1, &filament_size[1], 1.5, 3.25, calculate_volumetric_multipliers); + #if EXTRUDERS > 2 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_2, &filament_size[2], 1.5, 3.25, calculate_volumetric_multipliers); + #if EXTRUDERS > 3 + MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER_3, &filament_size[3], 1.5, 3.25, calculate_volumetric_multipliers); + #endif //EXTRUDERS > 3 + #endif //EXTRUDERS > 2 + #endif //EXTRUDERS > 1 } END_MENU(); @@ -1356,47 +1356,47 @@ void lcd_update() #endif if (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP) { - int32_t encoderMultiplier = 1; + int32_t encoderMultiplier = 1; #ifdef ENCODER_RATE_MULTIPLIER - if (encoderRateMultiplierEnabled) - { - int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; + if (encoderRateMultiplierEnabled) + { + int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; - if (lastEncoderMovementMillis != 0) - { - // Note that the rate is always calculated between to passes through the - // loop and that the abs of the encoderDiff value is tracked. - float encoderStepRate = - (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0; + if (lastEncoderMovementMillis != 0) + { + // Note that the rate is always calculated between to passes through the + // loop and that the abs of the encoderDiff value is tracked. + float encoderStepRate = + (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0; - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) - { - encoderMultiplier = 100; - } - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) - { - encoderMultiplier = 10; - } + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) + { + encoderMultiplier = 100; + } + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) + { + encoderMultiplier = 10; + } #ifdef ENCODER_RATE_MULTIPLIER_DEBUG - SERIAL_ECHO_START; - SERIAL_ECHO("Enc Step Rate: "); - SERIAL_ECHO(encoderStepRate); - SERIAL_ECHO(" Multiplier: "); - SERIAL_ECHO(encoderMultiplier); - SERIAL_ECHO(" ENCODER_10X_STEPS_PER_SEC: "); - SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC); - SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: "); - SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC); + SERIAL_ECHO_START; + SERIAL_ECHO("Enc Step Rate: "); + SERIAL_ECHO(encoderStepRate); + SERIAL_ECHO(" Multiplier: "); + SERIAL_ECHO(encoderMultiplier); + SERIAL_ECHO(" ENCODER_10X_STEPS_PER_SEC: "); + SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC); + SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: "); + SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC); #endif - } + } - lastEncoderMovementMillis = millis(); - } + lastEncoderMovementMillis = millis(); + } #endif lcdDrawUpdate = 1; - encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; + encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; encoderDiff = 0; timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; } From a8939eec28fc3c5225d665ffe15515ad63d273a8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 Feb 2015 02:08:41 -0800 Subject: [PATCH 11/17] Readability of MENU_MULTIPLIER_ITEM Last commit before bed. --- Marlin/ultralcd.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 387437d27..da7a2685c 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -150,22 +150,23 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l #ifdef ENCODER_RATE_MULTIPLIER #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ if (_menuItemNr == _lineNr) { \ - if (lcdDrawUpdate) { \ - const char* _label_pstr = PSTR(label); \ - if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ - lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ - }else{\ - lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ - }\ - }\ - if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ - lcd_quick_feedback(); \ - encoderRateMultiplierEnabled = true; \ - lastEncoderMovementMillis = 0; \ - menu_action_ ## type ( args ); \ - return;\ - }\ + if (lcdDrawUpdate) { \ + const char* _label_pstr = PSTR(label); \ + if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ + lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ + } + else {\ + lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ }\ + }\ + if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ + lcd_quick_feedback(); \ + encoderRateMultiplierEnabled = true; \ + lastEncoderMovementMillis = 0; \ + menu_action_ ## type ( args ); \ + return;\ + }\ + }\ _menuItemNr++;\ } while(0) #endif From 430c4b65385f2e45b8d564bf1afe36949052fbd7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 Feb 2015 02:17:16 -0800 Subject: [PATCH 12/17] Replace missing backslash --- Marlin/ultralcd.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index da7a2685c..710f96590 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -154,20 +154,20 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l const char* _label_pstr = PSTR(label); \ if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ - } - else {\ + } \ + else { \ lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ - }\ - }\ - if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ + } \ + } \ + if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ lcd_quick_feedback(); \ encoderRateMultiplierEnabled = true; \ lastEncoderMovementMillis = 0; \ menu_action_ ## type ( args ); \ - return;\ - }\ - }\ - _menuItemNr++;\ + return; \ + } \ + } \ + _menuItemNr++; \ } while(0) #endif #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0) From 27ac3e985d9c18f8df27edcceedcbd6b8f7b8bb1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Feb 2015 18:17:37 -0800 Subject: [PATCH 13/17] Add options to example_configurations --- Marlin/Configuration_adv.h | 6 +++--- Marlin/example_configurations/Hephestos/Configuration_adv.h | 5 +++++ Marlin/example_configurations/K8200/Configuration_adv.h | 5 +++++ Marlin/example_configurations/SCARA/Configuration_adv.h | 5 +++++ Marlin/example_configurations/WITBOX/Configuration_adv.h | 5 +++++ Marlin/example_configurations/delta/Configuration_adv.h | 5 +++++ Marlin/example_configurations/makibox/Configuration_adv.h | 5 +++++ .../tvrrug/Round2/Configuration_adv.h | 5 +++++ 8 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d3795074a..f2b312441 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -284,10 +284,10 @@ //=============================Additional Features=========================== //=========================================================================== -#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly -#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value -//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 1412c9941..0a9c8a129 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -284,6 +284,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index b3d9ed840..bf2daede0 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -284,6 +284,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 215ee494d..a32669881 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -287,6 +287,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 1412c9941..0a9c8a129 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -284,6 +284,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/delta/Configuration_adv.h b/Marlin/example_configurations/delta/Configuration_adv.h index 79d2036a0..9b49bfe1e 100644 --- a/Marlin/example_configurations/delta/Configuration_adv.h +++ b/Marlin/example_configurations/delta/Configuration_adv.h @@ -279,6 +279,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index 6c181fb55..1033b9989 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -283,6 +283,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index 64fd9ecc9..df413f6e6 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -284,6 +284,11 @@ //=============================Additional Features=========================== //=========================================================================== +#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly +#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceed this value, multiple the steps moved by ten to quickly advance the value +#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceed this value, multiple the steps moved by 100 to really quickly advance the value +//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value + //#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/ #define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again From 422582da71189b7e516bb0bb85feedc2eeae15cb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Feb 2015 18:24:16 -0800 Subject: [PATCH 14/17] Prep formatting for upcoming PR --- Marlin/ultralcd.cpp | 60 ++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 9bd50d565..a1a1b187d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -143,7 +143,7 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l _menuItemNr++;\ } while(0) #ifdef ENCODER_RATE_MULTIPLIER -#define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ + #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ if (_menuItemNr == _lineNr) { \ if (lcdDrawUpdate) { \ const char* _label_pstr = PSTR(label); \ @@ -163,18 +163,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l } \ } \ _menuItemNr++; \ -} while(0) -#endif + } while(0) +#endif //ENCODER_RATE_MULTIPLIER #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0) #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #ifdef ENCODER_RATE_MULTIPLIER -#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) -#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) -#else -#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) -#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) -#endif + #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) + #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#else //!ENCODER_RATE_MULTIPLIER + #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) + #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) +#endif //!ENCODER_RATE_MULTIPLIER #define END_MENU() \ if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \ if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \ @@ -1422,28 +1422,21 @@ void lcd_update() { int32_t encoderMultiplier = 1; -#ifdef ENCODER_RATE_MULTIPLIER - if (encoderRateMultiplierEnabled) - { - int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; + #ifdef ENCODER_RATE_MULTIPLIER - if (lastEncoderMovementMillis != 0) - { - // Note that the rate is always calculated between to passes through the - // loop and that the abs of the encoderDiff value is tracked. - float encoderStepRate = - (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0; + if (encoderRateMultiplierEnabled) { + int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP; - if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) - { - encoderMultiplier = 100; - } - else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) - { - encoderMultiplier = 10; - } + if (lastEncoderMovementMillis != 0) { + // Note that the rate is always calculated between to passes through the + // loop and that the abs of the encoderDiff value is tracked. + float encoderStepRate = + (float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0; -#ifdef ENCODER_RATE_MULTIPLIER_DEBUG + if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100; + else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10; + + #ifdef ENCODER_RATE_MULTIPLIER_DEBUG SERIAL_ECHO_START; SERIAL_ECHO("Enc Step Rate: "); SERIAL_ECHO(encoderStepRate); @@ -1453,12 +1446,13 @@ void lcd_update() SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC); SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: "); SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC); -#endif - } - - lastEncoderMovementMillis = millis(); + #endif //ENCODER_RATE_MULTIPLIER_DEBUG } -#endif + + lastEncoderMovementMillis = millis(); + } + #endif //ENCODER_RATE_MULTIPLIER + lcdDrawUpdate = 1; encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP; encoderDiff = 0; From 3a26804d80c0c14e34bf867e1b076b2285b9918a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Feb 2015 18:41:04 -0800 Subject: [PATCH 15/17] Adapt to latest PID code and fix typos --- Marlin/ultralcd.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index a1a1b187d..babdb98ec 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -863,7 +863,7 @@ static void lcd_control_menu() void copy_and_scalePID_d_E3() { copy_and_scalePID_d(2); } #if EXTRUDERS > 3 void copy_and_scalePID_i_E4() { copy_and_scalePID_i(3); } - void copy_and_scalePID_d_E5() { copy_and_scalePID_d(3); } + void copy_and_scalePID_d_E4() { copy_and_scalePID_d(3); } #endif //EXTRUDERS > 3 #endif //EXTRUDERS > 2 #endif //EXTRUDERS > 1 @@ -905,13 +905,12 @@ static void lcd_control_temperature_menu() #endif #ifdef PIDTEMP // set up temp variables - undo the default scaling - pid_current_extruder = 0; raw_Ki = unscalePID_i(PID_PARAM(Ki,0)); raw_Kd = unscalePID_d(PID_PARAM(Kd,0)); MENU_ITEM_EDIT(float52, MSG_PID_P, &PID_PARAM(Kp,0), 1, 9990); // i is typically a small value so allows values below 1 - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i); - MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E1); + MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d_E1); #ifdef PID_ADD_EXTRUSION_RATE MENU_ITEM_EDIT(float3, MSG_PID_C, &PID_PARAM(Kc,0), 1, 9990); #endif//PID_ADD_EXTRUSION_RATE From 1c13cd604bfb15a03d09f186520f7f531a1624ef Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 21 Feb 2015 18:45:10 -0800 Subject: [PATCH 16/17] Formatting in babysteps defines --- Marlin/ultralcd.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index babdb98ec..51658f141 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -99,19 +99,19 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l #define ENCODER_FEEDRATE_DEADZONE 10 #if !defined(LCD_I2C_VIKI) -#ifndef ENCODER_STEPS_PER_MENU_ITEM -#define ENCODER_STEPS_PER_MENU_ITEM 5 -#endif -#ifndef ENCODER_PULSES_PER_STEP -#define ENCODER_PULSES_PER_STEP 1 -#endif + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 5 + #endif + #ifndef ENCODER_PULSES_PER_STEP + #define ENCODER_PULSES_PER_STEP 1 + #endif #else -#ifndef ENCODER_STEPS_PER_MENU_ITEM -#define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation -#endif -#ifndef ENCODER_PULSES_PER_STEP -#define ENCODER_PULSES_PER_STEP 1 -#endif + #ifndef ENCODER_STEPS_PER_MENU_ITEM + #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation + #endif + #ifndef ENCODER_PULSES_PER_STEP + #define ENCODER_PULSES_PER_STEP 1 + #endif #endif From a57869ba496ba7848e30fd0645204e6b41de4a07 Mon Sep 17 00:00:00 2001 From: alexborro Date: Sun, 22 Feb 2015 11:02:04 -0300 Subject: [PATCH 17/17] Dummy Thermistor Table for testing purposes Am I the only one who always need to change the thermistortable.h to add a dummy table?? Ok, it is done. Just set the thermistor to 999 and it will always read 25C. Great for Testing or Development purposes. --- Marlin/Configuration.h | 1 + Marlin/thermistortables.h | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 41e1ed7ed..afcd9134c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -118,6 +118,7 @@ Here are some standard links for getting your machine calibrated: // 1010 is Pt1000 with 1k pullup (non standard) // 147 is Pt100 with 4k7 pullup // 110 is Pt100 with 1k pullup (non standard) +// 999 is a Dummy Table. It will ALWAYS read 25C.. Use it for Testing or Development purposes. NEVER for production machine. #define TEMP_SENSOR_0 -1 #define TEMP_SENSOR_1 -1 diff --git a/Marlin/thermistortables.h b/Marlin/thermistortables.h index 599d0d05c..aa1019b0a 100644 --- a/Marlin/thermistortables.h +++ b/Marlin/thermistortables.h @@ -1095,6 +1095,16 @@ const short temptable_1047[][2] PROGMEM = { }; #endif +#if (THERMISTORHEATER_0 == 999) || (THERMISTORHEATER_1 == 999) || (THERMISTORHEATER_2 == 999) || (THERMISTORHEATER_3 == 999) || (THERMISTORBED == 999) //User defined table +// Dummy Thermistor table.. It will ALWAYS read 25C. +const short temptable_999[][2] PROGMEM = { + {1*OVERSAMPLENR, 25}, + {1023*OVERSAMPLENR, 25} +}; +#endif + + + #define _TT_NAME(_N) temptable_ ## _N #define TT_NAME(_N) _TT_NAME(_N)