| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #pragma once
- // Flat, ungrouped event log the spy Arduino.h/SPI.h shims append to as a
- // real vendor GxEPD2 driver runs. Deliberately NOT grouped into
- // EpdCommand-shaped entries here - this exploratory pass prints the raw
- // observed event stream and compares it against the hand-written
- // panel_213_z98c.h by eye, to learn what the trace actually looks like
- // before building a grouping/JSON-emitting post-processor.
- #include <cstdint>
- #include <cstdio>
- enum class EventKind { PIN_MODE, DIGITAL_WRITE, DIGITAL_READ, DELAY, SPI_BEGIN_TXN, SPI_TRANSFER, SPI_SETTINGS };
- struct Trace {
- static void pin_mode(int pin, int mode) { printf("pinMode(%d, %d)\n", pin, mode); }
- static void digital_write(int pin, int value) { printf("digitalWrite(%d, %d)\n", pin, value); }
- // Every digitalRead() in these drivers is a busy-pin poll - there's
- // nothing else wired as an input. Log it as such and always report
- // "released" so _waitWhileBusy()'s loop exits after one check; we
- // don't need real timing, just to observe *that* a wait happened here.
- static int digital_read(int pin) {
- printf("digitalRead(%d) -> busy-check, reporting released\n", pin);
- return last_busy_release_value;
- }
- static void delay_ms(unsigned long ms) { printf("delay(%lu)\n", ms); }
- static void spi_settings(uint32_t clock_hz, uint8_t bit_order, uint8_t data_mode) {
- printf("SPISettings(clock_hz=%u, bit_order=%u, data_mode=%u)\n", (unsigned) clock_hz, bit_order, data_mode);
- }
- // dc_state: current logical level of the DC pin at the moment of this
- // transfer, as last set via digital_write() on the pin number the
- // harness tells us is DC (see set_dc_pin()). true = command byte,
- // false = data byte - matches GxEPD2_EPD::_writeCommand()/_writeData()
- // exactly (DC low while the command byte goes out, high for data).
- static uint8_t spi_transfer(uint8_t byte) {
- printf("SPI.transfer(0x%02X) dc=%s\n", byte, dc_is_low ? "LOW(cmd)" : "HIGH(data)");
- return 0;
- }
- static void set_dc_pin(int pin) { dc_pin = pin; }
- static void note_digital_write_for_dc(int pin, int value) {
- if (pin == dc_pin)
- dc_is_low = (value == 0);
- }
- static inline int dc_pin = -1;
- static inline bool dc_is_low = false;
- static inline int last_busy_release_value = 0; // overwritten by harness once busy_level is known
- };
|