Go to advanced search

by paddyg
Fri Dec 13, 2019 6:16 pm
Forum: Python
Topic: Webinterface - FLASK and while loop
Replies: 1
Views: 66

Re: Webinterface - FLASK and while loop

Do you need to set the global light_on True? You might need to put your actions into functions and run them in threads to stop the whole thing getting stuck in a flashing light loop. I think you have to put global as the first line of the function. Finally I think you can pass a list to gpio.setup s...
by paddyg
Wed Dec 11, 2019 6:50 pm
Forum: Python
Topic: Python script stops after 1 minute after boot
Replies: 5
Views: 153

Re: Python script stops after 1 minute after boot

So it's quite an obvious problem - once you know what it is! I just tried your code on my RPi and (after I struggled to get the internal pull-up to work at all, not sure what that's about. More investigation needed) I had exactly your problem. Then when I tried typing the mpg123 etc on the command l...
by paddyg
Wed Dec 11, 2019 8:38 am
Forum: Python
Topic: Render pi3d over omxplayer on pi4
Replies: 3
Views: 117

Re: Render pi3d over omxplayer on pi4

@pescew Glad that you seem to be able to find a way round the issue; I was going to suggest VLC or suchlike. I think everything (including omxplayer) uses ffmpeg inside (it's a very comprehensive, handy library) so you probably always get that, but it probably cuts out a bit of processing overhead t...
by paddyg
Tue Dec 10, 2019 11:43 pm
Forum: Python
Topic: trouble with gpiozero
Replies: 1
Views: 76

Re: trouble with gpiozero

https://gpiozero.readthedocs.io/en/stab ... t.html#led i.e. my_led.is_lit will be a boolean value (it is a function but it's hidden behind a decorator so that it behaves like a property (all things to google if they're not familiar))
by paddyg
Tue Dec 10, 2019 11:37 pm
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

OK the best thing I can suggest is that you take all your gui modifying code out of threads. You can leave you structure in functions but move master refs to a new non threaded GUI function def time_dependent_activities(): global val_1 if (tm_second == 10 or tm_second == 20): val_1 = val_1 + 255 if ...
by paddyg
Tue Dec 10, 2019 10:45 pm
Forum: Python
Topic: Render pi3d over omxplayer on pi4
Replies: 3
Views: 117

Re: Render pi3d over omxplayer on pi4

Ages since I've looked at omxplayer. Does it have an option to make it play in an X11 window? It sounds like it's playing directly to dispmanx and it's no longer possible (well not very easy - aka I don't know how) to run OpenGL to dispanx. I will have a look around and see what I can find - doesn't...
by paddyg
Tue Dec 10, 2019 10:22 pm
Forum: Python
Topic: numpy.append() in Python
Replies: 1
Views: 84

Re: numpy.append() in Python

Are you having problems with np.append()? You can append differently shaped arrays but they will be flattened first. If you specify a dimension to append in then the other dimensions must have the correct shape but not the axis you specify. So >>> a = np.array([[1,2,3],[4,5,6],[7,8,9]]) >>> b = np.a...
by paddyg
Tue Dec 10, 2019 10:14 pm
Forum: Python
Topic: Python script stops after 1 minute after boot
Replies: 5
Views: 153

Re: Python script stops after 1 minute after boot

I can't see why it would cause the program to stop but you should have a small sleep in you main while loop. Even time.sleep(0.1) will cut CPU from 100% to 1%. Does the program run indefinitely if you don't press either button to start the audio? Can you switch audio any number of times by pressing ...
by paddyg
Tue Dec 10, 2019 9:56 pm
Forum: Python
Topic: Loop () Code Structure
Replies: 3
Views: 171

Re: Loop () Code Structure

@rebthetractorma, well done for getting it working. It sounds a really interesting project and it would be good to share your ideas with others in the same position. I definitely don't want to pour cold water on your enthusiasm but the system does need to be fail-safe. i.e. if it goes wrong the resu...
by paddyg
Mon Dec 09, 2019 10:50 am
Forum: General discussion
Topic: RPI 4B 1GB Xinit keeps stopping; running out of options...
Replies: 6
Views: 269

Re: RPI 4B 1GB Xinit keeps stopping; running out of options...

@basm, well at least there's some info being fed back. The error message looks like memory allocation running 4K see https://www.raspberrypi.org/forums/viewtopic.php?t=246443&start=25 and others. However I think Wolfgang has run the PictureFrame app at 4K without it crashing - I don't know what RAM ...
by paddyg
Sun Dec 08, 2019 7:20 pm
Forum: Python
Topic: Loop () Code Structure
Replies: 3
Views: 171

Re: Loop () Code Structure

Is there a reason you need to run your subfiles in that rather non-standard way? Normally you would import the subfile once at the start of main and have a function with a loop in subfile that would check for input and stop accordingly. Maybe if you give some more info about what you're trying to do...
by paddyg
Sun Dec 08, 2019 6:20 pm
Forum: Python
Topic: Parent script termination
Replies: 17
Views: 581

Re: Parent script termination

To be fair, in your first reply you were pretty explicit about the OP needing to put the functionality in the imported file into functions, then importing the file only once and calling the functions in the parent program (at the point where the OP was trying to do repeated imports).
by paddyg
Sun Dec 08, 2019 8:25 am
Forum: Python
Topic: Parent script termination
Replies: 17
Views: 581

Re: Parent script termination

I would reiterate scotty101 here you should not be attempting to use subprocess or to "execute" a child python script for this.
by paddyg
Sat Dec 07, 2019 11:11 pm
Forum: Python
Topic: How to stop mp3 from playing if another GPIO button is pushed
Replies: 2
Views: 118

Re: How to stop mp3 from playing if another GPIO button is pushed

if you start mpg123 with the --remote option then you can pass commands via stdin i.e. @H LOAD/L <trackname>: load and start playing resource <trackname> @H LOADPAUSED/LP <trackname>: load but do not start playing resource <trackname> @H LOADLIST/LL <entry> <url>: load a playlist from given <url>, a...
by paddyg
Sat Dec 07, 2019 7:37 pm
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

Hi, Yes I just tested the idea of not putting the functions in Threads (pi3d_demos has an example using PyQt4 so I could add a time-wasting function very easily). The result is that the functions started by QTimer do block the execution of the main thread so that means that if you don't put the func...
by paddyg
Sat Dec 07, 2019 4:44 pm
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

That's lots of code to look at - well I did ask for it ;) However I am more confused than ever. You still don't have any loops in your threaded functions so there seems very little benefit putting them in threads at all. Have you tried: def prozenje(): digitalna_ura() aktivnosti_po_uri() watch_dog_p...
by paddyg
Sat Dec 07, 2019 9:15 am
Forum: General discussion
Topic: RPI 4B 1GB Xinit keeps stopping; running out of options...
Replies: 6
Views: 269

Re: RPI 4B 1GB Xinit keeps stopping; running out of options...

@basm does it only crash when running pi3d? Also what form does the crash take? You say X stops which sounds like you drop back to command line. PS what happens if you take out the hdmi_cvt out or only specify w,h,fps and not aspect ratio or set aspect ratio to 3 for 16:9. Don't know if screens can ...
by paddyg
Sat Dec 07, 2019 8:38 am
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

Some modules have functionality that has to run in the main thread of the process that started the program. For instance in pi3d the calls to external OpenGL DLLs can't be offloaded into spawned threads. So when it needs to be run at the same time as Qt or Flask etc it either has to be run as a diff...
by paddyg
Fri Dec 06, 2019 11:34 am
Forum: Python
Topic: Python script started on boot, how to show console output
Replies: 1
Views: 92

Re: Python script started on boot, how to show console output

Simplest might be to convert the print()s to writing to a file. You would need a mechanism to prevent it getting too big. On seeing the stdio of another session there is some info that may help here https://unix.stackexchange.com/questions/58550/how-to-view-the-output-of-a-running-process-in-another...
by paddyg
Fri Dec 06, 2019 11:09 am
Forum: Graphics programming
Topic: Open GL 2.1 on RPi 4
Replies: 6
Views: 514

Re: Open GL 2.1 on RPi 4

Looks like you haven't changed that first line of your fragment shader (you have to fix the vertex and fragment shaders. i.e. two edits) as per @Gavinmc42's suggestion. Try that and see what you get.
by paddyg
Fri Dec 06, 2019 12:00 am
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

Hi, this is a stripped back threading with while loops. Fairly ugly code with globals and copy pasted stuff that needs DRYing, but hopefully clear what's going on. You could use the QT timer to run a function to set the boolean trigger variables rather than a threaded loop. That wouldn't need to be ...
by paddyg
Thu Dec 05, 2019 9:24 pm
Forum: Python
Topic: Porting a C Python module to Python 3
Replies: 9
Views: 1887

Re: Porting a C Python module to Python 3

As a reference for anyone thinking of writing their own python module I though I would add some more comparisons: https://github.com/paddywwoof/atkinson 1. the un-accelerated python just reading and writing pixels using PIL.Image (much slower than 10x so maybe it would be better converting into pyth...
by paddyg
Thu Dec 05, 2019 6:10 pm
Forum: Python
Topic: Threading problems
Replies: 18
Views: 510

Re: Threading problems

As Paeryn says none of those threaded functions have while loops so they will just run then stop. Is that what you intend? Normally the threaded functions would be started then loop in the background doing something.
by paddyg
Thu Dec 05, 2019 4:52 pm
Forum: Français
Topic: lancer un programme avec un interrupteur
Replies: 17
Views: 379

Re: lancer un programme avec un interrupteur

ou utilisez le diviseur de tension pour fournir 3V3 à VCC de MM74c922 alors vous n'avez besoin de rien entre cela et le GPIO
by paddyg
Thu Dec 05, 2019 12:24 pm
Forum: Français
Topic: lancer un programme avec un interrupteur
Replies: 17
Views: 379

Re: lancer un programme avec un interrupteur

Oui, beaucoup de façons plus simples de dépouiller le chat :D ... mais l'affiche originale a commencé sur le fil de discussion en python. (Cela dépend aussi de ce qu’on entend par "...programme qu'on a fait sur nano...".)

Go to advanced search