static void IDrawTwoDigits(T_timeDateWorkspace *G_ws, T_region *r, char *aDigits, T_pixelColor aColor) { INT_32 x, y; INT_32 nextX; swim_set_fill_color(&G_win, BLACK); swim_set_pen_color(&G_win, BLACK); swim_set_fill_transparent(&G_win, 0); swim_set_xy(&G_win, r->iLeft+1, r->iTop+1); swim_set_pen_color(&G_win, aColor); if (aDigits[0] != ' ') swim_put_char(&G_win, aDigits[0]); swim_get_xy(&G_win, &x, &y); nextX = r->iLeft+1+G_ws->iBigDigitWidth-1; if (x < nextX) { swim_set_pen_color(&G_win, BLACK); swim_put_box(&G_win, x, y, nextX, y+G_ws->iBigDigitHeight-1); } swim_set_xy(&G_win, r->iLeft+1+G_ws->iBigDigitWidth, r->iTop+1); swim_set_pen_color(&G_win, aColor); if (aDigits[1] != ' ') swim_put_char(&G_win, aDigits[1]); swim_get_xy(&G_win, &x, &y); nextX = r->iLeft+1+2*G_ws->iBigDigitWidth-3; if (x < nextX) { swim_set_pen_color(&G_win, BLACK); swim_put_box(&G_win, x, y, nextX, y+G_ws->iBigDigitHeight-1); } }
static void ITestPatternColors(SWIM_WINDOW_T *aWin) { int x, y; TUInt16 i=0; for (y=1; y<32; y++) { for (x=0; x<256; x++, i++) { #if (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_SHARP_LQ043T3DG01) swim_set_pen_color(aWin, (y<<11)); #elif (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_INTELTRONIC_LMIX0560NTN53V1) swim_set_pen_color(aWin, (y<<10)+((x&128)?0x8000:0)); #elif (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_TIANMA_TM070RBHG04 || UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_SEIKO_70WVW2T) swim_set_pen_color(aWin, (y<<10)); #else swim_set_pen_color(aWin, (y<<11)); #endif swim_put_pixel(aWin, x+20, y+40); } } for (y=1; y<32; y++) { for (x=0; x<256; x++, i++) { #if (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_SHARP_LQ043T3DG01) swim_set_pen_color(aWin, (y<<6)); #elif (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_INTELTRONIC_LMIX0560NTN53V1) swim_set_pen_color(aWin, (y<<5)+((x&128)?0x8000:0)); #else swim_set_pen_color(aWin, (y<<5)); #endif swim_put_pixel(aWin, x+20, y+40+32); } } for (y=1; y<32; y++) { for (x=0; x<256; x++, i++) { #if (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_SHARP_LQ043T3DG01) swim_set_pen_color(aWin, (y<<0)); #elif (UEZ_DEFAULT_LCD_CONFIG==LCD_CONFIG_INTELTRONIC_LMIX0560NTN53V1) swim_set_pen_color(aWin, (y<<0)+((x&128)?0x8000:0)); #else swim_set_pen_color(aWin, (y<<0)); #endif swim_put_pixel(aWin, x+20, y+40+64); } } }
static void AudioPlayerScreen(T_uezDevice lcd) { T_pixelColor *pixels; SUIHidePage0(); UEZLCDGetFrame(lcd, 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); swim_set_title(&G_win, "uEZ(tm) Audio Player", BLUE); swim_set_pen_color(&G_win, YELLOW); swim_set_font(&G_win, &font_winfreesys14x16); SUIShowPage0(); }
void FCTL_Screen(T_uezDevice lcd) { T_pixelColor *pixels; SUIHidePage0(); UEZLCDGetFrame(lcd, 0, (void **)&pixels); swim_window_open( &G_ttWin, DISPLAY_WIDTH, DISPLAY_HEIGHT, pixels, 0, 0, DISPLAY_WIDTH-1, DISPLAY_HEIGHT-1, 2, YELLOW, RGB(0, 0, 0), RED); swim_set_font(&G_ttWin, &APP_DEMO_DEFAULT_FONT); swim_set_title(&G_ttWin, "Functional Test Loopback", BLUE); swim_set_pen_color(&G_ttWin, YELLOW); swim_set_fill_color(&G_ttWin, BLACK); swim_put_text_xy(&G_ttWin, "In this mode the ARM-TS-KIT serves as an RS232", TT_COLUMN_1, TT_ROW2_3); swim_put_text_xy(&G_ttWin, "and CAN loopback for functional test", TT_COLUMN_1, TT_ROW2_4); ChoicesDraw(&G_ttWin, G_ttChoices); SUIShowPage0(); }
static void BCMUpdate(T_brightnessControlWorkspace *G_ws) { T_region r; TUInt32 y; swim_set_font_transparency(&G_win, 1); r = G_ws->iRGroove; UEZLCDGetBacklightLevel(G_ws->iLCD, &G_ws->iLevel, &G_ws->iNumLevels); y = (G_ws->iLevel * (1+r.iBottom-r.iTop))/G_ws->iNumLevels; y = r.iBottom - y; if (y != G_ws->iKnobY) { if (G_ws->iKnobY) { // Erase the old one swim_set_fill_transparent(&G_win, 0); swim_set_pen_color(&G_win, BLACK); swim_set_fill_color(&G_win, BLACK); swim_put_box( &G_win, r.iLeft-15, G_ws->iKnobY-5, r.iRight+15, G_ws->iKnobY+5); } swim_set_fill_transparent(&G_win, 1); swim_set_pen_color(&G_win, YELLOW); swim_put_box( &G_win, r.iLeft, r.iTop, r.iRight, r.iBottom); G_ws->iKnobY = y; swim_set_fill_transparent(&G_win, 0); swim_set_pen_color(&G_win, YELLOW); swim_set_fill_color(&G_win, BLACK); swim_put_box( &G_win, r.iLeft-15, G_ws->iKnobY-5, r.iRight+15, G_ws->iKnobY+5); } }
static void TDMUpdate(T_timeDateWorkspace *G_ws) { char number[4]; T_uezTimeDate td; T_uezError error; // Now do the RTC error = UEZTimeDateGet(&td); if (error) { memset(&td, 0, sizeof(td)); } // Now draw the fields swim_set_font(&G_win, &TIME_DATE_FONT); swim_set_font_transparency(&G_win, 0); swim_set_pen_color(&G_win, YELLOW); // Date sprintf(number, "%2d", td.iDate.iMonth); IDrawTwoDigits(G_ws, &G_ws->iRField1, number, (G_ws->iField == 1)?GREEN:YELLOW); swim_set_pen_color(&G_win, YELLOW); swim_put_text_xy(&G_win, "/", G_ws->iRSlash1.iLeft+1, G_ws->iRSlash1.iTop+1); sprintf(number, "%2d", td.iDate.iDay); IDrawTwoDigits(G_ws, &G_ws->iRField2, number, (G_ws->iField == 2)?GREEN:YELLOW); swim_set_pen_color(&G_win, YELLOW); swim_put_text_xy(&G_win, "/", G_ws->iRSlash2.iLeft+1, G_ws->iRSlash2.iTop+1); sprintf(number, "%02d", td.iDate.iYear%100); IDrawTwoDigits(G_ws, &G_ws->iRField3, number, (G_ws->iField == 3)?GREEN:YELLOW); // Time sprintf(number, "%2d", td.iTime.iHour); IDrawTwoDigits(G_ws, &G_ws->iRField4, number, (G_ws->iField == 4)?GREEN:YELLOW); swim_set_pen_color(&G_win, YELLOW); swim_put_text_xy(&G_win, ":", G_ws->iRSlash4.iLeft+1, G_ws->iRSlash4.iTop+1); sprintf(number, "%02d", td.iTime.iMinute); IDrawTwoDigits(G_ws, &G_ws->iRField5, number, (G_ws->iField == 5)?GREEN:YELLOW); swim_set_pen_color(&G_win, YELLOW); swim_put_text_xy(&G_win, ":", G_ws->iRSlash5.iLeft+1, G_ws->iRSlash5.iTop+1); sprintf(number, "%02d", td.iTime.iSecond); IDrawTwoDigits(G_ws, &G_ws->iRField6, number, (G_ws->iField == 6)?GREEN:YELLOW); }
static void IPatternOfColors(T_brightnessControlWorkspace *G_ws) { int x, y; int v; TUInt16 i=0; T_pixelColor c; for (y=1; y<=(BCM_COLORS_HEIGHT/3); y++) { v = (y*256)/(BCM_COLORS_HEIGHT/3); c = RGB(v, 0, 0); for (x=0; x<BCM_COLORS_WIDTH; x++, i++) { swim_set_pen_color(&G_win, c); swim_put_pixel( &G_win, G_ws->iRColors.iLeft+x, G_ws->iRColors.iTop+y+0); } } for (y=1; y<=(BCM_COLORS_HEIGHT/3); y++) { v = (y*256)/(BCM_COLORS_HEIGHT/3); c = RGB(0, v, 0); for (x=0; x<BCM_COLORS_WIDTH; x++, i++) { swim_set_pen_color(&G_win, c); swim_put_pixel( &G_win, G_ws->iRColors.iLeft+x, G_ws->iRColors.iTop+y+(BCM_COLORS_HEIGHT/3)); } } for (y=1; y<=(BCM_COLORS_HEIGHT/3); y++) { v = (y*256)/(BCM_COLORS_HEIGHT/3); c = RGB(0, 0, v); for (x=0; x<BCM_COLORS_WIDTH; x++, i++) { swim_set_pen_color(&G_win, c); swim_put_pixel( &G_win, G_ws->iRColors.iLeft+x, G_ws->iRColors.iTop+y+((2*BCM_COLORS_HEIGHT)/3)); } } }
/*---------------------------------------------------------------------------* * Routine: DR_DrawColor *---------------------------------------------------------------------------* * Description: * Draw the currently selected color in the upper left. *---------------------------------------------------------------------------*/ static void DR_DrawColor(void) { const T_choice * const p_lastChoice = &G_drChoices[0]; swim_set_fill_color( &G_drWin, G_drColor); swim_set_pen_color(&G_drWin, YELLOW); swim_put_box(&G_drWin, p_lastChoice->iLeft, p_lastChoice->iTop, p_lastChoice->iRight, p_lastChoice->iBottom); }
static void DrawScreenSaverBox(T_brightnessControlWorkspace *G_ws) { if(G_ScreenSaverOn == EFalse) { swim_set_fill_color(&G_win, BLACK); } else { swim_set_fill_color(&G_win, YELLOW); } swim_set_pen_color(&G_win, YELLOW); swim_put_box( &G_win, G_ssOptionBox.iLeft+1, G_ssOptionBox.iTop+1, G_ssOptionBox.iRight-1, G_ssOptionBox.iBottom-1); }
void BSODStart(const char *aLine) { T_pixelColor *pixels; T_uezDevice lcd; if (UEZLCDOpen("LCD", &lcd) == UEZ_ERROR_NONE) { UEZLCDOn(lcd); UEZLCDBacklight(lcd, 255); UEZLCDGetFrame(lcd, 0, (void **)&pixels); UEZLCDShowFrame(lcd, 0); swim_window_open(&G_bsodWin, UEZ_LCD_DISPLAY_WIDTH, UEZ_LCD_DISPLAY_HEIGHT, (COLOR_T *)pixels, 0, 0, UEZ_LCD_DISPLAY_WIDTH-1, UEZ_LCD_DISPLAY_HEIGHT-1, 2, WHITE, BLUE, WHITE); swim_set_font(&G_bsodWin, &font_winfreesys14x16_subset); swim_set_pen_color(&G_bsodWin, WHITE); G_bsodActive = ETrue; BSODPrint(aLine); } }
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(); }
/*---------------------------------------------------------------------------* * Routine: DR_Screen *---------------------------------------------------------------------------* * Description: * Draw the DrawMode screen. * Inputs: * T_uezDevice lcd -- LCD screen to use. *---------------------------------------------------------------------------*/ void DR_Screen(T_uezDevice lcd) { T_pixelColor *pixels; UEZLCDGetFrame(lcd, 0, (void **)&pixels); SUIHidePage0(); swim_window_open( &G_drWin, DISPLAY_WIDTH, DISPLAY_HEIGHT, pixels, 0, 0, DISPLAY_WIDTH-1, DISPLAY_HEIGHT-1, 2, YELLOW, RGB(0, 0, 0), RED); swim_set_font(&G_drWin, &APP_DEMO_DEFAULT_FONT); swim_set_title(&G_drWin, "uEZ(tm) Draw Demonstration", BLUE); swim_set_pen_color(&G_drWin, YELLOW); ChoicesDraw(&G_drWin, G_drChoices); // Now draw the drawing area swim_set_fill_color( &G_drWin, BLACK); swim_put_box( &G_drWin, DR_IMAGE_LEFT, DR_IMAGE_TOP, DR_IMAGE_RIGHT, DR_IMAGE_BOTTOM); SUIShowPage0(); }
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(); }
/*---------------------------------------------------------------------------* * 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); }
/*---------------------------------------------------------------------------* * 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); }
/********************************************************************** * * Function: c_entry * * Purpose: Application entry point from the startup code * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * *********************************************************************/ void c_entry(void) { SWIM_WINDOW_T win1; COLOR_T clr, *fblog; int idx; INT_32 lcddev; UNS_16 xgs, ygs, curx, cury, curym, xidx; /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Set virtual address of MMU table */ cp15_set_vmmu_addr((void *) (IRAM_BASE + (256 * 1024) - (16 * 1024))); /* Setup miscellaneous board functions */ phy3250_board_init(); /* Setup LCD muxing for STN Color 16BPP */ clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1); /* Enable clock to LCD block (HCLK_EN)*/ clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1); /* Setup LCD paramaters in the LCD controller */ lcddev = lcd_open(CLCDC, (INT_32) &LCD_DISPLAY); /* Upper Panel Frame Base Address register */ lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF); /* Enable LCD controller and power signals */ lcd_ioctl(lcddev, LCD_PWENABLE, 1); /* Enable LCD backlight */ phy3250_lcd_backlight_enable(TRUE); /* Enable LCD power */ phy3250_lcd_power_enable(TRUE); /* Set frame buffer address */ fblog = (COLOR_T *) cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF); /* Create a SWIM window */ swim_window_open(&win1, LCD_DISPLAY.pixels_per_line, LCD_DISPLAY.lines_per_panel, fblog, 0, 0, (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1),1, WHITE, BLACK, BLACK); /* Compute vertical size for bars */ ygs = LCD_DISPLAY.lines_per_panel / 3; /* Draw Red bars */ cury = 0; curx = 0; curym = ygs - 1; xgs = LCD_DISPLAY.pixels_per_line / RED_COLORS; clr = BLACK; for (xidx = 0; xidx < RED_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0800; } /* Draw green bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / GREEN_COLORS; clr = BLACK; for (xidx = 0; xidx < GREEN_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0020; } /* Draw blue bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / BLUE_COLORS; clr = BLACK; for (xidx = 0; xidx < BLUE_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0001; } }
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(); }
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. */ }
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(); }
/*---------------------------------------------------------------------------* * Routine: ChoicesUpdateContinuously *---------------------------------------------------------------------------* * Description: * Wait for a touchscreen event or timeout. Check the event and change * the state of the choices. Choices are chosen continuously as they * are pressed reporting events every call. * Inputs: * SWIM_WINDOW_T *aWin -- Window to draw within * const T_choice *aChoices -- Choices to use * T_uezQueue aTouchQueue -- Touchscreen queue * TUInt32 aTimeout -- Time to wait for touchscreen event * Outputs: * const T_choice * -- Last choice selected or 0 for none. *---------------------------------------------------------------------------*/ const T_choice *ChoicesUpdateContinuously( SWIM_WINDOW_T *aWin, const T_choice *aChoices, T_uezQueue aInputEventQueue, TUInt32 aTimeout) { T_uezInputEvent inputEvent; INT_32 winX, winY; static const T_choice *p_lastChoice = 0; const T_choice *p_choice = 0; const T_choice *p_choiceCalled = 0; if (UEZQueueReceive(aInputEventQueue, &inputEvent, aTimeout) == UEZ_ERROR_NONE) { winX = inputEvent.iEvent.iXY.iX; winY = inputEvent.iEvent.iXY.iY; swim_get_virtual_xy(aWin, &winX, &winY); // Is this a touching event? if (inputEvent.iEvent.iXY.iAction == XY_ACTION_PRESS_AND_HOLD) { // We are touching the screen. // Is this a different position than before? // Determine which choice we are in p_choice = IFindChoice(aChoices, winX, winY); if (p_choice != p_lastChoice) { if (p_lastChoice) { // Un-invert the last choice (draw black square) swim_set_fill_color(aWin, G_settings.iUnselectColor); swim_set_pen_color(aWin, G_settings.iUnselectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_lastChoice->iLeft, p_lastChoice->iTop, p_lastChoice->iRight, p_lastChoice->iBottom); swim_set_fill_transparent(aWin, 0); } if (p_choice) { // Invert the new choice swim_set_pen_color(aWin, G_settings.iSelectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_choice->iLeft, p_choice->iTop, p_choice->iRight, p_choice->iBottom); swim_set_fill_transparent(aWin, 0); } p_lastChoice = p_choice; p_choice = 0; } // Act like we just released the same spot // Determine which choice we are in p_choice = p_lastChoice; if (p_choice) { // Same as when we pressed // Do the action if (p_choice->iAction) { const T_choice *p_prevChoice = p_lastChoice; p_lastChoice = 0; // ButtonClick(); p_choiceCalled = p_choice; p_choice->iAction(p_choice); // Un-invert the last choice swim_set_fill_transparent(aWin, 1); swim_set_pen_color(aWin, G_settings.iUnselectColor); swim_put_box(aWin, p_prevChoice->iLeft, p_prevChoice->iTop, p_prevChoice->iRight, p_prevChoice->iBottom); swim_set_fill_transparent(aWin, 0); p_lastChoice = 0; } } } else { // The screen is no longer being touched. // Nothing being touched p_lastChoice = 0; return 0; } } else { return 0; } return p_choiceCalled; }
/********************************************************************** * * Function: c_entry * * Purpose: Application entry point from the startup code * * Processing: * See function. * * Parameters: None * * Outputs: None * * Returns: Nothing * * Notes: None * *********************************************************************/ void c_entry(void) { SWIM_WINDOW_T win1; COLOR_T clr, *fblog; int idx; UNS_16 xgs, ygs, curx, cury, curym, xidx; /* Disable interrupts in ARM core */ disable_irq_fiq(); /* Set virtual address of MMU table */ cp15_set_vmmu_addr((void *) (IRAM_BASE + (256 * 1024) - (16 * 1024))); /* Initialize interrupt system */ int_initialize(0xFFFFFFFF); /* Install standard IRQ dispatcher at ARM IRQ vector */ int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler); /* Setup miscellaneous board functions */ phy3250_board_init(); /* enable clock to ADC block - 32KHz clock */ clkpwr_clk_en_dis(CLKPWR_ADC_CLK,1); /* TSC IRQ goes active when the FIFO reaches the Interrupt level */ int_install_irq_handler(IRQ_TS_IRQ, (PFV) tsc_user_interrupt); /* Enable interrupt */ int_enable(IRQ_TS_IRQ); /* Open TSC, sets default timing values, fifo = 16, resolution = 10bits */ tscdev = tsc_open(TSC, 0); /* TSC Auto mode enable, this also sets AUTO bit */ tsc_ioctl(tscdev,TSC_AUTO_EN, 1); /* Setup LCD muxing for STN Color 16BPP */ clkpwr_setup_lcd(CLKPWR_LCDMUX_TFT16, 1); /* Enable clock to LCD block (HCLK_EN)*/ clkpwr_clk_en_dis(CLKPWR_LCD_CLK, 1); /* Setup LCD paramaters in the LCD controller */ lcddev = lcd_open(CLCDC, (INT_32) &LCD_DISPLAY); /* Upper Panel Frame Base Address register */ lcd_ioctl(lcddev, LCD_SET_UP_FB, PHY_LCD_FRAME_BUF); /* Enable LCD controller and power signals */ lcd_ioctl(lcddev, LCD_PWENABLE, 1); /* Enable LCD backlight */ phy3250_lcd_backlight_enable(TRUE); /* Enable LCD power */ phy3250_lcd_power_enable(TRUE); /* write cursor image array data to cursor image RAM */ lcd_ioctl(lcddev, LCD_CRSR_INIT_IMG, (INT_32) &cursorimage[0]); /* enable the default cursor 0 */ lcd_ioctl(lcddev,LCD_CRSR_EN,1); /* set the cursor X/Y position */ lcd_ioctl(lcddev, LCD_CRSR_XY, 0x0); /* set the cursor pallette BGR value, col0*/ lcd_ioctl(lcddev, LCD_CRSR_PAL0, 0x00ff0000); /* set the cursor pallette BGR value, col1 */ lcd_ioctl(lcddev, LCD_CRSR_PAL1, 0x000000ff); /* Enable IRQ interrupts in the ARM core */ enable_irq(); /* Set frame buffer address */ fblog = (COLOR_T *)cp15_map_physical_to_virtual(PHY_LCD_FRAME_BUF); /* Create a SWIM window */ swim_window_open(&win1, LCD_DISPLAY.pixels_per_line, LCD_DISPLAY.lines_per_panel, fblog, 0, 0, (LCD_DISPLAY.pixels_per_line - 1), (LCD_DISPLAY.lines_per_panel - 1), 1, WHITE, BLACK, BLACK); /* Compute vertical size for bars */ ygs = LCD_DISPLAY.lines_per_panel / 3; /* Draw Red bars */ cury = 0; curx = 0; curym = ygs - 1; xgs = LCD_DISPLAY.pixels_per_line / RED_COLORS; clr = BLACK; for (xidx = 0; xidx < RED_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0800; } /* Draw green bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / GREEN_COLORS; clr = BLACK; for (xidx = 0; xidx < GREEN_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0020; } /* Draw blue bars */ cury = cury + ygs; curx = 0; curym = cury + (ygs - 1); xgs = LCD_DISPLAY.pixels_per_line / BLUE_COLORS; clr = BLACK; for (xidx = 0; xidx < BLUE_COLORS; xidx++) { swim_set_pen_color(&win1, clr); for (idx = 0; idx <= xgs; idx++) { swim_put_line(&win1, curx, cury, curx, curym); curx++; } clr = clr + 0x0001; } /* lets stay here forever */ while(1); }
/*---------------------------------------------------------------------------* * Routine: DrawMode *---------------------------------------------------------------------------* * Description: * Put the processor in the draw mode 'application' or 'demo'. * Buttons are shown to load, save, exit, and change the current color. * The user can then draw in the designated area a small picture using * the current color. * Inputs: * const T_choice *aChoice -- Choice object selected for this action. *---------------------------------------------------------------------------*/ void DrawMode(const T_choice *aChoice) { T_uezDevice lcd; T_uezDevice ts; static T_uezQueue queue = (TUInt32)NULL; INT_32 winX, winY; T_pixelColor *pixels; T_uezInputEvent inputEvent; TBool isDrawing = EFalse; INT_32 lastWinX, lastWinY; G_drExit = EFalse; #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, "Draw TS" ); #else if (UEZQueueCreate(1, sizeof(T_uezInputEvent), &queue) == UEZ_ERROR_NONE) { #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", &lcd) == UEZ_ERROR_NONE) { UEZLCDGetFrame(lcd, 0, (void **)&pixels); // Put the draw screen up DR_Screen(lcd); DR_DrawColor(); while (!G_drExit) { // Wait forever until we receive a touchscreen event // NOTE: UEZTSGetReading() can also be used, but it doesn't wait. if (UEZQueueReceive(queue, &inputEvent, UEZ_TIMEOUT_INFINITE)==UEZ_ERROR_NONE) { winX = inputEvent.iEvent.iXY.iX; winY = inputEvent.iEvent.iXY.iY; swim_get_virtual_xy(&G_drWin, &winX, &winY); // Are we in the drawing area? if ((winX > DR_IMAGE_LEFT) && (winX < DR_IMAGE_RIGHT) && (winY > DR_IMAGE_TOP) && (winY < DR_IMAGE_BOTTOM)) { // Pen down or up? if (inputEvent.iEvent.iXY.iAction == XY_ACTION_PRESS_AND_HOLD) { UEZLCDScreensaverWake(); if (G_drColor == BLACK) { // Draw a 3x3 block in the area swim_set_pen_color(&G_drWin, G_drColor); if (isDrawing) { DrawBlockLine(lastWinX, lastWinY, winX, winY); } else { DrawBlockPixel(winX, winY); } } else { // Draw a dot swim_set_pen_color(&G_drWin, G_drColor); if (isDrawing) { swim_put_line(&G_drWin, lastWinX, lastWinY, winX, winY); } else { swim_put_pixel(&G_drWin, winX, winY); } } isDrawing = ETrue; lastWinX = winX; lastWinY = winY; } else { // No longer drawing isDrawing = EFalse; } } else { ChoicesUpdateByReading(&G_drWin, G_drChoices, &inputEvent); if (inputEvent.iEvent.iXY.iAction == XY_ACTION_RELEASE) isDrawing = EFalse; } } } UEZLCDClose(lcd); } UEZTSClose(ts, queue); } #ifndef NO_DYNAMIC_MEMORY_ALLOC UEZQueueDelete(queue); #endif } }
/*---------------------------------------------------------------------------* * Routine: ChoicesUpdateByReading *---------------------------------------------------------------------------* * Description: * An input event has been received. Check the event and change * the state of the choices. * Inputs: * SWIM_WINDOW_T *aWin -- Window to draw within * const T_choice *aChoices -- Choices to use * T_uezQueue aTouchQueue -- Touchscreen queue * TUInt32 aTimeout -- Time to wait for touchscreen event * Outputs: * const T_choice * -- Last choice selected or 0 for none. *---------------------------------------------------------------------------*/ const T_choice *ChoicesUpdateByReading( SWIM_WINDOW_T *aWin, const T_choice *aChoices, T_uezInputEvent *p_inputEvent) { INT_32 winX, winY; static TUInt16 lastX = 0, lastY = 0; static const T_choice *p_lastChoice = 0; static const T_choice *p_buttonChoice = 0; static const T_choice *p_nextButtonChoice = 0; const T_choice *p_choice = 0; const T_choice *p_choiceCalled = 0; winX = p_inputEvent->iEvent.iXY.iX; winY = p_inputEvent->iEvent.iXY.iY; swim_get_virtual_xy(aWin, &winX, &winY); // Is this a touching event? if(p_inputEvent->iType == INPUT_EVENT_TYPE_XY) { // Is this a press or hold event? if (p_inputEvent->iEvent.iXY.iAction == XY_ACTION_PRESS_AND_HOLD) { // We are touching the screen. // Is this a different position than before? if ((p_inputEvent->iEvent.iXY.iX != lastX) || (p_inputEvent->iEvent.iXY.iY != lastY)) { // Determine which choice we are in p_choice = IFindChoice(aChoices, winX, winY); if (p_choice != p_lastChoice) { #if HAPTIC_FEEDBACK hapticFeedback(DEFAULT_HAPTIC_TIME_MS); #endif if (p_lastChoice) { // Un-invert the last choice swim_set_fill_color(aWin, G_settings.iUnselectColor); swim_set_pen_color(aWin, G_settings.iUnselectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_lastChoice->iLeft, p_lastChoice->iTop, p_lastChoice->iRight, p_lastChoice->iBottom); swim_set_fill_transparent(aWin, 0); } // Turn off button repeating when we leave focus G_repeatOn = EFalse; if (p_choice) { // Invert the new choice swim_set_pen_color(aWin, G_settings.iSelectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_choice->iLeft, p_choice->iTop, p_choice->iRight, p_choice->iBottom); swim_set_fill_transparent(aWin, 0); // If the option we are over is repeating, // turn on repeating. if (p_choice->iFlags & SUI_FLAG_REPEAT) G_repeatOn = ETrue; } p_lastChoice = p_choice; p_choice = 0; } } // Are we allowed to repeat? if (G_repeatOn) { if (!G_repeating) { G_repeating = ETrue; G_repeatLastTouch = UEZTickCounterGet(); G_repeatTime = REPEAT_TIME_1; // first repeat is slow } else { // Time to repeat? if (UEZTickCounterGetDelta(G_repeatLastTouch) >= G_repeatTime) { if (G_repeatTime == REPEAT_TIME_1) G_repeatTime = REPEAT_TIME_2; else if (G_repeatTime == REPEAT_TIME_2) G_repeatTime = REPEAT_TIME_3; G_repeatLastTouch = UEZTickCounterGet(); // Cause a repeat by signalling a non-touch event below //p_reading->iFlags &= ~TSFLAG_PEN_DOWN; } } } } else { // Really not touching? // Are we repeating? if (G_repeating) { // Stop that. G_repeating = EFalse; } } // Release event (real for faked above?) if (p_inputEvent->iEvent.iXY.iAction == XY_ACTION_RELEASE) { // The screen is no longer being touched. // Determine which choice we are in p_choice = p_lastChoice; if (p_choice) { // Same as when we pressed // Do the action if (p_choice->iAction) { const T_choice *p_prevChoice = p_lastChoice; p_lastChoice = 0; p_choiceCalled = p_choice; // Un-invert the last choice swim_set_fill_transparent(aWin, 1); swim_set_pen_color(aWin, G_settings.iUnselectColor); swim_put_box(aWin, p_prevChoice->iLeft, p_prevChoice->iTop, p_prevChoice->iRight, p_prevChoice->iBottom); swim_set_fill_transparent(aWin, 0); p_choice->iAction(p_choice); p_lastChoice = 0; } } } } else { // This is a button event if(p_inputEvent->iEvent.iButton.iAction == BUTTON_ACTION_PRESS) { if(p_buttonChoice == 0){ p_buttonChoice = IFindChoiceTopLeft(aChoices); } else { // Un-invert the last choice swim_set_fill_color(aWin, G_settings.iUnselectColor); swim_set_pen_color(aWin, G_settings.iUnselectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_buttonChoice->iLeft, p_buttonChoice->iTop, p_buttonChoice->iRight, p_buttonChoice->iBottom); swim_set_fill_transparent(aWin, 0); if(p_inputEvent->iEvent.iButton.iKey == KEY_ARROW_RIGHT) { p_nextButtonChoice = IFindChoiceRight(aChoices, p_buttonChoice, 2); if(p_nextButtonChoice == p_buttonChoice) p_buttonChoice = IFindChoiceRight(aChoices, p_buttonChoice, 1); else p_buttonChoice = p_nextButtonChoice; } else if(p_inputEvent->iEvent.iButton.iKey == KEY_ARROW_LEFT) { p_nextButtonChoice = IFindChoiceLeft(aChoices, p_buttonChoice, 2); if(p_nextButtonChoice == p_buttonChoice) p_buttonChoice = IFindChoiceLeft(aChoices, p_buttonChoice, 1); else p_buttonChoice = p_nextButtonChoice; } else if(p_inputEvent->iEvent.iButton.iKey == KEY_ARROW_UP) { p_nextButtonChoice = IFindChoiceUp(aChoices, p_buttonChoice, 2); if(p_nextButtonChoice == p_buttonChoice) p_buttonChoice = IFindChoiceUp(aChoices, p_buttonChoice, 1); else p_buttonChoice = p_nextButtonChoice; } else if(p_inputEvent->iEvent.iButton.iKey == KEY_ARROW_DOWN) { p_nextButtonChoice = IFindChoiceDown(aChoices, p_buttonChoice, 2); if(p_nextButtonChoice == p_buttonChoice) p_buttonChoice = IFindChoiceDown(aChoices, p_buttonChoice, 1); else p_buttonChoice = p_nextButtonChoice; } else if(p_inputEvent->iEvent.iButton.iKey == KEY_ENTER) { p_choice = p_buttonChoice; p_buttonChoice = 0; p_choiceCalled = p_choice; p_choice->iAction(p_choice); } } // Invert the new choice swim_set_pen_color(aWin, G_settings.iSelectColor); swim_set_fill_transparent(aWin, 1); swim_put_box(aWin, p_buttonChoice->iLeft, p_buttonChoice->iTop, p_buttonChoice->iRight, p_buttonChoice->iBottom); swim_set_fill_transparent(aWin, 0); } else /* BUTTON_ACTION_RELEASE */{ } } return p_choiceCalled; }