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 EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AppLauncher.h Source File

AppLauncher.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_LAUNCHER_H
00018 #define APP_LAUNCHER_H
00019 
00020 #include "App.h"
00021 #include "DMBoard.h"
00022 #include "lpc_swim.h"
00023 #include "Clickable.h"
00024 
00025 /**
00026  * An App example using a number of buttons to launch different Apps.
00027  *
00028  * The purpose of this example is to demonstrate how to manage a set of
00029  * Apps and launch them either as a result of clicked buttons or (in the 
00030  * case of the TouchCalibrationApp) after an extended press of the USER
00031  * button on the back of the display module.
00032  */
00033 class AppLauncher : public App {
00034 public:
00035 
00036     AppLauncher();
00037     virtual ~AppLauncher();
00038 
00039     enum CommonApplicationIDs {
00040         CalibrationApp = 0xffff,
00041     };
00042 
00043     virtual bool setup();
00044     virtual void runToCompletion();
00045     virtual bool teardown();
00046 
00047     void setAppCreatorFunc(App*(*callback)(uint32_t buttonID));
00048 
00049     bool addButton(uint32_t buttonID, const char* caption);
00050     bool addImageButton(uint32_t buttonID, const char* imgUp, const char* imgDown = 0);
00051     bool addImageButton(uint32_t buttonID, const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);
00052     bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, const char* imgUp, const char* imgDown = 0);
00053     bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);
00054 
00055 private:
00056     enum Constants {
00057        TitleHeight = 20,
00058        ButtonWidth = 75,
00059        ButtonHeight = 75,
00060        ButtonRows   = 2,
00061        ButtonColumns = 5,
00062        NumberOfButtons = ButtonRows*ButtonColumns,
00063     };
00064 
00065     Display* _disp;
00066     SWIM_WINDOW_T* _win;
00067     void* _fb;
00068     Clickable* _buttons[NumberOfButtons];
00069     int _usedButtons;
00070     App*(*_callback)(uint32_t buttonID);
00071     bool _supportsCalibration;
00072     bool _newTouchEvent;
00073     bool _newButtonEvent;
00074 
00075     void draw();
00076     void onTouchEvent();
00077     void onButtonEvent();
00078 };
00079 
00080 #endif