Ender3 - Marlin 2.1.2.4 build (#16)
This commit was merged in pull request #16.
This commit is contained in:
504
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/boards.h
Normal file
504
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/boards.h
Normal file
@@ -0,0 +1,504 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
/**
|
||||
* Whenever changes are made to this file, please update Marlin/Makefile
|
||||
* and _data/boards.yml in the MarlinDocumentation repo.
|
||||
*/
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
#define BOARD_UNKNOWN -1
|
||||
|
||||
//
|
||||
// RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
|
||||
//
|
||||
|
||||
#define BOARD_RAMPS_OLD 1000 // MEGA/RAMPS up to 1.2
|
||||
|
||||
#define BOARD_RAMPS_13_EFB 1010 // RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_13_EEB 1011 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_13_EFF 1012 // RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_13_EEF 1013 // RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_13_SF 1014 // RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
|
||||
|
||||
#define BOARD_RAMPS_14_EFB 1020 // RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_14_EEB 1021 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_14_EFF 1022 // RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_14_EEF 1023 // RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_14_SF 1024 // RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
|
||||
|
||||
#define BOARD_RAMPS_PLUS_EFB 1030 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_PLUS_EEB 1031 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_PLUS_EFF 1032 // RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_PLUS_EEF 1033 // RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_PLUS_SF 1034 // RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
|
||||
|
||||
//
|
||||
// RAMPS Derivatives - ATmega1280, ATmega2560
|
||||
//
|
||||
|
||||
#define BOARD_3DRAG 1100 // 3Drag Controller
|
||||
#define BOARD_K8200 1101 // Velleman K8200 Controller (derived from 3Drag Controller)
|
||||
#define BOARD_K8400 1102 // Velleman K8400 Controller (derived from 3Drag Controller)
|
||||
#define BOARD_K8600 1103 // Velleman K8600 Controller (Vertex Nano)
|
||||
#define BOARD_K8800 1104 // Velleman K8800 Controller (Vertex Delta)
|
||||
#define BOARD_BAM_DICE 1105 // 2PrintBeta BAM&DICE with STK drivers
|
||||
#define BOARD_BAM_DICE_DUE 1106 // 2PrintBeta BAM&DICE Due with STK drivers
|
||||
#define BOARD_MKS_BASE 1107 // MKS BASE v1.0
|
||||
#define BOARD_MKS_BASE_14 1108 // MKS BASE v1.4 with Allegro A4982 stepper drivers
|
||||
#define BOARD_MKS_BASE_15 1109 // MKS BASE v1.5 with Allegro A4982 stepper drivers
|
||||
#define BOARD_MKS_BASE_16 1110 // MKS BASE v1.6 with Allegro A4982 stepper drivers
|
||||
#define BOARD_MKS_BASE_HEROIC 1111 // MKS BASE 1.0 with Heroic HR4982 stepper drivers
|
||||
#define BOARD_MKS_GEN_13 1112 // MKS GEN v1.3 or 1.4
|
||||
#define BOARD_MKS_GEN_L 1113 // MKS GEN L
|
||||
#define BOARD_KFB_2 1114 // BigTreeTech or BIQU KFB2.0
|
||||
#define BOARD_ZRIB_V20 1115 // zrib V2.0 (Chinese RAMPS replica)
|
||||
#define BOARD_ZRIB_V52 1116 // zrib V5.2 (Chinese RAMPS replica)
|
||||
#define BOARD_FELIX2 1117 // Felix 2.0+ Electronics Board (RAMPS like)
|
||||
#define BOARD_RIGIDBOARD 1118 // Invent-A-Part RigidBoard
|
||||
#define BOARD_RIGIDBOARD_V2 1119 // Invent-A-Part RigidBoard V2
|
||||
#define BOARD_SAINSMART_2IN1 1120 // Sainsmart 2-in-1 board
|
||||
#define BOARD_ULTIMAKER 1121 // Ultimaker
|
||||
#define BOARD_ULTIMAKER_OLD 1122 // Ultimaker (Older electronics. Pre 1.5.4. This is rare)
|
||||
#define BOARD_AZTEEG_X3 1123 // Azteeg X3
|
||||
#define BOARD_AZTEEG_X3_PRO 1124 // Azteeg X3 Pro
|
||||
#define BOARD_ULTIMAIN_2 1125 // Ultimainboard 2.x (Uses TEMP_SENSOR 20)
|
||||
#define BOARD_RUMBA 1126 // Rumba
|
||||
#define BOARD_RUMBA_RAISE3D 1127 // Raise3D N series Rumba derivative
|
||||
#define BOARD_RL200 1128 // Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
|
||||
#define BOARD_FORMBOT_TREX2PLUS 1129 // Formbot T-Rex 2 Plus
|
||||
#define BOARD_FORMBOT_TREX3 1130 // Formbot T-Rex 3
|
||||
#define BOARD_FORMBOT_RAPTOR 1131 // Formbot Raptor
|
||||
#define BOARD_FORMBOT_RAPTOR2 1132 // Formbot Raptor 2
|
||||
#define BOARD_BQ_ZUM_MEGA_3D 1133 // bq ZUM Mega 3D
|
||||
#define BOARD_MAKEBOARD_MINI 1134 // MakeBoard Mini v2.1.2 by MicroMake
|
||||
#define BOARD_TRIGORILLA_13 1135 // TriGorilla Anycubic version 1.3-based on RAMPS EFB
|
||||
#define BOARD_TRIGORILLA_14 1136 // ... Ver 1.4
|
||||
#define BOARD_TRIGORILLA_14_11 1137 // ... Rev 1.1 (new servo pin order)
|
||||
#define BOARD_RAMPS_ENDER_4 1138 // Creality: Ender-4, CR-8
|
||||
#define BOARD_RAMPS_CREALITY 1139 // Creality: CR10S, CR20, CR-X
|
||||
#define BOARD_DAGOMA_F5 1140 // Dagoma F5
|
||||
#define BOARD_FYSETC_F6_13 1141 // FYSETC F6 1.3
|
||||
#define BOARD_FYSETC_F6_14 1142 // FYSETC F6 1.4
|
||||
#define BOARD_DUPLICATOR_I3_PLUS 1143 // Wanhao Duplicator i3 Plus
|
||||
#define BOARD_VORON 1144 // VORON Design
|
||||
#define BOARD_TRONXY_V3_1_0 1145 // Tronxy TRONXY-V3-1.0
|
||||
#define BOARD_Z_BOLT_X_SERIES 1146 // Z-Bolt X Series
|
||||
#define BOARD_TT_OSCAR 1147 // TT OSCAR
|
||||
#define BOARD_OVERLORD 1148 // Overlord/Overlord Pro
|
||||
#define BOARD_HJC2560C_REV1 1149 // ADIMLab Gantry v1
|
||||
#define BOARD_HJC2560C_REV2 1150 // ADIMLab Gantry v2
|
||||
#define BOARD_TANGO 1151 // BIQU Tango V1
|
||||
#define BOARD_MKS_GEN_L_V2 1152 // MKS GEN L V2
|
||||
#define BOARD_MKS_GEN_L_V21 1153 // MKS GEN L V2.1
|
||||
#define BOARD_COPYMASTER_3D 1154 // Copymaster 3D
|
||||
#define BOARD_ORTUR_4 1155 // Ortur 4
|
||||
#define BOARD_TENLOG_D3_HERO 1156 // Tenlog D3 Hero IDEX printer
|
||||
#define BOARD_TENLOG_MB1_V23 1157 // Tenlog D3, D5, D6 IDEX Printer
|
||||
#define BOARD_RAMPS_S_12_EEFB 1158 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
|
||||
#define BOARD_RAMPS_S_12_EEEB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
|
||||
#define BOARD_RAMPS_S_12_EFFB 1160 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
|
||||
#define BOARD_LONGER3D_LK1_PRO 1161 // Longer LK1 PRO / Alfawise U20 Pro (PRO version)
|
||||
#define BOARD_LONGER3D_LKx_PRO 1162 // Longer LKx PRO / Alfawise Uxx Pro (PRO version)
|
||||
#define BOARD_ZRIB_V53 1163 // Zonestar zrib V5.3 (Chinese RAMPS replica)
|
||||
#define BOARD_PXMALION_CORE_I3 1164 // Pxmalion Core I3
|
||||
|
||||
//
|
||||
// RAMBo and derivatives
|
||||
//
|
||||
|
||||
#define BOARD_RAMBO 1200 // Rambo
|
||||
#define BOARD_MINIRAMBO 1201 // Mini-Rambo
|
||||
#define BOARD_MINIRAMBO_10A 1202 // Mini-Rambo 1.0a
|
||||
#define BOARD_EINSY_RAMBO 1203 // Einsy Rambo
|
||||
#define BOARD_EINSY_RETRO 1204 // Einsy Retro
|
||||
#define BOARD_SCOOVO_X9H 1205 // abee Scoovo X9H
|
||||
#define BOARD_RAMBO_THINKERV2 1206 // ThinkerV2
|
||||
|
||||
//
|
||||
// Other ATmega1280, ATmega2560
|
||||
//
|
||||
|
||||
#define BOARD_CNCONTROLS_11 1300 // Cartesio CN Controls V11
|
||||
#define BOARD_CNCONTROLS_12 1301 // Cartesio CN Controls V12
|
||||
#define BOARD_CNCONTROLS_15 1302 // Cartesio CN Controls V15
|
||||
#define BOARD_CHEAPTRONIC 1303 // Cheaptronic v1.0
|
||||
#define BOARD_CHEAPTRONIC_V2 1304 // Cheaptronic v2.0
|
||||
#define BOARD_MIGHTYBOARD_REVE 1305 // Makerbot Mightyboard Revision E
|
||||
#define BOARD_MEGATRONICS 1306 // Megatronics
|
||||
#define BOARD_MEGATRONICS_2 1307 // Megatronics v2.0
|
||||
#define BOARD_MEGATRONICS_3 1308 // Megatronics v3.0
|
||||
#define BOARD_MEGATRONICS_31 1309 // Megatronics v3.1
|
||||
#define BOARD_MEGATRONICS_32 1310 // Megatronics v3.2
|
||||
#define BOARD_ELEFU_3 1311 // Elefu Ra Board (v3)
|
||||
#define BOARD_LEAPFROG 1312 // Leapfrog
|
||||
#define BOARD_MEGACONTROLLER 1313 // Mega controller
|
||||
#define BOARD_GT2560_REV_A 1314 // Geeetech GT2560 Rev A
|
||||
#define BOARD_GT2560_REV_A_PLUS 1315 // Geeetech GT2560 Rev A+ (with auto level probe)
|
||||
#define BOARD_GT2560_REV_B 1316 // Geeetech GT2560 Rev B
|
||||
#define BOARD_GT2560_V3 1317 // Geeetech GT2560 Rev B for A10(M/T/D)
|
||||
#define BOARD_GT2560_V4 1318 // Geeetech GT2560 Rev B for A10(M/T/D)
|
||||
#define BOARD_GT2560_V3_MC2 1319 // Geeetech GT2560 Rev B for Mecreator2
|
||||
#define BOARD_GT2560_V3_A20 1320 // Geeetech GT2560 Rev B for A20(M/T/D)
|
||||
#define BOARD_EINSTART_S 1321 // Einstart retrofit
|
||||
#define BOARD_WANHAO_ONEPLUS 1322 // Wanhao 0ne+ i3 Mini
|
||||
#define BOARD_LEAPFROG_XEED2015 1323 // Leapfrog Xeed 2015
|
||||
#define BOARD_PICA_REVB 1324 // PICA Shield (original version)
|
||||
#define BOARD_PICA 1325 // PICA Shield (rev C or later)
|
||||
#define BOARD_INTAMSYS40 1326 // Intamsys 4.0 (Funmat HT)
|
||||
#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct G-code only)
|
||||
#define BOARD_GT2560_V4_A20 1328 // Geeetech GT2560 Rev B for A20(M/T/D)
|
||||
#define BOARD_PROTONEER_CNC_SHIELD_V3 1329 // Mega controller & Protoneer CNC Shield V3.00
|
||||
#define BOARD_WEEDO_62A 1330 // WEEDO 62A board (TINA2, Monoprice Cadet, etc.)
|
||||
|
||||
//
|
||||
// ATmega1281, ATmega2561
|
||||
//
|
||||
|
||||
#define BOARD_MINITRONICS 1400 // Minitronics v1.0/1.1
|
||||
#define BOARD_SILVER_GATE 1401 // Silvergate v1.0
|
||||
|
||||
//
|
||||
// Sanguinololu and Derivatives - ATmega644P, ATmega1284P
|
||||
//
|
||||
|
||||
#define BOARD_SANGUINOLOLU_11 1500 // Sanguinololu < 1.2
|
||||
#define BOARD_SANGUINOLOLU_12 1501 // Sanguinololu 1.2 and above
|
||||
#define BOARD_MELZI 1502 // Melzi
|
||||
#define BOARD_MELZI_V2 1503 // Melzi V2
|
||||
#define BOARD_MELZI_MAKR3D 1504 // Melzi with ATmega1284 (MaKr3d version)
|
||||
#define BOARD_MELZI_CREALITY 1505 // Melzi Creality3D (for CR-10 etc)
|
||||
#define BOARD_MELZI_MALYAN 1506 // Melzi Malyan M150
|
||||
#define BOARD_MELZI_TRONXY 1507 // Tronxy X5S
|
||||
#define BOARD_STB_11 1508 // STB V1.1
|
||||
#define BOARD_AZTEEG_X1 1509 // Azteeg X1
|
||||
#define BOARD_ANET_10 1510 // Anet 1.0 (Melzi clone)
|
||||
#define BOARD_ZMIB_V2 1511 // ZoneStar ZMIB V2
|
||||
|
||||
//
|
||||
// Other ATmega644P, ATmega644, ATmega1284P
|
||||
//
|
||||
|
||||
#define BOARD_GEN3_MONOLITHIC 1600 // Gen3 Monolithic Electronics
|
||||
#define BOARD_GEN3_PLUS 1601 // Gen3+
|
||||
#define BOARD_GEN6 1602 // Gen6
|
||||
#define BOARD_GEN6_DELUXE 1603 // Gen6 deluxe
|
||||
#define BOARD_GEN7_CUSTOM 1604 // Gen7 custom (Alfons3 Version) https://github.com/Alfons3/Generation_7_Electronics
|
||||
#define BOARD_GEN7_12 1605 // Gen7 v1.1, v1.2
|
||||
#define BOARD_GEN7_13 1606 // Gen7 v1.3
|
||||
#define BOARD_GEN7_14 1607 // Gen7 v1.4
|
||||
#define BOARD_OMCA_A 1608 // Alpha OMCA
|
||||
#define BOARD_OMCA 1609 // Final OMCA
|
||||
#define BOARD_SETHI 1610 // Sethi 3D_1
|
||||
|
||||
//
|
||||
// Teensyduino - AT90USB1286, AT90USB1286P
|
||||
//
|
||||
|
||||
#define BOARD_TEENSYLU 1700 // Teensylu
|
||||
#define BOARD_PRINTRBOARD 1701 // Printrboard (AT90USB1286)
|
||||
#define BOARD_PRINTRBOARD_REVF 1702 // Printrboard Revision F (AT90USB1286)
|
||||
#define BOARD_BRAINWAVE 1703 // Brainwave (AT90USB646)
|
||||
#define BOARD_BRAINWAVE_PRO 1704 // Brainwave Pro (AT90USB1286)
|
||||
#define BOARD_SAV_MKI 1705 // SAV Mk-I (AT90USB1286)
|
||||
#define BOARD_TEENSY2 1706 // Teensy++2.0 (AT90USB1286)
|
||||
#define BOARD_5DPRINT 1707 // 5DPrint D8 Driver Board
|
||||
|
||||
//
|
||||
// LPC1768 ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_RAMPS_14_RE_ARM_EFB 2000 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_14_RE_ARM_EEB 2001 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_14_RE_ARM_EFF 2002 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_14_RE_ARM_EEF 2003 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_14_RE_ARM_SF 2004 // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
|
||||
#define BOARD_MKS_SBASE 2005 // MKS-Sbase
|
||||
#define BOARD_AZSMZ_MINI 2006 // AZSMZ Mini
|
||||
#define BOARD_BIQU_BQ111_A4 2007 // BIQU BQ111-A4
|
||||
#define BOARD_SELENA_COMPACT 2008 // Selena Compact
|
||||
#define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0
|
||||
#define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L
|
||||
#define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6, revision 1 prototype
|
||||
#define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1
|
||||
#define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3
|
||||
#define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4
|
||||
#define BOARD_EMOTRONIC 2015 // eMotion-Tech eMotronic
|
||||
|
||||
//
|
||||
// LPC1769 ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_MKS_SGEN 2500 // MKS-SGen
|
||||
#define BOARD_AZTEEG_X5_GT 2501 // Azteeg X5 GT
|
||||
#define BOARD_AZTEEG_X5_MINI 2502 // Azteeg X5 Mini
|
||||
#define BOARD_AZTEEG_X5_MINI_WIFI 2503 // Azteeg X5 Mini Wifi
|
||||
#define BOARD_COHESION3D_REMIX 2504 // Cohesion3D ReMix
|
||||
#define BOARD_COHESION3D_MINI 2505 // Cohesion3D Mini
|
||||
#define BOARD_SMOOTHIEBOARD 2506 // Smoothieboard
|
||||
#define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0
|
||||
#define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO
|
||||
#define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2
|
||||
#define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo
|
||||
#define BOARD_FLY_CDY 2511 // FLYmaker FLY CDY
|
||||
|
||||
//
|
||||
// SAM3X8E ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_DUE3DOM 3000 // DUE3DOM for Arduino DUE
|
||||
#define BOARD_DUE3DOM_MINI 3001 // DUE3DOM MINI for Arduino DUE
|
||||
#define BOARD_RADDS 3002 // RADDS
|
||||
#define BOARD_RAMPS_FD_V1 3003 // RAMPS-FD v1
|
||||
#define BOARD_RAMPS_FD_V2 3004 // RAMPS-FD v2
|
||||
#define BOARD_RAMPS_SMART_EFB 3005 // RAMPS-SMART (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_SMART_EEB 3006 // RAMPS-SMART (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_SMART_EFF 3007 // RAMPS-SMART (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_SMART_EEF 3008 // RAMPS-SMART (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_SMART_SF 3009 // RAMPS-SMART (Power outputs: Spindle, Controller Fan)
|
||||
#define BOARD_RAMPS_DUO_EFB 3010 // RAMPS Duo (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS_DUO_EEB 3011 // RAMPS Duo (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS_DUO_EFF 3012 // RAMPS Duo (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS_DUO_EEF 3013 // RAMPS Duo (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS_DUO_SF 3014 // RAMPS Duo (Power outputs: Spindle, Controller Fan)
|
||||
#define BOARD_RAMPS4DUE_EFB 3015 // RAMPS4DUE (Power outputs: Hotend, Fan, Bed)
|
||||
#define BOARD_RAMPS4DUE_EEB 3016 // RAMPS4DUE (Power outputs: Hotend0, Hotend1, Bed)
|
||||
#define BOARD_RAMPS4DUE_EFF 3017 // RAMPS4DUE (Power outputs: Hotend, Fan0, Fan1)
|
||||
#define BOARD_RAMPS4DUE_EEF 3018 // RAMPS4DUE (Power outputs: Hotend0, Hotend1, Fan)
|
||||
#define BOARD_RAMPS4DUE_SF 3019 // RAMPS4DUE (Power outputs: Spindle, Controller Fan)
|
||||
#define BOARD_RURAMPS4D_11 3020 // RuRAMPS4Duo v1.1
|
||||
#define BOARD_RURAMPS4D_13 3021 // RuRAMPS4Duo v1.3
|
||||
#define BOARD_ULTRATRONICS_PRO 3022 // ReprapWorld Ultratronics Pro V1.0
|
||||
#define BOARD_ARCHIM1 3023 // UltiMachine Archim1 (with DRV8825 drivers)
|
||||
#define BOARD_ARCHIM2 3024 // UltiMachine Archim2 (with TMC2130 drivers)
|
||||
#define BOARD_ALLIGATOR 3025 // Alligator Board R2
|
||||
#define BOARD_CNCONTROLS_15D 3026 // Cartesio CN Controls V15 on DUE
|
||||
#define BOARD_KRATOS32 3027 // K.3D Kratos32 (Arduino Due Shield)
|
||||
|
||||
//
|
||||
// SAM3X8C ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_PRINTRBOARD_G2 3100 // Printrboard G2
|
||||
#define BOARD_ADSK 3101 // Arduino DUE Shield Kit (ADSK)
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M0+
|
||||
//
|
||||
|
||||
#define BOARD_BTT_EBB42_V1_1 4000 // BigTreeTech EBB42 V1.1 (STM32G0B1CB)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V3_0 4001 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B0RE / STM32G0B1RE)
|
||||
#define BOARD_BTT_MANTA_E3_EZ_V1_0 4002 // BigTreeTech Manta E3 EZ V1.0 (STM32G0B1RE)
|
||||
#define BOARD_BTT_MANTA_M4P_V2_1 4003 // BigTreeTech Manta M4P V2.1 (STM32G0B0RE)
|
||||
#define BOARD_BTT_MANTA_M5P_V1_0 4004 // BigTreeTech Manta M5P V1.0 (STM32G0B1RE)
|
||||
#define BOARD_BTT_MANTA_M8P_V1_0 4005 // BigTreeTech Manta M8P V1.0 (STM32G0B1VE)
|
||||
#define BOARD_BTT_MANTA_M8P_V1_1 4006 // BigTreeTech Manta M8P V1.1 (STM32G0B1VE)
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M3
|
||||
//
|
||||
|
||||
#define BOARD_MALYAN_M200_V2 5000 // STM32F070CB controller
|
||||
#define BOARD_MALYAN_M300 5001 // STM32F070-based delta
|
||||
#define BOARD_STM32F103RE 5002 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_MALYAN_M200 5003 // STM32C8 Libmaple-based STM32F1 controller
|
||||
#define BOARD_STM3R_MINI 5004 // STM32F103RE Libmaple-based STM32F1 controller
|
||||
#define BOARD_GTM32_PRO_VB 5005 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI 5006 // STM32F103VE controller
|
||||
#define BOARD_GTM32_MINI_A30 5007 // STM32F103VE controller
|
||||
#define BOARD_GTM32_REV_B 5008 // STM32F103VE controller
|
||||
#define BOARD_MORPHEUS 5009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller
|
||||
#define BOARD_CHITU3D 5010 // Chitu3D (STM32F103RE)
|
||||
#define BOARD_MKS_ROBIN 5011 // MKS Robin (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_MINI 5012 // MKS Robin Mini (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO 5013 // MKS Robin Nano (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V2 5014 // MKS Robin Nano V2 (STM32F103VE)
|
||||
#define BOARD_MKS_ROBIN_LITE 5015 // MKS Robin Lite/Lite2 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_LITE3 5016 // MKS Robin Lite3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_PRO 5017 // MKS Robin Pro (STM32F103ZE)
|
||||
#define BOARD_MKS_ROBIN_E3 5018 // MKS Robin E3 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3_V1_1 5019 // MKS Robin E3 V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D 5020 // MKS Robin E3D (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3D_V1_1 5021 // MKS Robin E3D V1.1 (STM32F103RC)
|
||||
#define BOARD_MKS_ROBIN_E3P 5022 // MKS Robin E3P (STM32F103VE)
|
||||
#define BOARD_BTT_SKR_MINI_V1_1 5023 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_0 5024 // BigTreeTech SKR Mini E3 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_2 5025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 5026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 5027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 5028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 5029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
#define BOARD_JGAURORA_A5S_A1 5030 // JGAurora A5S A1 (STM32F103ZE)
|
||||
#define BOARD_FYSETC_AIO_II 5031 // FYSETC AIO_II (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH 5032 // FYSETC Cheetah (STM32F103RC)
|
||||
#define BOARD_FYSETC_CHEETAH_V12 5033 // FYSETC Cheetah V1.2 (STM32F103RC)
|
||||
#define BOARD_LONGER3D_LK 5034 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE)
|
||||
#define BOARD_CCROBOT_MEEB_3DP 5035 // ccrobot-online.com MEEB_3DP (STM32F103RC)
|
||||
#define BOARD_CHITU3D_V5 5036 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V6 5037 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE)
|
||||
#define BOARD_CHITU3D_V9 5038 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE)
|
||||
#define BOARD_CREALITY_V4 5039 // Creality v4.x (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V422 5040 // Creality v4.2.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V423 5041 // Creality v4.2.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V425 5042 // Creality v4.2.5 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V427 5043 // Creality v4.2.7 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V4210 5044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30
|
||||
#define BOARD_CREALITY_V431 5045 // Creality v4.3.1 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_A 5046 // Creality v4.3.1a (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_B 5047 // Creality v4.3.1b (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_C 5048 // Creality v4.3.1c (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V431_D 5049 // Creality v4.3.1d (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V452 5050 // Creality v4.5.2 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V453 5051 // Creality v4.5.3 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_CREALITY_V521 5052 // Creality v5.2.1 (STM32F103VE) as found in the SV04
|
||||
#define BOARD_CREALITY_V24S1 5053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7
|
||||
#define BOARD_CREALITY_V24S1_301 5054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1
|
||||
#define BOARD_CREALITY_V25S1 5055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro
|
||||
#define BOARD_TRIGORILLA_PRO 5056 // Trigorilla Pro (STM32F103ZE)
|
||||
#define BOARD_FLY_MINI 5057 // FLYmaker FLY MINI (STM32F103RC)
|
||||
#define BOARD_FLSUN_HISPEED 5058 // FLSUN HiSpeedV1 (STM32F103VE)
|
||||
#define BOARD_BEAST 5059 // STM32F103RE Libmaple-based controller
|
||||
#define BOARD_MINGDA_MPX_ARM_MINI 5060 // STM32F103ZE Mingda MD-16
|
||||
#define BOARD_GTM32_PRO_VD 5061 // STM32F103VE controller
|
||||
#define BOARD_ZONESTAR_ZM3E2 5062 // Zonestar ZM3E2 (STM32F103RC)
|
||||
#define BOARD_ZONESTAR_ZM3E4 5063 // Zonestar ZM3E4 V1 (STM32F103VC)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 5064 // Zonestar ZM3E4 V2 (STM32F103VC)
|
||||
#define BOARD_ERYONE_ERY32_MINI 5065 // Eryone Ery32 mini (STM32F103VE)
|
||||
#define BOARD_PANDA_PI_V29 5066 // Panda Pi V2.9 - Standalone (STM32F103RC)
|
||||
#define BOARD_SOVOL_V131 5067 // Sovol V1.3.1 (GD32F103RE)
|
||||
|
||||
//
|
||||
// ARM Cortex-M4F
|
||||
//
|
||||
|
||||
#define BOARD_TEENSY31_32 5100 // Teensy3.1 and Teensy3.2
|
||||
#define BOARD_TEENSY35_36 5101 // Teensy3.5 and Teensy3.6
|
||||
|
||||
//
|
||||
// STM32 ARM Cortex-M4F
|
||||
//
|
||||
|
||||
#define BOARD_ARMED 5200 // Arm'ed STM32F4-based controller
|
||||
#define BOARD_RUMBA32_V1_0 5201 // RUMBA32 STM32F446VE based controller from Aus3D
|
||||
#define BOARD_RUMBA32_V1_1 5202 // RUMBA32 STM32F446VE based controller from Aus3D
|
||||
#define BOARD_RUMBA32_MKS 5203 // RUMBA32 STM32F446VE based controller from Makerbase
|
||||
#define BOARD_RUMBA32_BTT 5204 // RUMBA32 STM32F446VE based controller from BIGTREETECH
|
||||
#define BOARD_BLACK_STM32F407VE 5205 // BLACK_STM32F407VE
|
||||
#define BOARD_BLACK_STM32F407ZE 5206 // BLACK_STM32F407ZE
|
||||
#define BOARD_BTT_SKR_MINI_E3_V3_0_1 5207 // BigTreeTech SKR Mini E3 V3.0.1 (STM32F401RC)
|
||||
#define BOARD_BTT_SKR_PRO_V1_1 5208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
|
||||
#define BOARD_BTT_SKR_PRO_V1_2 5209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG)
|
||||
#define BOARD_BTT_BTT002_V1_0 5210 // BigTreeTech BTT002 v1.0 (STM32F407VG)
|
||||
#define BOARD_BTT_E3_RRF 5211 // BigTreeTech E3 RRF (STM32F407VG)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_A 5212 // BigTreeTech SKR v2.0 Rev A (STM32F407VG)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_B 5213 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG)
|
||||
#define BOARD_BTT_GTR_V1_0 5214 // BigTreeTech GTR v1.0 (STM32F407IGT)
|
||||
#define BOARD_BTT_OCTOPUS_V1_0 5215 // BigTreeTech Octopus v1.0 (STM32F446ZE)
|
||||
#define BOARD_BTT_OCTOPUS_V1_1 5216 // BigTreeTech Octopus v1.1 (STM32F446ZE)
|
||||
#define BOARD_BTT_OCTOPUS_PRO_V1_0 5217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE / STM32F429ZG)
|
||||
#define BOARD_LERDGE_K 5218 // Lerdge K (STM32F407ZG)
|
||||
#define BOARD_LERDGE_S 5219 // Lerdge S (STM32F407VE)
|
||||
#define BOARD_LERDGE_X 5220 // Lerdge X (STM32F407VE)
|
||||
#define BOARD_FYSETC_S6 5221 // FYSETC S6 (STM32F446VE)
|
||||
#define BOARD_FYSETC_S6_V2_0 5222 // FYSETC S6 v2.0 (STM32F446VE)
|
||||
#define BOARD_FYSETC_SPIDER 5223 // FYSETC Spider (STM32F446VE)
|
||||
#define BOARD_FLYF407ZG 5224 // FLYmaker FLYF407ZG (STM32F407ZG)
|
||||
#define BOARD_MKS_ROBIN2 5225 // MKS Robin2 V1.0 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 5226 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 5227 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3_1 5228 // MKS Robin Nano V3.1 (STM32F407VE)
|
||||
#define BOARD_MKS_MONSTER8_V1 5229 // MKS Monster8 V1 (STM32F407VE)
|
||||
#define BOARD_MKS_MONSTER8_V2 5230 // MKS Monster8 V2 (STM32F407VE)
|
||||
#define BOARD_ANET_ET4 5231 // ANET ET4 V1.x (STM32F407VG)
|
||||
#define BOARD_ANET_ET4P 5232 // ANET ET4P V1.x (STM32F407VG)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 5233 // FYSETC Cheetah V2.0 (STM32F401RC)
|
||||
#define BOARD_TH3D_EZBOARD_V2 5234 // TH3D EZBoard v2.0 (STM32F405RG)
|
||||
#define BOARD_OPULO_LUMEN_REV3 5235 // Opulo Lumen PnP Controller REV3 (STM32F407VE / STM32F407VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 5236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE)
|
||||
#define BOARD_MKS_EAGLE 5237 // MKS Eagle (STM32F407VE)
|
||||
#define BOARD_ARTILLERY_RUBY 5238 // Artillery Ruby (STM32F401RC)
|
||||
#define BOARD_FYSETC_SPIDER_V2_2 5239 // FYSETC Spider V2.2 (STM32F446VE)
|
||||
#define BOARD_CREALITY_V24S1_301F4 5240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4
|
||||
#define BOARD_OPULO_LUMEN_REV4 5241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG)
|
||||
#define BOARD_FYSETC_SPIDER_KING407 5242 // FYSETC Spider King407 (STM32F407ZG)
|
||||
#define BOARD_MKS_SKIPR_V1 5243 // MKS SKIPR v1.0 all-in-one board (STM32F407VE)
|
||||
#define BOARD_TRONXY_V10 5244 // TRONXY V10 (STM32F446ZE)
|
||||
|
||||
//
|
||||
// ARM Cortex-M7
|
||||
//
|
||||
|
||||
#define BOARD_REMRAM_V1 6000 // RemRam v1
|
||||
#define BOARD_TEENSY41 6001 // Teensy 4.1
|
||||
#define BOARD_T41U5XBB 6002 // T41U5XBB Teensy 4.1 breakout board
|
||||
#define BOARD_NUCLEO_F767ZI 6003 // ST NUCLEO-F767ZI Dev Board
|
||||
#define BOARD_BTT_SKR_SE_BX_V2 6004 // BigTreeTech SKR SE BX V2.0 (STM32H743II)
|
||||
#define BOARD_BTT_SKR_SE_BX_V3 6005 // BigTreeTech SKR SE BX V3.0 (STM32H743II)
|
||||
#define BOARD_BTT_SKR_V3_0 6006 // BigTreeTech SKR V3.0 (STM32H743VI / STM32H723VG)
|
||||
#define BOARD_BTT_SKR_V3_0_EZ 6007 // BigTreeTech SKR V3.0 EZ (STM32H743VI / STM32H723VG)
|
||||
#define BOARD_BTT_OCTOPUS_MAX_EZ_V1_0 6008 // BigTreeTech Octopus Max EZ V1.0 (STM32H723ZE)
|
||||
|
||||
//
|
||||
// Espressif ESP32 WiFi
|
||||
//
|
||||
|
||||
#define BOARD_ESPRESSIF_ESP32 7000 // Generic ESP32
|
||||
#define BOARD_MRR_ESPA 7001 // MRR ESPA based on ESP32 (native pins only)
|
||||
#define BOARD_MRR_ESPE 7002 // MRR ESPE based on ESP32 (with I2S stepper stream)
|
||||
#define BOARD_E4D_BOX 7003 // E4d@BOX
|
||||
#define BOARD_RESP32_CUSTOM 7004 // Rutilea ESP32 custom board
|
||||
#define BOARD_FYSETC_E4 7005 // FYSETC E4
|
||||
#define BOARD_PANDA_ZHU 7006 // Panda_ZHU
|
||||
#define BOARD_PANDA_M4 7007 // Panda_M4
|
||||
#define BOARD_MKS_TINYBEE 7008 // MKS TinyBee based on ESP32 (with I2S stepper stream)
|
||||
#define BOARD_ENWI_ESPNP 7009 // enwi ESPNP based on ESP32 (with I2S stepper stream)
|
||||
|
||||
//
|
||||
// SAMD51 ARM Cortex-M4
|
||||
//
|
||||
|
||||
#define BOARD_AGCM4_RAMPS_144 7100 // RAMPS 1.4.4
|
||||
#define BOARD_BRICOLEMON_V1_0 7101 // Bricolemon
|
||||
#define BOARD_BRICOLEMON_LITE_V1_0 7102 // Bricolemon Lite
|
||||
|
||||
//
|
||||
// SAMD21 ARM Cortex-M4
|
||||
//
|
||||
|
||||
#define BOARD_MINITRONICS20 7103 // Minitronics v2.0
|
||||
|
||||
//
|
||||
// Custom board
|
||||
//
|
||||
|
||||
#define BOARD_CUSTOM 9998 // Custom pins definition for development and/or rare boards
|
||||
|
||||
//
|
||||
// Simulations
|
||||
//
|
||||
|
||||
#define BOARD_SIMULATED 9999
|
||||
|
||||
#define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B)
|
||||
#define MB(V...) DO(MB,||,V)
|
||||
39
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/bug_on.h
Normal file
39
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/bug_on.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Copyright (c) 2021 X-Ryl669 [https://blog.cyril.by]
|
||||
*
|
||||
* 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
|
||||
|
||||
// We need SERIAL_ECHOPGM and macros.h
|
||||
#include "serial.h"
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
// Useful macro for stopping the CPU on an unexpected condition
|
||||
// This is used like SERIAL_ECHOPGM, that is: a key-value call of the local variables you want
|
||||
// to dump to the serial port before stopping the CPU.
|
||||
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
|
||||
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
|
||||
#elif ENABLED(MARLIN_DEV_MODE)
|
||||
// Don't stop the CPU here, but at least dump the bug on the serial port
|
||||
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
|
||||
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); } while(0)
|
||||
#else
|
||||
// Release mode, let's ignore the bug
|
||||
#define BUG_ON(V...) NOOP
|
||||
#endif
|
||||
120
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/debug_out.h
Normal file
120
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/debug_out.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Serial aliases for debugging.
|
||||
// Include this header after defining DEBUG_OUT
|
||||
// (or not) in a given .cpp file
|
||||
//
|
||||
|
||||
#undef DEBUG_SECTION
|
||||
#undef DEBUG_ECHO_START
|
||||
#undef DEBUG_ERROR_START
|
||||
#undef DEBUG_CHAR
|
||||
#undef DEBUG_ECHO
|
||||
#undef DEBUG_DECIMAL
|
||||
#undef DEBUG_ECHO_F
|
||||
#undef DEBUG_ECHOLN
|
||||
#undef DEBUG_ECHOPGM
|
||||
#undef DEBUG_ECHOLNPGM
|
||||
#undef DEBUG_ECHOF
|
||||
#undef DEBUG_ECHOLNF
|
||||
#undef DEBUG_ECHOPGM_P
|
||||
#undef DEBUG_ECHOLNPGM_P
|
||||
#undef DEBUG_ECHOPAIR_F
|
||||
#undef DEBUG_ECHOPAIR_F_P
|
||||
#undef DEBUG_ECHOLNPAIR_F
|
||||
#undef DEBUG_ECHOLNPAIR_F_P
|
||||
#undef DEBUG_ECHO_MSG
|
||||
#undef DEBUG_ERROR_MSG
|
||||
#undef DEBUG_EOL
|
||||
#undef DEBUG_FLUSH
|
||||
#undef DEBUG_POS
|
||||
#undef DEBUG_XYZ
|
||||
#undef DEBUG_DELAY
|
||||
#undef DEBUG_SYNCHRONIZE
|
||||
|
||||
#if DEBUG_OUT
|
||||
|
||||
#include "debug_section.h"
|
||||
#define DEBUG_SECTION(N,S,D) SectionLog N(F(S),D)
|
||||
|
||||
#define DEBUG_ECHO_START SERIAL_ECHO_START
|
||||
#define DEBUG_ERROR_START SERIAL_ERROR_START
|
||||
#define DEBUG_CHAR SERIAL_CHAR
|
||||
#define DEBUG_ECHO SERIAL_ECHO
|
||||
#define DEBUG_DECIMAL SERIAL_DECIMAL
|
||||
#define DEBUG_ECHO_F SERIAL_ECHO_F
|
||||
#define DEBUG_ECHOLN SERIAL_ECHOLN
|
||||
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
|
||||
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
|
||||
#define DEBUG_ECHOF SERIAL_ECHOF
|
||||
#define DEBUG_ECHOLNF SERIAL_ECHOLNF
|
||||
#define DEBUG_ECHOPGM SERIAL_ECHOPGM
|
||||
#define DEBUG_ECHOPGM_P SERIAL_ECHOPGM_P
|
||||
#define DEBUG_ECHOPAIR_F SERIAL_ECHOPAIR_F
|
||||
#define DEBUG_ECHOPAIR_F_P SERIAL_ECHOPAIR_F_P
|
||||
#define DEBUG_ECHOLNPGM SERIAL_ECHOLNPGM
|
||||
#define DEBUG_ECHOLNPGM_P SERIAL_ECHOLNPGM_P
|
||||
#define DEBUG_ECHOLNPAIR_F SERIAL_ECHOLNPAIR_F
|
||||
#define DEBUG_ECHOLNPAIR_F_P SERIAL_ECHOLNPAIR_F_P
|
||||
#define DEBUG_ECHO_MSG SERIAL_ECHO_MSG
|
||||
#define DEBUG_ERROR_MSG SERIAL_ERROR_MSG
|
||||
#define DEBUG_EOL SERIAL_EOL
|
||||
#define DEBUG_FLUSH SERIAL_FLUSH
|
||||
#define DEBUG_POS SERIAL_POS
|
||||
#define DEBUG_XYZ SERIAL_XYZ
|
||||
#define DEBUG_DELAY(ms) serial_delay(ms)
|
||||
#define DEBUG_SYNCHRONIZE() planner.synchronize()
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_SECTION(...) NOOP
|
||||
#define DEBUG_ECHO_START() NOOP
|
||||
#define DEBUG_ERROR_START() NOOP
|
||||
#define DEBUG_CHAR(...) NOOP
|
||||
#define DEBUG_ECHO(...) NOOP
|
||||
#define DEBUG_DECIMAL(...) NOOP
|
||||
#define DEBUG_ECHO_F(...) NOOP
|
||||
#define DEBUG_ECHOLN(...) NOOP
|
||||
#define DEBUG_ECHOPGM(...) NOOP
|
||||
#define DEBUG_ECHOLNPGM(...) NOOP
|
||||
#define DEBUG_ECHOF(...) NOOP
|
||||
#define DEBUG_ECHOLNF(...) NOOP
|
||||
#define DEBUG_ECHOPGM_P(...) NOOP
|
||||
#define DEBUG_ECHOLNPGM_P(...) NOOP
|
||||
#define DEBUG_ECHOPAIR_F(...) NOOP
|
||||
#define DEBUG_ECHOPAIR_F_P(...) NOOP
|
||||
#define DEBUG_ECHOLNPAIR_F(...) NOOP
|
||||
#define DEBUG_ECHOLNPAIR_F_P(...) NOOP
|
||||
#define DEBUG_ECHO_MSG(...) NOOP
|
||||
#define DEBUG_ERROR_MSG(...) NOOP
|
||||
#define DEBUG_EOL() NOOP
|
||||
#define DEBUG_FLUSH() NOOP
|
||||
#define DEBUG_POS(...) NOOP
|
||||
#define DEBUG_XYZ(...) NOOP
|
||||
#define DEBUG_DELAY(...) NOOP
|
||||
#define DEBUG_SYNCHRONIZE() NOOP
|
||||
|
||||
#endif
|
||||
|
||||
#undef DEBUG_OUT
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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 "serial.h"
|
||||
#include "../module/motion.h"
|
||||
|
||||
class SectionLog {
|
||||
public:
|
||||
SectionLog(FSTR_P const fmsg=nullptr, bool inbug=true) {
|
||||
the_msg = fmsg;
|
||||
if ((debug = inbug)) echo_msg(F(">>>"));
|
||||
}
|
||||
|
||||
~SectionLog() { if (debug) echo_msg(F("<<<")); }
|
||||
|
||||
private:
|
||||
FSTR_P the_msg;
|
||||
bool debug;
|
||||
|
||||
void echo_msg(FSTR_P const fpre) {
|
||||
SERIAL_ECHOF(fpre);
|
||||
if (the_msg) {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOF(the_msg);
|
||||
}
|
||||
SERIAL_CHAR(' ');
|
||||
print_pos(current_position);
|
||||
}
|
||||
};
|
||||
190
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/drivers.h
Normal file
190
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/drivers.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
//
|
||||
// Included by MarlinConfigPre.h ahead of Configuration_adv.h.
|
||||
// Don't use #if in this file for anything not defined early!
|
||||
//
|
||||
|
||||
#define _A4988 0x4988
|
||||
#define _A5984 0x5984
|
||||
#define _DRV8825 0x8825
|
||||
#define _LV8729 0x8729
|
||||
#define _TB6560 0x6560
|
||||
#define _TB6600 0x6600
|
||||
#define _TMC2100 0x2100
|
||||
#define _TMC2130 0x2130A
|
||||
#define _TMC2130_STANDALONE 0x2130B
|
||||
#define _TMC2160 0x2160A
|
||||
#define _TMC2160_STANDALONE 0x2160B
|
||||
#define _TMC2208 0x2208A
|
||||
#define _TMC2208_STANDALONE 0x2208B
|
||||
#define _TMC2209 0x2209A
|
||||
#define _TMC2209_STANDALONE 0x2209B
|
||||
#define _TMC26X 0x2600A
|
||||
#define _TMC26X_STANDALONE 0x2600B
|
||||
#define _TMC2660 0x2660A
|
||||
#define _TMC2660_STANDALONE 0x2660B
|
||||
#define _TMC5130 0x5130A
|
||||
#define _TMC5130_STANDALONE 0x5130B
|
||||
#define _TMC5160 0x5160A
|
||||
#define _TMC5160_STANDALONE 0x5160B
|
||||
|
||||
#define _DRIVER_ID(V) _CAT(_, V)
|
||||
#define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _DRIVER_ID(T))
|
||||
|
||||
#define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
|
||||
#define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
|
||||
#define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
|
||||
#define AXIS_DRIVER_TYPE_I(T) _AXIS_DRIVER_TYPE(I,T)
|
||||
#define AXIS_DRIVER_TYPE_J(T) _AXIS_DRIVER_TYPE(J,T)
|
||||
#define AXIS_DRIVER_TYPE_K(T) _AXIS_DRIVER_TYPE(K,T)
|
||||
#define AXIS_DRIVER_TYPE_U(T) _AXIS_DRIVER_TYPE(U,T)
|
||||
#define AXIS_DRIVER_TYPE_V(T) _AXIS_DRIVER_TYPE(V,T)
|
||||
#define AXIS_DRIVER_TYPE_W(T) _AXIS_DRIVER_TYPE(W,T)
|
||||
|
||||
#define AXIS_DRIVER_TYPE_X2(T) (HAS_X2_STEPPER && _AXIS_DRIVER_TYPE(X2,T))
|
||||
#define AXIS_DRIVER_TYPE_Y2(T) (HAS_DUAL_Y_STEPPERS && _AXIS_DRIVER_TYPE(Y2,T))
|
||||
#define AXIS_DRIVER_TYPE_Z2(T) (NUM_Z_STEPPERS >= 2 && _AXIS_DRIVER_TYPE(Z2,T))
|
||||
#define AXIS_DRIVER_TYPE_Z3(T) (NUM_Z_STEPPERS >= 3 && _AXIS_DRIVER_TYPE(Z3,T))
|
||||
#define AXIS_DRIVER_TYPE_Z4(T) (NUM_Z_STEPPERS >= 4 && _AXIS_DRIVER_TYPE(Z4,T))
|
||||
|
||||
#define AXIS_DRIVER_TYPE_E(N,T) (E_STEPPERS > N && _AXIS_DRIVER_TYPE(E##N,T))
|
||||
#define AXIS_DRIVER_TYPE_E0(T) AXIS_DRIVER_TYPE_E(0,T)
|
||||
#define AXIS_DRIVER_TYPE_E1(T) AXIS_DRIVER_TYPE_E(1,T)
|
||||
#define AXIS_DRIVER_TYPE_E2(T) AXIS_DRIVER_TYPE_E(2,T)
|
||||
#define AXIS_DRIVER_TYPE_E3(T) AXIS_DRIVER_TYPE_E(3,T)
|
||||
#define AXIS_DRIVER_TYPE_E4(T) AXIS_DRIVER_TYPE_E(4,T)
|
||||
#define AXIS_DRIVER_TYPE_E5(T) AXIS_DRIVER_TYPE_E(5,T)
|
||||
#define AXIS_DRIVER_TYPE_E6(T) AXIS_DRIVER_TYPE_E(6,T)
|
||||
#define AXIS_DRIVER_TYPE_E7(T) AXIS_DRIVER_TYPE_E(7,T)
|
||||
|
||||
#define AXIS_DRIVER_TYPE(A,T) AXIS_DRIVER_TYPE_##A(T)
|
||||
|
||||
#define _OR_ADTE(N,T) || AXIS_DRIVER_TYPE_E(N,T)
|
||||
#define HAS_E_DRIVER(T) (0 RREPEAT2(E_STEPPERS, _OR_ADTE, T))
|
||||
|
||||
#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Z(T) \
|
||||
|| AXIS_DRIVER_TYPE_I(T) || AXIS_DRIVER_TYPE_J(T) || AXIS_DRIVER_TYPE_K(T) \
|
||||
|| AXIS_DRIVER_TYPE_U(T) || AXIS_DRIVER_TYPE_V(T) || AXIS_DRIVER_TYPE_W(T) \
|
||||
|| AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
|
||||
|| AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
|
||||
|
||||
//
|
||||
// Trinamic Stepper Drivers
|
||||
//
|
||||
|
||||
// Test for supported TMC drivers that require advanced configuration
|
||||
// Does not match standalone configurations
|
||||
#if ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
|
||||
|| HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209) \
|
||||
|| HAS_DRIVER(TMC2660) \
|
||||
|| HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) )
|
||||
#define HAS_TRINAMIC_CONFIG 1
|
||||
#endif
|
||||
|
||||
#define HAS_TRINAMIC HAS_TRINAMIC_CONFIG
|
||||
|
||||
#if ( HAS_DRIVER(TMC2130_STANDALONE) || HAS_DRIVER(TMC2160_STANDALONE) \
|
||||
|| HAS_DRIVER(TMC2208_STANDALONE) || HAS_DRIVER(TMC2209_STANDALONE) \
|
||||
|| HAS_DRIVER(TMC26X_STANDALONE) || HAS_DRIVER(TMC2660_STANDALONE) \
|
||||
|| HAS_DRIVER(TMC5130_STANDALONE) || HAS_DRIVER(TMC5160_STANDALONE) )
|
||||
#define HAS_TRINAMIC_STANDALONE 1
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)
|
||||
#define HAS_TMCX1X0 1
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209)
|
||||
#define HAS_TMC220x 1
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC26X)
|
||||
#define HAS_TMC26X 1
|
||||
#endif
|
||||
|
||||
#define AXIS_IS_TMC(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_IS_TMC_CONFIG(A) ( AXIS_IS_TMC(A) || AXIS_DRIVER_TYPE(A,TMC26X) )
|
||||
|
||||
// Test for a driver that uses SPI - this allows checking whether a _CS_ pin
|
||||
// is considered sensitive
|
||||
#define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )
|
||||
|
||||
#define AXIS_HAS_RXTX AXIS_HAS_UART
|
||||
|
||||
#define AXIS_HAS_HW_SERIAL(A) ( AXIS_HAS_UART(A) && defined(A##_HARDWARE_SERIAL) )
|
||||
#define AXIS_HAS_SW_SERIAL(A) ( AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL) )
|
||||
|
||||
#define AXIS_HAS_STALLGUARD(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2209) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_STEALTHCHOP(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_SG_RESULT(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )
|
||||
|
||||
#define AXIS_HAS_COOLSTEP(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2209) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define _OR_EAH(N,T) || AXIS_HAS_##T(E##N)
|
||||
#define E_AXIS_HAS(T) (0 _OR_EAH(0,T) _OR_EAH(1,T) _OR_EAH(2,T) _OR_EAH(3,T) _OR_EAH(4,T) _OR_EAH(5,T) _OR_EAH(6,T) _OR_EAH(7,T))
|
||||
|
||||
#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \
|
||||
|| AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \
|
||||
|| AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \
|
||||
|| AXIS_HAS_##T(I) || AXIS_HAS_##T(J) || AXIS_HAS_##T(K) \
|
||||
|| AXIS_HAS_##T(U) || AXIS_HAS_##T(V) || AXIS_HAS_##T(W) \
|
||||
|| E_AXIS_HAS(T) )
|
||||
|
||||
#if ANY_AXIS_HAS(STEALTHCHOP)
|
||||
#define HAS_STEALTHCHOP 1
|
||||
#endif
|
||||
#if ANY_AXIS_HAS(STALLGUARD)
|
||||
#define HAS_STALLGUARD 1
|
||||
#endif
|
||||
#if ANY_AXIS_HAS(SG_RESULT)
|
||||
#define HAS_SG_RESULT 1
|
||||
#endif
|
||||
#if ANY_AXIS_HAS(COOLSTEP)
|
||||
#define HAS_COOLSTEP 1
|
||||
#endif
|
||||
#if ANY_AXIS_HAS(RXTX)
|
||||
#define HAS_TMC_UART 1
|
||||
#endif
|
||||
#if ANY_AXIS_HAS(SPI)
|
||||
#define HAS_TMC_SPI 1
|
||||
#endif
|
||||
616
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/language.h
Normal file
616
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/language.h
Normal file
@@ -0,0 +1,616 @@
|
||||
/**
|
||||
* 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"
|
||||
|
||||
#define _UxGT(a) a
|
||||
|
||||
// Fallback if no language is set. DON'T CHANGE
|
||||
#ifndef LCD_LANGUAGE
|
||||
#define LCD_LANGUAGE en
|
||||
#endif
|
||||
|
||||
// For character-based LCD controllers (DISPLAY_CHARSET_HD44780)
|
||||
#define JAPANESE 1
|
||||
#define WESTERN 2
|
||||
#define CYRILLIC 3
|
||||
|
||||
// NOTE: IF YOU CHANGE LANGUAGE FILES OR MERGE A FILE WITH CHANGES
|
||||
//
|
||||
// ==> ALWAYS TRY TO COMPILE MARLIN WITH/WITHOUT "ULTIPANEL" / "ULTRA_LCD" / "SDSUPPORT" #define IN "Configuration.h"
|
||||
// ==> ALSO TRY ALL AVAILABLE LANGUAGE OPTIONS
|
||||
// See also https://marlinfw.org/docs/development/lcd_language.html
|
||||
|
||||
// Languages
|
||||
// an Aragonese
|
||||
// bg Bulgarian
|
||||
// ca Catalan
|
||||
// cz Czech
|
||||
// da Danish
|
||||
// de German
|
||||
// el Greek (Greece)
|
||||
// el_CY Greek (Cyprus)
|
||||
// en English
|
||||
// es Spanish
|
||||
// eu Basque-Euskera
|
||||
// fi Finnish
|
||||
// fr French
|
||||
// gl Galician
|
||||
// hr Croatian
|
||||
// hu Hungarian
|
||||
// it Italian
|
||||
// jp_kana Japanese
|
||||
// ko_KR Korean (South Korea)
|
||||
// nl Dutch
|
||||
// pl Polish
|
||||
// pt Portuguese
|
||||
// pt_br Portuguese (Brazilian)
|
||||
// ro Romanian
|
||||
// ru Russian
|
||||
// sk Slovak
|
||||
// sv Swedish
|
||||
// tr Turkish
|
||||
// uk Ukrainian
|
||||
// vi Vietnamese
|
||||
// zh_CN Chinese (Simplified)
|
||||
// zh_TW Chinese (Traditional)
|
||||
|
||||
#ifdef DEFAULT_SOURCE_CODE_URL
|
||||
#undef SOURCE_CODE_URL
|
||||
#define SOURCE_CODE_URL DEFAULT_SOURCE_CODE_URL
|
||||
#endif
|
||||
|
||||
#ifdef CUSTOM_MACHINE_NAME
|
||||
#undef MACHINE_NAME
|
||||
#define MACHINE_NAME CUSTOM_MACHINE_NAME
|
||||
#elif defined(DEFAULT_MACHINE_NAME)
|
||||
#undef MACHINE_NAME
|
||||
#define MACHINE_NAME DEFAULT_MACHINE_NAME
|
||||
#endif
|
||||
|
||||
#ifndef MACHINE_UUID
|
||||
#define MACHINE_UUID DEFAULT_MACHINE_UUID
|
||||
#endif
|
||||
|
||||
#define MARLIN_WEBSITE_URL "marlinfw.org"
|
||||
|
||||
//#if !defined(STRING_SPLASH_LINE3) && defined(WEBSITE_URL)
|
||||
// #define STRING_SPLASH_LINE3 WEBSITE_URL
|
||||
//#endif
|
||||
|
||||
//
|
||||
// Common Serial Console Messages
|
||||
// Don't change these strings because serial hosts look for them.
|
||||
//
|
||||
|
||||
#define STR_ENQUEUEING "enqueueing \""
|
||||
#define STR_POWERUP "PowerUp"
|
||||
#define STR_POWEROFF "PowerOff"
|
||||
#define STR_EXTERNAL_RESET " External Reset"
|
||||
#define STR_BROWNOUT_RESET " Brown out Reset"
|
||||
#define STR_WATCHDOG_RESET " Watchdog Reset"
|
||||
#define STR_SOFTWARE_RESET " Software Reset"
|
||||
#define STR_FREE_MEMORY " Free Memory: "
|
||||
#define STR_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
|
||||
#define STR_OK "ok"
|
||||
#define STR_WAIT "wait"
|
||||
#define STR_STATS "Stats: "
|
||||
#define STR_FILE_SAVED "Done saving file."
|
||||
#define STR_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: "
|
||||
#define STR_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: "
|
||||
#define STR_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: "
|
||||
#define STR_FILE_PRINTED "Done printing file"
|
||||
#define STR_NO_MEDIA "No media"
|
||||
#define STR_BEGIN_FILE_LIST "Begin file list"
|
||||
#define STR_END_FILE_LIST "End file list"
|
||||
#define STR_INVALID_EXTRUDER "Invalid extruder"
|
||||
#define STR_INVALID_E_STEPPER "Invalid E stepper"
|
||||
#define STR_E_STEPPER_NOT_SPECIFIED "E stepper not specified"
|
||||
#define STR_INVALID_SOLENOID "Invalid solenoid"
|
||||
#define STR_COUNT_X " Count X:"
|
||||
#define STR_COUNT_A " Count A:"
|
||||
#define STR_WATCHDOG_FIRED "Watchdog timeout. Reset required."
|
||||
#define STR_ERR_KILLED "Printer halted. kill() called!"
|
||||
#define STR_FLOWMETER_FAULT "Coolant flow fault. Flowmeter safety is active. Attention required."
|
||||
#define STR_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
|
||||
#define STR_ERR_SERIAL_MISMATCH "Serial status mismatch"
|
||||
#define STR_BUSY_PROCESSING "busy: processing"
|
||||
#define STR_BUSY_PAUSED_FOR_USER "busy: paused for user"
|
||||
#define STR_BUSY_PAUSED_FOR_INPUT "busy: paused for input"
|
||||
#define STR_Z_MOVE_COMP "Z_move_comp"
|
||||
#define STR_RESEND "Resend: "
|
||||
#define STR_UNKNOWN_COMMAND "Unknown command: \""
|
||||
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
|
||||
#define STR_ERR_FANSPEED "Fan speed E"
|
||||
|
||||
#define STR_PROBE_OFFSET "Probe Offset"
|
||||
#define STR_SKEW_MIN "min_skew_factor: "
|
||||
#define STR_SKEW_MAX "max_skew_factor: "
|
||||
#define STR_ERR_MATERIAL_INDEX "M145 S<index> out of range (0-1)"
|
||||
#define STR_ERR_M421_PARAMETERS "M421 incorrect parameter usage"
|
||||
#define STR_ERR_BAD_PLANE_MODE "G5 requires XY plane mode"
|
||||
#define STR_ERR_MESH_XY "Mesh point out of range"
|
||||
#define STR_ERR_ARC_ARGS "G2/G3 bad parameters"
|
||||
#define STR_ERR_PROTECTED_PIN "Protected Pin"
|
||||
#define STR_ERR_M420_FAILED "Failed to enable Bed Leveling"
|
||||
#define STR_ERR_M428_TOO_FAR "Too far from MIN/MAX"
|
||||
#define STR_ERR_M303_DISABLED "PIDTEMP disabled"
|
||||
#define STR_M119_REPORT "Reporting endstop status"
|
||||
#define STR_ON "ON"
|
||||
#define STR_OFF "OFF"
|
||||
#define STR_ENDSTOP_HIT "TRIGGERED"
|
||||
#define STR_ENDSTOP_OPEN "open"
|
||||
#define STR_DUPLICATION_MODE "Duplication mode: "
|
||||
#define STR_SOFT_MIN " Min: "
|
||||
#define STR_SOFT_MAX " Max: "
|
||||
|
||||
#define STR_SAVED_POS "Position saved"
|
||||
#define STR_RESTORING_POS "Restoring position"
|
||||
#define STR_INVALID_POS_SLOT "Invalid slot. Total: "
|
||||
#define STR_DONE "Done."
|
||||
|
||||
#define STR_SD_CANT_OPEN_SUBDIR "Cannot open subdir "
|
||||
#define STR_SD_INIT_FAIL "No SD card"
|
||||
#define STR_SD_VOL_INIT_FAIL "volume.init failed"
|
||||
#define STR_SD_OPENROOT_FAIL "openRoot failed"
|
||||
#define STR_SD_CARD_OK "SD card ok"
|
||||
#define STR_SD_CARD_RELEASED "SD card released"
|
||||
#define STR_SD_WORKDIR_FAIL "workDir open failed"
|
||||
#define STR_SD_OPEN_FILE_FAIL "open failed, File: "
|
||||
#define STR_SD_FILE_OPENED "File opened: "
|
||||
#define STR_SD_SIZE " Size: "
|
||||
#define STR_SD_FILE_SELECTED "File selected"
|
||||
#define STR_SD_WRITE_TO_FILE "Writing to file: "
|
||||
#define STR_SD_PRINTING_BYTE "SD printing byte "
|
||||
#define STR_SD_NOT_PRINTING "Not SD printing"
|
||||
#define STR_SD_ERR_WRITE_TO_FILE "error writing to file"
|
||||
#define STR_SD_ERR_READ "SD read error"
|
||||
#define STR_SD_CANT_ENTER_SUBDIR "Cannot enter subdir: "
|
||||
|
||||
#define STR_ENDSTOPS_HIT "endstops hit: "
|
||||
#define STR_ERR_COLD_EXTRUDE_STOP " cold extrusion prevented"
|
||||
#define STR_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented"
|
||||
#define STR_ERR_HOTEND_TOO_COLD "Hotend too cold"
|
||||
#define STR_ERR_EEPROM_WRITE "Error writing to EEPROM!"
|
||||
#define STR_ERR_EEPROM_CORRUPT "EEPROM Corrupt"
|
||||
|
||||
#define STR_FILAMENT_CHANGE_HEAT_LCD "Press button to heat nozzle"
|
||||
#define STR_FILAMENT_CHANGE_INSERT_LCD "Insert filament and press button"
|
||||
#define STR_FILAMENT_CHANGE_WAIT_LCD "Press button to resume"
|
||||
#define STR_FILAMENT_CHANGE_HEAT_M108 "Send M108 to heat nozzle"
|
||||
#define STR_FILAMENT_CHANGE_INSERT_M108 "Insert filament and send M108"
|
||||
#define STR_FILAMENT_CHANGE_WAIT_M108 "Send M108 to resume"
|
||||
|
||||
#define STR_STOP_PRE "!! STOP called because of "
|
||||
#define STR_STOP_POST " error - restart with M999"
|
||||
#define STR_STOP_BLTOUCH "BLTouch"
|
||||
#define STR_STOP_UNHOMED "unhomed"
|
||||
#define STR_KILL_PRE "!! KILL caused by "
|
||||
#define STR_KILL_INACTIVE_TIME "too much inactive time - current command: "
|
||||
#define STR_KILL_BUTTON "KILL button/pin"
|
||||
|
||||
// temperature.cpp strings
|
||||
#define STR_PID_AUTOTUNE "PID Autotune"
|
||||
#define STR_PID_AUTOTUNE_START " start"
|
||||
#define STR_PID_BAD_HEATER_ID " failed! Bad heater id"
|
||||
#define STR_PID_TEMP_TOO_HIGH " failed! Temperature too high"
|
||||
#define STR_PID_TIMEOUT " failed! timeout"
|
||||
#define STR_BIAS " bias: "
|
||||
#define STR_D_COLON " d: "
|
||||
#define STR_T_MIN " min: "
|
||||
#define STR_T_MAX " max: "
|
||||
#define STR_KU " Ku: "
|
||||
#define STR_TU " Tu: "
|
||||
#define STR_CLASSIC_PID " Classic PID "
|
||||
#define STR_KP " Kp: "
|
||||
#define STR_KI " Ki: "
|
||||
#define STR_KD " Kd: "
|
||||
#define STR_PID_AUTOTUNE_FINISHED " finished! Put the last Kp, Ki and Kd constants from below into Configuration.h"
|
||||
#define STR_PID_DEBUG " PID_DEBUG "
|
||||
#define STR_PID_DEBUG_INPUT ": Input "
|
||||
#define STR_PID_DEBUG_OUTPUT " Output "
|
||||
#define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !"
|
||||
#define STR_MPC_AUTOTUNE "MPC Autotune"
|
||||
#define STR_MPC_AUTOTUNE_START " start for " STR_E
|
||||
#define STR_MPC_AUTOTUNE_INTERRUPTED " interrupted!"
|
||||
#define STR_MPC_AUTOTUNE_FINISHED " finished! Put the constants below into Configuration.h"
|
||||
#define STR_MPC_COOLING_TO_AMBIENT "Cooling to ambient"
|
||||
#define STR_MPC_HEATING_PAST_200 "Heating to over 200C"
|
||||
#define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at "
|
||||
#define STR_MPC_TEMPERATURE_ERROR "Temperature error"
|
||||
|
||||
#define STR_HEATER_BED "bed"
|
||||
#define STR_HEATER_CHAMBER "chamber"
|
||||
#define STR_COOLER "cooler"
|
||||
#define STR_MOTHERBOARD "motherboard"
|
||||
#define STR_PROBE "probe"
|
||||
#define STR_REDUNDANT "redundant "
|
||||
#define STR_LASER_TEMP "laser temperature"
|
||||
|
||||
#define STR_STOPPED_HEATER ", system stopped! Heater_ID: "
|
||||
#define STR_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !"
|
||||
#define STR_T_HEATING_FAILED "Heating failed"
|
||||
#define STR_T_THERMAL_RUNAWAY "Thermal Runaway"
|
||||
#define STR_T_MALFUNCTION "Thermal Malfunction"
|
||||
#define STR_T_MAXTEMP "MAXTEMP triggered"
|
||||
#define STR_T_MINTEMP "MINTEMP triggered"
|
||||
#define STR_ERR_PROBING_FAILED "Probing Failed"
|
||||
#define STR_ZPROBE_OUT_SER "Z Probe Past Bed"
|
||||
|
||||
// Debug
|
||||
#define STR_DEBUG_PREFIX "DEBUG:"
|
||||
#define STR_DEBUG_OFF "off"
|
||||
#define STR_DEBUG_ECHO "ECHO"
|
||||
#define STR_DEBUG_INFO "INFO"
|
||||
#define STR_DEBUG_ERRORS "ERRORS"
|
||||
#define STR_DEBUG_DRYRUN "DRYRUN"
|
||||
#define STR_DEBUG_COMMUNICATION "COMMUNICATION"
|
||||
#define STR_DEBUG_DETAIL "DETAIL"
|
||||
|
||||
#define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)"
|
||||
#define STR_WRONG_PASSWORD "Incorrect Password"
|
||||
#define STR_PASSWORD_TOO_LONG "Password too long"
|
||||
#define STR_PASSWORD_REMOVED "Password removed"
|
||||
#define STR_REMINDER_SAVE_SETTINGS "Remember to save!"
|
||||
#define STR_PASSWORD_SET "Password is "
|
||||
|
||||
// Settings Report Strings
|
||||
#define STR_Z_AUTO_ALIGN "Z Auto-Align"
|
||||
#define STR_BACKLASH_COMPENSATION "Backlash compensation"
|
||||
#define STR_S_SEG_PER_SEC "S<seg-per-sec>"
|
||||
#define STR_DELTA_SETTINGS "Delta (L<diagonal-rod> R<radius> H<height> S<seg-per-sec> XYZ<tower-angle-trim> ABC<rod-trim>)"
|
||||
#define STR_SCARA_SETTINGS "SCARA"
|
||||
#define STR_POLARGRAPH_SETTINGS "Polargraph"
|
||||
#define STR_SCARA_P_T_Z "P<theta-psi-offset> T<theta-offset> Z<home-offset>"
|
||||
#define STR_ENDSTOP_ADJUSTMENT "Endstop adjustment"
|
||||
#define STR_SKEW_FACTOR "Skew Factor"
|
||||
#define STR_FILAMENT_SETTINGS "Filament settings"
|
||||
#define STR_MAX_ACCELERATION "Max Acceleration (units/s2)"
|
||||
#define STR_MAX_FEEDRATES "Max feedrates (units/s)"
|
||||
#define STR_ACCELERATION_P_R_T "Acceleration (units/s2) (P<print-accel> R<retract-accel> T<travel-accel>)"
|
||||
#define STR_TOOL_CHANGING "Tool-changing"
|
||||
#define STR_HOTEND_OFFSETS "Hotend offsets"
|
||||
#define STR_SERVO_ANGLES "Servo Angles"
|
||||
#define STR_HOTEND_PID "Hotend PID"
|
||||
#define STR_BED_PID "Bed PID"
|
||||
#define STR_CHAMBER_PID "Chamber PID"
|
||||
#define STR_STEPS_PER_UNIT "Steps per unit"
|
||||
#define STR_LINEAR_ADVANCE "Linear Advance"
|
||||
#define STR_CONTROLLER_FAN "Controller Fan"
|
||||
#define STR_STEPPER_MOTOR_CURRENTS "Stepper motor currents"
|
||||
#define STR_RETRACT_S_F_Z "Retract (S<length> F<feedrate> Z<lift>)"
|
||||
#define STR_RECOVER_S_F "Recover (S<length> F<feedrate>)"
|
||||
#define STR_AUTO_RETRACT_S "Auto-Retract (S<enable>)"
|
||||
#define STR_FILAMENT_LOAD_UNLOAD "Filament load/unload"
|
||||
#define STR_POWER_LOSS_RECOVERY "Power-loss recovery"
|
||||
#define STR_FILAMENT_RUNOUT_SENSOR "Filament runout sensor"
|
||||
#define STR_DRIVER_STEPPING_MODE "Driver stepping mode"
|
||||
#define STR_STEPPER_DRIVER_CURRENT "Stepper driver current"
|
||||
#define STR_HYBRID_THRESHOLD "Hybrid Threshold"
|
||||
#define STR_STALLGUARD_THRESHOLD "StallGuard threshold"
|
||||
#define STR_HOME_OFFSET "Home offset"
|
||||
#define STR_SOFT_ENDSTOPS "Soft endstops"
|
||||
#define STR_MATERIAL_HEATUP "Material heatup parameters"
|
||||
#define STR_LCD_CONTRAST "LCD Contrast"
|
||||
#define STR_LCD_BRIGHTNESS "LCD Brightness"
|
||||
#define STR_DISPLAY_SLEEP "Display Sleep"
|
||||
#define STR_UI_LANGUAGE "UI Language"
|
||||
#define STR_Z_PROBE_OFFSET "Z-Probe Offset"
|
||||
#define STR_TEMPERATURE_UNITS "Temperature Units"
|
||||
#define STR_USER_THERMISTORS "User thermistors"
|
||||
#define STR_DELAYED_POWEROFF "Delayed poweroff"
|
||||
|
||||
//
|
||||
// Endstop Names used by Endstops::report_states
|
||||
//
|
||||
#if HAS_X_AXIS
|
||||
#define STR_X_MIN "x_min"
|
||||
#define STR_X_MAX "x_max"
|
||||
#define STR_X2_MIN "x2_min"
|
||||
#define STR_X2_MAX "x2_max"
|
||||
#endif
|
||||
|
||||
#if HAS_Y_AXIS
|
||||
#define STR_Y_MIN "y_min"
|
||||
#define STR_Y_MAX "y_max"
|
||||
#define STR_Y2_MIN "y2_min"
|
||||
#define STR_Y2_MAX "y2_max"
|
||||
#endif
|
||||
|
||||
#if HAS_Z_AXIS
|
||||
#define STR_Z_MIN "z_min"
|
||||
#define STR_Z_MAX "z_max"
|
||||
#define STR_Z2_MIN "z2_min"
|
||||
#define STR_Z2_MAX "z2_max"
|
||||
#define STR_Z3_MIN "z3_min"
|
||||
#define STR_Z3_MAX "z3_max"
|
||||
#define STR_Z4_MIN "z4_min"
|
||||
#define STR_Z4_MAX "z4_max"
|
||||
#endif
|
||||
|
||||
#define STR_Z_PROBE "z_probe"
|
||||
#define STR_PROBE_EN "probe_en"
|
||||
#define STR_FILAMENT "filament"
|
||||
|
||||
// General axis names
|
||||
#define STR_X "X"
|
||||
#define STR_Y "Y"
|
||||
#define STR_Z "Z"
|
||||
#define STR_E "E"
|
||||
#if IS_KINEMATIC
|
||||
#define STR_A "A"
|
||||
#define STR_B "B"
|
||||
#define STR_C "C"
|
||||
#else
|
||||
#define STR_A "X"
|
||||
#define STR_B "Y"
|
||||
#define STR_C "Z"
|
||||
#endif
|
||||
#define STR_X2 "X2"
|
||||
#define STR_Y2 "Y2"
|
||||
#define STR_Z2 "Z2"
|
||||
#define STR_Z3 "Z3"
|
||||
#define STR_Z4 "Z4"
|
||||
|
||||
// Extra Axis and Endstop Names
|
||||
#if HAS_I_AXIS
|
||||
#if AXIS4_NAME == 'A'
|
||||
#define STR_I "A"
|
||||
#define STR_I_MIN "a_min"
|
||||
#define STR_I_MAX "a_max"
|
||||
#elif AXIS4_NAME == 'B'
|
||||
#define STR_I "B"
|
||||
#define STR_I_MIN "b_min"
|
||||
#define STR_I_MAX "b_max"
|
||||
#elif AXIS4_NAME == 'C'
|
||||
#define STR_I "C"
|
||||
#define STR_I_MIN "c_min"
|
||||
#define STR_I_MAX "c_max"
|
||||
#elif AXIS4_NAME == 'U'
|
||||
#define STR_I "U"
|
||||
#define STR_I_MIN "u_min"
|
||||
#define STR_I_MAX "u_max"
|
||||
#elif AXIS4_NAME == 'V'
|
||||
#define STR_I "V"
|
||||
#define STR_I_MIN "v_min"
|
||||
#define STR_I_MAX "v_max"
|
||||
#elif AXIS4_NAME == 'W'
|
||||
#define STR_I "W"
|
||||
#define STR_I_MIN "w_min"
|
||||
#define STR_I_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_I ""
|
||||
#endif
|
||||
|
||||
#if HAS_J_AXIS
|
||||
#if AXIS5_NAME == 'B'
|
||||
#define STR_J "B"
|
||||
#define STR_J_MIN "b_min"
|
||||
#define STR_J_MAX "b_max"
|
||||
#elif AXIS5_NAME == 'C'
|
||||
#define STR_J "C"
|
||||
#define STR_J_MIN "c_min"
|
||||
#define STR_J_MAX "c_max"
|
||||
#elif AXIS5_NAME == 'U'
|
||||
#define STR_J "U"
|
||||
#define STR_J_MIN "u_min"
|
||||
#define STR_J_MAX "u_max"
|
||||
#elif AXIS5_NAME == 'V'
|
||||
#define STR_J "V"
|
||||
#define STR_J_MIN "v_min"
|
||||
#define STR_J_MAX "v_max"
|
||||
#elif AXIS5_NAME == 'W'
|
||||
#define STR_J "W"
|
||||
#define STR_J_MIN "w_min"
|
||||
#define STR_J_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS5_NAME can only be one of 'B', 'C', 'U', 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_J ""
|
||||
#endif
|
||||
|
||||
#if HAS_K_AXIS
|
||||
#if AXIS6_NAME == 'C'
|
||||
#define STR_K "C"
|
||||
#define STR_K_MIN "c_min"
|
||||
#define STR_K_MAX "c_max"
|
||||
#elif AXIS6_NAME == 'U'
|
||||
#define STR_K "U"
|
||||
#define STR_K_MIN "u_min"
|
||||
#define STR_K_MAX "u_max"
|
||||
#elif AXIS6_NAME == 'V'
|
||||
#define STR_K "V"
|
||||
#define STR_K_MIN "v_min"
|
||||
#define STR_K_MAX "v_max"
|
||||
#elif AXIS6_NAME == 'W'
|
||||
#define STR_K "W"
|
||||
#define STR_K_MIN "w_min"
|
||||
#define STR_K_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS6_NAME can only be one of 'C', 'U', 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_K ""
|
||||
#endif
|
||||
|
||||
#if HAS_U_AXIS
|
||||
#if AXIS7_NAME == 'U'
|
||||
#define STR_U "U"
|
||||
#define STR_U_MIN "u_min"
|
||||
#define STR_U_MAX "u_max"
|
||||
#elif AXIS7_NAME == 'V'
|
||||
#define STR_U "V"
|
||||
#define STR_U_MIN "v_min"
|
||||
#define STR_U_MAX "v_max"
|
||||
#elif AXIS7_NAME == 'W'
|
||||
#define STR_U "W"
|
||||
#define STR_U_MIN "w_min"
|
||||
#define STR_U_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS7_NAME can only be one of 'U', 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_U ""
|
||||
#endif
|
||||
|
||||
#if HAS_V_AXIS
|
||||
#if AXIS8_NAME == 'V'
|
||||
#define STR_V "V"
|
||||
#define STR_V_MIN "v_min"
|
||||
#define STR_V_MAX "v_max"
|
||||
#elif AXIS8_NAME == 'W'
|
||||
#define STR_V "W"
|
||||
#define STR_V_MIN "w_min"
|
||||
#define STR_V_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS8_NAME can only be one of 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_V ""
|
||||
#endif
|
||||
|
||||
#if HAS_W_AXIS
|
||||
#if AXIS9_NAME == 'W'
|
||||
#define STR_W "W"
|
||||
#define STR_W_MIN "w_min"
|
||||
#define STR_W_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS9_NAME can only be 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_W ""
|
||||
#endif
|
||||
|
||||
#if ANY(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
|
||||
|
||||
// Custom characters defined in the first 8 characters of the LCD
|
||||
#define LCD_STR_BEDTEMP "\x00" // Print only as a char. This will have 'unexpected' results when used in a string!
|
||||
#define LCD_STR_DEGREE "\x01"
|
||||
#define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation
|
||||
#define LCD_STR_UPLEVEL "\x03"
|
||||
#define LCD_STR_REFRESH "\x04"
|
||||
#define LCD_STR_FOLDER "\x05"
|
||||
#define LCD_STR_FEEDRATE "\x06"
|
||||
#define LCD_STR_CLOCK "\x07"
|
||||
#define LCD_STR_ARROW_RIGHT ">" /* from the default character set */
|
||||
|
||||
#else
|
||||
//
|
||||
// Custom characters from Marlin_symbols.fon which was merged into ISO10646-0-3.bdf
|
||||
// \x00 intentionally skipped to avoid problems in strings
|
||||
//
|
||||
#define LCD_STR_REFRESH "\x01"
|
||||
#define LCD_STR_FOLDER "\x02"
|
||||
#define LCD_STR_ARROW_RIGHT "\x03"
|
||||
#define LCD_STR_UPLEVEL "\x04"
|
||||
#define LCD_STR_CLOCK "\x05"
|
||||
#define LCD_STR_FEEDRATE "\x06"
|
||||
#define LCD_STR_BEDTEMP "\x07"
|
||||
#define LCD_STR_THERMOMETER "\x08"
|
||||
#define LCD_STR_DEGREE "\x09"
|
||||
|
||||
#define LCD_STR_SPECIAL_MAX '\x09'
|
||||
// Maximum here is 0x1F because 0x20 is ' ' (space) and the normal charsets begin.
|
||||
// Better stay below 0x10 because DISPLAY_CHARSET_HD44780_WESTERN begins here.
|
||||
|
||||
// Symbol characters
|
||||
#define LCD_STR_FILAM_DIA "\xF8"
|
||||
#define LCD_STR_FILAM_MUL "\xA4"
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Tool indexes for LCD display only
|
||||
*
|
||||
* By convention the LCD shows "E1" for the first extruder.
|
||||
* However, internal to Marlin E0/T0 is the first tool, and
|
||||
* most board silkscreens say "E0." Zero-based labels will
|
||||
* make these indexes consistent but this defies expectation.
|
||||
*/
|
||||
#if ENABLED(NUMBER_TOOLS_FROM_0)
|
||||
#define LCD_FIRST_TOOL 0
|
||||
#define STR_N0 "0"
|
||||
#define STR_N1 "1"
|
||||
#define STR_N2 "2"
|
||||
#define STR_N3 "3"
|
||||
#define STR_N4 "4"
|
||||
#define STR_N5 "5"
|
||||
#define STR_N6 "6"
|
||||
#define STR_N7 "7"
|
||||
#else
|
||||
#define LCD_FIRST_TOOL 1
|
||||
#define STR_N0 "1"
|
||||
#define STR_N1 "2"
|
||||
#define STR_N2 "3"
|
||||
#define STR_N3 "4"
|
||||
#define STR_N4 "5"
|
||||
#define STR_N5 "6"
|
||||
#define STR_N6 "7"
|
||||
#define STR_N7 "8"
|
||||
#endif
|
||||
|
||||
#define STR_E0 STR_E STR_N0
|
||||
#define STR_E1 STR_E STR_N1
|
||||
#define STR_E2 STR_E STR_N2
|
||||
#define STR_E3 STR_E STR_N3
|
||||
#define STR_E4 STR_E STR_N4
|
||||
#define STR_E5 STR_E STR_N5
|
||||
#define STR_E6 STR_E STR_N6
|
||||
#define STR_E7 STR_E STR_N7
|
||||
|
||||
// Include localized LCD Menu Messages
|
||||
|
||||
#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(fontdata/langdata_##M.h)
|
||||
#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M)
|
||||
|
||||
#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h)
|
||||
#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M)
|
||||
|
||||
// Use superscripts, if possible. Evaluated at point of use.
|
||||
#define SUPERSCRIPT_TWO TERN(NOT_EXTENDED_ISO10646_1_5X7, "^2", "²")
|
||||
#define SUPERSCRIPT_THREE TERN(NOT_EXTENDED_ISO10646_1_5X7, "^3", "³")
|
||||
|
||||
#include "multi_language.h" // Allow multiple languages
|
||||
|
||||
#include "../lcd/language/language_en.h"
|
||||
#include LANGUAGE_INCL(LCD_LANGUAGE)
|
||||
#include LANGUAGE_INCL(LCD_LANGUAGE_2)
|
||||
#include LANGUAGE_INCL(LCD_LANGUAGE_3)
|
||||
#include LANGUAGE_INCL(LCD_LANGUAGE_4)
|
||||
#include LANGUAGE_INCL(LCD_LANGUAGE_5)
|
||||
|
||||
#if NONE(DISPLAY_CHARSET_ISO10646_1, \
|
||||
DISPLAY_CHARSET_ISO10646_5, \
|
||||
DISPLAY_CHARSET_ISO10646_KANA, \
|
||||
DISPLAY_CHARSET_ISO10646_GREEK, \
|
||||
DISPLAY_CHARSET_ISO10646_CN, \
|
||||
DISPLAY_CHARSET_ISO10646_TR, \
|
||||
DISPLAY_CHARSET_ISO10646_PL, \
|
||||
DISPLAY_CHARSET_ISO10646_CZ, \
|
||||
DISPLAY_CHARSET_ISO10646_SK)
|
||||
#define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays.
|
||||
#endif
|
||||
805
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/macros.h
Normal file
805
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/macros.h
Normal file
@@ -0,0 +1,805 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#ifndef __has_include
|
||||
#define __has_include(...) 1
|
||||
#endif
|
||||
|
||||
#define ABCE 4
|
||||
#define XYZE 4
|
||||
#define ABC 3
|
||||
#define XYZ 3
|
||||
#define XY 2
|
||||
|
||||
#define _AXIS(A) (A##_AXIS)
|
||||
|
||||
#define _XSTOP_ 0x01
|
||||
#define _YSTOP_ 0x02
|
||||
#define _ZSTOP_ 0x03
|
||||
#define _ISTOP_ 0x04
|
||||
#define _JSTOP_ 0x05
|
||||
#define _KSTOP_ 0x06
|
||||
#define _USTOP_ 0x07
|
||||
#define _VSTOP_ 0x08
|
||||
#define _WSTOP_ 0x09
|
||||
#define _XMIN_ 0x11
|
||||
#define _YMIN_ 0x12
|
||||
#define _ZMIN_ 0x13
|
||||
#define _IMIN_ 0x14
|
||||
#define _JMIN_ 0x15
|
||||
#define _KMIN_ 0x16
|
||||
#define _UMIN_ 0x17
|
||||
#define _VMIN_ 0x18
|
||||
#define _WMIN_ 0x19
|
||||
#define _XMAX_ 0x21
|
||||
#define _YMAX_ 0x22
|
||||
#define _ZMAX_ 0x23
|
||||
#define _IMAX_ 0x24
|
||||
#define _JMAX_ 0x25
|
||||
#define _KMAX_ 0x26
|
||||
#define _UMAX_ 0x27
|
||||
#define _VMAX_ 0x28
|
||||
#define _WMAX_ 0x29
|
||||
#define _XDIAG_ 0x31
|
||||
#define _YDIAG_ 0x32
|
||||
#define _ZDIAG_ 0x33
|
||||
#define _IDIAG_ 0x34
|
||||
#define _JDIAG_ 0x35
|
||||
#define _KDIAG_ 0x36
|
||||
#define _UDIAG_ 0x37
|
||||
#define _VDIAG_ 0x38
|
||||
#define _WDIAG_ 0x39
|
||||
#define _E0DIAG_ 0xE0
|
||||
#define _E1DIAG_ 0xE1
|
||||
#define _E2DIAG_ 0xE2
|
||||
#define _E3DIAG_ 0xE3
|
||||
#define _E4DIAG_ 0xE4
|
||||
#define _E5DIAG_ 0xE5
|
||||
#define _E6DIAG_ 0xE6
|
||||
#define _E7DIAG_ 0xE7
|
||||
|
||||
#define _FORCE_INLINE_ __attribute__((__always_inline__)) __inline__
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#define NO_INLINE __attribute__((noinline))
|
||||
#define _UNUSED __attribute__((unused))
|
||||
#define __O0 __attribute__((optimize("O0"))) // No optimization and less debug info
|
||||
#define __Og __attribute__((optimize("Og"))) // Optimize the debugging experience
|
||||
#define __Os __attribute__((optimize("Os"))) // Optimize for size
|
||||
#define __O1 __attribute__((optimize("O1"))) // Try to reduce size and cycles; nothing that takes a lot of time to compile
|
||||
#define __O2 __attribute__((optimize("O2"))) // Optimize even more
|
||||
#define __O3 __attribute__((optimize("O3"))) // Optimize yet more
|
||||
|
||||
#define IS_CONSTEXPR(...) __builtin_constant_p(__VA_ARGS__) // Only valid solution with C++14. Should use std::is_constant_evaluated() in C++20 instead
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
// Clock speed factors
|
||||
#if !defined(CYCLES_PER_MICROSECOND) && !defined(__STM32F1__)
|
||||
#define CYCLES_PER_MICROSECOND (F_CPU / 1000000UL) // 16 or 20 on AVR
|
||||
#endif
|
||||
|
||||
// Nanoseconds per cycle
|
||||
#define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU)
|
||||
|
||||
// Macros to make a string from a macro
|
||||
#define STRINGIFY_(M) #M
|
||||
#define STRINGIFY(M) STRINGIFY_(M)
|
||||
|
||||
#define A(CODE) " " CODE "\n\t"
|
||||
#define L(CODE) CODE ":\n\t"
|
||||
|
||||
// Macros for bit masks
|
||||
#undef _BV
|
||||
#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 |= _BV(B))
|
||||
#endif
|
||||
#ifndef CBI
|
||||
#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))
|
||||
#define CBI32(n,b) (n &= ~_BV32(b))
|
||||
#define TBI32(N,B) (N ^= _BV32(B))
|
||||
|
||||
#define cu(x) ({__typeof__(x) _x = (x); (_x)*(_x)*(_x);})
|
||||
#define RADIANS(d) ((d)*float(M_PI)/180.0f)
|
||||
#define DEGREES(r) ((r)*180.0f/float(M_PI))
|
||||
#define HYPOT2(x,y) (sq(x)+sq(y))
|
||||
#define NORMSQ(x,y,z) (sq(x)+sq(y)+sq(z))
|
||||
|
||||
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
|
||||
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
|
||||
|
||||
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})
|
||||
#define IS_POWER_OF_2(x) ((x) && !((x) & ((x) - 1)))
|
||||
|
||||
// Macros to constrain values
|
||||
#ifdef __cplusplus
|
||||
|
||||
// C++11 solution that is standards compliant.
|
||||
template <class V, class N> static constexpr void NOLESS(V& v, const N n) {
|
||||
if (n > v) v = n;
|
||||
}
|
||||
template <class V, class N> static constexpr void NOMORE(V& v, const N n) {
|
||||
if (n < v) v = n;
|
||||
}
|
||||
template <class V, class N1, class N2> static constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
|
||||
if (n1 > v) v = n1;
|
||||
else if (n2 < v) v = n2;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define NOLESS(v, n) \
|
||||
do{ \
|
||||
__typeof__(v) _n = (n); \
|
||||
if (_n > v) v = _n; \
|
||||
}while(0)
|
||||
|
||||
#define NOMORE(v, n) \
|
||||
do{ \
|
||||
__typeof__(v) _n = (n); \
|
||||
if (_n < v) v = _n; \
|
||||
}while(0)
|
||||
|
||||
#define LIMIT(v, n1, n2) \
|
||||
do{ \
|
||||
__typeof__(v) _n1 = (n1); \
|
||||
__typeof__(v) _n2 = (n2); \
|
||||
if (_n1 > v) v = _n1; \
|
||||
else if (_n2 < v) v = _n2; \
|
||||
}while(0)
|
||||
|
||||
#endif
|
||||
|
||||
// Macros to chain up to 40 conditions
|
||||
#define _DO_1(W,C,A) (_##W##_1(A))
|
||||
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
|
||||
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
|
||||
#define _DO_4(W,C,A,V...) (_##W##_1(A) C _DO_3(W,C,V))
|
||||
#define _DO_5(W,C,A,V...) (_##W##_1(A) C _DO_4(W,C,V))
|
||||
#define _DO_6(W,C,A,V...) (_##W##_1(A) C _DO_5(W,C,V))
|
||||
#define _DO_7(W,C,A,V...) (_##W##_1(A) C _DO_6(W,C,V))
|
||||
#define _DO_8(W,C,A,V...) (_##W##_1(A) C _DO_7(W,C,V))
|
||||
#define _DO_9(W,C,A,V...) (_##W##_1(A) C _DO_8(W,C,V))
|
||||
#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
|
||||
#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
|
||||
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
|
||||
#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
|
||||
#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
|
||||
#define _DO_15(W,C,A,V...) (_##W##_1(A) C _DO_14(W,C,V))
|
||||
#define _DO_16(W,C,A,V...) (_##W##_1(A) C _DO_15(W,C,V))
|
||||
#define _DO_17(W,C,A,V...) (_##W##_1(A) C _DO_16(W,C,V))
|
||||
#define _DO_18(W,C,A,V...) (_##W##_1(A) C _DO_17(W,C,V))
|
||||
#define _DO_19(W,C,A,V...) (_##W##_1(A) C _DO_18(W,C,V))
|
||||
#define _DO_20(W,C,A,V...) (_##W##_1(A) C _DO_19(W,C,V))
|
||||
#define _DO_21(W,C,A,V...) (_##W##_1(A) C _DO_20(W,C,V))
|
||||
#define _DO_22(W,C,A,V...) (_##W##_1(A) C _DO_21(W,C,V))
|
||||
#define _DO_23(W,C,A,V...) (_##W##_1(A) C _DO_22(W,C,V))
|
||||
#define _DO_24(W,C,A,V...) (_##W##_1(A) C _DO_23(W,C,V))
|
||||
#define _DO_25(W,C,A,V...) (_##W##_1(A) C _DO_24(W,C,V))
|
||||
#define _DO_26(W,C,A,V...) (_##W##_1(A) C _DO_25(W,C,V))
|
||||
#define _DO_27(W,C,A,V...) (_##W##_1(A) C _DO_26(W,C,V))
|
||||
#define _DO_28(W,C,A,V...) (_##W##_1(A) C _DO_27(W,C,V))
|
||||
#define _DO_29(W,C,A,V...) (_##W##_1(A) C _DO_28(W,C,V))
|
||||
#define _DO_30(W,C,A,V...) (_##W##_1(A) C _DO_29(W,C,V))
|
||||
#define _DO_31(W,C,A,V...) (_##W##_1(A) C _DO_30(W,C,V))
|
||||
#define _DO_32(W,C,A,V...) (_##W##_1(A) C _DO_31(W,C,V))
|
||||
#define _DO_33(W,C,A,V...) (_##W##_1(A) C _DO_32(W,C,V))
|
||||
#define _DO_34(W,C,A,V...) (_##W##_1(A) C _DO_33(W,C,V))
|
||||
#define _DO_35(W,C,A,V...) (_##W##_1(A) C _DO_34(W,C,V))
|
||||
#define _DO_36(W,C,A,V...) (_##W##_1(A) C _DO_35(W,C,V))
|
||||
#define _DO_37(W,C,A,V...) (_##W##_1(A) C _DO_36(W,C,V))
|
||||
#define _DO_38(W,C,A,V...) (_##W##_1(A) C _DO_37(W,C,V))
|
||||
#define _DO_39(W,C,A,V...) (_##W##_1(A) C _DO_38(W,C,V))
|
||||
#define _DO_40(W,C,A,V...) (_##W##_1(A) C _DO_39(W,C,V))
|
||||
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
|
||||
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
|
||||
#define DO(W,C,V...) (_DO_N(W,C,NUM_ARGS(V),V))
|
||||
|
||||
// Concatenate symbol names, without or with pre-expansion
|
||||
#define _CAT(a,V...) a##V
|
||||
#define CAT(a,V...) _CAT(a,V)
|
||||
|
||||
// Recognize "true" values: blank, 1, 0x1, true
|
||||
#define _ISENA_ ~,1
|
||||
#define _ISENA_1 ~,1
|
||||
#define _ISENA_0x1 ~,1
|
||||
#define _ISENA_true ~,1
|
||||
#define _ISENA(V...) IS_PROBE(V)
|
||||
|
||||
// Macros to evaluate simple option switches
|
||||
#define _ENA_1(O) _ISENA(CAT(_IS,CAT(ENA_, O)))
|
||||
#define _DIS_1(O) NOT(_ENA_1(O))
|
||||
#define ENABLED(V...) DO(ENA,&&,V)
|
||||
#define DISABLED(V...) DO(DIS,&&,V)
|
||||
#define COUNT_ENABLED(V...) DO(ENA,+,V)
|
||||
|
||||
// Ternary pre-compiler macros conceal non-emitted content from the compiler
|
||||
#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION ? 'A' : 'B'
|
||||
#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION ? 'A' : '0'
|
||||
#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION ? 'A' : '1'
|
||||
#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION ? 'A' : '<nul>'
|
||||
#define _TERN(E,V...) __TERN(_CAT(T_,E),V) // Prepend 'T_' to get 'T_0' or 'T_1'
|
||||
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
|
||||
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
|
||||
|
||||
// Macros to conditionally emit array items and function arguments
|
||||
#define _OPTITEM(A...) A,
|
||||
#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A))
|
||||
#define _OPTARG(A...) , A
|
||||
#define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A))
|
||||
#define _OPTCODE(A) A;
|
||||
#define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A))
|
||||
|
||||
// Macros to avoid operations that aren't always optimized away (e.g., 'f + 0.0' and 'f * 1.0').
|
||||
// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
|
||||
#define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'
|
||||
#define MINUS_TERN0(O,A) _TERN(_ENA_1(O),,- (A)) // OPTION ? '- (A)' : '<nul>'
|
||||
#define MUL_TERN1(O,A) _TERN(_ENA_1(O),,* (A)) // OPTION ? '* (A)' : '<nul>'
|
||||
#define DIV_TERN1(O,A) _TERN(_ENA_1(O),,/ (A)) // OPTION ? '/ (A)' : '<nul>'
|
||||
#define SUM_TERN(O,B,A) ((B) PLUS_TERN0(O,A)) // ((B) (OPTION ? '+ (A)' : '<nul>'))
|
||||
#define DIFF_TERN(O,B,A) ((B) MINUS_TERN0(O,A)) // ((B) (OPTION ? '- (A)' : '<nul>'))
|
||||
#define MUL_TERN(O,B,A) ((B) MUL_TERN1(O,A)) // ((B) (OPTION ? '* (A)' : '<nul>'))
|
||||
#define DIV_TERN(O,B,A) ((B) DIV_TERN1(O,A)) // ((B) (OPTION ? '/ (A)' : '<nul>'))
|
||||
|
||||
#define IF_ENABLED TERN_
|
||||
#define IF_DISABLED(O,A) TERN(O,,A)
|
||||
|
||||
#define ANY(V...) !DISABLED(V)
|
||||
#define NONE(V...) DISABLED(V)
|
||||
#define ALL(V...) ENABLED(V)
|
||||
#define BOTH(V1,V2) ALL(V1,V2)
|
||||
#define EITHER(V1,V2) ANY(V1,V2)
|
||||
#define MANY(V...) (COUNT_ENABLED(V) > 1)
|
||||
|
||||
// Macros to support pins/buttons exist testing
|
||||
#define PIN_EXISTS(PN) (defined(PN##_PIN) && PN##_PIN >= 0)
|
||||
#define _PINEX_1 PIN_EXISTS
|
||||
#define PINS_EXIST(V...) DO(PINEX,&&,V)
|
||||
#define ANY_PIN(V...) DO(PINEX,||,V)
|
||||
|
||||
#define BUTTON_EXISTS(BN) (defined(BTN_##BN) && BTN_##BN >= 0)
|
||||
#define _BTNEX_1 BUTTON_EXISTS
|
||||
#define BUTTONS_EXIST(V...) DO(BTNEX,&&,V)
|
||||
#define ANY_BUTTON(V...) DO(BTNEX,||,V)
|
||||
|
||||
// Value helper macros
|
||||
#define WITHIN(N,L,H) ((N) >= (L) && (N) <= (H))
|
||||
#define ISEOL(C) ((C) == '\n' || (C) == '\r')
|
||||
#define NUMERIC(a) WITHIN(a, '0', '9')
|
||||
#define DECIMAL(a) (NUMERIC(a) || a == '.')
|
||||
#define HEXCHR(a) (NUMERIC(a) ? (a) - '0' : WITHIN(a, 'a', 'f') ? ((a) - 'a' + 10) : WITHIN(a, 'A', 'F') ? ((a) - 'A' + 10) : -1)
|
||||
#define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+')
|
||||
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
|
||||
|
||||
// Array shorthand
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
#define ZERO(a) memset((void*)a,0,sizeof(a))
|
||||
#define COPY(a,b) do{ \
|
||||
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
|
||||
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
|
||||
}while(0)
|
||||
|
||||
// Expansion of some code
|
||||
#define CODE_16( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O; P
|
||||
#define CODE_15( A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N; O
|
||||
#define CODE_14( A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A; B; C; D; E; F; G; H; I; J; K; L; M; N
|
||||
#define CODE_13( A,B,C,D,E,F,G,H,I,J,K,L,M,...) A; B; C; D; E; F; G; H; I; J; K; L; M
|
||||
#define CODE_12( A,B,C,D,E,F,G,H,I,J,K,L,...) A; B; C; D; E; F; G; H; I; J; K; L
|
||||
#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
|
||||
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
|
||||
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
|
||||
#define CODE_8( A,B,C,D,E,F,G,H,...) A; B; C; D; E; F; G; H
|
||||
#define CODE_7( A,B,C,D,E,F,G,...) A; B; C; D; E; F; G
|
||||
#define CODE_6( A,B,C,D,E,F,...) A; B; C; D; E; F
|
||||
#define CODE_5( A,B,C,D,E,...) A; B; C; D; E
|
||||
#define CODE_4( A,B,C,D,...) A; B; C; D
|
||||
#define CODE_3( A,B,C,...) A; B; C
|
||||
#define CODE_2( A,B,...) A; B
|
||||
#define CODE_1( A,...) A
|
||||
#define CODE_0(...)
|
||||
#define _CODE_N(N,V...) CODE_##N(V)
|
||||
#define CODE_N(N,V...) _CODE_N(N,V)
|
||||
|
||||
// Expansion of some non-delimited content
|
||||
#define GANG_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A B C D E F G H I J K L M N O P
|
||||
#define GANG_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A B C D E F G H I J K L M N O
|
||||
#define GANG_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A B C D E F G H I J K L M N
|
||||
#define GANG_13(A,B,C,D,E,F,G,H,I,J,K,L,M...) A B C D E F G H I J K L M
|
||||
#define GANG_12(A,B,C,D,E,F,G,H,I,J,K,L...) A B C D E F G H I J K L
|
||||
#define GANG_11(A,B,C,D,E,F,G,H,I,J,K,...) A B C D E F G H I J K
|
||||
#define GANG_10(A,B,C,D,E,F,G,H,I,J,...) A B C D E F G H I J
|
||||
#define GANG_9( A,B,C,D,E,F,G,H,I,...) A B C D E F G H I
|
||||
#define GANG_8( A,B,C,D,E,F,G,H,...) A B C D E F G H
|
||||
#define GANG_7( A,B,C,D,E,F,G,...) A B C D E F G
|
||||
#define GANG_6( A,B,C,D,E,F,...) A B C D E F
|
||||
#define GANG_5( A,B,C,D,E,...) A B C D E
|
||||
#define GANG_4( A,B,C,D,...) A B C D
|
||||
#define GANG_3( A,B,C,...) A B C
|
||||
#define GANG_2( A,B,...) A B
|
||||
#define GANG_1( A,...) A
|
||||
#define GANG_0(...)
|
||||
#define _GANG_N(N,V...) GANG_##N(V)
|
||||
#define GANG_N(N,V...) _GANG_N(N,V)
|
||||
#define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
|
||||
// Expansion of some list items
|
||||
#define LIST_26(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
|
||||
#define LIST_25(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y
|
||||
#define LIST_24(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X
|
||||
#define LIST_23(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W
|
||||
#define LIST_22(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V
|
||||
#define LIST_21(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U
|
||||
#define LIST_20(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T
|
||||
#define LIST_19(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S
|
||||
#define LIST_18(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R
|
||||
#define LIST_17(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q
|
||||
#define LIST_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P
|
||||
#define LIST_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
|
||||
#define LIST_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N
|
||||
#define LIST_13(A,B,C,D,E,F,G,H,I,J,K,L,M,...) A,B,C,D,E,F,G,H,I,J,K,L,M
|
||||
#define LIST_12(A,B,C,D,E,F,G,H,I,J,K,L,...) A,B,C,D,E,F,G,H,I,J,K,L
|
||||
#define LIST_11(A,B,C,D,E,F,G,H,I,J,K,...) A,B,C,D,E,F,G,H,I,J,K
|
||||
#define LIST_10(A,B,C,D,E,F,G,H,I,J,...) A,B,C,D,E,F,G,H,I,J
|
||||
#define LIST_9( A,B,C,D,E,F,G,H,I,...) A,B,C,D,E,F,G,H,I
|
||||
#define LIST_8( A,B,C,D,E,F,G,H,...) A,B,C,D,E,F,G,H
|
||||
#define LIST_7( A,B,C,D,E,F,G,...) A,B,C,D,E,F,G
|
||||
#define LIST_6( A,B,C,D,E,F,...) A,B,C,D,E,F
|
||||
#define LIST_5( A,B,C,D,E,...) A,B,C,D,E
|
||||
#define LIST_4( A,B,C,D,...) A,B,C,D
|
||||
#define LIST_3( A,B,C,...) A,B,C
|
||||
#define LIST_2( A,B,...) A,B
|
||||
#define LIST_1( A,...) A
|
||||
#define LIST_0(...)
|
||||
|
||||
#define _LIST_N(N,V...) LIST_##N(V)
|
||||
#define LIST_N(N,V...) _LIST_N(N,V)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
|
||||
#define ARRAY_N_1(N,K) { LIST_N_1(N,K) }
|
||||
|
||||
#define _JOIN_1(O) (O)
|
||||
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
|
||||
|
||||
#define NOOP (void(0))
|
||||
|
||||
#define CEILING(x,y) (((x) + (y) - 1) / (y))
|
||||
|
||||
#undef ABS
|
||||
#ifdef __cplusplus
|
||||
template <class T> static constexpr const T ABS(const T v) { return v >= 0 ? v : -v; }
|
||||
#else
|
||||
#define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;})
|
||||
#endif
|
||||
|
||||
#define UNEAR_ZERO(x) ((x) < 0.000001f)
|
||||
#define NEAR_ZERO(x) WITHIN(x, -0.000001f, 0.000001f)
|
||||
#define NEAR(x,y) NEAR_ZERO((x)-(y))
|
||||
|
||||
#define RECIPROCAL(x) (NEAR_ZERO(x) ? 0 : (1 / float(x)))
|
||||
#define FIXFLOAT(f) ({__typeof__(f) _f = (f); _f + (_f < 0 ? -0.0000005f : 0.0000005f);})
|
||||
|
||||
//
|
||||
// Maths macros that can be overridden by HAL
|
||||
//
|
||||
#define ACOS(x) acosf(x)
|
||||
#define ATAN2(y, x) atan2f(y, x)
|
||||
#define POW(x, y) powf(x, y)
|
||||
#define SQRT(x) sqrtf(x)
|
||||
#define RSQRT(x) (1.0f / sqrtf(x))
|
||||
#define CEIL(x) ceilf(x)
|
||||
#define FLOOR(x) floorf(x)
|
||||
#define TRUNC(x) truncf(x)
|
||||
#define LROUND(x) lroundf(x)
|
||||
#define FMOD(x, y) fmodf(x, y)
|
||||
#define HYPOT(x,y) SQRT(HYPOT2(x,y))
|
||||
|
||||
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
|
||||
#define _NUM_ARGS(_,n,m,l,k,j,i,h,g,f,e,d,c,b,a,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,40,39,38,37,36,35,34,33,32,31,30,29,28,27,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)
|
||||
|
||||
// Use TWO_ARGS(__VA_ARGS__) to get whether there are 1, 2, or >2 arguments
|
||||
#define _TWO_ARGS(_,n,m,l,k,j,i,h,g,f,e,d,c,b,a,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 TWO_ARGS(V...) _TWO_ARGS(0,V,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1,0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#ifndef _MINMAX_H_
|
||||
#define _MINMAX_H_
|
||||
|
||||
extern "C++" {
|
||||
|
||||
// C++11 solution that is standards compliant. Return type is deduced automatically
|
||||
template <class N> static constexpr N _MIN(const N val) { return val; }
|
||||
template <class N> static constexpr N _MAX(const N val) { return val; }
|
||||
template <class L, class R> static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
return lhs < rhs ? lhs : rhs;
|
||||
}
|
||||
template <class L, class R> static constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
|
||||
return lhs > rhs ? lhs : rhs;
|
||||
}
|
||||
template<class T, class ... Ts> static constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
|
||||
template<class T, class ... Ts> static constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Allow manipulating enumeration value like flags without ugly cast everywhere
|
||||
#define ENUM_FLAGS(T) \
|
||||
FORCE_INLINE constexpr T operator&(T x, T y) { return static_cast<T>(static_cast<int>(x) & static_cast<int>(y)); } \
|
||||
FORCE_INLINE constexpr T operator|(T x, T y) { return static_cast<T>(static_cast<int>(x) | static_cast<int>(y)); } \
|
||||
FORCE_INLINE constexpr T operator^(T x, T y) { return static_cast<T>(static_cast<int>(x) ^ static_cast<int>(y)); } \
|
||||
FORCE_INLINE constexpr T operator~(T x) { return static_cast<T>(~static_cast<int>(x)); } \
|
||||
FORCE_INLINE T & operator&=(T &x, T y) { x = x & y; return x; } \
|
||||
FORCE_INLINE T & operator|=(T &x, T y) { x = x | y; return x; } \
|
||||
FORCE_INLINE T & operator^=(T &x, T y) { x = x ^ y; return x; }
|
||||
|
||||
// C++11 solution that is standard compliant. <type_traits> is not available on all platform
|
||||
namespace Private {
|
||||
template<bool, typename _Tp = void> struct enable_if { };
|
||||
template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; };
|
||||
|
||||
template<typename T, typename U> struct is_same { enum { value = false }; };
|
||||
template<typename T> struct is_same<T, T> { enum { value = true }; };
|
||||
|
||||
template <typename T, typename ... Args> struct first_type_of { typedef T type; };
|
||||
template <typename T> struct first_type_of<T> { typedef T type; };
|
||||
|
||||
// remove const/volatile type qualifiers
|
||||
template<typename T> struct remove_const { typedef T type; };
|
||||
template<typename T> struct remove_const<T const> { typedef T type; };
|
||||
|
||||
template<typename T> struct remove_volatile { typedef T type; };
|
||||
template<typename T> struct remove_volatile<T volatile> { typedef T type; };
|
||||
|
||||
template<typename T> struct remove_cv { typedef typename remove_const<typename remove_volatile<T>::type>::type type; };
|
||||
|
||||
// test if type is integral
|
||||
template<typename> struct _is_integral { enum { value = false }; };
|
||||
template<> struct _is_integral<unsigned char> { enum { value = true }; };
|
||||
template<> struct _is_integral<unsigned short> { enum { value = true }; };
|
||||
template<> struct _is_integral<unsigned int> { enum { value = true }; };
|
||||
template<> struct _is_integral<unsigned long> { enum { value = true }; };
|
||||
template<> struct _is_integral<unsigned long long> { enum { value = true }; };
|
||||
template<> struct _is_integral<char> { enum { value = true }; };
|
||||
template<> struct _is_integral<short> { enum { value = true }; };
|
||||
template<> struct _is_integral<int> { enum { value = true }; };
|
||||
template<> struct _is_integral<long> { enum { value = true }; };
|
||||
template<> struct _is_integral<long long> { enum { value = true }; };
|
||||
template<typename T> struct is_integral : public _is_integral<typename remove_cv<T>::type> {};
|
||||
}
|
||||
|
||||
// enum type check and regression to its underlying integral.
|
||||
namespace Private {
|
||||
template<typename T> struct is_enum { enum { value = __is_enum(T) }; };
|
||||
|
||||
template<typename T, bool = is_enum<T>::value> struct _underlying_type { using type = __underlying_type(T); };
|
||||
template<typename T> struct _underlying_type<T, false> { };
|
||||
|
||||
template<typename T> struct underlying_type : public _underlying_type<T> { };
|
||||
}
|
||||
|
||||
// C++11 solution using SFINAE to detect the existence of a member in a class at compile time.
|
||||
// It creates a HasMember<Type> structure containing 'value' set to true if the member exists
|
||||
#define HAS_MEMBER_IMPL(Member) \
|
||||
namespace Private { \
|
||||
template <typename Type, typename Yes=char, typename No=long> struct HasMember_ ## Member { \
|
||||
template <typename C> static Yes& test( decltype(&C::Member) ) ; \
|
||||
template <typename C> static No& test(...); \
|
||||
enum { value = sizeof(test<Type>(0)) == sizeof(Yes) }; }; \
|
||||
}
|
||||
|
||||
// Call the method if it exists, but do nothing if it does not. The method is detected at compile time.
|
||||
// If the method exists, this is inlined and does not cost anything. Else, an "empty" wrapper is created, returning a default value
|
||||
#define CALL_IF_EXISTS_IMPL(Return, Method, ...) \
|
||||
HAS_MEMBER_IMPL(Method) \
|
||||
namespace Private { \
|
||||
template <typename T, typename ... Args> FORCE_INLINE typename enable_if<HasMember_ ## Method <T>::value, Return>::type Call_ ## Method(T * t, Args... a) { return static_cast<Return>(t->Method(a...)); } \
|
||||
_UNUSED static Return Call_ ## Method(...) { return __VA_ARGS__; } \
|
||||
}
|
||||
#define CALL_IF_EXISTS(Return, That, Method, ...) \
|
||||
static_cast<Return>(Private::Call_ ## Method(That, ##__VA_ARGS__))
|
||||
|
||||
// Compile-time string manipulation
|
||||
namespace CompileTimeString {
|
||||
// Simple compile-time parser to find the position of the end of a string
|
||||
constexpr const char* findStringEnd(const char *str) {
|
||||
return *str ? findStringEnd(str + 1) : str;
|
||||
}
|
||||
|
||||
// Check whether a string contains a specific character
|
||||
constexpr bool contains(const char *str, const char ch) {
|
||||
return *str == ch ? true : (*str ? contains(str + 1, ch) : false);
|
||||
}
|
||||
// Find the last position of the specific character (should be called with findStringEnd)
|
||||
constexpr const char* findLastPos(const char *str, const char ch) {
|
||||
return *str == ch ? (str + 1) : findLastPos(str - 1, ch);
|
||||
}
|
||||
// Compile-time evaluation of the last part of a file path
|
||||
// Typically used to shorten the path to file in compiled strings
|
||||
// CompileTimeString::baseName(__FILE__) returns "macros.h" and not /path/to/Marlin/src/core/macros.h
|
||||
constexpr const char* baseName(const char *str) {
|
||||
return contains(str, '/') ? findLastPos(findStringEnd(str), '/') : str;
|
||||
}
|
||||
|
||||
// Find the first occurrence of a character in a string (or return the last position in the string)
|
||||
constexpr const char* findFirst(const char *str, const char ch) {
|
||||
return *str == ch || *str == 0 ? (str + 1) : findFirst(str + 1, ch);
|
||||
}
|
||||
// Compute the string length at compile time
|
||||
constexpr unsigned stringLen(const char *str) {
|
||||
return *str == 0 ? 0 : 1 + stringLen(str + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#define ONLY_FILENAME CompileTimeString::baseName(__FILE__)
|
||||
/** Get the templated type name. This does not depends on RTTI, but on the preprocessor, so it should be quite safe to use even on old compilers.
|
||||
WARNING: DO NOT RENAME THIS FUNCTION (or change the text inside the function to match what the preprocessor will generate)
|
||||
The name is chosen very short since the binary will store "const char* gtn(T*) [with T = YourTypeHere]" so avoid long function name here */
|
||||
template <typename T>
|
||||
inline const char* gtn(T*) {
|
||||
// It works on GCC by instantiating __PRETTY_FUNCTION__ and parsing the result. So the syntax here is very limited to GCC output
|
||||
constexpr unsigned verboseChatLen = sizeof("const char* gtn(T*) [with T = ") - 1;
|
||||
static char templateType[sizeof(__PRETTY_FUNCTION__) - verboseChatLen] = {};
|
||||
__builtin_memcpy(templateType, __PRETTY_FUNCTION__ + verboseChatLen, sizeof(__PRETTY_FUNCTION__) - verboseChatLen - 2);
|
||||
return templateType;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define __MIN_N(N,V...) MIN_##N(V)
|
||||
#define _MIN_N(N,V...) __MIN_N(N,V)
|
||||
#define _MIN_N_REF() _MIN_N
|
||||
#define _MIN(V...) EVAL(_MIN_N(TWO_ARGS(V),V))
|
||||
#define MIN_2(a,b) ((a)<(b)?(a):(b))
|
||||
#define MIN_3(a,V...) MIN_2(a,DEFER2(_MIN_N_REF)()(TWO_ARGS(V),V))
|
||||
|
||||
#define __MAX_N(N,V...) MAX_##N(V)
|
||||
#define _MAX_N(N,V...) __MAX_N(N,V)
|
||||
#define _MAX_N_REF() _MAX_N
|
||||
#define _MAX(V...) EVAL(_MAX_N(TWO_ARGS(V),V))
|
||||
#define MAX_2(a,b) ((a)>(b)?(a):(b))
|
||||
#define MAX_3(a,V...) MAX_2(a,DEFER2(_MAX_N_REF)()(TWO_ARGS(V),V))
|
||||
|
||||
#endif
|
||||
|
||||
// Macros for adding
|
||||
#define INC_0 1
|
||||
#define INC_1 2
|
||||
#define INC_2 3
|
||||
#define INC_3 4
|
||||
#define INC_4 5
|
||||
#define INC_5 6
|
||||
#define INC_6 7
|
||||
#define INC_7 8
|
||||
#define INC_8 9
|
||||
#define INC_9 10
|
||||
#define INC_10 11
|
||||
#define INC_11 12
|
||||
#define INC_12 13
|
||||
#define INC_13 14
|
||||
#define INC_14 15
|
||||
#define INC_15 16
|
||||
#define INC_16 17
|
||||
#define INC_17 18
|
||||
#define INC_18 19
|
||||
#define INC_19 20
|
||||
#define INC_20 21
|
||||
#define INCREMENT_(n) INC_##n
|
||||
#define INCREMENT(n) INCREMENT_(n)
|
||||
|
||||
#define ADD0(N) N
|
||||
#define ADD1(N) INCREMENT_(N)
|
||||
#define ADD2(N) ADD1(ADD1(N))
|
||||
#define ADD3(N) ADD1(ADD2(N))
|
||||
#define ADD4(N) ADD2(ADD2(N))
|
||||
#define ADD5(N) ADD2(ADD3(N))
|
||||
#define ADD6(N) ADD3(ADD3(N))
|
||||
#define ADD7(N) ADD3(ADD4(N))
|
||||
#define ADD8(N) ADD4(ADD4(N))
|
||||
#define ADD9(N) ADD4(ADD5(N))
|
||||
#define ADD10(N) ADD5(ADD5(N))
|
||||
#define SUM(A,B) _CAT(ADD,A)(B)
|
||||
#define DOUBLE_(n) ADD##n(n)
|
||||
#define DOUBLE(n) DOUBLE_(n)
|
||||
|
||||
// Macros for subtracting
|
||||
#define DEC_0 0
|
||||
#define DEC_1 0
|
||||
#define DEC_2 1
|
||||
#define DEC_3 2
|
||||
#define DEC_4 3
|
||||
#define DEC_5 4
|
||||
#define DEC_6 5
|
||||
#define DEC_7 6
|
||||
#define DEC_8 7
|
||||
#define DEC_9 8
|
||||
#define DEC_10 9
|
||||
#define DEC_11 10
|
||||
#define DEC_12 11
|
||||
#define DEC_13 12
|
||||
#define DEC_14 13
|
||||
#define DEC_15 14
|
||||
#define DECREMENT_(n) DEC_##n
|
||||
#define DECREMENT(n) DECREMENT_(n)
|
||||
|
||||
#define SUB0(N) N
|
||||
#define SUB1(N) DECREMENT_(N)
|
||||
#define SUB2(N) SUB1(SUB1(N))
|
||||
#define SUB3(N) SUB1(SUB2(N))
|
||||
#define SUB4(N) SUB2(SUB2(N))
|
||||
#define SUB5(N) SUB2(SUB3(N))
|
||||
#define SUB6(N) SUB3(SUB3(N))
|
||||
#define SUB7(N) SUB3(SUB4(N))
|
||||
#define SUB8(N) SUB4(SUB4(N))
|
||||
#define SUB9(N) SUB4(SUB5(N))
|
||||
#define SUB10(N) SUB5(SUB5(N))
|
||||
|
||||
//
|
||||
// Primitives supporting precompiler REPEAT
|
||||
//
|
||||
#define FIRST(a,...) a
|
||||
#define SECOND(a,b,...) b
|
||||
#define THIRD(a,b,c,...) c
|
||||
|
||||
// Defer expansion
|
||||
#define EMPTY()
|
||||
#define DEFER(M) M EMPTY()
|
||||
#define DEFER2(M) M EMPTY EMPTY()()
|
||||
#define DEFER3(M) M EMPTY EMPTY EMPTY()()()
|
||||
#define DEFER4(M) M EMPTY EMPTY EMPTY EMPTY()()()()
|
||||
|
||||
// Force define expansion
|
||||
#define EVAL(V...) EVAL16(V)
|
||||
#define EVAL4096(V...) EVAL2048(EVAL2048(V))
|
||||
#define EVAL2048(V...) EVAL1024(EVAL1024(V))
|
||||
#define EVAL1024(V...) EVAL512(EVAL512(V))
|
||||
#define EVAL512(V...) EVAL256(EVAL256(V))
|
||||
#define EVAL256(V...) EVAL128(EVAL128(V))
|
||||
#define EVAL128(V...) EVAL64(EVAL64(V))
|
||||
#define EVAL64(V...) EVAL32(EVAL32(V))
|
||||
#define EVAL32(V...) EVAL16(EVAL16(V))
|
||||
#define EVAL16(V...) EVAL8(EVAL8(V))
|
||||
#define EVAL8(V...) EVAL4(EVAL4(V))
|
||||
#define EVAL4(V...) EVAL2(EVAL2(V))
|
||||
#define EVAL2(V...) EVAL1(EVAL1(V))
|
||||
#define EVAL1(V...) V
|
||||
|
||||
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
|
||||
#define PROBE() ~, 1 // Second item will be 1 if this is passed
|
||||
#define _NOT_0 PROBE()
|
||||
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
|
||||
#define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'.
|
||||
|
||||
#define IF_ELSE(TF) _IF_ELSE(_BOOL(TF))
|
||||
#define _IF_ELSE(TF) _CAT(_IF_, TF)
|
||||
|
||||
#define _IF_1(V...) V _IF_1_ELSE
|
||||
#define _IF_0(...) _IF_0_ELSE
|
||||
|
||||
#define _IF_1_ELSE(...)
|
||||
#define _IF_0_ELSE(V...) V
|
||||
|
||||
#define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)())
|
||||
#define _END_OF_ARGUMENTS_() 0
|
||||
|
||||
// Simple Inline IF Macros, friendly to use in other macro definitions
|
||||
#define IF(O, A, B) ((O) ? (A) : (B))
|
||||
#define IF_0(O, A) IF(O, A, 0)
|
||||
#define IF_1(O, A) IF(O, A, 1)
|
||||
|
||||
//
|
||||
// REPEAT core macros. Recurse N times with ascending I.
|
||||
//
|
||||
|
||||
// Call OP(I) N times with ascending counter.
|
||||
#define _REPEAT(_RPT_I,_RPT_N,_RPT_OP) \
|
||||
_RPT_OP(_RPT_I) \
|
||||
IF_ELSE(SUB1(_RPT_N)) \
|
||||
( DEFER2(__REPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __REPEAT() _REPEAT
|
||||
|
||||
// Call OP(I, ...) N times with ascending counter.
|
||||
#define _REPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
|
||||
_RPT_OP(_RPT_I,V) \
|
||||
IF_ELSE(SUB1(_RPT_N)) \
|
||||
( DEFER2(__REPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __REPEAT2() _REPEAT2
|
||||
|
||||
// Repeat a macro passing S...N-1.
|
||||
#define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP))
|
||||
#define REPEAT(N,OP) REPEAT_S(0,N,OP)
|
||||
#define REPEAT_1(N,OP) REPEAT_S(1,INCREMENT(N),OP)
|
||||
|
||||
// Repeat a macro passing 0...N-1 plus additional arguments.
|
||||
#define REPEAT2_S(S,N,OP,V...) EVAL(_REPEAT2(S,SUB##S(N),OP,V))
|
||||
#define REPEAT2(N,OP,V...) REPEAT2_S(0,N,OP,V)
|
||||
|
||||
// Use RREPEAT macros with REPEAT macros for nesting
|
||||
#define _RREPEAT(_RPT_I,_RPT_N,_RPT_OP) \
|
||||
_RPT_OP(_RPT_I) \
|
||||
IF_ELSE(SUB1(_RPT_N)) \
|
||||
( DEFER2(__RREPEAT)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __RREPEAT() _RREPEAT
|
||||
#define _RREPEAT2(_RPT_I,_RPT_N,_RPT_OP,V...) \
|
||||
_RPT_OP(_RPT_I,V) \
|
||||
IF_ELSE(SUB1(_RPT_N)) \
|
||||
( DEFER2(__RREPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __RREPEAT2() _RREPEAT2
|
||||
#define RREPEAT_S(S,N,OP) EVAL1024(_RREPEAT(S,SUB##S(N),OP))
|
||||
#define RREPEAT(N,OP) RREPEAT_S(0,N,OP)
|
||||
#define RREPEAT_1(N,OP) RREPEAT_S(1,INCREMENT(N),OP)
|
||||
#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V))
|
||||
#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V)
|
||||
|
||||
// Emit a list of N OP(I) items with ascending counter.
|
||||
#define _REPLIST(_RPT_I,_RPT_N,_RPT_OP) \
|
||||
_RPT_OP(_RPT_I) \
|
||||
IF_ELSE(SUB1(_RPT_N)) \
|
||||
( , DEFER2(__REPLIST)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __REPLIST() _REPLIST
|
||||
|
||||
// Repeat a macro, comma-separated, passing S...N-1.
|
||||
#define REPLIST_S(S,N,OP) EVAL(_REPLIST(S,SUB##S(N),OP))
|
||||
#define REPLIST(N,OP) REPLIST_S(0,N,OP)
|
||||
#define REPLIST_1(N,OP) REPLIST_S(1,INCREMENT(N),OP)
|
||||
|
||||
// Call OP(A) with each item as an argument
|
||||
#define _MAP(_MAP_OP,A,V...) \
|
||||
_MAP_OP(A) \
|
||||
IF_ELSE(HAS_ARGS(V)) \
|
||||
( DEFER2(__MAP)()(_MAP_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __MAP() _MAP
|
||||
|
||||
#define MAP(OP,V...) EVAL(_MAP(OP,V))
|
||||
|
||||
// Emit a list of OP(A) with the given items
|
||||
#define _MAPLIST(_MAP_OP,A,V...) \
|
||||
_MAP_OP(A) \
|
||||
IF_ELSE(HAS_ARGS(V)) \
|
||||
( , DEFER2(__MAPLIST)()(_MAP_OP,V) ) \
|
||||
( /* Do nothing */ )
|
||||
#define __MAPLIST() _MAPLIST
|
||||
|
||||
#define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V))
|
||||
|
||||
// Temperature Sensor Config
|
||||
#define TEMP_SENSOR(N) TEMP_SENSOR_##N
|
||||
#define _HAS_E_TEMP(N) || TEMP_SENSOR(N)
|
||||
#define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP))
|
||||
#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2)
|
||||
33
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/millis_t.h
Normal file
33
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/millis_t.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 <stdint.h>
|
||||
|
||||
typedef uint32_t millis_t;
|
||||
|
||||
#define SEC_TO_MS(N) millis_t((N)*1000UL)
|
||||
#define MIN_TO_MS(N) SEC_TO_MS((N)*60UL)
|
||||
#define MS_TO_SEC(N) millis_t((N)/1000UL)
|
||||
|
||||
#define PENDING(NOW,SOON) ((int32_t)(NOW-(SOON))<0)
|
||||
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
/*******************************************************
|
||||
* multi_language.h *
|
||||
* By Marcio Teixeira 2019 for Aleph Objects *
|
||||
*******************************************************/
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
typedef const char Language_Str[];
|
||||
#define LSTR PROGMEM Language_Str
|
||||
|
||||
#ifdef LCD_LANGUAGE_5
|
||||
#define NUM_LANGUAGES 5
|
||||
#elif defined(LCD_LANGUAGE_4)
|
||||
#define NUM_LANGUAGES 4
|
||||
#elif defined(LCD_LANGUAGE_3)
|
||||
#define NUM_LANGUAGES 3
|
||||
#elif defined(LCD_LANGUAGE_2)
|
||||
#define NUM_LANGUAGES 2
|
||||
#else
|
||||
#define NUM_LANGUAGES 1
|
||||
#endif
|
||||
|
||||
// Set unused languages equal to each other so the
|
||||
// compiler can optimize away the conditionals.
|
||||
#define LCD_LANGUAGE_1 LCD_LANGUAGE
|
||||
#ifndef LCD_LANGUAGE_2
|
||||
#define LCD_LANGUAGE_2 LCD_LANGUAGE
|
||||
#endif
|
||||
#ifndef LCD_LANGUAGE_3
|
||||
#define LCD_LANGUAGE_3 LCD_LANGUAGE_2
|
||||
#endif
|
||||
#ifndef LCD_LANGUAGE_4
|
||||
#define LCD_LANGUAGE_4 LCD_LANGUAGE_3
|
||||
#endif
|
||||
#ifndef LCD_LANGUAGE_5
|
||||
#define LCD_LANGUAGE_5 LCD_LANGUAGE_4
|
||||
#endif
|
||||
|
||||
#define _GET_LANG(LANG) Language_##LANG
|
||||
#define GET_LANG(LANG) _GET_LANG(LANG)
|
||||
|
||||
#if NUM_LANGUAGES > 1
|
||||
#define HAS_MULTI_LANGUAGE 1
|
||||
#if HAS_MARLINUI_MENU
|
||||
#define HAS_MENU_MULTI_LANGUAGE 1
|
||||
#endif
|
||||
#define GET_TEXT(MSG) ( \
|
||||
ui.language == 4 ? GET_LANG(LCD_LANGUAGE_5)::MSG : \
|
||||
ui.language == 3 ? GET_LANG(LCD_LANGUAGE_4)::MSG : \
|
||||
ui.language == 2 ? GET_LANG(LCD_LANGUAGE_3)::MSG : \
|
||||
ui.language == 1 ? GET_LANG(LCD_LANGUAGE_2)::MSG : \
|
||||
GET_LANG(LCD_LANGUAGE )::MSG )
|
||||
#define MAX_LANG_CHARSIZE _MAX(GET_LANG(LCD_LANGUAGE )::CHARSIZE, \
|
||||
GET_LANG(LCD_LANGUAGE_2)::CHARSIZE, \
|
||||
GET_LANG(LCD_LANGUAGE_3)::CHARSIZE, \
|
||||
GET_LANG(LCD_LANGUAGE_4)::CHARSIZE, \
|
||||
GET_LANG(LCD_LANGUAGE_5)::CHARSIZE )
|
||||
#else
|
||||
#define GET_TEXT(MSG) GET_LANG(LCD_LANGUAGE)::MSG
|
||||
#define MAX_LANG_CHARSIZE LANG_CHARSIZE
|
||||
#endif
|
||||
#define GET_TEXT_F(MSG) FPSTR(GET_TEXT(MSG))
|
||||
|
||||
#define GET_EN_TEXT(MSG) GET_LANG(en)::MSG
|
||||
#define GET_EN_TEXT_F(MSG) FPSTR(GET_EN_TEXT(MSG))
|
||||
|
||||
#define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE
|
||||
#define LANG_CHARSIZE GET_TEXT(CHARSIZE)
|
||||
#define USE_WIDE_GLYPH (LANG_CHARSIZE > 2)
|
||||
|
||||
#define MSG_1_LINE(A) A "\0" "\0"
|
||||
#define MSG_2_LINE(A,B) A "\0" B "\0"
|
||||
#define MSG_3_LINE(A,B,C) A "\0" B "\0" C
|
||||
106
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial.cpp
Normal file
106
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 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 "serial.h"
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_ETHERNET
|
||||
#include "../feature/ethernet.h"
|
||||
#endif
|
||||
|
||||
// Echo commands to the terminal by default in dev mode
|
||||
uint8_t marlin_debug_flags = TERN(MARLIN_DEV_MODE, MARLIN_DEBUG_ECHO, MARLIN_DEBUG_NONE);
|
||||
|
||||
// Commonly-used strings in serial output
|
||||
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");
|
||||
PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T"); PGMSTR(NUL_STR, "");
|
||||
|
||||
#define _N_STR(N) PGMSTR(N##_STR, STR_##N);
|
||||
#define _N_LBL(N) PGMSTR(N##_LBL, STR_##N ":");
|
||||
#define _SP_N_STR(N) PGMSTR(SP_##N##_STR, " " STR_##N);
|
||||
#define _SP_N_LBL(N) PGMSTR(SP_##N##_LBL, " " STR_##N ":");
|
||||
MAP(_N_STR, LOGICAL_AXIS_NAMES); MAP(_SP_N_STR, LOGICAL_AXIS_NAMES);
|
||||
MAP(_N_LBL, LOGICAL_AXIS_NAMES); MAP(_SP_N_LBL, LOGICAL_AXIS_NAMES);
|
||||
|
||||
// Hook Meatpack if it's enabled on the first leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_1)
|
||||
SerialLeafT1 mpSerial1(false, _SERIAL_LEAF_1);
|
||||
#endif
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_2)
|
||||
SerialLeafT2 mpSerial2(false, _SERIAL_LEAF_2);
|
||||
#endif
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_3)
|
||||
SerialLeafT3 mpSerial3(false, _SERIAL_LEAF_3);
|
||||
#endif
|
||||
|
||||
// Step 2: For multiserial, handle the second serial port as well
|
||||
#if HAS_MULTI_SERIAL
|
||||
#if HAS_ETHERNET
|
||||
// We need a definition here
|
||||
SerialLeafT2 msSerial2(ethernet.have_telnet_client, MYSERIAL2, false);
|
||||
#endif
|
||||
|
||||
#define __S_LEAF(N) ,SERIAL_LEAF_##N
|
||||
#define _S_LEAF(N) __S_LEAF(N)
|
||||
|
||||
SerialOutputT multiSerial( SERIAL_LEAF_1 REPEAT_S(2, INCREMENT(NUM_SERIAL), _S_LEAF) );
|
||||
|
||||
#undef __S_LEAF
|
||||
#undef _S_LEAF
|
||||
|
||||
#endif
|
||||
|
||||
void serial_print_P(PGM_P str) {
|
||||
while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c);
|
||||
}
|
||||
|
||||
void serial_echo_start() { serial_print(F("echo:")); }
|
||||
void serial_error_start() { serial_print(F("Error:")); }
|
||||
|
||||
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
||||
|
||||
void serial_offset(const_float_t v, const uint8_t sp/*=0*/) {
|
||||
if (v == 0 && sp == 1)
|
||||
SERIAL_CHAR(' ');
|
||||
else if (v > 0 || (v == 0 && sp == 2))
|
||||
SERIAL_CHAR('+');
|
||||
SERIAL_DECIMAL(v);
|
||||
}
|
||||
|
||||
void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); }
|
||||
void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
|
||||
void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); }
|
||||
|
||||
void print_bin(uint16_t val) {
|
||||
for (uint8_t i = 16; i--;) {
|
||||
SERIAL_CHAR('0' + TEST(val, i));
|
||||
if (!(i & 0x3) && i) SERIAL_CHAR(' ');
|
||||
}
|
||||
}
|
||||
|
||||
void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
|
||||
if (prefix) serial_print(prefix);
|
||||
SERIAL_ECHOPGM_P(
|
||||
LIST_N(DOUBLE(NUM_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k, SP_U_STR, u, SP_V_STR, v, SP_W_STR, w)
|
||||
);
|
||||
if (suffix) serial_print(suffix); else SERIAL_EOL();
|
||||
}
|
||||
375
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial.h
Normal file
375
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial.h
Normal file
@@ -0,0 +1,375 @@
|
||||
/**
|
||||
* 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"
|
||||
#include "serial_hook.h"
|
||||
|
||||
#if HAS_MEATPACK
|
||||
#include "../feature/meatpack.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Debugging flags for use by M111
|
||||
//
|
||||
enum MarlinDebugFlags : uint8_t {
|
||||
MARLIN_DEBUG_NONE = 0,
|
||||
MARLIN_DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
|
||||
MARLIN_DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
|
||||
MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented
|
||||
MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
|
||||
MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
|
||||
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
|
||||
#else
|
||||
MARLIN_DEBUG_LEVELING = 0,
|
||||
MARLIN_DEBUG_MESH_ADJUST = 0,
|
||||
#endif
|
||||
MARLIN_DEBUG_ALL = 0xFF
|
||||
};
|
||||
|
||||
extern uint8_t marlin_debug_flags;
|
||||
#define DEBUGGING(F) (marlin_debug_flags & (MARLIN_DEBUG_## F))
|
||||
|
||||
//
|
||||
// Serial redirection
|
||||
//
|
||||
// Step 1: Find out what the first serial leaf is
|
||||
#if HAS_MULTI_SERIAL && defined(SERIAL_CATCHALL)
|
||||
#define _SERIAL_LEAF_1 MYSERIAL
|
||||
#else
|
||||
#define _SERIAL_LEAF_1 MYSERIAL1
|
||||
#endif
|
||||
|
||||
// Hook Meatpack if it's enabled on the first leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_1)
|
||||
typedef MeatpackSerial<decltype(_SERIAL_LEAF_1)> SerialLeafT1;
|
||||
extern SerialLeafT1 mpSerial1;
|
||||
#define SERIAL_LEAF_1 mpSerial1
|
||||
#else
|
||||
#define SERIAL_LEAF_1 _SERIAL_LEAF_1
|
||||
#endif
|
||||
|
||||
// Step 2: For multiserial wrap all serial ports in a single
|
||||
// interface with the ability to output to multiple serial ports.
|
||||
#if HAS_MULTI_SERIAL
|
||||
#define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p)
|
||||
#define _PORT_RESTORE(n) RESTORE(n)
|
||||
#define SERIAL_ASSERT(P) if (multiSerial.portMask!=(P)) { debugger(); }
|
||||
// If we have a catchall, use that directly
|
||||
#ifdef SERIAL_CATCHALL
|
||||
#define _SERIAL_LEAF_2 SERIAL_CATCHALL
|
||||
#elif HAS_ETHERNET
|
||||
typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2; // We need to create an instance here
|
||||
extern SerialLeafT2 msSerial2;
|
||||
#define _SERIAL_LEAF_2 msSerial2
|
||||
#else
|
||||
#define _SERIAL_LEAF_2 MYSERIAL2 // Don't create a useless instance here, directly use the existing instance
|
||||
#endif
|
||||
|
||||
// Nothing complicated here
|
||||
#define _SERIAL_LEAF_3 MYSERIAL3
|
||||
|
||||
// Hook Meatpack if it's enabled on the second leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_2)
|
||||
typedef MeatpackSerial<decltype(_SERIAL_LEAF_2)> SerialLeafT2;
|
||||
extern SerialLeafT2 mpSerial2;
|
||||
#define SERIAL_LEAF_2 mpSerial2
|
||||
#else
|
||||
#define SERIAL_LEAF_2 _SERIAL_LEAF_2
|
||||
#endif
|
||||
|
||||
// Hook Meatpack if it's enabled on the third leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_3)
|
||||
typedef MeatpackSerial<decltype(_SERIAL_LEAF_3)> SerialLeafT3;
|
||||
extern SerialLeafT3 mpSerial3;
|
||||
#define SERIAL_LEAF_3 mpSerial3
|
||||
#else
|
||||
#define SERIAL_LEAF_3 _SERIAL_LEAF_3
|
||||
#endif
|
||||
|
||||
#define __S_MULTI(N) decltype(SERIAL_LEAF_##N),
|
||||
#define _S_MULTI(N) __S_MULTI(N)
|
||||
|
||||
typedef MultiSerial< REPEAT_1(NUM_SERIAL, _S_MULTI) 0> SerialOutputT;
|
||||
|
||||
#undef __S_MULTI
|
||||
#undef _S_MULTI
|
||||
|
||||
extern SerialOutputT multiSerial;
|
||||
#define SERIAL_IMPL multiSerial
|
||||
#else
|
||||
#define _PORT_REDIRECT(n,p) NOOP
|
||||
#define _PORT_RESTORE(n) NOOP
|
||||
#define SERIAL_ASSERT(P) NOOP
|
||||
#define SERIAL_IMPL SERIAL_LEAF_1
|
||||
#endif
|
||||
|
||||
#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
|
||||
#define PORT_RESTORE() _PORT_RESTORE(1)
|
||||
#define SERIAL_PORTMASK(P) SerialMask::from(P)
|
||||
|
||||
//
|
||||
// SERIAL_CHAR - Print one or more individual chars
|
||||
//
|
||||
inline void SERIAL_CHAR(char a) { SERIAL_IMPL.write(a); }
|
||||
template <typename ... Args>
|
||||
void SERIAL_CHAR(char a, Args ... args) { SERIAL_IMPL.write(a); SERIAL_CHAR(args ...); }
|
||||
|
||||
/**
|
||||
* SERIAL_ECHO - Print a single string or value.
|
||||
* Any numeric parameter (including char) is printed as a base-10 number.
|
||||
* A string pointer or literal will be output as a string.
|
||||
*
|
||||
* NOTE: Use SERIAL_CHAR to print char as a single character.
|
||||
*/
|
||||
template <typename T>
|
||||
void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); }
|
||||
|
||||
// Wrapper for ECHO commands to interpret a char
|
||||
inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
|
||||
#define AS_DIGIT(n) C('0' + (n))
|
||||
|
||||
template <typename T>
|
||||
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
|
||||
|
||||
// SERIAL_PRINT works like SERIAL_ECHO but also takes the numeric base
|
||||
template <typename T, typename U>
|
||||
void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
|
||||
|
||||
template <typename T>
|
||||
void SERIAL_PRINTLN(T x, PrintBase y) { SERIAL_IMPL.println(x, y); }
|
||||
|
||||
// Flush the serial port
|
||||
inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); }
|
||||
inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
|
||||
|
||||
// Serial echo and error prefixes
|
||||
#define SERIAL_ECHO_START() serial_echo_start()
|
||||
#define SERIAL_ERROR_START() serial_error_start()
|
||||
|
||||
// Serial end-of-line
|
||||
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
||||
|
||||
// Print a single PROGMEM, PGM_P, or PSTR() string.
|
||||
void serial_print_P(PGM_P str);
|
||||
inline void serial_println_P(PGM_P str) { serial_print_P(str); SERIAL_EOL(); }
|
||||
|
||||
// Print a single FSTR_P, F(), or FPSTR() string.
|
||||
inline void serial_print(FSTR_P const fstr) { serial_print_P(FTOP(fstr)); }
|
||||
inline void serial_println(FSTR_P const fstr) { serial_println_P(FTOP(fstr)); }
|
||||
|
||||
//
|
||||
// SERIAL_ECHOPGM... macros are used to output string-value pairs.
|
||||
//
|
||||
|
||||
// Print up to 20 pairs of values. Odd elements must be literal strings.
|
||||
#define __SEP_N(N,V...) _SEP_##N(V)
|
||||
#define _SEP_N(N,V...) __SEP_N(N,V)
|
||||
#define _SEP_N_REF() _SEP_N
|
||||
#define _SEP_1(s) serial_print(F(s));
|
||||
#define _SEP_2(s,v) serial_echopair(F(s),v);
|
||||
#define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPGM(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be literal strings.
|
||||
#define __SELP_N(N,V...) _SELP_##N(V)
|
||||
#define _SELP_N(N,V...) __SELP_N(N,V)
|
||||
#define _SELP_N_REF() _SELP_N
|
||||
#define _SELP_1(s) serial_print(F(s "\n"));
|
||||
#define _SELP_2(s,v) serial_echolnpair(F(s),v);
|
||||
#define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOLNPGM(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values. Odd elements must be PSTR pointers.
|
||||
#define __SEP_N_P(N,V...) _SEP_##N##_P(V)
|
||||
#define _SEP_N_P(N,V...) __SEP_N_P(N,V)
|
||||
#define _SEP_N_P_REF() _SEP_N_P
|
||||
#define _SEP_1_P(p) serial_print_P(p);
|
||||
#define _SEP_2_P(p,v) serial_echopair_P(p,v);
|
||||
#define _SEP_3_P(p,v,V...) _SEP_2_P(p,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPGM_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be PSTR pointers.
|
||||
#define __SELP_N_P(N,V...) _SELP_##N##_P(V)
|
||||
#define _SELP_N_P(N,V...) __SELP_N_P(N,V)
|
||||
#define _SELP_N_P_REF() _SELP_N_P
|
||||
#define _SELP_1_P(p) serial_println_P(p)
|
||||
#define _SELP_2_P(p,v) serial_echolnpair_P(p,v)
|
||||
#define _SELP_3_P(p,v,V...) { _SEP_2_P(p,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
|
||||
#define SERIAL_ECHOLNPGM_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values. Odd elements must be FSTR_P, F(), or FPSTR().
|
||||
#define __SEP_N_F(N,V...) _SEP_##N##_F(V)
|
||||
#define _SEP_N_F(N,V...) __SEP_N_F(N,V)
|
||||
#define _SEP_N_F_REF() _SEP_N_F
|
||||
#define _SEP_1_F(p) serial_print(p);
|
||||
#define _SEP_2_F(p,v) serial_echopair(p,v);
|
||||
#define _SEP_3_F(p,v,V...) _SEP_2_F(p,v); DEFER2(_SEP_N_F_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOF(V...) do{ EVAL(_SEP_N_F(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be FSTR_P, F(), or FPSTR().
|
||||
#define __SELP_N_F(N,V...) _SELP_##N##_F(V)
|
||||
#define _SELP_N_F(N,V...) __SELP_N_F(N,V)
|
||||
#define _SELP_N_F_REF() _SELP_N_F
|
||||
#define _SELP_1_F(p) serial_println(p)
|
||||
#define _SELP_2_F(p,v) serial_echolnpair(p,v)
|
||||
#define _SELP_3_F(p,v,V...) { _SEP_2_F(p,v); DEFER2(_SELP_N_F_REF)()(TWO_ARGS(V),V); }
|
||||
#define SERIAL_ECHOLNF(V...) do{ EVAL(_SELP_N_F(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
#ifdef AllowDifferentTypeInList
|
||||
|
||||
inline void SERIAL_ECHOLIST_IMPL() {}
|
||||
template <typename T>
|
||||
void SERIAL_ECHOLIST_IMPL(T && t) { SERIAL_IMPL.print(t); }
|
||||
|
||||
template <typename T, typename ... Args>
|
||||
void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
|
||||
SERIAL_IMPL.print(t);
|
||||
serial_print(F(", "));
|
||||
SERIAL_ECHOLIST_IMPL(args...);
|
||||
}
|
||||
|
||||
template <typename ... Args>
|
||||
void SERIAL_ECHOLIST(FSTR_P const str, Args && ... args) {
|
||||
SERIAL_IMPL.print(FTOP(str));
|
||||
SERIAL_ECHOLIST_IMPL(args...);
|
||||
}
|
||||
|
||||
#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
|
||||
|
||||
template <typename ... Args>
|
||||
void SERIAL_ECHOLIST(FSTR_P const fstr, Args && ... args) {
|
||||
serial_print(fstr);
|
||||
typename Private::first_type_of<Args...>::type values[] = { args... };
|
||||
constexpr size_t argsSize = sizeof...(args);
|
||||
for (size_t i = 0; i < argsSize; i++) {
|
||||
if (i) serial_print(F(", "));
|
||||
SERIAL_IMPL.print(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// SERIAL_ECHO_F prints a floating point value with optional precision
|
||||
inline void SERIAL_ECHO_F(EnsureDouble x, int digit=2) { SERIAL_IMPL.print(x, digit); }
|
||||
|
||||
#define SERIAL_ECHOPAIR_F_P(P,V...) do{ serial_print_P(P); SERIAL_ECHO_F(V); }while(0)
|
||||
#define SERIAL_ECHOLNPAIR_F_P(P,V...) do{ SERIAL_ECHOPAIR_F_P(P,V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHOPAIR_F_F(S,V...) do{ serial_print(S); SERIAL_ECHO_F(V); }while(0)
|
||||
#define SERIAL_ECHOLNPAIR_F_F(S,V...) do{ SERIAL_ECHOPAIR_F_F(S,V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHOPAIR_F(S,V...) SERIAL_ECHOPAIR_F_F(F(S),V)
|
||||
#define SERIAL_ECHOLNPAIR_F(V...) do{ SERIAL_ECHOPAIR_F(V); SERIAL_EOL(); }while(0)
|
||||
|
||||
#define SERIAL_ECHO_MSG(V...) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(V); }while(0)
|
||||
#define SERIAL_ERROR_MSG(V...) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(V); }while(0)
|
||||
|
||||
#define SERIAL_ECHO_SP(C) serial_spaces(C)
|
||||
|
||||
#define SERIAL_ECHO_TERNARY(TF, PRE, ON, OFF, POST) serial_ternary(TF, F(PRE), F(ON), F(OFF), F(POST))
|
||||
|
||||
#if SERIAL_FLOAT_PRECISION
|
||||
#define SERIAL_DECIMAL(V) SERIAL_PRINT(V, SERIAL_FLOAT_PRECISION)
|
||||
#else
|
||||
#define SERIAL_DECIMAL(V) SERIAL_ECHO(V)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
|
||||
//
|
||||
inline void serial_echopair_P(PGM_P const pstr, serial_char_t v) { serial_print_P(pstr); SERIAL_CHAR(v.c); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, float v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, double v) { serial_print_P(pstr); SERIAL_DECIMAL(v); }
|
||||
//inline void serial_echopair_P(PGM_P const pstr, const char *v) { serial_print_P(pstr); SERIAL_ECHO(v); }
|
||||
inline void serial_echopair_P(PGM_P const pstr, FSTR_P v) { serial_print_P(pstr); SERIAL_ECHOF(v); }
|
||||
|
||||
// Default implementation for types without a specialization. Handles integers.
|
||||
template <typename T>
|
||||
inline void serial_echopair_P(PGM_P const pstr, T v) { serial_print_P(pstr); SERIAL_ECHO(v); }
|
||||
|
||||
// Add a newline.
|
||||
template <typename T>
|
||||
inline void serial_echolnpair_P(PGM_P const pstr, T v) { serial_echopair_P(pstr, v); SERIAL_EOL(); }
|
||||
|
||||
// Catch-all for __FlashStringHelper *
|
||||
template <typename T>
|
||||
inline void serial_echopair(FSTR_P const fstr, T v) { serial_echopair_P(FTOP(fstr), v); }
|
||||
|
||||
// Add a newline to the serial output
|
||||
template <typename T>
|
||||
inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP(fstr), v); }
|
||||
|
||||
void serial_echo_start();
|
||||
void serial_error_start();
|
||||
inline void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr) {
|
||||
if (pre) serial_print(pre);
|
||||
if (onoff && on) serial_print(on);
|
||||
if (!onoff && off) serial_print(off);
|
||||
if (post) serial_print(post);
|
||||
}
|
||||
void serialprint_onoff(const bool onoff);
|
||||
void serialprintln_onoff(const bool onoff);
|
||||
void serialprint_truefalse(const bool tf);
|
||||
void serial_spaces(uint8_t count);
|
||||
void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2)
|
||||
|
||||
void print_bin(const uint16_t val);
|
||||
void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
|
||||
|
||||
inline void print_pos(const xyze_pos_t &xyze, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
|
||||
print_pos(NUM_AXIS_ELEM(xyze), prefix, suffix);
|
||||
}
|
||||
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0)
|
||||
|
||||
//
|
||||
// Commonly-used strings in serial output
|
||||
//
|
||||
|
||||
#define _N_STR(N) N##_STR
|
||||
#define _N_LBL(N) N##_LBL
|
||||
#define _N_STR_A(N) _N_STR(N)[]
|
||||
#define _N_LBL_A(N) _N_LBL(N)[]
|
||||
#define _SP_N_STR(N) SP_##N##_STR
|
||||
#define _SP_N_LBL(N) SP_##N##_LBL
|
||||
#define _SP_N_STR_A(N) _SP_N_STR(N)[]
|
||||
#define _SP_N_LBL_A(N) _SP_N_LBL(N)[]
|
||||
|
||||
extern const char SP_A_STR[], SP_B_STR[], SP_C_STR[], SP_P_STR[], SP_T_STR[], NUL_STR[],
|
||||
MAPLIST(_N_STR_A, LOGICAL_AXIS_NAMES), MAPLIST(_SP_N_STR_A, LOGICAL_AXIS_NAMES),
|
||||
MAPLIST(_N_LBL_A, LOGICAL_AXIS_NAMES), MAPLIST(_SP_N_LBL_A, LOGICAL_AXIS_NAMES);
|
||||
|
||||
PGM_P const SP_AXIS_LBL[] PROGMEM = { MAPLIST(_SP_N_LBL, LOGICAL_AXIS_NAMES) };
|
||||
PGM_P const SP_AXIS_STR[] PROGMEM = { MAPLIST(_SP_N_STR, LOGICAL_AXIS_NAMES) };
|
||||
|
||||
#undef _N_STR
|
||||
#undef _N_LBL
|
||||
#undef _N_STR_A
|
||||
#undef _N_LBL_A
|
||||
#undef _SP_N_STR
|
||||
#undef _SP_N_LBL
|
||||
#undef _SP_N_STR_A
|
||||
#undef _SP_N_LBL_A
|
||||
259
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial_base.h
Normal file
259
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial_base.h
Normal file
@@ -0,0 +1,259 @@
|
||||
/**
|
||||
* 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/MarlinConfigPre.h"
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
#include "../feature/e_parser.h"
|
||||
#endif
|
||||
|
||||
// Used in multiple places
|
||||
// You can build it but not manipulate it.
|
||||
// There are only few places where it's required to access the underlying member: GCodeQueue, SerialMask and MultiSerial
|
||||
struct serial_index_t {
|
||||
// A signed index, where -1 is a special case meaning no action (neither output or input)
|
||||
int8_t index;
|
||||
|
||||
// Check if the index is within the range [a ... b]
|
||||
constexpr inline bool within(const int8_t a, const int8_t b) const { return WITHIN(index, a, b); }
|
||||
constexpr inline bool valid() const { return WITHIN(index, 0, 7); } // At most, 8 bits
|
||||
|
||||
// Construction is either from an index
|
||||
constexpr serial_index_t(const int8_t index) : index(index) {}
|
||||
|
||||
// Default to "no index"
|
||||
constexpr serial_index_t() : index(-1) {}
|
||||
};
|
||||
|
||||
// In order to catch usage errors in code, we make the base to encode number explicit
|
||||
// If given a number (and not this enum), the compiler will reject the overload, falling back to the (double, digit) version
|
||||
// We don't want hidden conversion of the first parameter to double, so it has to be as hard to do for the compiler as creating this enum
|
||||
enum class PrintBase {
|
||||
Dec = 10,
|
||||
Hex = 16,
|
||||
Oct = 8,
|
||||
Bin = 2
|
||||
};
|
||||
|
||||
// A simple feature list enumeration
|
||||
enum class SerialFeature {
|
||||
None = 0x00,
|
||||
MeatPack = 0x01, //!< Enabled when Meatpack is present
|
||||
BinaryFileTransfer = 0x02, //!< Enabled for BinaryFile transfer support (in the future)
|
||||
Virtual = 0x04, //!< Enabled for virtual serial port (like Telnet / Websocket / ...)
|
||||
Hookable = 0x08, //!< Enabled if the serial class supports a setHook method
|
||||
};
|
||||
ENUM_FLAGS(SerialFeature);
|
||||
|
||||
// flushTX is not implemented in all HAL, so use SFINAE to call the method where it is.
|
||||
CALL_IF_EXISTS_IMPL(void, flushTX);
|
||||
CALL_IF_EXISTS_IMPL(bool, connected, true);
|
||||
CALL_IF_EXISTS_IMPL(SerialFeature, features, SerialFeature::None);
|
||||
|
||||
// A simple forward struct to prevent the compiler from selecting print(double, int) as a default overload
|
||||
// for any type other than double/float. For double/float, a conversion exists so the call will be invisible.
|
||||
struct EnsureDouble {
|
||||
double a;
|
||||
operator double() { return a; }
|
||||
// If the compiler breaks on ambiguity here, it's likely because print(X, base) is called with X not a double/float, and
|
||||
// a base that's not a PrintBase value. This code is made to detect the error. You MUST set a base explicitly like this:
|
||||
//SERIAL_PRINT(v, PrintBase::Hex)
|
||||
EnsureDouble(double a) : a(a) {}
|
||||
EnsureDouble(float a) : a(a) {}
|
||||
};
|
||||
|
||||
// Using Curiously-Recurring Template Pattern here to avoid virtual table cost when compiling.
|
||||
// Since the real serial class is known at compile time, this results in the compiler writing
|
||||
// a completely efficient code.
|
||||
template <class Child>
|
||||
struct SerialBase {
|
||||
#if ENABLED(EMERGENCY_PARSER)
|
||||
const bool ep_enabled;
|
||||
EmergencyParser::State emergency_state;
|
||||
inline bool emergency_parser_enabled() { return ep_enabled; }
|
||||
SerialBase(bool ep_capable) : ep_enabled(ep_capable), emergency_state(EmergencyParser::State::EP_RESET) {}
|
||||
#else
|
||||
SerialBase(const bool) {}
|
||||
#endif
|
||||
|
||||
#define SerialChild static_cast<Child*>(this)
|
||||
|
||||
// Static dispatch methods below:
|
||||
// The most important method here is where it all ends to:
|
||||
void write(uint8_t c) { SerialChild->write(c); }
|
||||
|
||||
// Called when the parser finished processing an instruction, usually build to nothing
|
||||
void msgDone() const { SerialChild->msgDone(); }
|
||||
|
||||
// Called on initialization
|
||||
void begin(const long baudRate) { SerialChild->begin(baudRate); }
|
||||
|
||||
// Called on destruction
|
||||
void end() { SerialChild->end(); }
|
||||
|
||||
/** Check for available data from the port
|
||||
@param index The port index, usually 0 */
|
||||
int available(serial_index_t index=0) const { return SerialChild->available(index); }
|
||||
|
||||
/** Read a value from the port
|
||||
@param index The port index, usually 0 */
|
||||
int read(serial_index_t index=0) { return SerialChild->read(index); }
|
||||
|
||||
/** Combine the features of this serial instance and return it
|
||||
@param index The port index, usually 0 */
|
||||
SerialFeature features(serial_index_t index=0) const { return static_cast<const Child*>(this)->features(index); }
|
||||
|
||||
// Check if the serial port has a feature
|
||||
bool has_feature(serial_index_t index, SerialFeature flag) const { return (features(index) & flag) != SerialFeature::None; }
|
||||
|
||||
// Check if the serial port is connected (usually bypassed)
|
||||
bool connected() const { return SerialChild->connected(); }
|
||||
|
||||
// Redirect flush
|
||||
void flush() { SerialChild->flush(); }
|
||||
|
||||
// Not all implementation have a flushTX, so let's call them only if the child has the implementation
|
||||
void flushTX() { CALL_IF_EXISTS(void, SerialChild, flushTX); }
|
||||
|
||||
// Glue code here
|
||||
void write(const char *str) { while (*str) write(*str++); }
|
||||
void write(const uint8_t *buffer, size_t size) { while (size--) write(*buffer++); }
|
||||
void print(char *str) { write(str); }
|
||||
void print(const char *str) { write(str); }
|
||||
// No default argument to avoid ambiguity
|
||||
|
||||
// Define print for every fundamental integer type, to ensure that all redirect properly
|
||||
// to the correct underlying implementation.
|
||||
|
||||
// Prints are performed with a single size, to avoid needing multiple print functions.
|
||||
// The fixed integer size used for prints will be the larger of long or a pointer.
|
||||
#if __LONG_WIDTH__ >= __INTPTR_WIDTH__
|
||||
typedef long int_fixed_print_t;
|
||||
typedef unsigned long uint_fixed_print_t;
|
||||
#else
|
||||
typedef intptr_t int_fixed_print_t;
|
||||
typedef uintptr_t uint_fixed_print_t;
|
||||
|
||||
FORCE_INLINE void print(intptr_t c, PrintBase base) { printNumber_signed(c, base); }
|
||||
FORCE_INLINE void print(uintptr_t c, PrintBase base) { printNumber_unsigned(c, base); }
|
||||
#endif
|
||||
|
||||
FORCE_INLINE void print(char c, PrintBase base) { printNumber_signed(c, base); }
|
||||
FORCE_INLINE void print(short c, PrintBase base) { printNumber_signed(c, base); }
|
||||
FORCE_INLINE void print(int c, PrintBase base) { printNumber_signed(c, base); }
|
||||
FORCE_INLINE void print(long c, PrintBase base) { printNumber_signed(c, base); }
|
||||
FORCE_INLINE void print(unsigned char c, PrintBase base) { printNumber_unsigned(c, base); }
|
||||
FORCE_INLINE void print(unsigned short c, PrintBase base) { printNumber_unsigned(c, base); }
|
||||
FORCE_INLINE void print(unsigned int c, PrintBase base) { printNumber_unsigned(c, base); }
|
||||
FORCE_INLINE void print(unsigned long c, PrintBase base) { printNumber_unsigned(c, base); }
|
||||
|
||||
void print(EnsureDouble c, int digits) { printFloat(c, digits); }
|
||||
|
||||
// Forward the call to the former's method
|
||||
|
||||
// Default implementation for anything without a specialization
|
||||
// This handles integers since they are the most common
|
||||
template <typename T>
|
||||
void print(T c) { print(c, PrintBase::Dec); }
|
||||
|
||||
void print(float c) { print(c, 2); }
|
||||
void print(double c) { print(c, 2); }
|
||||
|
||||
void println(char *s) { print(s); println(); }
|
||||
void println(const char *s) { print(s); println(); }
|
||||
void println(float c, int digits) { print(c, digits); println(); }
|
||||
void println(double c, int digits) { print(c, digits); println(); }
|
||||
void println() { write('\r'); write('\n'); }
|
||||
|
||||
// Default implementations for types without a specialization. Handles integers.
|
||||
template <typename T>
|
||||
void println(T c, PrintBase base) { print(c, base); println(); }
|
||||
|
||||
template <typename T>
|
||||
void println(T c) { println(c, PrintBase::Dec); }
|
||||
|
||||
// Forward the call to the former's method
|
||||
void println(float c) { println(c, 2); }
|
||||
void println(double c) { println(c, 2); }
|
||||
|
||||
// Print a number with the given base
|
||||
NO_INLINE void printNumber_unsigned(uint_fixed_print_t n, PrintBase base) {
|
||||
if (n) {
|
||||
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
|
||||
int8_t i = 0;
|
||||
while (n) {
|
||||
buf[i++] = n % (uint_fixed_print_t)base;
|
||||
n /= (uint_fixed_print_t)base;
|
||||
}
|
||||
while (i--) write((char)(buf[i] + (buf[i] < 10 ? '0' : 'A' - 10)));
|
||||
}
|
||||
else write('0');
|
||||
}
|
||||
|
||||
NO_INLINE void printNumber_signed(int_fixed_print_t n, PrintBase base) {
|
||||
if (base == PrintBase::Dec && n < 0) {
|
||||
n = -n; // This works because all platforms Marlin's builds on are using 2-complement encoding for negative number
|
||||
// On such CPU, changing the sign of a number is done by inverting the bits and adding one, so if n = 0x80000000 = -2147483648 then
|
||||
// -n = 0x7FFFFFFF + 1 => 0x80000000 = 2147483648 (if interpreted as unsigned) or -2147483648 if interpreted as signed.
|
||||
// On non 2-complement CPU, there would be no possible representation for 2147483648.
|
||||
write('-');
|
||||
}
|
||||
printNumber_unsigned((uint_fixed_print_t)n , base);
|
||||
}
|
||||
|
||||
// Print a decimal number
|
||||
NO_INLINE void printFloat(double number, uint8_t digits) {
|
||||
// Handle negative numbers
|
||||
if (number < 0.0) {
|
||||
write('-');
|
||||
number = -number;
|
||||
}
|
||||
|
||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||
double rounding = 0.5;
|
||||
for (uint8_t i = 0; i < digits; ++i) rounding *= 0.1;
|
||||
number += rounding;
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
double remainder = number - (double)int_part;
|
||||
printNumber_unsigned(int_part, PrintBase::Dec);
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
if (digits) {
|
||||
write('.');
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits--) {
|
||||
remainder *= 10.0;
|
||||
unsigned long toPrint = (unsigned long)remainder;
|
||||
printNumber_unsigned(toPrint, PrintBase::Dec);
|
||||
remainder -= toPrint;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// All serial instances will be built by chaining the features required
|
||||
// for the function in the form of a template type definition.
|
||||
308
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial_hook.h
Normal file
308
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/serial_hook.h
Normal file
@@ -0,0 +1,308 @@
|
||||
/**
|
||||
* 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 "serial_base.h"
|
||||
|
||||
// A mask containing a bitmap of the serial port to act upon
|
||||
// This is written to ensure a serial index is never used as a serial mask
|
||||
class SerialMask {
|
||||
uint8_t mask;
|
||||
|
||||
// This constructor is private to ensure you can't convert an index to a mask
|
||||
// The compiler will stop here if you are mixing index and mask in your code.
|
||||
// If you need to, you'll have to use the explicit static "from" method here
|
||||
SerialMask(const serial_index_t);
|
||||
|
||||
public:
|
||||
inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; }
|
||||
inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); }
|
||||
inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); }
|
||||
static SerialMask from(const serial_index_t index) {
|
||||
if (index.valid()) return SerialMask(_BV(index.index));
|
||||
return SerialMask(0); // A invalid index mean no output
|
||||
}
|
||||
|
||||
constexpr SerialMask(const uint8_t mask) : mask(mask) {}
|
||||
constexpr SerialMask(const SerialMask &rs) : mask(rs.mask) {} // Can't use = default here since not all frameworks support this
|
||||
|
||||
SerialMask& operator=(const SerialMask &rs) { mask = rs.mask; return *this; }
|
||||
|
||||
static constexpr uint8_t All = 0xFF;
|
||||
};
|
||||
|
||||
// The most basic serial class: it dispatch to the base serial class with no hook whatsoever. This will compile to nothing but the base serial class
|
||||
template <class SerialT>
|
||||
struct BaseSerial : public SerialBase< BaseSerial<SerialT> >, public SerialT {
|
||||
typedef SerialBase< BaseSerial<SerialT> > BaseClassT;
|
||||
|
||||
// It's required to implement a write method here to help compiler disambiguate what method to call
|
||||
using SerialT::write;
|
||||
using SerialT::flush;
|
||||
|
||||
void msgDone() {}
|
||||
|
||||
// We don't care about indices here, since if one can call us, it's the right index anyway
|
||||
int available(serial_index_t) { return (int)SerialT::available(); }
|
||||
int read(serial_index_t) { return (int)SerialT::read(); }
|
||||
bool connected() { return CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected);; }
|
||||
void flushTX() { CALL_IF_EXISTS(void, static_cast<SerialT*>(this), flushTX); }
|
||||
|
||||
SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, static_cast<const SerialT*>(this), features, index); }
|
||||
|
||||
// Two implementations of the same method exist in both base classes so indicate the right one
|
||||
using SerialT::available;
|
||||
using SerialT::read;
|
||||
using SerialT::begin;
|
||||
using SerialT::end;
|
||||
|
||||
using BaseClassT::print;
|
||||
using BaseClassT::println;
|
||||
|
||||
BaseSerial(const bool e) : BaseClassT(e) {}
|
||||
|
||||
// Forward constructor
|
||||
template <typename... Args>
|
||||
BaseSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...) {}
|
||||
};
|
||||
|
||||
// A serial with a condition checked at runtime for its output
|
||||
// A bit less efficient than static dispatching but since it's only used for ethernet's serial output right now, it's ok.
|
||||
template <class SerialT>
|
||||
struct ConditionalSerial : public SerialBase< ConditionalSerial<SerialT> > {
|
||||
typedef SerialBase< ConditionalSerial<SerialT> > BaseClassT;
|
||||
|
||||
bool & condition;
|
||||
SerialT & out;
|
||||
NO_INLINE size_t write(uint8_t c) { if (condition) return out.write(c); return 0; }
|
||||
void flush() { if (condition) out.flush(); }
|
||||
void begin(long br) { out.begin(br); }
|
||||
void end() { out.end(); }
|
||||
|
||||
void msgDone() {}
|
||||
bool connected() { return CALL_IF_EXISTS(bool, &out, connected); }
|
||||
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
|
||||
|
||||
int available(serial_index_t) { return (int)out.available(); }
|
||||
int read(serial_index_t) { return (int)out.read(); }
|
||||
int available() { return (int)out.available(); }
|
||||
int read() { return (int)out.read(); }
|
||||
SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, &out, features, index); }
|
||||
|
||||
ConditionalSerial(bool & conditionVariable, SerialT & out, const bool e) : BaseClassT(e), condition(conditionVariable), out(out) {}
|
||||
};
|
||||
|
||||
// A simple forward class that taking a reference to an existing serial instance (likely created in their respective framework)
|
||||
template <class SerialT>
|
||||
struct ForwardSerial : public SerialBase< ForwardSerial<SerialT> > {
|
||||
typedef SerialBase< ForwardSerial<SerialT> > BaseClassT;
|
||||
|
||||
SerialT & out;
|
||||
NO_INLINE size_t write(uint8_t c) { return out.write(c); }
|
||||
void flush() { out.flush(); }
|
||||
void begin(long br) { out.begin(br); }
|
||||
void end() { out.end(); }
|
||||
|
||||
void msgDone() {}
|
||||
// Existing instances implement Arduino's operator bool, so use that if it's available
|
||||
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
|
||||
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
|
||||
|
||||
int available(serial_index_t) { return (int)out.available(); }
|
||||
int read(serial_index_t) { return (int)out.read(); }
|
||||
int available() { return (int)out.available(); }
|
||||
int read() { return (int)out.read(); }
|
||||
SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, &out, features, index); }
|
||||
|
||||
ForwardSerial(const bool e, SerialT & out) : BaseClassT(e), out(out) {}
|
||||
};
|
||||
|
||||
// A class that can be hooked and unhooked at runtime, useful to capture the output of the serial interface
|
||||
template <class SerialT>
|
||||
struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public SerialT {
|
||||
typedef SerialBase< RuntimeSerial<SerialT> > BaseClassT;
|
||||
typedef void (*WriteHook)(void * userPointer, uint8_t c);
|
||||
typedef void (*EndOfMessageHook)(void * userPointer);
|
||||
|
||||
WriteHook writeHook;
|
||||
EndOfMessageHook eofHook;
|
||||
void * userPointer;
|
||||
|
||||
NO_INLINE size_t write(uint8_t c) {
|
||||
if (writeHook) writeHook(userPointer, c);
|
||||
return SerialT::write(c);
|
||||
}
|
||||
|
||||
NO_INLINE void msgDone() {
|
||||
if (eofHook) eofHook(userPointer);
|
||||
}
|
||||
|
||||
int available(serial_index_t) { return (int)SerialT::available(); }
|
||||
int read(serial_index_t) { return (int)SerialT::read(); }
|
||||
using SerialT::available;
|
||||
using SerialT::read;
|
||||
using SerialT::flush;
|
||||
using SerialT::begin;
|
||||
using SerialT::end;
|
||||
|
||||
using BaseClassT::print;
|
||||
using BaseClassT::println;
|
||||
|
||||
// Underlying implementation might use Arduino's bool operator
|
||||
bool connected() {
|
||||
return Private::HasMember_connected<SerialT>::value
|
||||
? CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected)
|
||||
: static_cast<SerialT*>(this)->operator bool();
|
||||
}
|
||||
|
||||
void flushTX() { CALL_IF_EXISTS(void, static_cast<SerialT*>(this), flushTX); }
|
||||
|
||||
// Append Hookable for this class
|
||||
SerialFeature features(serial_index_t index) const { return SerialFeature::Hookable | CALL_IF_EXISTS(SerialFeature, static_cast<const SerialT*>(this), features, index); }
|
||||
|
||||
void setHook(WriteHook writeHook=0, EndOfMessageHook eofHook=0, void * userPointer=0) {
|
||||
// Order is important here as serial code can be called inside interrupts
|
||||
// When setting a hook, the user pointer must be set first so if writeHook is called as soon as it's set, it'll be valid
|
||||
if (userPointer) this->userPointer = userPointer;
|
||||
this->writeHook = writeHook;
|
||||
this->eofHook = eofHook;
|
||||
// Order is important here because of asynchronous access here
|
||||
// When unsetting a hook, the user pointer must be unset last so that any pending writeHook is still using the old pointer
|
||||
if (!userPointer) this->userPointer = 0;
|
||||
}
|
||||
|
||||
RuntimeSerial(const bool e) : BaseClassT(e), writeHook(0), eofHook(0), userPointer(0) {}
|
||||
|
||||
// Forward constructor
|
||||
template <typename... Args>
|
||||
RuntimeSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...), writeHook(0), eofHook(0), userPointer(0) {}
|
||||
};
|
||||
|
||||
#define _S_CLASS(N) class Serial##N##T,
|
||||
#define _S_NAME(N) Serial##N##T,
|
||||
|
||||
template < REPEAT(NUM_SERIAL, _S_CLASS) const uint8_t offset=0, const uint8_t step=1 >
|
||||
struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > {
|
||||
typedef SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > BaseClassT;
|
||||
|
||||
#undef _S_CLASS
|
||||
#undef _S_NAME
|
||||
|
||||
SerialMask portMask;
|
||||
|
||||
#define _S_DECLARE(N) Serial##N##T & serial##N;
|
||||
REPEAT(NUM_SERIAL, _S_DECLARE);
|
||||
#undef _S_DECLARE
|
||||
|
||||
static constexpr uint8_t Usage = _BV(step) - 1; // A bit mask containing 'step' bits
|
||||
|
||||
#define _OUT_PORT(N) (Usage << (offset + (step * N))),
|
||||
static constexpr uint8_t output[] = { REPEAT(NUM_SERIAL, _OUT_PORT) };
|
||||
#undef _OUT_PORT
|
||||
|
||||
#define _OUT_MASK(N) | output[N]
|
||||
static constexpr uint8_t ALL = 0 REPEAT(NUM_SERIAL, _OUT_MASK);
|
||||
#undef _OUT_MASK
|
||||
|
||||
NO_INLINE void write(uint8_t c) {
|
||||
#define _S_WRITE(N) if (portMask.enabled(output[N])) serial##N.write(c);
|
||||
REPEAT(NUM_SERIAL, _S_WRITE);
|
||||
#undef _S_WRITE
|
||||
}
|
||||
NO_INLINE void msgDone() {
|
||||
#define _S_DONE(N) if (portMask.enabled(output[N])) serial##N.msgDone();
|
||||
REPEAT(NUM_SERIAL, _S_DONE);
|
||||
#undef _S_DONE
|
||||
}
|
||||
int available(serial_index_t index) {
|
||||
uint8_t pos = offset;
|
||||
#define _S_AVAILABLE(N) if (index.within(pos, pos + step - 1)) return serial##N.available(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_AVAILABLE);
|
||||
#undef _S_AVAILABLE
|
||||
return false;
|
||||
}
|
||||
int read(serial_index_t index) {
|
||||
uint8_t pos = offset;
|
||||
#define _S_READ(N) if (index.within(pos, pos + step - 1)) return serial##N.read(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_READ);
|
||||
#undef _S_READ
|
||||
return -1;
|
||||
}
|
||||
void begin(const long br) {
|
||||
#define _S_BEGIN(N) if (portMask.enabled(output[N])) serial##N.begin(br);
|
||||
REPEAT(NUM_SERIAL, _S_BEGIN);
|
||||
#undef _S_BEGIN
|
||||
}
|
||||
void end() {
|
||||
#define _S_END(N) if (portMask.enabled(output[N])) serial##N.end();
|
||||
REPEAT(NUM_SERIAL, _S_END);
|
||||
#undef _S_END
|
||||
}
|
||||
bool connected() {
|
||||
bool ret = true;
|
||||
#define _S_CONNECTED(N) if (portMask.enabled(output[N]) && !CALL_IF_EXISTS(bool, &serial##N, connected)) ret = false;
|
||||
REPEAT(NUM_SERIAL, _S_CONNECTED);
|
||||
#undef _S_CONNECTED
|
||||
return ret;
|
||||
}
|
||||
|
||||
using BaseClassT::available;
|
||||
using BaseClassT::read;
|
||||
|
||||
// Redirect flush
|
||||
NO_INLINE void flush() {
|
||||
#define _S_FLUSH(N) if (portMask.enabled(output[N])) serial##N.flush();
|
||||
REPEAT(NUM_SERIAL, _S_FLUSH);
|
||||
#undef _S_FLUSH
|
||||
}
|
||||
NO_INLINE void flushTX() {
|
||||
#define _S_FLUSHTX(N) if (portMask.enabled(output[N])) CALL_IF_EXISTS(void, &serial0, flushTX);
|
||||
REPEAT(NUM_SERIAL, _S_FLUSHTX);
|
||||
#undef _S_FLUSHTX
|
||||
}
|
||||
|
||||
// Forward feature queries
|
||||
SerialFeature features(serial_index_t index) const {
|
||||
uint8_t pos = offset;
|
||||
#define _S_FEATURES(N) if (index.within(pos, pos + step - 1)) return serial##N.features(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_FEATURES);
|
||||
#undef _S_FEATURES
|
||||
return SerialFeature::None;
|
||||
}
|
||||
|
||||
#define _S_REFS(N) Serial##N##T & serial##N,
|
||||
#define _S_INIT(N) ,serial##N (serial##N)
|
||||
|
||||
MultiSerial(REPEAT(NUM_SERIAL, _S_REFS) const SerialMask mask=ALL, const bool e=false)
|
||||
: BaseClassT(e), portMask(mask) REPEAT(NUM_SERIAL, _S_INIT) {}
|
||||
|
||||
};
|
||||
|
||||
// Build the actual serial object depending on current configuration
|
||||
#define Serial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, BaseSerial)
|
||||
#define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial)
|
||||
#if HAS_MULTI_SERIAL
|
||||
#define Serial2Class ConditionalSerial
|
||||
#if NUM_SERIAL >= 3
|
||||
#define Serial3Class ConditionalSerial
|
||||
#endif
|
||||
#endif
|
||||
1125
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/types.h
Normal file
1125
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/types.h
Normal file
File diff suppressed because it is too large
Load Diff
179
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/utility.cpp
Normal file
179
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/utility.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* 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 "utility.h"
|
||||
|
||||
#include "../MarlinCore.h"
|
||||
#include "../module/temperature.h"
|
||||
|
||||
void safe_delay(millis_t ms) {
|
||||
while (ms > 50) {
|
||||
ms -= 50;
|
||||
delay(50);
|
||||
thermalManager.task();
|
||||
}
|
||||
delay(ms);
|
||||
thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made
|
||||
}
|
||||
|
||||
// A delay to provide brittle hosts time to receive bytes
|
||||
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
|
||||
|
||||
#include "../gcode/gcode.h" // for set_autoreport_paused
|
||||
|
||||
void serial_delay(const millis_t ms) {
|
||||
const bool was = gcode.set_autoreport_paused(true);
|
||||
safe_delay(ms);
|
||||
gcode.set_autoreport_paused(was);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
|
||||
#include "../module/probe.h"
|
||||
#include "../module/motion.h"
|
||||
#include "../module/planner.h"
|
||||
#include "../libs/numtostr.h"
|
||||
#include "../feature/bedlevel/bedlevel.h"
|
||||
|
||||
void log_machine_info() {
|
||||
SERIAL_ECHOLNPGM("Machine Type: "
|
||||
TERN_(DELTA, "Delta")
|
||||
TERN_(IS_SCARA, "SCARA")
|
||||
TERN_(IS_CORE, "Core")
|
||||
TERN_(MARKFORGED_XY, "MarkForgedXY")
|
||||
TERN_(MARKFORGED_YX, "MarkForgedYX")
|
||||
TERN_(IS_CARTESIAN, "Cartesian")
|
||||
);
|
||||
|
||||
SERIAL_ECHOLNPGM("Probe: "
|
||||
TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
|
||||
TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
|
||||
TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
|
||||
TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
|
||||
TERN_(BD_SENSOR, "BD_SENSOR")
|
||||
TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
|
||||
TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
|
||||
TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
|
||||
TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
|
||||
TERN_(MAGLEV4, "MAGLEV4")
|
||||
IF_DISABLED(PROBE_SELECTED, "NONE")
|
||||
);
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
|
||||
#if !HAS_PROBE_XY_OFFSET
|
||||
SERIAL_ECHOPGM("Probe Offset X0 Y0 Z", probe.offset.z, " (");
|
||||
#else
|
||||
SERIAL_ECHOPGM_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z);
|
||||
if (probe.offset_xy.x > 0)
|
||||
SERIAL_ECHOPGM(" (Right");
|
||||
else if (probe.offset_xy.x < 0)
|
||||
SERIAL_ECHOPGM(" (Left");
|
||||
else if (probe.offset_xy.y != 0)
|
||||
SERIAL_ECHOPGM(" (Middle");
|
||||
else
|
||||
SERIAL_ECHOPGM(" (Aligned With");
|
||||
|
||||
if (probe.offset_xy.y > 0)
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
|
||||
else if (probe.offset_xy.y < 0)
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
|
||||
else if (probe.offset_xy.x != 0)
|
||||
SERIAL_ECHOPGM("-Center");
|
||||
|
||||
SERIAL_ECHOPGM(" & ");
|
||||
|
||||
#endif
|
||||
|
||||
SERIAL_ECHOF(probe.offset.z < 0 ? F("Below") : probe.offset.z > 0 ? F("Above") : F("Same Z as"));
|
||||
SERIAL_ECHOLNPGM(" Nozzle)");
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_ABL_OR_UBL
|
||||
SERIAL_ECHOPGM("Auto Bed Leveling: "
|
||||
TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
|
||||
TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
|
||||
TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
|
||||
TERN_(AUTO_BED_LEVELING_UBL, "UBL")
|
||||
);
|
||||
|
||||
if (planner.leveling_active) {
|
||||
SERIAL_ECHOLNPGM(" (enabled)");
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (planner.z_fade_height)
|
||||
SERIAL_ECHOLNPGM("Z Fade: ", planner.z_fade_height);
|
||||
#endif
|
||||
#if ABL_PLANAR
|
||||
SERIAL_ECHOPGM("ABL Adjustment");
|
||||
LOOP_NUM_AXES(a) {
|
||||
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]));
|
||||
serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]);
|
||||
}
|
||||
#else
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
SERIAL_ECHOPGM("UBL Adjustment Z");
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
SERIAL_ECHOPGM("ABL Adjustment Z");
|
||||
#endif
|
||||
const float rz = bedlevel.get_z_correction(current_position);
|
||||
SERIAL_ECHO(ftostr43sign(rz, '+'));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (planner.z_fade_height) {
|
||||
SERIAL_ECHOPGM(" (", ftostr43sign(rz * planner.fade_scaling_factor_for_z(current_position.z), '+'));
|
||||
SERIAL_CHAR(')');
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM(" (disabled)");
|
||||
|
||||
SERIAL_EOL();
|
||||
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
SERIAL_ECHOPGM("Mesh Bed Leveling");
|
||||
if (planner.leveling_active) {
|
||||
SERIAL_ECHOLNPGM(" (enabled)");
|
||||
const float z_offset = bedlevel.get_z_offset(),
|
||||
z_correction = bedlevel.get_z_correction(current_position);
|
||||
SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(z_offset + z_correction, '+'));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
if (planner.z_fade_height) {
|
||||
SERIAL_ECHOPGM(" (", ftostr43sign(
|
||||
z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+'
|
||||
));
|
||||
SERIAL_CHAR(')');
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOPGM(" (disabled)");
|
||||
|
||||
SERIAL_EOL();
|
||||
|
||||
#endif // MESH_BED_LEVELING
|
||||
}
|
||||
|
||||
#endif // DEBUG_LEVELING_FEATURE
|
||||
94
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/utility.h
Normal file
94
creality-ender3/Marlin-2.1.2.4/Marlin/src/core/utility.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* 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/MarlinConfigPre.h"
|
||||
#include "../core/types.h"
|
||||
#include "../core/millis_t.h"
|
||||
|
||||
void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive.
|
||||
|
||||
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
|
||||
void serial_delay(const millis_t ms);
|
||||
#else
|
||||
inline void serial_delay(const millis_t) {}
|
||||
#endif
|
||||
|
||||
#if GRID_MAX_POINTS
|
||||
|
||||
// 16x16 bit arrays
|
||||
template <int W, int H>
|
||||
struct FlagBits {
|
||||
bits_t(W) flags[H];
|
||||
void fill() { memset(flags, 0xFF, sizeof(flags)); }
|
||||
void reset() { memset(flags, 0x00, sizeof(flags)); }
|
||||
void unmark(const uint8_t x, const uint8_t y) { CBI(flags[y], x); }
|
||||
void mark(const uint8_t x, const uint8_t y) { SBI(flags[y], x); }
|
||||
bool marked(const uint8_t x, const uint8_t y) { return TEST(flags[y], x); }
|
||||
inline void unmark(const xy_int8_t &xy) { unmark(xy.x, xy.y); }
|
||||
inline void mark(const xy_int8_t &xy) { mark(xy.x, xy.y); }
|
||||
inline bool marked(const xy_int8_t &xy) { return marked(xy.x, xy.y); }
|
||||
};
|
||||
|
||||
typedef FlagBits<GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y> MeshFlags;
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
void log_machine_info();
|
||||
#else
|
||||
#define log_machine_info() NOOP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A restorer instance remembers a variable's value before setting a
|
||||
* new value, then restores the old value when it goes out of scope.
|
||||
* Put operator= on your type to get extended behavior on value change.
|
||||
*/
|
||||
template<typename T>
|
||||
class restorer {
|
||||
T& ref_;
|
||||
T val_;
|
||||
public:
|
||||
restorer(T& perm) : ref_(perm), val_(perm) {}
|
||||
restorer(T& perm, T temp_val) : ref_(perm), val_(perm) { perm = temp_val; }
|
||||
~restorer() { restore(); }
|
||||
inline void restore() { ref_ = val_; }
|
||||
};
|
||||
|
||||
#define REMEMBER(N,X,V...) restorer<__typeof__(X)> restorer_##N(X, ##V)
|
||||
#define RESTORE(N) restorer_##N.restore()
|
||||
|
||||
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
|
||||
// Axis names for G-code parsing, reports, etc.
|
||||
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
|
||||
#if NUM_AXES <= XYZ && !HAS_EXTRUDERS
|
||||
#define AXIS_CHAR(A) ((char)('X' + A))
|
||||
#define IAXIS_CHAR AXIS_CHAR
|
||||
#else
|
||||
const xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K', 'U', 'V', 'W');
|
||||
#define AXIS_CHAR(A) axis_codes[A]
|
||||
#define IAXIS_CHAR(A) iaxis_codes[A]
|
||||
#endif
|
||||
Reference in New Issue
Block a user