示例#1
0
static uint32_t ScrLPModes_Sleep_ProcessMessage( SWGTScreen* pScreen, SWGTCoreMessage* pMsg )
{
    SGUIColor clr ;

//    printf( "ScrLPModes_Sleep - msg id %x\r\n", pMsg->dwID ) ;

    switch ( pMsg->dwID )
    {
        case WGT_MSG_TIMER :
            clr.u.dwRGBA = GUICLR_WHITE;
//            g_WGT_CoreData.pBE->DrawFilledRectangle( 42, 240, BOARD_LCD_WIDTH, 120, NULL, &clr ) ;
            g_WGT_CoreData.pBE->DrawText( 42, 240, "Init mode ...", &clr, (void*)&g_Font10x14, 0 ) ;

            clr.u.dwRGBA = GUICLR_ATMEL_BLUE;
            g_WGT_CoreData.pBE->DrawText( 25, 240, "Touch the screen\n   to wake-up", &clr, (void*)&g_Font10x14, 0 ) ;

            // Disable all ITs
            taskENTER_CRITICAL();
            g_irq[0] = NVIC->ISER[0];
            g_irq[1] = NVIC->ISER[1];
            NVIC->ICER[0] = 0xFFFFFFFF;
            NVIC->ICER[1] = 0xFFFFFFFF;

            // Configure PIOA with IT priority > basepri  (lower has higher priority on Cortex M3)
            NVIC_SetPriority(PIOA_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY - 16);
            /* Enable the interrupt for PIOA */
            NVIC_EnableIRQ(PIOA_IRQn);

            // Enable the PIO for wake-up
            SUPC->SUPC_WUIR = (g_sleepWakeUpPin << 16) | g_sleepWakeUpPin;
            // WFI or WFE mode can wake-up
            PMC->PMC_FSMR &= (unsigned int)~PMC_FSMR_LPM;
            // Clear Deep Sleep
            SCB->SCR &= (unsigned int)~(1 << 2);

            // Enter Sleep Mode
            __WFI();

            // Re configure PIOA with IT priority > basepri  (lower has higher priority on Cortex M3)
            NVIC_SetPriority(PIOA_IRQn, configMAX_SYSCALL_INTERRUPT_PRIORITY + 16);
            // Re-enable all ITs
            NVIC->ISER[0] = g_irq[0];
            NVIC->ISER[1] = g_irq[1];
            taskEXIT_CRITICAL();

            // Go back to previous screen
            WGT_SetCurrentScreen( &ScrLPModes );
        break;
    }

    return SAMGUI_E_OK ;
}
static uint32_t ScrAudio_ProcessMessage( SWGTScreen* pScreen, SWGTCoreMessage* pMsg )
{
//    printf( "ScrAudio - msg id %x\r\n", pMsg->dwID ) ;

    switch ( pMsg->dwID )
    {
        case WGT_MSG_POINTER_RELEASED : // cursor released
        case WGT_MSG_KEY_RELEASED : // button released
            // Send message to switch to main screen
            WGT_SetCurrentScreen( &ScrMain ) ;
        break ;
    }

    return SAMGUI_E_OK ;
}
示例#3
0
static uint32_t ScrMain_ProcessMessage( SWGTScreen* pScreen, SWGTCoreMessage* pMsg )
{
    static uint32_t dwTimeUpdate=0 ;
    SWGT_Widget* pWidget ;

//    if ( pMsg->dwID != WGT_MSG_TIMER ) printf( "ScrMain - msg id %x\r\n", pMsg->dwID ) ;

    switch ( pMsg->dwID )
    {
        case WGT_MSG_TIMER :
            ScrMain_DrawStatus() ;

            // Increment timestamp
            dwTimeUpdate++ ;
            if ( dwTimeUpdate == 60000 )
            {
                // Write parameters every 60 seconds
                Demo_Parameters_CommitChanges() ;
                dwTimeUpdate=0 ;
            }
        break ;

        case WGT_MSG_PAINT :
#if defined DEMO_USE_QTOUCH
            WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
#else
            WGT_Screen_SetSelectedWidget( pScreen, &g_btnAudio ) ;
#endif // defined DEMO_USE_QTOUCH

            ScrMain_DrawStatus() ;
        break ;

        case WGT_MSG_KEY_RELEASED : // button released
//        case WGT_MSG_KEY_PRESSED : // button pressed
            switch ( pMsg->dwParam1 )
            {
                // Select next widget
                case WGT_KEY_PB1 :
                case WGT_KEY_K4 :
                    if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
                    {
                        if ( pWidget )
                        {
                            if ( pWidget == &g_btnAudio )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnVideo ) ;
                            }

                            if ( pWidget == &g_btnVideo )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSlideShow ) ;
                            }

                            if ( pWidget == &g_btnSlideShow )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSettings ) ;
                            }

#if defined DEMO_USE_QTOUCH
                            if ( pWidget == &g_btnSettings )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
                            }

                            if ( pWidget == &g_btnQTouch )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                            }
#else
                            if ( pWidget == &g_btnSettings )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                            }
#endif // defined DEMO_USE_QTOUCH

                            if ( pWidget == &g_btnLPModes )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnInfos )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnAudio ) ;
                            }
                        }
                    }
                break ;

#if defined DEMO_USE_QTOUCH
                // Select previous widget
                case WGT_KEY_K2 :
                    if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
                    {
                        if ( pWidget )
                        {
                            if ( pWidget == &g_btnAudio )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnVideo )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnAudio ) ;
                            }

                            if ( pWidget == &g_btnSlideShow )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnVideo ) ;
                            }

                            if ( pWidget == &g_btnSettings )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSlideShow ) ;
                            }

                            if ( pWidget == &g_btnQTouch )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSettings ) ;
                            }

                            if ( pWidget == &g_btnLPModes )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
                            }

                            if ( pWidget == &g_btnInfos )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                            }
                        }
                    }
                break ;
#endif //defined DEMO_USE_QTOUCH

#if defined DEMO_USE_QTOUCH
                // Select up widget
                case WGT_KEY_K1 :
                    if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
                    {
                        if ( pWidget )
                        {
                            if ( pWidget == &g_btnAudio )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnVideo )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnSlideShow )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnSettings )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnAudio ) ;
                            }

                            if ( pWidget == &g_btnQTouch )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnVideo ) ;
                            }

                            if ( pWidget == &g_btnLPModes )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSlideShow ) ;
                            }

                            if ( pWidget == &g_btnInfos )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
                            }
                        }
                    }
                break ;
#endif // defined DEMO_USE_QTOUCH

#if defined DEMO_USE_QTOUCH
                // Select down widget
                case WGT_KEY_K5 :
                    if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
                    {
                        if ( pWidget )
                        {
                            if ( pWidget == &g_btnAudio )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnSettings ) ;
                            }

                            if ( pWidget == &g_btnVideo )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
                            }

                            if ( pWidget == &g_btnSlideShow )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                            }

                            if ( pWidget == &g_btnSettings )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnQTouch )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnLPModes )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                            }

                            if ( pWidget == &g_btnInfos )
                            {
                                WGT_Screen_SetSelectedWidget( pScreen, &g_btnVideo ) ;
                            }
                        }
                    }
                break ;
#endif // defined DEMO_USE_QTOUCH

                // Enter
                case WGT_KEY_PB2 :
                case WGT_KEY_K3 :
                    if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
                    {
                        if ( pWidget != NULL )
                        {
//                            printf( "ScrMain - Sending selected\r\n" ) ;
                            WGT_PostMessage( WGT_MSG_WIDGET_SELECTED, (uint32_t)pWidget, 0 ) ;
                        }
                    }
                break ;
            }
        break ;

        case WGT_MSG_KEY_PRESSED : // button pressed
            switch ( pMsg->dwParam1 )
            {
                case WGT_KEY_S1 :
                case WGT_KEY_VR1 :
//                    printf( "ScrMain - pot %u %u %u\r\n", pMsg->dwParam2, pMsg->dwParam2/7, ((pMsg->dwParam2*7)/256) ) ;

#if defined DEMO_USE_QTOUCH
                    switch ( ((pMsg->dwParam2*7)/256) )
#else
                    switch ( ((pMsg->dwParam2*6)/256) )
#endif // defined DEMO_USE_QTOUCH
                    {
                        case 0 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnAudio ) ;
                        break ;

                        case 1 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnVideo ) ;
                        break ;

                        case 2 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnSlideShow ) ;
                        break ;

                        case 3 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnSettings ) ;
                        break ;

#if defined DEMO_USE_QTOUCH
                        case 4 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnQTouch ) ;
                        break ;

                        case 5 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                        break ;

                        case 6 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                        break ;
#else
                        case 4 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnLPModes ) ;
                        break ;

                        case 5 :
                            WGT_Screen_SetSelectedWidget( pScreen, &g_btnInfos ) ;
                        break ;
#endif // defined DEMO_USE_QTOUCH
                    }
                break ;
            }
        break ;

        case WGT_MSG_WIDGET_SELECTED :
//            printf( "ScrMain - switching screen\r\n" ) ;
            if ( pMsg->dwParam1 == (uint32_t)&g_btnVideo )
            {
//                WGT_SetCurrentScreen( &ScrCube ) ;
//                WGT_SetCurrentScreen( &ScrStarfield ) ;
                WGT_SetCurrentScreen( &ScrDISPDemo ) ;
            }

            if ( pMsg->dwParam1 == (uint32_t)&g_btnSlideShow )
            {
                WGT_SetCurrentScreen( &ScrPPT ) ;
            }

            if ( pMsg->dwParam1 == (uint32_t)&g_btnAudio )
            {
                WGT_SetCurrentScreen( &ScrAudio ) ;
            }

#if defined DEMO_USE_QTOUCH
            if ( pMsg->dwParam1 == (uint32_t)&g_btnQTouch )
            {
                WGT_SetCurrentScreen( &ScrQTouch ) ;
            }
#endif // defined DEMO_USE_QTOUCH

            if ( pMsg->dwParam1 == (uint32_t)&g_btnLPModes )
            {
                WGT_SetCurrentScreen( &ScrLPModes ) ;
            }

            if ( pMsg->dwParam1 == (uint32_t)&g_btnSettings )
            {
                WGT_SetCurrentScreen( &ScrSettings ) ;
            }

            if ( pMsg->dwParam1 == (uint32_t)&g_btnInfos )
            {
                WGT_SetCurrentScreen( &ScrInfos ) ;
            }
        break ;
    }

    return SAMGUI_E_OK ;
}
示例#4
0
static uint32_t _ScrSettings_Date_ProcessMessage( SWGTScreen* pScreen, SWGTCoreMessage* pMsg )
{
//    printf( "ScrSettings_Date - msg id %x\r\n", pMsg->dwID ) ;

    switch ( pMsg->dwID )
    {
        case WGT_MSG_WIDGET_SELECTED :
            /*
             * Handle Back button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnBack )
            {
                g_demo_parameters.dwDay=gs_dwDay ;
                g_demo_parameters.dwMonth=gs_dwMonth ;
                g_demo_parameters.dwYear=gs_dwYear ;
                Demo_Parameters_CommitChanges() ;

                WGT_SetCurrentScreen( &ScrSettings ) ;
            }

            /*
             * Handle UP/Day button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnUpDay )
            {
                if ( gs_dwDay == 31 )
                {
                    gs_dwDay=1 ;
                }
                else
                {
                    gs_dwDay++ ;
                }

                _ScrSettings_Date_SetDay() ;
                WGT_Draw( &g_wgt_Day, g_WGT_CoreData.pBE ) ;
            }

            /*
             * Handle DOWN/Day button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnDownDay )
            {
                if ( gs_dwDay == 1 )
                {
                    gs_dwDay=31 ;
                }
                else
                {
                    gs_dwDay-- ;
                }

                _ScrSettings_Date_SetDay() ;
                WGT_Draw( &g_wgt_Day, g_WGT_CoreData.pBE ) ;
            }

            /*
             * Handle UP/Month button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnUpMonth )
            {
                if ( gs_dwMonth == 12 )
                {
                    gs_dwMonth=1 ;
                }
                else
                {
                    gs_dwMonth++ ;
                }

                _ScrSettings_Date_SetMonth() ;
                WGT_Draw( &g_wgt_Month, g_WGT_CoreData.pBE ) ;
            }

            /*
             * Handle DOWN/Month button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnDownMonth )
            {
                if ( gs_dwMonth == 1 )
                {
                    gs_dwMonth=12 ;
                }
                else
                {
                    gs_dwMonth-- ;
                }

                _ScrSettings_Date_SetMonth() ;
                WGT_Draw( &g_wgt_Month, g_WGT_CoreData.pBE ) ;
            }

            /*
             * Handle UP/Year button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnUpYear )
            {
                if ( gs_dwYear == 2020 )
                {
                    gs_dwYear=2000 ;
                }
                else
                {
                    gs_dwYear++ ;
                }

                _ScrSettings_Date_SetYear() ;
                WGT_Draw( &g_wgt_Year, g_WGT_CoreData.pBE ) ;
            }

            /*
             * Handle DOWN/Year button
             */
            if ( pMsg->dwParam1 == (uint32_t)&g_btnDownYear )
            {
                if ( gs_dwYear == 2000 )
                {
                    gs_dwYear=2020 ;
                }
                else
                {
                    gs_dwYear-- ;
                }

                _ScrSettings_Date_SetYear() ;
                WGT_Draw( &g_wgt_Year, g_WGT_CoreData.pBE ) ;
            }
        break ;

        case WGT_MSG_TIMER :
        break ;
    }

    return SAMGUI_E_OK ;
}