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 TProximityState 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(TProximityState, self.proxi.proximity_state)

    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.