Compare commits

...

90 Commits

Author SHA1 Message Date
InsanityAutomation aac6724398 Update pins_GMARSH_EBAB.h 2021-01-23 11:48:02 -05:00
InsanityAutomation 8bab8954c4 Put in or for spi pins on 208 package 2021-01-19 14:31:52 -05:00
InsanityAutomation 9bdc1187d0 Initial Commit 2021-01-19 14:31:44 -05:00
Katelyn Schiesser fda9fb563b Raise Z on exit from 'Level Bed Corners' (#20817) 2021-01-18 21:59:18 -06:00
Scott Lahteine 49b5e1d9bf Clean up whitespace, headings 2021-01-18 21:54:23 -06:00
thinkyhead eb84acaf5b [cron] Bump distribution date (2021-01-19) 2021-01-19 00:45:26 +00:00
thinkyhead e9364c7cba [cron] Bump distribution date (2021-01-18) 2021-01-18 00:41:57 +00:00
Scott Lahteine 08f392cdd3 OS-native targets for "mftest -a" 2021-01-17 15:45:04 -06:00
Scott Lahteine bb597dcf66 Internal G29N for G28+G29 (#20800) 2021-01-17 12:08:40 -06:00
George Fu fec58157ac FYSETC_242 OLED 12864 for S6 (#20767) 2021-01-17 00:46:57 -06:00
Scott Lahteine 6be8ffb771 Reduce some G-code strings 2021-01-16 23:18:02 -06:00
zeleps 1b19eed195 Fix Tramming Wizard behavior (#20796) 2021-01-16 23:08:48 -06:00
Scott Lahteine fb41413b76 Optimize some G-code strings 2021-01-16 22:53:50 -06:00
Scott Lahteine 40c8f2001d Apply bool to some MKS UI 2021-01-16 22:53:50 -06:00
Scott Lahteine b41f41589a General cleanup, use _BV 2021-01-16 22:53:50 -06:00
ellensp 69a6d26c80 Fix Trigorilla Pro STOP pins (#20801) 2021-01-16 22:34:54 -06:00
Alexander D. Kanevskiy 0fef29b6e3 NEOPIXEL overridable on BTT SKR (#20797) 2021-01-16 19:51:08 -06:00
Martin f7e2467da1 4 / 5 digits for some edit items (#20793) 2021-01-16 19:49:34 -06:00
Giuliano Zaro dc44edc1b8 Update Italian language (#20789) 2021-01-16 19:20:35 -06:00
thinkyhead ca53d88284 [cron] Bump distribution date (2021-01-17) 2021-01-17 00:42:42 +00:00
ellensp 5e46f63e17 Fix Ender-3 V2 DWIN LPC signed warnings (#20786) 2021-01-16 00:50:25 -06:00
RFBomb 43a91e5963 Configurable Corner Leveling point order (#20733) 2021-01-16 00:43:38 -06:00
Giuliano Zaro 1d5862a39b MMU2 as standard serial device (#20771) 2021-01-15 20:38:34 -06:00
thinkyhead 7c786506e1 [cron] Bump distribution date (2021-01-16) 2021-01-16 00:45:54 +00:00
Marcio Teixeira d03c3980de Improve filament runout handling in FTDI EVE Touch UI
- On filament runout, take the user to the tune menu where they can initiate a filament change or resume the print.
2021-01-15 17:44:16 -06:00
Marcio T 9bbe9455cf Fix compatibility macros 2021-01-15 17:44:16 -06:00
Marcio Teixeira 6376b683c7 Silence unused parameter warnings 2021-01-15 17:44:16 -06:00
Jelmer van der Stel 9dba7cd371 Fix Ender 3 V2 encoder (#20784) 2021-01-15 17:23:04 -06:00
thinkyhead 49e252df03 [cron] Bump distribution date (2021-01-15) 2021-01-15 00:42:52 +00:00
EvilGremlin 8049db20ff ESP32 Tone Generator (#20704) 2021-01-14 02:33:50 -06:00
vitaliy172 ecf5f5d21d Update Ukrainian language (#20668) 2021-01-14 02:21:28 -06:00
Scott Lahteine 12a39450b0 MKS prelim. cleanup (2) 2021-01-14 00:56:35 -06:00
Scott Lahteine c753fc690f More MKS UI prelim. cleanup 2021-01-14 00:27:10 -06:00
MKS-Sean 35c1b330ec MKS WiFi for TFT_LVGL_UI (#20191) 2021-01-13 22:41:09 -06:00
thinkyhead a88ae2080c [cron] Bump distribution date (2021-01-14) 2021-01-14 00:47:36 +00:00
Scott Lahteine e8aa6ab735 Ignore M22 during SD print 2021-01-12 22:33:03 -06:00
Scott Lahteine f2726399dd Move WRITE_FAN 2021-01-12 22:33:03 -06:00
Scott Lahteine d47e694048 whitespace 2021-01-12 22:33:03 -06:00
Scott Lahteine 44c57ab05a MKS UI prelim. cleanup (#20763) 2021-01-12 21:02:35 -06:00
Scott Lahteine 4a89731025 Rotary encoder cleanup (#20753) 2021-01-12 20:43:52 -06:00
Giuliano Zaro 2b928b4754 Fix comments (#20759) 2021-01-12 19:38:51 -06:00
thinkyhead 923ca6f104 [cron] Bump distribution date (2021-01-13) 2021-01-13 00:40:12 +00:00
Scott Lahteine 4472ba2b6b Ok to use C++11 'auto' 2021-01-12 18:08:24 -06:00
Johan van der Vyver 7f3dcb3e8a Multi-platform DWIN_CREALITY_LCD support (#20738)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2021-01-12 18:05:49 -06:00
thinkyhead a26f2fb00b [cron] Bump distribution date (2021-01-12) 2021-01-12 00:33:31 +00:00
devin122 8ff87c120a Fix TMC220x short circuit (#20731) 2021-01-11 01:46:17 -06:00
Serhiy-K 4327b5c1b0 Fixes for TFTGLCD (#20734) 2021-01-10 23:59:42 -06:00
Victor Oliveira d6de6de1bb NO_SD_DETECT option (#20741) 2021-01-10 21:55:16 -06:00
Scott Lahteine 9eecb2f542 Fix joystick include 2021-01-10 21:49:35 -06:00
Scott Lahteine 54debf855c Tweak STM32F1 pin r/w/t 2021-01-10 21:38:31 -06:00
Scott Lahteine acda53aa1c Clean up some includes 2021-01-10 21:38:31 -06:00
Scott Lahteine 71921bc9b2 Update Slovak glyphs 2021-01-10 21:38:31 -06:00
thinkyhead bc5c52dc95 [cron] Bump distribution date (2021-01-11) 2021-01-11 00:30:23 +00:00
Mike La Spina cf1f8aff77 Laser Test Fire (#20452) 2021-01-10 06:01:25 -06:00
Anthony Rich d78f2926ec Wanhao One+ SD detect pin (#20724) 2021-01-10 05:50:09 -06:00
thinkyhead 46916d322e [cron] Bump distribution date (2021-01-10) 2021-01-10 00:30:52 +00:00
Scott Lahteine 299f849ffa Optimize some G76 strings 2021-01-09 00:09:03 -06:00
Dmitry Katsubo bbf06152da Fix misc. warnings (#20715) 2021-01-08 18:55:36 -06:00
Scott Lahteine 8ffae97128 Fix Python 2.7 compatibility
Fix regression from #20692
2021-01-08 18:51:54 -06:00
Markus d4ac8bc67b Up to 6 Tramming points (#20720) 2021-01-08 18:42:08 -06:00
thinkyhead 8e1637a2cc [cron] Bump distribution date (2021-01-09) 2021-01-09 00:29:33 +00:00
thinkyhead 4e8d92bece [cron] Bump distribution date (2021-01-08) 2021-01-08 00:29:39 +00:00
qwewer0 4eedeabb51 Fix M48 output (#20713) 2021-01-07 17:55:57 -06:00
TheCodeExorcist 3009707723 Improved MKS Robin support (#19333) 2021-01-06 21:13:15 -06:00
Java 8edcf03715 Preheat before Power Loss Recovery homing (#20697) 2021-01-06 20:57:11 -06:00
thinkyhead abea8ff8f4 [cron] Bump distribution date (2021-01-07) 2021-01-07 00:30:20 +00:00
Scott Lahteine 3dd1fe4211 Custom build_flags by feature (#20692) 2021-01-05 21:03:13 -06:00
thinkyhead d2969d2326 [cron] Bump distribution date (2021-01-06) 2021-01-06 00:27:10 +00:00
wilbur4321 e3831c146d Multi-Z stepper inverting (#20678)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
2021-01-05 17:03:45 -06:00
ellensp 218de578e0 Fix Azteeg X3 macro typo (#20681) 2021-01-05 06:23:56 -06:00
ellensp 87fbda8344 Define SANGUINOLOLU 1.1 enable pins (#20682) 2021-01-05 06:22:51 -06:00
ellensp e9ab6c10cf No BTN_ENC_EN on Anet 10 (#20684) 2021-01-05 06:21:08 -06:00
Giuliano Zaro 1eb592550c Temperature report followup (#20687)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2021-01-05 06:18:09 -06:00
FanDjango dc3cfd0d9d Adjustable precision in M105 temperature report (#20602)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2021-01-04 23:57:58 -06:00
zeleps 2f17f2207a Don't apply hotend_offset.z to Z soft endstops (#20675)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
2021-01-04 23:48:42 -06:00
Scott Lahteine d2e1e9a0ac Indent tool_change_prime 2021-01-04 23:36:12 -06:00
Scott Lahteine c0a3931595 Clarify solenoid active / magnet-on state 2021-01-04 23:09:35 -06:00
FanDjango 55d1938977 Defer "quiet probing" till the last Z bump (#20610) 2021-01-04 20:32:52 -06:00
Scott Lahteine 3a99d001ff Solenoid cleanups
Followups to #20473 ahead of #20675
2021-01-04 19:01:45 -06:00
thinkyhead 7033003c36 [cron] Bump distribution date (2021-01-05) 2021-01-05 00:26:38 +00:00
Scott Lahteine 21c7e699f1 Remove untranslated strings 2021-01-04 18:18:45 -06:00
Scott Lahteine 208200a3cc G34/M422 cleanup 2021-01-04 17:52:00 -06:00
Scott Lahteine ba2cadb479 Move duplication_e_mask 2021-01-03 22:23:13 -06:00
Scott Lahteine ca47dffa35 Fix delayed_move_time elapsed test 2021-01-03 22:22:21 -06:00
InsanityAutomation 548d5603ea Fix IDEX reboot on travel after G28 X (#20654) 2021-01-03 22:07:29 -06:00
InsanityAutomation 6b458676b1 Fix SD SPI Speed override, FTDI mesh edit (#20657)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
2021-01-03 21:59:48 -06:00
Scott Lahteine 63448f3244 Rename FTDI EVE screen data structs 2021-01-03 21:52:05 -06:00
Marcio T 2d88bcb67e Fix thermal error protection, reporting (#20655) 2021-01-03 21:39:15 -06:00
thinkyhead effc37362a [cron] Bump distribution date (2021-01-04) 2021-01-04 00:26:24 +00:00
Giuliano Zaro 3ba80d11eb Update Italian language (#20663) 2021-01-03 17:43:31 -06:00
311 changed files with 4666 additions and 3868 deletions
+27 -4
View File
@@ -128,7 +128,7 @@
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
#define MOTHERBOARD BOARD_RAMPS_14_EFB
#define MOTHERBOARD BOARD_GMARSH_EBAB
#endif
// Name displayed in the LCD "Ready" message and Info menu
@@ -1089,7 +1089,7 @@
//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing
//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
// Require minimum nozzle and/or bed temperature for probing.
// Require minimum nozzle and/or bed temperature for probing
//#define PREHEAT_BEFORE_PROBING
#if ENABLED(PREHEAT_BEFORE_PROBING)
#define PROBING_NOZZLE_TEMP 120 // (°C) Only applies to E0 at this time
@@ -1451,6 +1451,25 @@
#define LEVEL_CORNERS_VERIFY_RAISED // After adjustment triggers the probe, re-probe to verify
//#define LEVEL_CORNERS_AUDIO_FEEDBACK
#endif
/**
* Corner Leveling Order
*
* Set 2 or 4 points. When 2 points are given, the 3rd is the center of the opposite edge.
*
* LF Left-Front RF Right-Front
* LB Left-Back RB Right-Back
*
* Examples:
*
* Default {LF,RB,LB,RF} {LF,RF} {LB,LF}
* LB --------- RB LB --------- RB LB --------- RB LB --------- RB
* | 4 3 | | 3 2 | | <3> | | 1 |
* | | | | | | | <3>|
* | 1 2 | | 1 4 | | 1 2 | | 2 |
* LF --------- RF LF --------- RF LF --------- RF LF --------- RF
*/
#define LEVEL_CORNERS_LEVELING_ORDER { LF, RF, RB, LB }
#endif
/**
@@ -1821,7 +1840,7 @@
* SD Card support is disabled by default. If your controller has an SD slot,
* you must uncomment the following option or it won't work.
*/
//#define SDSUPPORT
#define SDSUPPORT
/**
* SD CARD: ENABLE CRC
@@ -2395,6 +2414,10 @@
//#define TFT_COLOR_UI
//#define TFT_LVGL_UI
#if ENABLED(TFT_LVGL_UI)
//#define MKS_WIFI_MODULE // MKS WiFi module
#endif
/**
* TFT Rotation. Set to one of the following values:
*
@@ -2428,7 +2451,7 @@
//#define TOUCH_CALIBRATION_Y -8981
//#define TOUCH_OFFSET_X -43
//#define TOUCH_OFFSET_Y 257
//#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
//#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#if ENABLED(TFT_COLOR_UI)
//#define SINGLE_TOUCH_NAVIGATION
+17 -8
View File
@@ -552,7 +552,7 @@
//#define X_DUAL_STEPPER_DRIVERS
#if ENABLED(X_DUAL_STEPPER_DRIVERS)
#define INVERT_X2_VS_X_DIR true // Set 'true' if X motors should rotate in opposite directions
//#define INVERT_X2_VS_X_DIR // Enable if X2 direction signal is opposite to X
//#define X_DUAL_ENDSTOPS
#if ENABLED(X_DUAL_ENDSTOPS)
#define X2_USE_ENDSTOP _XMAX_
@@ -562,7 +562,7 @@
//#define Y_DUAL_STEPPER_DRIVERS
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#define INVERT_Y2_VS_Y_DIR true // Set 'true' if Y motors should rotate in opposite directions
//#define INVERT_Y2_VS_Y_DIR // Enable if Y2 direction signal is opposite to Y
//#define Y_DUAL_ENDSTOPS
#if ENABLED(Y_DUAL_ENDSTOPS)
#define Y2_USE_ENDSTOP _YMAX_
@@ -576,6 +576,11 @@
#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many
#if NUM_Z_STEPPER_DRIVERS > 1
// Enable if Z motor direction signals are the opposite of Z1
//#define INVERT_Z2_VS_Z_DIR
//#define INVERT_Z3_VS_Z_DIR
//#define INVERT_Z4_VS_Z_DIR
//#define Z_MULTI_ENDSTOPS
#if ENABLED(Z_MULTI_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_
@@ -1383,13 +1388,16 @@
* Set this option to one of the following (or the board's defaults apply):
*
* LCD - Use the SD drive in the external LCD controller.
* ONBOARD - Use the SD drive on the control board. (No SD_DETECT_PIN. M21 to init.)
* ONBOARD - Use the SD drive on the control board.
* CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file).
*
* :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ]
*/
//#define SDCARD_CONNECTION LCD
// Enable if SD detect is rendered useless (e.g., by using an SD extender)
//#define NO_SD_DETECT
#endif // SDSUPPORT
/**
@@ -3050,6 +3058,10 @@
#define SPEED_POWER_MAX 100 // (%) 0-100
#define SPEED_POWER_STARTUP 80 // (%) M3/M4 speed/power default (with no arguments)
// Define the minimum and maximum test pulse time values for a laser test fire function
#define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu
#define LASER_TEST_PULSE_MAX 999 // Caution: Menu may not show more than 3 characters
/**
* Enable inline laser power to be handled in the planner / stepper routines.
* Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I)
@@ -3332,7 +3344,7 @@
//#define USER_SCRIPT_RETURN // Return to status screen after a script
#define USER_DESC_1 "Home & UBL Info"
#define USER_GCODE_1 "G28\nG29 W"
#define USER_GCODE_1 "G29NW"
#define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
#define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
@@ -3341,7 +3353,7 @@
#define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
#define USER_DESC_4 "Heat Bed/Home/Level"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG29N"
#define USER_DESC_5 "Home & Info"
#define USER_GCODE_5 "G28\nM503"
@@ -3589,10 +3601,7 @@
//#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs
#elif HAS_PRUSA_MMU2
// Serial port used for communication with MMU2.
// For AVR enable the UART port used for the MMU. (e.g., mmuSerial)
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
#define MMU2_SERIAL_PORT 2
#define MMU2_SERIAL mmuSerial
// Use hardware reset for MMU if a pin is defined for it
//#define MMU2_RST_PIN 23
+7
View File
@@ -97,6 +97,13 @@ typedef int8_t pin_t;
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if !WITHIN(MMU2_SERIAL_PORT, -1, 3)
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#define MMU2_SERIAL mmuSerial
#endif
#ifdef LCD_SERIAL_PORT
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
#error "LCD_SERIAL_PORT must be from -1 to 3. Please update your configuration."
+8
View File
@@ -59,6 +59,14 @@
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU2_SERIAL MSERIAL(SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be from 0 to 3. Please update your configuration."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL lcdSerial
+1 -1
View File
@@ -50,7 +50,7 @@
#define PWM_PIN(P) WITHIN(P, 2, 13)
#ifndef MASK
#define MASK(PIN) (1 << PIN)
#define MASK(PIN) _BV(PIN)
#endif
/**
+1 -1
View File
@@ -121,7 +121,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
// missing from CMSIS: Check if interrupt is enabled or not
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
+7
View File
@@ -90,6 +90,13 @@ extern uint16_t HAL_adc_result;
// Public functions
// ------------------------
//
// Tone
//
void toneInit();
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
void noTone(const pin_t _pin);
// clear reset reason
void HAL_clear_reset_source();
+1 -1
View File
@@ -30,7 +30,7 @@ class Servo {
MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
TAU_MSEC = 20,
TAU_USEC = (TAU_MSEC * 1000),
MAX_COMPARE = ((1 << 16) - 1), // 65535
MAX_COMPARE = _BV(16) - 1, // 65535
CHANNEL_MAX_NUM = 16;
public:
+59
View File
@@ -0,0 +1,59 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* Description: Tone function for ESP32
* Derived from https://forum.arduino.cc/index.php?topic=136500.msg2903012#msg2903012
*/
#ifdef ARDUINO_ARCH_ESP32
#include "../../inc/MarlinConfig.h"
#include "HAL.h"
static pin_t tone_pin;
volatile static int32_t toggles;
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
tone_pin = _pin;
toggles = 2 * frequency * duration / 1000;
HAL_timer_start(TONE_TIMER_NUM, 2 * frequency);
}
void noTone(const pin_t _pin) {
HAL_timer_disable_interrupt(TONE_TIMER_NUM);
WRITE(_pin, LOW);
}
HAL_TONE_TIMER_ISR() {
HAL_timer_isr_prologue(TONE_TIMER_NUM);
if (toggles) {
toggles--;
TOGGLE(tone_pin);
}
else noTone(tone_pin); // turn off interrupt
}
#endif // ARDUINO_ARCH_ESP32
+1 -1
View File
@@ -45,7 +45,7 @@ const tTimerConfig TimerConfig [NUM_HARDWARE_TIMERS] = {
{ TIMER_GROUP_0, TIMER_0, STEPPER_TIMER_PRESCALE, stepTC_Handler }, // 0 - Stepper
{ TIMER_GROUP_0, TIMER_1, TEMP_TIMER_PRESCALE, tempTC_Handler }, // 1 - Temperature
{ TIMER_GROUP_1, TIMER_0, PWM_TIMER_PRESCALE, pwmTC_Handler }, // 2 - PWM
{ TIMER_GROUP_1, TIMER_1, 1, nullptr }, // 3
{ TIMER_GROUP_1, TIMER_1, TONE_TIMER_PRESCALE, toneTC_Handler }, // 3 - Tone
};
// ------------------------
+9
View File
@@ -44,6 +44,9 @@ typedef uint64_t hal_timer_t;
#ifndef PWM_TIMER_NUM
#define PWM_TIMER_NUM 2 // index of timer to use for PWM outputs
#endif
#ifndef TONE_TIMER_NUM
#define TONE_TIMER_NUM 3 // index of timer for beeper tones
#endif
#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals
@@ -59,6 +62,8 @@ typedef uint64_t hal_timer_t;
#define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts
#define TONE_TIMER_PRESCALE 1000 // Arbitrary value, no idea what i'm doing here
#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz
#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency
@@ -90,11 +95,15 @@ typedef uint64_t hal_timer_t;
#ifndef HAL_PWM_TIMER_ISR
#define HAL_PWM_TIMER_ISR() extern "C" void pwmTC_Handler()
#endif
#ifndef HAL_TONE_TIMER_ISR
#define HAL_TONE_TIMER_ISR() extern "C" void toneTC_Handler()
#endif
extern "C" {
void tempTC_Handler();
void stepTC_Handler();
void pwmTC_Handler();
void toneTC_Handler();
}
// ------------------------
-1
View File
@@ -1,6 +1,5 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
+10
View File
@@ -82,6 +82,16 @@ extern "C" volatile uint32_t _millis;
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL UsbSerial
#elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL UsbSerial
+1 -1
View File
@@ -25,7 +25,7 @@
* Emulate EEPROM storage using Flash Memory
*
* Use a single 32K flash sector to store EEPROM data. To reduce the
* number of erase operations a simple "levelling" scheme is used that
* number of erase operations a simple "leveling" scheme is used that
* maintains a number of EEPROM "slots" within the larger flash sector.
* Each slot is used in turn and the entire sector is only erased when all
* slots have been used.
+1 -1
View File
@@ -116,7 +116,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#elif HAS_WIRED_LCD
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
#error "Serial port pins (1) conflict with Encoder Buttons!"
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
#elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \
|| ANY_RX(1, LCD_SDSS, LCD_PINS_RS, SD_MISO_PIN, DOGLCD_A0, SD_SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
#error "Serial port pins (1) conflict with LCD pins!"
#endif
+1 -1
View File
@@ -152,7 +152,7 @@ FORCE_INLINE static void HAL_timer_disable_interrupt(const uint8_t timer_num) {
// This function is missing from CMSIS
FORCE_INLINE static bool NVIC_GetEnableIRQ(IRQn_Type IRQn) {
return (NVIC->ISER[((uint32_t)IRQn) >> 5] & (1 << ((uint32_t)IRQn) & 0x1F)) != 0;
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
}
FORCE_INLINE static bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
+10
View File
@@ -57,6 +57,16 @@
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL Serial
#elif WITHIN(MMU2_SERIAL_PORT, 0, 3)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL Serial
+4 -4
View File
@@ -21,13 +21,13 @@
#ifdef ADAFRUIT_GRAND_CENTRAL_M4
/**
* Framework doesn't define some serial to save sercom resources
* Framework doesn't define some serials to save sercom resources
* hence if these are used I need to define them
*/
#include "../../inc/MarlinConfig.h"
#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1
#if USING_SERIAL_1
Uart Serial2(&sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
void SERCOM4_0_Handler() { Serial2.IrqHandler(); }
void SERCOM4_1_Handler() { Serial2.IrqHandler(); }
@@ -35,7 +35,7 @@
void SERCOM4_3_Handler() { Serial2.IrqHandler(); }
#endif
#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2
#if USING_SERIAL_2
Uart Serial3(&sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
void SERCOM1_0_Handler() { Serial3.IrqHandler(); }
void SERCOM1_1_Handler() { Serial3.IrqHandler(); }
@@ -43,7 +43,7 @@
void SERCOM1_3_Handler() { Serial3.IrqHandler(); }
#endif
#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3
#if USING_SERIAL_3
Uart Serial4(&sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
void SERCOM5_0_Handler() { Serial4.IrqHandler(); }
void SERCOM5_1_Handler() { Serial4.IrqHandler(); }
+1 -1
View File
@@ -31,7 +31,7 @@
*/
#ifndef MASK
#define MASK(PIN) (1 << PIN)
#define MASK(PIN) _BV(PIN)
#endif
/**
+1 -1
View File
@@ -157,7 +157,7 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num) {
// missing from CMSIS: Check if interrupt is enabled or not
static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) {
return (NVIC->ISER[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) != 0;
return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F);
}
bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
+10
View File
@@ -65,6 +65,16 @@
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL SerialUSB
#elif WITHIN(MMU2_SERIAL_PORT, 1, 6)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL SerialUSB
+4
View File
@@ -48,6 +48,10 @@
DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
#endif
#if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0
DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT)
#endif
#if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
#endif
+1 -1
View File
@@ -59,7 +59,7 @@ void FastIO_init(); // Must be called before using fast io macros
#endif
#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO)))))
#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO))))
#define _TOGGLE(IO) TBI32(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR, STM_PIN(digitalPinToPinName(IO)))
#define _GET_MODE(IO)
#define _SET_MODE(IO,M) pinMode(IO, M)
-1
View File
@@ -84,7 +84,6 @@ class TFT_FSMC {
}
};
#ifdef STM32F1xx
#define FSMC_PIN_DATA STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, AFIO_NONE)
#elif defined(STM32F4xx)
+15 -2
View File
@@ -99,6 +99,18 @@
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL UsbSerial
#elif WITHIN(MMU2_SERIAL_PORT, 1, NUM_UARTS)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#elif NUM_UARTS == 5
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
#else
#error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL UsbSerial
@@ -109,8 +121,9 @@
#else
#error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
#endif
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
// Set interrupt grouping for this MCU
+1 -1
View File
@@ -45,7 +45,7 @@ uint8_t ServoCount = 0;
*
* This uses the smallest prescaler that allows an overflow < 2^16.
*/
#define MAX_OVERFLOW UINT16_MAX //((1 << 16) - 1)
#define MAX_OVERFLOW UINT16_MAX // _BV(16) - 1
#define CYC_MSEC (1000 * CYCLES_PER_MICROSECOND)
#define TAU_MSEC 20
#define TAU_USEC (TAU_MSEC * 1000)
-1
View File
@@ -1,6 +1,5 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* This program is free software: you can redistribute it and/or modify
+3 -3
View File
@@ -29,9 +29,9 @@
#include <libmaple/gpio.h>
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << ((V) ? 0 : 16))
#define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit))
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & _BV32(PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = _BV32(PIN_MAP[IO].gpio_bit) << ((V) ? 0 : 16))
#define TOGGLE(IO) TBI32(PIN_MAP[IO].gpio_device->regs->ODR, PIN_MAP[IO].gpio_bit)
#define _GET_MODE(IO) gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit)
#define _SET_MODE(IO,M) gpio_set_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, M)
+1 -1
View File
@@ -28,7 +28,7 @@
*/
#ifndef MASK
#define MASK(PIN) (1 << PIN)
#define MASK(PIN) _BV(PIN)
#endif
#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)
+1 -1
View File
@@ -28,7 +28,7 @@
*/
#ifndef MASK
#define MASK(PIN) (1 << PIN)
#define MASK(PIN) _BV(PIN)
#endif
#define GPIO_BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)
+7 -9
View File
@@ -28,9 +28,9 @@
#undef DISABLED // Redefined by ESP32
#undef M_PI // Redefined by all
#undef _BV // Redefined by some
#undef sq // Redefined by teensy3/wiring.h
#undef SBI // Redefined by arduino/const_functions.h
#undef CBI // Redefined by arduino/const_functions.h
#undef sq // Redefined by teensy3/wiring.h
#undef UNUSED // Redefined by stm32f4xx_hal_def.h
#include <Arduino.h> // NOTE: If included earlier then this line is a NOOP
@@ -40,18 +40,16 @@
#undef _BV
#define _BV(b) (1UL << (b))
#ifndef SBI
#define SBI(A,B) (A |= _BV(B))
#endif
#ifndef CBI
#define CBI(A,B) (A &= ~_BV(B))
#endif
#undef sq
#define sq(x) ((x)*(x))
#ifndef SBI
#define SBI(A,B) (A |= (1 << (B)))
#endif
#ifndef CBI
#define CBI(A,B) (A &= ~(1 << (B)))
#endif
#ifndef __AVR__
#ifndef strchr_P // Some platforms define a macro (DUE, teensy35)
inline const char* strchr_P(const char *s, int c) { return strchr(s,c); }
@@ -43,10 +43,9 @@ static bool isDataProc(uint32_t instr) {
}
UnwResult UnwStartArm(UnwState * const state) {
bool found = false;
uint16_t t = UNW_MAX_INSTR_COUNT;
do {
for (;;) {
uint32_t instr;
/* Attempt to read the instruction */
@@ -527,7 +526,7 @@ UnwResult UnwStartArm(UnwState * const state) {
if (--t == 0) return UNWIND_EXHAUSTED;
} while (!found);
}
return UNWIND_UNSUPPORTED;
}
@@ -30,12 +30,11 @@ static int32_t signExtend11(const uint16_t value) {
}
UnwResult UnwStartThumb(UnwState * const state) {
bool found = false;
uint16_t t = UNW_MAX_INSTR_COUNT;
uint32_t lastJumpAddr = 0; // Last JUMP address, to try to detect infinite loops
bool loopDetected = false; // If a loop was detected
do {
for (;;) {
uint16_t instr;
/* Attempt to read the instruction */
@@ -1059,7 +1058,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
if (--t == 0) return UNWIND_EXHAUSTED;
} while (!found);
}
return UNWIND_SUCCESS;
}
+29 -40
View File
@@ -128,11 +128,8 @@ static UnwResult UnwTabStateInit(const UnwindCallbacks *cb, UnwTabState *ucb, ui
* Execute unwinding instructions
*/
static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabState *ucb) {
int instruction;
uint32_t mask;
uint32_t reg;
uint32_t vsp;
uint32_t mask, reg, vsp;
/* Consume all instruction byte */
while ((instruction = UnwTabGetNextInstruction(cb, ucb)) != -1) {
@@ -140,12 +137,12 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
if ((instruction & 0xC0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP
/* vsp = vsp + (xxxxxx << 2) + 4 */
ucb->vrs[13] += ((instruction & 0x3F) << 2) + 4;
} else
if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
}
else if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
/* vsp = vsp - (xxxxxx << 2) - 4 */
ucb->vrs[13] -= ((instruction & 0x3F) << 2) - 4;
} else
if ((instruction & 0xF0) == 0x80) {
}
else if ((instruction & 0xF0) == 0x80) {
/* pop under mask {r15-r12},{r11-r4} or refuse to unwind */
instruction = instruction << 8 | UnwTabGetNextInstruction(cb, ucb);
@@ -171,17 +168,17 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
}
/* Patch up the vrs sp if it was in the mask */
if ((instruction & (1 << (13 - 4))) != 0)
if (instruction & (1 << (13 - 4)))
ucb->vrs[13] = vsp;
} else
if ((instruction & 0xF0) == 0x90 && // ARM_EXIDX_CMD_REG_TO_SP
instruction != 0x9D &&
instruction != 0x9F) {
}
else if ((instruction & 0xF0) == 0x90 // ARM_EXIDX_CMD_REG_TO_SP
&& instruction != 0x9D
&& instruction != 0x9F
) {
/* vsp = r[nnnn] */
ucb->vrs[13] = ucb->vrs[instruction & 0x0F];
} else
if ((instruction & 0xF0) == 0xA0) { // ARM_EXIDX_CMD_REG_POP
}
else if ((instruction & 0xF0) == 0xA0) { // ARM_EXIDX_CMD_REG_POP
/* pop r4-r[4+nnn] or pop r4-r[4+nnn], r14*/
vsp = ucb->vrs[13];
@@ -204,8 +201,8 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[13] = vsp;
} else
if (instruction == 0xB0) { // ARM_EXIDX_CMD_FINISH
}
else if (instruction == 0xB0) { // ARM_EXIDX_CMD_FINISH
/* finished */
if (ucb->vrs[15] == 0)
ucb->vrs[15] = ucb->vrs[14];
@@ -213,8 +210,8 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
/* All done unwinding */
return UNWIND_SUCCESS;
} else
if (instruction == 0xB1) { // ARM_EXIDX_CMD_REG_POP
}
else if (instruction == 0xB1) { // ARM_EXIDX_CMD_REG_POP
/* pop register under mask {r3,r2,r1,r0} */
vsp = ucb->vrs[13];
mask = UnwTabGetNextInstruction(cb, ucb);
@@ -234,16 +231,15 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
}
ucb->vrs[13] = (uint32_t)vsp;
} else
if (instruction == 0xB2) { // ARM_EXIDX_CMD_DATA_POP
}
else if (instruction == 0xB2) { // ARM_EXIDX_CMD_DATA_POP
/* vps = vsp + 0x204 + (uleb128 << 2) */
ucb->vrs[13] += 0x204 + (UnwTabGetNextInstruction(cb, ucb) << 2);
} else
if (instruction == 0xB3 || // ARM_EXIDX_CMD_VFP_POP
instruction == 0xC8 ||
instruction == 0xC9) {
}
else if (instruction == 0xB3 // ARM_EXIDX_CMD_VFP_POP
|| instruction == 0xC8
|| instruction == 0xC9
) {
/* pop VFP double-precision registers */
vsp = ucb->vrs[13];
@@ -266,27 +262,20 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
}
ucb->vrs[13] = vsp;
} else
if ((instruction & 0xF8) == 0xB8 ||
(instruction & 0xF8) == 0xD0) {
}
else if ((instruction & 0xF8) == 0xB8 || (instruction & 0xF8) == 0xD0) {
/* Pop VFP double precision registers D[8]-D[8+nnn] */
ucb->vrs[14] = 0x80 | (instruction & 0x07);
if ((instruction & 0xF8) == 0xD0) {
if ((instruction & 0xF8) == 0xD0)
ucb->vrs[14] = 1 << 17;
}
} else
}
else
return UNWIND_UNSUPPORTED_DWARF_INSTR;
}
return UNWIND_SUCCESS;
}
static inline __attribute__((always_inline)) uint32_t read_psp() {
/* Read the current PSP and return its value as a pointer */
uint32_t psp;
+4 -2
View File
@@ -655,11 +655,12 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
#if ENABLED(DUAL_X_CARRIAGE)
// handle delayed move timeout
if (delayed_move_time && ELAPSED(ms, delayed_move_time + 1000UL) && IsRunning()) {
if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) {
// travel moves have been received so enact them
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
destination = current_position;
prepare_line_to_destination();
planner.synchronize();
}
#endif
@@ -994,8 +995,9 @@ void setup() {
#endif
MYSERIAL0.begin(BAUDRATE);
uint32_t serial_connect_timeout = millis() + 1000UL;
millis_t serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
MYSERIAL1.begin(BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
+1
View File
@@ -229,6 +229,7 @@
#define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
#define BOARD_GMARSH_EBAB 2015 // GMARSH EBAB board, revision 1 prototype
//
// LPC1769 ARM Cortex M3
+2 -6
View File
@@ -84,17 +84,13 @@
#define _BV(n) (1<<(n))
#define TEST(n,b) (!!((n)&_BV(b)))
#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
#ifndef SBI
#define SBI(A,B) (A |= (1 << (B)))
#define SBI(A,B) (A |= _BV(B))
#endif
#ifndef CBI
#define CBI(A,B) (A &= ~(1 << (B)))
#define CBI(A,B) (A &= ~_BV(B))
#endif
#define TBI(N,B) (N ^= _BV(B))
#define _BV32(b) (1UL << (b))
#define TEST32(n,b) !!((n)&_BV32(b))
#define SBI32(n,b) (n |= _BV32(b))
+4
View File
@@ -23,6 +23,10 @@
#include "../../inc/MarlinConfigPre.h"
#if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
#define G28_L0_ENSURES_LEVELING_OFF 1
#endif
#if ENABLED(PROBE_MANUALLY)
extern bool g29_in_progress;
#else
+2 -1
View File
@@ -321,7 +321,8 @@
// Check for commands that require the printer to be homed
if (may_move) {
planner.synchronize();
if (axes_should_home()) gcode.home_all_axes();
// Send 'N' to force homing before G29 (internal only)
if (axes_should_home() || parser.seen('N')) gcode.home_all_axes();
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
}
+2 -2
View File
@@ -93,8 +93,8 @@ namespace DirectStepping {
static constexpr int DIRECTIONAL = dir ? 1 : 0;
static constexpr int SEGMENTS = segments;
static constexpr int NUM_SEGMENTS = 1 << BITS_SEGMENT;
static constexpr int SEGMENT_STEPS = (1 << (BITS_SEGMENT - DIRECTIONAL)) - 1;
static constexpr int NUM_SEGMENTS = _BV(BITS_SEGMENT);
static constexpr int SEGMENT_STEPS = _BV(BITS_SEGMENT - DIRECTIONAL) - 1;
static constexpr int TOTAL_STEPS = SEGMENT_STEPS * SEGMENTS;
static constexpr int PAGE_SIZE = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8;
+2 -3
View File
@@ -34,7 +34,6 @@
#include "encoder_i2c.h"
#include "../module/temperature.h"
#include "../module/stepper.h"
#include "../gcode/parser.h"
@@ -85,7 +84,7 @@ void I2CPositionEncoder::update() {
* the encoder would be re-enabled.
*/
/*
#if 0
// If the magnetic strength has been good for a certain time, start trusting the module again
if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) {
@@ -111,7 +110,7 @@ void I2CPositionEncoder::update() {
SERIAL_ECHOLNPGM(")");
#endif
}
*/
#endif
return;
}
-1
View File
@@ -32,7 +32,6 @@
#include "../inc/MarlinConfig.h" // for pins
#include "../module/planner.h"
#include "../module/temperature.h"
Joystick joystick;
-1
View File
@@ -27,7 +27,6 @@
#include "../inc/MarlinConfigPre.h"
#include "../core/types.h"
#include "../core/macros.h"
#include "../module/temperature.h"
class Joystick {
+8 -11
View File
@@ -91,8 +91,6 @@ MMU2 mmu2;
#define MMU2_NO_TOOL 99
#define MMU_BAUD 115200
#define mmuSerial MMU2_SERIAL
bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved;
#if HAS_PRUSA_MMU2S
bool MMU2::mmu2s_triggered;
@@ -128,12 +126,11 @@ void MMU2::init() {
set_runout_valid(false);
#if PIN_EXISTS(MMU2_RST)
// TODO use macros for this
WRITE(MMU2_RST_PIN, HIGH);
SET_OUTPUT(MMU2_RST_PIN);
#endif
mmuSerial.begin(MMU_BAUD);
MMU2_SERIAL.begin(MMU_BAUD);
extruder = MMU2_NO_TOOL;
safe_delay(10);
@@ -386,8 +383,8 @@ bool MMU2::rx_start() {
bool MMU2::rx_str_P(const char* str) {
uint8_t i = strlen(rx_buffer);
while (mmuSerial.available()) {
rx_buffer[i++] = mmuSerial.read();
while (MMU2_SERIAL.available()) {
rx_buffer[i++] = MMU2_SERIAL.read();
rx_buffer[i] = '\0';
if (i == sizeof(rx_buffer) - 1) {
@@ -418,7 +415,7 @@ bool MMU2::rx_str_P(const char* str) {
void MMU2::tx_str_P(const char* str) {
clear_rx_buffer();
uint8_t len = strlen_P(str);
LOOP_L_N(i, len) mmuSerial.write(pgm_read_byte(str++));
LOOP_L_N(i, len) MMU2_SERIAL.write(pgm_read_byte(str++));
rx_buffer[0] = '\0';
prev_request = millis();
}
@@ -429,7 +426,7 @@ void MMU2::tx_str_P(const char* str) {
void MMU2::tx_printf_P(const char* format, int argument = -1) {
clear_rx_buffer();
uint8_t len = sprintf_P(tx_buffer, format, argument);
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]);
rx_buffer[0] = '\0';
prev_request = millis();
}
@@ -440,7 +437,7 @@ void MMU2::tx_printf_P(const char* format, int argument = -1) {
void MMU2::tx_printf_P(const char* format, int argument1, int argument2) {
clear_rx_buffer();
uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2);
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
LOOP_L_N(i, len) MMU2_SERIAL.write(tx_buffer[i]);
rx_buffer[0] = '\0';
prev_request = millis();
}
@@ -449,7 +446,7 @@ void MMU2::tx_printf_P(const char* format, int argument1, int argument2) {
* Empty the rx buffer
*/
void MMU2::clear_rx_buffer() {
while (mmuSerial.available()) mmuSerial.read();
while (MMU2_SERIAL.available()) MMU2_SERIAL.read();
rx_buffer[0] = '\0';
}
@@ -955,7 +952,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
/**
* Load filament to nozzle of multimaterial printer
*
* This function is used only only after T? (user select filament) and M600 (change filament).
* This function is used only after T? (user select filament) and M600 (change filament).
* It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading
* filament to nozzle.
*/
+1 -1
View File
@@ -122,7 +122,7 @@ void Power::power_off() {
#ifdef PSU_POWEROFF_GCODE
GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE));
#endif
PSU_PIN_OFF();
PSU_PIN_OFF();
}
}
+27 -36
View File
@@ -342,6 +342,30 @@ void PrintJobRecovery::resume() {
gcode.process_subcommands_now_P(PSTR("M420 S0 Z0"));
#endif
#if HAS_HEATED_BED
const int16_t bt = info.target_temperature_bed;
if (bt) {
// Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt);
gcode.process_subcommands_now(cmd);
}
#endif
// Restore all hotend temperatures
#if HAS_HOTEND
HOTEND_LOOP() {
const int16_t et = info.target_temperature[e];
if (et) {
#if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e);
gcode.process_subcommands_now(cmd);
#endif
sprintf_P(cmd, PSTR("M109 S%i"), et);
gcode.process_subcommands_now(cmd);
}
}
#endif
// Reset E, raise Z, home XY...
#if Z_HOME_DIR > 0
@@ -353,20 +377,11 @@ void PrintJobRecovery::resume() {
#else // "G92.9 E0 ..."
// Set Z to 0, raise Z by info.zraise, and Home (XY only for Cartesian)
// with no raise. (Only do simulated homing in Marlin Dev Mode.)
sprintf_P(cmd, PSTR("G92.9 E0 "
#if ENABLED(BACKUP_POWER_SUPPLY)
"Z%s" // Z was already raised at outage
#else
"Z0\nG1Z%s" // Set Z=0 and Raise Z now
#endif
),
dtostrf(info.zraise, 1, 3, str_1)
);
// If a Z raise occurred at outage restore Z, otherwise raise Z now
sprintf_P(cmd, PSTR("G92.9 E0 " TERN(BACKUP_POWER_SUPPLY, "Z%s", "Z0\nG1Z%s")), dtostrf(info.zraise, 1, 3, str_1));
gcode.process_subcommands_now(cmd);
// Home safely with no Z raise
gcode.process_subcommands_now_P(PSTR(
"G28R0" // No raise during G28
#if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
@@ -404,30 +419,6 @@ void PrintJobRecovery::resume() {
#endif
#endif
#if HAS_HEATED_BED
const int16_t bt = info.target_temperature_bed;
if (bt) {
// Restore the bed temperature
sprintf_P(cmd, PSTR("M190 S%i"), bt);
gcode.process_subcommands_now(cmd);
}
#endif
// Restore all hotend temperatures
#if HAS_HOTEND
HOTEND_LOOP() {
const int16_t et = info.target_temperature[e];
if (et) {
#if HAS_MULTI_HOTEND
sprintf_P(cmd, PSTR("T%i S"), e);
gcode.process_subcommands_now(cmd);
#endif
sprintf_P(cmd, PSTR("M109 S%i"), et);
gcode.process_subcommands_now(cmd);
}
}
#endif
// Select the previously active tool (with no_move)
#if HAS_MULTI_EXTRUDER
sprintf_P(cmd, PSTR("T%i S"), info.active_extruder);
+14 -28
View File
@@ -32,51 +32,37 @@
#if ENABLED(PARKING_EXTRUDER)
#include "../module/tool_change.h"
#define SOLENOID_MAGNETIZED_STATE (TERN_(PARKING_EXTRUDER_SOLENOIDS_INVERT,!)PARKING_EXTRUDER_SOLENOIDS_PINS_ACTIVE)
#else
#define SOLENOID_MAGNETIZED_STATE HIGH
#endif
#define HAS_SOLENOID(N) (HAS_SOLENOID_##N && TERN(MANUAL_SOLENOID_CONTROL, true, EXTRUDERS > N))
#define HAS_SOLENOID(N) (HAS_SOLENOID_##N && (ENABLED(MANUAL_SOLENOID_CONTROL) || N < EXTRUDERS))
// Used primarily with MANUAL_SOLENOID_CONTROL
static void set_solenoid(const uint8_t num, const bool active) {
const uint8_t value = active ? SOLENOID_MAGNETIZED_STATE : !SOLENOID_MAGNETIZED_STATE;
const uint8_t value = active ? PE_MAGNET_ON_STATE : !PE_MAGNET_ON_STATE;
switch (num) {
case 0:
OUT_WRITE(SOL0_PIN, value);
TERN_(PARKING_EXTRUDER, if (!active && active_extruder == 0) parking_extruder_set_parked()); // If active extruder's solenoid is disabled, carriage is considered parked
break;
case 0: OUT_WRITE(SOL0_PIN, value); break;
#if HAS_SOLENOID(1)
case 1:
OUT_WRITE(SOL1_PIN, value);
TERN_(PARKING_EXTRUDER, if (!active && active_extruder == 1) parking_extruder_set_parked()); // If active extruder's solenoid is disabled, carriage is considered parked
break;
case 1: OUT_WRITE(SOL1_PIN, value); break;
#endif
#if HAS_SOLENOID(2)
case 2:
OUT_WRITE(SOL2_PIN, value);
break;
case 2: OUT_WRITE(SOL2_PIN, value); break;
#endif
#if HAS_SOLENOID(3)
case 3:
OUT_WRITE(SOL3_PIN, value);
break;
case 3: OUT_WRITE(SOL3_PIN, value); break;
#endif
#if HAS_SOLENOID(4)
case 4:
OUT_WRITE(SOL4_PIN, value);
break;
case 4: OUT_WRITE(SOL4_PIN, value); break;
#endif
#if HAS_SOLENOID(5)
case 5:
OUT_WRITE(SOL5_PIN, value);
break;
case 5: OUT_WRITE(SOL5_PIN, value); break;
#endif
default:
SERIAL_ECHO_MSG(STR_INVALID_SOLENOID);
break;
default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break;
}
#if ENABLED(PARKING_EXTRUDER)
if (!active && active_extruder == num) // If active extruder's solenoid is disabled, carriage is considered parked
parking_extruder_set_parked(true);
#endif
}
void enable_solenoid(const uint8_t num) { set_solenoid(num, true); }
+3
View File
@@ -36,6 +36,9 @@
SpindleLaser cutter;
uint8_t SpindleLaser::power;
#if ENABLED(LASER_FEATURE)
cutter_test_pulse_t SpindleLaser::testPulse = 50; // Test fire Pulse time ms value.
#endif
bool SpindleLaser::isReady; // Ready to apply power setting from the UI to OCR
cutter_power_t SpindleLaser::menuPower, // Power set via LCD menu in PWM, PERCENT, or RPM
SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM
+23 -1
View File
@@ -30,6 +30,10 @@
#include "spindle_laser_types.h"
#if USE_BEEPER
#include "../libs/buzzer.h"
#endif
#if ENABLED(LASER_POWER_INLINE)
#include "../module/planner.h"
#endif
@@ -90,6 +94,10 @@ public:
static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); }
static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); }
#if ENABLED(LASER_FEATURE)
static cutter_test_pulse_t testPulse; // Test fire Pulse ms value
#endif
static bool isReady; // Ready to apply power setting from the UI to OCR
static uint8_t power;
@@ -230,7 +238,21 @@ public:
}
#endif
#endif
#if ENABLED(LASER_FEATURE)
/**
* Test fire the laser using the testPulse ms duration
* Also fires with any PWM power that was previous set
* If not set defaults to 80% power
*/
static inline void test_fire_pulse() {
enable_forward(); // Turn Laser on (Spindle speak but same funct)
TERN_(USE_BEEPER, buzzer.tone(30, 3000));
delay(testPulse); // Delay for time set by user in pulse ms menu screen.
disable(); // Turn laser off
}
#endif
#endif // HAS_LCD_MENU
#if ENABLED(LASER_POWER_INLINE)
/**
+5
View File
@@ -52,6 +52,11 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;
#endif
#endif
#if ENABLED(LASER_FEATURE)
typedef uint16_t cutter_test_pulse_t;
#define CUTTER_MENU_PULSE_TYPE uint16_3
#endif
#if ENABLED(MARLIN_DEV_MODE)
typedef uint16_t cutter_frequency_t;
#define CUTTER_MENU_FREQUENCY_TYPE uint16_5
+2 -2
View File
@@ -147,7 +147,7 @@
static TMC_driver_data get_driver_data(TMC2208Stepper &st) {
constexpr uint8_t OTPW_bp = 0, OT_bp = 1;
constexpr uint8_t S2G_bm = 0b11110; // 2..5
constexpr uint8_t S2G_bm = 0b111100; // 2..5
TMC_driver_data data;
const auto ds = data.drv_status = st.DRV_STATUS();
data.is_otpw = TEST(ds, OTPW_bp);
@@ -291,7 +291,7 @@
bool should_step_down = false;
if (need_update_error_counters) {
if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++;
if (data.is_ot | data.is_s2g) st.error_count++;
else if (st.error_count > 0) st.error_count--;
#if ENABLED(STOP_ON_ERROR)
+6
View File
@@ -36,6 +36,9 @@ PGMSTR(point_name_3, TRAMMING_POINT_NAME_3);
PGMSTR(point_name_4, TRAMMING_POINT_NAME_4);
#ifdef TRAMMING_POINT_NAME_5
PGMSTR(point_name_5, TRAMMING_POINT_NAME_5);
#ifdef TRAMMING_POINT_NAME_6
PGMSTR(point_name_6, TRAMMING_POINT_NAME_6);
#endif
#endif
#endif
@@ -45,6 +48,9 @@ PGM_P const tramming_point_name[] PROGMEM = {
, point_name_4
#ifdef TRAMMING_POINT_NAME_5
, point_name_5
#ifdef TRAMMING_POINT_NAME_6
, point_name_6
#endif
#endif
#endif
};
+9 -2
View File
@@ -31,17 +31,20 @@
constexpr xy_pos_t screws_tilt_adjust_pos[] = TRAMMING_POINT_XY;
#define G35_PROBE_COUNT COUNT(screws_tilt_adjust_pos)
static_assert(G35_PROBE_COUNT >= 3, "TRAMMING_POINT_XY requires at least 3 XY positions.");
static_assert(WITHIN(G35_PROBE_COUNT, 3, 6), "TRAMMING_POINT_XY requires between 3 and 6 XY positions.");
#define VALIDATE_TRAMMING_POINT(N) static_assert(N >= G35_PROBE_COUNT || Probe::build_time::can_reach(screws_tilt_adjust_pos[N]), \
"TRAMMING_POINT_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.")
VALIDATE_TRAMMING_POINT(0); VALIDATE_TRAMMING_POINT(1); VALIDATE_TRAMMING_POINT(2); VALIDATE_TRAMMING_POINT(3); VALIDATE_TRAMMING_POINT(4);
VALIDATE_TRAMMING_POINT(0); VALIDATE_TRAMMING_POINT(1); VALIDATE_TRAMMING_POINT(2); VALIDATE_TRAMMING_POINT(3); VALIDATE_TRAMMING_POINT(4); VALIDATE_TRAMMING_POINT(5);
extern const char point_name_1[], point_name_2[], point_name_3[]
#ifdef TRAMMING_POINT_NAME_4
, point_name_4[]
#ifdef TRAMMING_POINT_NAME_5
, point_name_5[]
#ifdef TRAMMING_POINT_NAME_6
, point_name_6[]
#endif
#endif
#endif
;
@@ -56,6 +59,10 @@ extern const char point_name_1[], point_name_2[], point_name_3[]
#ifdef TRAMMING_POINT_NAME_5
#undef _NR_TRAM_NAMES
#define _NR_TRAM_NAMES 5
#ifdef TRAMMING_POINT_NAME_6
#undef _NR_TRAM_NAMES
#define _NR_TRAM_NAMES 6
#endif
#endif
#endif
#endif
+9 -4
View File
@@ -181,14 +181,18 @@ G29_TYPE GcodeSuite::G29() {
no_action = seenA || seenQ,
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");
G29_RETURN(false);
}
// Send 'N' to force homing before G29 (internal only)
if (parser.seen('N'))
gcode.process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
// Define local vars 'static' for manual probing, 'auto' otherwise
#define ABL_VAR TERN_(PROBE_MANUALLY, static)
@@ -249,7 +253,6 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
struct linear_fit_data lsf_results;
incremental_LSF_reset(&lsf_results);
#endif
/**
@@ -324,6 +327,8 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
incremental_LSF_reset(&lsf_results);
do_topography_map = verbose_level > 2 || parser.boolval('T');
// X and Y specify points in each direction, overriding the default
+1 -1
View File
@@ -85,7 +85,7 @@ void GcodeSuite::G29() {
mbl.reset();
mbl_probe_index = 0;
if (!ui.wait_for_move) {
queue.inject_P(PSTR("G28\nG29 S2"));
queue.inject_P(parser.seen('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
return;
}
state = MeshNext;
+2 -3
View File
@@ -241,7 +241,7 @@ void GcodeSuite::G28() {
// Disable the leveling matrix before homing
#if HAS_LEVELING
IF_ENABLED(RESTORE_LEVELING_AFTER_G28, const bool leveling_restore_state = planner.leveling_active);
const bool leveling_restore_state = parser.boolval('L', TERN(RESTORE_LEVELING_AFTER_G28, planner.leveling_active, ENABLED(ENABLE_LEVELING_AFTER_G28)));
IF_ENABLED(PROBE_MANUALLY, g29_in_progress = false); // Cancel the active G29 session
set_bed_leveling_enabled(false);
#endif
@@ -440,8 +440,7 @@ void GcodeSuite::G28() {
do_blocking_move_to_z(delta_clip_start_height);
#endif
IF_ENABLED(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_restore_state));
IF_ENABLED(ENABLE_LEVELING_AFTER_G28, set_bed_leveling_enabled(true));
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_restore_state));
restore_feedrate_and_scaling();
+9 -24
View File
@@ -320,7 +320,6 @@ void GcodeSuite::G34() {
};
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
// Check if the applied corrections go in the correct direction.
// Calculate the sum of the absolute deviations from the mean of the probe measurements.
// Compare to the last iteration to ensure it's getting better.
@@ -478,32 +477,18 @@ void GcodeSuite::M422() {
const bool is_probe_point = parser.seen('S');
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
if (is_probe_point && parser.seen('W')) {
SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
return;
}
#endif
if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) {
SERIAL_ECHOLNPGM("?(S) and (W) may not be combined.");
return;
}
xy_pos_t *pos_dest = (
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
!is_probe_point ? z_stepper_align.stepper_xy :
#endif
TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :)
z_stepper_align.xy
);
if (!is_probe_point
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
&& !parser.seen('W')
#endif
) {
SERIAL_ECHOLNPGM(
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
"?(S) or (W) is required."
#else
"?(S) is required."
#endif
);
if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) {
SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required.");
return;
}
@@ -512,7 +497,7 @@ void GcodeSuite::M422() {
if (is_probe_point) {
position_index = parser.intval('S') - 1;
if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) {
SERIAL_ECHOLNPGM("?(S) Z-ProbePosition index invalid.");
SERIAL_ECHOLNPGM("?(S) Probe-position index invalid.");
return;
}
}
@@ -520,7 +505,7 @@ void GcodeSuite::M422() {
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
position_index = parser.intval('W') - 1;
if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) {
SERIAL_ECHOLNPGM("?(W) Z-Stepper index invalid.");
SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid.");
return;
}
#endif
+24 -12
View File
@@ -38,7 +38,7 @@
#include "../../feature/probe_temp_comp.h"
#include "../../lcd/marlinui.h"
#include "../../MarlinCore.h" // for wait_for_heatup and idle()
#include "../../MarlinCore.h" // for wait_for_heatup, idle(), G28_STR
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
#include "../../module/printcounter.h"
@@ -91,6 +91,12 @@
* - `B` - Run bed temperature calibration.
* - `P` - Run probe temperature calibration.
*/
static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); }
static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); }
static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); }
static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); }
void GcodeSuite::G76() {
// Check if heated bed is available and z-homing is done with probe
#if TEMP_SENSOR_BED == 0 || !(HOMING_Z_WITH_PROBE)
@@ -108,7 +114,7 @@ void GcodeSuite::G76() {
};
auto wait_for_temps = [&](const float tb, const float tp, millis_t &ntr, const millis_t timeout=0) {
SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
say_waiting_for(); SERIAL_ECHOLNPGM("bed and probe temperature.");
while (fabs(thermalManager.degBed() - tb) > 0.1f || thermalManager.degProbe() > tp)
if (report_temps(ntr, timeout)) return true;
return false;
@@ -162,7 +168,7 @@ void GcodeSuite::G76() {
return;
}
process_subcommands_now_P(PSTR("G28"));
process_subcommands_now_P(G28_STR);
}
remember_feedrate_scaling_off();
@@ -184,7 +190,7 @@ void GcodeSuite::G76() {
uint16_t target_bed = cali_info_init[TSI_BED].start_temp,
target_probe = temp_comp.bed_calib_probe_temp;
SERIAL_ECHOLNPGM("Waiting for cooling.");
say_waiting_for(); SERIAL_ECHOLNPGM(" cooling.");
while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe)
report_temps(next_temp_report);
@@ -207,7 +213,8 @@ void GcodeSuite::G76() {
// Move the nozzle to the probing point and wait for the probe to reach target temp
do_blocking_move_to(noz_pos_xyz);
SERIAL_ECHOLNPGM("Waiting for probe heating.");
say_waiting_for_probe_heating();
SERIAL_EOL();
while (thermalManager.degProbe() < target_probe)
report_temps(next_temp_report);
@@ -216,10 +223,14 @@ void GcodeSuite::G76() {
}
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
if (temp_comp.finish_calibration(TSI_BED))
SERIAL_ECHOLNPGM("Successfully calibrated bed.");
else
SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset.");
if (temp_comp.finish_calibration(TSI_BED)) {
say_successfully_calibrated();
SERIAL_ECHOLNPGM(" bed.");
}
else {
say_failed_to_calibrate();
SERIAL_ECHOLNPGM(" bed. Values reset.");
}
// Cleanup
thermalManager.setTargetBed(0);
@@ -254,7 +265,8 @@ void GcodeSuite::G76() {
// Move probe to probing point and wait for it to reach target temperature
do_blocking_move_to(noz_pos_xyz);
SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe);
say_waiting_for_probe_heating();
SERIAL_ECHOLNPAIR(" Bed:", target_bed, " Probe:", target_probe);
const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
while (thermalManager.degProbe() < target_probe) {
if (report_temps(next_temp_report, probe_timeout_ms)) {
@@ -271,9 +283,9 @@ void GcodeSuite::G76() {
SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
if (temp_comp.finish_calibration(TSI_PROBE))
SERIAL_ECHOPGM("Successfully calibrated");
say_successfully_calibrated();
else
SERIAL_ECHOPGM("!Failed to calibrate");
say_failed_to_calibrate();
SERIAL_ECHOLNPGM(" probe.");
// Cleanup
+1
View File
@@ -245,6 +245,7 @@ void GcodeSuite::M48() {
SERIAL_ECHO(n + 1);
SERIAL_ECHOPAIR(" of ", int(n_samples));
SERIAL_ECHOPAIR_F(": z: ", pz, 3);
SERIAL_CHAR(' ');
dev_report(verbose_level > 2, mean, sigma, min, max);
SERIAL_EOL();
}
@@ -26,7 +26,6 @@
#include "../../../feature/filwidth.h"
#include "../../../module/planner.h"
#include "../../../module/temperature.h"
#include "../../../MarlinCore.h"
#include "../../gcode.h"
+1 -1
View File
@@ -102,7 +102,7 @@ void GcodeSuite::M600() {
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
// If needed, home before parking for filament change
if (!all_axes_trusted()) home_all_axes();
if (!all_axes_trusted()) home_all_axes(true);
#endif
#if HAS_MULTI_EXTRUDER
+2 -2
View File
@@ -369,9 +369,9 @@ public:
static void process_subcommands_now_P(PGM_P pgcode);
static void process_subcommands_now(char * gcode);
static inline void home_all_axes() {
static inline void home_all_axes(const bool keep_leveling=false) {
extern const char G28_STR[];
process_subcommands_now_P(G28_STR);
process_subcommands_now_P(keep_leveling ? G28_STR : TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
}
#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)
-1
View File
@@ -27,7 +27,6 @@
#include "../gcode.h"
#include "../../feature/babystep.h"
#include "../../module/probe.h"
#include "../../module/temperature.h"
#include "../../module/planner.h"
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
+5 -1
View File
@@ -35,6 +35,10 @@ void GcodeSuite::M21() { card.mount(); }
/**
* M22: Release SD Card
*/
void GcodeSuite::M22() { card.release(); }
void GcodeSuite::M22() {
if (!IS_SD_PRINTING()) card.release();
}
#endif // SDSUPPORT
+3 -5
View File
@@ -651,6 +651,9 @@
#if ENABLED(DWIN_CREALITY_LCD)
#define SERIAL_CATCHALL 0
#ifndef LCD_SERIAL_PORT
#define LCD_SERIAL_PORT 3 // Creality 4.x board
#endif
#endif
/**
@@ -1045,11 +1048,6 @@
#define INVERT_E_DIR false
#endif
// Fallback SPI Speed for SD
#if ENABLED(SDSUPPORT) && !defined(SD_SPI_SPEED)
#define SD_SPI_SPEED SPI_FULL_SPEED
#endif
/**
* This setting is also used by M109 when trying to calculate
* a ballpark safe margin to prevent wait-forever situation.
+14 -7
View File
@@ -211,14 +211,18 @@
#if DISABLED(Y_DUAL_STEPPER_DRIVERS)
#undef Y2_DRIVER_TYPE
#endif
#if NUM_Z_STEPPER_DRIVERS < 2
#undef Z2_DRIVER_TYPE
#endif
#if NUM_Z_STEPPER_DRIVERS < 3
#undef Z3_DRIVER_TYPE
#endif
#if NUM_Z_STEPPER_DRIVERS < 4
#undef Z4_DRIVER_TYPE
#undef INVERT_Z4_VS_Z_DIR
#if NUM_Z_STEPPER_DRIVERS < 3
#undef Z3_DRIVER_TYPE
#undef INVERT_Z3_VS_Z_DIR
#if NUM_Z_STEPPER_DRIVERS < 2
#undef Z2_DRIVER_TYPE
#undef INVERT_Z2_VS_Z_DIR
#endif
#endif
#endif
//
@@ -508,7 +512,10 @@
#endif
// Flag the indexed serial ports that are in use
#define ANY_SERIAL_IS(N) (defined(SERIAL_PORT) && SERIAL_PORT == (N)) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N))
#define ANY_SERIAL_IS(N) (defined(SERIAL_PORT) && SERIAL_PORT == (N)) || \
(defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \
(defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \
(defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N))
#if ANY_SERIAL_IS(-1)
#define USING_SERIAL_DEFAULT
#endif
+10 -1
View File
@@ -323,6 +323,11 @@
*/
#if ENABLED(SDSUPPORT)
// Extender cable doesn't support SD_DETECT_PIN
#if ENABLED(NO_SD_DETECT)
#undef SD_DETECT_PIN
#endif
#if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD)
//
// The external SD card is not used. Hardware SPI is used to access the card.
@@ -2297,7 +2302,6 @@
#if FAN_COUNT > 0
#define HAS_FAN 1
#define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING)
#endif
/**
@@ -2708,6 +2712,11 @@
#endif
#endif
// Fallback SPI Speed for SD
#if ENABLED(SDSUPPORT) && !defined(SD_SPI_SPEED)
#define SD_SPI_SPEED SPI_FULL_SPEED
#endif
// Defined here to catch the above defines
#if ENABLED(SDCARD_SORT_ALPHA) && (FOLDER_SORTING || ENABLED(SDSORT_GCODE))
#define HAS_FOLDER_SORTING 1
+16 -5
View File
@@ -588,10 +588,6 @@
#error "SERIAL_PORT must be defined."
#elif defined(SERIAL_PORT_2) && SERIAL_PORT_2 == SERIAL_PORT
#error "SERIAL_PORT_2 cannot be the same as SERIAL_PORT."
#elif defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == SERIAL_PORT
#error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT."
#elif defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == SERIAL_PORT_2
#error "LCD_SERIAL_PORT cannot be the same as SERIAL_PORT_2."
#endif
#if !(defined(__AVR__) && defined(USBCON))
#if ENABLED(SERIAL_XON_XOFF) && RX_BUFFER_SIZE < 1024
@@ -1595,7 +1591,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
/**
* ULTIPANEL encoder
*/
#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !defined(SHIFT_CLK)
#if IS_ULTIPANEL && NONE(IS_NEWPANEL, SR_LCD_2W_NL) && !PIN_EXISTS(SHIFT_CLK)
#error "ULTIPANEL controllers require some kind of encoder."
#endif
@@ -2389,11 +2385,26 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "SERIAL_PORT is set to -1, but the MOTHERBOARD has no native USB support. Set SERIAL_PORT to a valid value for your board."
#elif SERIAL_PORT_2 == -1
#error "SERIAL_PORT_2 is set to -1, but the MOTHERBOARD has no native USB support. Set SERIAL_PORT_2 to a valid value for your board."
#elif MMU2_SERIAL_PORT == -1
#error "MMU2_SERIAL_PORT is set to -1, but the MOTHERBOARD has no native USB support. Set MMU2_SERIAL_PORT to a valid value for your board."
#elif LCD_SERIAL_PORT == -1
#error "LCD_SERIAL_PORT is set to -1, but the MOTHERBOARD has no native USB support. Set LCD_SERIAL_PORT to a valid value for your board."
#endif
#endif
/**
* MMU2 require a dedicated serial port
*/
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == SERIAL_PORT
#error "MMU2_SERIAL_PORT cannot be the same as SERIAL_PORT."
#elif defined(SERIAL_PORT_2) && MMU2_SERIAL_PORT == SERIAL_PORT_2
#error "MMU2_SERIAL_PORT cannot be the same as SERIAL_PORT_2."
#elif defined(LCD_SERIAL_PORT) && MMU2_SERIAL_PORT == LCD_SERIAL_PORT
#error "MMU2_SERIAL_PORT cannot be the same as LCD_SERIAL_PORT."
#endif
#endif
/**
* Serial displays require a dedicated serial port
*/
+1 -1
View File
@@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2021-01-03"
#define STRING_DISTRIBUTION_DATE "2021-01-19"
#endif
/**
+5 -4
View File
@@ -313,7 +313,7 @@ void MarlinUI::init_lcd() {
t = 0;
#if ENABLED(TFTGLCD_PANEL_SPI)
// SPI speed must be less 10MHz
_SET_OUTPUT(TFTGLCD_CS);
SET_OUTPUT(TFTGLCD_CS);
WRITE(TFTGLCD_CS, HIGH);
spiInit(TERN(__STM32F1__, SPI_QUARTER_SPEED, SPI_FULL_SPEED));
WRITE(TFTGLCD_CS, LOW);
@@ -855,13 +855,14 @@ void MarlinUI::draw_status_screen() {
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
if (!PanelDetected) return;
ui.encoder_direction_normal();
lcd.setCursor(0, MIDDLE_Y);
const uint8_t y = TERN0(AUTO_BED_LEVELING_UBL, ui.external_control) ? LCD_HEIGHT - 1 : MIDDLE_Y;
lcd.setCursor(0, y);
lcd.write(COLOR_EDIT);
lcd_put_u8str_P(pstr);
if (value) {
lcd.write(':');
lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), MIDDLE_Y); // Right-justified, padded by spaces
lcd.write(' '); // Overwrite char if value gets shorter
lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), y); // Right-justified, padded by spaces
lcd.write(' '); // Overwrite char if value gets shorter
lcd.print(value);
lcd.write(' ');
lcd.print_line();
+4 -7
View File
@@ -61,15 +61,12 @@ extern TFTGLCD lcd;
#include "../lcdprint.h"
// Use panel encoder - free old encoder pins
#undef BTN_EN1
#undef BTN_EN2
#undef BTN_ENC
#define BTN_EN1 -1
#define BTN_EN2 -1
#define BTN_ENC -1
#undef BTN_EN1
#undef BTN_EN2
#undef BTN_ENC
#ifndef EN_C
#define EN_C 4 //for click
#define EN_C 4 // for click
#endif
#endif // IS_TFTGLCD_PANEL
+234
View File
@@ -0,0 +1,234 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "../inc/MarlinConfig.h"
#if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL
#define HAS_ENCODER_WHEEL 1
#endif
#if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
#define HAS_DIGITAL_BUTTONS 1
#endif
#if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL))
#define HAS_SHIFT_ENCODER 1
#endif
// I2C buttons must be read in the main thread
#if ANY(LCD_I2C_VIKI, LCD_I2C_PANELOLU2, IS_TFTGLCD_PANEL)
#define HAS_SLOW_BUTTONS 1
#endif
#if HAS_ENCODER_WHEEL
#define ENCODER_PHASE_0 0
#define ENCODER_PHASE_1 2
#define ENCODER_PHASE_2 3
#define ENCODER_PHASE_3 1
#endif
#if EITHER(HAS_DIGITAL_BUTTONS, DWIN_CREALITY_LCD)
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
#define BLEN_A 0
#define BLEN_B 1
#define EN_A _BV(BLEN_A)
#define EN_B _BV(BLEN_B)
#define _BUTTON_PRESSED(BN) !READ(BTN_##BN)
#if BUTTON_EXISTS(ENC) || HAS_TOUCH_BUTTONS
#define BLEN_C 2
#define EN_C _BV(BLEN_C)
#endif
#if ENABLED(LCD_I2C_VIKI)
#include <LiquidTWI2.h>
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
// button and encoder bit positions within 'buttons'
#define B_LE (BUTTON_LEFT << B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
#define B_UP (BUTTON_UP << B_I2C_BTN_OFFSET)
#define B_MI (BUTTON_SELECT << B_I2C_BTN_OFFSET)
#define B_DW (BUTTON_DOWN << B_I2C_BTN_OFFSET)
#define B_RI (BUTTON_RIGHT << B_I2C_BTN_OFFSET)
#if BUTTON_EXISTS(ENC) // The pause/stop/restart button is connected to BTN_ENC when used
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
#define BUTTON_CLICK() (buttons & (B_MI|B_RI|B_ST)) // Pause/stop also acts as click until a proper pause/stop is implemented.
#else
#define BUTTON_CLICK() (buttons & (B_MI|B_RI))
#endif
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
#elif ENABLED(LCD_I2C_PANELOLU2)
#if !BUTTON_EXISTS(ENC) // Use I2C if not directly connected to a pin
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
#define B_MI (PANELOLU2_ENCODER_C << B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
#define BUTTON_CLICK() (buttons & B_MI)
#endif
#endif
#else
#undef BUTTON_EXISTS
#define BUTTON_EXISTS(...) false
// Dummy button, never pressed
#define _BUTTON_PRESSED(BN) false
// Shift register bits correspond to buttons:
#define BL_LE 7 // Left
#define BL_UP 6 // Up
#define BL_MI 5 // Middle
#define BL_DW 4 // Down
#define BL_RI 3 // Right
#define BL_ST 2 // Red Button
#define B_LE _BV(BL_LE)
#define B_UP _BV(BL_UP)
#define B_MI _BV(BL_MI)
#define B_DW _BV(BL_DW)
#define B_RI _BV(BL_RI)
#define B_ST _BV(BL_ST)
#ifndef BUTTON_CLICK
#define BUTTON_CLICK() (buttons & (B_MI|B_ST))
#endif
#endif
#if IS_RRW_KEYPAD
#define BTN_OFFSET 0 // Bit offset into buttons for shift register values
#define BLEN_KEYPAD_F3 0
#define BLEN_KEYPAD_F2 1
#define BLEN_KEYPAD_F1 2
#define BLEN_KEYPAD_DOWN 3
#define BLEN_KEYPAD_RIGHT 4
#define BLEN_KEYPAD_MIDDLE 5
#define BLEN_KEYPAD_UP 6
#define BLEN_KEYPAD_LEFT 7
#define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
#define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
#define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
#define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
#define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
#define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
#define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
#define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
#define RRK(B) (keypad_buttons & (B))
#ifdef EN_C
#define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
#else
#define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
#endif
#endif
#ifndef EN_A
#define EN_A 0
#endif
#ifndef EN_B
#define EN_B 0
#endif
#ifndef EN_C
#define EN_C 0
#endif
#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_BUTTONS, IS_TFTGLCD_PANEL)
#define BLEN_D 3
#define EN_D _BV(BLEN_D)
#else
#define EN_D 0
#endif
#define BUTTON_PRESSED(BN) (_BUTTON_PRESSED_##BN)
#if BUTTON_EXISTS(EN1)
#define _BUTTON_PRESSED_EN1 _BUTTON_PRESSED(EN1)
#else
#define _BUTTON_PRESSED_EN1 false
#endif
#if BUTTON_EXISTS(EN2)
#define _BUTTON_PRESSED_EN2 _BUTTON_PRESSED(EN2)
#else
#define _BUTTON_PRESSED_EN2 false
#endif
#if BUTTON_EXISTS(ENC_EN)
#define _BUTTON_PRESSED_ENC_EN _BUTTON_PRESSED(ENC_EN)
#else
#define _BUTTON_PRESSED_ENC_EN false
#endif
#if BUTTON_EXISTS(ENC)
#define _BUTTON_PRESSED_ENC _BUTTON_PRESSED(ENC)
#else
#define _BUTTON_PRESSED_ENC false
#endif
#if BUTTON_EXISTS(UP)
#define _BUTTON_PRESSED_UP _BUTTON_PRESSED(UP)
#else
#define _BUTTON_PRESSED_UP false
#endif
#if BUTTON_EXISTS(DWN)
#define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DWN)
#else
#define _BUTTON_PRESSED_DWN false
#endif
#if BUTTON_EXISTS(LFT)
#define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LFT)
#else
#define _BUTTON_PRESSED_LFT false
#endif
#if BUTTON_EXISTS(RT)
#define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RT)
#else
#define _BUTTON_PRESSED_RT false
#endif
#if BUTTON_EXISTS(BACK)
#define _BUTTON_PRESSED_BACK _BUTTON_PRESSED(BACK)
#else
#define _BUTTON_PRESSED_BACK false
#endif
#ifndef BUTTON_CLICK
#if EN_C > 0
#define BUTTON_CLICK() (buttons & EN_C)
#else
#define BUTTON_CLICK() false
#endif
#endif
#if EN_D > 0
#define LCD_BACK_CLICKED() (buttons & EN_D)
#else
#define LCD_BACK_CLICKED() false
#endif
@@ -107,3 +107,16 @@ public:
: U8GLIB(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset)
{ }
};
extern u8g_dev_t u8g_dev_ssd1309_sw_spi;
extern u8g_dev_t u8g_dev_ssd1309_hw_spi;
class U8GLIB_SSD1309_128X64_HAL : public U8GLIB {
public:
U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
{ }
U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset = U8G_PIN_NONE)
: U8GLIB(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset)
{ }
};
@@ -52,7 +52,9 @@
#elif defined(ARDUINO_ARCH_STM32)
uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
#define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn
#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn
#elif defined(__AVR__)
+5 -4
View File
@@ -15,9 +15,10 @@ const u8g_fntpgm_uint8_t fontpage_2_186_186[33] U8G_FONT_SECTION("fontpage_2_186
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xBA,0xBA,0x00,0x0A,0x00,0x00,
0x00,0x03,0x0A,0x0A,0x06,0x01,0x00,0x20,0x40,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,
0xE0};
const u8g_fntpgm_uint8_t fontpage_2_190_190[33] U8G_FONT_SECTION("fontpage_2_190_190") = {
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xBE,0xBE,0x00,0x0A,0x00,0x00,
0x00,0x03,0x0A,0x0A,0x06,0x01,0x00,0xA0,0x40,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,
const u8g_fntpgm_uint8_t fontpage_2_189_190[49] U8G_FONT_SECTION("fontpage_2_189_190") = {
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xBD,0xBE,0x00,0x0A,0x00,0x00,
0x00,0x05,0x0A,0x0A,0x06,0x00,0x00,0x50,0x20,0x00,0x80,0x80,0x80,0x80,0x80,0x80,
0xF8,0x03,0x0A,0x0A,0x06,0x01,0x00,0xA0,0x40,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,
0xE0};
const u8g_fntpgm_uint8_t fontpage_2_199_200[47] U8G_FONT_SECTION("fontpage_2_199_200") = {
0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xC7,0xC8,0x00,0x0A,0x00,0x00,
@@ -40,7 +41,7 @@ const u8g_fntpgm_uint8_t fontpage_2_253_254[47] U8G_FONT_SECTION("fontpage_2_253
static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {
FONTDATA_ITEM(2, 140, 143, fontpage_2_140_143), // 'Č' -- 'ď'
FONTDATA_ITEM(2, 186, 186, fontpage_2_186_186), // 'ĺ' -- 'ĺ'
FONTDATA_ITEM(2, 190, 190, fontpage_2_190_190), // 'ľ' -- 'ľ'
FONTDATA_ITEM(2, 189, 190, fontpage_2_189_190), // 'Ľ' -- 'ľ'
FONTDATA_ITEM(2, 199, 200, fontpage_2_199_200), // 'Ň' -- 'ň'
FONTDATA_ITEM(2, 224, 225, fontpage_2_224_225), // 'Š' -- 'š'
FONTDATA_ITEM(2, 229, 229, fontpage_2_229_229), // 'ť' -- 'ť'
+13 -3
View File
@@ -110,11 +110,9 @@
#define U8G_CLASS U8GLIB_MINI12864_2X // 8 stripes (HW-SPI)
#endif
#elif EITHER(MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864)
#elif ENABLED(MKS_12864OLED_SSD1306)
// MKS 128x64 (SSD1306) OLED I2C LCD
// - or -
// FYSETC OLED 2.42" 128 × 64 FULL GRAPHICS CONTROLLER
#define FORCE_SOFT_SPI // SW-SPI
@@ -124,6 +122,18 @@
#define U8G_CLASS U8GLIB_SSD1306_128X64 // 8 stripes
#endif
#elif ENABLED(FYSETC_242_OLED_12864)
// FYSETC OLED 2.42" 128 × 64 FULL GRAPHICS CONTROLLER
#define FORCE_SOFT_SPI // SW-SPI
#if ENABLED(ALTERNATIVE_LCD)
#define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes
#else
#define U8G_CLASS U8GLIB_SSD1309_128X64_HAL
#endif
#elif ENABLED(ZONESTAR_12864OLED_SSD1306)
// Zonestar SSD1306 OLED SPI LCD
@@ -245,9 +245,8 @@ u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire = { u8g_dev_ssd1306_128x64_2x_2_w
uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq) {
uint8_t is_escape = 0;
uint8_t value;
for (;;) {
value = u8g_pgm_read(esc_seq);
uint8_t value = u8g_pgm_read(esc_seq);
if (is_escape == 0) {
if (value != 255) {
if (u8g_WriteByte(u8g, dev, value) == 0 )
@@ -0,0 +1,128 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB
#include "HAL_LCD_com_defines.h"
#include <U8glib.h>
#define WIDTH 128
#define HEIGHT 64
#define PAGE_HEIGHT 8
// SSD1309 init sequence
static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM = {
U8G_ESC_CS(0), // Disable chip
U8G_ESC_ADR(0), // Instruction mode
U8G_ESC_RST(1), // Do reset low pulse with (1*16)+2 milliseconds
U8G_ESC_CS(1), // Enable chip
0xFD,0x12, // Command Lock
0xAE, // Set Display Off
0xD5,0xA0, // Set Display Clock Divide Ratio/Oscillator Frequency
0xA8,0x3F, // Set Multiplex Ratio
0x3D,0x00, // Set Display Offset
0x40, // Set Display Start Line
0xA1, // Set Segment Re-Map
0xC8, // Set COM Output Scan Direction
0xDA,0x12, // Set COM Pins Hardware Configuration
0x81,0xDF, // Set Current Control
0xD9,0x82, // Set Pre-Charge Period
0xDB,0x34, // Set VCOMH Deselect Level
0xA4, // Set Entire Display On/Off
0xA6, // Set Normal/Inverse Display
U8G_ESC_VCC(1), // Power up VCC & Stabilized
U8G_ESC_DLY(50),
0xAF, // Set Display On
U8G_ESC_DLY(50),
U8G_ESC_CS(0), // Disable chip
U8G_ESC_END // End of sequence
};
// Select one init sequence here
#define u8g_dev_ssd1309_128x64_init_seq u8g_dev_ssd1309_128x64_init_seq
static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = {
U8G_ESC_ADR(0), // Instruction mode
U8G_ESC_CS(1), // Enable chip
0x010, // Set upper 4 bit of the col adr to 0
0x000, // Set lower 4 bit of the col adr to 4
U8G_ESC_END // End of sequence
};
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
U8G_ESC_ADR(0), // Instruction mode
U8G_ESC_CS(1), // Enable chip
0x0AE, // Display off
U8G_ESC_CS(0), // Disable chip
U8G_ESC_END // End of sequence
};
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
U8G_ESC_ADR(0), // Instruction mode
U8G_ESC_CS(1), // Enable chip
0x0AF, // Display on
U8G_ESC_DLY(50), // Delay 50 ms
U8G_ESC_CS(0), // Disable chip
U8G_ESC_END // End of sequence
};
uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
switch(msg) {
case U8G_DEV_MSG_INIT:
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq);
break;
case U8G_DEV_MSG_STOP:
break;
case U8G_DEV_MSG_PAGE_NEXT: {
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start);
u8g_WriteByte(u8g, dev, 0x0B0 | pb->p.page); // Select current page (SSD1306)
u8g_SetAddress(u8g, dev, 1); // Data mode
if (u8g_pb_WriteBuffer(pb, u8g, dev) == 0) return 0;
u8g_SetChipSelect(u8g, dev, 0);
}
break;
case U8G_DEV_MSG_CONTRAST:
u8g_SetChipSelect(u8g, dev, 1);
u8g_SetAddress(u8g, dev, 0); // Instruction mode
u8g_WriteByte(u8g, dev, 0x081);
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); // 11 Jul 2015: fixed contrast calculation
u8g_SetChipSelect(u8g, dev, 0);
return 1;
case U8G_DEV_MSG_SLEEP_ON:
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
return 1;
case U8G_DEV_MSG_SLEEP_OFF:
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
return 1;
}
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
}
uint8_t u8g_dev_ssd1309_buf[WIDTH*2] U8G_NOCOMMON ;
u8g_pb_t u8g_dev_ssd1309_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1309_buf};
u8g_dev_t u8g_dev_ssd1309_sw_spi = { u8g_dev_ssd1309_128x64_fn, &u8g_dev_ssd1309_pb, U8G_COM_HAL_SW_SPI_FN };
#endif // HAS_MARLINUI_U8GLIB
+11 -4
View File
@@ -82,20 +82,27 @@ inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
// Send the data in the buffer and the packet end
inline void DWIN_Send(size_t &i) {
++i;
LOOP_L_N(n, i) { MYSERIAL1.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
LOOP_L_N(n, 4) { MYSERIAL1.write(DWIN_BufTail[n]); delayMicroseconds(1); }
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
}
/*-------------------------------------- System variable function --------------------------------------*/
// Handshake (1: Success, 0: Fail)
bool DWIN_Handshake(void) {
#ifndef LCD_BAUDRATE
#define LCD_BAUDRATE 115200
#endif
LCD_SERIAL.begin(LCD_BAUDRATE);
const millis_t serial_connect_timeout = millis() + 1000UL;
while (!LCD_SERIAL && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
size_t i = 0;
DWIN_Byte(i, 0x00);
DWIN_Send(i);
while (MYSERIAL1.available() > 0 && recnum < (signed)sizeof(databuf)) {
databuf[recnum] = MYSERIAL1.read();
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
databuf[recnum] = LCD_SERIAL.read();
// ignore the invalid data
if (databuf[0] != FHONE) { // prevent the program from running.
if (recnum > 0) {
+2 -4
View File
@@ -502,9 +502,7 @@ inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valr
valref += EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_CCW)
valref -= EncoderRate.encoderMoveValue;
else if (encoder_diffState == ENCODER_DIFF_ENTER)
return true;
return false;
return encoder_diffState == ENCODER_DIFF_ENTER;
}
//
@@ -2334,7 +2332,7 @@ void HMI_Prepare() {
case PREPARE_CASE_HOME: // Homing
checkkey = Last_Prepare;
index_prepare = MROWS;
queue.inject_P(PSTR("G28")); // G28 will set home_flag
queue.inject_P(G28_STR); // G28 will set home_flag
Popup_Window_Home();
break;
#if HAS_ZOFFSET_ITEM
+1 -1
View File
@@ -249,7 +249,7 @@ typedef struct {
float Move_E_scale = 0;
#endif
float offset_value = 0;
char show_mode = 0; // -1: Temperature control 0: Printing temperature
int8_t show_mode = 0; // -1: Temperature control 0: Printing temperature
} HMI_value_t;
#define DWIN_CHINESE 123
+73 -71
View File
@@ -33,6 +33,7 @@
#if ENABLED(DWIN_CREALITY_LCD)
#include "rotary_encoder.h"
#include "../../buttons.h"
#include "../../../MarlinCore.h"
#include "../../../HAL/shared/Delay.h"
@@ -43,17 +44,23 @@
#include <stdlib.h>
#ifndef ENCODER_PULSES_PER_STEP
#define ENCODER_PULSES_PER_STEP 4
#endif
ENCODER_Rate EncoderRate;
// Buzzer
void Encoder_tick(void) {
WRITE(BEEPER_PIN, 1);
delay(10);
WRITE(BEEPER_PIN, 0);
void Encoder_tick() {
#if PIN_EXISTS(BEEPER)
WRITE(BEEPER_PIN, HIGH);
delay(10);
WRITE(BEEPER_PIN, LOW);
#endif
}
// Encoder initialization
void Encoder_Configuration(void) {
void Encoder_Configuration() {
#if BUTTON_EXISTS(EN1)
SET_INPUT_PULLUP(BTN_EN1);
#endif
@@ -63,21 +70,21 @@ void Encoder_Configuration(void) {
#if BUTTON_EXISTS(ENC)
SET_INPUT_PULLUP(BTN_ENC);
#endif
#ifdef BEEPER_PIN
#if PIN_EXISTS(BEEPER)
SET_OUTPUT(BEEPER_PIN);
#endif
}
// Analyze encoder value and return state
ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
ENCODER_DiffState Encoder_ReceiveAnalyze() {
const millis_t now = millis();
static unsigned char lastEncoderBits;
unsigned char newbutton = 0;
static uint8_t lastEncoderBits;
uint8_t newbutton = 0;
static signed char temp_diff = 0;
ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
if (BUTTON_PRESSED(EN1)) newbutton |= 0x01;
if (BUTTON_PRESSED(EN2)) newbutton |= 0x02;
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
if (BUTTON_PRESSED(ENC)) {
static millis_t next_click_update_ms;
if (ELAPSED(now, next_click_update_ms)) {
@@ -94,22 +101,22 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
}
if (newbutton != lastEncoderBits) {
switch (newbutton) {
case ENCODER_PHASE_0: {
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
case ENCODER_PHASE_0:
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
}break;
case ENCODER_PHASE_1: {
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
break;
case ENCODER_PHASE_1:
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
}break;
case ENCODER_PHASE_2: {
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
break;
case ENCODER_PHASE_2:
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
}break;
case ENCODER_PHASE_3: {
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
break;
case ENCODER_PHASE_3:
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
}break;
break;
}
lastEncoderBits = newbutton;
}
@@ -137,9 +144,12 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
}
EncoderRate.lastEncoderTime = ms;
}
#else
constexpr int32_t encoderMultiplier = 1;
#endif // ENCODER_RATE_MULTIPLIER
#endif
// EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
@@ -153,23 +163,23 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
#if PIN_EXISTS(LCD_LED)
// Take the low 24 valid bits 24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
unsigned int LED_DataArray[LED_NUM];
uint16_t LED_DataArray[LED_NUM];
// LED light operation
void LED_Action(void) {
void LED_Action() {
LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
delay(30);
LED_Control(RGB_SCALE_WARM_WHITE,0x00);
}
// LED initialization
void LED_Configuration(void) {
void LED_Configuration() {
SET_OUTPUT(LCD_LED_PIN);
}
// LED write data
void LED_WriteData(void) {
unsigned char tempCounter_LED, tempCounter_Bit;
void LED_WriteData() {
uint8_t tempCounter_LED, tempCounter_Bit;
for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
@@ -190,14 +200,13 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
// LED control
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
void LED_Control(unsigned char RGB_Scale, unsigned char luminance) {
unsigned char temp_Counter;
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
LED_DataArray[temp_Counter] = 0;
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
for (uint8_t i = 0; i < LED_NUM; i++) {
LED_DataArray[i] = 0;
switch (RGB_Scale) {
case RGB_SCALE_R10_G7_B5: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*5/10; break;
case RGB_SCALE_R10_G7_B4: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*7/10) << 16 | luminance*4/10; break;
case RGB_SCALE_R10_G8_B7: LED_DataArray[temp_Counter] = (luminance*10/10) << 8 | (luminance*8/10) << 16 | luminance*7/10; break;
case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
}
}
LED_WriteData();
@@ -207,45 +216,38 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) {
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
// change_Time: gradient time (ms)
void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval) {
unsigned char temp_Counter;
unsigned char LED_R_Data[LED_NUM], LED_G_Data[LED_NUM], LED_B_Data[LED_NUM];
bool LED_R_Flag = 0, LED_G_Flag = 0, LED_B_Flag = 0;
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
struct { uint8_t g, r, b; } led_data[LED_NUM];
for (uint8_t i = 0; i < LED_NUM; i++) {
switch (RGB_Scale) {
case RGB_SCALE_R10_G7_B5: {
LED_R_Data[temp_Counter] = luminance*10/10;
LED_G_Data[temp_Counter] = luminance*7/10;
LED_B_Data[temp_Counter] = luminance*5/10;
}break;
case RGB_SCALE_R10_G7_B4: {
LED_R_Data[temp_Counter] = luminance*10/10;
LED_G_Data[temp_Counter] = luminance*7/10;
LED_B_Data[temp_Counter] = luminance*4/10;
}break;
case RGB_SCALE_R10_G8_B7: {
LED_R_Data[temp_Counter] = luminance*10/10;
LED_G_Data[temp_Counter] = luminance*8/10;
LED_B_Data[temp_Counter] = luminance*7/10;
}break;
case RGB_SCALE_R10_G7_B5:
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
break;
case RGB_SCALE_R10_G7_B4:
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
break;
case RGB_SCALE_R10_G8_B7:
led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
break;
}
}
for (temp_Counter = 0; temp_Counter < LED_NUM; temp_Counter++) {
if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) > LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000100;
else if ((unsigned char)(LED_DataArray[temp_Counter] >> 8) < LED_R_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000100;
while (1) {
else LED_R_Flag = 1;
if ((unsigned char)(LED_DataArray[temp_Counter]>>16) > LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x010000;
else if ((unsigned char)(LED_DataArray[temp_Counter]>>16) < LED_G_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x010000;
else LED_G_Flag = 1;
if ((unsigned char)LED_DataArray[temp_Counter] > LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] -= 0x000001;
else if ((unsigned char)LED_DataArray[temp_Counter] < LED_B_Data[temp_Counter]) LED_DataArray[temp_Counter] += 0x000001;
else LED_B_Flag = 1;
struct { bool g, r, b; } led_flag = { false, false, false };
for (uint8_t i = 0; i < LED_NUM; i++) {
while (1) {
const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
r = uint8_t(LED_DataArray[i] >> 8),
b = uint8_t(LED_DataArray[i]);
if (g == led_data[i].g) led_flag.g = true;
else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
if (r == led_data[i].r) led_flag.r = true;
else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
if (b == led_data[i].b) led_flag.b = true;
else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
LED_WriteData();
if (led_flag.r && led_flag.g && led_flag.b) break;
delay(change_Interval);
}
LED_WriteData();
if (LED_R_Flag && LED_G_Flag && LED_B_Flag) break;
else delay(change_Interval);
}
}
+7 -16
View File
@@ -34,15 +34,6 @@
/*********************** Encoder Set ***********************/
#define ENCODER_PHASE_0 0
#define ENCODER_PHASE_1 2
#define ENCODER_PHASE_2 3
#define ENCODER_PHASE_3 1
#define ENCODER_PULSES_PER_STEP 4
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
typedef struct {
bool enabled = false;
int encoderMoveValue = 0;
@@ -59,10 +50,10 @@ typedef enum {
} ENCODER_DiffState;
// Encoder initialization
void Encoder_Configuration(void);
void Encoder_Configuration();
// Analyze encoder value and return state
ENCODER_DiffState Encoder_ReceiveAnalyze(void);
ENCODER_DiffState Encoder_ReceiveAnalyze();
/*********************** Encoder LED ***********************/
@@ -82,23 +73,23 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void);
extern unsigned int LED_DataArray[LED_NUM];
// LED light operation
void LED_Action(void);
void LED_Action();
// LED initialization
void LED_Configuration(void);
void LED_Configuration();
// LED write data
void LED_WriteData(void);
void LED_WriteData();
// LED control
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
void LED_Control(unsigned char RGB_Scale, unsigned char luminance);
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
// LED gradient control
// RGB_Scale: RGB color ratio
// luminance: brightness (0~0xFF)
// change_Time: gradient time (ms)
void LED_GraduallyControl(unsigned char RGB_Scale, unsigned char luminance, unsigned int change_Interval);
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
#endif // LCD_LED
@@ -86,9 +86,9 @@ namespace Anycubic {
safe_delay(200);
// Enable levelling and Disable end stops during print
// Enable leveling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands_P(AC_cmnd_enable_levelling);
injectCommands_P(AC_cmnd_enable_leveling);
// Startup tunes are defined in Tunes.h
//PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
@@ -620,10 +620,10 @@ namespace Anycubic {
case 21: // A21 Home Axis A21 X
if (!isPrinting()) {
switch ((char)panel_command[4]) {
case 'X': injectCommands_P(PSTR("G28 X")); break;
case 'Y': injectCommands_P(PSTR("G28 Y")); break;
case 'Z': injectCommands_P(PSTR("G28 Z")); break;
case 'C': injectCommands_P(PSTR("G28")); break;
case 'X': injectCommands_P(PSTR("G28X")); break;
case 'Y': injectCommands_P(PSTR("G28Y")); break;
case 'Z': injectCommands_P(PSTR("G28Z")); break;
case 'C': injectCommands_P(G28_STR); break;
}
}
break;
@@ -718,7 +718,7 @@ namespace Anycubic {
// If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
if ((selectedmeshpoint.x == pos.x) && (selectedmeshpoint.y == pos.y)) {
if (!isPositionKnown())
injectCommands_P(PSTR("G28")); // home
injectCommands_P(G28_STR); // home
if (isPositionKnown()) {
#if ACDEBUG(AC_INFO)
@@ -746,7 +746,7 @@ namespace Anycubic {
if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling
else {
injectCommands_P(isMachineHomed() ? PSTR("G29") : PSTR("G28\nG29"));
injectCommands_P(PSTR("G28O\nG29"));
printer_state = AC_printer_probing;
SendtoTFTLN(AC_msg_start_probing);
}
@@ -762,7 +762,7 @@ namespace Anycubic {
selectedmeshpoint.x = selectedmeshpoint.y = 99;
}
break;
case 'D': // Save Z Offset tables and restore levelling state
case 'D': // Save Z Offset tables and restore leveling state
if (!isPrinting()) {
setAxisPosition_mm(1.0,Z);
injectCommands_P(PSTR("M500"));
@@ -784,7 +784,7 @@ namespace Anycubic {
float Zshift = atof(&panel_command[4]);
setSoftEndstopState(false); // disable endstops
// Allow temporary Z position nudging during print
// From the levelling panel use the all points UI to adjust the print pos.
// From the leveling panel use the all points UI to adjust the print pos.
if (isPrinting()) {
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPAIR("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift);
@@ -105,8 +105,8 @@
#define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_levelling PSTR("M420 S1 V1")
#define AC_cmnd_power_loss_recovery PSTR("G28 X Y R5\nG28 Z") // Lift, home X and Y then home Z when in 'safe' position
#define AC_cmnd_enable_leveling PSTR("M420SV")
#define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
namespace Anycubic {
enum heater_state_t : uint8_t {
@@ -28,7 +28,7 @@
#include "../../../../libs/numtostr.h"
#include "../../../../module/motion.h" // for A20 read printing speed feedrate_percentage
#include "../../../../MarlinCore.h" // for quickstop_stepper and disable_steppers
#include "../../../../MarlinCore.h" // for quickstop_stepper, disable_steppers, G28_STR
#include "../../../../inc/MarlinConfig.h"
// command sending macro's with debugging capability
@@ -274,12 +274,12 @@ void AnycubicTFTClass::HandleSpecialMenu() {
case '6': // "<06SMeshLvl>"
SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling");
ExtUI::injectCommands_P(PSTR("G29 S1"));
ExtUI::injectCommands_P(PSTR("G29S1"));
break;
case '7': // "<07MeshNPnt>"
SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point");
ExtUI::injectCommands_P(PSTR("G29 S2"));
ExtUI::injectCommands_P(PSTR("G29S2"));
break;
case '8': // "<08HtEndPID>"
@@ -324,7 +324,7 @@ void AnycubicTFTClass::HandleSpecialMenu() {
case '2': // "<02ABL>"
SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling");
ExtUI::injectCommands_P(PSTR("G28\nG29"));
ExtUI::injectCommands_P(PSTR("G29N"));
break;
case '3': // "<03HtendPID>"
@@ -592,15 +592,12 @@ void AnycubicTFTClass::GetCommandFromTFT() {
} break;
case 5: { // A5 GET CURRENT COORDINATE
float xPostition = ExtUI::getAxisPosition_mm(ExtUI::X);
float yPostition = ExtUI::getAxisPosition_mm(ExtUI::Y);
float zPostition = ExtUI::getAxisPosition_mm(ExtUI::Z);
SEND_PGM("A5V X: ");
LCD_SERIAL.print(xPostition);
SEND_PGM(" Y: ");
LCD_SERIAL.print(yPostition);
SEND_PGM(" Z: ");
LCD_SERIAL.print(zPostition);
const float xPosition = ExtUI::getAxisPosition_mm(ExtUI::X),
yPosition = ExtUI::getAxisPosition_mm(ExtUI::Y),
zPosition = ExtUI::getAxisPosition_mm(ExtUI::Z);
SEND_PGM("A5V X: "); LCD_SERIAL.print(xPosition);
SEND_PGM( " Y: "); LCD_SERIAL.print(yPosition);
SEND_PGM( " Z: "); LCD_SERIAL.print(zPosition);
SENDLINE_PGM("");
} break;
@@ -761,14 +758,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
if (!ExtUI::isPrinting() && !ExtUI::isPrintingFromMediaPaused()) {
if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) {
if (CodeSeen('X'))
ExtUI::injectCommands_P(PSTR("G28 X"));
ExtUI::injectCommands_P(PSTR("G28X"));
if (CodeSeen('Y'))
ExtUI::injectCommands_P(PSTR("G28 Y"));
ExtUI::injectCommands_P(PSTR("G28Y"));
if (CodeSeen('Z'))
ExtUI::injectCommands_P(PSTR("G28 Z"));
ExtUI::injectCommands_P(PSTR("G28Z"));
}
else if (CodeSeen('C')) {
ExtUI::injectCommands_P(PSTR("G28"));
ExtUI::injectCommands_P(G28_STR);
}
}
break;
@@ -33,11 +33,9 @@
#include "../../ui_api.h"
#include "../../../../MarlinCore.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../gcode/queue.h"
#include "../../../../module/planner.h"
#include "../../../../sd/cardreader.h"
#include "../../../../libs/duration_t.h"
#include "../../../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
@@ -206,6 +206,10 @@
// Define macros for compatibility
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#define _CAT(a,V...) a##V
#define CAT(a,V...) _CAT(a,V)
@@ -75,9 +75,7 @@ namespace FTDI {
while (has_more_notes()) {
onIdle();
#ifdef EXTENSIBLE_UI
ExtUI::yield();
#endif
TERN_(TOUCH_UI_FTDI_EVE, ExtUI::yield());
}
}
@@ -32,7 +32,7 @@ using namespace Theme;
void AlertDialogBox::onEntry() {
BaseScreen::onEntry();
sound.play(screen_data.AlertDialogBox.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS);
sound.play(screen_data.AlertDialog.isError ? sad_trombone : twinkle, PLAY_ASYNCHRONOUS);
}
void AlertDialogBox::onRedraw(draw_mode_t what) {
@@ -45,7 +45,7 @@ template<typename T>
void AlertDialogBox::show(const T message) {
drawMessage(message);
storeBackground();
screen_data.AlertDialogBox.isError = false;
screen_data.AlertDialog.isError = false;
GOTO_SCREEN(AlertDialogBox);
}
@@ -53,7 +53,7 @@ template<typename T>
void AlertDialogBox::showError(const T message) {
drawMessage(message);
storeBackground();
screen_data.AlertDialogBox.isError = true;
screen_data.AlertDialog.isError = true;
GOTO_SCREEN(AlertDialogBox);
}
@@ -116,8 +116,8 @@ void BaseNumericAdjustmentScreen::widgets_t::_button(CommandProcessor &cmd, uint
BaseNumericAdjustmentScreen::widgets_t &BaseNumericAdjustmentScreen::widgets_t::precision(uint8_t decimals, precision_default_t initial) {
_decimals = decimals;
if (screen_data.BaseNumericAdjustmentScreen.increment == 0) {
screen_data.BaseNumericAdjustmentScreen.increment = 243 + (initial - DEFAULT_LOWEST) - _decimals;
if (screen_data.BaseNumericAdjustment.increment == 0) {
screen_data.BaseNumericAdjustment.increment = 243 + (initial - DEFAULT_LOWEST) - _decimals;
}
return *this;
}
@@ -154,7 +154,7 @@ void BaseNumericAdjustmentScreen::widgets_t::heading(progmem_str label) {
void BaseNumericAdjustmentScreen::widgets_t::_draw_increment_btn(CommandProcessor &cmd, uint8_t, const uint8_t tag) {
const char *label = PSTR("?");
uint8_t pos;
uint8_t & increment = screen_data.BaseNumericAdjustmentScreen.increment;
uint8_t & increment = screen_data.BaseNumericAdjustment.increment;
if (increment == 0) {
increment = tag; // Set the default value to be the first.
@@ -358,7 +358,7 @@ void BaseNumericAdjustmentScreen::widgets_t::home_buttons(uint8_t tag) {
}
void BaseNumericAdjustmentScreen::onEntry() {
screen_data.BaseNumericAdjustmentScreen.increment = 0; // This will force the increment to be picked while drawing.
screen_data.BaseNumericAdjustment.increment = 0; // This will force the increment to be picked while drawing.
BaseScreen::onEntry();
CommandProcessor cmd;
cmd.set_button_style_callback(nullptr);
@@ -367,14 +367,14 @@ void BaseNumericAdjustmentScreen::onEntry() {
bool BaseNumericAdjustmentScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: GOTO_PREVIOUS(); return true;
case 240 ... 245: screen_data.BaseNumericAdjustmentScreen.increment = tag; break;
case 240 ... 245: screen_data.BaseNumericAdjustment.increment = tag; break;
default: return current_screen.onTouchHeld(tag);
}
return true;
}
float BaseNumericAdjustmentScreen::getIncrement() {
switch (screen_data.BaseNumericAdjustmentScreen.increment) {
switch (screen_data.BaseNumericAdjustment.increment) {
case 240: return 0.001;
case 241: return 0.01;
case 242: return 0.1;
@@ -21,7 +21,7 @@
#include "../config.h"
#if BOTH(TOUCH_UI_FTDI_EVE, AUTO_BED_LEVELING_UBL)
#if BOTH(TOUCH_UI_FTDI_EVE, HAS_MESH)
#include "screens.h"
#include "screen_data.h"
@@ -196,7 +196,7 @@ void BedMeshScreen::drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, ExtUI::
}
if (opts & USE_HIGHLIGHT) {
const uint8_t tag = screen_data.BedMeshScreen.highlightedTag;
const uint8_t tag = screen_data.BedMesh.highlightedTag;
uint8_t x, y;
if (tagToPoint(tag, x, y)) {
cmd.cmd(COLOR_A(128))
@@ -221,16 +221,16 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) {
}
void BedMeshScreen::onEntry() {
screen_data.BedMeshScreen.highlightedTag = 0;
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_NONE;
screen_data.BedMesh.highlightedTag = 0;
screen_data.BedMesh.count = GRID_MAX_POINTS;
screen_data.BedMesh.message = screen_data.BedMesh.MSG_NONE;
BaseScreen::onEntry();
}
float BedMeshScreen::getHightlightedValue() {
if (screen_data.BedMeshScreen.highlightedTag) {
if (screen_data.BedMesh.highlightedTag) {
xy_uint8_t pt;
tagToPoint(screen_data.BedMeshScreen.highlightedTag, pt.x, pt.y);
tagToPoint(screen_data.BedMesh.highlightedTag, pt.x, pt.y);
return ExtUI::getMeshPoint(pt);
}
return NAN;
@@ -253,9 +253,9 @@ void BedMeshScreen::drawHighlightedPointValue() {
.tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
.tag(0);
switch (screen_data.BedMeshScreen.message) {
case screen_data.BedMeshScreen.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break;
case screen_data.BedMeshScreen.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break;
switch (screen_data.BedMesh.message) {
case screen_data.BedMesh.MSG_MESH_COMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE)); break;
case screen_data.BedMesh.MSG_MESH_INCOMPLETE: cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_INCOMPLETE)); break;
default: break;
}
}
@@ -277,11 +277,11 @@ void BedMeshScreen::onRedraw(draw_mode_t what) {
if (what & FOREGROUND) {
constexpr float autoscale_max_amplitude = 0.03;
const bool gotAllPoints = screen_data.BedMeshScreen.count >= GRID_MAX_POINTS;
const bool gotAllPoints = screen_data.BedMesh.count >= GRID_MAX_POINTS;
if (gotAllPoints) {
drawHighlightedPointValue();
}
const float levelingProgress = sq(float(screen_data.BedMeshScreen.count) / GRID_MAX_POINTS);
const float levelingProgress = sq(float(screen_data.BedMesh.count) / GRID_MAX_POINTS);
BedMeshScreen::drawMesh(INSET_POS(MESH_POS), ExtUI::getMeshArray(),
USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (gotAllPoints ? USE_COLORS : 0),
autoscale_max_amplitude * levelingProgress
@@ -290,7 +290,7 @@ void BedMeshScreen::onRedraw(draw_mode_t what) {
}
bool BedMeshScreen::onTouchStart(uint8_t tag) {
screen_data.BedMeshScreen.highlightedTag = tag;
screen_data.BedMesh.highlightedTag = tag;
return true;
}
@@ -309,35 +309,24 @@ void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) {
onRefresh();
}
bool BedMeshScreen::isMeshComplete(ExtUI::bed_mesh_t data) {
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
if (isnan(data[x][y])) {
return false;
}
}
}
return true;
}
void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
switch (state) {
case ExtUI::MESH_START:
screen_data.BedMeshScreen.count = 0;
screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_NONE;
screen_data.BedMesh.count = 0;
screen_data.BedMesh.message = screen_data.BedMesh.MSG_NONE;
break;
case ExtUI::MESH_FINISH:
if (screen_data.BedMeshScreen.count == GRID_MAX_POINTS && isMeshComplete(ExtUI::getMeshArray()))
screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_MESH_COMPLETE;
if (screen_data.BedMesh.count == GRID_MAX_POINTS && ExtUI::getMeshValid())
screen_data.BedMesh.message = screen_data.BedMesh.MSG_MESH_COMPLETE;
else
screen_data.BedMeshScreen.message = screen_data.BedMeshScreen.MSG_MESH_INCOMPLETE;
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
screen_data.BedMesh.message = screen_data.BedMesh.MSG_MESH_INCOMPLETE;
screen_data.BedMesh.count = GRID_MAX_POINTS;
break;
case ExtUI::PROBE_START:
screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y);
screen_data.BedMesh.highlightedTag = pointToTag(x, y);
break;
case ExtUI::PROBE_FINISH:
screen_data.BedMeshScreen.count++;
screen_data.BedMesh.count++;
break;
}
BedMeshScreen::onMeshUpdate(x, y, 0);
@@ -345,7 +334,7 @@ void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::pr
void BedMeshScreen::startMeshProbe() {
GOTO_SCREEN(BedMeshScreen);
screen_data.BedMeshScreen.count = 0;
screen_data.BedMesh.count = 0;
injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
}
@@ -319,7 +319,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) {
case 9: GOTO_SCREEN(FilesScreen); break;
case 10: GOTO_SCREEN(MainMenu); break;
case 13: GOTO_SCREEN(BioConfirmHomeE); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28 Z")); break;
case 14: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
case 15: GOTO_SCREEN(TemperatureScreen); break;
case 16: fine_motion = !fine_motion; break;
default: return false;
@@ -122,17 +122,17 @@ void ChangeFilamentScreen::drawTempGradient(uint16_t x, uint16_t y, uint16_t w,
void ChangeFilamentScreen::onEntry() {
BaseScreen::onEntry();
screen_data.ChangeFilamentScreen.e_tag = ExtUI::getActiveTool() + 10;
screen_data.ChangeFilamentScreen.t_tag = 0;
screen_data.ChangeFilamentScreen.repeat_tag = 0;
screen_data.ChangeFilamentScreen.saved_extruder = getActiveTool();
screen_data.ChangeFilament.e_tag = ExtUI::getActiveTool() + 10;
screen_data.ChangeFilament.t_tag = 0;
screen_data.ChangeFilament.repeat_tag = 0;
screen_data.ChangeFilament.saved_extruder = getActiveTool();
#if FILAMENT_UNLOAD_PURGE_LENGTH > 0
screen_data.ChangeFilamentScreen.need_purge = true;
screen_data.ChangeFilament.need_purge = true;
#endif
}
void ChangeFilamentScreen::onExit() {
setActiveTool(screen_data.ChangeFilamentScreen.saved_extruder, true);
setActiveTool(screen_data.ChangeFilament.saved_extruder, true);
}
void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
@@ -170,7 +170,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10;
if (screen_data.ChangeFilamentScreen.t_tag && !t_ok) {
if (screen_data.ChangeFilament.t_tag && !t_ok) {
cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING));
} else if (getActualTemp_celsius(e) > 100) {
cmd.cmd(COLOR_RGB(0xFF0000))
@@ -181,12 +181,12 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
#define TOG_STYLE(A) colors(A ? action_btn : normal_btn)
const bool tog2 = screen_data.ChangeFilamentScreen.t_tag == 2;
const bool tog3 = screen_data.ChangeFilamentScreen.t_tag == 3;
const bool tog4 = screen_data.ChangeFilamentScreen.t_tag == 4;
const bool tog10 = screen_data.ChangeFilamentScreen.e_tag == 10;
const bool tog2 = screen_data.ChangeFilament.t_tag == 2;
const bool tog3 = screen_data.ChangeFilament.t_tag == 3;
const bool tog4 = screen_data.ChangeFilament.t_tag == 4;
const bool tog10 = screen_data.ChangeFilament.e_tag == 10;
#if HAS_MULTI_HOTEND
const bool tog11 = screen_data.ChangeFilamentScreen.e_tag == 11;
const bool tog11 = screen_data.ChangeFilament.e_tag == 11;
#endif
cmd.TOG_STYLE(tog10)
@@ -200,8 +200,8 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
if (!t_ok) reset_menu_timeout();
const bool tog7 = screen_data.ChangeFilamentScreen.repeat_tag == 7;
const bool tog8 = screen_data.ChangeFilamentScreen.repeat_tag == 8;
const bool tog7 = screen_data.ChangeFilament.repeat_tag == 7;
const bool tog8 = screen_data.ChangeFilament.repeat_tag == 8;
{
char str[30];
@@ -228,7 +228,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
}
uint8_t ChangeFilamentScreen::getSoftenTemp() {
switch (screen_data.ChangeFilamentScreen.t_tag) {
switch (screen_data.ChangeFilament.t_tag) {
case 2: return LOW_TEMP;
case 3: return MED_TEMP;
case 4: return HIGH_TEMP;
@@ -237,7 +237,7 @@ uint8_t ChangeFilamentScreen::getSoftenTemp() {
}
ExtUI::extruder_t ChangeFilamentScreen::getExtruder() {
switch (screen_data.ChangeFilamentScreen.e_tag) {
switch (screen_data.ChangeFilament.e_tag) {
case 13: return ExtUI::E3;
case 12: return ExtUI::E2;
case 11: return ExtUI::E1;
@@ -248,8 +248,8 @@ ExtUI::extruder_t ChangeFilamentScreen::getExtruder() {
void ChangeFilamentScreen::doPurge() {
#if FILAMENT_UNLOAD_PURGE_LENGTH > 0
constexpr float purge_distance_mm = FILAMENT_UNLOAD_PURGE_LENGTH;
if (screen_data.ChangeFilamentScreen.need_purge) {
screen_data.ChangeFilamentScreen.need_purge = false;
if (screen_data.ChangeFilament.need_purge) {
screen_data.ChangeFilament.need_purge = false;
MoveAxisScreen::setManualFeedrate(getExtruder(), purge_distance_mm);
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(getExtruder()) + purge_distance_mm, getExtruder());
}
@@ -277,23 +277,23 @@ bool ChangeFilamentScreen::onTouchEnd(uint8_t tag) {
case 3:
case 4:
// Change temperature
screen_data.ChangeFilamentScreen.t_tag = tag;
screen_data.ChangeFilament.t_tag = tag;
setTargetTemp_celsius(getSoftenTemp(), getExtruder());
break;
case 7:
screen_data.ChangeFilamentScreen.repeat_tag = (screen_data.ChangeFilamentScreen.repeat_tag == 7) ? 0 : 7;
screen_data.ChangeFilament.repeat_tag = (screen_data.ChangeFilament.repeat_tag == 7) ? 0 : 7;
break;
case 8:
screen_data.ChangeFilamentScreen.repeat_tag = (screen_data.ChangeFilamentScreen.repeat_tag == 8) ? 0 : 8;
screen_data.ChangeFilament.repeat_tag = (screen_data.ChangeFilament.repeat_tag == 8) ? 0 : 8;
break;
case 10:
case 11:
// Change extruder
screen_data.ChangeFilamentScreen.e_tag = tag;
screen_data.ChangeFilamentScreen.t_tag = 0;
screen_data.ChangeFilamentScreen.repeat_tag = 0;
screen_data.ChangeFilament.e_tag = tag;
screen_data.ChangeFilament.t_tag = 0;
screen_data.ChangeFilament.repeat_tag = 0;
#if FILAMENT_UNLOAD_PURGE_LENGTH > 0
screen_data.ChangeFilamentScreen.need_purge = true;
screen_data.ChangeFilament.need_purge = true;
#endif
setActiveTool(getExtruder(), true);
break;
@@ -319,7 +319,7 @@ bool ChangeFilamentScreen::onTouchHeld(uint8_t tag) {
void ChangeFilamentScreen::onIdle() {
reset_menu_timeout();
if (screen_data.ChangeFilamentScreen.repeat_tag) onTouchHeld(screen_data.ChangeFilamentScreen.repeat_tag);
if (screen_data.ChangeFilament.repeat_tag) onTouchHeld(screen_data.ChangeFilament.repeat_tag);
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
onRefresh();
refresh_timer.start();
@@ -38,15 +38,15 @@ void MoveEScreen::onRedraw(draw_mode_t what) {
w.heading( GET_TEXT_F(MSG_E_MOVE));
w.color(Theme::e_axis);
#if EXTRUDERS == 1
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E), screen_data.MoveAxis.e_rel[0], canMove(E0));
#elif HAS_MULTI_EXTRUDER
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), screen_data.MoveAxisScreen.e_rel[0], canMove(E0));
w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), screen_data.MoveAxisScreen.e_rel[1], canMove(E1));
w.adjuster( 8, GET_TEXT_F(MSG_AXIS_E1), screen_data.MoveAxis.e_rel[0], canMove(E0));
w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), screen_data.MoveAxis.e_rel[1], canMove(E1));
#if EXTRUDERS > 2
w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), screen_data.MoveAxisScreen.e_rel[2], canMove(E2));
w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), screen_data.MoveAxis.e_rel[2], canMove(E2));
#endif
#if EXTRUDERS > 3
w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), screen_data.MoveAxisScreen.e_rel[3], canMove(E3));
w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), screen_data.MoveAxis.e_rel[3], canMove(E3));
#endif
#endif
w.increments();
@@ -21,7 +21,7 @@
#include "../config.h"
#if ENABLED(TOUCH_UI_FTDI_EVE) && defined(TOUCH_UI_COCOA_PRESS)
#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS)
#include "screens.h"
@@ -21,7 +21,7 @@
#include "../config.h"
#if ENABLED(TOUCH_UI_FTDI_EVE) && defined(TOUCH_UI_COCOA_PRESS)
#if BOTH(TOUCH_UI_FTDI_EVE, TOUCH_UI_COCOA_PRESS)
#include "screens.h"
#include "screen_data.h"
@@ -54,7 +54,7 @@ void PreheatTimerScreen::draw_message(draw_mode_t what) {
}
uint16_t PreheatTimerScreen::secondsRemaining() {
const uint32_t elapsed_sec = (millis() - screen_data.PreheatTimerScreen.start_ms) / 1000;
const uint32_t elapsed_sec = (millis() - screen_data.PreheatTimer.start_ms) / 1000;
return (COCOA_PRESS_PREHEAT_SECONDS > elapsed_sec) ? COCOA_PRESS_PREHEAT_SECONDS - elapsed_sec : 0;
}
@@ -118,7 +118,7 @@ void PreheatTimerScreen::draw_adjuster(draw_mode_t what, uint8_t tag, progmem_st
}
void PreheatTimerScreen::onEntry() {
screen_data.PreheatTimerScreen.start_ms = millis();
screen_data.PreheatTimer.start_ms = millis();
}
void PreheatTimerScreen::onRedraw(draw_mode_t what) {
@@ -53,12 +53,12 @@ bool ConfirmStartPrintDialogBox::onTouchEnd(uint8_t tag) {
const char *ConfirmStartPrintDialogBox::getFilename(bool longName) {
FileList files;
files.seek(screen_data.ConfirmStartPrintDialogBox.file_index, true);
files.seek(screen_data.ConfirmStartPrintDialog.file_index, true);
return longName ? files.longFilename() : files.shortFilename();
}
void ConfirmStartPrintDialogBox::show(uint8_t file_index) {
screen_data.ConfirmStartPrintDialogBox.file_index = file_index;
screen_data.ConfirmStartPrintDialog.file_index = file_index;
GOTO_SCREEN(ConfirmStartPrintDialogBox);
}
@@ -36,8 +36,15 @@ void ConfirmUserRequestAlertBox::onRedraw(draw_mode_t mode) {
bool ConfirmUserRequestAlertBox::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1:
ExtUI::setUserConfirmed();
GOTO_PREVIOUS();
if (ExtUI::isPrintingPaused()) {
// The TuneMenu will call ExtUI::setUserConfirmed()
GOTO_SCREEN(TuneMenu);
current_screen.forget();
}
else {
ExtUI::setUserConfirmed();
GOTO_PREVIOUS();
}
return true;
case 2: GOTO_PREVIOUS(); return true;
default: return false;
@@ -47,7 +54,7 @@ bool ConfirmUserRequestAlertBox::onTouchEnd(uint8_t tag) {
void ConfirmUserRequestAlertBox::show(const char* msg) {
drawMessage(msg);
storeBackground();
screen_data.AlertDialogBox.isError = false;
screen_data.AlertDialog.isError = false;
GOTO_SCREEN(ConfirmUserRequestAlertBox);
}
@@ -55,4 +62,5 @@ void ConfirmUserRequestAlertBox::hide() {
if (AT_SCREEN(ConfirmUserRequestAlertBox))
GOTO_PREVIOUS();
}
#endif // TOUCH_UI_FTDI_EVE
@@ -32,8 +32,8 @@ using namespace ExtUI;
using namespace Theme;
void FilesScreen::onEntry() {
screen_data.FilesScreen.cur_page = 0;
screen_data.FilesScreen.selected_tag = 0xFF;
screen_data.Files.cur_page = 0;
screen_data.Files.selected_tag = 0xFF;
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP);
#endif
@@ -50,21 +50,21 @@ const char *FilesScreen::getSelectedFilename(bool longName) {
void FilesScreen::drawSelectedFile() {
FileList files;
files.seek(getSelectedFileIndex(), true);
screen_data.FilesScreen.flags.is_dir = files.isDir();
screen_data.Files.flags.is_dir = files.isDir();
drawFileButton(
files.filename(),
screen_data.FilesScreen.selected_tag,
screen_data.FilesScreen.flags.is_dir,
screen_data.Files.selected_tag,
screen_data.Files.flags.is_dir,
true
);
}
uint16_t FilesScreen::getSelectedFileIndex() {
return getFileForTag(screen_data.FilesScreen.selected_tag);
return getFileForTag(screen_data.Files.selected_tag);
}
uint16_t FilesScreen::getFileForTag(uint8_t tag) {
return screen_data.FilesScreen.cur_page * files_per_page + tag - 2;
return screen_data.Files.cur_page * files_per_page + tag - 2;
}
#if ENABLED(TOUCH_UI_PORTRAIT)
@@ -106,15 +106,15 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir,
void FilesScreen::drawFileList() {
FileList files;
screen_data.FilesScreen.num_page = max(1,ceil(float(files.count()) / files_per_page));
screen_data.FilesScreen.cur_page = min(screen_data.FilesScreen.cur_page, screen_data.FilesScreen.num_page-1);
screen_data.FilesScreen.flags.is_root = files.isAtRootDir();
screen_data.Files.num_page = max(1,ceil(float(files.count()) / files_per_page));
screen_data.Files.cur_page = min(screen_data.Files.cur_page, screen_data.Files.num_page-1);
screen_data.Files.flags.is_root = files.isAtRootDir();
#undef MARGIN_T
#undef MARGIN_B
#define MARGIN_T 0
#define MARGIN_B 0
uint16_t fileIndex = screen_data.FilesScreen.cur_page * files_per_page;
uint16_t fileIndex = screen_data.Files.cur_page * files_per_page;
for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) {
if (files.seek(fileIndex)) {
drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false);
@@ -126,8 +126,8 @@ void FilesScreen::drawFileList() {
}
void FilesScreen::drawHeader() {
const bool prev_enabled = screen_data.FilesScreen.cur_page > 0;
const bool next_enabled = screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page - 1);
const bool prev_enabled = screen_data.Files.cur_page > 0;
const bool next_enabled = screen_data.Files.cur_page < (screen_data.Files.num_page - 1);
#undef MARGIN_T
#undef MARGIN_B
@@ -136,7 +136,7 @@ void FilesScreen::drawHeader() {
char str[16];
sprintf_P(str, PSTR("Page %d of %d"),
screen_data.FilesScreen.cur_page + 1, screen_data.FilesScreen.num_page);
screen_data.Files.cur_page + 1, screen_data.Files.num_page);
CommandProcessor cmd;
cmd.colors(normal_btn)
@@ -158,8 +158,8 @@ void FilesScreen::drawFooter() {
#define MARGIN_T 5
#define MARGIN_B 5
#endif
const bool has_selection = screen_data.FilesScreen.selected_tag != 0xFF;
const uint8_t back_tag = screen_data.FilesScreen.flags.is_root ? 240 : 245;
const bool has_selection = screen_data.Files.selected_tag != 0xFF;
const uint8_t back_tag = screen_data.Files.flags.is_root ? 240 : 245;
const uint8_t y = GRID_ROWS - footer_h + 1;
const uint8_t h = footer_h;
@@ -171,7 +171,7 @@ void FilesScreen::drawFooter() {
.enabled(has_selection)
.colors(has_selection ? action_btn : normal_btn);
if (screen_data.FilesScreen.flags.is_dir)
if (screen_data.Files.flags.is_dir)
cmd.tag(244).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_OPEN));
else
cmd.tag(243).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_PRINT));
@@ -186,8 +186,8 @@ void FilesScreen::onRedraw(draw_mode_t what) {
}
void FilesScreen::gotoPage(uint8_t page) {
screen_data.FilesScreen.selected_tag = 0xFF;
screen_data.FilesScreen.cur_page = page;
screen_data.Files.selected_tag = 0xFF;
screen_data.Files.cur_page = page;
CommandProcessor cmd;
cmd.cmd(CMD_DLSTART)
.cmd(CLEAR_COLOR_RGB(bg_color))
@@ -201,13 +201,13 @@ bool FilesScreen::onTouchEnd(uint8_t tag) {
switch (tag) {
case 240: GOTO_PREVIOUS(); return true;
case 241:
if (screen_data.FilesScreen.cur_page > 0) {
gotoPage(screen_data.FilesScreen.cur_page-1);
if (screen_data.Files.cur_page > 0) {
gotoPage(screen_data.Files.cur_page-1);
}
break;
case 242:
if (screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page-1)) {
gotoPage(screen_data.FilesScreen.cur_page+1);
if (screen_data.Files.cur_page < (screen_data.Files.num_page-1)) {
gotoPage(screen_data.Files.cur_page+1);
}
break;
case 243:
@@ -229,18 +229,18 @@ bool FilesScreen::onTouchEnd(uint8_t tag) {
break;
default:
if (tag < 240) {
screen_data.FilesScreen.selected_tag = tag;
screen_data.Files.selected_tag = tag;
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
if (FTDI::ftdi_chip >= 810) {
const char *longFilename = getSelectedLongFilename();
if (longFilename[0]) {
CommandProcessor cmd;
uint16_t text_width = cmd.font(font_medium).text_width(longFilename);
screen_data.FilesScreen.scroll_pos = 0;
screen_data.Files.scroll_pos = 0;
if (text_width > display_width)
screen_data.FilesScreen.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R;
screen_data.Files.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R;
else
screen_data.FilesScreen.scroll_max = 0;
screen_data.Files.scroll_max = 0;
}
}
#endif
@@ -254,9 +254,9 @@ void FilesScreen::onIdle() {
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810)
if (FTDI::ftdi_chip >= 810) {
CLCD::mem_write_32(CLCD::REG::MACRO_0,
VERTEX_TRANSLATE_X(-int32_t(screen_data.FilesScreen.scroll_pos)));
if (screen_data.FilesScreen.scroll_pos < screen_data.FilesScreen.scroll_max * 16)
screen_data.FilesScreen.scroll_pos++;
VERTEX_TRANSLATE_X(-int32_t(screen_data.Files.scroll_pos)));
if (screen_data.Files.scroll_pos < screen_data.Files.scroll_max * 16)
screen_data.Files.scroll_pos++;
}
#endif
}

Some files were not shown because too many files have changed in this diff Show More