Go to advanced search

by paddyg
Sat Sep 23, 2017 4:36 pm
Forum: Python
Topic: Write a python code in Raspberry Pi to receive signals from Arduino when a pushbutton on the Arduino board is pressed
Replies: 1
Views: 45

Re: Write a python code in Raspberry Pi to receive signals from Arduino when a pushbutton on the Arduino board is presse

This code I found from earlier this year getting gps via arduino (to laptop but essentially same thing with different serial (probably as you have, assuming you looked that up somewhere)). Also commented out writing to file and reduce indent accordingly. import serial ser = serial.Serial('/dev/ttyUS...
by paddyg
Fri Sep 22, 2017 8:55 pm
Forum: Python
Topic: XBox 360 controller I want something to happen when button A is keydown.
Replies: 2
Views: 70

Re: XBox 360 controller I want something to happen when button A is keydown.

I'm not sure what the problem is (I didn't look very hard and you didn't list any error messages etc) but I know it's a really bad idea to use function names or files names which are the same as standard python built-ins (or already used in standard modules) i.e. input() and quit() are not good.
by paddyg
Thu Sep 21, 2017 11:22 pm
Forum: Python
Topic: [solved]Problem writing serial strings
Replies: 2
Views: 74

Re: Problem writing serial strings

you probably have to encode it, first convert the number to a string. You can probably do something like
str(f).encode()
python2 did a lot of things 'automatically' which was ok most of the time but occasionally very frustrating!
by paddyg
Thu Sep 14, 2017 5:23 pm
Forum: Python
Topic: pygame library error?
Replies: 8
Views: 305

Re: pygame library error?

Hi, it might be $ sudo apt-get install libsdl2-dev (this runs on my RPi but pygame already works (but using x11)) there's something about it here https://wiki.libsdl.org/Installation where they point you to the ready built sdl2 here https://buildbot.libsdl.org/sdl-builds/sdl-raspberrypi/?C=M;O=D tho...
by paddyg
Thu Sep 14, 2017 1:51 pm
Forum: Python
Topic: pygame library error?
Replies: 8
Views: 305

Re: pygame library error?

pygame was already installed in the raspbian stretch image. Are you using jessie? (you can tell by running cat /etc/os-release) If you are then you could try upgrading using pip. Something like $ sudo python3 -mpip install pygame --upgrade you might be able to apt-get install from an alternative sou...
by paddyg
Thu Sep 14, 2017 10:46 am
Forum: Python
Topic: pygame library error?
Replies: 8
Views: 305

Re: pygame library error?

Hi, the default pygame on the raspbian stretch image seems to be 1.9.3 (see attached) can you upgrade to that?
Screenshot01.jpg
Screenshot01.jpg (52.26 KiB) Viewed 250 times
by paddyg
Wed Sep 13, 2017 10:35 pm
Forum: Python
Topic: pygame library error?
Replies: 8
Views: 305

Re: pygame library error?

Hi, I've just run this lots of times on ubuntu laptop and on RPi3 with raspbian stretch, python3 and python2 and it seemed fine. I ran top in another terminal and there was no sign of memory usage increasing. The only thing I've done since burning the SD is increase the GPU memory, set up vnc server...
by paddyg
Wed Sep 13, 2017 1:32 pm
Forum: Python
Topic: Python speed, benchmarks, 2v3
Replies: 18
Views: 904

Re: Python speed, benchmarks, 2v3

I've profiled quite a bit but it's quite hard to extrapolate. I was mainly trying to just get rid of bottlenecks rather than compare 2 v 3, but I did look at the pypy profile (and concluded that it was essentially incomparable!) You can see, however, that py3 is doing an awful lot more function call...
by paddyg
Wed Sep 13, 2017 10:58 am
Forum: Python
Topic: Python speed, benchmarks, 2v3
Replies: 18
Views: 904

Re: Python speed, benchmarks, 2v3

@gkreidl Hi, thanks for pointing me here (better not to subvert @ozziepiuser's thread any more). I've not used pystone before but it certainly does give py2.7 a speed advantage over py3.5. Just to check my own sanity I reran recent programs and, although py2 often came out faster, it is by a much sm...
by paddyg
Wed Sep 13, 2017 10:25 am
Forum: Python
Topic: What to do with “Unexpected indent” in python 3? "while True:
Replies: 7
Views: 327

Re: What to do with “Unexpected indent” in python 3? "while True:

In my experience this has 99.9% been due to mixed tabs and spaces, either with multiple people working on a project or me copying some useful code from somewhere else. To start with I was fairly tabspace agnostic but I now always use spaces and set the editor (geany) to show whitespace and formattin...
by paddyg
Wed Sep 13, 2017 10:16 am
Forum: Python
Topic: Retrieving value from external pigpio script
Replies: 7
Views: 245

Re: Retrieving value from external pigpio script

Hi, glad you got it working. It's hard to tell from your snippets of code but it all looks rather complicated. I guess you must instantiate your class then have some way for the program to not exit immediately. Something like m = Main() m.Setup() while True: and Setup() looks to start another thread...
by paddyg
Mon Sep 11, 2017 10:15 pm
Forum: Python
Topic: need help to learn python
Replies: 17
Views: 480

Re: need help to learn python

I've done quite a bit of speed testing (to squeeze fps out of pi3d) On this laptop (64bit linux) there's basically no difference now between py2 and py3 in terms of speed. On the raspberry pi you will find that some things are faster with python2 (very_long_list.index() 195ns v. 202ns) but other are...
by paddyg
Mon Sep 11, 2017 8:58 pm
Forum: Python
Topic: Retrieving value from external pigpio script
Replies: 7
Views: 245

Re: Retrieving value from external pigpio script

OK. One thing that did occur to me was that the p.stdout.readline() approach will block until it gets a new line character or it timesout (whereas the frequency() call will just give you the latest frequency) Any kind of blocking in the main while loop is the main pitfall people run into.
by paddyg
Mon Sep 11, 2017 8:45 pm
Forum: Python
Topic: function for write to chronodot
Replies: 2
Views: 119

Re: function for write to chronodot

well you can simply pass a tuple (or list) def write_chronodot(data): i2c_bus.write_i2c_block_data(0x68,0x00,data) # write 3 chronodot registers (sec-min-hour) print ("1= ",data[0]) ... data = (sec, min, hour) = (1, 2, 3) write_chronodot(data) # to set time ... (s, m, h) = read_chronodot() print("se...
by paddyg
Mon Sep 11, 2017 11:30 am
Forum: Python
Topic: Retrieving value from external pigpio script
Replies: 7
Views: 245

Re: Retrieving value from external pigpio script

Well I should think the os piping of output and input is pretty efficient but it feels better to put it all in one application without the complications of sending info back and forth. I don't know what your 'main' application is going to do but I would simply put it all in the part of your listing....
by paddyg
Sun Sep 10, 2017 5:43 pm
Forum: Python
Topic: Python referencing db connection in another script
Replies: 3
Views: 156

Re: Python referencing db connection in another script

I would get it working as a very simple single file first and split it up later. I would make sure I could get info from the db by printing values to screen. The syntax looks a bit odd where you import the class then have with OpenConn.Open_Conn: which isn't syntax I'm familiar with. a) I would expe...
by paddyg
Sun Sep 10, 2017 5:20 pm
Forum: Python
Topic: No module named 'smbus' on Python3.6.2
Replies: 11
Views: 246

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

IMHO the python2v3 and pip2v3 ambiguity is an unasked for complication. At this stage (stretch) "python" and "pip" as symbolic links to python2.7 should have been removed so users have to type python2, python3, pip2 or pip3. At the next issue of debian (buster) python and pip should point to python3...
by paddyg
Sun Sep 10, 2017 1:19 pm
Forum: Python
Topic: No module named 'smbus' on Python3.6.2
Replies: 11
Views: 246

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

and did smbus2 (as per the bottom of the thread) not work?
by paddyg
Sun Sep 10, 2017 12:59 pm
Forum: Python
Topic: No module named 'smbus' on Python3.6.2
Replies: 11
Views: 246

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

viewtopic.php?f=32&t=122260 might be relevant (they seem to say you need to pip3 install it)
by paddyg
Sun Sep 10, 2017 12:36 pm
Forum: Python
Topic: Retrieving value from external pigpio script
Replies: 7
Views: 245

Re: Retrieving value from external pigpio script

try flushing your output. in pwm_monitor.py import time import sys i = 0 while True: print(i) sys.stdout.flush() i += 1 time.sleep(5.0) then in temp1.py import time import subprocess p = subprocess.Popen(['python3','pwm_monitor.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: prin...
by paddyg
Fri Sep 08, 2017 5:05 pm
Forum: Python
Topic: pypy with numpy
Replies: 1
Views: 199

Re: pypy with numpy

Just rechecked this following the move to raspbian stretch. The good news is that the pypy 'bundled' with the system is now 5.6 and I found a reasonably simple way to get numpy and PIL using pip. The confusing thing is that the current versions of these two modules don't work! (Not checked if it's j...
by paddyg
Thu Sep 07, 2017 10:45 pm
Forum: OpenGLES
Topic: How to use OpenGL
Replies: 10
Views: 931

Re: How to use OpenGL

I attempted to explain 3D graphics with OpenGL(ES2) and pi3d here. As @derhass says: being comfortable with vectors and matrices will help enormously if you want to understand the low level stuff.
by paddyg
Wed Sep 06, 2017 3:31 pm
Forum: Python
Topic: How to display simple game on 32x32 matrix?
Replies: 2
Views: 123

Re: How to display simple game on 32x32 matrix?

@Tomacco That's actually pretty impressive, especially for a first program! But runs too fast with inadequate bullets for me to survive long. To get it working on 32x32 matrix might not be too bad but I think you will have to branch away from the turtle display (and possibly key input). With such a ...
by paddyg
Wed Sep 06, 2017 9:27 am
Forum: Python
Topic: Alarm clock
Replies: 14
Views: 464

Re: Alarm clock

Well my comment still applies. LCD is not the same token as lcd ! (Also the file names and line numbers in your error messages don't match your github file so still a bit of a guess) To be fair, again, python allows you to be rather slack with the scope of variables. Really you should specify global...
by paddyg
Tue Sep 05, 2017 10:33 pm
Forum: Python
Topic: Alarm clock
Replies: 14
Views: 464

Re: Alarm clock

Without your code it's pretty much impossible to help you much more than reiterate the error messages that you (presumably) have already read. It looks like you're importing a module called LCD (or importing it as LCD) and you are trying to call methods as if it's an instance of a class. In the Adaf...

Go to advanced search