Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
TIME.hpp@30:4cde05cc7c4f, 2018-01-06 (annotated)
- Committer:
- thomasmorris
- Date:
- Sat Jan 06 17:43:17 2018 +0000
- Revision:
- 30:4cde05cc7c4f
- Child:
- 31:4a88bf97b53e
Latest Revision LCD time setting
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 30:4cde05cc7c4f | 1 | #ifndef _TIME_HPP_ //Known as header guards |
thomasmorris | 30:4cde05cc7c4f | 2 | #define _TIME_HPP_ |
thomasmorris | 30:4cde05cc7c4f | 3 | |
thomasmorris | 30:4cde05cc7c4f | 4 | #include "mbed.h" |
thomasmorris | 30:4cde05cc7c4f | 5 | #include "rtos.h" |
thomasmorris | 30:4cde05cc7c4f | 6 | int current_time_global = 0; |
thomasmorris | 30:4cde05cc7c4f | 7 | int new_time = 0; |
thomasmorris | 30:4cde05cc7c4f | 8 | int get_current_time() |
thomasmorris | 30:4cde05cc7c4f | 9 | { |
thomasmorris | 30:4cde05cc7c4f | 10 | |
thomasmorris | 30:4cde05cc7c4f | 11 | current_time_global = time(0); |
thomasmorris | 30:4cde05cc7c4f | 12 | return current_time_global; |
thomasmorris | 30:4cde05cc7c4f | 13 | } |
thomasmorris | 30:4cde05cc7c4f | 14 | //Time File |
thomasmorris | 30:4cde05cc7c4f | 15 | |
thomasmorris | 30:4cde05cc7c4f | 16 | //Seconds to Seconds |
thomasmorris | 30:4cde05cc7c4f | 17 | void Add_Second() |
thomasmorris | 30:4cde05cc7c4f | 18 | { |
thomasmorris | 30:4cde05cc7c4f | 19 | new_time = time(0) + 1; |
thomasmorris | 30:4cde05cc7c4f | 20 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 21 | } |
thomasmorris | 30:4cde05cc7c4f | 22 | void Subtract_Second() |
thomasmorris | 30:4cde05cc7c4f | 23 | { |
thomasmorris | 30:4cde05cc7c4f | 24 | new_time = time(0) - 1; |
thomasmorris | 30:4cde05cc7c4f | 25 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 26 | } |
thomasmorris | 30:4cde05cc7c4f | 27 | //Minutes to Seconds |
thomasmorris | 30:4cde05cc7c4f | 28 | void Add_Minute() |
thomasmorris | 30:4cde05cc7c4f | 29 | { |
thomasmorris | 30:4cde05cc7c4f | 30 | new_time = time(0) + 60; |
thomasmorris | 30:4cde05cc7c4f | 31 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 32 | } |
thomasmorris | 30:4cde05cc7c4f | 33 | void Subtract_Minute() |
thomasmorris | 30:4cde05cc7c4f | 34 | { |
thomasmorris | 30:4cde05cc7c4f | 35 | new_time = time(0) - 60; |
thomasmorris | 30:4cde05cc7c4f | 36 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 37 | } |
thomasmorris | 30:4cde05cc7c4f | 38 | //Hours to Seconds |
thomasmorris | 30:4cde05cc7c4f | 39 | void Add_hour() |
thomasmorris | 30:4cde05cc7c4f | 40 | { |
thomasmorris | 30:4cde05cc7c4f | 41 | new_time = time(0) + 3600; |
thomasmorris | 30:4cde05cc7c4f | 42 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 43 | } |
thomasmorris | 30:4cde05cc7c4f | 44 | void Subtract_hour() |
thomasmorris | 30:4cde05cc7c4f | 45 | { |
thomasmorris | 30:4cde05cc7c4f | 46 | new_time = time(0) - 3600; |
thomasmorris | 30:4cde05cc7c4f | 47 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 48 | } |
thomasmorris | 30:4cde05cc7c4f | 49 | //Days to Seconds |
thomasmorris | 30:4cde05cc7c4f | 50 | void Add_Day() |
thomasmorris | 30:4cde05cc7c4f | 51 | { |
thomasmorris | 30:4cde05cc7c4f | 52 | new_time = time(0) - 86400; |
thomasmorris | 30:4cde05cc7c4f | 53 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 54 | } |
thomasmorris | 30:4cde05cc7c4f | 55 | void Subtract_Day() |
thomasmorris | 30:4cde05cc7c4f | 56 | { |
thomasmorris | 30:4cde05cc7c4f | 57 | new_time = time(0) - 86400; |
thomasmorris | 30:4cde05cc7c4f | 58 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 59 | } |
thomasmorris | 30:4cde05cc7c4f | 60 | //Months to Seconds |
thomasmorris | 30:4cde05cc7c4f | 61 | void Add_Month() |
thomasmorris | 30:4cde05cc7c4f | 62 | { |
thomasmorris | 30:4cde05cc7c4f | 63 | new_time = time(0) + 2629743; |
thomasmorris | 30:4cde05cc7c4f | 64 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 65 | } |
thomasmorris | 30:4cde05cc7c4f | 66 | void Subtract_Month() |
thomasmorris | 30:4cde05cc7c4f | 67 | { |
thomasmorris | 30:4cde05cc7c4f | 68 | new_time = time(0) - 2629743; |
thomasmorris | 30:4cde05cc7c4f | 69 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 70 | } |
thomasmorris | 30:4cde05cc7c4f | 71 | //Years |
thomasmorris | 30:4cde05cc7c4f | 72 | void Add_Year() |
thomasmorris | 30:4cde05cc7c4f | 73 | { |
thomasmorris | 30:4cde05cc7c4f | 74 | new_time = time(0) + 31556926; |
thomasmorris | 30:4cde05cc7c4f | 75 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 76 | } |
thomasmorris | 30:4cde05cc7c4f | 77 | void Subtract_Year() |
thomasmorris | 30:4cde05cc7c4f | 78 | { |
thomasmorris | 30:4cde05cc7c4f | 79 | new_time = time(0) + 31556926; |
thomasmorris | 30:4cde05cc7c4f | 80 | set_time(new_time); |
thomasmorris | 30:4cde05cc7c4f | 81 | } |
thomasmorris | 30:4cde05cc7c4f | 82 | #endif |