Sha256: 873ebb26126aa7c0e2ce1edcf4e6eb6347fc36142dbcbee6ea85ff2a3c549dc7

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

#include "stdafx.h"

#if _WIN32_WCE > 0x501
#include <nled.h>
#include "Vibrate.h"
#include <common/RhodesApp.h>

IMPLEMENT_LOGCLASS(CVibrate, "Vibrate");

CVibrate *CVibrate::m_pInstance = NULL;
CMutex CVibrate::m_mxLocker;

CVibrate::CVibrate (IRhoClassFactory* factory) : CRhoThread(factory), m_nDuration(2), m_bToggled(false)
{
}

CVibrate::~CVibrate ()
{
    untoggle();
}

void CVibrate::createCVibrate()
{
    static CVibrate instance(rho_impl_createClassFactory());
    m_pInstance = &instance;
}

CVibrate &CVibrate::getCVibrate()
{
    m_mxLocker.Lock();

    if (!m_pInstance)
        createCVibrate();
    
    m_mxLocker.Unlock();
    
    return *m_pInstance;
}

void CVibrate::toggle()
{
    toggle (m_nDuration);
}

void CVibrate::toggle(int seconds)
{
    m_nDuration = seconds;
    start(epNormal);
}

void CVibrate::untoggle()
{
    NLED_SETTINGS_INFO settings;
    settings.LedNum= 1; 
    settings.OffOnBlink= 0; 
    NLedSetDevice (NLED_SETTINGS_INFO_ID, &settings);
    m_bToggled = false;
	stop(0);
}

void CVibrate::run() 
{
    NLED_SETTINGS_INFO settings;

    settings.LedNum= 1;
    NLedGetDeviceInfo(NLED_SETTINGS_INFO_ID,  &settings);

    if (!m_bToggled && settings.OffOnBlink == 0) {
        settings.LedNum= 1; 
        settings.OffOnBlink= 1;
        NLedSetDevice (NLED_SETTINGS_INFO_ID, &settings);
        m_bToggled = true;        
        wait (m_nDuration);
		untoggle();
    }
}

#endif // _WIN32_WCE

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rhodes-2.3.0 platform/wm/rhodes/Vibrate.cpp
rhodes-2.3.0.beta.3 platform/wm/rhodes/Vibrate.cpp
rhodes-2.3.0.beta.2 platform/wm/rhodes/Vibrate.cpp
rhodes-2.3.0.beta.1 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.6 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.6.beta.1 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.5 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.5.beta.3 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.5.beta.2 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.5.beta.1 platform/wm/rhodes/Vibrate.cpp
rhodes-2.2.4.beta.1 platform/wm/rhodes/Vibrate.cpp