Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
1:a5258871b33d
Method ramp scrolling improved, and more bitmaps moved to QSPI memory

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 1:a5258871b33d 1 #ifndef NETWORKPARAMETERS_H
jmitc91516 1:a5258871b33d 2 #define NETWORKPARAMETERS_H
jmitc91516 1:a5258871b33d 3
jmitc91516 1:a5258871b33d 4 #include "EthernetInterface.h"
jmitc91516 1:a5258871b33d 5 #include "USBHostGC.h"
jmitc91516 1:a5258871b33d 6
jmitc91516 1:a5258871b33d 7 #include "GuiLib.h"
jmitc91516 1:a5258871b33d 8
jmitc91516 1:a5258871b33d 9
jmitc91516 1:a5258871b33d 10 /*
jmitc91516 1:a5258871b33d 11 A struct to relate the index of an easyGUI touch area on the 'EthernetParametersPage',
jmitc91516 1:a5258871b33d 12 with the easyGUI variable and our own internal variable to which it corresponds
jmitc91516 1:a5258871b33d 13 */
jmitc91516 1:a5258871b33d 14 typedef struct structNetworkParametersEasyGUITouchAreaAndVariables {
jmitc91516 1:a5258871b33d 15 int touchAreaIndex;
jmitc91516 1:a5258871b33d 16 GuiConst_TEXT * easyGUIVariablePtr;
jmitc91516 1:a5258871b33d 17 unsigned int * internalVariablePtr;
jmitc91516 1:a5258871b33d 18 unsigned int maxValue;
jmitc91516 1:a5258871b33d 19 GuiConst_INTCOLOR * easyGUIBackgroundColorVariablePtr;
jmitc91516 1:a5258871b33d 20 char variableName[41];
jmitc91516 1:a5258871b33d 21 } NetworkParametersEasyGUITouchAreaAndVariables;
jmitc91516 1:a5258871b33d 22
jmitc91516 1:a5258871b33d 23 /*
jmitc91516 1:a5258871b33d 24 This class handles the IP address, etc, to be used by the system. It deals with the user interface
jmitc91516 1:a5258871b33d 25 (i.e. the easyGUI 'EthernetParametersPage'), as well as storing the values in QSPI memory.
jmitc91516 1:a5258871b33d 26
jmitc91516 1:a5258871b33d 27 Note that this class is a singleton - we do not need or want there to be more than one instance of it
jmitc91516 1:a5258871b33d 28 (we do not want multiple values for the IP address, etc, and nor will we show
jmitc91516 1:a5258871b33d 29 more than one easyGUI 'EthernetParametersPage' to the user at the same time).
jmitc91516 1:a5258871b33d 30 */
jmitc91516 1:a5258871b33d 31 class NetworkParameters {
jmitc91516 1:a5258871b33d 32 public:
jmitc91516 1:a5258871b33d 33 /**
jmitc91516 1:a5258871b33d 34 * Static method to create (if necessary) and retrieve the single NetworkParameters instance
jmitc91516 1:a5258871b33d 35 */
jmitc91516 1:a5258871b33d 36 static NetworkParameters * GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC);
jmitc91516 1:a5258871b33d 37
jmitc91516 1:a5258871b33d 38 void GetPortNumberAsString(char *portBuffer);
jmitc91516 1:a5258871b33d 39 int GetPortNumber(void) { return portNumber; }
jmitc91516 1:a5258871b33d 40
jmitc91516 1:a5258871b33d 41 void GetIPAddressAsString(char *ipAddressBuffer);
jmitc91516 1:a5258871b33d 42 void SetIPAddressFromString(char *ipAddressBuffer);
jmitc91516 1:a5258871b33d 43
jmitc91516 1:a5258871b33d 44 void GetSubnetMaskAsString(char *subnetMaskBuffer);
jmitc91516 1:a5258871b33d 45 void SetSubnetMaskFromString(char *subnetMaskBuffer);
jmitc91516 1:a5258871b33d 46
jmitc91516 1:a5258871b33d 47 void GetGatewayAddressAsString(char *gatewayAddressBuffer);
jmitc91516 1:a5258871b33d 48 void SetGatewayAddressFromString(char *gatewayAddressBuffer);
jmitc91516 1:a5258871b33d 49
jmitc91516 1:a5258871b33d 50 bool GetUseDHCP(void) { return useDHCP; }
jmitc91516 1:a5258871b33d 51
jmitc91516 1:a5258871b33d 52 bool TouchAreaIsNetworkParameter(int touchAreaIndex);
jmitc91516 1:a5258871b33d 53
jmitc91516 1:a5258871b33d 54 bool DealWithTouch(int touchAreaIndex);
jmitc91516 1:a5258871b33d 55
jmitc91516 1:a5258871b33d 56 void DisplayingEasyGUIPage(bool updateEasyGUIVariables);
jmitc91516 1:a5258871b33d 57
jmitc91516 1:a5258871b33d 58 // Public so TouchCallback(main.cpp) can call it when this page is about to be displayed
jmitc91516 1:a5258871b33d 59 void RestoreRealValues(void);
jmitc91516 1:a5258871b33d 60
jmitc91516 1:a5258871b33d 61 void SaveRealValues(EthernetInterface *eth);
jmitc91516 1:a5258871b33d 62
jmitc91516 1:a5258871b33d 63 private:
jmitc91516 1:a5258871b33d 64 static NetworkParameters * theNetworkParametersInstance;
jmitc91516 1:a5258871b33d 65
jmitc91516 1:a5258871b33d 66 USBDeviceConnected* usbDevice;
jmitc91516 1:a5258871b33d 67 USBHostGC* usbHostGC;
jmitc91516 1:a5258871b33d 68
jmitc91516 1:a5258871b33d 69 static const GuiConst_INTCOLOR inactiveFieldBackgroundColour;
jmitc91516 1:a5258871b33d 70 static const GuiConst_INTCOLOR activeFieldBackgroundColour;
jmitc91516 1:a5258871b33d 71
jmitc91516 1:a5258871b33d 72 static const unsigned int defaultPortNumber;
jmitc91516 1:a5258871b33d 73 static const unsigned int defaultIPAddress[4];
jmitc91516 1:a5258871b33d 74 static const unsigned int defaultSubnetMask[4];
jmitc91516 1:a5258871b33d 75 static const unsigned int defaultGatewayAddress[4];
jmitc91516 1:a5258871b33d 76
jmitc91516 1:a5258871b33d 77
jmitc91516 1:a5258871b33d 78 // singleton class -> constructor is private
jmitc91516 1:a5258871b33d 79 NetworkParameters(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC);
jmitc91516 1:a5258871b33d 80 ~NetworkParameters();
jmitc91516 1:a5258871b33d 81
jmitc91516 1:a5258871b33d 82 unsigned int portNumber;
jmitc91516 1:a5258871b33d 83 unsigned int ipAddress[4];
jmitc91516 1:a5258871b33d 84 unsigned int subnetMask[4];
jmitc91516 1:a5258871b33d 85 unsigned int gatewayAddress[4];
jmitc91516 1:a5258871b33d 86
jmitc91516 1:a5258871b33d 87 // The parameter values we are actually using to talk to the world
jmitc91516 1:a5258871b33d 88 unsigned int realPortNumber;
jmitc91516 1:a5258871b33d 89 unsigned int realIPAddress[4];
jmitc91516 1:a5258871b33d 90 unsigned int realSubnetMask[4];
jmitc91516 1:a5258871b33d 91 unsigned int realGatewayAddress[4];
jmitc91516 1:a5258871b33d 92
jmitc91516 1:a5258871b33d 93 bool useDHCP;
jmitc91516 1:a5258871b33d 94
jmitc91516 1:a5258871b33d 95 enum { COUNT_OF_VARIABLES_FOR_TOUCH_AREAS = 13 };
jmitc91516 1:a5258871b33d 96 NetworkParametersEasyGUITouchAreaAndVariables variablesForTouchArea[COUNT_OF_VARIABLES_FOR_TOUCH_AREAS];
jmitc91516 1:a5258871b33d 97
jmitc91516 1:a5258871b33d 98 int indexOfVariablesCurrentlyBeingEdited;
jmitc91516 1:a5258871b33d 99
jmitc91516 1:a5258871b33d 100 void GetIPAddressFieldAsString(int fieldIndex, char *ipAddressBuffer, bool wantLeadingSpaces = true);
jmitc91516 1:a5258871b33d 101 void GetSubnetMaskFieldAsString(int fieldIndex, char *subnetMaskBuffer, bool wantLeadingSpaces = true);
jmitc91516 1:a5258871b33d 102 void GetGatewayAddressFieldAsString(int fieldIndex, char *gatewayAddressBuffer, bool wantLeadingSpaces = true);
jmitc91516 1:a5258871b33d 103
jmitc91516 1:a5258871b33d 104 void SetPortNumberFromString(char *portBuffer);
jmitc91516 1:a5258871b33d 105 void SetIPAddressFieldFromString(int fieldIndex, char *ipAddressBuffer);
jmitc91516 1:a5258871b33d 106 void SetSubnetMaskFieldFromString(int fieldIndex, char *subnetMaskBuffer);
jmitc91516 1:a5258871b33d 107 void SetGatewayAddressFieldFromString(int fieldIndex, char *gatewayAddressBuffer);
jmitc91516 1:a5258871b33d 108
jmitc91516 1:a5258871b33d 109 bool DealWithApplyButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 110 bool DealWithCancelButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 111 bool DealWithUseDHCPButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 112
jmitc91516 1:a5258871b33d 113 bool DealWithIPEditButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 114 bool DealWithMaskEditButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 115 bool DealWithGatewayEditButton(int touchAreaIndex);
jmitc91516 1:a5258871b33d 116
jmitc91516 1:a5258871b33d 117 void RestoreInitialValues(void);
jmitc91516 1:a5258871b33d 118
jmitc91516 1:a5258871b33d 119 void UpdateEasyGUIPage(void);
jmitc91516 1:a5258871b33d 120
jmitc91516 1:a5258871b33d 121 void SaveToQSPISettings(void);
jmitc91516 1:a5258871b33d 122 void ReadFromQSPISettings(void);
jmitc91516 1:a5258871b33d 123
jmitc91516 1:a5258871b33d 124 int GetIndexOfVariablesToEditForTouchArea(int touchAreaIndex);
jmitc91516 1:a5258871b33d 125
jmitc91516 1:a5258871b33d 126 void UpdateInternalValuesFromEasyGUIVariables(void);
jmitc91516 1:a5258871b33d 127 void UpdateEasyGUIVariablesFromInternalValues(void);
jmitc91516 1:a5258871b33d 128
jmitc91516 1:a5258871b33d 129 void SetAllFieldBackgroundColoursToInactive(void);
jmitc91516 1:a5258871b33d 130 void SetAllFieldBackgroundColoursToWhite(void);
jmitc91516 1:a5258871b33d 131
jmitc91516 1:a5258871b33d 132 };
jmitc91516 1:a5258871b33d 133
jmitc91516 1:a5258871b33d 134 #endif // NETWORKPARAMETERS_H
jmitc91516 1:a5258871b33d 135