Part 4 of a series on using C++ for microcontroller I/O library development. Covers extending a GPIO abstraction to support input pins and bidirectional I/O pins using a class hierarchy with multiple inheritance. Introduces a safe direction-setting pattern where each pin class exposes direction_set_input()/direction_set_output() methods with empty defaults. Then builds a quadrature rotary encoder decoder with bounce-resistant logic, a saturating counter class using virtual after_update() hooks, and a complete demo on LPCXpresso hardware displaying the count on an HC595-driven seven-segment display.
1 Impression