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 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 #include "Resource.h"
00026 
00027 /**
00028  * An App example. This uses a number of buttons to launch different Apps.
00029  *
00030  * The purpose of this example is to demonstrate how to manage a set of
00031  * Apps and launch them either as a result of clicked buttons or (in the 
00032  * case of the TouchCalibrationApp) after an extended press of the USER
00033  * button on the back of the display module.
00034  */
00035 class AppLauncherSpecial : public App {
00036 public:
00037 
00038     AppLauncherSpecial(int iconWidth=64, int iconHeight=64);
00039     virtual ~AppLauncherSpecial();
00040 
00041     enum CommonApplicationIDs {
00042         CalibrationApp = 0xffff,
00043     };
00044 
00045     virtual bool setup();
00046     virtual void runToCompletion();
00047     virtual bool teardown();
00048 
00049     void setAppCreatorFunc(App*(*callback)(uint32_t buttonID));
00050 
00051     bool addButton(uint32_t buttonID, const char* caption);
00052     bool addImageButton(uint32_t buttonID, const char* imgUp, const char* imgDown = 0);
00053     bool addImageButton(uint32_t buttonID, const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);
00054     bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, const char* imgUp, const char* imgDown = 0);
00055     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);
00056     bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, Resource* resUp, Resource* resDown = 0);
00057 
00058     enum Resources {
00059         Resource_Background,
00060     };
00061 
00062     /** Specifies the resource to use
00063      *
00064      *  Adds a resource for a specific id. This allows the
00065      *  user program to select e.g. which image to use and
00066      *  if it should be loaded from a file or an array.
00067      *
00068      *  @param id  the identifier
00069      *  @param res the resource
00070      */
00071     void addResource(Resources id, Resource* res);
00072     
00073 private:
00074     enum Constants {
00075        TitleHeight = 20,
00076        ButtonWidth = 75,
00077        ButtonHeight = 75,
00078        ButtonRows   = 2,
00079        ButtonColumns = 5,
00080        NumberOfButtons = ButtonRows*ButtonColumns,
00081     };
00082 
00083     Display* _disp;
00084     SWIM_WINDOW_T* _win;
00085     void* _fb;
00086     Clickable* _buttons[NumberOfButtons];
00087     int _usedButtons;
00088     App*(*_callback)(uint32_t buttonID);
00089     bool _supportsCalibration;
00090     bool _newTouchEvent;
00091     bool _newButtonEvent;
00092     Image::ImageData_t _bgImg;
00093     char _currentTime[30];
00094     Resource* _resBg;
00095     int _iconWidth;
00096     int _iconHeight;
00097 
00098     void draw();
00099     void onTouchEvent();
00100     void onButtonEvent();
00101 };
00102 
00103 #endif
00104 
00105