Exemplo n.º 1
0
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse;
    
    if (m_pActiveScreen)
    {
        m_pActiveScreen->Draw();
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    }
    else
    {
        dwPriorityToUse = LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW);
    }
    
    lgLcdBitmap160x43x1* pScreen = GetLCDScreen();
    if (pScreen && (LGLCD_INVALID_DEVICE != m_hDevice))
    {
        DWORD res = ERROR_SUCCESS;
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        
        HandleErrorFromAPI(res);

        // read the soft buttons
        ReadButtons();
    }

    return S_OK;
}
Exemplo n.º 2
0
BOOL CLCDOutput::OnDraw(void)
{
    DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);

    if ( (NULL == m_pActivePage) ||
        (LGLCD_INVALID_DEVICE == m_hDevice) ||
        (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
    {
        // don't submit the bitmap
        return TRUE;
    }

    // Render the active screen
    m_pGfx->BeginDraw();
    m_pGfx->ClearScreen();
    m_pActivePage->OnDraw(*m_pGfx);
    m_pGfx->EndDraw(); 

    // Get the active bitmap
    lgLcdBitmap* pBitmap = m_pGfx->GetLCDScreen();

    // Only submit if the bitmap needs to be updated
    // (If the priority or bitmap have changed)
    DWORD res = ERROR_SUCCESS;
    if (DoesBitmapNeedUpdate(pBitmap))
    {
        res = lgLcdUpdateBitmap(m_hDevice, &pBitmap->bmp_mono.hdr, dwPriorityToUse);
        HandleErrorFromAPI(res);
    }

    return (LGLCD_INVALID_DEVICE != m_hDevice);
}
Exemplo n.º 3
0
HRESULT CLCDOutput::Draw()
{
    DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
    
    if ( (NULL == m_pActiveScreen)              ||
         (LGLCD_INVALID_DEVICE == m_hDevice)    ||
         (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
    {
        // don't submit the bitmap
        return S_OK;
    }

    // Render the active screen
    m_pActiveScreen->Draw();
    
    // Get the active bitmap
    lgLcdBitmap160x43x1* pScreen = m_pActiveScreen->GetLCDScreen();

    // Only submit if the bitmap needs to be updated
    // (If the priority or bitmap have changed)
    DWORD res = ERROR_SUCCESS;
    if (DoesBitmapNeedUpdate(pScreen))
    {
        res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
        HandleErrorFromAPI(res);
    }

    // read the soft buttons
    ReadButtons();

    return S_OK;
}
Exemplo n.º 4
0
void CLCDOutput::Update(DWORD dwTimestamp)
{
    if (m_pActiveScreen)
    {
        m_pActiveScreen->Update(dwTimestamp);
    }

    // check for expiration
    if (m_pActiveScreen && m_pActiveScreen->HasExpired())
    {
        m_pActiveScreen = NULL;
        //m_nPriority = LGLCD_PRIORITY_FYI; -> needs to go so that if a 
		// program sets priority to LGLCD_PRIORITY_BACKGROUND, that 
		// priority sticks.

        OnScreenExpired(m_pActiveScreen);

        // Clear the bitmap
        ClearBitmap(m_pLastBitmap);

        // find the next active screen
        LCD_MGR_LIST::iterator it = m_LCDMgrList.begin();
        while(it != m_LCDMgrList.end())
        {
            CLCDManager *pMgr = *it;
            LCDUIASSERT(NULL != pMgr);

            if (!pMgr->HasExpired())
            {
                ActivateScreen(pMgr);
                //m_nPriority = LGLCD_PRIORITY_FYI;  -> needs to go so that if a 
				// program sets priority to LGLCD_PRIORITY_BACKGROUND, that 
				// priority sticks.
                break;
            }

            ++it;
        }

        // if no screen found, empty the screen at idle priority
        if (NULL == m_pActiveScreen)
        {
            if (LGLCD_INVALID_DEVICE != m_hDevice)
            {
                lgLcdUpdateBitmap(m_hDevice, &CLCDManager::GetLCDScreen()->hdr,
                    LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
            }
        }
    }

    // check for lcd devices
    if (LGLCD_INVALID_DEVICE == m_hDevice)
    {
        EnumerateDevices();
    }
}
Exemplo n.º 5
0
void CLCDOutput::SetScreenPriority(DWORD priority)
{
    // Priority has changed
    // If we're going into idle, send an idle frame
    if (LGLCD_PRIORITY_IDLE_NO_SHOW == priority)
    {
        lgLcdUpdateBitmap(m_hDevice, &m_pGfx->GetLCDScreen()->bmp_mono.hdr,
            LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
    }

    m_nPriority = priority;
}
Exemplo n.º 6
0
//************************************************************************
// Hides the applet
//************************************************************************
bool CLCDConnectionLogitech::HideApplet()
{
	if (!GetConnectionState() == CONNECTED)
		return false;

	DWORD rc;

	rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
	if (rc != ERROR_SUCCESS)
		return false;

	return true;
}
Exemplo n.º 7
0
void CLCDOutput::OnUpdate(DWORD dwTimestamp)
{
    if (m_pActivePage)
    {
        m_pActivePage->OnUpdate(dwTimestamp);
    }

    // check for expiration
    if (m_pActivePage && m_pActivePage->HasExpired())
    {
        m_pActivePage = NULL;
        //m_nPriority = LGLCD_PRIORITY_FYI; -> needs to go so that if a 
        // program sets priority to LGLCD_PRIORITY_BACKGROUND, that 
        // priority sticks.

        OnPageExpired(m_pActivePage);

        // find the next active screen
        for (size_t i = 0; i < m_Objects.size(); i++)
        {
            CLCDPage *pPage = dynamic_cast<CLCDPage*>(m_Objects[i]);
            LCDUIASSERT(NULL != pPage);

            if (!pPage->HasExpired())
            {
                ShowPage(pPage);
                //m_nPriority = LGLCD_PRIORITY_FYI;  -> needs to go so that if a 
                // program sets priority to LGLCD_PRIORITY_BACKGROUND, that 
                // priority sticks.
                break;
            }
        }

        // if no screen found, empty the screen at idle priority
        if (NULL == m_pActivePage)
        {
            OnEnteringIdle();
            if (LGLCD_INVALID_DEVICE != m_hDevice)
            {
                m_pGfx->ClearScreen();
                lgLcdUpdateBitmap(m_hDevice, &m_pGfx->GetLCDScreen()->bmp_mono.hdr,
                    LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
            }
        }
    }
}
Exemplo n.º 8
0
void CLCDConnectionLogitech::runDrawingThread() {
	m_hStopEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
	m_hDrawEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

	DWORD dwRes = 0;

	while (1) {
		HANDLE hArray[2] = { m_hStopEvent, m_hDrawEvent };
		dwRes = WaitForMultipleObjects(2, hArray, FALSE, INFINITE);
		if (dwRes == WAIT_OBJECT_0) {
			break;
		}
		else if (dwRes == WAIT_OBJECT_0 + 1) {
			DWORD rc;
			if (GetConnectionState() != CONNECTED) {
				continue;
			}
			// do a sync update if the applet is in the foreground, or every 500 ms
			// the delay is there because sync updates can take up to 33ms to fail
			if (m_dwForegroundCheck < GetTickCount())
			{
				m_dwForegroundCheck = GetTickCount() + 500;
				rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_SYNC_COMPLETE_WITHIN_FRAME(m_iPriority));
				if (rc == ERROR_ACCESS_DENIED)
				{
					rc = ERROR_SUCCESS;
					m_bIsForeground = false;
				}
				else if (rc == ERROR_SUCCESS)
					m_bIsForeground = true;
			}
			else
				rc = lgLcdUpdateBitmap(m_hDevice, &m_lcdBitmap.hdr, LGLCD_ASYNC_UPDATE(m_iPriority));

			if (rc != ERROR_SUCCESS) {
				HandleErrorFromAPI(rc);
			}
		}
	}
	CloseHandle(m_hStopEvent);
	CloseHandle(m_hDrawEvent);
}
Exemplo n.º 9
0
void lcd_update (int led, int on)
{
	int track, x, y;

	if (!inited)
		return;

	if (led < 0) {
		lgLcdUpdateBitmap (device, lbh, LGLCD_PRIORITY_IDLE_NO_SHOW);
		return;
	}
	if (on < 0)
		return;

	if (led >= 1 && led <= 4) {
		x = 23 + (led - 1) * 40;
		y = 17;
		track = gui_data.drive_track[led - 1];
		if (gui_data.drive_disabled[led - 1]) {
			track = -1;
			on = 0;
		}
		putnumbers (x, y, track, on);
	} else if (led == 0) {
		dorect (&coords[4 * 2], on);
	} else if (led == 5) {
		dorect (&coords[4 * 1], on);
	} else if (led == 6) {
		dorect (&coords[4 * 0], on);
	} else if (led == 7) {
		y = 2;
		x = 125;
		putnumbers (x, y, gui_data.fps <= 999 ? (gui_data.fps + 5) / 10 : 99, 0);
	} else if (led == 8) {
		y = 2;
		x = 98;
		putnumbers (x, y, gui_data.idle <= 999 ? gui_data.idle / 10 : 99, 0);
	}
	lgLcdUpdateBitmap (device, lbh, LGLCD_ASYNC_UPDATE (LGLCD_PRIORITY_NORMAL + 1));
}
Exemplo n.º 10
0
//************************************************************************
//
// CLCDOutput::SetScreenPriority
//
//************************************************************************
void CLCDOutput::SetScreenPriority(DWORD priority)
{
    if (priority == m_nPriority)
    {
        // Nothing to do
        return;
    }

    // Clear the bitmap
    ClearBitmap(m_pLastBitmap);

    m_nPriority = priority;
    m_bPriorityHasChanged = TRUE;

    if (LGLCD_PRIORITY_IDLE_NO_SHOW == m_nPriority)
    {
        // send an empty bitmap at idle priority
        if (LGLCD_INVALID_DEVICE != m_hDevice)
        {
            lgLcdUpdateBitmap(m_hDevice, &m_pLastBitmap->hdr,
                LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
        }
    }
}