locked
Vibrate functions in VB? RRS feed

  • Question

  • How do I write code to vibrate functions in VB?  I see lots of examples in C# but not clear on how to do this in VB

     

    Thanks

    Tuesday, September 28, 2010 4:00 PM

Answers

  • Hi,

    Try this,

    Private Structure NLED_SETTINGS_INFO 
    	Public LedNum As Integer 
    	Public OffOnBlink As Integer 
    	Public TotalCycleTime As Integer 
    	Public OnTime As Integer 
    	Public OffTime As Integer 
    	Public MetaCycleOn As Integer 
    	Public MetaCycleOff As Integer 
    	End Structure 
    	
    	<DllImport("Coredll")> _ 
    	Private Shared Function NLedSetDevice(ByVal deviceId As Integer, ByRef info As NLED_SETTINGS_INFO) As Boolean 
    End Function 
    	
    Private Shared Sub SetVibrate(ByVal state As Boolean) 
    	Dim info As New NLED_SETTINGS_INFO() 
    	info.LedNum = 1 
    	info.OffOnBlink = If(state, 1, 0) 
    	NLedSetDevice(1, info) 
    End Sub 
    

     

    Regards,

    Malleswar

    Wednesday, September 29, 2010 4:01 AM

All replies

  • Hi,

    Try this,

    Private Structure NLED_SETTINGS_INFO 
    	Public LedNum As Integer 
    	Public OffOnBlink As Integer 
    	Public TotalCycleTime As Integer 
    	Public OnTime As Integer 
    	Public OffTime As Integer 
    	Public MetaCycleOn As Integer 
    	Public MetaCycleOff As Integer 
    	End Structure 
    	
    	<DllImport("Coredll")> _ 
    	Private Shared Function NLedSetDevice(ByVal deviceId As Integer, ByRef info As NLED_SETTINGS_INFO) As Boolean 
    End Function 
    	
    Private Shared Sub SetVibrate(ByVal state As Boolean) 
    	Dim info As New NLED_SETTINGS_INFO() 
    	info.LedNum = 1 
    	info.OffOnBlink = If(state, 1, 0) 
    	NLedSetDevice(1, info) 
    End Sub 
    

     

    Regards,

    Malleswar

    Wednesday, September 29, 2010 4:01 AM
  • I just finished some related task and share my solution in C++.  A bit of guilty by getting help here without offering anything back.

     void CVibratorHelper::Vibrate(void)
     {
      SetLedStatus(GetLedCount() - 1, 1);
     }

     void CVibratorHelper::Cancel()
     {
      SetLedStatus( GetLedCount()-1, 0 );
     }

     int CVibratorHelper::GetLedCount()
     {
      NLED_COUNT_INFO nci;
      int wCount = 0;
      if(NLedGetDeviceInfo(NLED_COUNT_INFO_ID, (PVOID) &nci))
       wCount = (int) nci.cLeds;
      return wCount;
     }

     void CVibratorHelper::SetLedStatus(int index, int status)
     {
      NLED_SETTINGS_INFO nsi;
      nsi.LedNum = (INT) index;
      nsi.OffOnBlink = (INT) status;
      NLedSetDevice(NLED_SETTINGS_INFO_ID, &nsi);
     }

    Wednesday, September 29, 2010 9:44 AM
  • Thanks Malleswar,  I will give it a shot.
    Wednesday, September 29, 2010 11:53 AM