NestGen2.Dial (nest_gen2 v0.6.6)

Copy Markdown View Source

The ring and its press.

The ring is read by an ADBS-A350 optical sensor at a fixed 750 cpi: about 7800 counts per turn. There is no absolute position, so the angle is relative to start-up (or reset_angle/0) and can drift a few degrees over many turns.

Events: :dial for every movement, :dial_step each time the angle crosses a multiple of the step size (default 10°, with Nest's click), :button on press.

Do not ask users to hold the press: a long hold triggers the power chip's hardware reset.

Summary

Functions

Degrees turned clockwise since start-up or the last reset.

Returns a specification to start this module under a supervisor.

Simulates pressing (:down) or releasing (:up) the ring.

Calibration: sensor counts per full turn (default 7800).

Degrees between :dial_step events, or nil for none.

Degrees between :dial_step events, or nil.

Simulates turning the ring by degrees (positive is clockwise), with the same events a real turn gives. For the host viewer, tests and remote control.

Functions

angle()

@spec angle() :: float()

Degrees turned clockwise since start-up or the last reset.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

press(state)

@spec press(:down | :up) :: :ok

Simulates pressing (:down) or releasing (:up) the ring.

reset_angle()

@spec reset_angle() :: :ok

set_counts_per_turn(counts)

@spec set_counts_per_turn(pos_integer()) :: :ok

Calibration: sensor counts per full turn (default 7800).

set_step(degrees)

@spec set_step(pos_integer() | nil) :: :ok

Degrees between :dial_step events, or nil for none.

start_link(_)

step()

@spec step() :: pos_integer() | nil

Degrees between :dial_step events, or nil.

turn(degrees)

@spec turn(number()) :: :ok

Simulates turning the ring by degrees (positive is clockwise), with the same events a real turn gives. For the host viewer, tests and remote control.