libepaper 2.0.0
A C++23 library for controlling Waveshare e-paper displays on Raspberry Pi, featuring transparent sleep/wake management and a fluent builder API.
Loading...
Searching...
No Matches
mock_pin.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "epaper/hal/gpio.hpp"
4#include <cstddef>
5
6namespace epaper::hal {
7
23public:
29 auto write(bool level) -> void {
30 last_level_ = level;
31 write_count_++;
32 }
33
38 [[nodiscard]] auto last_level() const -> bool { return last_level_; }
39
44 [[nodiscard]] auto write_count() const -> std::size_t { return write_count_; }
45
49 auto reset() -> void {
50 write_count_ = 0;
51 last_level_ = false;
52 }
53
54private:
55 bool last_level_ = false;
56 std::size_t write_count_ = 0;
57};
58
59static_assert(DigitalOutput<MockOutputPin>, "MockOutputPin must satisfy DigitalOutput concept");
60
76public:
81 auto read() -> bool {
82 read_count_++;
83 return level_;
84 }
85
90 auto set_level(bool level) -> void { level_ = level; }
91
96 [[nodiscard]] auto read_count() const -> std::size_t { return read_count_; }
97
101 auto reset() -> void {
102 read_count_ = 0;
103 level_ = false;
104 }
105
106private:
107 bool level_ = false;
108 std::size_t read_count_ = 0;
109};
110
111static_assert(DigitalInput<MockInputPin>, "MockInputPin must satisfy DigitalInput concept");
112
113} // namespace epaper::hal
Definition mock_pin.hpp:75
auto reset() -> void
Reset pin state for new test.
Definition mock_pin.hpp:101
auto read_count() const -> std::size_t
Get total number of read operations.
Definition mock_pin.hpp:96
auto read() -> bool
Read logic level from pin (returns configured level).
Definition mock_pin.hpp:81
auto set_level(bool level) -> void
Set the level that read() will return.
Definition mock_pin.hpp:90
Definition mock_pin.hpp:22
auto write_count() const -> std::size_t
Get total number of write operations.
Definition mock_pin.hpp:44
auto last_level() const -> bool
Get the last written logic level.
Definition mock_pin.hpp:38
auto reset() -> void
Reset pin state for new test.
Definition mock_pin.hpp:49
auto write(bool level) -> void
Write logic level to pin (records operation).
Definition mock_pin.hpp:29
GPIO pin concepts for hardware abstraction.
Definition gpio.hpp:62