Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Ambient Light Sensor
-
Hi,
I actually use Pythonista since many month and I have interest for the ObjC Classes with the module objc_util. My problem is that I don't know how to get the value of the ambient light sensor. I saw post on StackOverFlow about this sensor in Objectiv C but i have no idea how to use the IOKit framework to get the sensor's value.
Thanks
Ekl3ndil
-
Hi,
AFAIK ALS value is not available via any Objective C framework. You can read it via IOKit, but it's not Objective C, it's C and it's not so easy. But I didn't check for some time. If it's already there, feel free to correct me.
Anyway, for what purpose do you need this value? Maybe the screen brightness is enough for you? If your device has auto brightness turned on, you can deduce surrounding light from it. It's available via
[[UIScreen mainScreen] brightness]
(Objective C) and this one can be used in Pythonista in this way:from objc_util import * screen = ObjCClass('UIScreen') print(screen.mainScreen().brightness())
You can learn more about Objective C in Pythonista here.
Zrzka
-
Hi
Thanks you for your answer. I already know how to know the screen brightness thanks UIscreen class. I just wan’t to know how i can use the IOKit. I know isn’t easy.
Thanks you
-
have you found example C code that is purported to work on un-jailbroken devices? If you post the link, we can try converting it
-
Hi,
i found this link to read the value of the sensor in objc, but I have no idea how i can convert it. HereThanks
-
Pretty sure that is all either depreciated, or only works on jailbroken devices. I tried the very first line, IOHIDEventSystemCreate, and it returned a null pointer.