示例#1
0
static void AudioPlayerOptionDraw(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, AUDIO_FILE_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);
	
}
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
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. */
}
示例#5
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();
}
示例#6
0
static void AudioPlayerChoices(void)
{
    T_region r;
    T_region rlist;
    T_region rline;
    T_region rbottom;
    TUInt16 fontHeight;
    TUInt16 lineHeight;
    int i = 0;
    T_choice *p = G_ws->iChoices;

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

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

    RegionShrink(&r, 10);

    RegionSplitFromBottom(&r, &rbottom, 4+fontHeight+2+EXIT_BUTTON_HEIGHT, 2);
    rlist = r;
	
    G_ws->iChoiceBox = rlist;
    RegionShrink(&rlist, 2);
    
	
	lineHeight = fontHeight+4;
    if (lineHeight < AUDIO_FILE_ICON_HEIGHT+4)
        lineHeight = AUDIO_FILE_ICON_HEIGHT+4;
	
    for (i=G_topFileIndex; i<MAX_CHOICES-1; i++, p++) {
        if (i>=G_ws->iAudioList.iCount)
            break;

        // Stop if there is not enough room for another line
        if ((1+rlist.iBottom - rlist.iTop)<(lineHeight+1))
            break;

        // Pull off some space
        RegionSplitFromTop(&rlist, &rline, lineHeight, 1);

        // Setup new choice
        p->iLeft = rline.iLeft;
        p->iTop = rline.iTop;
        p->iRight = rline.iRight-33;
        p->iBottom = rline.iBottom;
        p->iText = G_ws->iAudioList.iList[i].iName;
        p->iAction = AudioPlayerPlay;
        p->iIcon = G_audioFileIconPlay ;
        p->iData = &G_ws->iAudioList.iList[i];
        p->iDraw = AudioPlayerOptionDraw;
        G_ws->iChoiceBox.iBottom = rline.iBottom+2;
    }
	
	
    // Now add the back button
    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 = "";
    p->iAction = AudioPlayerExit;
    p->iIcon = G_exitIcon;
    p->iData = 0;
    p->iDraw = 0; // Use default
	p++;
	
	// Now add the up button
    RegionShrink(&rbottom, 1);
    p->iLeft = G_ws->iChoiceBox.iRight-33;
    p->iRight = G_ws->iChoiceBox.iRight-1;
    p->iTop = G_ws->iChoiceBox.iTop+1;
    p->iBottom = G_ws->iChoiceBox.iTop+33;
    p->iText = "";
    p->iAction = AudioScrollUp;
    p->iIcon = G_arrowUp;
    p->iData = 0;
    p->iDraw = 0;
	p++;
	
	// Now add the down button
    RegionShrink(&rbottom, 1);
    p->iLeft = G_ws->iChoiceBox.iRight-33;
    p->iRight = G_ws->iChoiceBox.iRight-1;
    p->iTop = G_ws->iChoiceBox.iBottom-33;
    p->iBottom = G_ws->iChoiceBox.iBottom-1;
    p->iText = "";
    p->iAction = AudioScrollDown;
    p->iIcon = G_arrowDown;
    p->iData = 0;
    p->iDraw = 0;

    // Next entry is the end of choices marker
    p++;
    p->iText = 0; // end of list marker*/
}
/* Creates a title bar for the window */
void swim_set_title(SWIM_WINDOW_T *win,
					const CHAR *title,
					COLOR_T ttlbkcolor)
{
	COLOR_T savedf, savedp, savedb;
	int32_t savedt;

	/* Is present font height larger than window client height? */
	if ((swim_get_font_height(win) < (4 + win->yvsize)) &&
		(title != (CHAR *) 0)) {
		/* There is enough room for title bar, so continue */

		/* Save original colors and font transparentcy flag */
		savedf = win->fill;
		savedp = win->pen;
		savedb = win->bkg;
		savedt = win->tfont;

		/* Set fill color to background color (temporarily)
		   used with box function */
		win->fill = ttlbkcolor;
		win->bkg = ttlbkcolor;
		win->pen = win->bkg;

		/* Draw the background for the title bar */
		swim_put_box(win, 0, 0, win->xvsize,
					 (4 + swim_get_font_height(win) - 2));

		/* Reset text starting position for title string */
		win->xvpos = win->xpvmin + 2;
		win->yvpos = win->ypvmin + 1;

		/* Restore original pen color (used for text color) */
		win->pen = savedp;

		/* Restore the original colors */
		win->fill = savedf;
		win->bkg = savedb;

		/* Put string in title bar area (with transparent background) */
		win->tfont = 0;
		swim_put_text(win, title);
		win->tfont = savedt;

		/* Draw a line under the title bar, but before the
		   (new) client area */
		swim_put_line(win, 0,
					  (4 + swim_get_font_height(win) - 1),
					  win->xpvmax, (4 + swim_get_font_height(win) - 1));

		/* Adjust client height of window (virtual and physcal) */
		win->ypmin = win->ypmin + swim_get_font_height(win) + 4;
		win->ypvmin = win->ypvmin + swim_get_font_height(win) + 4;

		/* Resize y dimension */
		win->yvsize = win->yvsize - swim_get_font_height(win) + 4;

		/* Reset text starting position to new client area */
		win->xvpos = win->xpvmin;
		win->yvpos = win->ypvmin;
	}
}
示例#8
0
static void VideoPlayerSelectChoices(void)
{
    T_region r;
    T_region rlist;
    T_region rline;
    T_region rbottom;
    TUInt16 fontHeight;
    TUInt16 lineHeight;
    int i = 0;
    T_choice *p = G_ws->iChoices;
    int count = 0;
    
    r.iLeft = 0;
    r.iTop = 0;
    r.iRight = G_win.xvsize;
    r.iBottom = G_win.yvsize;
    
    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    fontHeight = swim_get_font_height(&G_win);
    
    RegionShrink(&r, 5);
    
    RegionSplitFromBottom(&r, &rbottom, 4+fontHeight+2+EXIT_BUTTON_HEIGHT, 2);
    rlist = r;
    
    G_ws->iChoiceBox = rlist;
    RegionShrink(&rlist, 2);
    
    lineHeight = fontHeight+4;
    if (lineHeight < VIDEO_ICON_HEIGHT+4)
        lineHeight = VIDEO_ICON_HEIGHT+4;
    
    for (i=G_topFileIndex; i<MAX_VIDEOS; i++, p++) {

        if (i>=G_ws->iNumVideos)
            break;
      
        // Stop if there is not enough room for another line
        if ((1+rlist.iBottom - rlist.iTop)<(lineHeight+1))
            break;

        // Pull off some space
        RegionSplitFromTop(&rlist, &rline, lineHeight, 1);

        // Setup new choice
        p->iLeft = rline.iLeft;
        p->iTop = rline.iTop;
        p->iRight = rline.iRight-33;
        p->iBottom = rline.iBottom;
        p->iText = G_ws->iVideos[i].iTitle;
        p->iAction = VideoPlayerSelectAction;
        p->iIcon = G_slideshowSmallIcon;
        p->iData = &G_ws->iVideos[i];
        p->iDraw = VideoPlayerSelectOptionDraw;
        G_ws->iChoiceBox.iBottom = rline.iBottom+2;

        count++;
    }
    
    /*
    // Added to make sure window goes to the bottom even if list is too small
    while ((1+rlist.iBottom - rlist.iTop)>=(lineHeight+1)) {
        RegionSplitFromTop(&rlist, &rline, lineHeight, 1);
    }
    */
    
    // Now add the back button
    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 = VideoPlayerSelectExit;
    p->iIcon = G_exitIcon;
    p->iData = 0;
    p->iDraw = 0; // Use default
    p++;
	
	// Now add the up button (but only if needed)
    if (count < G_ws->iNumVideos) {
        // Need to be able to scroll
        RegionShrink(&rbottom, 1);
        p->iLeft = G_ws->iChoiceBox.iRight-33;
        p->iRight = G_ws->iChoiceBox.iRight-1;
        p->iTop = G_ws->iChoiceBox.iTop+1;
        p->iBottom = G_ws->iChoiceBox.iTop+33;
        p->iText = "";
        p->iAction = VideoPlayerSelectScrollUp;
        p->iIcon = G_arrowUp;
        p->iData = 0;
        p->iDraw = 0;
        p++;
    }
	
	// Now add the down button
    if (count < G_ws->iNumVideos) {
        RegionShrink(&rbottom, 1);
        p->iLeft = G_ws->iChoiceBox.iRight-33;
        p->iRight = G_ws->iChoiceBox.iRight-1;
        p->iTop = G_ws->iChoiceBox.iBottom-33;
        p->iBottom = G_ws->iChoiceBox.iBottom-1;
        p->iText = "";
        p->iAction = VideoPlayerSelectScrollDown;
        p->iIcon = G_arrowDown;
        p->iData = 0;
        p->iDraw = 0;
        p++;
    }
    
    // Next entry is the end of choices marker
    p->iText = 0; // end of list marker*/
}
static void MSMSetupChoices(void)
{
    T_region r;
    T_region rlist;
    T_region rline;
    T_region rbottom;
    TUInt16 fontHeight;
    TUInt16 lineHeight;
    int i;
    T_choice *p = G_ws->iChoices;

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

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

    RegionShrink(&r, 10);

    RegionSplitFromBottom(&r, &rbottom, 4+fontHeight+2+EXIT_BUTTON_HEIGHT, 2);
    rlist = r;

    G_ws->iChoiceBox = rlist;
    RegionShrink(&rlist, 2);
    lineHeight = fontHeight+4;
    if (lineHeight < SLIDESHOW_ICON_HEIGHT+4)
        lineHeight = SLIDESHOW_ICON_HEIGHT+4;

    for (i=0; i<MAX_CHOICES-1; i++, p++) {
        if (i>=G_ws->iSlideshowList.iCount)
            break;

        // Stop if there is not enough room for another line
        if ((1+rlist.iBottom - rlist.iTop)<(lineHeight+1))
            break;

        // Pull off some space
        RegionSplitFromTop(&rlist, &rline, lineHeight, 1);

        // Setup new choice
        p->iLeft = rline.iLeft;
        p->iTop = rline.iTop;
        p->iRight = rline.iRight;
        p->iBottom = rline.iBottom;
        p->iText = G_ws->iSlideshowList.iList[i].iName;
        p->iAction = SlideshowAction;
        p->iIcon = G_slideshowSmallIcon;
        p->iData = &G_ws->iSlideshowList.iList[i];
        p->iDraw = SlideshowOptionDraw;
        G_ws->iChoiceBox.iBottom = rline.iBottom+2;
    }

    // Now add the back button
    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 = SlideshowExit;
    p->iIcon = G_exitIcon;
    p->iData = 0;
    p->iDraw = 0; // Use default

    // Next entry is the end of choices marker
    p++;
    p->iText = 0; // end of list marker
}
示例#10
0
/*---------------------------------------------------------------------------*
 * Routine:  CalibrateScreen
 *---------------------------------------------------------------------------*
 * Description:
 *      Draw the screen used for calibration.
 * Inputs:
 *      TUInt16 *aPixels            -- Pointer to pixel memory
 *      TUInt16 aX, aY              -- Coordinate of target to draw
 *---------------------------------------------------------------------------*/
void CalibrateScreen()
{
  T_uezDevice lcd;
  T_pixelColor *pixels;
  SWIM_WINDOW_T win;
  TUInt16 fontHeight;

  if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE)  {
    UEZLCDOn(lcd);
    UEZLCDBacklight(lcd, 256);

    SUIHidePage0();

    UEZLCDGetFrame(lcd, 0, (void **)&pixels);
    swim_window_open(
                     &win,
                     DISPLAY_WIDTH,
                     DISPLAY_HEIGHT,
                     pixels,
                     0,
                     0,
                     DISPLAY_WIDTH-1,
                     DISPLAY_HEIGHT-1,
                     2,
                     YELLOW,
                     RGB(0, 0, 0),
                     RED);
    swim_set_font(&win, &APP_DEMO_DEFAULT_FONT);
    swim_set_title(&win, "Touchscreen Calibration", BLUE);
    fontHeight =  swim_get_font_height(&win);

    switch(G_calibrateState)
    {
    case FIRST_TARGET_RETRY:
      swim_put_text_horizontal_centered(&win,
                       "Calibration error, please try again.",
                       DISPLAY_WIDTH,
                       (fontHeight));
      swim_put_text_horizontal_centered(&win,
                       "Accurately press the center of the",
                       DISPLAY_WIDTH,
                       (DISPLAY_HEIGHT-(4*fontHeight)));
      swim_put_text_horizontal_centered(&win,
                       "red and white target shown.",
                       DISPLAY_WIDTH,
                       (DISPLAY_HEIGHT-(3*fontHeight)));
      break;
    case FIRST_TARGET:
    default:
      swim_put_text_horizontal_centered(&win,
                       "Before using this device, the touch",
                       DISPLAY_WIDTH,
                       (fontHeight));
            swim_put_text_horizontal_centered(&win,
                       "screen must be properly calibrated.",
                       DISPLAY_WIDTH,
                       (2*fontHeight));

            swim_put_text_horizontal_centered(&win,
                       "Accurately press the center of the",
                       DISPLAY_WIDTH,
                       (DISPLAY_HEIGHT-(4*fontHeight)));

            swim_put_text_horizontal_centered(&win,
                       "red and white target shown.",
                       DISPLAY_WIDTH,
                       (DISPLAY_HEIGHT-(3*fontHeight)));

      }
  SUIShowPage0();
  }
}
示例#11
0
void TDMScreen(T_timeDateWorkspace *G_ws)
{
    T_pixelColor *pixels;
    T_region r;
    T_region rbuttons;
    T_region rbutton;
    T_region rbottom;
    T_region rsub;
    T_region rtemp;
    TUInt32 width;
    TUInt32 height;
    T_choice *p = G_ws->iChoices;

    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) Time & Date Demonstration", 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);

    RegionSplitFromBottom(&r, &rbottom, 4+G_ws->iFontHeight+2+EXIT_BUTTON_HEIGHT, 2);
    rtemp = rbottom;

    // Up and Down arrow icons
    if (G_ws->iShowButtons) {
        RegionCenterLeftRight(&rtemp, &rsub, TDM_BUTTON_WIDTH*2+2);

        // Up arrow icon
        RegionSplitFromLeft(&rsub, &rbutton, TDM_BUTTON_WIDTH, 2);
        p->iLeft = rbutton.iLeft;
        p->iTop = rbutton.iTop;
        p->iRight = rbutton.iRight;
        p->iBottom = rbutton.iBottom;
        p->iText = "";
        p->iAction = PushUp;
        p->iIcon = G_upArrowIcon;
        p->iData = (void *)G_ws;
        p->iDraw = 0; // standard icon
        p->iFlags = SUI_FLAG_REPEAT;
        p++;

        // Down arrow icon
        RegionSplitFromLeft(&rsub, &rbutton, TDM_BUTTON_WIDTH, 0);
        p->iLeft = rbutton.iLeft;
        p->iTop = rbutton.iTop;
        p->iRight = rbutton.iRight;
        p->iBottom = rbutton.iBottom;
        p->iText = "";
        p->iAction = PushDown;
        p->iIcon = G_downArrowIcon;
        p->iData = (void *)G_ws;
        p->iDraw = 0; // standard icon
        p->iFlags = SUI_FLAG_REPEAT;
        p++;
    }

    // Add the back button
    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 = TDMExit;
    p->iIcon = G_exitIcon;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // Use default
    p->iFlags = 0;
    p++;

    swim_set_font_transparency(&G_win, 0);
    swim_set_fill_transparent(&G_win, 0);
    swim_set_font_transparency(&G_win, 1);
    swim_set_font(&G_win, &TIME_DATE_FONT);
    G_ws->iBigDigitWidth = 2+swim_get_font_char_width(&G_win, '1');
    G_ws->iBigWidthSlash = 1+swim_get_font_char_width(&G_win, '/');
    G_ws->iBigDigitHeight = swim_get_font_height(&G_win);
    width = G_ws->iBigDigitWidth*6+/*2+TDM_BUTTON_WIDTH*/+G_ws->iBigWidthSlash*2+2*2+2*2;
    height = (G_ws->iBigDigitHeight+4)*2;
//    if ((TDM_BUTTON_HEIGHT*2+2)>height)
//        height = (TDM_BUTTON_HEIGHT*2+2);
    height += 2*2;
    width += 2*2; // padding
//    height += TDM_BUTTON_HEIGHT+2;

    RegionCenterTopBottom(&r, &G_ws->iRMiddle, height);
#if 0
    RegionSplitFromBottom(&G_ws->iRMiddle, &rtemp, TDM_BUTTON_HEIGHT, 2);
#endif
    rbuttons = G_ws->iRMiddle;
    RegionCenterLeftRight(&rbuttons, &G_ws->iRMiddle, width);
    rbuttons = G_ws->iRMiddle;

    // Now create the fields
    RegionSplitFromTop(&rbuttons, &rsub, G_ws->iBigDigitHeight+4, 2);

    RegionSplitFromLeft(&rsub, &G_ws->iRField1, G_ws->iBigDigitWidth*2, 4);
    RegionSplitFromLeft(&rsub, &G_ws->iRSlash1, G_ws->iBigWidthSlash, 0);
    rbutton = G_ws->iRField1;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField1;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;
    RegionSplitFromLeft(&rsub, &G_ws->iRField2, G_ws->iBigDigitWidth*2, 4);
    RegionSplitFromLeft(&rsub, &G_ws->iRSlash2, G_ws->iBigWidthSlash, 0);
    rbutton = G_ws->iRField2;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField2;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;
    RegionSplitFromLeft(&rsub, &G_ws->iRField3, G_ws->iBigDigitWidth*2, 0);
    rbutton = G_ws->iRField3;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField3;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;

    // Now create the fields
    RegionSplitFromTop(&rbuttons, &rsub, G_ws->iBigDigitHeight+4, 0);
    RegionSplitFromLeft(&rsub, &G_ws->iRField4, G_ws->iBigDigitWidth*2, 4);
    RegionSplitFromLeft(&rsub, &G_ws->iRSlash4, G_ws->iBigWidthSlash, 0);
    rbutton = G_ws->iRField4;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField4;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;
    RegionSplitFromLeft(&rsub, &G_ws->iRField5, G_ws->iBigDigitWidth*2, 4);
    RegionSplitFromLeft(&rsub, &G_ws->iRSlash5, G_ws->iBigWidthSlash, 0);
    rbutton = G_ws->iRField5;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField5;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;
    RegionSplitFromLeft(&rsub, &G_ws->iRField6, G_ws->iBigDigitWidth*2, 0);
    rbutton = G_ws->iRField6;
    p->iLeft = rbutton.iLeft;
    p->iTop = rbutton.iTop;
    p->iRight = rbutton.iRight;
    p->iBottom = rbutton.iBottom;
    p->iText = "";
    p->iAction = SelectField6;
    p->iIcon = 0;
    p->iData = (void *)G_ws;
    p->iDraw = 0; // standard icon
    p->iFlags = 0;
    p++;

    // Mark the end of the choices
    p->iText = 0;

    swim_set_font(&G_win, &APP_DEMO_DEFAULT_FONT);
    ChoicesDraw(&G_win, G_ws->iChoices);

    TDMUpdate(G_ws);

    SUIShowPage0();
}