ArduinoLibs
|
00001 /* 00002 * Copyright (C) 2012 Southern Storm Software, Pty Ltd. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00019 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00020 * DEALINGS IN THE SOFTWARE. 00021 */ 00022 00023 #ifndef TimeField_h 00024 #define TimeField_h 00025 00026 #include "Field.h" 00027 00028 #define TIMEFIELD_READ_ONLY true 00029 #define TIMEFIELD_READ_WRITE false 00030 00031 class TimeField : public Field { 00032 public: 00033 explicit TimeField(const String &label); 00034 TimeField(Form &form, const String &label, int maxHours, bool readOnly); 00035 00036 int dispatch(int event); 00037 00038 void enterField(bool reverse); 00039 void exitField(); 00040 00041 unsigned long value() const { return _value; } 00042 void setValue(unsigned long value); 00043 00044 int maxHours() const { return _maxHours; } 00045 void setMaxHours(int maxHours) { _maxHours = maxHours; } 00046 00047 bool readOnly() const { return _readOnly; } 00048 void setReadOnly(bool value); 00049 00050 private: 00051 unsigned long _value; 00052 int _maxHours; 00053 int _printLen; 00054 bool _readOnly; 00055 uint8_t editField; 00056 00057 void printTime(); 00058 int printField(unsigned long value); 00059 }; 00060 00061 #endif