![]() |
python - how to read information from light meter, microphone and accelerometers?
Hi,
does any know how I can retrieve the information provided by the light meter, microphone and accelerometers? Are there ready to use classes? D-BUS? Any hints, examples are appreciated. Thanks and kind regards blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
Okay, for the accelerometers I found some information here:
http://wiki.maemo.org/Accelerometers Cheers Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
(Once installed the python files will be in /opt/healthcheck/ Example code (Functions file): Code:
# -*- coding: utf-8 -*- |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
Looking into and waiting for qtmultimedia/mobility :) |
Re: python - how to read information from light meter, microphone and accelerometers?
This answers most. Thanks a lot.
But why call external tools to read the "files" why not simply use Code:
def funcProxState(): Cheers blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
I have just managed to play with accelerometer so here's a simple script to output the phone's state.
Code:
from ctypes import * |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
(Very new to python, linux and QT, so the whole thing is a learning curve! |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
I want to emit a IR-Signal when the signal level of on of the sensors (Proximity sensor, Microphone, Accelerometers) raises above a certain threshold and remotely trigger my Canon EOS 7D ;-) Cheers blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
Here some fine links: http://gnosis.cx/TPiP/ http://docs.python.org/lib/string-methods.html By the way, do you know how I can get the light intensity like the app "luxus" does? Cheers blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
not seen luxus, but can check later.
which light intensity? the screen brightness intensity should be in the code above. :) (out on lunch, so not near a pc) |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
If I can make the program react fast enough it might be possible to use it for such photos: http://gallery.olausson.de/v/20082211_-_wings_of_fire/ Since I want to try it again with a way sharper lense and some more experience it would be very nice if the N900 could trigger the Canon EOS 7D as soon as the match ignites. This would reduce the junk images tremendous :-) Once I know how to read the ambient light intensity the rest should be straight forward ;-) Cheers blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
|
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
Cheers blubbi |
Re: python - how to read information from light meter, microphone and accelerometers?
Hi, am the author of the Luxus program.
I would like to help you and I will, but I seem to have temporary problems. My development PC just died and it will take some days to get it going again. Of course I have the backups but I can't easily access them right now. Meanwhile I was going to just look at the source code package from the web: http://maemo.org/packages/source/vie...e/luxus/0.4-1/ and copy paste the relevant code lines here for reading the ambient light sensor, but that web address isn't working for me either. :( Basically it's really simple, there's a special file somewhere in /proc/sys/dev/something/something that you read, it has the light sensor value in lux units. If you are able to fetch the source code, you can locate the exact path by finding where I am opening some file from a path like that. |
Re: python - how to read information from light meter, microphone and accelerometers?
Hej, no big deal, I'll check your source code (asap maemo is up again)
I could have come up with this idea myself... *stupid me* Actually I plan to work out and extend this little tool with the developer of "shutter" My first plan is to test the concept with this kind of photos: http://gallery.olausson.de/v/20082211_-_wings_of_fire/ I got a new shiny lens (Canon EF 100mm 2.8L IS Macro) which is way sharper then the lens I made those photos. The N900 combined with the new Lens some more experience and two new Canon flashes (Canon 580EX II) should yield more usable photos and reduces the "luck" in capturing the ignition point. Hopefully the sensor will provide the data at a high enough freqency, so Ii I can poll the data at a high enough rate it could also be possible to capture lightnings like the CHDK scripts for compact cameras found here: http://chdk.wikia.com/wiki/UBASIC/Sc...ghtning_Detect Cheers Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Here we go for the ambient light meter:
Code:
while true ; do cat /sys/class/i2c-adapter/i2c-2/2-0029/lux ; done Thanks toninikkanen Cheers Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
Allllllso.... whilst i'm in that folder, what are calib0 and calib1? :) (Useful things for healthcheck :) ) |
Re: python - how to read information from light meter, microphone and accelerometers?
Mmmh, I am now playing around with python-pyinotify to poll the file but it did not what I expected...
I get only a response for "process_IN_OPEN", "process_IN_ACCESS" and "process_IN_CLOSE_NOWRITE" but nothing for "process_IN_MODIFY"... Any other ideas how to poll the file? Or should I build in a "only trigger event if value change caompared to last time"? Code:
#!/usr/bin/env python Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Polling a file under /sys typically makes no sense. The files you find there act as handy nameholders for different parts of drivers and doing open + read + close makes the driver create the content on the fly.
So, do not view this as regular files but as something you can read from and get the latest value. There is often a library to use to do the same thing which might be faster since opening and reading from a file is a magnitude slower than performing one break into kernel space with an ioctl. |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
Do you have a idea how I can access the file correctly? :D Cheers Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Mmmh, all I came up without having a clue if there is a special mechanism is the following:
Code:
f = open('/sys/class/i2c-adapter/i2c-2/2-0029/lux') Cheers Bjoern |
Re: python - how to read information from light meter, microphone and accelerometers?
Quote:
http://talk.maemo.org/showthread.php?t=54695 The interesting bits here are the call to "gobject.io_add_watch" and the "on_state_changed" callback. You don't even need to have a separate thread for it, simply start a GLib main loop (e.g. call gtk.main()) and the mainloop will call your callback when the file has changed (just waiting while it's not changing). |
All times are GMT. The time now is 00:07. |
vBulletin® Version 3.8.8