-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Help with scrolling 2 lines of text with runtext.py or other *.py #1087
Comments
Not clear what you mean, but do you want two different lines shown on the panel ? |
I am a systems/network administrator. Yes i would like to scroll 2 different lines of text simultaneously.
Can you explain about the "canvas"? I am only lightly versed in python,near zero in C++. I truly appreciate all of your coding and help to everyone on the forum.
If I stick with runtext.py, can you point me where to change the code.
#!/usr/bin/env python
# Display a runtext with double-buffering.
from samplebase import SampleBase
from rgbmatrix import graphics
import time
class RunText(SampleBase):
def __init__(self, *args, **kwargs):
super(RunText, self).__init__(*args, **kwargs)
self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel", default="Hello world!")
def run(self):
offscreen_canvas = self.matrix.CreateFrameCanvas()
font = graphics.Font()
font.LoadFont("../../../fonts/7x13.bdf")
textColor = graphics.Color(255, 255, 0)
pos = offscreen_canvas.width
my_text = self.args.text
while True:
offscreen_canvas.Clear()
len = graphics.DrawText(offscreen_canvas, font, pos, 10, textColor, my_text)
pos -= 1
if (pos + len < 0):
pos = offscreen_canvas.width
time.sleep(0.05)
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
# Main function
if __name__ == "__main__":
run_text = RunText()
if (not run_text.process()):
run_text.print_help()
…On Tue, Jun 23, 2020 at 11:16 AM Henner Zeller ***@***.***> wrote:
Not clear what you mean, but do you want two different lines shown on the
panel ?
Of course - just modify the code to do that. You have the power of Python
or C++ at your hands, you can do anything you want with the canvas the LED
matrix provides.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1087 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQBUPSKSPYGFJDYDJCWZKVLRYDBOTANCNFSM4OFURVXA>
.
|
I also have a similar requirement. Please provide if a solution exists! I am using c-code to make program for running two lines simultaneously, and for that i will have to run 2 for loops simultaneously inside main() function, is it possible? i think for that i will have to create a thread and in that thread the "canvas" will not be recognized, the "canvas" is only accessible in main() function isn't it? Please guide me in the right direction, Thank you! |
I will have to look over my notes and see how i finally got that to work. I
will get back to you shortly.
…On Tue, Jul 19, 2022 at 5:43 AM ARG ***@***.***> wrote:
I also have a similar requirement.
Please provide if a solution exists!
I am using c-code to make program for running two lines simultaneously,
and for that i will have to run 2 for loops simultaneously inside main()
function, is it possible?
i think for that i will have to create a thread and in that thread the
"canvas" will not be recognized, the "canvas" is only accessible in main()
function isn't it?
Please guide me in the right direction, Thank you!
—
Reply to this email directly, view it on GitHub
<#1087 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQBUPSJJBI7LCZAB626AR7DVUZ2CZANCNFSM4OFURVXA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thank you very much, i will be waiting... |
With script & python i am :
1 taking temperature readings from a database
2 combining all the information into 1 line
3 adjusting color of led text based on temp or humidity
4 creating a ppm
5 displaying ppm
Here my information Dump:
**pi@BondRoomLed:~ $ sudo crontab -l**
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/5 * * * * /home/pi/rpi-rgb-led-matrix-master/ledcron >> /home/pi/rpi-rgb-led-matrix-master/error.log 2>&1
**pi@BondRoomLed:~ $ cat /home/pi/rpi-rgb-led-matrix-master/ledcron**
#!/bin/bash
#A Bash script to copy data from database to prep led file,and display new data every 5 minutes by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/ledcron#
#1 script started every 5 minutes from crontab
sudo /usr/bin/killall led-matrix
sudo /usr/bin/killall python
cd /home/pi/rpi-rgb-led-matrix-master/
sudo /home/pi/rpi-rgb-led-matrix-master/rem.sh
**pi@BondRoomLed:~ $ cat /home/pi/rpi-rgb-led-matrix-master/rem.sh**
#!/bin/bash
#A Bash script to copy data from database to prep led file, by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/rem.sh
#2 Script
cd /home/pi/rpi-rgb-led-matrix-master/
echo " " >/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT device_desc FROM telemetry_log WHERE device_id='30' and unit_of_measure='F' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT SUBSTRING_INDEX(date,' ',-1) FROM telemetry_log WHERE device_id='30' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='30' and unit_of_measure='F' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p8888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='30' and unit_of_measure='%' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
echo " " >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT device_desc FROM telemetry_log WHERE device_id='72' and unit_of_measure='F' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT SUBSTRING_INDEX(date,' ',-1) FROM telemetry_log WHERE device_id='72' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='72' and unit_of_measure='F' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='72' and unit_of_measure='%' ORDER BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT Value FROM telemetry_log WHERE device_id='72' and unit_of_measure='%' ORDER BY date DESC Limit 1" >/home/pi/rpi-rgb-led-matrix-master/per.txt
echo $(cat /home/pi/rpi-rgb-led-matrix-master/exp.txt) > /home/pi/rpi-rgb-led-matrix-master/expNew.txt #Combine lines
sed "s/BondRoom/$(cat /home/pi/rpi-rgb-led-matrix-master/expNew.txt)/" /home/pi/rpi-rgb-led-matrix-master/Multi.py > /home/pi/rpi-rgb-led-matrix-master/Multi-line.py
sudo /home/pi/rpi-rgb-led-matrix-master/clr.sh
**pi@BondRoomLed:~ $ cat /home/pi/rpi-rgb-led-matrix-master/clr.sh**
#!/bin/bash
cd /home/pi/rpi-rgb-led-matrix-master/
#A Bash script to set led color depending on humidity by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/cls.sh
#3 script
if [ $(mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT (value AS SIGNED INTEGER) FROM telemetry_log WHERE device_id='72' and unit_of_measure='%' ORDER BY date DESC Limit 1;") -ge "52" ];
then
sed "s/ZZZZZ/$(cat /home/pi/rpi-rgb-led-matrix-master/red.txt)/" /home/pi/rpi-rgb-led-matrix-master/Multi-line.py > /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
else
sed "s/ZZZZZ/$(cat /home/pi/rpi-rgb-led-matrix-master/green.txt)/" /home/pi/rpi-rgb-led-matrix-master/Multi-line.py > /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
fi
sudo python /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
**pi@BondRoomLed:~ $ cat /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py**
from PIL import ImageFont, Image, ImageDraw
import textwrap
import os
# Source text, and wrap it.
userinput = "BondFront 17:02:26 68.88 F 44.75 % BondBack 14:03:20 69.96 F 51.87 %"
text = textwrap.fill(userinput, 38)
# Font size, color and type.
fontcolor = (0,255,0)
fontsize = 14
font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf", fontsize)
# Determine text size using a scratch image.
img = Image.new("RGBA", (1,1))
draw = ImageDraw.Draw(img)
textsize = draw.textsize(text, font)
# Now that we know how big it should be, create
# the final image and put the text on it.
background = (0, 0, 0, 15)
img = Image.new("RGBA", textsize, background)
draw = ImageDraw.Draw(img)
draw.text((0, 0), text, fontcolor, font)
img.save("seesharp.ppm")
os.system("./led-matrix -t 288 -D 1 -c 2 seesharp.ppm")
Results with 2 lines of scrolling text that updates every 5 minutes
Location of temp sensor, time of last read from sensor, and temp &
humidity of last read.


…On Thu, Jul 21, 2022 at 5:04 AM ARG ***@***.***> wrote:
Thank you very much, i will be waiting...
—
Reply to this email directly, view it on GitHub
<https://github.com/hzeller/rpi-rgb-led-matrix/issuesimage.png/1087#issuecomment-1191234623>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQBUPSL6ANDZSWPFVT44BITVVEHCFANCNFSM4OFURVXA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thank you! As i mentioned earlier i am using C-Code so this help is not usable for me, thank you for the efforts anyway :) |
In python i am :
1 taking temperature readings from a database
2 combining all the information into 1 line
3 adjusting color of led text based on temp or humidity
4 creating a ppm
5 displaying ppm
Here my information Dump:
***@***.***:~ $ sudo crontab -l*
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
*/5 * * * * /home/pi/rpi-rgb-led-matrix-master/ledcron >>
/home/pi/rpi-rgb-led-matrix-master/error.log 2>&1
***@***.***:~ $ cat /home/pi/rpi-rgb-led-matrix-master/ledcron*
#!/bin/bash
#A Bash script to copy data from database to prep led file,and display new
data every 5 minutes by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/ledcron#
#1 script started every 5 minutes from crontab
sudo /usr/bin/killall led-matrix
sudo /usr/bin/killall python
cd /home/pi/rpi-rgb-led-matrix-master/
sudo /home/pi/rpi-rgb-led-matrix-master/rem.sh
#sudo python /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
***@***.***:~ $ cat /home/pi/rpi-rgb-led-matrix-master/rem.sh*
#!/bin/bash
#A Bash script to copy data from database to prep led file, by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/rem.sh
#2 Script
cd /home/pi/rpi-rgb-led-matrix-master/
echo " " >/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT device_desc FROM telemetry_log WHERE device_id='30' and
unit_of_measure='F' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT
SUBSTRING_INDEX(date,' ',-1) FROM telemetry_log WHERE device_id='30' ORDER
BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='30' and
unit_of_measure='F' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p8888 -h 10.10.16.9 sensor_logs -e "SELECT DISTINCT
Value,unit_of_measure FROM telemetry_log WHERE device_id='30' and
unit_of_measure='%' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
echo " " >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT device_desc FROM telemetry_log WHERE device_id='72' and
unit_of_measure='F' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT
SUBSTRING_INDEX(date,' ',-1) FROM telemetry_log WHERE device_id='72' ORDER
BY date DESC Limit 1" >>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='72' and
unit_of_measure='F' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT Value,unit_of_measure FROM telemetry_log WHERE device_id='72' and
unit_of_measure='%' ORDER BY date DESC Limit 1"
>/home/pi/rpi-rgb-led-matrix-master/exp.txt
sudo mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT
DISTINCT Value FROM telemetry_log WHERE device_id='72' and
unit_of_measure='%' ORDER BY date DESC Limit 1"
/home/pi/rpi-rgb-led-matrix-master/per.txt
echo $(cat /home/pi/rpi-rgb-led-matrix-master/exp.txt) >
/home/pi/rpi-rgb-led-matrix-master/expNew.txt #Combine lines
sed "s/BondRoom/$(cat /home/pi/rpi-rgb-led-matrix-master/expNew.txt)/"
/home/pi/rpi-rgb-led-matrix-master/Multi.py >
/home/pi/rpi-rgb-led-matrix-master/Multi-line.py
sudo /home/pi/rpi-rgb-led-matrix-master/clr.sh
***@***.***:~ $ cat /home/pi/rpi-rgb-led-matrix-master/clr.sh*
#!/bin/bash
cd /home/pi/rpi-rgb-led-matrix-master/
#A Bash script to set led color depending on humidity by Shawn Logan
#/home/pi/rpi-rgb-led-matrix-master/cls.sh
#3 script
if [ $(mysql -sN -u root -p 88888 -h 10.10.16.9 sensor_logs -e "SELECT
(value AS SIGNED INTEGER) FROM telemetry_log WHERE device_id='72' and
unit_of_measure='%' ORDER BY date DESC Limit 1;") -ge "52" ];
then
sed "s/ZZZZZ/$(cat /home/pi/rpi-rgb-led-matrix-master/red.txt)/"
/home/pi/rpi-rgb-led-matrix-master/Multi-line.py >
/home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
else
sed "s/ZZZZZ/$(cat /home/pi/rpi-rgb-led-matrix-master/green.txt)/"
/home/pi/rpi-rgb-led-matrix-master/Multi-line.py >
/home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
fi
sudo python /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py
***@***.***:~ $ cat /home/pi/rpi-rgb-led-matrix-master/Multi-clr.py*
from PIL import ImageFont, Image, ImageDraw
import textwrap
import os
# Source text, and wrap it.
userinput = "BondFront 17:02:26 68.88 F 44.75 % BondBack 14:03:20 69.96 F
51.87 %"
text = textwrap.fill(userinput, 38)
# Font size, color and type.
fontcolor = (0,255,0)
fontsize = 14
font =
ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeSans.ttf",
fontsize)
# Determine text size using a scratch image.
img = Image.new("RGBA", (1,1))
draw = ImageDraw.Draw(img)
textsize = draw.textsize(text, font)
# Now that we know how big it should be, create
# the final image and put the text on it.
background = (0, 0, 0, 15)
img = Image.new("RGBA", textsize, background)
draw = ImageDraw.Draw(img)
draw.text((0, 0), text, fontcolor, font)
img.save("seesharp.ppm")
os.system("./led-matrix -t 288 -D 1 -c 2 seesharp.ppm")
…On Tue, Jul 19, 2022 at 5:43 AM ARG ***@***.***> wrote:
I also have a similar requirement.
Please provide if a solution exists!
I am using c-code to make program for running two lines simultaneously,
and for that i will have to run 2 for loops simultaneously inside main()
function, is it possible?
i think for that i will have to create a thread and in that thread the
"canvas" will not be recognized, the "canvas" is only accessible in main()
function isn't it?
Please guide me in the right direction, Thank you!
—
Reply to this email directly, view it on GitHub
<#1087 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQBUPSJJBI7LCZAB626AR7DVUZ2CZANCNFSM4OFURVXA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I have read through all the pertinent info from adafruit and rpi-rgb-led-matrix. Sorry if this is a repeated question.
Is it done with multiple lines? like this:
self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel", default="ZZZZZZ")
self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel", default="XXXXXX")
Thanks in advance.
The text was updated successfully, but these errors were encountered: