Go to advanced search

by paddyg
Mon Jan 22, 2018 5:20 pm
Forum: Python
Topic: Multithreading guidiance
Replies: 11
Views: 257

Re: Multithreading guidiance

Ah yes there are a couple of things. It's a bit trickier because Qt has a 'hidden' loop system designed to make it hard to figure out what's going on. You can do threading two ways. First as you did originally by inheriting Thread and overriding start() and or run(). That's quite a tidy way that avo...
by paddyg
Mon Jan 22, 2018 10:42 am
Forum: Python
Topic: Robot web control and distance sensor working in parallel
Replies: 2
Views: 60

Re: Robot web control and distance sensor working in parallel

As the Flask functions only run when requested by the web request you are probably best off moving the contents of your drive function to a different thread with a loop forever in it and make your Flask get() functionality in drive() simply set various state values to effect the behaviour. In someth...
by paddyg
Mon Jan 22, 2018 12:30 am
Forum: Python
Topic: Multithreading guidiance
Replies: 11
Views: 257

Re: Multithreading guidiance

It looks quite complicated code so I might have missed this in your code but I would expect to see a thread function that has an infinite loop which keeps reading from your sensor and writing the result into a global variable (or, better an object that you passed to the function when you started it,...
by paddyg
Sat Jan 13, 2018 7:23 pm
Forum: Python
Topic: crop image problem
Replies: 1
Views: 61

Re: crop image problem

With tk you need to use the built in loop system and get it to do regular updates using the 'after' function to recursively call a function. This is rather hacky mod of your code that works on this laptop. import tkinter as tk from PIL import Image, ImageTk deneme = tk.Tk() deneme.geometry("400x400"...
by paddyg
Sun Dec 24, 2017 8:52 am
Forum: Python
Topic: Calling specific int in python
Replies: 3
Views: 209

Re: Calling specific int in python

You may be better describing what you want to do with words as well/instead of using pseudocode. Obviously I am familiar with odes as a form of archaic poetry and I know how to solve differential equations but I don't know what i, s, and d are. Also l can't really tell what your 'this' and 'it', tha...
by paddyg
Sat Dec 23, 2017 12:05 pm
Forum: Python
Topic: Calling specific int in python
Replies: 3
Views: 209

Re: Calling specific int in python

Hi, you can't use f1, f2 etc without defining them first. You can just xx=np.array([0.01,0.012,0.014,0.016]) yy=np.array([32.95388698,33.87900347,33.84214074,34.11856704]) f = xx + yy print(f) ## gives ## array([ 32.96388698, 33.89100347, 33.85614074, 34.13456704]) and you can access elements of f u...
by paddyg
Fri Dec 15, 2017 9:41 am
Forum: Python
Topic: Can't create callback thread. Too many simultaneous pigpio connections
Replies: 2
Views: 241

Re: Can't create callback thread. Too many simultaneous pigpio connections

Try doing all your setup stuff once, at the beginning, and limit your while loop function to checking. No idea if this will help but it seems very wasteful to do all the setup each time you call the function. def displaystops(): try: if topstop.value: # don't need to check if True ==True set_pixel(7...
by paddyg
Wed Dec 13, 2017 11:24 pm
Forum: Networking and servers
Topic: How-to: AP+wifi client on Zero W with Stretch Lite
Replies: 12
Views: 1720

Re: How-to: AP+wifi client on Zero W with Stretch Lite

Cheers, I can live with this. It's not bad really compared with a 'big' computer start up time. I think I must have been spoiled doing the initial testing on my RPi 3; I could fiddle around then reboot and it only seemed to take a few seconds! Thanks again for your detailed instructions.
by paddyg
Wed Dec 13, 2017 7:41 pm
Forum: Networking and servers
Topic: How-to: AP+wifi client on Zero W with Stretch Lite
Replies: 12
Views: 1720

Re: How-to: AP+wifi client on Zero W with Stretch Lite

@SurferTim Thanks, yes that's what I want, and in fact it does work really well as it is... apart from booting up stops for a long time at Started hostname services.. Start job is running... ...then ..DHCPDISCOVER on wlan0... interval 5.. 9..17..21 etc at the end. w.r.t. your instructions above (whi...
by paddyg
Wed Dec 13, 2017 6:13 pm
Forum: Networking and servers
Topic: How-to: AP+wifi client on Zero W with Stretch Lite
Replies: 12
Views: 1720

Re: How-to: AP+wifi client on Zero W with Stretch Lite

Thanks from me also. I'm using @SurferTim's version and it works OK.. but my situation is slightly different. I want the RPi zero to act as a wifi hotspot running a local server (I'm using Flask) to feed physical monitoring info back to A.N.Other's mobile phone. I really don't want the RPi to be abl...
by paddyg
Mon Dec 04, 2017 10:34 am
Forum: Python
Topic: New and need some help with automated chicken coop
Replies: 3
Views: 285

Re: New and need some help

As a general suggestion I would do this by keeping variables with the previous state and check these in your conditions. I would also have a WATER_TEMP_FREEZE_LOW value lower than WATER_TEMP_FREEZE_HIGH to force hysteresis behaviour (as you do with the 'normal' temperature). def waterHeater(self): f...
by paddyg
Wed Nov 29, 2017 3:43 pm
Forum: Python
Topic: Segmentation Fault using PyQt5 with Raspbian
Replies: 2
Views: 210

Re: Segmentation Fault using PyQt5 with Raspbian

Might be a red herring but since stretch the two library files I need to load have been moved see here. to opt/vc/lib/libbrcmEGL.so
by paddyg
Tue Nov 28, 2017 11:47 am
Forum: Advanced users
Topic: Generating Sounds
Replies: 16
Views: 986

Re: Generating Sounds

by paddyg
Mon Nov 27, 2017 10:45 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 41
Views: 6816

Re: Rust seems to bring some love to Rpi

The arguments for rust are that it's 'easier' to write 'safe' code. The problem is that if the switch is from old C and C++ utilities, not only is the switch from code that's already been written (so requires zero effort to write) and has a large pool of potential maintainers, but it's been very ext...
by paddyg
Mon Nov 27, 2017 9:51 pm
Forum: Advanced users
Topic: Generating Sounds
Replies: 16
Views: 986

Re: Generating Sounds

There are python modules that can process wav files, say, but I've tried doing realtime fft with numpy to create notes from samples and it's not really quick enough (but you might be able to generate the note samples before starting to play them). I have tried csound from python via subprocess.Popen...
by paddyg
Mon Nov 27, 2017 8:22 am
Forum: Python
Topic: How to code a button to turn on a light for a second.
Replies: 6
Views: 383

Re: How to code a button to turn on a light for a second.

Yes. https://pinout.xyz/pinout/pin5_gpio3 here is a handy pin plan that you can click on to see what each IO is suitable for. (Not sure if it's up to date, just the top of the list from a quick google). It's worth putting a very short sleep in your while loop so that even if none of the conditional ...
by paddyg
Sun Nov 26, 2017 11:23 pm
Forum: Python
Topic: How to code a button to turn on a light for a second.
Replies: 6
Views: 383

Re: How to code a button to turn on a light for a second.

will it not whip round that loop five times then stop? You haven't got any sleep in your else block. You could use a while True: to start with to help you test things and introduce sophistication (like a counter) a bit at a time, and only once the rest is working.
by paddyg
Sat Nov 25, 2017 10:04 pm
Forum: Python
Topic: Pythonic MIDI Programming
Replies: 2
Views: 218

Re: Pythonic MIDI Programming

Not exactly sure what functionality you are after (maybe you could give a bit of pseudo code or Delphi from previous) but python List and Dict are very easy to use, are flexible and will probably do most of whatever you might need. on_notes = {} off_notes = {} ... def key_on(num, value, x, y, z): on...
by paddyg
Tue Nov 21, 2017 2:24 pm
Forum: Other languages
Topic: Rust seems to bring some love to Rpi
Replies: 41
Views: 6816

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: 41
Views: 6816

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: 1155

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: 41
Views: 6816

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: 1155

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: 41
Views: 6816

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: 41
Views: 6816

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)

Go to advanced search