Something went wrong. Try again.
Live STIB-MIVB departures on the Pebble Time 2. It covers the bus, tram, and metro network of Brussels
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154#pragma once
#include <pebble.h>
#define MAX_STOPS 12#define MAX_ROWS 12#define NAME_LEN 32#define ID_LEN 16#define LINE_LEN 8#define PLATFORM_LEN 8#define MAX_STRIP 8#define MAX_SHAPE_BYTES 48#define MAX_DEPARTURES 64#define MAX_INFO_ROWS 8
#define ROW_FLAG_DISRUPTED 1#define ROW_FLAG_END 2
typedef struct { char line[LINE_LEN]; uint8_t kind : 3; uint8_t flags : 2; GColor color; GColor text_color; char destination[NAME_LEN]; int16_t min1; int16_t min2; char platform[PLATFORM_LEN]; int16_t delay_seconds; int16_t w_dest; int16_t w_dest_bold;} Row;
typedef struct { char name[NAME_LEN]; uint8_t marker;} StripEntry;
typedef struct { char line[LINE_LEN]; uint8_t kind : 3; GColor color; GColor text_color; char destination[NAME_LEN]; int16_t min1; int16_t min2; char disruption[256]; uint8_t strip_count : 4; uint8_t strip_received : 4; StripEntry strip[MAX_STRIP]; uint8_t status : 2; uint8_t shape[MAX_SHAPE_BYTES]; uint8_t shape_len : 6; bool header_received : 1;} LineDetail;
typedef struct { char id[ID_LEN]; char name[NAME_LEN]; uint16_t distance_m; uint8_t row_count; int16_t w_name; int16_t bikes_mechanical; int16_t bikes_electrical; int16_t docks; Row rows[MAX_ROWS];} Stop;
typedef struct { uint8_t stop : 4; uint8_t row : 4;} DepartureRef;
typedef enum { ROW_SELECT_INERT, ROW_SELECT_LINE, ROW_SELECT_STATION, ROW_SELECT_STAND} RowSelect;
typedef enum { DEPARTURE_TRANSIT, DEPARTURE_TRAIN, DEPARTURE_VILLO} DepartureClass;
typedef struct { DepartureClass class; bool nearby; bool info; RowSelect select; bool alarm;} Departure;
typedef enum { STATE_LOADING, STATE_OK, STATE_GEO_ERROR, STATE_NET_ERROR, STATE_STALE, STATE_EMPTY, STATE_NO_PHONE} ModelState;
typedef enum { PAGE_TRANSIT, PAGE_TRAINS, PAGE_VILLO, PAGE_FAVORITES, PAGE_COUNT} Page;
#define STALE_THRESHOLD_S 45
typedef enum { STALENESS_NONE, STALENESS_NUDGE} StalenessAction;
void model_init(void);void model_deinit(void);void model_begin(Page page, uint8_t stop_count);Stop *model_staging_stop_at(uint8_t index);void model_staging_note(uint8_t index);bool model_commit(Page page);void model_note_request(Page page);Page model_requested_page(void);Stop *model_stop_at(Page page, uint8_t index);Stop *model_stop_by_id(Page page, const char *id);uint8_t model_stop_count(Page page);const Row *model_glance_row(void);void model_set_state(ModelState state);ModelState model_state(void);bool model_vibrate(void);uint8_t model_lang(void);void model_set_config(bool vibrate, uint8_t lang);Departure model_classify(const Row *row);uint8_t model_departures(Page page, DepartureRef *out, uint8_t max);void model_mark_dirty(Page page);uint8_t model_distinct_stops(const DepartureRef *refs, uint8_t count);LineDetail *model_line_detail(void);void model_line_begin(void);bool model_line_complete(void);void model_note_data_arrival(Page page, time_t now);bool model_stale(Page page, time_t now);StalenessAction model_staleness_action(time_t now, time_t last_data, bool connected, bool already_nudged);StalenessAction model_check_staleness(Page page, time_t now);WakeupId model_wakeup_id(void);void model_set_wakeup_id(WakeupId id);void model_set_wakeup_label(const char *stop_id, const char *line, uint8_t kind);const char *model_wakeup_stop_id(void);const char *model_wakeup_line(void);uint8_t model_wakeup_kind(void);