Raspberry Pi Programming Pointers Needed

Hi, hopefully someone can help. I’m fairly experienced with arduino projects, but I’m branching into Raspberry Pi and could use some help. I plan to come to the first wichitaLUG meeting I can make, although I’m likely not able to make the one on the 12th of Feb.

I would like to start with a program that launches automatically when the Pi is turned on. This program would essentially be a slide show at first, working up to including some simple animations. I would also like to be able to access the I/O during this sideshow for some user input options, also having input from a touchscreen. Maybe similar to a pinball game without the physics, or maybe just a more complicated menu system.

Anyway, I’ve started working on this using pygame and had some moderate success with loading images, but lost steam on the project and thought I would reach out for pointers, pygame alternatives, etc.

Thanks!

1 Like

I’m not saying pygame is not the way to go, but I use tkinter for my interface needs.

Running on startup is pretty easy, there is a startup file that you can declare scripts be run in.

Thanks for the reply.

I can’t seem to find anything that shows what tkinter can do from a graphical point.

I don’t know why I didn’t include this in my original post, but this is essentially what I’m trying to do. The important bit starts about 10:30.

His is based on a Mac mini running a flash program. I want to do Pi mostly for the cost and availability of the hardware.

Here is a GUI I’m working on with tkinter. That video thing though is pretty snazzy, I’m going to defer to more knowledgeable python-ers.

1 Like

Another option would be to build the GUI using HTML/JS/whatever and run it in a web browser in kiosk mode. One upside is that this is very flexible; one downside is that it is very flexible. :sweat_smile:

For the GPIO inputs I believe there is a configuration file for mapping pins to key presses. Then you can just handle the key press in your GUI, which is generally well supported. Touchscreens usually are handled very similarly to mouse input for basic operations.

1 Like

That’s a very intriguing option. Can the browser based gui control the output pins too? I see a lot of tutorials for using html to control outputs like leds from a different device, but none that (clearly) indicate it can be done from a browser running on the same pi.
I just realized I could also control the functions remotely with a cell phone. This would be amazing when it’s on display.

Yeah, if you can control the pins via a browser on separate computer you can certainly do the same on a local browser. There are a bunch of different options for remotely controlling GPIO.

To note the WichitaLUG meetings got moved online at the moment due to Covid. I’d suggest joining the discord/matrix what have you if you have questions for semi-realtime.

I’m actually setting something like that up. (Though not pi, and not touching GPIO, though I really wish computers had more accessible GPIO.)

I’ll list two ways to launch things:

First way: To launch something automatically as a service, on most systems (using systemd, which almost all distros are) you can use a script similar to this one which I use for an led-blinker (My converted Chromebook has a led light on the back, which I like blinking when it’s on.) let’s call this led_blinker.service

Modify $USER to whatever your username that you want to run it is. Also the path, description and similar.

[Unit]
Description=LED blinker for Candy (Dell Chromebook 3120)
StartLimitIntervalSec=5
After=basic.target

[Service]
Type=simple
Restart=always
RestartSec=5
User=$USER
ExecStart=/usr/bin/python3 /home/$USER/git/candy-led/led.py

[Install]
WantedBy=multi-user.target

To ‘install’ that I’d just go:

sudo systemctl enable $PATH_TO_ABOVE_FILE
sudo systemctl start led_blinker.service

Then it will start each time, and in my case I get pretty colors! (Great for telling if it’s on or asleep)

To stop it:

sudo systemctl start led_blinker.service

To disable it (stop from starting up on startup):

sudo systemctl stop led_blinker.service

To get status it: (No sudo required in most cases)

systemctl status led_blinker.service

Second way: For graphical things using X11: Configured for autologin under X11, you could just add the line to ~/.xinitrc in most cases. Here’s arch’s wiki on it: xinit - ArchWiki (That’s for base X11, some Desktop environments may or may not respect that.)

A Third way would be to use crontab, but that’s usually for things you want to run periodically and have quit. It can also be used to check and launch processes if it dies, but with the line in the .service file systemd will try to handle that. There’s others.


Pygame I think uses the framebuffer/GL directly on Pi, but it’s been a while since I looked at it, so I think the first method would work if that’s all you want to run graphically.

1 Like

Thanks. I tried chrontab in the past but was never able to get it to work. I’ll try to add that capability to what I’m working with now.

I was able to get an html document on the pi and a node.js server to interact with it, along with some Javascript to turn leds on and off. It works on the pi in chromium, and any computer or smartphone on my network that can get to the ip address of the pi. It’s been a while since I got that “This is basically magic” feeling with electronics, but pushing a button on my phone and it taking a physical action was one of them. I followed this tutorial to get there.

Next step is to figure out how to use USB to an arduino over the same node.js server. I need more I/O than the pi can support, and some of that needs to be analog.

I plan on following these to get there.

I haven’t had a chance to mess with adobe animate. I still plan to check it out, but replicating the look of early 90’s tech with html and css shouldn’t be too hard to just write manually.

Thanks again for all the help!

2 Likes