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(); }
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(); }
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. */ }