The out-of-the-box demo application flashed on all display modules before they are shipped.

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers <title>AppImageViewer.h Source File</title>

AppImageViewer.h

00001 /*
00002  *  Copyright 2014 Embedded Artists AB
00003  *
00004  *  Licensed under the Apache License, Version 2.0 (the "License");
00005  *  you may not use this file except in compliance with the License.
00006  *  You may obtain a copy of the License at
00007  *
00008  *    http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *  Unless required by applicable law or agreed to in writing, software
00011  *  distributed under the License is distributed on an "AS IS" BASIS,
00012  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *  See the License for the specific language governing permissions and
00014  *  limitations under the License.
00015  */
00016  
00017 #ifndef APP_IMAGEVIEWER_H
00018 #define APP_IMAGEVIEWER_H
00019 
00020 #include "App.h"
00021 #include "DMBoard.h"
00022 #include "lpc_swim.h"
00023 #include "ImageButton.h"
00024 #include "Image.h"
00025 #include "Resource.h"
00026 
00027 /**
00028  * An App example. Searches for images on any connected media (USB Mass Storage, 
00029  * SD Card or QSPI File System) and presents the images one at a time, scaled to
00030  * fit the display.
00031  *
00032  * The purpose of this example is to show how to recursively search the file
00033  * systems and how to load images. The image scaling could be replaced with 
00034  * rotating, cropping or any other image operation. The two second delay between
00035  * images could be replaced with buttons or other touch events.
00036  */
00037 class AppImageViewer : public App {
00038 public:
00039 
00040     AppImageViewer();
00041     virtual ~AppImageViewer();
00042 
00043     virtual bool setup();
00044     virtual void runToCompletion();
00045     virtual bool teardown();
00046 
00047     void load(const char* file);
00048 
00049     enum Resources {
00050         Resource_Ok_button,
00051     };
00052 
00053     /** Specifies the resource to use
00054      *
00055      *  Adds a resource for a specific id. This allows the
00056      *  user program to select e.g. which image to use and
00057      *  if it should be loaded from a file or an array.
00058      *
00059      *  @param id  the identifier
00060      *  @param res the resource
00061      */
00062     void addResource(Resources id, Resource* res);
00063 
00064 private:
00065     Display* _disp;
00066     SWIM_WINDOW_T* _win;
00067     void* _fb1;
00068     void* _fb2;
00069     ImageButton* _btn;
00070     Mail<Image::ImageData_t, 2> _mailbox;
00071     int _active;
00072     int _next;
00073     Mutex _allowedToRender;
00074     Mutex _imageLoaded;
00075     Resource* _resOk;
00076 
00077     void draw();
00078 };
00079 
00080 #endif
00081 
00082