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 DrawPointInBox(TInt32 winX, TInt32 winY) { // Draw point only if in bounds if ((winX > DR_IMAGE_LEFT) && (winX < DR_IMAGE_RIGHT) && (winY > DR_IMAGE_TOP) && (winY < DR_IMAGE_BOTTOM)) { swim_put_pixel(&G_drWin, winX, winY); } }
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: 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 } }