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

Encapsulate Stepper, Planner, Endstops in singleton classes #3631

Merged
merged 5 commits into from
May 1, 2016

Conversation

thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented Apr 28, 2016

Improving the semantics of the codebase with singletons.

This PR leaves the code "intact", but:

  • Wraps the stepper as a singleton class named Stepper.
  • Instantiates a Stepper named stepper.
  • Wraps the endstops manager as a singleton class named Endstops.
  • Instantiates an Endstops named endstops.
  • Wraps the planner as a singleton class named Planner.
  • Instantiates a Planner named planner.
  • Removes st_ and plan_ prefixes from the method names.
  • Modifies code to use the stepper., planner., and endstops. objects.
  • Some other minor changes to facilitate the implementation.

Compiles with various options, but we'll see how Travis likes it. The first time I installed this on my machine it just worked. Not too surprising, as this is almost entirely a stylistic change.

It should be noted that a bug is fixed here also in the process:

  • dock_sled was disabling the probe when undocked, and enabling it when docked. That is now reversed. I may patch that separately.

@thinkyhead
Copy link
Member Author

Travis CI has been showing me the symbols I missed and I've been patching them up. But I have been called away so I will have to pick this up later!

@thinkyhead thinkyhead force-pushed the rc_singletons branch 2 times, most recently from 1d8e07f to b38903d Compare April 29, 2016 02:39
@thinkyhead
Copy link
Member Author

thinkyhead commented Apr 29, 2016

How can I coax the compiler into inlining the Stepper::isr function in the stepper ISR? Do I have to make it FORCE_INLINE it in stepper.h? It would be good to save the cost of a method call.

@thinkyhead thinkyhead force-pushed the rc_singletons branch 5 times, most recently from b356346 to 6e5963c Compare April 29, 2016 04:33
@thinkyhead
Copy link
Member Author

thinkyhead commented Apr 29, 2016

This finally passes all the checks in .travis.yml.

I have a Temperature singleton ready to go as a set of commits on top of this.

As usual, please look hard for any accidental typos or logical errors.

#if HAS_DIGIPOTSS

// From Arduino DigitalPotControl example
void digitalPotWrite(int address, int value) {
Stepper::void digitalPotWrite(int address, int value) {
Copy link

@ghost ghost Apr 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is void Stepper::digitalPotWrite(int address, int value) { right? (same comment in PR #3643)

@thinkyhead thinkyhead force-pushed the rc_singletons branch 4 times, most recently from 535ad78 to a59d25d Compare April 30, 2016 22:27
@thinkyhead thinkyhead merged commit c214556 into MarlinFirmware:RCBugFix May 1, 2016
@thinkyhead thinkyhead deleted the rc_singletons branch May 1, 2016 20:47
@ghost ghost mentioned this pull request May 2, 2016
thinkyhead added a commit that referenced this pull request May 2, 2016
Follow-up the PR #3631(Encapsulate Stepper, ...
thinkyhead added a commit that referenced this pull request May 3, 2016
Additional follow-up the PR #3631(Encapsulate S...
nomukaiki pushed a commit to nomukaiki/Marlin that referenced this pull request May 3, 2016
* RCBugFix: (251 commits)
  Fix for PR MarlinFirmware#3526(Configuration.h LCD & SDCard s...
  Additional follow-up the PR MarlinFirmware#3631(Encapsulate S...
  Cleanup, debug strings in Planner::adjusted_position
  Fix BABYSTEPPING, add it to Travis test
  8.3-filenames second try
  Revisited German translation
  Follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, ...
  Some clean-up for example configuration files
  Revert PR 3648 to fix SD printing
  Include more fans in sensitive pins list
  Use #undef in AZTEEG_X3_PRO for RAMPS overrides
  NOOP macro for do-nothing macros
  Updated comment for THERMAL_PROTECTION_BED
  Introduce temp watch protection for the bed
  Updated version header gen script
  Encapsulate dual Z endstop handling
  A little extra gcode_T spacing
  Planner singleton class
  Localize M119 in Endstops class
  Stepper and Endstops as singleton objects
  ...

# Conflicts:
#	Marlin/Configuration.h
#	Marlin/Configuration_adv.h
#	README.md
nomukaiki pushed a commit to nomukaiki/Marlin that referenced this pull request May 4, 2016
Follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, Planner, Endstops in singleton classes)

plan_bed_level_matrix -> planner.bed_level_matrix in multi extruders section of Marlin_main.cpp
It probably fix the Issue MarlinFirmware#3658(plan_bed_level_matrix not declarate).

movesplanned() -> planner.movesplanned() in ADVANCED_OK section of Marlin_main.cpp
It fix compilation error when ADVANCED_OK is enabled
nomukaiki pushed a commit to nomukaiki/Marlin that referenced this pull request May 4, 2016
Additional follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, Planner, Endstops in singleton classes)

・Change from abort_on_endstop_hit to stepper.abort_on_endstop_hit in endstop.cpp, Marlin_main.cpp, and ultralcd.cpp
・Add include path to cardreader.h and temperature.h in endstop.cpp(for CardReader class and disable_all_heaters())
It fix compilation error when ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED and SDSUPPORT are enabled.

・Change from digipot_current() to stepper.digipot_current() in Marlin_main.cpp
・Change from digitalPotWrite() to stepper.digitalPotWrite() in Marlin_main.cpp
It fix compilation errors when HAS_DIGIPOTSS is enabled.

・Change from microstep_mode() to stepper.microstep_mode() in Marlin_main.cpp
・Change attribute of microstep_mode() from private to public in stepper.h
・Change from microstep_readings() to stepper.microstep_readings() in Marlin_main.cpp
・Change from microstep_ms() to stepper.microstep_ms() in Marlin_main.
It fix compilation errors when HAS_MICROSTEPS is enabled.
nomukaiki pushed a commit to nomukaiki/Marlin that referenced this pull request May 4, 2016
…i/Marlin into configurations/KosselXL

* 'configurations/KosselXL' of https://github.com/nomukaiki/Marlin: (254 commits)
  Working version with Endstops
  New settings
  Fix for PR MarlinFirmware#3526(Configuration.h LCD & SDCard s...
  Additional follow-up the PR MarlinFirmware#3631(Encapsulate S...
  Cleanup, debug strings in Planner::adjusted_position
  Fix BABYSTEPPING, add it to Travis test
  8.3-filenames second try
  Revisited German translation
  Follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, ...
  Some clean-up for example configuration files
  Revert PR 3648 to fix SD printing
  Settings with BLTouch
  Include more fans in sensitive pins list
  Use #undef in AZTEEG_X3_PRO for RAMPS overrides
  NOOP macro for do-nothing macros
  Updated comment for THERMAL_PROTECTION_BED
  Introduce temp watch protection for the bed
  Updated version header gen script
  Encapsulate dual Z endstop handling
  A little extra gcode_T spacing
  ...
@thinkyhead thinkyhead mentioned this pull request Jul 8, 2016
@jbrazio jbrazio modified the milestone: 1.1.0 Jul 18, 2016
CONSULitAS pushed a commit to CONSULitAS/Marlin-K8200 that referenced this pull request Aug 18, 2016
Follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, Planner, Endstops in singleton classes)

plan_bed_level_matrix -> planner.bed_level_matrix in multi extruders section of Marlin_main.cpp
It probably fix the Issue MarlinFirmware#3658(plan_bed_level_matrix not declarate).

movesplanned() -> planner.movesplanned() in ADVANCED_OK section of Marlin_main.cpp
It fix compilation error when ADVANCED_OK is enabled
CONSULitAS pushed a commit to CONSULitAS/Marlin-K8200 that referenced this pull request Aug 18, 2016
Additional follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, Planner, Endstops in singleton classes)

・Change from abort_on_endstop_hit to stepper.abort_on_endstop_hit in endstop.cpp, Marlin_main.cpp, and ultralcd.cpp
・Add include path to cardreader.h and temperature.h in endstop.cpp(for CardReader class and disable_all_heaters())
It fix compilation error when ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED and SDSUPPORT are enabled.

・Change from digipot_current() to stepper.digipot_current() in Marlin_main.cpp
・Change from digitalPotWrite() to stepper.digitalPotWrite() in Marlin_main.cpp
It fix compilation errors when HAS_DIGIPOTSS is enabled.

・Change from microstep_mode() to stepper.microstep_mode() in Marlin_main.cpp
・Change attribute of microstep_mode() from private to public in stepper.h
・Change from microstep_readings() to stepper.microstep_readings() in Marlin_main.cpp
・Change from microstep_ms() to stepper.microstep_ms() in Marlin_main.
It fix compilation errors when HAS_MICROSTEPS is enabled.
thinkyhead added a commit that referenced this pull request Oct 27, 2016
nomukaiki pushed a commit to nomukaiki/Marlin that referenced this pull request Apr 2, 2017
* configurations/KosselXL: (265 commits)
  New PID and Z pos
  Latest settings for nozzle V6
  Delta segments per second
  Decreased delta segments
  Working version with Endstops
  New settings
  Fix for PR MarlinFirmware#3526(Configuration.h LCD & SDCard s...
  Additional follow-up the PR MarlinFirmware#3631(Encapsulate S...
  Cleanup, debug strings in Planner::adjusted_position
  Fix BABYSTEPPING, add it to Travis test
  8.3-filenames second try
  Revisited German translation
  Follow-up the PR MarlinFirmware#3631(Encapsulate Stepper, ...
  Some clean-up for example configuration files
  Revert PR 3648 to fix SD printing
  Settings with BLTouch
  Include more fans in sensitive pins list
  Use #undef in AZTEEG_X3_PRO for RAMPS overrides
  NOOP macro for do-nothing macros
  Updated comment for THERMAL_PROTECTION_BED
  ...

# Conflicts:
#	Marlin/Configuration.h
#	Marlin/Configuration_adv.h
#	Marlin/pins_RAMPS.h
#	Marlin/ultralcd.h
drewmoseley pushed a commit to drewmoseley/Marlin that referenced this pull request Nov 8, 2023
…_documentation_part1

MK3 fix eeprom doxygen documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants