omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    3
    6
    3654
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ekl3ndil
      Ekl3ndil last edited by

      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

      1 Reply Last reply Reply Quote 0
      • zrzka
        zrzka last edited by

        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

        1 Reply Last reply Reply Quote 0
        • Ekl3ndil
          Ekl3ndil last edited by

          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

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            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

            1 Reply Last reply Reply Quote 0
            • Ekl3ndil
              Ekl3ndil last edited by Ekl3ndil

              Hi,
              i found this link to read the value of the sensor in objc, but I have no idea how i can convert it. Here

              Thanks

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors