refactor: moved more logic components into core#293
Open
andre-stefanov wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1: Extract pure domain logic into core
Summary
Extracts the pure (non-Arduino) arithmetic subsets of the firmware's core data types and algorithms into core, making them host-testable via the
nativePlatformIO environment. The original src files become thin overlays that inherit from the core versions and add only Arduino-dependent methods (ParseFromMeade,ToString). Zero behavior change — all 5 boards build green.Architecture
Each src originals (
DayTime,Declination,Latitude,Longitude) is now a thin overlay:New files
src/core/types/{DayTime,RightAscension,Declination,Latitude,Longitude}.{hpp,cpp}src/core/{SiderealClock,CalendarMath,CoordinateMath,CoordinateFormatter}.{hpp,cpp}src/{RightAscension}.{hpp,cpp}(new overlay)unit_tests/test_core/{test_sidereal,test_calendar,test_coordinate_math,test_coordinate_formatter,test_eeprom_layout,types/test_daytime,types/test_declination,types/test_latitude,types/test_longitude,types/test_right_ascension}.cppModified files
src/{DayTime,Declination,Latitude,Longitude}.{hpp,cpp}core::SiderealClockTest results
All 5 board matrix builds green (
ramps,mksgenlv21,mksgenlv2,mksgenlv1,esp32,oaeboardv1).Key decisions
<Arduino.h>viainc/Globals.hppand are untestable on native. Pure logic is extracted intocore/first, then tested.#includethe core version and add onlyString-dependent methods. No flag day.corenamespace: All extracted types live innamespace coreto avoid collisions with the overlay classes in the global namespace.core::RightAscensionwas added as a first-class RA coordinate type alongsideDeclination, replacingDayTimeinCoordinateFormatter::formatRA(). Inheritance fromDayTimeis acknowledged as a transitional convenience — a composition-based design is planned for Phase 2.What's next (Phase 2)
Introduce HAL interfaces (
IStepperMotor,ISystemClock,IEeprom, …), domain ports (IClock,IPersistentStore,IStepperAxis, …), and adapters that bind ports to HAL. WireMountto use injected port pointers instead of concrete types.