Loading...
Searching...
No Matches
weather_reading.h
Go to the documentation of this file.
1
13#pragma once
14#include <stdbool.h>
15#include <stdint.h>
16#include <time.h>
17
18#include "wire/weather_wire.h"
19
24
26#define WEATHER_GROUP_CURRENT (1u << 0)
28#define WEATHER_GROUP_EXTRA (1u << 1)
30#define WEATHER_GROUP_FORECAST (1u << 2)
32#define WEATHER_GROUP_AIR (1u << 3)
33
42typedef struct
43{
44 uint8_t groups;
45 bool ok;
46 int temp;
47 const char *cond;
50 const char *wind_dir;
51 const char *cond_label;
52 int sunrise;
53 int sunset;
54 int uv;
61 const uint8_t *hourly;
62 uint16_t hourly_len;
63 const uint8_t *daily;
64 uint16_t daily_len;
66
73typedef struct
74{
75 uint8_t tag;
76 int16_t temp;
77 char cond[32];
78 char cond_label[20];
81 char wind_dir[4];
82 int16_t sunrise;
83 int16_t sunset;
84 int uv;
91 time_t forecast_day;
93 time_t hourly_first;
94 time_t daily_first;
96 time_t last_sync;
98
106typedef struct
107{
108 time_t now;
109 time_t day_start;
110 uint8_t hour;
111 uint8_t minute;
112 uint8_t second;
113 uint8_t wday;
115
135bool weather_reading_apply(WeatherState *state, const WeatherMessage *msg, const WeatherClock *clock);
136
147void weather_reading_convert(WeatherState *state, bool to_fahrenheit);
148
bool weather_reading_apply(WeatherState *state, const WeatherMessage *msg, const WeatherClock *clock)
Put a message's readings into the kept weather.
Definition weather_reading.c:46
void weather_reading_convert(WeatherState *state, bool to_fahrenheit)
Convert every temperature in the kept weather to the other unit.
Definition weather_reading.c:135
The watch's clock at the moment a message lands, broken apart.
Definition weather_reading.h:107
uint8_t second
The local second, 0 to 59.
Definition weather_reading.h:112
time_t day_start
Local midnight of today.
Definition weather_reading.h:109
uint8_t minute
The local minute, 0 to 59.
Definition weather_reading.h:111
uint8_t wday
The local weekday, 0 for Sunday.
Definition weather_reading.h:113
uint8_t hour
The local hour, 0 to 23.
Definition weather_reading.h:110
time_t now
The time the message landed.
Definition weather_reading.h:108
The 7-day strip. count is 0 until a reading lands.
Definition weather_wire.h:55
The hourly strip. count is 0 until a reading lands.
Definition weather_wire.h:46
One weather message as the transport read it, before anything is kept.
Definition weather_reading.h:43
int wind_kmh
Wind speed in km/h.
Definition weather_reading.h:49
int temp_min
Today's low.
Definition weather_reading.h:56
int precip_chance
Percent chance of rain.
Definition weather_reading.h:57
int temp_max
Today's high.
Definition weather_reading.h:55
uint16_t daily_len
Its length in bytes.
Definition weather_reading.h:64
int sunset
Sunset as minutes past local midnight.
Definition weather_reading.h:53
uint8_t groups
The WEATHER_GROUP_ bits for the groups that arrived.
Definition weather_reading.h:44
bool ok
The phone's fetch worked, so the current reading is real.
Definition weather_reading.h:45
int sunrise
Sunrise as minutes past local midnight.
Definition weather_reading.h:52
const char * wind_dir
Wind direction, such as "NW".
Definition weather_reading.h:50
int humidity
Percent humidity.
Definition weather_reading.h:48
const uint8_t * hourly
The packed hourly strip, or NULL when none arrived.
Definition weather_reading.h:61
uint16_t hourly_len
Its length in bytes.
Definition weather_reading.h:62
int temp
The temperature in the user's unit.
Definition weather_reading.h:46
int dew_point
Dew point temperature.
Definition weather_reading.h:60
int uv
UV index.
Definition weather_reading.h:54
int feels_like
How warm it feels.
Definition weather_reading.h:58
const char * cond_label
The sky in words, such as "Partly Cloudy", or NULL for a face with no key for it.
Definition weather_reading.h:51
int pressure
Sea level pressure in hPa.
Definition weather_reading.h:59
const char * cond
The sky word, such as "SUNNY".
Definition weather_reading.h:47
const uint8_t * daily
The packed daily strip, or NULL when none arrived.
Definition weather_reading.h:63
The weather a store keeps, laid out as the blob it saves to flash.
Definition weather_reading.h:74
WeatherDaily daily
The 7-day forecast strip (count 0 when none).
Definition weather_reading.h:95
time_t hourly_first
When the hourly strip's first column starts, or 0 when none came.
Definition weather_reading.h:93
int pressure
Sea level pressure in hPa (-1 when none).
Definition weather_reading.h:89
int temp_min
Today's low (WEATHER_NO_TEMP when none).
Definition weather_reading.h:86
int precip_chance
Percent chance of precip (-1 when none).
Definition weather_reading.h:87
int16_t sunrise
Sunrise as minutes past local midnight, -1 when none.
Definition weather_reading.h:82
int uv
UV index (-1 when none).
Definition weather_reading.h:84
int16_t sunset
Sunset as minutes past local midnight, -1 when none.
Definition weather_reading.h:83
WeatherHourly hourly
The hourly forecast strip (count 0 when none).
Definition weather_reading.h:92
int temp_max
Today's high (WEATHER_NO_TEMP when none).
Definition weather_reading.h:85
char cond[32]
Short word for the sky, such as "SUNNY".
Definition weather_reading.h:77
int dew_point
Dew point temperature (WEATHER_NO_TEMP when none).
Definition weather_reading.h:90
time_t last_sync
When the last reading landed, or 0 for never.
Definition weather_reading.h:96
time_t daily_first
Local midnight of the daily strip's first day, or 0 when none came.
Definition weather_reading.h:94
int humidity
Percent humidity, -1 when none.
Definition weather_reading.h:79
char wind_dir[4]
Wind direction like "NW".
Definition weather_reading.h:81
int wind_kmh
Wind speed in km/h, -1 when none.
Definition weather_reading.h:80
uint8_t tag
The store's tag, so a restore can tell this blob from another shape.
Definition weather_reading.h:75
int feels_like
Apparent temperature (WEATHER_NO_TEMP when none).
Definition weather_reading.h:88
int16_t temp
Current temperature in the user's unit (WEATHER_NO_TEMP when none).
Definition weather_reading.h:76
time_t forecast_day
Local midnight of the day the high, low, UV, and rain chance came, or 0.
Definition weather_reading.h:91
char cond_label[20]
The sky in words, such as "Partly Cloudy", empty when the phone sent none.
Definition weather_reading.h:78
The forecast strips as the phone packs them, and the readers that unpack them.