Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
src/ConfigurationHandler/Controls/TimerControl.h@133:c871de2d2b90, 2016-09-27 (annotated)
- Committer:
- jmarkel44
- Date:
- Tue Sep 27 15:28:59 2016 +0000
- Revision:
- 133:c871de2d2b90
- Parent:
- 132:45821e189dd0
- Child:
- 136:6ad7ba157b70
timer controls working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmarkel44 | 12:ea87887ca7ad | 1 | /****************************************************************************** |
jmarkel44 | 12:ea87887ca7ad | 2 | * |
jmarkel44 | 12:ea87887ca7ad | 3 | * File: TimerControl.h |
jmarkel44 | 12:ea87887ca7ad | 4 | * Desciption: ICE Timer Control Class |
jmarkel44 | 12:ea87887ca7ad | 5 | * |
jmarkel44 | 12:ea87887ca7ad | 6 | *****************************************************************************/ |
jmarkel44 | 12:ea87887ca7ad | 7 | #ifndef TIMERCONTROL_H |
jmarkel44 | 12:ea87887ca7ad | 8 | #define TIMERCONTROL_H |
jmarkel44 | 12:ea87887ca7ad | 9 | |
jmarkel44 | 12:ea87887ca7ad | 10 | #include <string> |
jmarkel44 | 122:4db48b933115 | 11 | #include <stdio.h> |
jmarkel44 | 132:45821e189dd0 | 12 | #include <vector> |
jmarkel44 | 19:9bc8fabeddfa | 13 | |
jmarkel44 | 12:ea87887ca7ad | 14 | class TimerControl |
jmarkel44 | 12:ea87887ca7ad | 15 | { |
jmarkel44 | 12:ea87887ca7ad | 16 | private: |
jmarkel44 | 122:4db48b933115 | 17 | std::string controlFile; |
jmarkel44 | 122:4db48b933115 | 18 | std::string id; |
jmarkel44 | 122:4db48b933115 | 19 | std::string output; |
jmarkel44 | 132:45821e189dd0 | 20 | |
jmarkel44 | 128:534bf29132f8 | 21 | enum State { |
jmarkel44 | 128:534bf29132f8 | 22 | STATE_OFF, |
jmarkel44 | 128:534bf29132f8 | 23 | STATE_RUNNING, |
jmarkel44 | 128:534bf29132f8 | 24 | STATE_DISABLED |
jmarkel44 | 128:534bf29132f8 | 25 | }; |
jmarkel44 | 128:534bf29132f8 | 26 | State currentState; |
jmarkel44 | 132:45821e189dd0 | 27 | |
jmarkel44 | 132:45821e189dd0 | 28 | typedef struct { |
jmarkel44 | 132:45821e189dd0 | 29 | unsigned int priority; // uniqueness to each timer element |
jmarkel44 | 132:45821e189dd0 | 30 | unsigned long startTime; // epoch time |
jmarkel44 | 132:45821e189dd0 | 31 | unsigned int duration; // in seconds |
jmarkel44 | 132:45821e189dd0 | 32 | unsigned long actualStarTime; |
jmarkel44 | 132:45821e189dd0 | 33 | } Schedule_t; |
jmarkel44 | 132:45821e189dd0 | 34 | |
jmarkel44 | 132:45821e189dd0 | 35 | std::vector<Schedule_t> schedule; |
jmarkel44 | 132:45821e189dd0 | 36 | unsigned long actualStartTime; |
jmarkel44 | 128:534bf29132f8 | 37 | |
jmarkel44 | 12:ea87887ca7ad | 38 | public: |
jmarkel44 | 19:9bc8fabeddfa | 39 | TimerControl() {}; |
jmarkel44 | 12:ea87887ca7ad | 40 | ~TimerControl() { |
jmarkel44 | 12:ea87887ca7ad | 41 | printf("\r%s destructor invoked\n", __func__); |
jmarkel44 | 12:ea87887ca7ad | 42 | } |
jmarkel44 | 20:653923c2f37a | 43 | // load a control from the control file |
jmarkel44 | 122:4db48b933115 | 44 | bool load(std::string filename); |
jmarkel44 | 128:534bf29132f8 | 45 | |
jmarkel44 | 122:4db48b933115 | 46 | void display(void); |
jmarkel44 | 128:534bf29132f8 | 47 | |
jmarkel44 | 122:4db48b933115 | 48 | std::string getControlFile(void) { |
jmarkel44 | 12:ea87887ca7ad | 49 | return controlFile; |
jmarkel44 | 12:ea87887ca7ad | 50 | } |
jmarkel44 | 128:534bf29132f8 | 51 | |
jmarkel44 | 132:45821e189dd0 | 52 | bool timerStart(void); |
jmarkel44 | 132:45821e189dd0 | 53 | bool timerStop(void); |
jmarkel44 | 126:c85ac6a8e9af | 54 | |
jmarkel44 | 133:c871de2d2b90 | 55 | void startFeed(void); |
jmarkel44 | 133:c871de2d2b90 | 56 | void stopFeed(void); |
jmarkel44 | 133:c871de2d2b90 | 57 | |
jmarkel44 | 126:c85ac6a8e9af | 58 | void start(void); |
jmarkel44 | 126:c85ac6a8e9af | 59 | void update(void); |
jmarkel44 | 128:534bf29132f8 | 60 | |
jmarkel44 | 128:534bf29132f8 | 61 | State getCurrentState(void) const { |
jmarkel44 | 128:534bf29132f8 | 62 | return currentState; |
jmarkel44 | 128:534bf29132f8 | 63 | } |
jmarkel44 | 12:ea87887ca7ad | 64 | }; |
jmarkel44 | 12:ea87887ca7ad | 65 | |
jmarkel44 | 12:ea87887ca7ad | 66 | #endif |