|
|
|
@ -62,11 +62,44 @@
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if PIN_EXISTS(PHOTOGRAPH)
|
|
|
|
|
constexpr uint8_t NUM_PULSES = 16;
|
|
|
|
|
constexpr float PULSE_LENGTH = 0.01524;
|
|
|
|
|
inline void set_photo_pin(const uint8_t state) { WRITE(PHOTOGRAPH_PIN, state); _delay_ms(PULSE_LENGTH); }
|
|
|
|
|
inline void tweak_photo_pin() { set_photo_pin(HIGH); set_photo_pin(LOW); }
|
|
|
|
|
inline void spin_photo_pin() { for (uint8_t i = NUM_PULSES; i--;) tweak_photo_pin(); }
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE void set_photo_pin(const uint8_t state) {
|
|
|
|
|
constexpr uint32_t pulse_length = (
|
|
|
|
|
#ifdef PHOTO_PULSES_US
|
|
|
|
|
PHOTO_PULSE_DELAY_US
|
|
|
|
|
#else
|
|
|
|
|
15 // 15.24 from _delay_ms(0.01524)
|
|
|
|
|
#endif
|
|
|
|
|
);
|
|
|
|
|
WRITE(PHOTOGRAPH_PIN, state);
|
|
|
|
|
delayMicroseconds(pulse_length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FORCE_INLINE void tweak_photo_pin() { set_photo_pin(HIGH); set_photo_pin(LOW); }
|
|
|
|
|
|
|
|
|
|
#ifdef PHOTO_PULSES_US
|
|
|
|
|
|
|
|
|
|
inline void pulse_photo_pin(const uint32_t duration, const uint8_t state) {
|
|
|
|
|
if (state) {
|
|
|
|
|
for (const uint32_t stop = micros() + duration; micros() < stop;)
|
|
|
|
|
tweak_photo_pin();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
delayMicroseconds(duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void spin_photo_pin() {
|
|
|
|
|
static constexpr uint32_t sequence[] = PHOTO_PULSES_US;
|
|
|
|
|
for (uint8_t i = 0; i < COUNT(sequence); i++)
|
|
|
|
|
pulse_photo_pin(sequence[i], !(i & 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
constexpr uint8_t NUM_PULSES = 16;
|
|
|
|
|
inline void spin_photo_pin() { for (uint8_t i = NUM_PULSES; i--;) tweak_photo_pin(); }
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|