Add image helper functions
This commit is contained in:
parent
eb8598ce48
commit
f6ec40de2f
|
@ -9,6 +9,7 @@ OBJS += render.o
|
|||
OBJS += decoder.o
|
||||
OBJS += backlight.o
|
||||
OBJS += print.o
|
||||
OBJS += image.o
|
||||
|
||||
FONTS = $(basename $(wildcard fonts/*.c))
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
@ -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
|
Loading…
Reference in New Issue