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

Show power source type on detailed screen in soldering mode (#1708) #1709

Merged
merged 2 commits into from
Jun 18, 2023

Conversation

ia
Copy link
Collaborator

@ia ia commented Jun 16, 2023

UX perspective
But nasty hacks may apply, sorry :(

A few comments:

  • I was considering a few approaches - this one turned out to be less invasive.
  • As much as strange trick with overloading OLED::print may look - it works for my own surprise and, what's more important - doesn't break any other visible OLED functionality.
  • I thought that shrtn existed strings anyway better than adding another one set of arrays of chars considering how valuable space is for some supported devices.

Waiting for a feedback crossing fingers.

@@ -4,6 +4,39 @@ extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle;
extern OperatingMode currentMode;

int8_t getPowerSourceNumber(void) {
Copy link
Owner

Choose a reason for hiding this comment

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

Probably worth moving this into its own file with matching header, since its no longer coupled to debug menu

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its no longer coupled to debug menu

Technically it still is but just reused in another place at the same time. Plus, I always thought that the less new files in a patch the better but it depends on a project I guess. So, to be clear though - are you sure that this demands creating a separate translation unit? Just asking, Captn. If so, then tell me the name of a new file and the location in the source tree - it's not mine ship after all ;)

Copy link
Owner

Choose a reason for hiding this comment

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

This could just be a powerSource.c file in the same folder; I view files more as wanting to be able to know what file to open when I first open the repo. So I dont like overly deep mess'es of files with similar names. But also I dont like burying a shared function in a file that sounds like it only does one thing.

To me the question would be "given the function getPowerSourceNumber; which of these files has it in" and thats not clear.

@@ -105,7 +105,7 @@ class OLED {
static void setBrightness(uint8_t contrast);
static void setInverseDisplay(bool inverted);
static int16_t getCursorX() { return cursor_x; }
static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font
static void print(const char *string, FontStyle fontStyle, uint8_t num = 0); // Draw a string (or only a number of chars from string if specified) to the current location, with selected font
Copy link
Owner

Choose a reason for hiding this comment

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

num (or n in .cpp) is a fairly awkward parameter name and isnt self-documenting. What about maxLength as the argument?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, how about just length not to overstretch the declaration? Will it be fine?

Copy link
Owner

Choose a reason for hiding this comment

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

Well its more of a max limiter than an actual length; but if you keep the comment noting its a max, that should be fine.~

const uint8_t *next = reinterpret_cast<const uint8_t *>(str);
bool cut = n ? true : false;
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of this, could default the max length to 255, then just expand the check on line 415 to do while(next[0] && n--) sort of thing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very creative! Haven't thought about that.

@ia
Copy link
Collaborator Author

ia commented Jun 16, 2023

Just one last initiative of mine - if you're unhappy, then tell me and I will add a new file. But since SolderingCommon.cpp has detailedPowerStatus() already anyway, so I thought... what about this?

Although I see your logic in file naming and I understand it - it makes sense. So I'm sorry - I didn't mean to be rude nor stubborn in any way at all: just with open source projects without strict rules & regulations sometimes it's just not obvious how to make it better, that's it.

@ia ia requested a review from Ralim June 16, 2023 05:34
Copy link
Owner

@Ralim Ralim left a comment

Choose a reason for hiding this comment

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

Yep this is good by me, fair call on the common file :)

@Ralim
Copy link
Owner

Ralim commented Jun 16, 2023

No need to apologise; different opinions are good; I prefer discussion on a PR than having inflexible rules that drive people nuts.

Will wait and see if any others comment for a day or so; If not I'm happy to merge it in then.

@Ralim Ralim merged commit a1b9e40 into Ralim:dev Jun 18, 2023
@ia ia deleted the dev-pwr branch June 21, 2023 17:23
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