|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The poll transactions and the angle steps of the rotary knob, see knob.h. More...
Functions | |
| uint16_t | knob_decode (uint8_t hi, uint8_t lo) |
The datasheet's angle, 0..16383, rising counter-clockwise seen from the chip's top: hi read from KNOB_REG_ANGLE_HI, lo from KNOB_REG_ANGLE_LO. | |
| uint16_t | knob_clockwise (uint16_t angle) |
angle mirrored, rising clockwise seen from the top: 0 stays 0. | |
| bool | knob_attach (knob_t *k, unsigned addr) |
Take addr as the sensor's address and forget the reference. | |
| int | knob_poll_addr (const knob_t *k) |
| The address the next poll reads, or -1 for a knob that is not attached: then no transaction is made. | |
| bool | knob_poll_probe_first (const knob_t *k) |
| Whether the next poll probes the address before its reads: an attached knob with no reference. | |
| void | knob_reset (knob_t *k) |
| Forget the reference: the next usable reading moves nothing. | |
| int | knob_feed (knob_t *k, bool usable, uint16_t raw) |
| Feed one poll. | |
| int | knob_poll_done (knob_t *k, bool answered, const uint8_t bytes[KNOB_POLL_READS]) |
| End one poll. | |
| float | knob_span_fraction (int steps, int scale_deg) |
Fraction of a slider's span that steps moves it when the span is scale_deg degrees of knob. | |
Variables | |
| const uint8_t | knob_poll_regs [KNOB_POLL_READS] |
The poll transactions and the angle steps of the rotary knob, see knob.h.
SPDX-License-Identifier: MIT
| bool knob_attach | ( | knob_t * | k, |
| unsigned | addr ) |
Take addr as the sensor's address and forget the reference.
An address the panel board answers at (panel_i2c.h) is refused: the knob stays detached, knob_poll_addr() names no address and nothing is ever sent for it. Returns whether the address was taken.
| k | The knob to attach. |
| addr | The 7-bit sensor address. |
| uint16_t knob_clockwise | ( | uint16_t | angle | ) |
angle mirrored, rising clockwise seen from the top: 0 stays 0.
| angle | The angle, 0 to 16383. |
| uint16_t knob_decode | ( | uint8_t | hi, |
| uint8_t | lo ) |
The datasheet's angle, 0..16383, rising counter-clockwise seen from the chip's top: hi read from KNOB_REG_ANGLE_HI, lo from KNOB_REG_ANGLE_LO.
Bits 1 and 0 of lo are ignored.
| hi | The byte read from KNOB_REG_ANGLE_HI. |
| lo | The byte read from KNOB_REG_ANGLE_LO. |
| int knob_feed | ( | knob_t * | k, |
| bool | usable, | ||
| uint16_t | raw ) |
Feed one poll.
usable false (no answer) forgets the reference. Returns the signed steps since the last usable reading, positive for a rising raw, taking the short way across 16383 to 0; zero for the first reading after a reset, and for a step over KNOB_MAX_STEP, which becomes the new reference.
| k | The knob. |
| usable | false for no answer, which forgets the reference. |
| raw | The angle, 0 to 16383. |
| int knob_poll_addr | ( | const knob_t * | k | ) |
The address the next poll reads, or -1 for a knob that is not attached: then no transaction is made.
| k | The knob. |
| int knob_poll_done | ( | knob_t * | k, |
| bool | answered, | ||
| const uint8_t | bytes[KNOB_POLL_READS] ) |
End one poll.
answered: every read of knob_poll_regs answered, and bytes[i] is what knob_poll_regs[i] gave. Returns the steps, positive clockwise seen from the top; a poll that was not answered, or a knob that is not attached, returns 0 and forgets the reference. A poll whose two 0x03 bytes differ returns 0 and keeps the reference.
| k | The knob. |
| answered | true when every read of knob_poll_regs answered. |
| bytes | The bytes read, one per knob_poll_regs entry. |
| bool knob_poll_probe_first | ( | const knob_t * | k | ) |
Whether the next poll probes the address before its reads: an attached knob with no reference.
A probe that is not acknowledged ends the poll as not answered, with no read made.
| k | The knob. |
| void knob_reset | ( | knob_t * | k | ) |
Forget the reference: the next usable reading moves nothing.
| k | The knob to reset. |
| float knob_span_fraction | ( | int | steps, |
| int | scale_deg ) |
Fraction of a slider's span that steps moves it when the span is scale_deg degrees of knob.
scale_deg outside the setting's range is clamped to it.
| steps | The signed steps moved. |
| scale_deg | Degrees of knob per full slider span. |
| const uint8_t knob_poll_regs[KNOB_POLL_READS] |