-
Notifications
You must be signed in to change notification settings - Fork 1
/
messages.h
185 lines (150 loc) · 3.88 KB
/
messages.h
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <pico/stdlib.h>
// Messages destined at the animation task
typedef struct {
char time[6];
char condition[32];
double temperature;
double precipitation_probability;
} forecast_t;
#define NO_FORECASTS 3
typedef struct {
char name[16];
double temperature;
} inside_temperature_t;
#define NO_INSIDE_TEMPERATURES 10
typedef struct {
int fetched_fields;
char condition[32];
double temperature;
double humidty;
double wind_speed;
double wind_bearing;
double pressure;
double precipitation_probability;
int forecasts_count;
forecast_t forecasts[NO_FORECASTS];
int inside_temperatures_count;
inside_temperature_t inside_temperatures[NO_INSIDE_TEMPERATURES];
} weather_data_t;
#define FIELD_MPD_STATE (1<<0)
#define FIELD_MPD_MEDIA_TITLE (1<<2)
#define FIELD_MPD_MEDIA_ARTIST (1<<3)
#define FIELD_MPD_MEDIA_ALBUM_NAME (1<<4)
#define FIELD_MPD_ALL (FIELD_MPD_STATE | FIELD_MPD_MEDIA_TITLE | FIELD_MPD_MEDIA_ARTIST | \
FIELD_MPD_MEDIA_ALBUM_NAME)
typedef struct {
int fetched_fields;
char state[16];
char media_title[64];
char media_artist[64];
char media_album_name[64];
} media_player_data_t;
typedef struct {
char start[16];
char summary[256];
} appointment_t;
#define NO_APPOINTMENTS 3
typedef struct {
appointment_t appointments[NO_APPOINTMENTS];
} calendar_data_t;
#define NO_SCROLLERS 4
typedef struct {
int array_size;
char text[NO_SCROLLERS][256];
} scroller_data_t;
typedef struct {
char towards[16];
char departures_summary[64];
} journey_t;
#define NO_TRANSPORT_JOURNIES 2
typedef struct {
journey_t journies[NO_TRANSPORT_JOURNIES];
} transport_data_t;
typedef struct {
bool occupied;
} porch_t;
typedef struct {
char text[256];
} notification_t;
#define DS3231_DATETIME_LEN 7
typedef struct {
uint8_t datetime_buffer[DS3231_DATETIME_LEN];
} ds3231_t;
typedef struct {
float temperature;
#if BME680_PRESENT
float pressure;
float humidity;
#endif
} climate_t;
typedef struct {
int clock_colon_flash;
int clock_duration;
int inside_temperatures_scroll_speed;
int current_weather_duration;
int weather_forecast_duration;
int media_player_scroll_speed;
int calendar_scroll_speed;
int transport_duration;
int scroller_interval;
int scroller_speed;
int snowflake_count;
} configuration_t;
#define MESSAGE_ANIM_NULL 0
#define MESSAGE_ANIM_WEATHER 1
#define MESSAGE_ANIM_MEDIA_PLAYER 2
#define MESSAGE_ANIM_CALENDAR 3
#define MESSAGE_ANIM_SCROLLER 4
#define MESSAGE_ANIM_NOTIFICATION 5
#define MESSAGE_ANIM_TRANSPORT 6
#define MESSAGE_ANIM_PORCH 7
#define MESSAGE_ANIM_DS3231 8
#define MESSAGE_ANIM_BRIGHTNESS 9
#define MESSAGE_ANIM_GRAYSCALE 10
#define MESSAGE_ANIM_CONFIGURATION 100
typedef struct {
uint8_t message_type;
union {
weather_data_t weather_data;
media_player_data_t media_player_data;
calendar_data_t calendar_data;
scroller_data_t scroller_data;
transport_data_t transport_data;
porch_t porch;
notification_t notification;
ds3231_t ds3231;
uint8_t brightness;
bool grayscale;
configuration_t configuration;
};
} message_anim_t;
// Messages destined at I2C task
#define MESSAGE_DS3231_NULL 0
#define MESSAGE_DS3231_DS3231 1
typedef struct {
uint8_t message_type;
union {
ds3231_t ds3231;
};
} message_i2c_t;
// Messages destined at buzzer task
#define MESSAGE_BUZZER_NULL 0
#define MESSAGE_BUZZER_PLAY 1
#define BUZZER_PLAY_NULL 0
#define BUZZER_PLAY_NOTIFICATION 1
#define BUZZER_PLAY_PORCH 2
typedef struct {
uint8_t message_type;
union {
uint8_t play_type;
};
} message_buzzer_t;
// Messages destined at MQTT task
#define MESSAGE_MQTT_NULL 0
#define MESSAGE_MQTT_CLIMATE 1
typedef struct {
uint8_t message_type;
union {
climate_t climate;
};
} message_mqtt_t;