-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path60ghzbreathheart.h
More file actions
executable file
·154 lines (121 loc) · 5.44 KB
/
Copy path60ghzbreathheart.h
File metadata and controls
executable file
·154 lines (121 loc) · 5.44 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef _60GHZBREATHHEART_H__
#define _60GHZBREATHHEART_H__
#define MESSAGE_HEAD1 0x53 //Data frame header1
#define MESSAGE_HEAD2 0x59 //Data frame header2
#define MESSAGE_END1 0x54 //End1 of data frame
#define MESSAGE_END2 0x43 //End2 of data frame
#define HUMAN_PSE_RADAR 0x80 //Human presence data
#define PRESENCE_INF 0x01 //Presence Information
#define SOMEONE_HERE 0x01 //Someone here
#define NOONE_HERE 0x00 //Noone here
#define MOVE_INF 0x02 //Campaign Information
#define PSE_NONE 0x00 //None
#define STATIONARY 0x01 //A person is stationary
#define MOVEMENT 0x02 //A person in motion
#define BODY_SIG 0x03 //Body movement information
#define DISTANCE 0x04 //Distance from the person being detected
#define DIRECTIONS 0x05 //Body orientation
#define HEART_INF 0x85 //Heart rate information
#define HEART_RATE 0x02 //Heart rate
#define HEART_RATE_WAVE 0x05 //Heart rate waveform (No analysis for now)
#define BREATH_RATE_RADAR 0x81 //Respiratory heart rate data
#define BREATH_INF 0x01 //Breathing data
#define BREATH_NORMAL 0x01 //Normal breathing
#define BREATH_RAPID 0x02 //Acute respiratory abnormalities
#define BREATH_SLOW 0x03 //Slow heartbeat
#define BREATH_NONE 0x04 //Radar detection nothing
#define BREATH_VAL 0x02 //Breathing values
#define BREATH_WAVE 0x05 //Respiratory waveform (No analysis for now)
#define SLEEP_INF 0x84 //Sleep information
#define INOUT_BED 0x01 //In bed or out of bed
#define OUT_BED 0x00 //Out of bed
#define IN_BED 0x01 //In bed
#define INOUT_NONE 0x02 //None (Display in real-time detection mode)
#define SLEEP_STATE 0x02 //Sleep state
#define DEEP_SLEEP 0x00 //Deep sleep
#define LIGHT_SLEEP 0x01 //Light sleep
#define AWAKE 0x02 //Awake
#define SLEEP_NONE 0x03 //None (Display in real-time detection mode)
#define AWAKE_TIME 0x03 //Awake time
#define LIGHTSLEEP_TIME 0x04 //Light sleep time
#define DEEPSLEEP_TIME 0x05 //Deep sleep time
#define SLEEP_SCORE 0x06 //Sleep quality score
#define SLEEP_STATUE 0x0C //Sleep integrated status reporte
#define SLEEP_QUALITY 0x0D //Comprehensive information reporting on sleep quality
#define SLEEP_ERROR 0x0E //Abnormal sleep reporte
#define SLEEP_LESS4H 0x00 //Sleep less than 4 hours
#define SLEEP_OVER12H 0x01 //Sleep over 12 hours
#define SLEEP_LONGTIMENOONE 0x02 //Unusual situation, no one for a long time
#define SLEEP_ERRORNONE 0x03 //None
#define reset_frame_len 10 //Reset data frame length
//Reset data frame
const unsigned char breath_reset_frame[10] = {0x53, 0x59, 0x01, 0x02, 0x00, 0x01, 0x0F, 0xBF, 0x54, 0x43};
#define mode_frame_len 10
const unsigned char realtime_mode_frame[10] = {0x53, 0x59, 0x84, 0x0F, 0x00, 0x01, 0x00, 0x40, 0x54, 0x43};
const unsigned char sleepstatus_mode_frame[10] = {0x53, 0x59, 0x84, 0x0F, 0x00, 0x01, 0x01, 0x41, 0x54, 0x43};
//Return status, Use in arduino
#define NOONE 0x01
#define SOMEONE 0x02
#define NONEPSE 0x03
#define STATION 0x04
#define MOVE 0x05
#define BODYVAL 0x06
#define DISVAL 0x07
#define DIREVAL 0x08
#define HEARTRATEVAL 0x09
#define HEARTRATEWAVE 0x10
#define BREATHNOR 0x11
#define BREATHRAPID 0x12
#define BREATHSLOW 0x13
#define BREATHNONE 0x14
#define BREATHVAL 0x15
#define BREATHWAVE 0x16
#define OUTBED 0x17
#define INBED 0x18
#define NOINOUT 0x19
#define SLEEPAWAKE 0x20
#define SLEEPLIGHT 0x21
#define SLEEPDEEP 0x22
#define SLEEPNONE 0x23
#define AWAKETIME 0x24
#define LIGHTTIME 0x25
#define DEEPTIME 0x26
#define SLEEPSCORE 0x27
#define SLEEPSTATUE 0x28
#define SLEEPQUALITY 0x29
#define SLEEPLESS4H 0x30
#define SLEEPOVER12H 0x31
#define LONGTIMENOONE 0x32
#define ERRORNONE 0x33
class BreathHeart_60GHz{
private:
Stream *stream; // e.g. SoftwareSerial or Serial1
boolean newData;
byte dataLen;
unsigned char Msg[20] = {0}; //Storage of the data frames returned by the radar up to a maximum length of 20.
int count = 0;
int checkdata_len = 2; //Without cyclic sending, number of frames sent
void data_printf(const unsigned char* buff, int len);
float Byte2Int(unsigned int x, unsigned int y);
void reset_val();
public:
unsigned int sensor_report = 0, bodysign_val = 0, awake_time = 0, light_time = 0, deep_time = 0, sleep_score = 0, turn_num = 0;
unsigned int heart_rate = 0, heart_point_1 = 0, heart_point_2 = 0, heart_point_3 = 0, heart_point_4 = 0, heart_point_5 = 0;
unsigned int breath_rate = 0, breath_point_1 = 0, breath_point_2 = 0, breath_point_3 = 0, breath_point_4 = 0, breath_point_5 = 0;
unsigned int substantial_move_ratio = 0, samll_move_ratio = 0, apnea_num = 0, sleep_status = 0, sleep_time = 0;
unsigned int awake_time_radio = 0, light_time_radio = 0, deep_time_radio = 0;
unsigned int outbed_time = 0, outbed_num = 0;
float distance = 0;
float Dir_x = 0, Dir_y = 0, Dir_z = 0;
boolean existence;
BreathHeart_60GHz(Stream *s);
void recvRadarBytes();
void Breath_Heart();
void HumanExis_Func();
void showData();
void SleepInf_Decode();
void send_func(const unsigned char* buff, int len, bool cyclic = false);
void reset_func();
void ModeSelect_fuc(int mode);
};
#endif