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

Support UTF-8 and scroll longer labels on the screen #22

Merged
merged 4 commits into from
Mar 20, 2023

Conversation

sabeechen
Copy link
Contributor

This PR:

  • Makes the E-TKT UTF-8 aware by parsing string contents to determine character position, length, etc
  • Uses the UTF-8 awareness to avoid substituting placeholder characters for the special characters it supports.
  • Makes the E-TKT scroll longer labels as its printing.
  • Renders special characters (♡, ☆, ♪, €) by picking and choosing different characters from different fonts for the best readability on the low-res screen. Small rant: this was exactly as tedious as it sounds, but I think I did the best with what was available in U8g2lib.

Reviewer notes:

  • I would have normally to split this into two PR's, but the logic for rendering characters of different widths is pretty intermingled with the logic for scrolling the display, so I just made it all one.
  • The auto formatting seems to want to put the big charSet map one line, which seems ugly to me but I didn't want to fight the formatter.

Since the website doesn't support printing labels long enough to trigger the screen scrolling (yet!) you can send labels using the command line, for example:
Linux (bash)

curl -vvv -X POST http://192.168.0.145/api/task -H 'Content-Type: application/json' -d '{"parameter":"tag", value:" This♡label☆is♪too€long@to$fit "}'

Windows (powershell)

$data = @{'parameter'='tag';
          'value'=' This♡label☆is♪too€long@to$fit '
}
Invoke-WebRequest -Uri http://192.168.0.145/api/task -Method POST -Body ($data|ConvertTo-Json) -ContentType "application/json"

@andreisperid andreisperid merged commit 481e268 into andreisperid:main Mar 20, 2023
@andreisperid
Copy link
Owner

Great work @sabeechen 😀

I've just tested it here and just had a minor issue (invalid conversion from 'char' to 'const char*' [-fpermissive]), but fixed in 3c09061, check it out if it makes sense.

@sabeechen
Copy link
Contributor Author

That edit looks good, thank you. The E-TKT I do development on (I have two now!) is in rough shape hardware-wise and I have to make a bunch of kludgy code edits to keep it calibrated, which I then have to revert before I make a PR. I'll be more careful about it in the future.

@andreisperid
Copy link
Owner

Absolutely no problem :)

@andreisperid andreisperid added this to the v1.0.1 milestone May 4, 2023
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.

None yet

2 participants