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

Extend Printcounter on LCD over 22 days #4312

Closed
wants to merge 1 commit into from
Closed

Extend Printcounter on LCD over 22 days #4312

wants to merge 1 commit into from

Conversation

petrzjunior
Copy link
Contributor

As #4287 allowed longer counting in Printcounter, we should implement it in LCD Info menu. This PR handles with second as long (int32) and adds days counter. That extends LCD to display up to 4 billion seconds or 25 000 days. That lot more than current 32 thousand minutes or 22 days. Timer is moved to next line to fit into 16-char display.

If merged, will need some help from @MarlinFirmware/language-team

@jbrazio jbrazio added this to the 1.1.0 milestone Jul 15, 2016
int hrs = long(stats.printTime / 60 / 60) % 24;
int day = int(stats.printTime / 60 / 60 / 24);
char timeString[14];
sprintf_P(timeString, PSTR("%i%s %i%s %02i%s"), day, MSG_SHORT_DAY, hrs, MSG_SHORT_HOUR, min, MSG_SHORT_MINUTE);
Copy link
Member

@thinkyhead thinkyhead Jul 16, 2016

Choose a reason for hiding this comment

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

This will produce smaller code as it uses less string storage and encourages the compiler to skip creating temporary variables:

sprintf_P(timeString,
  PSTR("%i" MSG_SHORT_DAY " %i" MSG_SHORT_HOUR " %i" MSG_SHORT_MINUTE),
  int(stats.printTime / 60 / 60 / 24),
  int((stats.printTime / 60 / 60) % 24),
  int((stats.printTime / 60) % 60)
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thinkyhead OK, you got me. Tried that previously, but I thought, I can't do modulus (%) with decimals or whatewer it is. And converting to long caused weird bugs inside Arduino, so I used temporary vars. Now OK?

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.

3 participants