Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate some code out of MarlinCore #20832

Merged
merged 2 commits into from
Jan 21, 2021

Conversation

thinkyhead
Copy link
Member

MarlinCore should be as light as possible and just encapsulate its own global state flags, setup, and loop. This PR migrates items to other files according to the best fit.

@thinkyhead thinkyhead added PR: Coding Standards T: Development Makefiles, PlatformIO, Python scripts, etc. PR: General Cleanup labels Jan 20, 2021
@thinkyhead thinkyhead force-pushed the bf2_MISC_FIXES_DEC branch 9 times, most recently from 3d4afb2 to 5a5aacf Compare January 21, 2021 01:22
@thinkyhead thinkyhead force-pushed the bf2_MISC_FIXES_DEC branch 4 times, most recently from 396a105 to 74e1662 Compare January 21, 2021 01:54
@X-Ryl669
Copy link
Contributor

X-Ryl669 commented Jan 21, 2021

There's already a very good documentation about using Marlin (for users) but I think a documentation about developing for Marlin is a bit lagging behind.

I don't know how you think about this, but I think that adding some documentation in the docs/ folder about Marlin's architecture is beneficial for new developers like me. While you are orthogonalizing the code, I think it'll be great if you started describing the overall architecture & modules.

I'll try to add such documentation for the PR I've opened, so bit-by-bit, it'll be good.

@thinkyhead
Copy link
Member Author

Marlin's architecture is in flux, but one might write some general notes about the set of patterns we've ended with up at this point in time as a result of its evolution by selection. The website (MarlinDocumentation repo) would be the better place to post documentation which is intended to be seen. The 'docs' folder is probably going to go away, with the "Bresenham" document being moved to the website as a topical article.

@thinkyhead thinkyhead merged commit c0870d4 into MarlinFirmware:bugfix-2.0.x Jan 21, 2021
@thinkyhead thinkyhead deleted the bf2_MISC_FIXES_DEC branch January 21, 2021 09:40
@X-Ryl669
Copy link
Contributor

I agree that Bresemham description should be in the external documentation since it's not related to this code directly. Yet a documentation about what is the current state of the code should be in the current repository IMHO so it can easily be kept in sync. From experience with large code base at work, external documentation is never in sync so it's more or less useless.

That's my current feeling while trying to understand the huge code base, some help would have been really appreciated and a good documentation helps.

@kad
Copy link
Contributor

kad commented Jan 21, 2021

This PR broke compilation of bugfix-2.0.x if SHOW_REMAINING_TIME and ROTATE_PROGRESS_DISPLAY are enabled:

Marlin/src/lcd/dogm/status_screen_DOGM.cpp: In static member function 'static void MarlinUI::draw_status_screen()':
Marlin/src/lcd/dogm/status_screen_DOGM.cpp:706:60: error: 'E_LBL' was not declared in this scope
           lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL);
                                                            ^~~~~
*** [.pio/build/anycubic_mega_zero_btt_mini_bl_e0fan/src/src/lcd/dogm/status_screen_DOGM.cpp.o] Error 1

It can be fixed with simple patch below, but probably there is a better way:

diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
index 985041ede5..22e620098c 100644
--- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
+++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
@@ -687,6 +687,8 @@ void MarlinUI::draw_status_screen() {

       #if ALL(DOGM_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)

+        extern const char E_LBL[];
+
         if (prev_blink != blink) {
           prev_blink = blink;
           if (++progress_state >= 3) progress_state = 0;

@qwewer0
Copy link
Contributor

qwewer0 commented Jan 21, 2021

@kad Mine compiles just fine if DOGM_SD_PERCENT, SHOW_REMAINING_TIME and ROTATE_PROGRESS_DISPLAY are all enabled.

@JayceeB1
Copy link

JayceeB1 commented Jan 21, 2021

Can't compile too with those modifications

In file included from Marlin\src\lcd\dogm../../inc/../core/boards.h:24,

             from Marlin\src\lcd\dogm\../../inc/MarlinConfigPre.h:37,
             from Marlin\src\lcd\dogm\status_screen_DOGM.cpp:28:

Marlin\src\lcd\dogm\status_screen_DOGM.cpp: In static member function 'static void MarlinUI::draw_status_screen()':
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:53: error: 'printingIsActive' was not declared in this scope
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
| ^~~~~~~~~~~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:415:26: note: in definition of macro 'THIRD'
415 | #define THIRD(a,b,c,...) c
| ^
Marlin\src\lcd\dogm../../inc/../core/macros.h:190:29: note: in expansion of macro '___TERN'
190 | #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
| ^~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:189:29: note: in expansion of macro '__TERN'
189 | #define _TERN(E,V...) _TERN(CAT(T,E),V) // Prepend 'T' to get 'T_0' or 'T_1'
| ^~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:186:29: note: in expansion of macro '_TERN'
186 | #define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0'
| ^~~~~
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:29: note: in expansion of macro 'TERN0'
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
| ^~~~~
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:75: error: 'marlin_state' was not declared in this scope
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
Compiling .pio\build\LPC1769\src\src\lcd\menu\menu_filament.cpp.o
| ^~~~~~~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:415:26: note: in definition of macro 'THIRD'
415 | #define THIRD(a,b,c,...) c
| ^
Marlin\src\lcd\dogm../../inc/../core/macros.h:190:29: note: in expansion of macro '___TERN'
190 | #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
| ^~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:189:29: note: in expansion of macro '__TERN'
189 | #define _TERN(E,V...) _TERN(CAT(T,E),V) // Prepend 'T' to get 'T_0' or 'T_1'
| ^~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:186:29: note: in expansion of macro '_TERN'
186 | #define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0'
| ^~~~~
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:29: note: in expansion of macro 'TERN0'
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
| ^~~~~
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:91: error: 'MF_SD_COMPLETE' was not declared in this scope
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
| ^~~~~~~~~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:415:26: note: in definition of macro 'THIRD'
415 | #define THIRD(a,b,c,...) c
| ^
Marlin\src\lcd\dogm../../inc/../core/macros.h:190:29: note: in expansion of macro '___TERN'
190 | #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
| ^~~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:189:29: note: in expansion of macro '__TERN'
189 | #define _TERN(E,V...) _TERN(CAT(T,E),V) // Prepend 'T' to get 'T_0' or 'T_1'
| ^~~~~~
Marlin\src\lcd\dogm../../inc/../core/macros.h:186:29: note: in expansion of macro '_TERN'
186 | #define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0'
| ^~~~~
Marlin\src\lcd\dogm\status_screen_DOGM.cpp:433:29: note: in expansion of macro 'TERN0'
433 | const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
| ^~~~~
*** [.pio\build\LPC1769\src\src\lcd\dogm\status_screen_DOGM.cpp.o] Error 1

@kad
Copy link
Contributor

kad commented Jan 21, 2021

@kad Mine compiles just fine if DOGM_SD_PERCENT, SHOW_REMAINING_TIME and ROTATE_PROGRESS_DISPLAY are all enabled.

Steps to reproduce:

  • checkout bugfix-2.0.x
  • cp ../Configurations/config/examples/Creality/Ender-3/BigTreeTech\ SKR\ Mini\ E3\ 2.0/* Marlin/
  • modify Configuration_adv.h to enable DOGM_SD_PERCENT, SHOW_REMAINING_TIME, USE_M73_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY (diff compared to examples repo below)
  • pio run -e STM32F103RC_btt

Result:

(pio) kad@hc:~/git/Marlin$ git show-ref --head HEAD | grep -v remotes
d879853e8f9902a407dbf3282fa12fc7d49d3c94 HEAD
(pio) kad@hc:~/git/Marlin$ git status
On branch bugfix-2.0.x
Your branch is up to date with 'upstream/bugfix-2.0.x'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   Marlin/Configuration.h
	modified:   Marlin/Configuration_adv.h

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	Marlin/_Bootscreen.h
	Marlin/_Statusscreen.h

no changes added to commit (use "git add" and/or "git commit -a")
(pio) kad@hc:~/git/Marlin$ pio run -e STM32F103RC_btt
....
Marlin/src/lcd/dogm/status_screen_DOGM.cpp: In static member function 'static void MarlinUI::draw_status_screen()':
Marlin/src/lcd/dogm/status_screen_DOGM.cpp:706:60: error: 'E_LBL' was not declared in this scope
           lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL);
                                                            ^~~~~
*** [.pio/build/STM32F103RC_btt/src/src/lcd/dogm/status_screen_DOGM.cpp.o] Error 1
=================================================== [FAILED] Took 3.46 seconds ===================================================

Environment      Status    Duration
---------------  --------  ------------
STM32F103RC_btt  FAILED    00:00:03.460
diff -u "../Configurations/config/examples/Creality/Ender-3/BigTreeTech SKR Mini E3 2.0/Configuration_adv.h" Marlin/Configuration_adv.h
--- "../Configurations/config/examples/Creality/Ender-3/BigTreeTech SKR Mini E3 2.0/Configuration_adv.h"	2021-01-21 19:35:01.132357657 +0200
+++ Marlin/Configuration_adv.h	2021-01-21 20:05:24.474831188 +0200
@@ -1164,10 +1164,10 @@
 #endif

 #if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) && ANY(HAS_MARLINUI_U8GLIB, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, EXTENSIBLE_UI)
-  //#define SHOW_REMAINING_TIME       // Display estimated time to completion
+  #define SHOW_REMAINING_TIME       // Display estimated time to completion
   #if ENABLED(SHOW_REMAINING_TIME)
-    //#define USE_M73_REMAINING_TIME  // Use remaining time from M73 command instead of estimation
-    //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
+    #define USE_M73_REMAINING_TIME  // Use remaining time from M73 command instead of estimation
+    #define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time
   #endif

   #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI)
@@ -1420,7 +1420,7 @@
  */
 #if HAS_MARLINUI_U8GLIB
   // Show SD percentage next to the progress bar
-  //#define DOGM_SD_PERCENT
+  #define DOGM_SD_PERCENT

   // Save many cycles by drawing a hollow frame or no frame on the Info Screen
   //#define XYZ_NO_FRAME

JayceeB1 added a commit to JayceeB1/Marlin that referenced this pull request Jan 21, 2021
JayceeB1 added a commit to JayceeB1/Marlin that referenced this pull request Jan 21, 2021
thinkyhead pushed a commit that referenced this pull request Jan 25, 2021
thinkyhead pushed a commit that referenced this pull request Jan 25, 2021
thinkyhead pushed a commit that referenced this pull request Jan 25, 2021
Jyers pushed a commit to Jyers/Marlin that referenced this pull request Feb 3, 2021
Jyers pushed a commit to Jyers/Marlin that referenced this pull request Feb 3, 2021
Jyers pushed a commit to Jyers/Marlin that referenced this pull request Feb 3, 2021
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
kpishere pushed a commit to kpishere/Marlin that referenced this pull request Feb 19, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 25, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Feb 26, 2021
zillarob pushed a commit to zillarob/Marlin that referenced this pull request Mar 11, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
W4tel-BiDi pushed a commit to W4tel-BiDi/Marlin that referenced this pull request Apr 5, 2021
thinkyhead added a commit to thinkyhead/Marlin that referenced this pull request Apr 29, 2021
thinkyhead pushed a commit that referenced this pull request Apr 30, 2021
thinkyhead pushed a commit that referenced this pull request Apr 30, 2021
thinkyhead pushed a commit that referenced this pull request Apr 30, 2021
thinkyhead pushed a commit that referenced this pull request Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Coding Standards PR: General Cleanup T: Development Makefiles, PlatformIO, Python scripts, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants