FINAL PROJECT isn't it

Fork of ELEC351 by Plymouth ELEC351 Group T

Committer:
thomasmorris
Date:
Sat Jan 06 23:04:05 2018 +0000
Revision:
31:4a88bf97b53e
Child:
33:3b5096f0126a
Working LCD set time

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 31:4a88bf97b53e 1 #include "TIME.hpp"
thomasmorris 31:4a88bf97b53e 2
thomasmorris 31:4a88bf97b53e 3
thomasmorris 31:4a88bf97b53e 4 using namespace std;
thomasmorris 31:4a88bf97b53e 5
thomasmorris 31:4a88bf97b53e 6 int current_time_global = 0;
thomasmorris 31:4a88bf97b53e 7 int new_time = 0;
thomasmorris 31:4a88bf97b53e 8
thomasmorris 31:4a88bf97b53e 9 int get_current_time() //Get Current Time
thomasmorris 31:4a88bf97b53e 10 {
thomasmorris 31:4a88bf97b53e 11 current_time_global = time(0);
thomasmorris 31:4a88bf97b53e 12 return current_time_global;
thomasmorris 31:4a88bf97b53e 13 }
thomasmorris 31:4a88bf97b53e 14
thomasmorris 31:4a88bf97b53e 15 void Add_Second() //Seconds to Seconds
thomasmorris 31:4a88bf97b53e 16 {
thomasmorris 31:4a88bf97b53e 17 new_time = time(0) + 1;
thomasmorris 31:4a88bf97b53e 18 set_time(new_time);
thomasmorris 31:4a88bf97b53e 19 }
thomasmorris 31:4a88bf97b53e 20
thomasmorris 31:4a88bf97b53e 21 void Subtract_Second()
thomasmorris 31:4a88bf97b53e 22 {
thomasmorris 31:4a88bf97b53e 23 new_time = time(0) - 1;
thomasmorris 31:4a88bf97b53e 24 set_time(new_time);
thomasmorris 31:4a88bf97b53e 25 }
thomasmorris 31:4a88bf97b53e 26
thomasmorris 31:4a88bf97b53e 27 void Add_Minute() //Minutes to Seconds
thomasmorris 31:4a88bf97b53e 28 {
thomasmorris 31:4a88bf97b53e 29 new_time = time(0) + 60;
thomasmorris 31:4a88bf97b53e 30 set_time(new_time);
thomasmorris 31:4a88bf97b53e 31 }
thomasmorris 31:4a88bf97b53e 32
thomasmorris 31:4a88bf97b53e 33 void Subtract_Minute()
thomasmorris 31:4a88bf97b53e 34 {
thomasmorris 31:4a88bf97b53e 35 new_time = time(0) - 60;
thomasmorris 31:4a88bf97b53e 36 set_time(new_time);
thomasmorris 31:4a88bf97b53e 37 }
thomasmorris 31:4a88bf97b53e 38
thomasmorris 31:4a88bf97b53e 39 void Add_Hour() //Hours to Seconds
thomasmorris 31:4a88bf97b53e 40 {
thomasmorris 31:4a88bf97b53e 41 new_time = time(0) + 3600;
thomasmorris 31:4a88bf97b53e 42 set_time(new_time);
thomasmorris 31:4a88bf97b53e 43 }
thomasmorris 31:4a88bf97b53e 44
thomasmorris 31:4a88bf97b53e 45 void Subtract_Hour()
thomasmorris 31:4a88bf97b53e 46 {
thomasmorris 31:4a88bf97b53e 47 new_time = time(0) - 3600;
thomasmorris 31:4a88bf97b53e 48 set_time(new_time);
thomasmorris 31:4a88bf97b53e 49 }
thomasmorris 31:4a88bf97b53e 50
thomasmorris 31:4a88bf97b53e 51 void Add_Day() //Days to Seconds
thomasmorris 31:4a88bf97b53e 52 {
thomasmorris 31:4a88bf97b53e 53 new_time = time(0) + 86400;
thomasmorris 31:4a88bf97b53e 54 set_time(new_time);
thomasmorris 31:4a88bf97b53e 55 }
thomasmorris 31:4a88bf97b53e 56
thomasmorris 31:4a88bf97b53e 57 void Subtract_Day()
thomasmorris 31:4a88bf97b53e 58 {
thomasmorris 31:4a88bf97b53e 59 new_time = time(0) - 86400;
thomasmorris 31:4a88bf97b53e 60 set_time(new_time);
thomasmorris 31:4a88bf97b53e 61 }
thomasmorris 31:4a88bf97b53e 62
thomasmorris 31:4a88bf97b53e 63 void Add_Month() //Months to Seconds
thomasmorris 31:4a88bf97b53e 64 {
thomasmorris 31:4a88bf97b53e 65 new_time = time(0) + 2629743;
thomasmorris 31:4a88bf97b53e 66 set_time(new_time);
thomasmorris 31:4a88bf97b53e 67 }
thomasmorris 31:4a88bf97b53e 68
thomasmorris 31:4a88bf97b53e 69 void Subtract_Month()
thomasmorris 31:4a88bf97b53e 70 {
thomasmorris 31:4a88bf97b53e 71 new_time = time(0) - 2629743;
thomasmorris 31:4a88bf97b53e 72 set_time(new_time);
thomasmorris 31:4a88bf97b53e 73 }
thomasmorris 31:4a88bf97b53e 74
thomasmorris 31:4a88bf97b53e 75 void Add_Year() //Years to Seconds
thomasmorris 31:4a88bf97b53e 76 {
thomasmorris 31:4a88bf97b53e 77 new_time = time(0) + 31556926;
thomasmorris 31:4a88bf97b53e 78 set_time(new_time);
thomasmorris 31:4a88bf97b53e 79 }
thomasmorris 31:4a88bf97b53e 80
thomasmorris 31:4a88bf97b53e 81 void Subtract_Year()
thomasmorris 31:4a88bf97b53e 82 {
thomasmorris 31:4a88bf97b53e 83 new_time = time(0) - 31556926;
thomasmorris 31:4a88bf97b53e 84 set_time(new_time);
thomasmorris 31:4a88bf97b53e 85 }
thomasmorris 31:4a88bf97b53e 86
thomasmorris 31:4a88bf97b53e 87 int LCD_Time_Get(string Unit)
thomasmorris 31:4a88bf97b53e 88 {
thomasmorris 31:4a88bf97b53e 89 int temp_months = 0;
thomasmorris 31:4a88bf97b53e 90 int temp_days = 0;
thomasmorris 31:4a88bf97b53e 91 int temp_hours = 0;
thomasmorris 31:4a88bf97b53e 92 int temp_minutes = 0;
thomasmorris 31:4a88bf97b53e 93 int temp_seconds = 0;
thomasmorris 31:4a88bf97b53e 94
thomasmorris 31:4a88bf97b53e 95 if(Unit == "Years")
thomasmorris 31:4a88bf97b53e 96 {
thomasmorris 31:4a88bf97b53e 97 int years = time(0) / year;
thomasmorris 31:4a88bf97b53e 98 return (1970 + years);
thomasmorris 31:4a88bf97b53e 99 }
thomasmorris 31:4a88bf97b53e 100 else if(Unit == "Months")
thomasmorris 31:4a88bf97b53e 101 {
thomasmorris 31:4a88bf97b53e 102 int temp_months = time(0) / month;
thomasmorris 31:4a88bf97b53e 103 int months = (temp_months % 12);
thomasmorris 31:4a88bf97b53e 104 return (months + 1);
thomasmorris 31:4a88bf97b53e 105 }
thomasmorris 31:4a88bf97b53e 106 else if(Unit == "Days")
thomasmorris 31:4a88bf97b53e 107 {
thomasmorris 31:4a88bf97b53e 108 int temp_days = time(0) / day;
thomasmorris 31:4a88bf97b53e 109 int days = fmod(temp_days,Days_In_Month);
thomasmorris 31:4a88bf97b53e 110 return (days + 1);
thomasmorris 31:4a88bf97b53e 111 }
thomasmorris 31:4a88bf97b53e 112 else if(Unit == "Hours")
thomasmorris 31:4a88bf97b53e 113 {
thomasmorris 31:4a88bf97b53e 114 int temp_hours = time(0) / hour;
thomasmorris 31:4a88bf97b53e 115 int hours = temp_hours % 24;
thomasmorris 31:4a88bf97b53e 116 return hours;
thomasmorris 31:4a88bf97b53e 117 }
thomasmorris 31:4a88bf97b53e 118 else if(Unit == "Minutes")
thomasmorris 31:4a88bf97b53e 119 {
thomasmorris 31:4a88bf97b53e 120 int temp_minutes = time(0) / minute;
thomasmorris 31:4a88bf97b53e 121 int minutes = temp_minutes % 60;
thomasmorris 31:4a88bf97b53e 122 return minutes;
thomasmorris 31:4a88bf97b53e 123 }
thomasmorris 31:4a88bf97b53e 124 else if(Unit == "Seconds")
thomasmorris 31:4a88bf97b53e 125 {
thomasmorris 31:4a88bf97b53e 126 int temp_seconds = time(0) / second;
thomasmorris 31:4a88bf97b53e 127 int seconds = temp_seconds % 60;
thomasmorris 31:4a88bf97b53e 128 return seconds;
thomasmorris 31:4a88bf97b53e 129 }
thomasmorris 31:4a88bf97b53e 130 else
thomasmorris 31:4a88bf97b53e 131 {
thomasmorris 31:4a88bf97b53e 132 cout << "Wrong Input Passed to LCD Time Function" << endl;
thomasmorris 31:4a88bf97b53e 133 }
thomasmorris 31:4a88bf97b53e 134 }
thomasmorris 31:4a88bf97b53e 135