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

Writing variables to papirus #201

Open
plagergren opened this issue Dec 8, 2018 · 7 comments
Open

Writing variables to papirus #201

plagergren opened this issue Dec 8, 2018 · 7 comments

Comments

@plagergren
Copy link

I am writing some lua code that has the following where float is a floating point number:
floater = tostring(float)
os.execute(sudo paprius-textfill 'floater')

and this works fine except I want the value of floater to display not the word "floater"
I have tried a lot of different ways to do what I want including grep and all kinds of folderol. Nothing works so far. I get all kinds of different errors depending on which code du jour I am using.
How do I assign a value and print it to the papirus screen using textfill?
Actually, what I really want to do is to use screen.partial_update to refresh only part of the screen that has changed.

Thanks!

@tvoverbeek
Copy link
Contributor

@plagergren
floater is already a string.
Try with os.execute('papirus-textfill '..floater)
.. is the lua string concatenation operator.
For papirus sudo is not needed unless you have an old version of Raspbian.
Here a sample lua test program which works for me:

for val=1.0,2.0,0.1 do
   cmd='papirus-textfill '..tostring(val)..' 180'
   os.execute(cmd)
   os.execute('sleep 1')
end

The 180 is for rotating the image on the display.
For partial updates you either need some python glue or implement it directly in lua.
See the papirus-clock example for how to use papirus.partial_update().

@plagergren
Copy link
Author

plagergren commented Dec 14, 2018 via email

@tvoverbeek
Copy link
Contributor

@plagergren The papirus example programs use the papirus python module as interface between the low level driver (the epd_fuse service) and the program.
In principle all commands are sent to files in /dev/epd. You would have to implement the papirus module in lua to get a pure lua implementation.
If you can call a python script from lua you could write a small one which does the partial_update
and call that from your lua program.
You will have to dive into the low level details to get this working.

@plagergren
Copy link
Author

plagergren commented Dec 14, 2018 via email

@plagergren
Copy link
Author

plagergren commented Dec 27, 2018 via email

@tvoverbeek
Copy link
Contributor

@plagergren Yes, all text displayed is first made as an image using the Python Image Library and then copied to the PaPiRus.
I just updated papirus-textfill on github with an option to use partial-update.
Here is the new help:

usage: papirus-textfill [-h] [--rotation ROTATION] [--partialupdate]
                        displaytext

positional arguments:
  displaytext           Text to display (max 40 char)

optional arguments:
  -h, --help            show this help message and exit
  --rotation ROTATION, -r ROTATION
                        Rotation one of 0, 90, 180,270
  --partialupdate, -p   Use partial instead of full update

Just replace your copy of papirus-textfill with the current one on github and use the '-p' option.

PS Your name sounds scandinavian. Swedish? If so Lycka till

@plagergren
Copy link
Author

plagergren commented Dec 27, 2018 via email

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

2 participants