twobells 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {twobells-0.2.2/src/twobells.egg-info → twobells-0.3.0}/PKG-INFO +2 -2
- {twobells-0.2.2 → twobells-0.3.0}/README.md +1 -1
- {twobells-0.2.2 → twobells-0.3.0}/pyproject.toml +1 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/app.py +20 -6
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/panel.py +77 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/render.py +59 -24
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/sign.py +101 -35
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/view.py +74 -14
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/dev.py +1 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/setup.py +11 -10
- twobells-0.3.0/src/twobells/cli/timetable.py +96 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/__init__.py +1 -1
- twobells-0.3.0/src/twobells/core/bounded.py +120 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/walk.py +8 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/words.py +8 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/collector.py +113 -3
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/config.py +54 -4
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/snapshot.py +116 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/alerts.js +6 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/app.css +18 -3
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/board.js +177 -16
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/disruptions.js +10 -6
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/extras.js +9 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/header.js +2 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/hero.js +16 -8
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/index.html +12 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/main.js +11 -6
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/sheet.js +51 -6
- twobells-0.3.0/src/twobells/data/london_stops.csv +389 -0
- twobells-0.3.0/src/twobells/data/metrolink_stops.csv +106 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/fetch/handoff.py +4 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/config.py +137 -12
- twobells-0.3.0/src/twobells/settings/modes.py +168 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/schema.py +193 -15
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/api.py +166 -11
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/keytest.py +29 -4
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/lookups.py +132 -3
- twobells-0.3.0/src/twobells/sources/tfl.py +390 -0
- twobells-0.3.0/src/twobells/sources/trams.py +89 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/timetable/routesetup.py +18 -7
- twobells-0.3.0/src/twobells/timetable/trams.py +537 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/groupform.py +142 -27
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/keystate.py +4 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/overview.py +49 -4
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/places.py +7 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/status.py +1 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/web.css +2 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/finish.js +11 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/index.html +18 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/keys.js +12 -2
- twobells-0.3.0/src/twobells/wizard_static/presets.js +149 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/state.js +24 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/steps.js +8 -7
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/stops.js +19 -10
- twobells-0.3.0/src/twobells/wizard_static/trams.js +139 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/walk.js +5 -1
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/wizard.js +32 -0
- {twobells-0.2.2 → twobells-0.3.0/src/twobells.egg-info}/PKG-INFO +2 -2
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells.egg-info/SOURCES.txt +8 -0
- {twobells-0.2.2 → twobells-0.3.0}/tests/test_deploy.py +15 -5
- twobells-0.2.2/src/twobells/cli/timetable.py +0 -55
- twobells-0.2.2/src/twobells/wizard_static/presets.js +0 -79
- {twobells-0.2.2 → twobells-0.3.0}/LICENSE +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/setup.cfg +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/__main__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/displays/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/displays/display.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/displays/screen.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/displays/waveshare.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/dotfont.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/flaps.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/fonts/Inter-ExtraBold.ttf +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/fonts/Inter-Regular.ttf +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/fonts/LICENSE +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/fonts/SHA256SUMS +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/platformclock.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/positions.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/route.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/scroll.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/speaker.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/splitflap.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/state.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/tft.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/board/themes.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/common.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/main.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/run.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/cli/serve.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/announce.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/budget.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/calling.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/errors.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/files.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/model.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/net.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/osgb.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/polling.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/core/safexml.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/area.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/enrich.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/history.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/performance.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard/repay.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/api.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/area.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/dom.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/flap.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/fonts/DepartureboardDots.woff2 +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/fonts/LICENSE +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/fonts/SHA256SUMS +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/history.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/icons/apple-touch-icon.png +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/icons/icon-192.png +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/icons/icon-512.png +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/icons/icon.svg +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/icons.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/kiosk.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/live.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/look.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/manifest.webmanifest +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/map.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/measures.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/pa.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/performance.html +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/performance.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/platformclock.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/show.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/strip.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/theme.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/time.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/train.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/inter-4.1/InterVariable.woff2 +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/inter-4.1/LICENSE +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/inter-4.1/SHA256SUMS +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/LICENSE +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/SHA256SUMS +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet-src.esm.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/vendor/leaflet-1.9.4/leaflet.css +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/dashboard_static/weather.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/data/gb_stations.csv +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/data/naptan_area_grid.csv +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/emulator/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/emulator/emulation.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/emulator/emulator.html +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/emulator/fake.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/emulator/server.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/fetch/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/fetch/service.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/installs.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/keyresults.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/overlay.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/show.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/settings/store.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/discover.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/spool/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/spool/checks.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/spool/folder.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/spool/runner.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/setup/spool/worker.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/bods.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/bodsbus.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/darwin.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/disruptions.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/holidays.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/lastbus.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/livebus.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/transportapi.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/sources/weather.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/timetable/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/timetable/build.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/timetable/model.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/timetable/roads.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/version.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/__init__.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/auth.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/formpages.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/icons.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/keyspage.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/netguard.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/server.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/settings.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/settingsite.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/web/windowrows.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/api.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/home.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/maps.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/roads.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/say.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/station.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/views.js +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells/wizard_static/wizard.css +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells.egg-info/dependency_links.txt +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells.egg-info/entry_points.txt +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells.egg-info/requires.txt +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/src/twobells.egg-info/top_level.txt +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/tests/test_docs.py +0 -0
- {twobells-0.2.2 → twobells-0.3.0}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twobells
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop
|
|
5
5
|
Author: Albert Cornelissen
|
|
6
6
|
License-Expression: MIT
|
|
@@ -106,7 +106,7 @@ No config files to write. Give the setup wizard your postcode or address: it fin
|
|
|
106
106
|
|
|
107
107
|
Everything else is on the settings site, in plain words, behind one password:
|
|
108
108
|
|
|
109
|
-
<img width="49%" alt="The settings site's Dashboard page: how many trains and buses
|
|
109
|
+
<img width="49%" alt="The settings site's Dashboard page: which modes of transport it lists, how many trains and buses, and position strips on or off" src="docs/images/settings-dashboard.png">
|
|
110
110
|
|
|
111
111
|
## What it covers
|
|
112
112
|
|
|
@@ -72,7 +72,7 @@ No config files to write. Give the setup wizard your postcode or address: it fin
|
|
|
72
72
|
|
|
73
73
|
Everything else is on the settings site, in plain words, behind one password:
|
|
74
74
|
|
|
75
|
-
<img width="49%" alt="The settings site's Dashboard page: how many trains and buses
|
|
75
|
+
<img width="49%" alt="The settings site's Dashboard page: which modes of transport it lists, how many trains and buses, and position strips on or off" src="docs/images/settings-dashboard.png">
|
|
76
76
|
|
|
77
77
|
## What it covers
|
|
78
78
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "twobells"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Two Bells: know when to leave. Train and bus departures for Great Britain, on an e-paper or HDMI board on a Raspberry Pi and on a web dashboard, installed on a Pi, in Docker or on a desktop"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -159,6 +159,9 @@ class Board:
|
|
|
159
159
|
# Whether a screen scrolls text too long for its space (the scrolling
|
|
160
160
|
# setting); off, it cuts it short with "…", as e-paper always does.
|
|
161
161
|
scrolling: bool = True
|
|
162
|
+
# The modes it shows, a section each, in order ([board] modes,
|
|
163
|
+
# settings/modes.py); each has a source in `sources`.
|
|
164
|
+
modes: tuple[str, ...] = ("train", "bus")
|
|
162
165
|
|
|
163
166
|
|
|
164
167
|
def reset_code_page(folder: Path, timezone: str) -> Callable[[], CodeView | None]:
|
|
@@ -342,7 +345,7 @@ def _poll_vehicles(tracker: Tracker, state: dict, now: datetime) -> None:
|
|
|
342
345
|
def _route_view(board: Board, state: dict, view: BoardView, now: datetime, clock: str | None) -> RouteView | None:
|
|
343
346
|
"""The page for the next bus you can catch that has a route strip, if any."""
|
|
344
347
|
tracker = board.tracker
|
|
345
|
-
if tracker is None or not tracker.policy.is_active(now):
|
|
348
|
+
if tracker is None or "bus" not in board.modes or not tracker.policy.is_active(now):
|
|
346
349
|
return None
|
|
347
350
|
hhmm = now.strftime("%H:%M")
|
|
348
351
|
upcoming = [d for d in _departures(state, "bus", now) if not d.is_gone(hhmm)]
|
|
@@ -357,7 +360,7 @@ def _route_view(board: Board, state: dict, view: BoardView, now: datetime, clock
|
|
|
357
360
|
chosen = next((d for d in upcoming if catchable(d)), None)
|
|
358
361
|
if chosen is None:
|
|
359
362
|
return None
|
|
360
|
-
row = view.
|
|
363
|
+
row = view.section("bus").rows[upcoming.index(chosen)]
|
|
361
364
|
strip = tracker.routes[chosen.service]
|
|
362
365
|
entry = state.get("vehicles", {})
|
|
363
366
|
last_success = from_iso(entry.get("last_success"))
|
|
@@ -377,6 +380,17 @@ def _route_view(board: Board, state: dict, view: BoardView, now: datetime, clock
|
|
|
377
380
|
)
|
|
378
381
|
|
|
379
382
|
|
|
383
|
+
def _labels(board: Board) -> dict[str, tuple[str, str]]:
|
|
384
|
+
"""A section's own heading and empty words, by mode, where its source
|
|
385
|
+
has them: London's metro is "Underground", "DLR" and the like."""
|
|
386
|
+
found = {}
|
|
387
|
+
for config in board.sources:
|
|
388
|
+
label, empty = getattr(config.source, "label", None), getattr(config.source, "empty", None)
|
|
389
|
+
if isinstance(label, str) and isinstance(empty, str):
|
|
390
|
+
found[config.source.name] = (label, empty)
|
|
391
|
+
return found
|
|
392
|
+
|
|
393
|
+
|
|
380
394
|
def _stop_names(board: Board) -> dict[str, str]:
|
|
381
395
|
"""What a screen's bus rows call your stops, by label, from the bus
|
|
382
396
|
source's timetable (sources/bodsbus.py); none when it has none to give,
|
|
@@ -461,24 +475,24 @@ def run_once(
|
|
|
461
475
|
stale = {
|
|
462
476
|
c.source.name for c in board.sources if _is_stale(c, entries.get(c.source.name, {}), now)
|
|
463
477
|
}
|
|
464
|
-
|
|
478
|
+
departures = {mode: _departures(state, mode, now) for mode in board.modes}
|
|
465
479
|
view = build_view(
|
|
466
480
|
title=board.title,
|
|
467
|
-
|
|
468
|
-
buses=buses,
|
|
481
|
+
departures=departures,
|
|
469
482
|
now=now.strftime("%H:%M"),
|
|
470
483
|
stale=stale,
|
|
471
484
|
walk=board.walk,
|
|
472
485
|
wording=board.theme.wording,
|
|
473
486
|
clock=now.strftime("%H:%M:%S") if live else None,
|
|
474
487
|
notices=_notices(board, state, now),
|
|
475
|
-
rain=_rain(board, state,
|
|
488
|
+
rain=_rain(board, state, [d for found in departures.values() for d in found], now, live),
|
|
476
489
|
strips=strips,
|
|
477
490
|
# Only a screen wide enough draws them; e-paper never asks.
|
|
478
491
|
stop_names=_stop_names(board) if live else None,
|
|
479
492
|
last_bus=_last_bus(board, now) if live and "last_bus" in board.show else None,
|
|
480
493
|
show=board.show,
|
|
481
494
|
scroll=board.scrolling,
|
|
495
|
+
labels=_labels(board),
|
|
482
496
|
)
|
|
483
497
|
|
|
484
498
|
code = _reset_code(board)
|
|
@@ -82,3 +82,80 @@ HDMI_1280X400 = Panel.sized("hdmi-1280x400", 1280, 400, epaper=False)
|
|
|
82
82
|
HDMI_1920X440 = Panel("hdmi-1920x440", 1920, 440, scale=4, epaper=False)
|
|
83
83
|
|
|
84
84
|
PANELS = {p.name: p for p in (PHAT, PHAT_V1, WAVESHARE_10IN85G, HDMI_1280X400, HDMI_1920X440)}
|
|
85
|
+
|
|
86
|
+
# How many modes (settings/modes.py) each panel has room for, a section
|
|
87
|
+
# each, in any look: as many as keep every one of them at least one whole
|
|
88
|
+
# row in every look the panel has, at every text size the plain look offers.
|
|
89
|
+
# The type is sized to the panel's height, so it is height that counts, not
|
|
90
|
+
# inches. Each section takes a heading (the sign look: a dotted rule) as well
|
|
91
|
+
# as its rows.
|
|
92
|
+
#
|
|
93
|
+
# - The pHATs: 2. With 3, the plain look has room for 1 row each at the
|
|
94
|
+
# standard size and none for the third from text size 13 (122 rows); the
|
|
95
|
+
# original's 104 has none for it even at the standard size.
|
|
96
|
+
# - The 10.85" e-paper: 3. 160 pHAT rows in the plain look: 3 trains, 2 buses
|
|
97
|
+
# and 1 tram at the standard size, a row each at the biggest; the sign look
|
|
98
|
+
# (120 dots) 3, 1 and 1.
|
|
99
|
+
# - The 7.9" screen: 2. At 3 pixels a dot it is 133 tall, little more than the
|
|
100
|
+
# pHAT, and a screen's "Calling at" line takes a row: 1 row each at the
|
|
101
|
+
# standard size, none for the third mode from text size 13.
|
|
102
|
+
# - The 11.3" bar screen: 2. 146 rows in the plain look and 110 dots in the
|
|
103
|
+
# sign look: with the "Calling at" line, 2 trains, 1 bus and 1 tram at the
|
|
104
|
+
# standard size, and none for the third from text size 14.
|
|
105
|
+
#
|
|
106
|
+
# Trains and buses have always shared every display, so none has room for
|
|
107
|
+
# fewer than 2 (the original pHAT's biggest text cuts its last row short).
|
|
108
|
+
# tests/board/test_panel.py measures these against the looks' layouts.
|
|
109
|
+
MOST_MODES = {PHAT.name: 2, PHAT_V1.name: 2, WAVESHARE_10IN85G.name: 3, HDMI_1280X400.name: 2, HDMI_1920X440.name: 2}
|
|
110
|
+
|
|
111
|
+
# The HDMI screens have room for one mode more in the looks that keep it a
|
|
112
|
+
# whole row too: the station board look (its dots are fixed), the TFT and
|
|
113
|
+
# split-flap looks (drawn at the standard text size, 11), and the plain look
|
|
114
|
+
# up to the biggest text size that does, given here. Bigger than that, the
|
|
115
|
+
# plain look keeps MOST_MODES.
|
|
116
|
+
#
|
|
117
|
+
# - The 7.9" screen: up to 12, with a row each for 3 modes at 12 and 2 rows
|
|
118
|
+
# for the first two; at 13 the third has none.
|
|
119
|
+
# - The 11.3" bar screen: up to 13, a row each at 13; at 14 the third has none.
|
|
120
|
+
#
|
|
121
|
+
# The e-paper panels keep MOST_MODES whatever the look, so changing the look
|
|
122
|
+
# on e-paper never changes how many modes fit. tests/board/test_panel.py
|
|
123
|
+
# measures these too.
|
|
124
|
+
MORE_MODES_UP_TO = {HDMI_1280X400.name: 12, HDMI_1920X440.name: 13}
|
|
125
|
+
# What the settings call each panel, in a sentence: "The Inky pHAT has room for 2".
|
|
126
|
+
PANEL_NAMES = {
|
|
127
|
+
PHAT.name: "the Inky pHAT",
|
|
128
|
+
PHAT_V1.name: "the original Inky pHAT",
|
|
129
|
+
WAVESHARE_10IN85G.name: "the 10.85-inch e-paper panel",
|
|
130
|
+
HDMI_1280X400.name: "the 7.9-inch screen",
|
|
131
|
+
HDMI_1920X440.name: "the 11.3-inch bar screen",
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def most_modes(panel: Panel, look: str | None = None, text_size: int | None = None) -> int:
|
|
136
|
+
"""How many modes `panel` has room for: in any look (MOST_MODES), or,
|
|
137
|
+
given the `look` by name, in that look, with `text_size` the plain look's
|
|
138
|
+
text size (None: the standard). 2 for a panel of another size, as an Inky
|
|
139
|
+
the library detects can be."""
|
|
140
|
+
most = MOST_MODES.get(panel.name, 2)
|
|
141
|
+
biggest = MORE_MODES_UP_TO.get(panel.name)
|
|
142
|
+
if look is None or biggest is None:
|
|
143
|
+
return most
|
|
144
|
+
if look == "plain" and text_size is not None and text_size > biggest:
|
|
145
|
+
return most
|
|
146
|
+
return most + 1
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def biggest_text_for(panel: Panel, count: int) -> int | None:
|
|
150
|
+
"""The biggest plain-look text size at which `panel` has room for
|
|
151
|
+
`count` modes, where only some sizes do; None where every size does, or
|
|
152
|
+
none (most_modes says which)."""
|
|
153
|
+
biggest = MORE_MODES_UP_TO.get(panel.name)
|
|
154
|
+
if biggest is None or count <= MOST_MODES.get(panel.name, 2):
|
|
155
|
+
return None
|
|
156
|
+
return biggest
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def panel_name(panel: Panel) -> str:
|
|
160
|
+
"""The panel in words, for a sentence: "the Inky pHAT"."""
|
|
161
|
+
return PANEL_NAMES.get(panel.name, "this display")
|
|
@@ -19,6 +19,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
|
19
19
|
|
|
20
20
|
from ..core import words
|
|
21
21
|
from ..core.model import Strip
|
|
22
|
+
from ..settings import modes as mode_list
|
|
22
23
|
from .panel import (
|
|
23
24
|
NOTES_SIDE_BY_SIDE_MIN_WIDTH,
|
|
24
25
|
PHAT,
|
|
@@ -37,9 +38,6 @@ WIDTH, HEIGHT = PHAT.size
|
|
|
37
38
|
# Below the header, and either side of the rule between sections.
|
|
38
39
|
_SECTION_GAP = 6
|
|
39
40
|
PAD = 3
|
|
40
|
-
_MAX_ROWS = {"Trains": 3, "Buses": 2}
|
|
41
|
-
# A screen with the room (the bar screen) shows one more bus; e-paper keeps its two.
|
|
42
|
-
_SCREEN_MAX_BUSES = 3
|
|
43
41
|
# Beside a section's label when its feed has stopped, in the sign look's words.
|
|
44
42
|
_NOT_UPDATING = "! NOT UPDATING"
|
|
45
43
|
|
|
@@ -527,24 +525,54 @@ def calling_height(text_size: int = TEXT_SIZE) -> int:
|
|
|
527
525
|
def calling_line(section: Section, live: bool) -> str | None:
|
|
528
526
|
"""The first train's "Calling at" line, on a screen (`live`), which
|
|
529
527
|
scrolls it under the train's row; None on e-paper, which can't."""
|
|
530
|
-
if not live or section.
|
|
528
|
+
if not live or section.kind != "train" or not section.rows:
|
|
531
529
|
return None
|
|
532
530
|
return section.rows[0].calling
|
|
533
531
|
|
|
534
532
|
|
|
535
|
-
def
|
|
536
|
-
"""
|
|
537
|
-
|
|
538
|
-
|
|
533
|
+
def calling_section(sections: tuple[Section, ...], live: bool) -> str | None:
|
|
534
|
+
"""The mode whose first train has its "Calling at" line drawn under it:
|
|
535
|
+
the first section with one. A board has room for one."""
|
|
536
|
+
return next((section.mode for section in sections if calling_line(section, live)), None)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
def share_rows(rows: int, modes: tuple[str, ...], epaper: bool) -> dict[str, int]:
|
|
540
|
+
"""`rows` shared among the sections of `modes`, in order: a row each,
|
|
541
|
+
then each in turn as many more as it takes at most while it shares the
|
|
542
|
+
board (modes.Mode.most_rows), the first first. A mode alone takes them all."""
|
|
543
|
+
if len(modes) == 1:
|
|
544
|
+
return {modes[0]: rows}
|
|
545
|
+
shared = dict.fromkeys(modes, 1)
|
|
546
|
+
left = rows - len(modes)
|
|
547
|
+
for mode in modes:
|
|
548
|
+
more = max(0, min(mode_list.mode(mode).most_rows[0 if epaper else 1] - 1, left))
|
|
549
|
+
shared[mode] += more
|
|
550
|
+
left -= more
|
|
551
|
+
return shared
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
def row_limits(panel: Panel, text_size: int = TEXT_SIZE, calling: bool = False,
|
|
555
|
+
modes: tuple[str, ...] = ("train", "bus")) -> dict[str, int]:
|
|
556
|
+
"""Rows each mode's section shows: 3 trains and 2 buses on the pHAT's
|
|
557
|
+
122 rows, fewer on a shorter panel (the original pHAT has 104) or with
|
|
558
|
+
bigger text, rather than cut off; at least one each. `calling` makes
|
|
559
|
+
room for the "Calling at" line."""
|
|
560
|
+
if not modes:
|
|
561
|
+
return {}
|
|
562
|
+
rows = max(len(modes), rows_room(panel, len(modes), text_size, calling))
|
|
563
|
+
return share_rows(rows, modes, panel.epaper)
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
def rows_room(panel: Panel, sections: int, text_size: int = TEXT_SIZE, calling: bool = False) -> int:
|
|
567
|
+
"""How many whole rows fit on `panel` beside the header and `sections`
|
|
568
|
+
sections' labels, with the rule and its gaps between each two, and with
|
|
569
|
+
`calling` the "Calling at" line."""
|
|
539
570
|
s = plain_scale(panel)
|
|
540
571
|
header_h, label_h, row_h = heights(text_size)
|
|
541
|
-
fixed = header_h + _SECTION_GAP + label_h + 1
|
|
572
|
+
fixed = header_h + _SECTION_GAP + sections * label_h + (sections - 1) * (1 + _SECTION_GAP)
|
|
542
573
|
if calling:
|
|
543
574
|
fixed += calling_height(text_size)
|
|
544
|
-
|
|
545
|
-
most_buses = _MAX_ROWS["Buses"] if panel.epaper else _SCREEN_MAX_BUSES
|
|
546
|
-
buses = max(1, min(most_buses, rows - _MAX_ROWS["Trains"]))
|
|
547
|
-
return {"Trains": min(_MAX_ROWS["Trains"], rows - buses), "Buses": buses}
|
|
575
|
+
return (panel.height // s - fixed) // row_h
|
|
548
576
|
|
|
549
577
|
|
|
550
578
|
def header_rain(view: BoardView, fonts: Fonts, width: int, scale: int) -> tuple[str, float] | None:
|
|
@@ -612,6 +640,8 @@ class Painter:
|
|
|
612
640
|
self.s = plain_scale(panel)
|
|
613
641
|
self.text_size = text_size
|
|
614
642
|
self.limits = row_limits(panel, text_size)
|
|
643
|
+
# The mode whose first train's "Calling at" line is drawn, if any (calling_section).
|
|
644
|
+
self.calling_for: str | None = None
|
|
615
645
|
self.header_h, self.label_h, self.row_h = heights(text_size)
|
|
616
646
|
self.calling_h = calling_height(text_size)
|
|
617
647
|
# Smaller type sits on the same baseline as the row text.
|
|
@@ -673,7 +703,7 @@ class Painter:
|
|
|
673
703
|
self.text((stamp_x, s), stamp, self.f.regular, self.paper)
|
|
674
704
|
|
|
675
705
|
def drawn_rows(self, section: Section) -> tuple[Row, ...]:
|
|
676
|
-
return section.rows[: self.limits.get(section.
|
|
706
|
+
return section.rows[: self.limits.get(section.mode, 1)]
|
|
677
707
|
|
|
678
708
|
def section(self, section: Section, y: int, where_x: float | None = None) -> int:
|
|
679
709
|
s, pad = self.s, PAD * self.s
|
|
@@ -712,9 +742,9 @@ class Painter:
|
|
|
712
742
|
if not any(r.strip for r in rows):
|
|
713
743
|
where_x = None # no room kept for strips that none of them has
|
|
714
744
|
stop_room = stop_column(rows, section.stop_names, self.f, self.width, s, self.live)
|
|
715
|
-
calling = calling_line(section, self.live)
|
|
745
|
+
calling = calling_line(section, self.live) if section.mode == self.calling_for else None
|
|
716
746
|
for index, row in enumerate(rows):
|
|
717
|
-
self.row(row, y, platform_x, leave_x, where_x, train=section.
|
|
747
|
+
self.row(row, y, platform_x, leave_x, where_x, train=section.kind == "train", stop_room=stop_room)
|
|
718
748
|
y += self.row_h * s
|
|
719
749
|
if index == 0 and calling:
|
|
720
750
|
y = self.calling(calling, y)
|
|
@@ -797,16 +827,21 @@ def board_frame(view: BoardView, palette: Palette, panel: Panel = PHAT, text_siz
|
|
|
797
827
|
|
|
798
828
|
|
|
799
829
|
def paint_board(painter: Painter, view: BoardView, panel: Panel) -> Frame:
|
|
800
|
-
"""The board as `painter` draws it: the header,
|
|
830
|
+
"""The board as `painter` draws it: the header, then each mode's
|
|
831
|
+
section, a rule between each and the next."""
|
|
801
832
|
s = painter.s
|
|
802
|
-
|
|
803
|
-
|
|
833
|
+
painter.calling_for = calling_section(view.sections, painter.live)
|
|
834
|
+
painter.limits = row_limits(panel, painter.text_size, calling=painter.calling_for is not None,
|
|
835
|
+
modes=tuple(section.mode for section in view.sections))
|
|
804
836
|
painter.header(view)
|
|
805
|
-
|
|
806
|
-
where_x = where_column(
|
|
807
|
-
y =
|
|
808
|
-
|
|
809
|
-
|
|
837
|
+
drawn = [painter.drawn_rows(section) for section in view.sections]
|
|
838
|
+
where_x = where_column(drawn, painter.f, panel.width, s, painter.live)
|
|
839
|
+
y = (painter.header_h + _SECTION_GAP) * s
|
|
840
|
+
for index, section in enumerate(view.sections):
|
|
841
|
+
if index:
|
|
842
|
+
painter.rule(y + s)
|
|
843
|
+
y += (_SECTION_GAP + 1) * s
|
|
844
|
+
y = painter.section(section, y, where_x)
|
|
810
845
|
return painter.frame()
|
|
811
846
|
|
|
812
847
|
|
|
@@ -16,6 +16,7 @@ from dataclasses import dataclass, field, replace
|
|
|
16
16
|
from PIL import Image, ImageDraw
|
|
17
17
|
|
|
18
18
|
from ..core.model import Strip
|
|
19
|
+
from ..settings import modes as mode_list
|
|
19
20
|
from .dotfont import HEIGHT as GLYPH_H
|
|
20
21
|
from .dotfont import TINY, TINY_HEIGHT, DotFont
|
|
21
22
|
from .panel import (
|
|
@@ -43,7 +44,9 @@ _COL_GAP = 5
|
|
|
43
44
|
_FOOTER_GAP = 3
|
|
44
45
|
# Either side of the rain warning beside a notice, so the three read as three.
|
|
45
46
|
_NOTES_GAP = 2 * _COL_GAP
|
|
46
|
-
_ORDINALS = ("1st", "2nd", "3rd", "4th")
|
|
47
|
+
_ORDINALS = ("1st", "2nd", "3rd", "4th", "5th", "6th")
|
|
48
|
+
# The ordinals' column is as wide as a board of four trains needs.
|
|
49
|
+
_ORDINAL_W = "4th"
|
|
47
50
|
_MAX_TRAINS = 3
|
|
48
51
|
_FONT = DotFont()
|
|
49
52
|
_SMALL = DotFont(TINY)
|
|
@@ -165,10 +168,10 @@ class _Columns:
|
|
|
165
168
|
platform_x: float | None = None
|
|
166
169
|
|
|
167
170
|
|
|
168
|
-
def _train_columns(section: Section, width: int) -> _Columns:
|
|
171
|
+
def _train_columns(section: Section, width: int, most: int = _MAX_TRAINS) -> _Columns:
|
|
169
172
|
"""From the right, each column left-aligned clear of the widest one after
|
|
170
|
-
it, so it lines up."""
|
|
171
|
-
rows = section.rows[:
|
|
173
|
+
it, so it lines up, for the first `most` rows."""
|
|
174
|
+
rows = section.rows[:most]
|
|
172
175
|
if not rows:
|
|
173
176
|
return _Columns(width - MARGIN)
|
|
174
177
|
end = width - MARGIN - max(_w(r.right) for r in rows)
|
|
@@ -195,15 +198,20 @@ def _bus_columns(section: Section, width: int) -> _Columns:
|
|
|
195
198
|
return _Columns(leave_x, leave_x)
|
|
196
199
|
|
|
197
200
|
|
|
198
|
-
def
|
|
201
|
+
def _columns(section: Section, width: int, most: int) -> _Columns:
|
|
202
|
+
"""A section's columns, as its mode's rows are drawn (modes.Mode.rows)."""
|
|
203
|
+
return _train_columns(section, width, most) if section.kind == "train" else _bus_columns(section, width)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _where_column(view: BoardView, columns: list[_Columns], width: int) -> float | None:
|
|
199
207
|
"""Where the where words start, with the little lines after them: one
|
|
200
208
|
column down the board, clear of both sections' other columns. Only on a
|
|
201
209
|
screen wide enough: a strip changes every few seconds, so e-paper, which
|
|
202
210
|
redraws slowly and only on change, never shows one. It has a fixed width,
|
|
203
211
|
so it stays put as the words change."""
|
|
204
|
-
if view.clock is None or width < STRIP_COLUMN_MIN_WIDTH:
|
|
212
|
+
if view.clock is None or width < STRIP_COLUMN_MIN_WIDTH or not columns:
|
|
205
213
|
return None
|
|
206
|
-
return min(
|
|
214
|
+
return min(c.end for c in columns) - _COL_GAP - STRIP_WIDTH - _COL_GAP - where_width(width)
|
|
207
215
|
|
|
208
216
|
|
|
209
217
|
def _add_strip(layout: SignLayout, row: Row, where_x: float, y: int, width: int, train: bool, inverted: bool) -> None:
|
|
@@ -230,16 +238,19 @@ def _stop_column(section: Section, width: int, live: bool) -> int | None:
|
|
|
230
238
|
def calling_line(section: Section, live: bool) -> str | None:
|
|
231
239
|
"""The first train's "Calling at" line, on a screen (`live`), which
|
|
232
240
|
scrolls it under the train's row; None on e-paper, which can't."""
|
|
233
|
-
if not live or not section.rows:
|
|
241
|
+
if not live or section.kind != "train" or not section.rows:
|
|
234
242
|
return None
|
|
235
243
|
return section.rows[0].calling
|
|
236
244
|
|
|
237
245
|
|
|
238
246
|
def _trains(layout: SignLayout, section: Section, y: int, width: int, columns: _Columns,
|
|
239
|
-
where_x: float | None
|
|
240
|
-
|
|
247
|
+
where_x: float | None, most: int = _MAX_TRAINS, bottom: int | None = None,
|
|
248
|
+
calling: bool = True) -> int:
|
|
249
|
+
"""A train section's rows from `y`, the first `most`, while they fit
|
|
250
|
+
above `bottom`; with `calling`, the first one's "Calling at" line under it."""
|
|
251
|
+
time_x = MARGIN + _w(_ORDINAL_W) + _COL_GAP
|
|
241
252
|
dest_x = time_x + _w("00:00") + _COL_GAP
|
|
242
|
-
rows = section.rows[:
|
|
253
|
+
rows = section.rows[:most]
|
|
243
254
|
if not rows:
|
|
244
255
|
layout.add(MARGIN, y, section.empty_text)
|
|
245
256
|
return y + _LINE
|
|
@@ -247,6 +258,8 @@ def _trains(layout: SignLayout, section: Section, y: int, width: int, columns: _
|
|
|
247
258
|
where_x = None # no room kept for strips that none of them has
|
|
248
259
|
leave_for = section.leave_for or 0
|
|
249
260
|
for index, row in enumerate(rows):
|
|
261
|
+
if bottom is not None and index and y + GLYPH_H > bottom:
|
|
262
|
+
break
|
|
250
263
|
inverted = row.style is Style.INVERTED
|
|
251
264
|
status_x = _right(row.right, width)
|
|
252
265
|
if where_x is not None:
|
|
@@ -267,7 +280,7 @@ def _trains(layout: SignLayout, section: Section, y: int, width: int, columns: _
|
|
|
267
280
|
layout.add(columns.leave_x, y, section.leave, inverted)
|
|
268
281
|
layout.add(status_x, y, row.right, inverted)
|
|
269
282
|
y += _LINE
|
|
270
|
-
if index == 0 and calling_line(section, layout.live):
|
|
283
|
+
if index == 0 and calling and calling_line(section, layout.live):
|
|
271
284
|
# As on the real board: under the first train, where it calls, scrolling.
|
|
272
285
|
layout.fit(time_x, y, row.calling or "", width - MARGIN - time_x)
|
|
273
286
|
y += _LINE
|
|
@@ -279,8 +292,8 @@ def _trains(layout: SignLayout, section: Section, y: int, width: int, columns: _
|
|
|
279
292
|
|
|
280
293
|
|
|
281
294
|
def _buses(layout: SignLayout, section: Section, y: int, bottom: int, width: int, columns: _Columns,
|
|
282
|
-
where_x: float | None) -> int:
|
|
283
|
-
rows = list(section.rows)
|
|
295
|
+
where_x: float | None, most: int | None = None) -> int:
|
|
296
|
+
rows = list(section.rows[:most])
|
|
284
297
|
if not rows:
|
|
285
298
|
layout.add(MARGIN, y, section.empty_text)
|
|
286
299
|
return y + _LINE
|
|
@@ -321,7 +334,7 @@ def _buses(layout: SignLayout, section: Section, y: int, bottom: int, width: int
|
|
|
321
334
|
|
|
322
335
|
def _footer(layout: SignLayout, view: BoardView, width: int, height: int) -> None:
|
|
323
336
|
y = height - TINY_HEIGHT - 1
|
|
324
|
-
stale = [
|
|
337
|
+
stale = [mode_list.mode(s.mode).noun for s in view.sections if s.stale]
|
|
325
338
|
badge = "Not updating: " + ", ".join(stale) if stale else None
|
|
326
339
|
# Where the free part of the bottom line ends: before the badge, if there is one.
|
|
327
340
|
free_end = width - MARGIN
|
|
@@ -362,33 +375,86 @@ def _footer(layout: SignLayout, view: BoardView, width: int, height: int) -> Non
|
|
|
362
375
|
layout.add(width - MARGIN - _SMALL.getlength(badge), y, badge, inverted=True, small=True)
|
|
363
376
|
|
|
364
377
|
|
|
378
|
+
# From the top of a section's last line to the top of the next section's
|
|
379
|
+
# first: the line, then the dotted rule with its space either side.
|
|
380
|
+
_NEXT_SECTION = _LINE + _ABOVE_RULE - 2 + _BELOW_RULE
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def _most_rows(section: Section, alone: bool, epaper: bool) -> int:
|
|
384
|
+
"""The most rows a section draws: a train section 3 while it shares the
|
|
385
|
+
board, as many as there are ordinals alone; any other its mode's most
|
|
386
|
+
while it shares the board (modes.Mode.most_rows)."""
|
|
387
|
+
if section.kind == "train":
|
|
388
|
+
return len(_ORDINALS) if alone else _MAX_TRAINS
|
|
389
|
+
return mode_list.mode(section.mode).most_rows[0 if epaper else 1]
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _lines(section: Section, most: int, live: bool) -> int:
|
|
393
|
+
"""How many lines a section takes, drawn whole: its rows ("No buses" is
|
|
394
|
+
a line too), and a train's "Calling at" and leave lines."""
|
|
395
|
+
rows = max(1, min(most, len(section.rows)))
|
|
396
|
+
if section.kind != "train":
|
|
397
|
+
return rows
|
|
398
|
+
return rows + bool(calling_line(section, live)) + bool(section.leave and (section.leave_for or 0) < rows)
|
|
399
|
+
|
|
400
|
+
|
|
365
401
|
def sign_layout(view: BoardView, width: int = WIDTH, height: int = HEIGHT) -> SignLayout:
|
|
366
|
-
"""Places the text on a board `width` x `height` dots
|
|
402
|
+
"""Places the text on a board `width` x `height` dots: each mode's
|
|
403
|
+
section, a dotted rule between each and the next, and the bottom line.
|
|
404
|
+
Each section but the last draws its most rows (_most_rows), leaving the
|
|
405
|
+
sections after it a line each; the last has the rest of the room."""
|
|
367
406
|
layout = SignLayout(live=view.clock is not None, scroll=view.scroll)
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
407
|
+
sections = view.sections
|
|
408
|
+
alone = len(sections) == 1
|
|
409
|
+
epaper = view.clock is None
|
|
410
|
+
calling_for = next((s.mode for s in sections if calling_line(s, layout.live)), None)
|
|
411
|
+
columns = [_columns(s, width, _most_rows(s, alone, epaper)) for s in sections]
|
|
412
|
+
where_x = _where_column(view, columns, width)
|
|
373
413
|
footer_y = height - (GLYPH_H if view.clock else TINY_HEIGHT) - 1 # the bottom line's top
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
414
|
+
y = _TOP
|
|
415
|
+
for index, (section, cols) in enumerate(zip(sections, columns, strict=True)):
|
|
416
|
+
if index:
|
|
417
|
+
rule = y + _ABOVE_RULE - 2 # each line already carries 2 dots of leading
|
|
418
|
+
layout.rules.append(rule)
|
|
419
|
+
y = rule + _BELOW_RULE
|
|
420
|
+
calling = section.mode == calling_for
|
|
421
|
+
if index < len(sections) - 1:
|
|
422
|
+
# Room for a line of each section after it, above the bottom line.
|
|
423
|
+
bottom = footer_y - 2 - (len(sections) - 1 - index) * _NEXT_SECTION
|
|
424
|
+
most = _most_rows(section, alone, epaper)
|
|
425
|
+
if section.kind == "train":
|
|
426
|
+
y = _trains(layout, section, y, width, cols, where_x, most, bottom, calling)
|
|
427
|
+
else:
|
|
428
|
+
y = _buses(layout, section, y, bottom, width, cols, where_x, most)
|
|
429
|
+
continue
|
|
430
|
+
_last(layout, view, section, cols, y, footer_y, width, where_x, calling_for, alone, calling)
|
|
431
|
+
_footer(layout, view, width, height)
|
|
432
|
+
return layout
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _last(layout: SignLayout, view: BoardView, section: Section, columns: _Columns, top: int, footer_y: int,
|
|
436
|
+
width: int, where_x: float | None, calling_for: str | None, alone: bool, calling: bool) -> None:
|
|
437
|
+
"""The last section, from `top`, with all the room down to the bottom
|
|
438
|
+
line, and a rule over that line if there is room for it, as between
|
|
439
|
+
sections. A screen always has one, unless the "Calling at" line has
|
|
440
|
+
left it room for the rule or a bus, not both (the bar screen's third);
|
|
441
|
+
e-paper only when it costs no row, as it can on a full board."""
|
|
442
|
+
train = section.kind == "train"
|
|
443
|
+
most = _most_rows(section, alone, view.clock is None) if train else len(section.rows)
|
|
444
|
+
lines = _lines(section, most, layout.live) if train else max(1, len(section.rows))
|
|
445
|
+
without = min(lines, _rows_that_fit(top, footer_y - 2))
|
|
446
|
+
with_rule = min(lines, _rows_that_fit(top, footer_y - 2 * _FOOTER_GAP - 1))
|
|
447
|
+
screen_rule = view.clock is not None and calling_for is None
|
|
383
448
|
footer_rule = with_rule > 0 and (screen_rule or with_rule == without)
|
|
384
449
|
bottom = footer_y - 2 * _FOOTER_GAP - 1 if footer_rule else footer_y - 2
|
|
385
|
-
|
|
450
|
+
if train:
|
|
451
|
+
_trains(layout, section, top, width, columns, where_x, most, bottom, calling)
|
|
452
|
+
else:
|
|
453
|
+
_buses(layout, section, top, bottom, width, columns, where_x)
|
|
386
454
|
if footer_rule:
|
|
387
|
-
# Halfway between the last
|
|
388
|
-
last_bottom =
|
|
455
|
+
# Halfway between the last line and the bottom line, so the gaps match.
|
|
456
|
+
last_bottom = top + (with_rule - 1) * _LINE + GLYPH_H - 1
|
|
389
457
|
layout.rules.append(last_bottom + (footer_y - last_bottom) // 2)
|
|
390
|
-
_footer(layout, view, width, height)
|
|
391
|
-
return layout
|
|
392
458
|
|
|
393
459
|
|
|
394
460
|
def _rows_that_fit(top: int, bottom: int) -> int:
|