/** * @brief Save the data to specified file. * @param path: pointer to the saving path * @retval File saved */ uint8_t CAMERA_SaveToFile(uint8_t *path) { RTC_TimeTypeDef Time; RTC_DateTypeDef Date; FIL file; uint32_t NumWrittenData; uint8_t ret = 1; char filename[FILEMGR_FILE_NAME_SIZE]; char fullpath[FILEMGR_FILE_NAME_SIZE]; /* Create filename */ k_GetTime(&Time); k_GetDate(&Date); sprintf((char *)filename, "/Camera_%02d%02d%04d_%02d%02d%02d.bmp", Date.Date, Date.Month, Date.Year + 2015, Time.Hours, Time.Minutes, Time.Seconds); strcpy((char *)fullpath, (char *)path); strcat ((char *)fullpath, (char *)filename); BSP_CAMERA_Suspend(); BSP_SD_Init(); /* Can not create file */ if (f_open(&file, (char *)fullpath, FA_CREATE_NEW | FA_WRITE) == FR_OK) { /* Write the received data into the file */ if (f_write(&file, (char *)BMPHeader_QQVGA24Bit, RGB_HEADER_SIZE, (UINT *)&NumWrittenData) == FR_OK) { f_sync(&file); /* Convert RGB16 image to RGB24 */ RGB16toRGB24((uint8_t *)CAMERA_CVRT_BUFFER, (uint8_t *)&buffer_camera); if (f_write(&file, (char *)CAMERA_CVRT_BUFFER, MAX_IMAGE_SIZE, (UINT*)&NumWrittenData)== FR_OK) { /*File Written correctly */ ret = 0; } } f_close(&file); } BSP_CAMERA_Init(RESOLUTION_R160x120); CAMERA_Configured = 1; BSP_CAMERA_Resume(); return ret; }
/** * @brief Callback routine of desktop window status. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbStatus(WM_MESSAGE * pMsg) { int xSize, ySize; static uint8_t TempStr[50]; static WM_HTIMER hTimerTime; uint8_t res = 0; //static WM_HTIMER hSpriteTime; RTC_TimeTypeDef RTC_Time; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; WM_HWIN hWin; uint16_t PosDisplay; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0); break; case WM_DELETE: WM_DeleteTimer(hTimerTime); break; case WM_TIMER: if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME) { WM_InvalidateWindow(hWin); WM_RestartTimer(pMsg->Data.v, 1000); } break; case WM_PAINT: xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); PosDisplay = xSize; /* Draw background */ //GUI_SetColor(0x808080); //GUI_SetColor(0x742E1B); GUI_SetColor(0x000000); GUI_FillRect(0, 0, xSize - 1, ySize - 1); // status GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontHZ_Song_16); GUI_DispStringAt( (char *)StatusText, 4, 4); /* Draw time & Date */ GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(GUI_FONT_13B_ASCII); //time k_GetTime(&RTC_Time); sec = RTC_Time.Seconds; min = RTC_Time.Minutes; hour = RTC_Time.Hours; sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec); //sprintf((char *)TempStr, "%02d:%02d", hour , min); PosDisplay-=60; GUI_DispStringAt((char *)TempStr, PosDisplay, 0); //date k_GetDate(&RTC_DateStructure); year = RTC_DateStructure.Year + 2014; month = RTC_DateStructure.Month; day = RTC_DateStructure.Date; if((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900)) { sprintf((char *)TempStr, "%04d/%s/%02d", year, strMonth[month-1], day); } else { sprintf((char *)TempStr, "2014/01/01"); } PosDisplay-=10; GUI_DispStringAt((char *)TempStr, PosDisplay, 11); /* USB */ if(k_StorageGetStatus(USB_DISK_UNIT)) { PosDisplay-=35; GUI_DrawBitmap(&bmusbdisk, PosDisplay, 3); } /* MSD */ if(k_StorageGetStatus(MSD_DISK_UNIT)) { PosDisplay-=35; GUI_DrawBitmap(&bmmicrosd, PosDisplay, 3); } /* CPU */ sprintf((char *)TempStr, "%d %%", osGetCPUUsage()); if(osGetCPUUsage() > 95 ) { /* waiting for user input when using dialog box*/ sprintf((char *)TempStr, "95 %%"); } PosDisplay-=35; GUI_DispStringAt( (char *)TempStr, PosDisplay, 6); if(WT_Config.Print == 1 && PrintFile.print_status == 4)//本地打印Yes //print_status 0-stop 1-wait, 2-print ok, 3-print run, 4-print error { // WT_PrintFolder_Init(); // res=WT_PrintFiles_Init((char *)PrintFolder.FilesName[WT_Config.Print_ID]);//0-not init, 1-inited, 2-no files, 3-hardware error, 4-no folder // if(res != 1) wt_SetText_Status("打印文件错误"); wt_SetText_Status("打印文件错误"); } break; default: WM_DefaultProc(pMsg); } }
/** * @brief Callback routine of desktop window status. * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbStatus(WM_MESSAGE * pMsg) { int xSize, ySize; static uint8_t TempStr[50]; static WM_HTIMER hTimerTime; static WM_HTIMER hSpriteTime; RTC_TimeTypeDef RTC_Time; RTC_DateTypeDef RTC_DateStructure; uint8_t sec, min, hour, day, month; uint16_t year; WM_HWIN hWin; hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_CREATE: hTimerTime = WM_CreateTimer(hWin, ID_TIMER_TIME, 1000, 0); if(settings.b.enable_sprite) { hSpriteTime = WM_CreateTimer(hWin, ID_SPRITE_TIME, 50, 0); } break; case WM_DELETE: WM_DeleteTimer(hTimerTime); if(settings.b.enable_sprite) { WM_DeleteTimer(hSpriteTime); } break; case WM_TIMER: if( WM_GetTimerId(pMsg->Data.v) == ID_TIMER_TIME) { WM_InvalidateWindow(hWin); WM_RestartTimer(pMsg->Data.v, 1000); } else if( WM_GetTimerId(pMsg->Data.v) == ID_SPRITE_TIME) { if(settings.b.enable_sprite) { if(SpriteDisabled == 0) { _MoveSprite(&_aSprite[0]); } } WM_RestartTimer(pMsg->Data.v, 100); } break; case WM_PAINT: xSize = WM_GetWindowSizeX(hWin); ySize = WM_GetWindowSizeY(hWin); /* Draw background */ GUI_SetColor(0x40303030); GUI_FillRect(0, 0, xSize , ySize - 3); GUI_SetColor(0x808080); GUI_DrawHLine(ySize - 2, 0, xSize ); GUI_SetColor(0x404040); GUI_DrawHLine(ySize - 1, 0, xSize ); /* Draw time & Date */ GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_WHITE); GUI_SetFont(GUI_FONT_13B_ASCII); k_GetTime(&RTC_Time); sec = RTC_Time.Seconds; min = RTC_Time.Minutes; hour = RTC_Time.Hours; k_GetDate(&RTC_DateStructure); sprintf((char *)TempStr, "%02d:%02d:%02d", hour , min, sec); GUI_DispStringAt((char *)TempStr, xSize - 50, 4); year = RTC_DateStructure.Year + 2014; month = RTC_DateStructure.Month; day = RTC_DateStructure.Date; if((day > 0) && (day <= 31) && (month > 0)&& (month <= 12) && (year >= 1900)) { sprintf((char *)TempStr, "%02d, %s, %04d", day , strMonth[month-1], year); } else { sprintf((char *)TempStr, "01, January, 2014"); } GUI_DispStringHCenterAt((char *)TempStr, xSize / 2, 4); /* USB */ if(k_StorageGetStatus(USB_DISK_UNIT)) { GUI_DrawBitmap(&bmusbdisk, xSize - 80, 0); } /* MSD */ if(k_StorageGetStatus(MSD_DISK_UNIT)) { GUI_DrawBitmap(&bmmicrosd, xSize - 80 - 35 * k_StorageGetStatus(USB_DISK_UNIT) , 0); } sprintf((char *)TempStr, "CPU : %d %%", osGetCPUUsage()); if(osGetCPUUsage() > 95 ) { /* waiting for user input when using dialog box*/ sprintf((char *)TempStr, "CPU : 95 %%"); } GUI_DispStringAt( (char *)TempStr, 50, 4); break; default: WM_DefaultProc(pMsg); } }