Go to advanced search

by paddyg
Tue Nov 21, 2017 2:24 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 27
Views: 4871

Re: Rust seems to bring some love to Rpi

Yes, not sure why. It's a small but real difference (0.950s c.f. 0.925s) I've not looked at the internals of the generated code. Doing a basic prime calculation like the subject of this discussion, I get laptop (to 100,000) 2.35s +/-0.06 C 2.31s +/-0.01 rust RPi3 (to 50,000) 8.01s +/-0.07 C 11.4s +/...
by paddyg
Tue Nov 21, 2017 12:10 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 27
Views: 4871

Re: Rust seems to bring some love to Rpi

Hi, I've only been looking at rust for a week or so.. After reading the post here I uninstalled rust (lenovo i5 laptop ubuntu) and installed rustup as per Laurent's instructions and the required tool-chain for cross compiling. Subsequent to your post I compiled on the RPi3 (just) cargo build --relea...
by paddyg
Tue Nov 21, 2017 9:56 am
Forum: Python
Topic: RISING & FALLING
Replies: 28
Views: 583

Re: RISING & FALLING

I suppose the problem is that the spurious spikes have a falling edge (which can be ignored) but also a rising edge a few ms later (or visa versa), which triggers the gpio callback. I must say, I think the problem might possibly be solved more satisfactorily with some combination of smoothing capaci...
by paddyg
Mon Nov 20, 2017 10:28 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 27
Views: 4871

Re: Rust seems to bring some love to Rpi

@jahboater does that install rustup, cargo etc? I used

Code: Select all

curl https://sh.rustup.rs -sSf | sh
on my RPi which was pretty quick and is the 'preferred' way according to rust-lang.org
by paddyg
Mon Nov 20, 2017 10:01 pm
Forum: Python
Topic: RISING & FALLING
Replies: 28
Views: 583

Re: RISING & FALLING

Hi, are all those changes from random events or are some caused by you switching? It looks like it's steady when it's 1 but when it's 0 it jumps to 1 for a very short time (the opposite of your picture). A simple way to filter short blips would be exponential smoothing with an up threshold and a dow...
by paddyg
Mon Nov 20, 2017 1:11 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 27
Views: 4871

Re: Rust seems to bring some love to Rpi

Sounds like an expanded version of the Raspberry Pi forum rules "Be good to each other" ... But it doesn't say you can't use rust for whatever devilish antisocial purpose you had in mind, just abide by the rules if you contribute to IRC channels, github or official rust.org forum. So you could use r...
by paddyg
Sun Nov 19, 2017 9:47 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 27
Views: 4871

Re: Rust seems to bring some love to Rpi

Quick play with rust and very impressed. see viewtopic.php?f=32&t=188181&p=1236770#p1236770 (running rust from python)
by paddyg
Sun Nov 19, 2017 9:38 pm
Forum: Python
Topic: Porting a C Python module to Python 3
Replies: 8
Views: 580

Re: Porting a C Python module to Python 3

For even more completeness, and because I thought it was time to find out more about rust (touted as the successor to C/C++), I added another version here which actually turns out to be faster than the C and cython versions. For a one-off module, rust with ctypes (or cffi) seems to have a lot going ...
by paddyg
Sun Nov 19, 2017 1:59 pm
Forum: Python
Topic: RISING & FALLING
Replies: 28
Views: 583

Re: RISING & FALLING

Hi @fishwolf, it's tricky for us to track down the solution but it's also hard for you without more data (as you are finding). My approach would be a) try to find exactly what happens each time the switch makes or breaks. That's what my previous post was, basically run as simple a program as possibl...
by paddyg
Sat Nov 18, 2017 6:59 pm
Forum: Python
Topic: How to run Threads in Python Concurrently
Replies: 2
Views: 101

Re: How to run Threads in Python Concurrently

Well, you can but some functionality doesn't run unless it's in the main thread. To do it put the code from script one in a function and the code from script two in a different one, set each function as the target of thread and start them both, then pause in some way until you stop the program. Or y...
by paddyg
Sat Nov 18, 2017 10:57 am
Forum: Python
Topic: RISING & FALLING
Replies: 28
Views: 583

Re: RISING & FALLING

If the problem is a 'dirty' edge then you should be able to wait a short while in your callback function. This hypothesis would be consistent with your 'input=0' prints being after a switch to 1 but happening to be sampled 'on a bounce'. Like this (but inverted!): Untitled.jpg It would be easy to te...
by paddyg
Sat Nov 18, 2017 8:39 am
Forum: Python
Topic: RISING & FALLING
Replies: 28
Views: 583

Re: RISING & FALLING

I have had problems that looked similar where I had assumed my switch gave a simple step change but it actually had several on/off events in the microsecond or so between one state and the next. You can check this by having an ultra simple loop that writes gpio state to a file with open('log.txt', '...
by paddyg
Thu Nov 16, 2017 10:47 am
Forum: Python
Topic: Packaging code
Replies: 5
Views: 136

Re: Packaging code

Yes. That's the disadvantage I mentioned (it has to be typed in). In my opinion it's never worth it but the OP might have invented some miraculous code that they really did need to keep secret until they had finalised the sale of their start-up to Alphabet... Or possibly not.
by paddyg
Thu Nov 16, 2017 10:36 am
Forum: Python
Topic: Packaging code
Replies: 5
Views: 136

Re: Packaging code

You can't really do it in a way that would withstand any kind of serious reverse engineering.. but it's quite easy to make a routine in python that decrypts an encrypted file*. You would then need to execute your decrypted code (as well as decrypt the text file). The disadvantage is that your users ...
by paddyg
Wed Nov 15, 2017 4:05 pm
Forum: Python
Topic: Tkinter in while loop
Replies: 6
Views: 227

Re: Tkinter in while loop

In pi3d there was a decision (before I was involved so don't know all details) that it would be nice to allow tkinter to supply the graphical drawing surface as well as mouse and keyboard stuff. Because this was optional, the main pi3d display loop called tk.update() if required. However in the demo...
by paddyg
Tue Nov 14, 2017 8:31 pm
Forum: Python
Topic: Tkinter in while loop
Replies: 6
Views: 227

Re: Tkinter in while loop

Maybe there's some useful info in the code you run prior to your error message. On the RPi3 if I startx, then a terminal, then python3 I can pi@raspberrypi:~ $ python3 Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "license" for mor...
by paddyg
Tue Nov 14, 2017 8:08 pm
Forum: Python
Topic: getting info from an XML page
Replies: 7
Views: 183

Re: getting info from an XML page

Yes, I've used beutifulsoup too and confirm that it is very good. It's not a big deal to install and the benefit of learning to use it is that it's applicable to parsing info from other websites. This is the only thing I can find easily. You might be able to figure out how it works (I can't really r...
by paddyg
Tue Nov 14, 2017 10:37 am
Forum: Python
Topic: getting info from an XML page
Replies: 7
Views: 183

Re: getting info from an XML page

If you continue down this route, you might be able to glean something from my very basic (but maybe sufficient) parsing using the builtin xml.dom.minidom parse in this https://github.com/tipam/pi3d/blob/master/pi3d/util/PexParticles.py see the xml files it reads here https://github.com/pi3d/pi3d_dem...
by paddyg
Mon Nov 06, 2017 9:59 am
Forum: Python
Topic: HAP Node JS python script
Replies: 1
Views: 148

Re: HAP Node JS python script

In the absence of any code to look at there are hundred of potential answers but the first thing I would look at is the path to the file where you write the 0 or 1. If you don't specify that then I would expect the file to be created in the directory from where the script was run. This would be easy...
by paddyg
Thu Nov 02, 2017 10:57 pm
Forum: Python
Topic: Creat counter with RPi.GPIO add_event_detect callback performance
Replies: 4
Views: 240

Re: Creat counter with RPi.GPIO add_event_detect callback performance

I think I've seen a few comments about the callback system missing occasional edges. What do you get if you just run your counter as a thread with a loop forever and a time.sleep(0.0002), incrementing when last_val != 0 and val == 0? PS quick test on a RPi3 I can read at 230kHz so reading at 5kHz sh...
by paddyg
Thu Nov 02, 2017 4:17 pm
Forum: Python
Topic: arecord through subprocess works randomly in raspberry pi
Replies: 6
Views: 270

Re: how to use pyaudio to record audio controlled by pressing buttons?

Well that sounds like progress. How many times did print(index) run? By the way, you did include the lines that I didn't bother to re-write (i.e. reading from the stream and appending to the frames list variable? (I will edit my previous post to make it clearer, also fix the line that got the wrong ...
by paddyg
Wed Nov 01, 2017 7:21 pm
Forum: Python
Topic: Pi3D - Shifting object texture on shape
Replies: 6
Views: 350

Re: Pi3D - Shifting object texture on shape

Tweaked the fog distance in the shaders so it can control the start as well as complete distance for fog. see: https://github.com/tipam/pi3d/blob/6ee1 ... ape.py#L79 in develop branch at moment, probably release next version over next couple of weeks.
by paddyg
Wed Nov 01, 2017 9:25 am
Forum: Python
Topic: arecord through subprocess works randomly in raspberry pi
Replies: 6
Views: 270

Re: how to use pyaudio to record audio controlled by pressing buttons?

I haven't used pyaudio for years so can't give very specific advice on that. However if you follow the official example it should be OK. One thing that might be an issue on the RPi is the size of the list frames (if you leave it recording for a long time). The good thing about python is that you can...
by paddyg
Tue Oct 31, 2017 11:03 pm
Forum: Python
Topic: arecord through subprocess works randomly in raspberry pi
Replies: 6
Views: 270

Re: how to use pyaudio to record audio by pressing buttons?

I would have thought you needed a variable to hold states representing: button not pressed yet, button pressed once, button pressed more than once (i.e. 0,1,2 or more). You then increment this variable each time the buttons is pressed and replace your condition (that looks at the button state) with ...
by paddyg
Mon Oct 30, 2017 11:17 pm
Forum: Python
Topic: Pyglet and Raspberry Pi (Looking for tear-free 2D rendering library)
Replies: 6
Views: 377

Re: Pyglet and Raspberry Pi (Looking for tear-free 2D rendering library)

Hi, I would be interested to hear how you get on. For a while I've pondered on pros and cons of switching pi3d from directly accessing the broadcom libEGL.so and libGLESv2.so (or libbrcm.. after stretch) directly and using SDL2. It would be an extra layer of abstraction (so presumably slight perform...

Go to advanced search