Пример #1
0
static void VideoPlayerSelectOptionDraw(const T_choice *p_choice)
{
    T_region r;
    T_region icon;
    INT_32 imageX, imageY;
    TUInt16 fontHeight;
    T_region rtext;

    r.iLeft = p_choice->iLeft;
    r.iTop = p_choice->iTop;
    r.iRight = p_choice->iRight;
    r.iBottom = p_choice->iBottom;

    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    fontHeight = swim_get_font_height(&G_win);

    // Inset a little for this inner area
    RegionShrinkTopBottom(&r, 2);


    // Draw the icon to the left
    RegionSplitFromLeft(&r, &icon, VIDEO_ICON_WIDTH, 2);
    if (p_choice->iIcon) {
        imageX = icon.iLeft;
        imageY = icon.iTop;
        swim_get_physical_xy(&G_win, &imageX, &imageY);
        SUIDrawIcon(
            p_choice->iIcon,
            imageX,
            imageY);
    }

    // Center vertically and draw the text to the right
    RegionCenterTopBottom(&r, &rtext, fontHeight);
    swim_put_text_xy(
        &G_win,
        p_choice->iText,
        rtext.iLeft,
        rtext.iTop);
	
}
Пример #2
0
static void MSMDraw(void)
{
    static const char *noFiles = "< No SLIDES.TXT file found >";
    static const char *noDrive = "< No Drive Found >";
    static const char *noListINI = "< Show not found in SLIDES.INI file >";
    const char *p_msg = noFiles;
    TUInt32 width;
    TUInt16 fontHeight;
    T_region r1, r2;
    SUIHidePage0();

    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    fontHeight = swim_get_font_height(&G_win);
    swim_set_pen_color(&G_win, YELLOW);
    swim_set_fill_color(&G_win, BLACK);

    swim_put_box(&G_win,
          G_ws->iChoiceBox.iLeft,
          G_ws->iChoiceBox.iTop,
          G_ws->iChoiceBox.iRight,
          G_ws->iChoiceBox.iBottom);

    if (G_ws->iSlideshowList.iCount==0) {
        p_msg = noDrive;
        if (G_ws->iDriveError == UEZ_ERROR_READ_WRITE_ERROR)
            p_msg = noDrive;
        else if (G_ws->iDriveError == UEZ_ERROR_NOT_FOUND)
            p_msg = noFiles;
        else if (G_ws->iDriveError == UEZ_ERROR_EMPTY)
            p_msg = noListINI;

        width = swim_get_text_line_width(&G_win, p_msg);
        RegionCenterLeftRight(&G_ws->iChoiceBox, &r1, width);
        RegionCenterTopBottom(&r1, &r2, fontHeight);
        swim_put_text_xy(&G_win, p_msg, r2.iLeft, r2.iTop);
    }

    ChoicesDraw(&G_win, G_ws->iChoices);

    SUIShowPage0();
}
Пример #3
0
static void VideoPlayerSelectDraw(void)
{
    static const char *noFiles = "< No audio files found >";
	static const char *noDrive = "< No SD card found >";
    const char *p_msg = noFiles;
    TUInt32 width;
    TUInt16 fontHeight;
    T_region r1, r2;
    SUIHidePage0();

    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    fontHeight = swim_get_font_height(&G_win);
    swim_set_pen_color(&G_win, YELLOW);
    swim_set_fill_color(&G_win, BLACK);

    swim_put_box(&G_win, 
          G_ws->iChoiceBox.iLeft,
          G_ws->iChoiceBox.iTop,
          G_ws->iChoiceBox.iRight,
          G_ws->iChoiceBox.iBottom);

    if (G_ws->iNumVideos==0) {
        p_msg = noDrive;
        if (G_ws->iDriveError == UEZ_ERROR_READ_WRITE_ERROR)
            p_msg = noDrive;
        else if (G_ws->iDriveError == UEZ_ERROR_NOT_FOUND)
            p_msg = noFiles;
        
        width = swim_get_text_line_width(&G_win, p_msg);
        RegionCenterLeftRight(&G_ws->iChoiceBox, &r1, width);
        RegionCenterTopBottom(&r1, &r2, fontHeight);
        swim_put_text_xy(&G_win, p_msg, r2.iLeft, r2.iTop);
    }

    ChoicesDraw(&G_win, G_ws->iChoices);

    SUIShowPage0();
}
Пример #4
0
/*---------------------------------------------------------------------------*
 * Routine:  DR_Save
 *---------------------------------------------------------------------------*
 * Description:
 *      Save the currently shown image to the flash drive.
 * Inputs:
 *      const T_choice *aChoice   -- Choice object selected for this action.
 *---------------------------------------------------------------------------*/
static void DR_Save(const T_choice *aChoice)
{
    T_uezError error;
    T_uezError errorUSB, errorSD;
    T_uezFile file;
    INT_32 winX, winY;
    T_pixelColor *raster;
    TUInt32 num;
    TUInt16 x, y;

    // Draw line around choice while saving
    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, YELLOW);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);

    // Try to save to the USB drive
    error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_WRITE, &file);

    // If an error, try to save to the SD Card
    if (error != UEZ_ERROR_NONE)
        error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_WRITE, &file);
    else
        errorSD = UEZ_ERROR_UNKNOWN;

    // Any errors?
    if (error == UEZ_ERROR_NONE) {
        raster = (T_pixelColor  *)LOAD_SPACE;
        for (y=0; y<DR_IMAGE_HEIGHT; y++) {
            for (x=0; x<DR_IMAGE_WIDTH; x++) {
                winX = x + DR_IMAGE_LEFT+1;
                winY = y + DR_IMAGE_TOP+1;
                swim_get_physical_xy(&G_drWin, &winX, &winY);
                swim_driver_get_raster(&G_drWin, winX, winY, (COLOR_T *)raster, 1); // get pixel color
                raster++;
            }
        }
        // Save image
        error = UEZFileWrite(
                    file,
                    LOAD_SPACE,
                    DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor),
                    &num);
        if ((error != UEZ_ERROR_NONE) &&
                (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) {
            BeepError();
        }
        UEZFileClose(file);
    } else {
        // Had an error, report it
        SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE);
        BeepError();
        swim_set_fill_transparent(&G_drWin, 0);
        swim_set_fill_color(&G_drWin, BLACK);
        swim_set_pen_color(&G_drWin, YELLOW);
        swim_put_box(
            &G_drWin,
            DR_IMAGE_LEFT,
            DR_IMAGE_TOP,
            DR_IMAGE_RIGHT,
            DR_IMAGE_TOP+16);
        if (errorUSB == UEZ_ERROR_NOT_FOUND) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write image to USB Drive",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to USB Drive or SD Card",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to USB Drive",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else if (errorUSB == UEZ_ERROR_NOT_READY) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SDCard found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Could not write to SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else {
            swim_put_text_xy(
                &G_drWin,
                "Write error!",
                DR_IMAGE_LEFT+2,
                DR_IMAGE_TOP+2);
        }
        swim_set_fill_transparent(&G_drWin, 1);
        UEZTaskDelay(2000);
        SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE);
    }

    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, BLACK);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);
}
Пример #5
0
/*---------------------------------------------------------------------------*
 * Routine:  DR_Load
 *---------------------------------------------------------------------------*
 * Description:
 *      Load an image from the flash drive and show.
 * Inputs:
 *      const T_choice *aChoice   -- Choice object selected for this action.
 *---------------------------------------------------------------------------*/
static void DR_Load(const T_choice *aChoice)
{
    T_uezError error;
    T_uezError errorUSB, errorSD;
    T_uezFile file;
    INT_32 winX, winY;
    TUInt32 num;
    TUInt16 x, y;

    // Draw line around choice while loading
    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, YELLOW);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);

    // Try to load from the USB drive
    error = errorUSB = UEZFileOpen("0:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file);

    // If an error, try to load from the SD Card
    if (error != UEZ_ERROR_NONE)
        error = errorSD = UEZFileOpen("1:IMAGE.RAW", FILE_FLAG_READ_ONLY, &file);
    else
        errorSD = UEZ_ERROR_UNKNOWN;

    // Continue if no errors
    if (error == UEZ_ERROR_NONE) {
        error = UEZFileRead(
                    file,
                    LOAD_SPACE,
                    DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor),
                    &num);
        UEZFileClose(file);
        if ((error != UEZ_ERROR_NONE) &&
                (num != DR_IMAGE_WIDTH*DR_IMAGE_HEIGHT*sizeof(T_pixelColor))) {
            BeepError();
        } else {
            T_pixelColor *raster = (T_pixelColor *)LOAD_SPACE;
            for (y=0; y<DR_IMAGE_HEIGHT; y++) {
                for (x=0; x<DR_IMAGE_WIDTH; x++) {
                    winX = x + DR_IMAGE_LEFT+1;
                    winY = y + DR_IMAGE_TOP+1;
                    swim_get_physical_xy(&G_drWin, &winX, &winY);
                    swim_driver_put_pixel(&G_drWin, winX, winY, raster[x]);
                }
                raster += DR_IMAGE_WIDTH;
            }
        }
    }
    if (error) {
        // Had an error, report it
        SUICopyFast32(FRAME(1), FRAME(0), FRAME_SIZE);
        BeepError();
        swim_set_fill_transparent(&G_drWin, 0);
        swim_set_fill_color(&G_drWin, BLACK);
        swim_set_pen_color(&G_drWin, YELLOW);
        swim_put_box(
            &G_drWin,
            DR_IMAGE_LEFT,
            DR_IMAGE_TOP,
            DR_IMAGE_RIGHT,
            DR_IMAGE_TOP+16);
        if (errorUSB == UEZ_ERROR_NOT_FOUND) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on USB Drive!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
#if UEZ_DEFAULT_LCD_RES_QVGA
                    // Shorter string on QVGA screens
                    "Image file not found on USB or SD Card!",
#else
                    "Image file not found on USB Drive or SD Card!",
#endif
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on USB Drive!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else if (errorUSB == UEZ_ERROR_NOT_READY) {
            if (errorSD == UEZ_ERROR_NOT_READY) {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SD Card found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else if (errorSD == UEZ_ERROR_NOT_FOUND) {
                swim_put_text_xy(
                    &G_drWin,
                    "Image file not found on SD Card!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            } else {
                swim_put_text_xy(
                    &G_drWin,
                    "No USB Drive or SD Card found!",
                    DR_IMAGE_LEFT+2,
                    DR_IMAGE_TOP+2);
            }
        } else {
            swim_put_text_xy(
                &G_drWin,
                "Read error!",
                DR_IMAGE_LEFT+2,
                DR_IMAGE_TOP+2);
        }
        swim_set_fill_transparent(&G_drWin, 1);
        UEZTaskDelay(2000);
        SUICopyFast32(FRAME(0), FRAME(1), FRAME_SIZE);
    }

    swim_set_fill_transparent(&G_drWin, 1);
    swim_set_pen_color(&G_drWin, BLACK);
    swim_put_box(
        &G_drWin,
        aChoice->iLeft,
        aChoice->iTop,
        aChoice->iRight,
        aChoice->iBottom);
}
Пример #6
0
/*---------------------------------------------------------------------------*
 * Routine:  TitleScreen
 *---------------------------------------------------------------------------*
 * Description:
 *      Draw the title screen at boot
 *---------------------------------------------------------------------------*/
void TitleScreen(void)
{
    T_uezDevice lcd;
    T_pixelColor *pixels;
    TUInt16 i;
    char buffer[15];

    G_romChecksumCalculated = EFalse;
    UEZTaskCreate(
        (T_uezTaskFunction)CalcChecksumTask,
        "Chksum",
        UEZ_TASK_STACK_BYTES(256),
        (void *)0,
        UEZ_PRIORITY_NORMAL,
        0);

    if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE)  {
        UEZLCDGetFrame(lcd, 0, (void **)&pixels);
        UEZLCDBacklight(lcd, 0);
        UEZLCDOff(lcd);

        SUIHidePage0();

        swim_window_open(
            &G_mmWin,
            DISPLAY_WIDTH,
            DISPLAY_HEIGHT,
            pixels,
            0,
            0,
            DISPLAY_WIDTH-1,
            DISPLAY_HEIGHT-1,
            2,
            BLACK,
            RGB(0, 0, 0),
            RED);

        swim_set_font(&G_mmWin, &APP_DEMO_DEFAULT_FONT);

        SUIDrawBitmap(
			G_uEZLogo,
            (DISPLAY_WIDTH-UEZ_ICON_WIDTH)/2,
            (DISPLAY_HEIGHT-UEZ_ICON_HEIGHT)/2);

        SUIShowPage0();

        UEZLCDOn(lcd);
#if FAST_STARTUP
        UEZLCDBacklight(lcd, 255);
#else
        for (i=0; i<255; i++)  {
            UEZLCDBacklight(lcd, i);
            UEZTaskDelay(1);
        }
#endif
        // Create checksum string
#if FAST_STARTUP
        sprintf(buffer, "CS:????");
#else
        while (!G_romChecksumCalculated)
            UEZTaskDelay(10);
        sprintf(buffer, "CS:%08X", G_romChecksum);
        swim_set_font_transparency(&G_mmWin, 1);
        swim_put_text_xy(
            &G_mmWin,
            buffer,
            5,
            DISPLAY_HEIGHT-15);
        swim_set_font_transparency(&G_mmWin, 0);
#endif

    }
}
Пример #7
0
void BrightnessControlMode(const T_choice *aChoice)
{
    T_uezDevice ts;
    static T_uezQueue queue = NULL;
    static T_brightnessControlWorkspace *G_ws = NULL;
    INT_32 winX, winY;
    T_uezInputEvent inputEvent;
#if ENABLE_UEZ_BUTTON
    T_uezDevice keypadDevice;
#endif
#if UEZ_ENABLE_LIGHT_SENSOR
    TUInt32 levelCurrent = 1, levelPrevious = 0;
    T_uezDevice ls;
    DEVICE_LightSensor **p;
    T_uezError error;
    char levelText[30];
    TBool lightSensorActive = EFalse;

    if( UEZDeviceTableFind("Light Sensor", &ls) == UEZ_ERROR_NONE) {
        if(UEZDeviceTableGetWorkspace(ls, (T_uezDeviceWorkspace **)&p) == UEZ_ERROR_NONE) {
            if((*p)->Open((void *)p, "I2C1") == UEZ_ERROR_NONE) {
                lightSensorActive = ETrue;
            }
        }
    }
#endif
#ifdef NO_DYNAMIC_MEMORY_ALLOC
    if (NULL == G_ws)
    {
        G_ws = UEZMemAlloc(sizeof(*G_ws));
    }
#else
    G_ws = UEZMemAlloc(sizeof(*G_ws));
#endif

#if UEZ_ENABLE_LIGHT_SENSOR
    UEZTaskSuspend(G_lightSensorTask);
#endif
    if (!G_ws)
        return;
    memset(G_ws, 0, sizeof(*G_ws));
    G_ws->iExit = EFalse;
    G_ws->iNeedUpdate = ETrue;

#ifdef NO_DYNAMIC_MEMORY_ALLOC
    if (NULL == queue)
    {
        if (UEZQueueCreate(1, sizeof(T_uezInputEvent), &queue) != UEZ_ERROR_NONE)
        {
            queue = NULL;
        }
    }

    if (NULL != queue) {
        /* Register the queue so that the IAR Stateviewer Plugin knows about it. */
        UEZQueueAddToRegistry( queue, "Brightness TS" );
#else
    if (UEZQueueCreate(1, sizeof(T_uezInputEvent), &queue) == UEZ_ERROR_NONE) {
#if UEZ_REGISTER
        UEZQueueSetName(queue, "Brightness", "\0");
#endif
#endif
#if ENABLE_UEZ_BUTTON
        UEZKeypadOpen("BBKeypad", &keypadDevice, &queue);
#endif

        // Open up the touchscreen and pass in the queue to receive events
        if (UEZTSOpen("Touchscreen", &ts, &queue)==UEZ_ERROR_NONE)  {

            // Open the LCD and get the pixel buffer
            if (UEZLCDOpen("LCD", &G_ws->iLCD) == UEZ_ERROR_NONE)  {
                UEZLCDGetBacklightLevel(G_ws->iLCD, &G_ws->iLevel, &G_ws->iNumLevels);

                // Put the screen up
                BCMScreen(G_ws);

                // Sit here in a loop until we are done
                while (!G_ws->iExit) {
                    // Do choices and updates
                    if (UEZQueueReceive(queue, &inputEvent, 500)==UEZ_ERROR_NONE) {
                        winX = inputEvent.iEvent.iXY.iX;
                        winY = inputEvent.iEvent.iXY.iY;
                        swim_get_virtual_xy(&G_win, &winX, &winY);
                        if (inputEvent.iEvent.iXY.iAction == XY_ACTION_PRESS_AND_HOLD)  {
                            // Are we in the panel?
                            if ((winY >= G_ws->iRSlidePanel.iTop) && (winY <= G_ws->iRSlidePanel.iBottom) &&
                                    (winX >= G_ws->iRSlidePanel.iLeft) && (winX <= G_ws->iRSlidePanel.iRight)) {
                                // Inside the panel and touching the screen, let's map this to an intensity
                                // of 0-255
                                if(winY > G_ws->iRGroove.iBottom)
                                    G_ws->iLevel = 0;
                                else
                                {
                                    G_ws->iLevel =
                                        (G_ws->iRGroove.iBottom - winY)*(G_ws->iNumLevels)/
                                        (1+G_ws->iRGroove.iBottom-G_ws->iRGroove.iTop);
                                }
                                UEZLCDSetBacklightLevel(G_ws->iLCD, G_ws->iLevel);
                                G_ws->iNeedUpdate = ETrue;
                            }
                        }
                        ChoicesUpdateByReading(&G_win, G_ws->iChoices, &inputEvent);
#if UEZ_ENABLE_LIGHT_SENSOR
                        if (lightSensorActive) {
                            levelCurrent = (*p)->GetLevel((void *)p);
                            if(levelCurrent == 0xFFFFFFFF) { //ligh sensor no longer resonding
                                lightSensorActive = EFalse;
                                break;
                            }
                            if( levelCurrent != levelPrevious) {
                                swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
                                swim_set_fill_color(&G_win, BLACK);
                                swim_set_pen_color(&G_win, BLACK);
                                sprintf(levelText, "Ambient Light Level: %04d lux\0", levelCurrent);
                                //erase old text
                                swim_put_box(&G_win,
                                             (UEZ_LCD_DISPLAY_WIDTH/2) - (swim_get_text_line_width(&G_win, levelText) /2),//x1
                                             BCM_SLIDE_PANEL_OUTER_PADDING,//y1
                                             (UEZ_LCD_DISPLAY_WIDTH/2) + (swim_get_text_line_width(&G_win, levelText) /2),//x2
                                             BCM_SLIDE_PANEL_OUTER_PADDING + swim_get_font_height(&G_win));//y2
                                //put new text
                                swim_set_pen_color(&G_win, YELLOW);
                                swim_put_text_xy(&G_win, levelText,
                                                 (UEZ_LCD_DISPLAY_WIDTH/2) - (swim_get_text_line_width(&G_win, levelText) /2),//x
                                                 (BCM_SLIDE_PANEL_OUTER_PADDING));//y
                                levelPrevious = levelCurrent;
                            }
                        }
#endif
                    }
                    if (G_ws->iNeedUpdate) {
                        BCMUpdate(G_ws);
                        G_ws->iNeedUpdate = EFalse;
                    }
                }
                UEZLCDClose(G_ws->iLCD);
            }
            UEZTSClose(ts, queue);
        }
#if ENABLE_UEZ_BUTTON
        UEZKeypadClose(keypadDevice, &queue);
#endif
#ifndef NO_DYNAMIC_MEMORY_ALLOC
        UEZQueueDelete(queue);
#endif
#if UEZ_ENABLE_LIGHT_SENSOR
        (*p)->Close((void *)p);
        UEZTaskResume(G_lightSensorTask);
#endif
    }
    /* <<< WHIS >>> Potential memory leak in FreeRTOS version as G_ws is not
    free'd. */
}
Пример #8
0
static void BCMScreen(T_brightnessControlWorkspace *G_ws)
{
    T_pixelColor *pixels;
    T_region r;
    T_region rbottom;
    T_region rtemp;
    TUInt32 width;
    T_choice *p = G_ws->iChoices;
    TUInt32 padding;

    SUIHidePage0();

    UEZLCDGetFrame(G_ws->iLCD, 0, (void **)&pixels);
    swim_window_open(
        &G_win,
        DISPLAY_WIDTH,
        DISPLAY_HEIGHT,
        pixels,
        0,
        0,
        DISPLAY_WIDTH-1,
        DISPLAY_HEIGHT-1,
        2,
        YELLOW,
        RGB(0, 0, 0),
        RED);
    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    G_ws->iFontHeight = swim_get_font_height(&G_win);
    swim_set_title(&G_win, "uEZ(tm) Brightness Control", BLUE);
    swim_set_pen_color(&G_win, YELLOW);
    swim_set_fill_color(&G_win, BLACK);

    r.iLeft = 0;
    r.iTop = 0;
    r.iRight = G_win.xvsize;
    r.iBottom = G_win.yvsize;

    // Come off the edges
    RegionShrink(&r, SCREEN_EDGE_MIN_PADDING-2);

    // Add the back button
    RegionSplitFromBottom(&r, &rbottom, 4+G_ws->iFontHeight+2+EXIT_BUTTON_HEIGHT, 5);
    //RegionCenterLeftRight(&rbottom, &rtemp, EXIT_BUTTON_WIDTH);
    //rbottom = rtemp;

    rtemp = rbottom;
    RegionSplitFromLeft(&rtemp, &rbottom, EXIT_BUTTON_WIDTH, 5);

    RegionShrink(&rbottom, 1);
    p->iLeft = rbottom.iLeft;
    p->iRight = rbottom.iLeft+EXIT_BUTTON_WIDTH-1;
    p->iTop = rbottom.iTop;
    p->iBottom = rbottom.iTop+EXIT_BUTTON_HEIGHT-1;
    p->iText = "Exit";
    p->iAction = BCMExit;
    p->iIcon = G_exitIcon;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // Use default
    p++;

    rbottom = rtemp;
    RegionCenterLeftRight(&rbottom, &rtemp, 100);
    RegionSplitFromBottom(&rtemp, &G_ssOptionBox, (rtemp.iBottom-rtemp.iTop)/2+6, 5); // location of screen saver option box
    //RegionSplitFromLeft(&rtemp, &G_ssOptionBox, (rtemp.iBottom-rtemp.iTop)/2 - swim_get_font_height(&G_win)/2, 5);
    G_ssOptionBox.iRight = G_ssOptionBox.iLeft+swim_get_font_height(&G_win)+16; // size of screen saver option box
    G_ssOptionBox.iBottom = G_ssOptionBox.iTop+swim_get_font_height(&G_win)+16;

    p->iLeft = G_ssOptionBox.iLeft;
    p->iRight = G_ssOptionBox.iRight;
    p->iTop = G_ssOptionBox.iTop;
    p->iBottom = G_ssOptionBox.iBottom;
    p->iText = "";
    p->iAction = BCMScreenSaverToggle;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // Use default
    p++;

    // Determine the spacing between slider and RGB
    // Determine width used
    width = BCM_COLORS_WIDTH+BCM_SLIDE_PANEL_INNER_PADDING*2+BCM_SLIDE_PANEL_OUTER_PADDING*2+BCM_GROOVE_WIDTH;
    // Now subtract that from the full width available.
    width = (1+r.iRight-r.iLeft)-width;
    // Split it 3 ways to divide it evenly
    padding = width/3;

    // Now use this padding to take a chunk out of the left
    RegionSplitFromLeft(&r, &rtemp, 0, padding);
    // Now determine the region for the slider
    RegionSplitFromLeft(
        &r,
        &G_ws->iRSlidePanel,
        BCM_SLIDE_PANEL_INNER_PADDING*2+BCM_SLIDE_PANEL_OUTER_PADDING*2+BCM_GROOVE_WIDTH,
        padding);
    RegionCenterLeftRight(&G_ws->iRSlidePanel, &G_ws->iRGroove, BCM_GROOVE_WIDTH);
    RegionShrinkTopBottom(&G_ws->iRGroove, BCM_SLIDE_PANEL_INNER_PADDING);

    // Now place the colors on the right
    RegionSplitFromLeft(
        &r,
        &rtemp,
        BCM_COLORS_WIDTH,
        0);
    RegionCenterTopBottom(
        &rtemp,
        &G_ws->iRColors,
        BCM_COLORS_HEIGHT);

    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);

    swim_set_font_transparency(&G_win, 1);
    swim_set_fill_transparent(&G_win, 0);
    swim_set_pen_color(&G_win, YELLOW);
    r = G_ws->iRSlidePanel;
    swim_put_box(
        &G_win,
        r.iLeft,
        r.iTop,
        r.iRight,
        r.iBottom);
    r = G_ws->iRGroove;
    swim_put_box(
        &G_win,
        r.iLeft,
        r.iTop,
        r.iRight,
        r.iBottom);

    DrawScreenSaverBox(G_ws);

    swim_put_text_xy(&G_win, "Screen Saver On/Off",
                     G_ssOptionBox.iLeft+swim_get_font_height(&G_win)+22,//x
                     G_ssOptionBox.iTop+8);//y

    // Now do the RTC
    // Now draw the fields
    IPatternOfColors(G_ws);

    swim_set_pen_color(&G_win, YELLOW);
    ChoicesDraw(&G_win, G_ws->iChoices);

    SUIShowPage0();
}
Пример #9
0
/*---------------------------------------------------------------------------*
* Routine:  TitleScreen
*---------------------------------------------------------------------------*
* Description:
*      Draw the title screen at boot
*---------------------------------------------------------------------------*/
void TitleScreen(void)
{
    T_uezDevice lcd;
    T_pixelColor *pixels;
    TUInt16 i;
    char buffer[15];

    G_romChecksumCalculated = EFalse;
    UEZTaskCreate(
                  (T_uezTaskFunction)CalcChecksumTask,
                  "Chksum",
                  UEZ_TASK_STACK_BYTES(128),
                  (void *)0,
                  UEZ_PRIORITY_NORMAL,
                  0);

    if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE)  {
        UEZLCDGetFrame(lcd, 0, (void **)&pixels);
        UEZLCDBacklight(lcd, 0);
        UEZLCDOff(lcd);

        SUIHidePage0();

        swim_window_open(
                         &G_mmWin,
                         DISPLAY_WIDTH,
                         DISPLAY_HEIGHT,
                         pixels,
                         0,
                         0,
                         DISPLAY_WIDTH-1,
                         DISPLAY_HEIGHT-1,
                         2,
                         YELLOW,
                         RGB(0, 0, 0),
                         RED);

        swim_set_font(&G_mmWin, &APP_DEMO_DEFAULT_FONT);        
#if DKTS_BUTTON_SLIDE_SHOW_DEMO
        SUILoadPicture("1:SPLASH.TGA",0,0,(TUInt8 *)FRAME(0));
#else
        SUIDrawIcon(
                    G_titleScreen,
                    (DISPLAY_WIDTH-TITLE_SCREEN_WIDTH)/2,
                    (DISPLAY_HEIGHT-TITLE_SCREEN_HEIGHT)/2);

        swim_set_font_transparency(&G_mmWin, 1);
        swim_put_text_xy(
                         &G_mmWin,
                         VERSION_AS_TEXT,
                         DISPLAY_WIDTH-60,
                         DISPLAY_HEIGHT-15);
#endif
        SUIShowPage0();

        UEZLCDOn(lcd);
#if FAST_STARTUP
        UEZLCDBacklight(lcd, 255);
#else
        for (i=0; i<256; i++)  {
            UEZLCDBacklight(lcd, i);
            UEZTaskDelay(1);
        }
#endif
        // Create checksum string
#if FAST_STARTUP
        sprintf(buffer, "CS:????");
#else
        while (!G_romChecksumCalculated)
            UEZTaskDelay(10);
        sprintf(buffer, "CS:%08X", G_romChecksum);
        swim_set_font_transparency(&G_mmWin, 1);
#if DKTS_BUTTON_SLIDE_SHOW_DEMO // skip checksum print
#else
        swim_put_text_xy(
                         &G_mmWin,
                         buffer,
                         5,
                         DISPLAY_HEIGHT-15);
#endif
        swim_set_font_transparency(&G_mmWin, 0);
#endif

    }
}