Go to advanced search

by paddyg
Thu Aug 16, 2018 10:17 pm
Forum: Python
Topic: Adding inputs to existing tkinter stopwatch code
Replies: 10
Views: 208

Re: Adding inputs to existing tkinter stopwatch code

John, sounds like progress of some kind. Does it work ok if you comment out all the gpio stuff and just use the tk buttons? Try to add code back in a bit at time to narrow down the point where it stops working.
Paddy
by paddyg
Thu Aug 16, 2018 7:34 pm
Forum: Python
Topic: Adding inputs to existing tkinter stopwatch code
Replies: 10
Views: 208

Re: Adding inputs to existing tkinter stopwatch code

That's odd. I can't reproduce that error but I do get errors further on. Essentially a) the functions need to be defined before allocating to buttons (obviously!!) b) when_pressed is used differently, basically set equal to a function. See my revised code at the bottom which I've just checked on thi...
by paddyg
Sat Aug 11, 2018 2:32 pm
Forum: Python
Topic: Dynamic video playlist with OMXplayer and OSC
Replies: 8
Views: 159

Re: Dynamic video playlist with OMXplayer and OSC

Hi, I've not had chance to sort this out but did have a look around last night. Using OMXPlayer (the python wrapper module) I found that I could get useful info and control when only one instance of omxplayer was instantiated but when I created a second one then they both returned the same negative ...
by paddyg
Thu Aug 09, 2018 11:46 am
Forum: Python
Topic: Dynamic video playlist with OMXplayer and OSC
Replies: 8
Views: 159

Re: Dynamic video playlist with OMXplayer and OSC

busy now but will look later. I would expect you to need to use the subprocess module to run OMXPlayer twice. That's slightly trickier but not too bad
by paddyg
Wed Aug 08, 2018 9:08 pm
Forum: Python
Topic: Dynamic video playlist with OMXplayer and OSC
Replies: 8
Views: 159

Re: Dynamic video playlist with OMXplayer and OSC

The thing most likely to cause confusion for the python interpreter is using the same names for different things. Python will let you do this and will attempt to work out what to do but it will almost certainly confuse you! Typical issues are naming the program or imported file with a name that clas...
by paddyg
Sun Aug 05, 2018 9:48 pm
Forum: Python
Topic: Threading problem
Replies: 5
Views: 128

Re: Threading problem

You only have to wait a hundredth of a second plus whatever the response time of the mote is. You could have a toggle variable that you set with the GPIO button def LightThread(): global lights_on, lights_hide # don't need to have this line as you're not updating these but it makes it explicit while...
by paddyg
Sun Aug 05, 2018 9:19 pm
Forum: Python
Topic: Threading problem
Replies: 5
Views: 128

Re: Threading problem

Global variables usually work ok with Threads, or you can pass an object type of argument (i.e. an instance of a class or a list, but not a simple boolean) to the thread or you can use a Queue. Maybe post your code?
by paddyg
Sat Aug 04, 2018 8:39 pm
Forum: Python
Topic: Adding inputs to existing tkinter stopwatch code
Replies: 10
Views: 208

Re: Adding inputs to existing tkinter stopwatch code

Well most people will be put off by your un-formatted post. You need to use code tags (see sticky post at the top). Unless you have a very strong reason not to (and I couldn't see one in your code) you should use python3. i.e. import tkinter as tk. w.r.t your GPIO question you should, IMO, use https...
by paddyg
Fri Aug 03, 2018 10:33 pm
Forum: Python
Topic: Python script CPU usage is growing over time
Replies: 2
Views: 122

Re: Python script CPU usage is growing over time

maybe cputemp() is creating new instances of Text objects that somehow evade garbage collection (I've come across this with tk before) You should create one instance of your temerature Text and update that each loop along the lines of this example https://lawsie.github.io/guizero/blocking/
by paddyg
Fri Aug 03, 2018 9:30 pm
Forum: Python
Topic: Calling variables from different functions
Replies: 6
Views: 238

Re: Calling variables from different functions

When I've done similar things I've done the database connection at the beginning of the program when it starts so that conn and c are available to all functions (the alternative would be to make them 'belong' to your UI class and create them when you set it up (so they would be self.conn and self.c)...
by paddyg
Thu Jul 26, 2018 8:01 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Well spotted. I just used code that you posted but you just posted some code from Matt Richardson that you didn't understand! Hopefully you've learned something in the process.
by paddyg
Thu Jul 26, 2018 6:52 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Well google (or other search engine) 'should I connect 5V to raspberry pi gpio, even through a resistor' and see what other people think. Strange that your system doesn't work, it works fine for me as you can see on the video, and also when I put in the pull_up_down argument in and touched pin12 the...
by paddyg
Thu Jul 26, 2018 4:37 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Hmm 5V sounds a lot!!

The best way is to use internal pull up like you do in some of your code snippets and keep even 3V3 away.
by paddyg
Thu Jul 26, 2018 9:25 am
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Did yo check program on your system ? Fair cop, I just assumed that if the GPIO stuff worked ok for you then my code would probably be ok too. So I quickly copied the code to my Raspberry Pi to test it. Surprise, surprise it works fine! https://youtu.be/YQvqGKlydx0 EDIT - kids, don't do what I'm do...
by paddyg
Wed Jul 25, 2018 9:54 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Really you should heed our earlier advice and get comfortable with simpler programming concepts before becoming too confused with this kind of thing but here is a minimalist web page that polls another web page every 1000ms. The other web page runs your GPIO checking. There are various javascript li...
by paddyg
Wed Jul 25, 2018 7:25 am
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

When you say 'press the push button' I assume (having read and understood @topguy's explanation above) that you mean 'press the push button and hold it down while I refresh the page'. In which case it's not clear why it's not working. I would put in print() statements a various places to try to trac...
by paddyg
Tue Jul 24, 2018 12:18 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

What url are you typing into the browser? When you say 'refresh' it sounds like you are just reloading main.html. If you want the pin status on the main page you will (obviously) have to put the gpio reading code into that function (hello()). Otherwise you will have to enter the route to readPin12()...
by paddyg
Tue Jul 24, 2018 9:26 am
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

Well, if you don't want a variable pin number then it's not a 'variable'. Most (all) languages can't cope with variables named '12'. At this point I should say that if you are just getting into programming then learning to make interactive web pages is a bad place to start. A sound investment on you...
by paddyg
Tue Jul 24, 2018 6:59 am
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

he uses a system now pretty universal with dynamic Web apps where routing to different 'pages' and arguments are passed in the url. In the example you posted putting pin in angle brackets does the magic @app.route("/readPin/<pin>") def readPin(pin): try: means you can feed a url such as .../readPin/...
by paddyg
Mon Jul 23, 2018 11:05 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

As @topguy says, web pages aren't normally 'running' like a python loop, you have to manually refresh them to see if any changes have happened. You can put some javascript on your display page that can loop and read an information serving page but generally speaking the way web pages work takes a wh...
by paddyg
Mon Jul 23, 2018 8:59 pm
Forum: Python
Topic: Deleting a data series in a bar chart (matplotlib)
Replies: 2
Views: 86

Re: Deleting a data series in a bar chart (matplotlib)

Something like this seems to work. Most of the code is verifying that the plot has changed. There might well be a more official way of doing this, by the way. import matplotlib.pyplot as plt x = [i for i in range(0,11)] y = [i for i in range(5,16)] y2 = [i for i in range(4,15)] y3 = [i for i in rang...
by paddyg
Mon Jul 23, 2018 12:16 pm
Forum: Python
Topic: Switch with Raspberry Pi - Python
Replies: 32
Views: 841

Re: Switch with Raspberry Pi - Python

you need some curly brackets in your template and create some html to go in them. Were you getting the button status printed on the terminal?

look at some flask tutorials https://code.visualstudio.com/docs/pyth ... der-a-page for instance
by paddyg
Sat Jul 21, 2018 10:01 pm
Forum: OpenGLES
Topic: Star Citizen on the Raspberry Pi?!
Replies: 100
Views: 4077

Re: Star Citizen on the Raspberry Pi?!

Tim, yes I meant SirionBridge (unexpected ambiguity between parts of a medieval castle and futuristic spacecraft). I also managed to fall through a window near the radar screen. But to be honest the collision testing is remarkably good.
by paddyg
Sat Jul 21, 2018 9:24 pm
Forum: OpenGLES
Topic: Star Citizen on the Raspberry Pi?!
Replies: 100
Views: 4077

Re: Star Citizen on the Raspberry Pi?!

Tim, I can report that your multi-scene download works on the RPi nicely. I had to globally change the \r\n line ending in Kendal castle mtl file to \n before it would load any textures and I had to rename a couple of the bridge textures to match (fx3_panels and medmon1 I think). Paddy PS it's worry...

Go to advanced search