WindowsMobileメモ / バイブ制御


Last update: 2010-08-06 (金) 13:57:08

WindowsMobile?メモ/バイブ制御
Tag: WindowsMobile


WindowsMobile?でバイブ制御

Windows Mobileでバイブを制御する方法です。
バイブはLEDと同様の通知デバイスとして制御するようです。

関数

ずばり、以下の関数を使います。
(参考: Windows Embedded Developer Center)

BOOL WINAPI NLedSetDevice(
  UINT nDeviceId,
  void* pInput
);

引数は以下の通り。

  • nDeviceId? [in] Integer that specifies what information to set. You can set it to NLED_SETTINGS_INFO_ID to indicate that the pInput buffer contains information about the current settings for the notification LED.
  • pInput [out] Pointer to the buffer that contains the NLED_SETTINGS_INFO structure. This structure contains the new settings for the notification LED.

要するに、nDeviceId?は固定値NLED_COUNT_INFO_IDを指定、pInputには制御情報を格納した構造体NLED_SETTINGS_INFOへのポインタを指定します。

構造体NLED_SETTINGS_INFOの型は以下の通り。
(参考: Windows Embedded Developer Center)

struct NLED_SETTINGS_INFO {
  UINT LedNum;
  INT OffOnBlink;
  LONG TotalCycleTime;
  LONG OnTime;
  LONG OffTime;
  INT MetaCycleOn;
  INT MetaCycleOff;
};

各メンバは以下の通り。

  • LedNum? LED number. The first LED is zero (0).
  • OffOnBlink? Current setting. The following table shows the defined values.
    • 0 Off
    • 1 On
    • 2 Blink
  • TotalCycleTime? Total cycle time of a blink, in microseconds.
  • OnTime? On time of the cycle, in microseconds.
  • OffTime? Off time of the cycle, in microseconds.
  • MetaCycleOn? Number of on blink cycles.
  • MetaCycleOff? Number of off blink cycles.

今、試している機種(hTc Z)ではバイブはLedNum?1になるようです。
これは機種ごとに違う可能性が高いです。

OffOnBlink?は指定されている値から選択します。
バイブをオンにする場合は1 On、オフにする場合は0 Offを指定します。

Off/Onだけの場合は他の値を無視しても問題なさそうです。
OffOnBlink?2 Blinkにした場合は設定すると思われ。
でも使ってないので調べていません。

具体例

具体的に関数として作るとしたら以下のようになります。

void VIB_On( void )
{
	struct NLED_SETTINGS_INFO info = { 0 };

	info.LedNum = (UINT)1;
	info.OffOnBlink = (INT)1;

	NLedSetDevice( NLED_SETTINGS_INFO_ID, (void*)( &info ) );
}

void VIB_Off( void )
{
	struct NLED_SETTINGS_INFO info = { 0 };

	info.LedNum = (UINT)1;
	info.OffOnBlink = (INT)0;

	NLedSetDevice( NLED_SETTINGS_INFO_ID, (void*)( &info ) );
}

もっとちゃんと作るとしたらNLedSetDevice?()の戻り値をチェックしてFALSEの時はエラー処理をしましょう。
(多分、エラー表示だけになると思いますけど。)

補足

LedNum?0を指定したら充電ランプが点滅しました。
OffOnBlink?1 Onにしたのに何故2 Blinkみたいな動作をしたのかは謎。


コメント

コメントはありません。 コメント/WindowsMobileメモ/バイブ制御?

Online: 2


FrontPage

Soft

Tips


最新の20件

2021-12-21 2020-04-06 2020-03-10 2013-06-28 2013-11-13 2014-06-24

今日の19件

  • counter: 1783
  • today: 1
  • yesterday: 0
  • online: 2

edit