Add image helper functions

This commit is contained in:
Stefan `Sec` Zehl 2011-08-04 23:50:44 +02:00
parent eb8598ce48
commit f6ec40de2f
3 changed files with 55 additions and 0 deletions

View File

@ -9,6 +9,7 @@ OBJS += render.o
OBJS += decoder.o
OBJS += backlight.o
OBJS += print.o
OBJS += image.o
FONTS = $(basename $(wildcard fonts/*.c))

46
firmware/lcd/image.c Normal file
View File

@ -0,0 +1,46 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/display.h"
#include "filesystem/ff.h"
int lcdLoadImage(char *file) {
return readFile(file,(char *)lcdBuffer,RESX*RESY_B);
}
int lcdSaveImage(char *file) {
return writeFile(file,(char *)lcdBuffer,RESX*RESY_B);
}
uint8_t lcdShowAnim(char *fname, uint32_t framems) {
FIL file; /* File object */
int res;
UINT readbytes;
uint8_t state=0;
res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
if(res)
return 1;
getInputWaitRelease();
while(!getInputRaw()){
lcdFill(0x55);
res = f_read(&file, (char *)lcdBuffer, RESX*RESY_B, &readbytes);
if(res)
return -1;
if(readbytes<RESX*RESY_B){
f_lseek(&file,0);
continue;
};
lcdDisplay();
state=delayms_queue_plus(framems,0);
}
if(state)
work_queue();
return 0;
};

8
firmware/lcd/image.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef __DISPLAYIMG_H_
#define __DISPLAYIMG_H_
void lcdLoadImage(char *file);
void lcdSaveImage(char *file);
uint8_t lcdShowAnim(char *file, uint32_t framems);
#endif