Go to advanced search

by paddyg
Sun Oct 21, 2018 5:35 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Ah, well done spotting and removing the unneeded MEASURE_COUNT. You probably also spotted that the timeout and turn the solenoid off should go at the end of the start_pour just as it was in the function you deleted. I'm not really sure what your video shows as I don't know what the button, or the tw...
by paddyg
Sat Oct 20, 2018 8:10 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

In the code you just posted: highlight lines 37-43 (inclusive) press delete, then save. Alternative look at my post above 19 Oct 09:24 click on 'select all' at the top of the first code sample copy it then highlight all of your current code in your editor and paste over it. (It's exactly the same ex...
by paddyg
Sat Oct 20, 2018 7:55 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Well, as I said above: read the error message (only the last three or four lines generally make any sense, but don't stop reading it until you understand what caused the error) Then look at your code. You will immediately see that start_pour is redefined with an incorrect version after the correct v...
by paddyg
Sat Oct 20, 2018 7:27 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Hi @onlinegill, I'm back at a proper computer now so can see what I'm doing etc. I did correct my previous code when I replied to you and it appears I did it correctly (but there could well be other errors so you might have to debug as before!!). The error message you got pointed to the fact that th...
by paddyg
Sat Oct 20, 2018 6:41 am
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

hi sorry about that the second version of the fuction is incorrect and should be deleted. I tried to do that but hard on phone. I will re.edit prev post
by paddyg
Fri Oct 19, 2018 9:24 am
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Hi, your earlier post with the error message pointed to what the issue might be: that line turning the solenoid off should have been indented because it came just after the if line ending with a colon. However there were other inconsistencies that would have stopped the code working - you had the sa...
by paddyg
Thu Oct 18, 2018 8:47 pm
Forum: Python
Topic: Variable passed to class
Replies: 9
Views: 223

Re: Variable passed to class

@Krafter, I should probably feel sheepish to say this now, (but maybe there's a lesson in not being bashful about exposing ugly code to the 'pundits' (all capable of writing ugly code themselves!)) If we had realized that's what you wanted to do we might have suggested you leave your code as it was ...
by paddyg
Thu Oct 18, 2018 8:34 pm
Forum: Python
Topic: Working with camera
Replies: 1
Views: 102

Re: Working with camera

Using the standard features such as preview must be easier but I have captured picamera images as numpy arrays and displayed them using the gpu like this https://github.com/pi3d/pi3d_demos/blob ... imal_2d.py
by paddyg
Wed Oct 17, 2018 9:47 pm
Forum: Python
Topic: Variable passed to class
Replies: 9
Views: 223

Re: Variable passed to class

Looks quite complicated and it might be better to not suggest anything until you've digested and modified things in the light of comments... but it's probably worth pointing out that you will find life easier if you avoid repeating stuff whenever you can. i.e elif mode ==1 and random == 0 and color ...
by paddyg
Wed Oct 17, 2018 9:20 am
Forum: Python
Topic: Variable passed to class
Replies: 9
Views: 223

Re: Variable passed to class

Python will let you drive rough-shod over normal structured programming. So you could just class RGB: rgb_red = [100, 0, 0] etc ... RGB.my_random_color = [99,50,50] # you can now use your class level attribute! Quite hard to make suggestions without seeing how you intend to use this. Passing a varia...
by paddyg
Tue Oct 16, 2018 8:14 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

I don't mind at all. Just to further confuse you... It would be possible to have just one Button() and press it for different length of time to get different amounts. Along the lines of import time ... SMALL_TM = 0.5 BIG_TM = 3.0 ... def start_timer(): global start_tm start_tm = time.time() def star...
by paddyg
Tue Oct 16, 2018 2:36 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Well, you have to match up the Button() in the software with the physical connection to your RPi. That's up to you to do, but it might be neater to choose three adjacent spare GPIO pins. 14 and 15 would be next to 18 but double up as serial connections so how about three from 5, 6, 13, 19, 26 or fro...
by paddyg
Tue Oct 16, 2018 1:23 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Hi, I glad (and maybe slightly surprised) it worked with only minor indent mismatch! For your own sanity you should get used to putting all your imports at the top (but after the `#!/usr/bin/env python3`) then globals, constants etc. If you stick to a system it will make debugging easier; sensible t...
by paddyg
Mon Oct 15, 2018 10:26 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

well you might find a better example among all the recipes in the docs but I would do something along the lines of this (untested), using LED as generic output and Button for input, may be more appropriate ones (i.e. digitalInputDevice, digitalOutputDevice) from gpiozero import Button, LED from sign...
by paddyg
Mon Oct 15, 2018 8:18 pm
Forum: Python
Topic: stop solenoid valve with flow meter pulse
Replies: 23
Views: 466

Re: stop solenoid valve with flow meter pulse

Hi, I would use the https://gpiozero.readthedocs.io/en/stable/recipes.html module it breaks each 'action' out into a function like you've done with your pulse meter. Have a look at that and post again if you get stuck or something doesn't make sense.

Paddy
by paddyg
Mon Oct 15, 2018 8:03 pm
Forum: Python
Topic: OMXplayer wrapper - Keeping process alive after video ends
Replies: 3
Views: 170

Re: OMXplayer wrapper - Keeping process alive after video ends

This https://www.raspberrypi.org/forums/view ... =omxplayer poster had some issues wrapping omxplayer in python and, I think, managed to sort something out. Not the same specific problem as yours but might have similar solution.
by paddyg
Mon Oct 15, 2018 7:59 pm
Forum: Python
Topic: help i dont know python.
Replies: 2
Views: 96

Re: help i dont know python.

Did you get an error message when you ran the program? If you did that will probably tell you what the problem was. If you didn't then you should add print() statements to try to figure out what's not working. However if you really know no python then you will find it very difficult and I would sugg...
by paddyg
Sun Oct 14, 2018 6:09 pm
Forum: Python
Topic: variable modification thru GPIO
Replies: 4
Views: 141

Re: variable modification thru GPIO

well, at a guess something like (not tested): ... # this is a global 'const' so conventionally uses CAPS SEGMENT_PATTERN = [[0,1,2,3,4,5],[1,2],[0,1,6,4,3],[0,1,2,3,6],[1,2,5,6],[0,2,3,5,6], #0 to 5 [0,2,3,4,5,6],[0,1,2],[0,1,2,3,4,5,6],[0,1,2,5,6],[0,1,2,4,5,6], #6 to A [2,3,4,5,6],[0,3,4,5],[1,2,3...
by paddyg
Fri Oct 12, 2018 11:30 am
Forum: Python
Topic: variable modification thru GPIO
Replies: 4
Views: 141

Re: variable modification thru GPIO

With gpiozero you 'attach' functions to the Button instance to do the work for you https://gpiozero.readthedocs.io/en/stable/recipes.html#button. For your code, approximately (not tested) import RPi.GPIO as IO from gpiozero import LED from gpiozero import Button import time # you can do this - googl...
by paddyg
Fri Oct 12, 2018 9:12 am
Forum: Python
Topic: picamera and Flask - numpy issue
Replies: 4
Views: 170

Re: picamera and Flask - numpy issue

I was really just going by the error message the OP quoted But isn't frame a instance of type Mat? You may well ask! I find the python opencv docs almost impenetrable; they unhelpfully show Python: cv2.imdecode(buf, flags) → retval If you want to find out what a 'retval' is the only way seems to be ...
by paddyg
Fri Oct 05, 2018 9:41 pm
Forum: Python
Topic: No module named 'smbus' on Python3.6.2
Replies: 18
Views: 6431

Re: No module named 'smbus' on Python3.6.2

Well that doesn't sound too weired at all. You almost certainly didn't use pip3 on your old card.

I haven't needed to use smbus but I would heed the advice of a 'regular' like @bensimmo
by paddyg
Fri Oct 05, 2018 8:33 am
Forum: Python
Topic: No module named 'smbus' on Python3.6.2
Replies: 18
Views: 6431

Re: No module named 'smbus' on Python3.6.2

Assuming that you are using `$ python3 simple_smbus2_test.py` on both and `/usr/local/lib/..*../dist-packages/` is the same on both then it's not obvious. Once or twice I've had a missing module error message that was solved by deleting all the *.pyc files
by paddyg
Thu Oct 04, 2018 9:22 pm
Forum: Python
Topic: opening file into python project using cvl and matplotlib
Replies: 6
Views: 154

Re: opening file into python project using cvl and matplotlib

It's hard to know what you actually did but '...I copied the text from the Leafpad to the Nano...' sounds a little bit odd. What I would do is first open a terminal then $ cd '/home/pi/Python-Programs/tutorials/matplotlib tutorial (sentdex)/' $ nano stuff_for_part7 ####### now in the editor delete t...
by paddyg
Thu Oct 04, 2018 10:37 am
Forum: Python
Topic: Error Handling PyQt
Replies: 4
Views: 92

Re: Error Handling PyQt

Hmm, python is normally good at telling you exactly what the problem is and which line is causing it; does that help? I would expect you to need to do def remove(): r = table.currentRow() if r >= 0: dlg.lineEdit_Budget.setText(str(float(table.item(r,1).text()) + float(dlg.lineEdit_Budget.text()))) d...
by paddyg
Thu Oct 04, 2018 10:22 am
Forum: Python
Topic: Error Handling PyQt
Replies: 4
Views: 92

Re: Error Handling PyQt

After the line where you `r = table.currentRow()` check that it's >= 0 (I think it will be -1 if no row is selected) You can then either pop up an alert or change a label field accordingly.

Go to advanced search