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 AppNetworkSettings.h Source File

AppNetworkSettings.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_NETWORK_SETTINGS_H
00018 #define APP_NETWORK_SETTINGS_H
00019 
00020 #include "App.h"
00021 #include "DMBoard.h"
00022 #include "lpc_swim.h"
00023 #include "Button.h"
00024 #include "ImageButton.h"
00025 #include "DigitButton.h"
00026 #include "Resource.h"
00027 
00028 /**
00029  * An App example. Allows changing IP Address, Netmask and Gateway.
00030  *
00031  * The purpose of this example is to show some of the graphics primitives in
00032  * the SWIM library.
00033  */
00034 class AppNetworkSettings : public App {
00035 public:
00036 
00037     AppNetworkSettings();
00038     virtual ~AppNetworkSettings();
00039 
00040     virtual bool setup();
00041     virtual void runToCompletion();
00042     virtual bool teardown();
00043 
00044     void modifyValue(int mod);
00045     void changeActiveField(bool next);
00046     void setActiveField(uint32_t newField);
00047 
00048     enum Resources {
00049         Resource_Ok_button,
00050         Resource_Cancel_button,
00051         Resource_ArrowUp_button,
00052         Resource_ArrowDown_button,
00053         Resource_ArrowLeft_button,
00054         Resource_ArrowRight_button,
00055         Resource_Digits,
00056         NumResources,
00057     };
00058 
00059     /** Specifies the resource to use
00060      *
00061      *  Adds a resource for a specific id. This allows the
00062      *  user program to select e.g. which image to use and
00063      *  if it should be loaded from a file or an array.
00064      *
00065      *  @param id  the identifier
00066      *  @param res the resource
00067      */
00068     void addResource(Resources id, Resource* res);
00069 
00070 private:
00071     enum Buttons {
00072       ButtonIp0,
00073       ButtonIp1,
00074       ButtonIp2,
00075       ButtonIp3,
00076       ButtonMask0,
00077       ButtonMask1,
00078       ButtonMask2,
00079       ButtonMask3,
00080       ButtonGw0,
00081       ButtonGw1,
00082       ButtonGw2,
00083       ButtonGw3,
00084       ButtonOk,
00085       ButtonCancel,
00086       ButtonUp,
00087       ButtonDown,
00088       ButtonLeft,
00089       ButtonRight,
00090       NumButtons,
00091       NumFields = ButtonOk,
00092     };
00093 
00094     Display* _disp;
00095     SWIM_WINDOW_T* _win;
00096     void* _fb;
00097 
00098     Clickable* _buttons[NumButtons];
00099     
00100     uint32_t _activeField;
00101     uint32_t _values[NumFields];
00102     
00103     Image::ImageData_t _digitImage;
00104     
00105     Resource* _res[NumResources];
00106 
00107     void draw();
00108     void markField(int field, bool active);
00109     void addIPField(int y, int idx, const char* lbl);
00110 };
00111 
00112 #endif
00113 
00114