GSensor Introduction ch 20091015 GSensor SHAKE SIGNAL TIMER

  • Slides: 22
Download presentation
G-Sensor Introduction ch 2009/10/15

G-Sensor Introduction ch 2009/10/15

G-Sensor架構

G-Sensor架構

SHAKE SIGNAL TIMER SIGNAL G_SENSOR Middle layer CALLBACK G_SENSOR SERVICE G_SENSOR BSP

SHAKE SIGNAL TIMER SIGNAL G_SENSOR Middle layer CALLBACK G_SENSOR SERVICE G_SENSOR BSP

使用步驟 1. 注冊MASK為 NMASK_DEVICENOTIFIER_SENSOREXT的 DEVICENOTIFIER 2. 創建ISensor. Port. Ext接口 3. 打開/關閉Accel Sensor,打開/關閉Auto Sleep 4.

使用步驟 1. 注冊MASK為 NMASK_DEVICENOTIFIER_SENSOREXT的 DEVICENOTIFIER 2. 創建ISensor. Port. Ext接口 3. 打開/關閉Accel Sensor,打開/關閉Auto Sleep 4. 設置獲取數據的頻率(讀取Accel Sensor X, Y, Z軸上數 據的頻率)(可選) 5. 在AP的Handle. Event獲取數據

Notify Data notify 的w. Pram參數表示事件類型,dw. Param是具體的數 據 w. Pram參數的值: ACCEL_EVENT_INVALID = 0 x 0000,

Notify Data notify 的w. Pram參數表示事件類型,dw. Param是具體的數 據 w. Pram參數的值: ACCEL_EVENT_INVALID = 0 x 0000, ACCEL_EVENT_ROTATE_UP = 0 x 0100, ACCEL_EVENT_ROTATE_DOWN = 0 x 0200, ACCEL_EVENT_ROTATE_LEFT = 0 x 0300, ACCEL_EVENT_ROTATE_RIGHT = 0 x 0400, ACCEL_EVENT_ROTATE_TOP = 0 x 0500, ACCEL_EVENT_ROTATE_BOTTOM = 0 x 0600, ACCEL_EVENT_SHAKE_LEFT = 0 x 7000, ACCEL_EVENT_SHAKE_RIGHT = 0 x 8000

dw. Param參數是指向Accel. Data結構體的指針(沒有數據 則是NULL) typedef struct { int 32 accelx; int 32 accely; int

dw. Param參數是指向Accel. Data結構體的指針(沒有數據 則是NULL) typedef struct { int 32 accelx; int 32 accely; int 32 accelz; }Accel. Data;

API �uint 32 ISensor. Port. Ext_Add. Ref(ISensor. Port. Ext *p) �uint 32 ISensor. Port.

API �uint 32 ISensor. Port. Ext_Add. Ref(ISensor. Port. Ext *p) �uint 32 ISensor. Port. Ext_Release(ISensor. Port. Ext *p) �int ISensor. Port. Ext_Query. Interface(ISensor. Port. Ext *p, AEECLSID id, void **ppo) �uint 32 ISensor. Port. Ext_Accel. Control(ISensor. Port. Ext *p, boolean b. On, boolean b. Allow. To. Sleep) �int ISensor. Port. Ext_Set. Accel. Freq(ISensor. Port. Ext *p, uint 8 level)

ISensor. Port. Ext_Accel. Control boolean b. On: 打開/關閉G-Sensor boolean b. Allow. To. Sleep :

ISensor. Port. Ext_Accel. Control boolean b. On: 打開/關閉G-Sensor boolean b. Allow. To. Sleep : 是否允許G-Sensor自動睡眠 (背光關閉時時候GSensor睡眠) 注:開關G-Sensor需要成對使用,使用的時候打開, 不用就關閉。

ISensor. Port. Ext_Set. Accel. Freq 設置輪詢的間隔時間 注:此處的Freq是以level表示,一共有1~ 10 級,代表 100~1000 ms

ISensor. Port. Ext_Set. Accel. Freq 設置輪詢的間隔時間 注:此處的Freq是以level表示,一共有1~ 10 級,代表 100~1000 ms

Example AP启动时: ret |= NMI_Shell_Register. Notify(MEAL_Get. Shell(), AEECLSID_APP_UNITTEST, AEECLSID_DEVICENOTIFIER, NMASK_DEVICENOTIFIER_SENSOREXT); ret |= NMI_Shell_Create. Instance(

Example AP启动时: ret |= NMI_Shell_Register. Notify(MEAL_Get. Shell(), AEECLSID_APP_UNITTEST, AEECLSID_DEVICENOTIFIER, NMASK_DEVICENOTIFIER_SENSOREXT); ret |= NMI_Shell_Create. Instance( MEAL_Get. Shell(), AEECLSID_SENSORPORTEXT, (void **)&p. Me>p. ISensor. Port. Ext); if( ret == SUCCESS ) { ISensor. Port. Ext_Accel. Control(p. Me->p. ISensor. Port. Ext, TRUE); //需要使用的時候再去打 開 } AP结束时: NMI_Shell_Register. Notify(MEAL_Get. Shell(), AEECLSID_APP_UNITTEST, AEECLSID_DEVICENOTIFIER, NULL); if(p. Me->p. ISensor. Port. Ext) { ISensor. Port. Ext_Accel. Control(p. Me->p. ISensor. Port. Ext, FALSE, TRUE); //不用就去關閉 ISensor. Port. Ext_Release(p. Me->p. ISensor. Port. Ext); }

事件处理: case EVT_NOTIFY: switch ( ((AEENotify *) dw. Param)->cls ) { case AEECLSID_DEVICENOTIFIER: {

事件处理: case EVT_NOTIFY: switch ( ((AEENotify *) dw. Param)->cls ) { case AEECLSID_DEVICENOTIFIER: { AEENotify *p. Notify. Info = (AEENotify*) dw. Param; AEEDevice. Notify* p. Device. Notify = (AEEDevice. Notify*)p. Notify. Info->p. Data; switch ( p. Notify. Info->dw. Mask ) { case NMASK_DEVICENOTIFIER_SENSOREXT: { p. Me->event = p. Device. Notify->w. Param; >dw. Param, sizeof(Accel. Data)); if(p. Device. Notify->dw. Param) { MEMCPY(&p. Me->accel. Data, (void*)p. Device. Notify} MEAL_FEPost. Event(FE_EVENT_UPDATE, 0, 0); } break;

default: break; } } break; }

default: break; } } break; }