A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
SlideShow/SlideShow.h
- Committer:
- embeddedartists
- Date:
- 2014-12-21
- Revision:
- 5:f4de114c31c3
- Child:
- 13:bff2288c2c61
File content as of revision 5:f4de114c31c3:
#ifndef SLIDESHOW_H #define SLIDESHOW_H #include "mbed.h" #include "rtos.h" //#include "LcdController.h" #include "Image.h" #include "Renderer.h" /** */ class SlideShow { public: enum SlideShowError { Ok, InvalidScript, RuntimeError, UserAbort, ScriptEnd, OutOfMemory, FileError, }; typedef SlideShowError (*calloutFunc)(int calloutId, SlideShow* ss, int identifier); SlideShow(Renderer* r, /*LcdController::Config* screen,*/ const char* pathPrefix=NULL, uint8_t* bkg=NULL, int xoff=0, int yoff=0, int layer=0, Mutex* fileMutex=NULL); ~SlideShow(); SlideShowError prepare(const char* scriptFile); SlideShowError run(); void setCalloutHandler(calloutFunc func, int calloutId); void releaseScreen(void); void stop() { abortBeforeNextStep = true; } private: typedef uint16_t* image_t; class Transition { public: typedef enum { None, LeftRight, DownUp, TopDown, Blinds, Fade, Unknown, } Type; Transition(const char* typeStr) { if (typeStr == NULL) { t = Unknown; } else if (strcmp("none", typeStr) == 0) { t = None; } else if (strcmp("left-right", typeStr) == 0) { t = LeftRight; } else if (strcmp("down-up", typeStr) == 0) { t = DownUp; } else if (strcmp("top-down", typeStr) == 0) { t = TopDown; } else if (strcmp("blinds", typeStr) == 0) { t = Blinds; } else if (strcmp("fade", typeStr) == 0) { t = Fade; } else { t = Unknown; } }; ~Transition(); SlideShowError execute(SlideShow* ss, Image::ImageData_t* CurrentImage, Image::ImageData_t* NewImage); Type type() { return this->t; } const char* typeString() { switch(t) { case None: return "No"; case LeftRight: return "Left to Right"; case TopDown: return "Top to Bottom"; case Blinds: return "Blinds"; case Unknown: default: return "Unknown"; } }; private: Type t; enum Constants { LeftRight_DelayMs = 100, LeftRight_PixelsToSkip = 20, DownUp_DelayMs = 100, DownUp_LineSkip = 20, TopDown_DelayMs = 100, TopDown_LineSkip = 20, Blinds_LinesPerBlock = 8, Blinds_DelayMs = 20, Blinds_BeamColor = 0xffff, Blinds_BackColor = 0x0000, Fade_DelayMs = 80, }; }; class Command { public: typedef enum { Clear, Goto, LoadImage, Show, Wait, Callout, } Type; Command(Type cmd, int info=0, Transition* t=NULL, const char* filename=NULL, const char* prefix=NULL) { type = cmd; information = info; transition = t; if (filename == NULL) { fname = NULL; } else { fname = (char*)malloc(strlen(filename) + strlen(prefix) + 1); //+1 for null termination if (fname != NULL) { fname[0] = '\0'; strcat(fname, prefix); strcat(fname, filename); } } }; ~Command() { if (fname != NULL) { free(fname); fname = NULL; } }; void updateInfo(int newInfo) { information = newInfo; } int info() { return information; } void print(); SlideShowError handle(SlideShow* ss, int* seqIdx, int* lastTime); private: Type type; Transition* transition; int information; char* fname; }; typedef enum { Bmp, Raw } FileFormat; typedef struct { const char* pLabel; int index; } LabelInfo; enum { MaxNumPreparedImages = 100, } Constants; int screenWidth; int screenHeight; int screenPixels; int screenBytes; int drawXoff; int drawYoff; image_t ImageBackBuffer; Command** Sequence; int allocatedSequenceItems; int usedSequenceItems; const char* pathPrefix; int CurrentSlot; Image::ImageData_t PreparedImages[MaxNumPreparedImages]; Mutex* fileMutex; Renderer* rend; uint32_t rendHnd; int layer; calloutFunc callout; int calloutId; bool abortBeforeNextStep; // Utilities SlideShowError loadFile(const char* path, uint8_t** pData, uint32_t* pSize); // Parsing functions int getNextLine(char* pBuf, int* pOffset, char** ppLine); int splitLine(char* pLine, char** ppPart1, char** ppPart2, char** ppPart3); int findLabel(LabelInfo* pLabels, int numLabels, const char* pLabel); void freeSequence(void); SlideShowError expandSequence(); SlideShowError parseScript(char* pBuf); // Command related functions SlideShowError loadImage(const char* pFileName, int slot); void delay(int lastTime, int millis); SlideShowError runScript(); }; #endif