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

Code refactoring to make the code easier to read #671

Merged
merged 8 commits into from
Dec 15, 2024

Conversation

lenvm
Copy link
Collaborator

@lenvm lenvm commented Dec 13, 2024

What

This PR splits Software.ino into a number of different files.

It also updates:

  • DUAL_CAN to CAN_ADDON
  • CAN_FD to CANFD_ADDON

Why

  • The code is split into different files to make it easier to read the code, and to place functions that belong together, together :)
  • The updates in the defines are done, to make the code easier to read.

How

Different folders are created, each containing a specific subset of the code:

  • can: for functions related to CAN
  • contactorcontrol: for functions related to contactor control
  • equipmentstopbutton: for functions related to the equipment stop button
  • nvm: for functions related to setting storage
  • rs485: for functions related to RS485 / ModBus
  • seriallink: for functions related to Serial Link

In case you have any comments or requests, please let me know!

@lenvm lenvm requested a review from dalathegreat December 13, 2024 16:50
@lenvm lenvm force-pushed the feature/code-refactoring branch from c0fb6b7 to d580d3f Compare December 13, 2024 20:39
#define CRYSTAL_FREQUENCY_MHZ 8 //CAN_ADDON option, what is your MCP2515 add-on boards crystal frequency?
//#define CANFD_ADDON //Enable this line to activate an isolated secondary CAN-FD bus using add-on MCP2518FD chip / Native CANFD on Stark board
#ifdef CANFD_ADDON // CANFD_ADDON additional options if enabled
#define CANFD_ADDON_CRYSTAL_FREQUENCY_MHZ \
Copy link
Owner

Choose a reason for hiding this comment

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

The CANFD_ADDON_CRYSTAL_FREQUENCY_MHZ could always be defined, irregardless of CANFD_ADDON setting (makes this file smaller and easier to manage

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Implementing this change is fine by me, to make an upgrade to the code. In this PR I have tried to just refactor the code, without introducing changes to how the code works.

Shall we keep the suggested change for another PR?

@dalathegreat
Copy link
Owner

Very nice refactor, the silly large Software.ino refactor has been on my mind for a while, but been so busy with new integrations 😅

@dalathegreat
Copy link
Owner

@lenvm I think we can start looking into merging this, I just applied the critical PWM fix to main, and tagged 7.9.1 (so sorry, you'll have to deal with a minor merge conflict)

@lenvm lenvm force-pushed the feature/code-refactoring branch 2 times, most recently from 431e4b0 to fdf2516 Compare December 14, 2024 22:20
@lenvm
Copy link
Collaborator Author

lenvm commented Dec 14, 2024

@dalathegreat, no worries, I have rebased and resolved the merge conflict.

Please let me know if we need to merge #673 too, before we merge this one.

@mvgalen
Copy link
Collaborator

mvgalen commented Dec 15, 2024

@dalathegreat, no worries, I have rebased and resolved the merge conflict.

Please let me know if we need to merge #673 too, before we merge this one.

I have merged #673, but I do not see your rebase and the conflict is unsolved. If you commit the rebase, I will review and approve. Better not to keep a large PR like this around too long.

@dalathegreat
Copy link
Owner

@lenvm , I also merged #647 , I think we can hold off any other PRs now until this one is merged!

@lenvm lenvm force-pushed the feature/code-refactoring branch from fdf2516 to a9da915 Compare December 15, 2024 16:30
@lenvm lenvm force-pushed the feature/code-refactoring branch from a9da915 to 4e3dcf1 Compare December 15, 2024 16:35
@lenvm
Copy link
Collaborator Author

lenvm commented Dec 15, 2024

@dalathegreat, @mvgalen, I have rebased on main again. Please review the changes now.

Copy link
Owner

@dalathegreat dalathegreat left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Well needed refactoring! 🙌

@lenvm lenvm merged commit db77fcf into dalathegreat:main Dec 15, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants