The Following User Says Thank You to blubbi For This Useful Post: | ||
|
2010-06-07
, 19:16
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#12
|
I have just managed to play with accelerometer so here's a simple script to output the phone's state.
Code:from ctypes import * import os import sys import time from math import atan2 from pprint import pprint xlib = cdll.LoadLibrary("libX11.so.6") rr = cdll.LoadLibrary("libXrandr.so.2") def out_rotate(): f = open("/sys/class/i2c-adapter/i2c-3/3-001d/coord", 'r' ) cdinate = [int(w) for w in f.readline().split()] f.close() return cdinate print out_rotate() time.sleep(1)
|
2010-06-07
, 20:16
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#13
|
Why do you load X11 libraries to read from a file and write to the console? And lots of import?
|
2010-06-07
, 21:40
|
Posts: 44 |
Thanked: 89 times |
Joined on Oct 2009
|
#14
|
|
2010-06-07
, 21:57
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#15
|
The Following User Says Thank You to blubbi For This Useful Post: | ||
|
2010-06-07
, 22:45
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#16
|
while true ; do cat /sys/class/i2c-adapter/i2c-2/2-0029/lux ; done
The Following User Says Thank You to blubbi For This Useful Post: | ||
|
2010-06-07
, 22:48
|
|
Posts: 3,203 |
Thanked: 1,391 times |
Joined on Nov 2009
@ Worthing, England
|
#17
|
Here we go for the ambient light meter:
seems quite responsive ;-)Code:while true ; do cat /sys/class/i2c-adapter/i2c-2/2-0029/lux ; done
Thanks toninikkanen
Cheers
Bjoern
|
2010-06-08
, 00:54
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#18
|
#!/usr/bin/env python # -*- coding: utf-8 -*- # import os, time, pyinotify import pyinotify ambient_sensor = '/sys/class/i2c-adapter/i2c-2/2-0029/lux' wm = pyinotify.WatchManager() # Watch Manager mask = pyinotify.ALL_EVENTS def action(self, the_event): value = open(the_event.pathname, 'r').read().strip() return value class EventHandler(pyinotify.ProcessEvent): def process_IN_ACCESS(self, event): print "ACCESS event:", action(self, event) def process_IN_ATTRIB(self, event): print "ATTRIB event:", action(self, event) def process_IN_CLOSE_NOWRITE(self, event): print "CLOSE_NOWRITE event:", action(self, event) def process_IN_CLOSE_WRITE(self, event): print "CLOSE_WRITE event:", action(self, event) def process_IN_CREATE(self, event): print "CREATE event:", action(self, event) def process_IN_DELETE(self, event): print "DELETE event:", action(self, event) def process_IN_MODIFY(self, event): print "MODIFY event:", action(self, event) def process_IN_OPEN(self, event): print "OPEN event:", action(self, event) #log.setLevel(10) notifier = pyinotify.ThreadedNotifier(wm, EventHandler()) notifier.start() wdd = wm.add_watch(ambient_sensor, mask) wdd #wm.rm_watch(wdd.values()) time.sleep(5) notifier.stop()
|
2010-06-08
, 05:24
|
Posts: 726 |
Thanked: 345 times |
Joined on Apr 2010
@ Sweden
|
#19
|
|
2010-06-08
, 07:04
|
|
Posts: 288 |
Thanked: 113 times |
Joined on Dec 2009
@ Germany
|
#20
|
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.
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
My website:
- olausson.de
- gallery.olausson.de
My Applications: