Demo for Embedded World 2015.

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AppLauncherSpecial.h Source File

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