-
Notifications
You must be signed in to change notification settings - Fork 24
/
ClockShield.cpp
108 lines (90 loc) · 2.65 KB
/
ClockShield.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
Project: 1Sheeld Library
File: ClockShield.cpp
Version: 1.0
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2014.5
*/
#define FROM_ONESHEELD_LIBRARY
#include "OneSheeld.h"
#include "ClockShield.h"
//Class Constructor
ClockShield::ClockShield() : ShieldParent(CLOCK_ID)
{
hours=0;
minutes=0;
day=0;
month=0;
year=0;
}
//Blocking function
void ClockShield::queryDateAndTime()
{
OneSheeld.sendShieldFrame(CLOCK_ID,0,CLOCK_BEGIN,0);
}
//Seconds getter
byte ClockShield::getSeconds()
{
return seconds;
}
//Minutes getter
byte ClockShield::getMinutes()
{
return minutes;
}
//Hours getter
byte ClockShield::getHours()
{
return hours;
}
//Day getter
byte ClockShield::getDay()
{
return day;
}
//Month getter
byte ClockShield::getMonth()
{
return month;
}
//Year getter
short ClockShield::getYear()
{
return year;
}
//Clock Input Data Processing
void ClockShield::processData()
{
//Checking Function-ID
byte functionId=getOneSheeldInstance().getFunctionId();
if(functionId==CLOCK_DATE_VALUE)
{
byte argumentNumber=getOneSheeldInstance().getArgumentNo();
switch(argumentNumber)
{
case 0x01 : seconds=getOneSheeldInstance().getArgumentData(0)[0];break;
case 0x02 : seconds=getOneSheeldInstance().getArgumentData(0)[0];
minutes=getOneSheeldInstance().getArgumentData(1)[0];break;
case 0x03 : seconds=getOneSheeldInstance().getArgumentData(0)[0];
minutes=getOneSheeldInstance().getArgumentData(1)[0];
hours=getOneSheeldInstance().getArgumentData(2)[0];break;
case 0x04 : seconds=getOneSheeldInstance().getArgumentData(0)[0];
minutes=getOneSheeldInstance().getArgumentData(1)[0];
hours=getOneSheeldInstance().getArgumentData(2)[0];
day=getOneSheeldInstance().getArgumentData(3)[0];break;
case 0x05 : seconds=getOneSheeldInstance().getArgumentData(0)[0];
minutes=getOneSheeldInstance().getArgumentData(1)[0];
hours=getOneSheeldInstance().getArgumentData(2)[0];
day=getOneSheeldInstance().getArgumentData(3)[0];
month=getOneSheeldInstance().getArgumentData(4)[0];break;
case 0x06 : seconds=getOneSheeldInstance().getArgumentData(0)[0];
minutes=getOneSheeldInstance().getArgumentData(1)[0];
hours=getOneSheeldInstance().getArgumentData(2)[0];
day=getOneSheeldInstance().getArgumentData(3)[0];
month=getOneSheeldInstance().getArgumentData(4)[0];
year|=(short)getOneSheeldInstance().getArgumentData(5)[0];
year|=(short)(getOneSheeldInstance().getArgumentData(5)[1]<<8);break;
}
}
}