Update README.md

This commit is contained in:
iosullivan committed 2026-07-13 09:37:08 +10:00
1 parent 91fbcb1c8f
commit 65cd974ec9
1 file changed
+7 -6
+7 -6
View File
@@ -1,7 +1,7 @@
# CTA for ESP32 # CTA for ESP32
## Notes ## Notes
### CTA API interface ### CTA API interface
The CTA API can be fairly trivially queries to get a JSON response with the required metadata. The CTA API can be fairly trivially queried to get a JSON response with the required metadata.
- Docs are available here: https://www.transitchicago.com/developers/ttdocs/ - Docs are available here: https://www.transitchicago.com/developers/ttdocs/
- API consists of two main queries - API consists of two main queries
- 'Arrivals' - which lets you query all arrivals for a station available at https://lapi.transitchicago.com/api/1.0/ttarrivals.aspx - 'Arrivals' - which lets you query all arrivals for a station available at https://lapi.transitchicago.com/api/1.0/ttarrivals.aspx
@@ -48,7 +48,7 @@ The CTA API can be fairly trivially queries to get a JSON response with the requ
![Example Return](imgs/screenshot2.jpg) ![Example Return](imgs/screenshot2.jpg)
- The Locations API install returns all trains along a route. - The Locations API instead returns all trains along a route.
- In the above example, we have an array of all trains, starting at the top of the tree, we can pick each like you would in a folder. Some pseudocode: - In the above example, we have an array of all trains, starting at the top of the tree, we can pick each like you would in a folder. Some pseudocode:
- Say return json is output.json which = https://lapi.transitchicago.com/api/1.0/ttpositions.aspx?key=<KEYID>&rt=Blue&outputType=JSON - Say return json is output.json which = https://lapi.transitchicago.com/api/1.0/ttpositions.aspx?key=<KEYID>&rt=Blue&outputType=JSON
- `output->tmst` gives us the time we made this query, this is handy to find the current time. - `output->tmst` gives us the time we made this query, this is handy to find the current time.
@@ -64,11 +64,11 @@ The CTA API can be fairly trivially queries to get a JSON response with the requ
So example pseudocode: So example pseudocode:
``` ```
# Create a simple 2D array of all stations (imagine table with two columns) and when the next train arrives. Let's set arrival time to 999 for now (i.e. not any time soon). # Create a simple 2D array of all stations (imagine table with two columns) and when the next train arrives. Let's set arrival time to 2199-01-01 for now (i.e. not any time soon).
# We can use the station number instead of the name to keep code simpler (don't have to deal with spaces or symbols) # We can use the station number instead of the name to keep code simpler (don't have to deal with spaces or symbols)
stations_eta = <array> stations_eta = <array>
stations_eta[40380] = 999 stations_eta[40380] = 2199-01-01
stations_eta[40390] = 999 stations_eta[40390] = 2199-01-01
.... etc .... .... etc ....
# Get route data in JSON format # Get route data in JSON format
@@ -84,7 +84,8 @@ time_now = output->tmst
for train in output->ctatt->route->0->train: for train in output->ctatt->route->0->train:
# 'train' will now refer to the first train in the folder, aka 0. # 'train' will now refer to the first train in the folder, aka 0.
# So we can save the next stop of the train # So we can save the next stop of the train
next_stop = train->nextStaId statiom_eta[next_stop] = train->nextStaId
# The time of the next stop # The time of the next stop
time_to_stop = train->arrT time_to_stop = train->arrT
# Get the time difference. # Get the time difference.