Skip to content

Backport: Add header guards and clean up Button self-qualification#152

Merged
livingkurt merged 8 commits intomasterfrom
kurt/backport-code-cleanup
Mar 27, 2026
Merged

Backport: Add header guards and clean up Button self-qualification#152
livingkurt merged 8 commits intomasterfrom
kurt/backport-code-cleanup

Conversation

@livingkurt
Copy link
Copy Markdown
Collaborator

Summary

These are small cleanup changes identified during the RAII branch review (PR #151) that apply cleanly to master and reduce the diff size of the RAII branch when they're merged here first.

  • Add proper header guards to Button.h, Helios.h, ColorConstants.h, and Random.h. The first two had no include guard at all, the latter two used non-standard #pragma once.
  • Remove unnecessary Button:: self-qualification on static method calls within Button.cpp (holdPressing, processPreInput, processPostInput). These are calls to the class's own static members and don't need the class prefix.
  • Extract repeated Time::getCurtime() calls into a const local variable in Button::update() for clarity (the compiler likely optimizes this already, but the old AVR compiler may benefit).

Test plan

  • CLI builds with zero warnings
  • All 506 tests pass

Made with Cursor

- Add proper #ifndef/#define header guards to Button.h, Helios.h,
  ColorConstants.h, and Random.h (replacing #pragma once where used)
- Remove unnecessary Button:: self-qualification on static method calls
  within Button.cpp (holdPressing, processPreInput, processPostInput)
- Extract repeated Time::getCurtime() calls into const local variable
  in Button::update()

Made-with: Cursor
@Unreal-Dan
Copy link
Copy Markdown
Collaborator

Okay this is my first experience with cursor, this is really cool lol

I am curious though can it actually tell if the total size is smaller? It would need to look at this output of this build step:

master

Sketch uses 8010 bytes (97.78%) of program storage space. Maximum is 8192 bytes. (Hex: 1f4a/2000)
Global variables use 276 bytes (53.91%) of dynamic memory, leaving 236 bytes for local variables. Maximum is 512 bytes. (Hex: 114/200)
== Success building Helios v1.4.0 ==

This one

Sketch uses 7938 bytes (96.90%) of program storage space. Maximum is 8192 bytes. (Hex: 1f02/2000)
Global variables use 276 bytes (53.91%) of dynamic memory, leaving 236 bytes for local variables. Maximum is 512 bytes. (Hex: 114/200)
== Success building Helios v1.4.0 ==

So it's definitely smaller, which makes sense, but I'm curious would Cursor know if it wasn't?

Other than this question, changeset looks good to me and definitely fixes the issues

@Unreal-Dan
Copy link
Copy Markdown
Collaborator

Can confirm same size before and after removing the call to Helios::wakeup() in the ISR, therefore it was never needed and logically doesn't make sense for embedded.

Same size: 96.90% and globals 53.91%

Sketch uses 7938 bytes (96.90%) of program storage space. Maximum is 8192 bytes. (Hex: 1f02/2000)
Global variables use 276 bytes (53.91%) of dynamic memory, leaving 236 bytes for local variables. Maximum is 512 bytes. (Hex: 114/200)
== Success building Helios v1.4.0 ==

@livingkurt livingkurt merged commit 98d3c5b into master Mar 27, 2026
5 checks passed
livingkurt added a commit that referenced this pull request Mar 27, 2026
Backport cleanup from master (#152): replace #pragma once in Button.h
and add missing include guard to Helios.h with standard #ifndef guards.
This reduces the diff against master for the RAII PR review.

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 27, 2026
Port of master PR #152 cleanup changes to aeos branch:

- Add proper #ifndef/#define header guards to Button.h, Helios.h,
  ColorConstants.h, and Random.h (replacing #pragma once where used)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H
- Remove Helios::wakeup() from ISR (not used on embedded)
- Remove unnecessary Button:: self-qualification on static method calls
  within Button.cpp (holdPressing, processPreInput, processPostInput)
- Extract repeated Time::getCurtime() calls into const local variable
  in Button::update()
- Move Led::setBrightness() out of inline into Led.cpp
- Remove commented-out include from Pattern.cpp
- Remove unused Led.h include from TimeControl.cpp
- Update TimeControl.h comments for clarity

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 27, 2026
Port of master PR #152 cleanup changes to the master-c branch:

- Add proper #ifndef/#define guard to ColorConstants.h (replacing #pragma once)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H to match filename
- Remove helios_wakeup() from embedded ISR (not used on embedded)
- Extract repeated time_get_current_time() calls into const local variable
  in button_update() for clarity
- Remove unused Led.h include from TimeControl.cpp, reorder includes
- Update TimeControl.h comments on time_get_current_time() and
  time_microseconds() for clarity

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 27, 2026
Port of master PR #152 cleanup changes to the aeos-c branch:

- Add proper #ifndef/#define guard to ColorConstants.h (replacing #pragma once)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H to match filename
- Remove helios_wakeup() from embedded ISR (not used on embedded)
- Extract repeated time_get_current_time() calls into const local variable
  in button_update() for clarity
- Remove unused Led.h include from TimeControl.cpp, reorder includes
- Update TimeControl.h comments on time_get_current_time() and
  time_microseconds() for clarity

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 28, 2026
)

Port of master PR #152 cleanup changes to aeos branch:

- Add proper #ifndef/#define header guards to Button.h, Helios.h,
  ColorConstants.h, and Random.h (replacing #pragma once where used)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H
- Remove Helios::wakeup() from ISR (not used on embedded)
- Remove unnecessary Button:: self-qualification on static method calls
  within Button.cpp (holdPressing, processPreInput, processPostInput)
- Extract repeated Time::getCurtime() calls into const local variable
  in Button::update()
- Move Led::setBrightness() out of inline into Led.cpp
- Remove commented-out include from Pattern.cpp
- Remove unused Led.h include from TimeControl.cpp
- Update TimeControl.h comments for clarity

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 28, 2026
#154)

Port of master PR #152 cleanup changes to the master-c branch:

- Add proper #ifndef/#define guard to ColorConstants.h (replacing #pragma once)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H to match filename
- Remove helios_wakeup() from embedded ISR (not used on embedded)
- Extract repeated time_get_current_time() calls into const local variable
  in button_update() for clarity
- Remove unused Led.h include from TimeControl.cpp, reorder includes
- Update TimeControl.h comments on time_get_current_time() and
  time_microseconds() for clarity

Made-with: Cursor
livingkurt added a commit that referenced this pull request Mar 28, 2026
…155)

Port of master PR #152 cleanup changes to the aeos-c branch:

- Add proper #ifndef/#define guard to ColorConstants.h (replacing #pragma once)
- Rename Colortypes.h guard from COLOR_H to COLORTYPES_H to match filename
- Remove helios_wakeup() from embedded ISR (not used on embedded)
- Extract repeated time_get_current_time() calls into const local variable
  in button_update() for clarity
- Remove unused Led.h include from TimeControl.cpp, reorder includes
- Update TimeControl.h comments on time_get_current_time() and
  time_microseconds() for clarity

Made-with: Cursor
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.

2 participants