Closed GeorgeFlorian closed 5 years ago
First off: yes you should always run with sudo
, otherwise relevant realtime features can't be used. Also setting the isolcpus setting use is useful.
I am a bit surprised by your systemd message: as far as I know, the Raspbian Buster Lite is a systemd-basd system. When disabling things, also make sure to disable 1-wire protocol; there were some versions of Raspbian Lite that enabled it and messed with connected hardware. (W.r.t. operating system: I have heard people use the dietpi distribution with much success, as-in, apparently it reduces flicker compared to raspbian).
Ok, to answer the question: yes, this code can exhibit flicker. In your loop, you do Clear()
on the currently active frame and draw things back to it. This of course will create some flicker on each update.
To avoid that, you can write your text into an offline canvas, then use the SwapOnVSync()
to atomically swap it at frame sync:
static void Text_HasArrived(FrameCanvas *canvas, ...) {
...
}
int main(...) {
// ... init
RGBMatrix *matrix = rgb_matrix::CreateMatrixFromFlags(...);
// Create a new canvas to be used with led_matrix_swap_on_vsync
FrameCanvas *offscreen_canvas = matrix->CreateFrameCanvas();
while (condition) {
Text_HasArrived(offscreen_canvas, ...); // Write stuff to offline canvas
// Now, we pass that canvas to the matrix. It returns the previously active canvas
offscreen_canvas = matrix->SwapOnVSync(offscreen_canvas);
usleep(...);
}
}
See also examples such as scrolling-text-example.c
for some SwapOnVSync()
example.
Can I not run the program as root ?
Because I have the following error: https://stackoverflow.com/questions/57822336/system-path-to-bash-sh-returns-file-txt-permission-denied-only-when-c-pro?noredirect=1#comment102076685_57822336
The library drops the permissions from root
to daemon
after the hardware is initialized to minimize the security issues.
So if you want to read a file, it needs to be readable by that user.. You can make it readable to nobody (chmod a+r <file>
).
Alternatively, if you want to keep running as root, set the drop_privileges
in your RuntimeOptions to 0.
I didn't hear anything, sounds like you solved your problem ? Please make sure to close the issue in these cases.
I didn't hear anything, sounds like you solved your problem ? Please make sure to close the issue in these cases.
I ended up using runtime_defaults.drop_privileges = 0;
because I needed to open some sensitive files, like dhcpcd.conf
.
I have also improved the code to only update the image if some of the output actually changed, not on every cycle of the loop.
Also, Raspbian Buster Lite is indeed a systemd based OS. I don't how or why mine wasn't working properly. I did sudo rm /sbin/init; sudo ln -s /lib/systemd/systemd /sbin/init
and then a reboot and all worked out.
I haven't disable 1-wire protocol yet. I will look into it now.
EDIT:
Adding dtoverlay=w1-gpio
to /boot/config.txt
made the panel look like shit. I think you meant to remove dtoverlay=w1-gpio
if one finds it in /boot/config.txt
. That bit in the readme could use some brushing, because it isn't clear at all. For me at least.
Thank you !
Board: Raspberry Pi 4 OS: Linux raspberrypi 4.19.58-v7l+ Panels: Chinese 2727 SMD 64x32 5 pitch
Hello ! I am driving 4 panels using 2 chains.
I have the following "display" function in a while loop:
so:
I have tried all of the
runtime_defaults.gpio_slowdown
values. 0 and 1 scramble the out really bad.runtime_defaults.gpio_slowdown = 2
returns around 178 Hzruntime_defaults.gpio_slowdown = 3
returns around 216 Hzruntime_defaults.gpio_slowdown = 4
returns around 191 Hzruntime_defaults.gpio_slowdown = 5
returns around 170 HzAlso, another thing that I've noticed. Running the process with sudo will give it a bump in Hz.
runtime_defaults.gpio_slowdown = 2
returns around 231 Hzruntime_defaults.gpio_slowdown = 3
returns around 300 Hzruntime_defaults.gpio_slowdown = 4
returns around 253 Hzruntime_defaults.gpio_slowdown = 5
returns around 219 HzBut the flicker appears to be the same with either 2,3,4 and 5 option, sudo or without.
I am not using an Adafruit Hat. I had an active adapter made. I am using Raspbian Buster Lite, I have disabled the sound thingy, and the other services using:
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
. Also, when tryingsudo timedatectl set-ntp false
orsudo systemctl stop cron
I get this:What I don't know is how to not run anything else on the PI, because I don't know which process should run and which should not. And I don't understand what to do with
top
. It returns a bunch of things.What can cause the flicker ? Is it code related ? But if it was code related, it should've flicker once every 3 seconds. Thank you !