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

Using : in text is not Posible #31

Open
seppal123 opened this issue Jan 2, 2021 · 2 comments
Open

Using : in text is not Posible #31

seppal123 opened this issue Jan 2, 2021 · 2 comments

Comments

@seppal123
Copy link

Hi all

I would like to use the LED Badge as Status Monitor for Linux.
All i want is to output the uptime command to the LED. see example below.
Problem is, that the ":" characters have a buildin funktion for the bitmaps so i cannot show a Timestamp.
Is there a way that i can escape the ":" character so that they are not interpreted as Picture ?

Thanks is advance, and a happy new year 2021
Ciao
Sandro

---example--
sandro@schleppy:~/led-name-badge-ls32$ uptime
11:16:27 up 26 min, 1 user, load average: 0,56, 0,38, 0,21

sandro@schleppy:~/led-name-badge-ls32$ python3 ./led-badge-11x44.py "11:07:53 up 17 min, 1 user, load average: 0,00, 0,05, 0,09"
using [LSicroelectronics LS32 Custm HID] bus=1 dev=13
Traceback (most recent call last):
File "./led-badge-11x44.py", line 487, in
msgs.append(bitmap(arg))
File "./led-badge-11x44.py", line 360, in bitmap
return bitmap_text(arg)
File "./led-badge-11x44.py", line 315, in bitmap_text
(b,n) = bitmap_char(c)
File "./led-badge-11x44.py", line 284, in bitmap_char
return bitmap_preloaded[ord(ch)]
IndexError: list index out of range

@derpicknicker1
Copy link

derpicknicker1 commented Jul 6, 2021

Use two colons to escape

python3 ./led-badge-11x44.py "11::07::53 up 17 min, 1 user, load average: 0,00, 0,05, 0,09"

@juleskers
Copy link

If you want to create a shell one-liner for this, you can use sed to replace single colons with doubles, and then immediately insert the uptime output into the badge-script using "string interpolation"

  • sed "s/find/replace/g" does _s_ubstitution of find with replace, (g = global = don't stop after first replacement)
  • $( ... ) is bash-syntax for command interpolation, i.e. execute ... and give me its output as string.
# uptime
 16:54:42  up   0:07,  2 users,  load average: 0.46, 0.86, 0.51
# uptime | sed 's/:/::/g'
 16::54::59  up   0::07,  2 users,  load average:: 0.33, 0.81, 0.49
# echo "bash interpolation! >>$( uptime | sed 's/:/::/g' )<<"
bash interpolation! >> 16::59::21  up   0::11,  2 users,  load average:: 0.59, 0.68, 0.52<<

# python3 ./led-badge-11x44.py "$( uptime | sed 's/:/::/g' )"
...

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

No branches or pull requests

3 participants