sensor module specifications

Upload: nuwan-hemantha

Post on 04-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Sensor Module Specifications

    1/16

    1 (16)

    Python for s60Sensor module S60 sensor framework support

    Python for S60

    Sensor module for S60 Sensor FW

  • 8/13/2019 Sensor Module Specifications

    2/16

    2 (16)

    Python for s60Sensor module S60 sensor framework support

    TA!" #F $#%T"%TS

    1. Introduction

    sensor -- Module to access the device sensors

    Th&s PyS60 sensor module supports a''ess&n the sensors on the de&'es that hae S60 Sensor

    Framework l&*rar&es+ The S60 Sensor Framework was &ntrodu'ed &n S60 ,th "d&t&on- *ut &s also

    *a'kported to S60 .rd "d&t&on- Feature Pa'k 2 for some mo*&le de&'es- as well as the %ok&a "66

    de&'e- wh&'h &s an S60 .rd "d&t&on- Feature Pa'k 1 de&'e w&th sensor AP/s *ased on the S60 Sensor

    Framework+

    The sensor module offers d&re't a''ess to a de&'es phys&'al sensors+ The follow&n sensor 'hannels

    are supported *y the sensor module- pro&ded the de&'e supports them

    A''elerometer 34 sensor 'hannel

    5otat&on sensor 'hannel

    #r&entat&on sensor 'hannel

    A''elerometer dou*letap sensor 'hannel

    Pro7&m&ty mon&tor sensor 'hannel

    Am*&ent l&ht sensor 'hannel

    8anet&' %orth sensor 'hannel

  • 8/13/2019 Sensor Module Specifications

    3/16

  • 8/13/2019 Sensor Module Specifications

    4/16

    < (16)

    Python for s60Sensor module S60 sensor framework support

    Th&s fun't&on 'an *e used for =uery&n the lo&'al name *ased on alue+ The f&le sensor_defspyhas the

    mapp&n of d&fferent sensor propert&es to the&r respe't&e he7>de'&mal alues+ Follow&n ta*le 'onta&ns

    the sensor 'lasses- supported *y get_logicalname() and the respe't&e data lookup 'lasses+

    +ensor Class DataLookupClass

    Pro7&m&ty8on&tor TPro7&m&tyState

    #r&entat&on?ata TSensr?e&'e#r&entat&on

    Am*&ent!&ht?ata TSensrAm*&ent!&ht?ata

    A''elerometer?ou*leTapp&n?ata @SensrA''elerometer?&re't&on

  • 8/13/2019 Sensor Module Specifications

    5/16

    , (16)

    Python for s60Sensor module S60 sensor framework support

    4. Classes

    4.1 5ase class

    The *ase 'lass to all types of sensor 'lass &s Sensor+ Th&s 'lass pro&des the methods set'all*a'k-

    startl&sten&n and stopl&sten&n wh&'h are 'ommon to all the sensor 'lass o*9e'ts+ The &nd&&dual

    sensor 'lass o*9e'ts should *e used to use a spe'&f&' sensor+

    4.1.1 '!6ect creation

    Fun't&on s&nature &n&t(!data_filter"#one$)

    The dataf&lter arument &s only appl&'a*le for B34A7&s?ata and 5otat&on?ata sensor 'lasses+

    Poss&*le Calues 8ed&anF&lter()- !owPassF&lter()

    /f noth&n &s passed then the data &s left as&s w&thout any f&lter&n

    8ed&anF&lter D !owPassF&lter are standard no&se f&lter&n alor&thms wh&'h pro&de a smoother form

    of a s&nal remo&n the shortterm os'&llat&ons- lea&n only the lonterm trend+

    4.1.2 +et ata and rror Call!ac7

    Fun't&on s&nature set'all*a'k(data'all*a'k- !error_callback"#one$)

    Sets the data and error 'all*a'k fun't&on+ The error 'all*a'k fun't&on w&ll et an arument wh&'h w&ll

    'onta&n a map w&th $hannel /? and error str&n+ The data 'all*a'k fun't&on set w&ll not *e passed any

    aruments+

    4.1.4 '#en and listenFun't&on s&nature startl&sten&n()

    #pens the sensor 'hannel and start l&sten&n+ 5eturns True on su''ess and False on fa&lure+

    4.1.8 +to# and close

    Fun't&on s&nature stopl&sten&n()

    Stop l&sten&n to the open 'hannel and 'lose the 'hannel+ To start re'e&&n updates aa&n the

    startl&sten&n method 'an *e 'alled on the same sensor o*9e't+

  • 8/13/2019 Sensor Module Specifications

    6/16

    6 (16)

    Python for s60Sensor module S60 sensor framework support

    4.1.0 +et9et sensor channel #ro#erty

    The 'urrent release of PyS60 sensor module does not support e&ther retr&e&n or mod&fy&n all the

    sensor propert&es of a part&'ular 'hannel l&ke ?ata5ate- 8easure5ane- S'aled5ane et'+ Th&s feature

    w&ll *e pro&ded &n the future dot releases+ 5efer the &nd&&dual sensor 'lass des'r&pt&on for more deta&ls+

    4.1., Class attri!utes

    The sensor 'lasses hae one or more attr&*utes wh&'h w&ll 'onta&n the data returned *y the respe't&e

    sensor+ These attr&*utes w&ll *e set *efore the re&stered data 'all*a'k fun't&on &s 'alled and 'an *e

    a''essed us&n the respe't&e sensor 'lass o*9e't+

  • 8/13/2019 Sensor Module Specifications

    7/16

    E (16)

    Python for s60Sensor module S60 sensor framework support

    4.2 class Accelerometer$%&A*isata ?ete'ts moement estures- su'h as mo&n the de&'e up or down /nher&ts from the Sensor *ase 'lass

    Class attri!utes * a7&s alue y 3a7&s alue ; 4a7&s alue

    *am#le:

    from sensor import *import e32import time

    class Demopp!":

    def ##init##!self": self.accelerometer $ % ccelerometer&()isData!data#filter$o+ass-ilter!"" self.accelerometer.set#callac/!data#callac/$self.my#callac/" self.co0nter $ 1

    def my#callac/!self": -or stream sensor data the callac/ is hit 3 times per sec!4n 511". 6he de7ice cannot handle reso0rce h0n8ry operations li/e

    print in the callac/ f0nction for s0ch hi8h fre90encies. +or/aro0nd is to sample the data as demonstrated elo+.

    if self.co0nter $$ 1: print ;&:s, :s, (:s; !self.accelerometer.), self.accelerometer.y, self.accelerometer.

  • 8/13/2019 Sensor Module Specifications

    8/16

    (16)

    Python for s60Sensor module S60 sensor framework support

    4.4 class Accelerometerou!le"a##ingata ?ete'ts a dou*letap on the de&'e where the taps o''ur &n =u&'k su''ess&on and &n the same

    d&re't&on+

    /nher&ts from the Sensor *ase 'lass

    Class attri!ute:

    direction Ge7 alue &nd&'at&n the tap d&re't&on+ Hs&n etlo&'alname AP/ and 'lassname as

    @SensrA''elerometer?&re't&on the d&re't&on 'an *e determ&ned &n human reada*le form+

    4.4.1 +et9et #ro#erty

    Th&s sensor 'lass pro&des add&t&onal fun't&ons wh&'h 'an *e used to set>et some of the propert&es

    spe'&f&' to th&s sensor+N'" set>et sensor property AP/ &s not 'omplete yet and &s not supported for

    all sensors or all types of propert&es+ These AP/s m&ht 'hane &n the future dot releases+

    get

  • 8/13/2019 Sensor Module Specifications

    9/16

    : (16)

    Python for s60Sensor module S60 sensor framework support

    self.do0letap.start#listenin8!"

    if ##name## $$ '##main##': d $ Demopp!" d.r0n!" e32.ao#sleep!>" d.do0letap.stop#listenin8!" print ;?)itin8 Do0le 6ap;

  • 8/13/2019 Sensor Module Specifications

    10/16

    10 (16)

    Python for s60Sensor module S60 sensor framework support

    4.8 class Magnetometer$%&A*isata

    /nd&'ates the strenth of the eomanet&' flu7 dens&ty &n the - 3 and 4 a7es+

    #nly 'al&*rated a7&s data &s e7posed r&ht now and not raw data+

    /nher&ts from the Sensor *ase 'lass

    Class attri!utes:

    * a7&s alue

    y 3a7&s alue

    ; 4a7&s alue

    cali!

    def r0n!self": self.ma8netometer.start#listenin8!"

  • 8/13/2019 Sensor Module Specifications

    11/16

    11 (16)

    Python for s60Sensor module S60 sensor framework support

    if ##name## $$ '##main##': d $ Demopp!"

    d.r0n!" e32.ao#sleep!" d.ma8netometer.stop#listenin8!" print ;?)itin8 Ca8netometer)is;

  • 8/13/2019 Sensor Module Specifications

    12/16

    12 (16)

    Python for s60Sensor module S60 sensor framework support

    4.0 class MagneticNorthata

    /nd&'ates the num*er of derees *etween the de&'e and manet&' north

    /nher&ts from the Sensor *ase 'lass

    Class attri!ute:

    a;imuth : 0 to .,: 'lo'kw&se derees from manet&' north

    *am#le:

    from sensor import *import e32

    class Demopp!":

    def ##init##!self": self.ma8netic#north $ Ca8neticEorthData!" self.ma8netic#north.set#callac/!data#callac/$self.my#callac/"

    def my#callac/!self": if self.ma8netic#north.cali#le7el F 1:

    a

  • 8/13/2019 Sensor Module Specifications

    13/16

    1. (16)

    Python for s60Sensor module S60 sensor framework support

    4., class Am!ientLightata

    /nd&'ates the 'urrent l&ht leel

    /nher&ts from the Sensor *ase 'lass

    Class attri!ute:

    - am!ient

  • 8/13/2019 Sensor Module Specifications

    14/16

    1< (16)

    Python for s60Sensor module S60 sensor framework support

    4.3 class )ro*imityMonitor /nd&'ates how 'lose the de&'e &s to- for e7ample- the users hand or ear /nher&ts from the Sensor *ase 'lass

    Class attri!ute:- #ro*imity

  • 8/13/2019 Sensor Module Specifications

    15/16

    1, (16)

    Python for s60Sensor module S60 sensor framework support

    4./ class 'rientationata

    /nd&'ates the or&entat&on of the de&'e- for e7ample d&splay up or d&splay down

    /nher&ts from the Sensor *ase 'lass

    Class attri!ute:

    - device

  • 8/13/2019 Sensor Module Specifications

    16/16

    16 (16)

    Python for s60Sensor module S60 sensor framework support

    4. class (otationata ?ete'ts the rotat&on of the de&'e a*out ea'h a7&s

    /nher&ts from the Sensor *ase 'lass

    Class attri!utes:

    * a7&s alue

    y 3a7&s alue

    ; 4a7&s alue

    *am#le:

    from sensor import *import e32

    class Demopp!":

    def ##init##!self": self.rotation $ @otationData!" self.rotation.set#callac/!data#callac/$self.my#callac/" self.co0nter $ 1

    def my#callac/!self": -or stream sensor data the callac/ is hit appro)imately 21 times per sec!4n 511". 6he de7ice cannot handle reso0rce

    h0n8ry operations li/e print in the callac/ f0nction for s0ch hi8h fre90encies. +or/aro0nd is to sample the data as

    demonstrated elo+. if self.co0nter $$ 1: print ;&:s, :s, (:s; !self.rotation.), self.rotation.y, self.rotation.