Go to advanced search

by yeahbox
Wed Nov 28, 2012 12:22 am
Forum: Python
Topic: Simple print question
Replies: 3
Views: 803

Re: Simple print question

What you want is demonstrated here: http://www.raspberrypi.org/phpBB3/viewt ... 32&t=21265
by yeahbox
Sun Nov 25, 2012 11:02 pm
Forum: Python
Topic: Scientific Python
Replies: 20
Views: 10327

Re: Scientific Python

Python 3.x is the future, so if you get it working in 3.x then stay there. No point in going back to 2.x then. It is just a matter of time before people start migrating to 3.x. The fact that more and more packages comes out with support for 3.x now just makes it easier for people like me to take the...
by yeahbox
Sun Nov 25, 2012 2:22 pm
Forum: Python
Topic: getting out a class variable
Replies: 6
Views: 1003

Re: getting out a class variable

Don't forget to call the get_temp() method, this is the only place where you are actually updating the class variable Main.Temp

Code: Select all

C = gpio_heat.Main()
C.get_temp()
print (C.Temp , 'the temp')
by yeahbox
Sun Nov 25, 2012 1:59 pm
Forum: Python
Topic: getting out a class variable
Replies: 6
Views: 1003

Re: getting out a class variable

now I want to get access to the class variables , Main.Temp and Main.Test , which should be something like 16.7 , 5 , with a second script importing from the first one. #!/usr/bin/env python3 import sys from time import sleep import gpio_heat A = gpio_heat.Main.Temp B = gpio_heat.Main.Temp print ( ...
by yeahbox
Sun Nov 25, 2012 1:36 pm
Forum: Python
Topic: Scientific Python
Replies: 20
Views: 10327

Re: Scientific Python

I've installed matplotlib, but I can't seem to import it while using Python 3.2. I can import it from 2.7. You need to be a little bit more aware of what versions you are using. As mentioned above, if you used sudo apt-get install python-matplotlib then you get the packages that are matched to the ...
by yeahbox
Sat Nov 24, 2012 2:27 pm
Forum: Python
Topic: Streaming audio with Python
Replies: 9
Views: 27809

Re: Streaming audio with Python

Important note here - pyaudio spews out tons of diagnostics, including apparent "errors", even in correct operation. PyAudio is only providing bindings for Portaudio. Portaudio is then talking to for example ALSA on a linux machine and MME on a WinXP. So the error messages that you talk about is mo...
by yeahbox
Sat Nov 24, 2012 2:08 pm
Forum: Python
Topic: Streaming audio with Python
Replies: 9
Views: 27809

Re: Streaming audio with Python

Nice work so far but I'm afraid you've got multiple issues and many of them will not work. Keep it simple. Always a good strategy when you try out something new Make sure it works by testing small bits of code and expand functionality as you go along If it doesn't work, go back and read the errors, ...
by yeahbox
Thu Nov 15, 2012 12:36 am
Forum: Python
Topic: Cross-Platform serial comms
Replies: 5
Views: 1526

Re: Cross-Platform serial comms

If you just want to know what platform you are running on, try

Code: Select all

>>> import sys
>>> sys.platform
'darwin'
>>> sys.byteorder
'little'
>>> 
by yeahbox
Thu Nov 01, 2012 11:41 pm
Forum: Raspbian
Topic: New stable firmware update
Replies: 46
Views: 26868

Re: New stable firmware update

I also ran into some boot trouble after updating. I had 2012-09-18-wheezy-raspbian installed on my 256 MB RasPi. I was using the standard settings before so I wasn't modifying anything regarding overclocking or memorysplit. So I would say that my setup was pretty much standard and now it won't boot....
by yeahbox
Tue Oct 30, 2012 11:37 pm
Forum: Python
Topic: executing a program
Replies: 6
Views: 1400

Re: executing a program

If you are using IDLE you can press F5 to run your program. You can also play around interactively on the IDLE prompt, which is a great way of learning how different commands work. IDLE helps you by suggesting things that you can do by pressing TAB when you are writing your command. For example, try...
by yeahbox
Sun Oct 28, 2012 6:34 pm
Forum: Python
Topic: randomly occurring struct.error
Replies: 3
Views: 1327

Re: randomly occurring struct.error

I think you need to check the data that you read from the socket a little bit more. It is probably not a problem with struct, it's more likely that you read something you didn't expect from the socket. Also, it might seem silly when you do it, but write comments in english even though your native la...
by yeahbox
Sun Oct 28, 2012 1:57 pm
Forum: Python
Topic: How to print repeatedly to the same line?
Replies: 10
Views: 3085

Re: How to print repeatedly to the same line?

I did some quick googling and found this, http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python So my slight modification of that would be import os rows, columns = map(int, os.popen('stty size', 'r').read().split()) I don't think this is a general solution that works e...
by yeahbox
Sat Oct 27, 2012 11:05 pm
Forum: Python
Topic: How do I save a python script?
Replies: 3
Views: 984

Re: How do I save a python script?

I wrote a very basic example here that might help you along: http://www.raspberrypi.org/phpBB3/viewt ... =31&t=7102
by yeahbox
Sat Oct 27, 2012 11:00 pm
Forum: Python
Topic: How to print repeatedly to the same line?
Replies: 10
Views: 3085

Re: How to print repeatedly to the same line?

How can I get rid of the space between each entry? Ah, enter some python magic :) You can use the print() function from python 3.x even though you are running 2.7. See http://docs.python.org/library/functions.html#print for the official doc. Note that the "from __future__" stuff must be at the top ...
by yeahbox
Sat Oct 27, 2012 9:41 pm
Forum: Python
Topic: How to print repeatedly to the same line?
Replies: 10
Views: 3085

Re: How to print repeatedly to the same line?

I tried appending a comma , but then it fails to print anything at all until the loop has gone through all iterations. I want it to display each character as it goes. I'm sure it must be simple. But it eludes me. Everything is simple when you know the answer :) You need to flush stdout in order to ...
by yeahbox
Sun Oct 14, 2012 12:10 am
Forum: Graphics, sound and multimedia
Topic: Best way to get very precise sample playback w/multiple RPs?
Replies: 13
Views: 3451

Re: Best way to get very precise sample playback w/multiple

Even if you manage to syncronise the start of the playback of your sound(s) you will quickly run into trouble unless you take into account the inaccuracy in sample rates between different DA converters. 44100 Hz samplerate is more like 44100.00034154 Hz on one device and 44100.00053245 Hz on another...
by yeahbox
Sat Oct 13, 2012 11:19 pm
Forum: Automation, sensing and robotics
Topic: How can you use a pi to controlled a mains switch
Replies: 32
Views: 19990

Re: How can you use a pi to controlled a mains switch

No one in this thread has mentioned Telldus yet (http://telldus.se/) which is working really nice, I have a Tellstick duo connected to my raspi and I can turn on and off switches and also read temperatures from different temperature transmitters. So this would leave the hardware bit solved for you a...
by yeahbox
Mon Aug 27, 2012 3:53 pm
Forum: Graphics, sound and multimedia
Topic: writing directly to Pi's audio output?
Replies: 10
Views: 9795

Re: writing directly to Pi's audio output?

You might want to check out portaudio http://www.portaudio.com which will abstract away the hardware layer. If ALSA behaves then it is quite nice to work with portaudio. The advantage is that your application could be developed and tested on another machine (win/mac/lin) using another soundcard. The...
by yeahbox
Mon Aug 27, 2012 3:36 pm
Forum: Graphics, sound and multimedia
Topic: MPEG-2 license also for mp3?
Replies: 11
Views: 4223

Re: MPEG-2 license also for mp3?

Just make this clear, MP3 has nothing to do with MPEG-2 . Well, that's stretching it. MPEG-2 also defines audiolayer 1, 2 and 3, so you do have a layer 3 structure in MPEG-2 The difference is the samplerates (and some additional bitrates), where MPEG-1 layer 3 is 32kHz, 44.1kHz and 48kHz but MPEG-2...
by yeahbox
Thu Jun 28, 2012 12:08 am
Forum: Media centres
Topic: AirPlay
Replies: 39
Views: 36559

Re: AirPlay

I also installed Shairport the other day and I also got it playing. I did only test it briefly since the audio quality is poor on the built in analoge output and I just wanted to check if it worked. This is my educated guess/theory: The real airport express have an ASRC (Asyncronous Sample Rate Conv...
by yeahbox
Mon Jun 25, 2012 11:39 pm
Forum: General programming discussion
Topic: where to start? (learning C, C++)
Replies: 19
Views: 8527

Re: where to start? (learning C, C++)

I never miss an opportunity to recommend Python because is is a very nice language and I get payed every day writing Python code. If you are a HW engineer then maybe C would feel more natural because you are closer to the hardware, if you for example want to set some bits in a register somewhere. Bu...
by yeahbox
Mon Jun 25, 2012 11:05 pm
Forum: Python
Topic: Python becoming popular in the Enterprise
Replies: 4
Views: 1924

Re: Python becoming popular in the Enterprise

My home programming language is C#, but I downloaded the book Python 3 Object Oriented Programming. I have to say that python seems pretty bad in an object orientated "mode". I was disappointed. But i've only finished chapter 3. You should probably read some more chapters in your book before you ca...
by yeahbox
Mon Jun 25, 2012 10:28 pm
Forum: Graphics, sound and multimedia
Topic: Noise at front of audio playback
Replies: 49
Views: 33102

Re: Noise at front of audio playback

Sounds like there are some buffers that needs to be cleared properly here. I don't know much about ALSA but there must be some sort of output buffer that samples are written to. This buffer must be cleared of all previous samples before it is filled with the new samples that we want to play. There s...
by yeahbox
Mon Jun 11, 2012 7:16 am
Forum: Python
Topic: IDLE for Python on Debian
Replies: 7
Views: 16854

Re: IDLE for Python on Debian

whats so good about IDLE ? The good thing with IDLE is that it comes with the standard distribution of Python and it works (the same) in Win/MacOS/Linux. So if you want to be up and running quickly it is an excellent choice if IDE/editor. However it soon becomes too limited in functionality and the...
by yeahbox
Sun Jun 10, 2012 11:00 pm
Forum: Python
Topic: working with times and dates
Replies: 7
Views: 7255

Re: working with times and dates

1) If you know that the value you want to convert really is an integer, you can just use int() to convert it, like for example int('21') will result in the integer 21. This will raise an exception if it can't be converted. 2) You could use a try-except: import time try: while True: hour = time.strft...

Go to advanced search