blinkenxmas.routes

The blinkenxmas.routes module defines all the dynamically generated routes registered with the HTTP server for the bxweb application.

Route functions

blinkenxmas.routes.home(request)[source]

This is the handler for the root URL; it simply returns a redirect to /index.html.

blinkenxmas.routes.get_messages(request)[source]

Drains the Messages instance of all messages and returns them in the body of the response as a JSON-encoded list of strings.

blinkenxmas.routes.get_presets(request)[source]

Returns the list of defined presets as a JSON array.

blinkenxmas.routes.get_preset(request, name)[source]

Returns the animation frames for the named preset as a JSON array.

blinkenxmas.routes.del_preset(request, name)[source]

Removes the named preset from the store.

blinkenxmas.routes.set_preset(request, name)[source]

Replaces the named preset with the JSON data from the body of the request.

blinkenxmas.routes.preview(request)[source]

Previews the animation frames provided by the JSON array in the body of the request on the tree.

blinkenxmas.routes.preview_preset(request, name)[source]

Retrieves the named preset from the store and sends its animation frames to the tree.

blinkenxmas.routes.generate_animation(request, anim_name, params)[source]
blinkenxmas.routes.calibration_positions(request)[source]

Runs at the start of calibration, and immediately after each angle has been scanned. Ultimately it just falls through to the capture.html.pt template but before that, if LED positions from the scan of an angle are present, it will feed them to the calibration algorithm to determine 3D positions of those LEDs.

blinkenxmas.routes.calibration_preview(request)[source]

Continually sends JPEG frames from the camera to the client to provide the preview of the tree before the capture step.

blinkenxmas.routes.calibration_base(request, angle)[source]

Obtains the AngleScanner instance for the specified angle. If none exists, one will be constructed, which will implicitly capture the first image of the (unlit) tree at this angle.

The “base” image of the unlit tree is returned as the response.

blinkenxmas.routes.calibration_mask(request, angle)[source]

Returns a JSON array containing the coordinates drawn by the user around the outline of the tree at the specified angle. The coordinates are (x, y) pairs of floating-point values where (0, 0) is the top left of the base image, and (1, 1) is the bottom right of the image.

blinkenxmas.routes.calibration_state(request, angle)[source]

Returns a JSON object containing information about the progress and state of the (presumably ongoing) scan of the specified angle of the tree. This is typically polled during the scan to display the currently detected LEDs, and how confident the algorithm is in its determination of their position. It also includes the mask coordinates in case this is useful for display purposes.

Again, coordinates are specified as (x, y) pairs of floating-point values between (0, 0) for the top left of the image, and (1, 1) for the bottom right.

blinkenxmas.routes.calibration_run(request)[source]

Falls through to the calibrate.html.pt template. Before doing so, however, it retrieves the AngleScanner instance for the specified angle and starts the calibration scan. If mask data is passed (as a JSON array) in the “mask” value of the query-string, it will be passed to the scan method.

blinkenxmas.routes.calibration_cancel(request)[source]

Cancels any on-going scan of the tree angle specified in the “angle” value of the query-string.

blinkenxmas.routes.calibration_result(request)[source]

TODO

blinkenxmas.routes.calibration_commit(request)[source]

TODO

Support functions

blinkenxmas.routes.scanner_for(request, angle)[source]

Returns the AngleScanner instance for the specified angle, or raises ValueError if the current scanner does not match the requested angle.