This is my second attempt at a train-arrival indicator. It uses a Particle Core and the associated web services to display arrival times as a gauge using a servo.
The device makes an http request to the server, which in turn fetches train arrival times from the nextbus api, using some configuration from the server.
For the TL;DR of the NextBus XML feed: https://gist.github.com/grantland/7cf4097dd9cdf0dfed14
The device makes an http request periodically to http://${SERVER}/times/${DEVICE_NAME}
The expected result is an http body with the number of minutes to the next train.
The time is then represented by the device in some way (in the simple case, a servo).
Server proxies requests for the device to the nextbus xml feed, and emits the
number of minutes until the next train. config.yml
has some configuration to
determine which bus/train stop data to fetch:
devicename:
:a: 'sf-muni'
:r: 'N'
:s: '8888'
:dir: 'inbound'
devicename is the key, and the hash below (with :
prefix on key names, so it
is symbolized properly) are arguments added to the nextbus xml feed request.
:dir
is not used by the nextbus api, but is used to filter between multiple
direction
tags present in api response. Matching is done with
String.include?
(after converting to all lowercase), so 'inbound' will match
'Inbound to Destination'.
- find bug with reading http body
- handle non-200 error codes gracefully.
- change servo delay based on angle delta
- unit tests
- Build muni train enclosure
- add LEDs for lighting up when time is running short.
- add selective activation, so it doesnt run all day/night.
- implement sleep mode to allow for battery operation.
- Allow multiple devices
- Configuration done by yaml