3.9.2.8 class ProximityMonitor

Class Attribute

Proximity_state: The possible values are 0, 1 and 2. To get the logical names of these values use get_logicalname API with ProximityState as the class name.

Example

from sensor import *
import e32


class DemoApp():

    def __init__(self):
        self.proxi = ProximityMonitor()
        self.proxi.set_callback(data_callback=self.my_callback)

    def my_callback(self):
        print 'Proxi:', get_logicalname(ProximityState,
                                          self.proxi.proximity_state)
        print 'Timestamp:', self.proxi.timestamp

    def run(self):
        self.proxi.start_listening()

if __name__ == '__main__':
    d = DemoApp()
    d.run()
    e32.ao_sleep(10)
    d.proxi.stop_listening()
    print "After Stop Listening"
    e32.ao_sleep(5)
    print "Exiting Proximity"

See About this document... for information on suggesting changes.