Sample GUI for LPC4088. Base code to begin dev

Dependencies:   DMBasicGUI DMSupport

Fork of lpc4088_displaymodule_shipped_demo by Embedded Artists

Committer:
alindvall
Date:
Fri Mar 20 13:36:44 2015 +0000
Revision:
0:b94e330c98ac
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alindvall 0:b94e330c98ac 1 /*
alindvall 0:b94e330c98ac 2 * Copyright 2014 Embedded Artists AB
alindvall 0:b94e330c98ac 3 *
alindvall 0:b94e330c98ac 4 * Licensed under the Apache License, Version 2.0 (the "License");
alindvall 0:b94e330c98ac 5 * you may not use this file except in compliance with the License.
alindvall 0:b94e330c98ac 6 * You may obtain a copy of the License at
alindvall 0:b94e330c98ac 7 *
alindvall 0:b94e330c98ac 8 * http://www.apache.org/licenses/LICENSE-2.0
alindvall 0:b94e330c98ac 9 *
alindvall 0:b94e330c98ac 10 * Unless required by applicable law or agreed to in writing, software
alindvall 0:b94e330c98ac 11 * distributed under the License is distributed on an "AS IS" BASIS,
alindvall 0:b94e330c98ac 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
alindvall 0:b94e330c98ac 13 * See the License for the specific language governing permissions and
alindvall 0:b94e330c98ac 14 * limitations under the License.
alindvall 0:b94e330c98ac 15 */
alindvall 0:b94e330c98ac 16
alindvall 0:b94e330c98ac 17 #ifndef APP_IMAGEVIEWER_H
alindvall 0:b94e330c98ac 18 #define APP_IMAGEVIEWER_H
alindvall 0:b94e330c98ac 19
alindvall 0:b94e330c98ac 20 #include "App.h"
alindvall 0:b94e330c98ac 21 #include "DMBoard.h"
alindvall 0:b94e330c98ac 22 #include "lpc_swim.h"
alindvall 0:b94e330c98ac 23 #include "ImageButton.h"
alindvall 0:b94e330c98ac 24 #include "Image.h"
alindvall 0:b94e330c98ac 25 #include "Resource.h"
alindvall 0:b94e330c98ac 26
alindvall 0:b94e330c98ac 27 /**
alindvall 0:b94e330c98ac 28 * An App example. Searches for images on any connected media (USB Mass Storage,
alindvall 0:b94e330c98ac 29 * SD Card or QSPI File System) and presents the images one at a time, scaled to
alindvall 0:b94e330c98ac 30 * fit the display.
alindvall 0:b94e330c98ac 31 *
alindvall 0:b94e330c98ac 32 * The purpose of this example is to show how to recursively search the file
alindvall 0:b94e330c98ac 33 * systems and how to load images. The image scaling could be replaced with
alindvall 0:b94e330c98ac 34 * rotating, cropping or any other image operation. The two second delay between
alindvall 0:b94e330c98ac 35 * images could be replaced with buttons or other touch events.
alindvall 0:b94e330c98ac 36 */
alindvall 0:b94e330c98ac 37 class AppImageViewer : public App {
alindvall 0:b94e330c98ac 38 public:
alindvall 0:b94e330c98ac 39
alindvall 0:b94e330c98ac 40 AppImageViewer();
alindvall 0:b94e330c98ac 41 virtual ~AppImageViewer();
alindvall 0:b94e330c98ac 42
alindvall 0:b94e330c98ac 43 virtual bool setup();
alindvall 0:b94e330c98ac 44 virtual void runToCompletion();
alindvall 0:b94e330c98ac 45 virtual bool teardown();
alindvall 0:b94e330c98ac 46
alindvall 0:b94e330c98ac 47 void load(const char* file);
alindvall 0:b94e330c98ac 48
alindvall 0:b94e330c98ac 49 enum Resources {
alindvall 0:b94e330c98ac 50 Resource_Ok_button,
alindvall 0:b94e330c98ac 51 };
alindvall 0:b94e330c98ac 52
alindvall 0:b94e330c98ac 53 /** Specifies the resource to use
alindvall 0:b94e330c98ac 54 *
alindvall 0:b94e330c98ac 55 * Adds a resource for a specific id. This allows the
alindvall 0:b94e330c98ac 56 * user program to select e.g. which image to use and
alindvall 0:b94e330c98ac 57 * if it should be loaded from a file or an array.
alindvall 0:b94e330c98ac 58 *
alindvall 0:b94e330c98ac 59 * @param id the identifier
alindvall 0:b94e330c98ac 60 * @param res the resource
alindvall 0:b94e330c98ac 61 */
alindvall 0:b94e330c98ac 62 void addResource(Resources id, Resource* res);
alindvall 0:b94e330c98ac 63
alindvall 0:b94e330c98ac 64 private:
alindvall 0:b94e330c98ac 65 Display* _disp;
alindvall 0:b94e330c98ac 66 SWIM_WINDOW_T* _win;
alindvall 0:b94e330c98ac 67 void* _fb1;
alindvall 0:b94e330c98ac 68 void* _fb2;
alindvall 0:b94e330c98ac 69 ImageButton* _btn;
alindvall 0:b94e330c98ac 70 Mail<Image::ImageData_t, 2> _mailbox;
alindvall 0:b94e330c98ac 71 int _active;
alindvall 0:b94e330c98ac 72 int _next;
alindvall 0:b94e330c98ac 73 Mutex _allowedToRender;
alindvall 0:b94e330c98ac 74 Mutex _imageLoaded;
alindvall 0:b94e330c98ac 75 Resource* _resOk;
alindvall 0:b94e330c98ac 76
alindvall 0:b94e330c98ac 77 void draw();
alindvall 0:b94e330c98ac 78 };
alindvall 0:b94e330c98ac 79
alindvall 0:b94e330c98ac 80 #endif
alindvall 0:b94e330c98ac 81
alindvall 0:b94e330c98ac 82