Go to advanced search

by paddyg
Tue Jun 05, 2018 7:26 am
Forum: Other programming languages
Topic: rust version of pi3d (python graphics & 3D)
Replies: 2
Views: 284

Re: rust version of pi3d (python graphics & 3D)

good point. It depends, of course on where the bottlenecks are. Which is probably my next step (ie profiling). After a superficial test (varying polygons, pixels and number of objects to draw) The slow part on the RPI, at any rate, seems to be inside the new GL driver so building SDL to use the broa...
by paddyg
Mon Jun 04, 2018 7:03 pm
Forum: Other programming languages
Topic: rust version of pi3d (python graphics & 3D)
Replies: 2
Views: 284

rust version of pi3d (python graphics & 3D)

Anyone curious about rust (maybe after seeing the significant increase in speed with firefox quantum, or hearing that it will be the replacement for C/C++...!)? As an experiment I've started converting the python module pi3d to rust. I'm trying to keep the structure of the code as much in step as po...
by paddyg
Thu May 24, 2018 7:51 am
Forum: OpenGLES
Topic: getting a square-pixels pi3d Display
Replies: 3
Views: 407

Re: getting a square-pixels pi3d Display

Just for completeness. The further discussion here https://github.com/tipam/pi3d/issues/224 hopefully solved the problem for the OP
by paddyg
Tue May 15, 2018 11:36 pm
Forum: Python
Topic: Streaming a Pygame window
Replies: 2
Views: 151

Re: Streaming a Pygame window

Don't know if it's any use but I've used realvnc with the experimental video setting to remotely view the full graphics from the RPi remotely (doesn't have to have x11 server running unless you want to do file transfer and other things.) (Also it doesn't seem to be happy with the GL driver enabled)
by paddyg
Tue May 15, 2018 11:32 pm
Forum: Python
Topic: Passing Variables as Arguments to Timer Objects and other Functions
Replies: 2
Views: 164

Re: Passing Variables as Arguments to Timer Objects and other Functions

I wouldn't use the * expansion - it can be rather confusing. It basically expands a list or tuple into separate arguments for passing to a function, which is why python complains when you use it as you call the function. I would pass the list like this, which is easier to understand until you become...
by paddyg
Tue May 15, 2018 11:17 pm
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Jim, sorry not to reply to your previous post. Lots of good ideas there - I was partly diverted because of some thoughts I had about making pi3d easier to set up on Windows and OSX by using an openGL wrapper such as SDL2. The main reason for not going down that route has been the speed impact on the...
by paddyg
Fri May 11, 2018 7:43 am
Forum: Python
Topic: Using Python to look for a difference in response to HTML request from a website's API
Replies: 14
Views: 427

Re: Using Python to look for a difference in response to HTML request from a website's API

That kind of thing can be easy with python using urllib request. I've just done it for this page using this code import urllib.request import time URL = 'https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=213259' old_txt = None while True: with urllib.request.urlopen(URL) as response: new_txt =...
by paddyg
Thu May 10, 2018 10:58 pm
Forum: Python
Topic: button stop
Replies: 1
Views: 128

Re: button stop

Some of your indentation looks wrong, possibly you've mixed tabs and spaces. If you tidy that up it will be easier to help but if your elif goes with your if and you set prev_input equal to input at the end each loop then I would expect something more like elif prev_input and not input: The way you ...
by paddyg
Thu May 10, 2018 7:02 pm
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

That sounds bad. There's lots of scope for unsafe operations patching pointers and untyped python variables into gl functions. What python are you running and is it 64 or 32 bits? This laptop is also i5 8Gb with windows 10 - but it's in as small a partition as I thought I could get away with and it ...
by paddyg
Tue May 08, 2018 2:58 pm
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Hmm, there is a ShadowCaster class and shader that works ok for shadows cast onto the ground or other objects (see CastShadows and TigerShadow demos) but I can't get it to work for your rings (and I can't really remember how it works) I will have a look later.
by paddyg
Tue May 08, 2018 9:31 am
Forum: Python
Topic: Timezone Clock - Can this code be better?
Replies: 4
Views: 258

Re: Timezone Clock - Can this code be better?

google DRY v WET coding. This kind of thing (not tested at all so possibly full of typos etc.) #!/usr/bin/python import time import datetime import pytz from Adafruit_LED_Backpack import SevenSegment brightness = 15 # =========================================================================== # Cloc...
by paddyg
Tue May 08, 2018 8:15 am
Forum: Python
Topic: Using Hall Effect Sensor to measure wheel speed
Replies: 2
Views: 162

Re: Using Hall Effect Sensor to measure wheel speed

Hard to give much help without knowing what problems you've had, what sensor you're using and how you've wired it up and configured your software. But this is from a recent exercise bike project with all the extraneous bits deleted (hopefully I've not deleted anything vital!) I suggest you switch to...
by paddyg
Sun May 06, 2018 7:28 am
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Checked the Starfield.py demo on windows and noticed that Diplay.create() has the samples argument . This improves antialiassing for white lines on a black background, unfortunately it doesn't seem to have been implemented in the ANGLE software (maybe I should checkout the latest source code and rec...
by paddyg
Sat May 05, 2018 8:42 am
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

This kind of thing. The default size of a Triangle is side length 1 so sometimes you need to specify the corners or set_alpha(0.0) to hide them. ... saturnimg = pi3d.Texture("textures/Saturn_1024x512.jpg") empty0 = pi3d.Triangle(z=100.0) # displaced empty1 = pi3d.Triangle(rx=85.0) # no displacement ...
by paddyg
Fri May 04, 2018 10:24 pm
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Jim, I'll run this in the morning and show you what to do but basically the best way of doing things like this is using the parent-child system (The gun and turret of the TigerTank demo uses this, and probably others) So what you want is probably for both Saturn and its rings to be children of a 'em...
by paddyg
Sun Apr 29, 2018 8:15 am
Forum: Python
Topic: "pip uninstall" won't
Replies: 11
Views: 521

Re: "pip uninstall" won't

Did the example code have "import PIL" explicitly, and that's what caused the error or was the error subsequent when you tried to do something with PIL giving something such as "module 'PIL' has no attribute Image"? I think the old PIL did used to import PIL but new PIL (pillow) needs to do "from PI...
by paddyg
Sat Apr 28, 2018 9:45 am
Forum: Python
Topic: Installing Program requiring Python 2.7 when default is 3.x
Replies: 17
Views: 632

Re: Installing Program requiring Python 2.7 when default is 3.x

Hopefully the powers behind the scenes (Ted?) *do* have a plan and are rushing to get rid of any python2 dependencies so that nothing breaks when python becomes python3 (next year). In the mean time, each week that goes by adds to the problem as people start to learn how to program unaware that pyth...
by paddyg
Sat Apr 28, 2018 8:44 am
Forum: Python
Topic: Installing Program requiring Python 2.7 when default is 3.x
Replies: 17
Views: 632

Re: Installing Program requiring Python 2.7 when default is 3.x

@B.Goode, yes you're right generally but weewx seems to have simplified installing and running http://weewx.com/docs/debian.htm [I was looking at the wrong page before!! :oops: It needs python-configobj, python-cheetah and python-imaging. I think all those have py3 versions now but it's a long-winde...
by paddyg
Sat Apr 28, 2018 6:59 am
Forum: Python
Topic: Installing Program requiring Python 2.7 when default is 3.x
Replies: 17
Views: 632

Re: Installing Program requiring Python 2.7 when default is 3.x

I would side with @pfletch101 on this. In my opinion raspbian should have switched to defaulting to py3 months ago. In only 'a few months' support is going to be dropped for py2. I've not looked in detail at the source for weewx but I doubt very much that it needs to be py2 only - marshmallow-sqlalc...
by paddyg
Fri Apr 27, 2018 11:11 pm
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Jim, I think the area covered by the HYG-database is fairly local in galactic terms. Flying around the StarField.py demo makes you realize how gigantic the universe. To fly though the stars so they stream past sci-fi like you need to press w enough times to get up to a step size per frame of about 3...
by paddyg
Fri Apr 27, 2018 11:25 am
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

OK, the problem is that the Tube class uses Shape._lathe() to construct itself and that convenience method is designed to cope with any shape with rotational symmetry (and or shifted as in helix). This is used for Sphere, Cylinder, Cone, Helix, Tube, Torus, TCone, Lathe and it assumes that the Textu...
by paddyg
Fri Apr 27, 2018 6:39 am
Forum: Python
Topic: Pi3D
Replies: 241
Views: 25596

Re: Pi3D

Jim, great to hear from you again. I'll have a look at the tube distortion issue, it looks like the uv texture coordinates are being calculated wrong! On the realistic star map issue, I did just the thing you're looking for (for a local raspberry jam a couple of years ago) and replaced the existing ...
by paddyg
Tue Apr 24, 2018 3:02 pm
Forum: Python
Topic: Stop to play file!
Replies: 10
Views: 487

Re: Stop to play file!

import pygame.mixer from pygame.mixer import Sound from time import sleep from gpiozero import Button pygame.init() pygame.mixer.init() screen = pygame.display.set_mode((500,50)) but_a = Button(2) # allocate variable names so these can be referred to by pressing keyboard but_b = Button(3) button_so...
by paddyg
Sun Apr 22, 2018 4:31 pm
Forum: Python
Topic: Thread behaviour in Idle and Thonny
Replies: 10
Views: 337

Re: Thread behaviour in Idle and Thonny

the convention in python is that properties or methods named with an initial underscore are to be treated as privateish. Use them if you want but make sure you have a thorough knowledge of the module source code and know exactly what the consequences will be. ps I have found that a small number of t...
by paddyg
Thu Apr 19, 2018 8:10 pm
Forum: Python
Topic: Stop to play file!
Replies: 10
Views: 487

Re: Stop to play file!

well, stick with the system as before. in v.2 you need to replace 'a' with Button(2) etc in the definition of button_sounds. Then after that set the callback for each button. Do it in a loop as I suggested before. It's effectively doing for b in button_sounds: b.when_pressed = toggle_sound I'm in th...

Go to advanced search