|
@@ -62,11 +62,44 @@
|
62
|
62
|
#endif
|
63
|
63
|
|
64
|
64
|
#if PIN_EXISTS(PHOTOGRAPH)
|
65
|
|
- constexpr uint8_t NUM_PULSES = 16;
|
66
|
|
- constexpr float PULSE_LENGTH = 0.01524;
|
67
|
|
- inline void set_photo_pin(const uint8_t state) { WRITE(PHOTOGRAPH_PIN, state); _delay_ms(PULSE_LENGTH); }
|
68
|
|
- inline void tweak_photo_pin() { set_photo_pin(HIGH); set_photo_pin(LOW); }
|
69
|
|
- inline void spin_photo_pin() { for (uint8_t i = NUM_PULSES; i--;) tweak_photo_pin(); }
|
|
65
|
+
|
|
66
|
+ FORCE_INLINE void set_photo_pin(const uint8_t state) {
|
|
67
|
+ constexpr uint32_t pulse_length = (
|
|
68
|
+ #ifdef PHOTO_PULSES_US
|
|
69
|
+ PHOTO_PULSE_DELAY_US
|
|
70
|
+ #else
|
|
71
|
+ 15 // 15.24 from _delay_ms(0.01524)
|
|
72
|
+ #endif
|
|
73
|
+ );
|
|
74
|
+ WRITE(PHOTOGRAPH_PIN, state);
|
|
75
|
+ delayMicroseconds(pulse_length);
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ FORCE_INLINE void tweak_photo_pin() { set_photo_pin(HIGH); set_photo_pin(LOW); }
|
|
79
|
+
|
|
80
|
+ #ifdef PHOTO_PULSES_US
|
|
81
|
+
|
|
82
|
+ inline void pulse_photo_pin(const uint32_t duration, const uint8_t state) {
|
|
83
|
+ if (state) {
|
|
84
|
+ for (const uint32_t stop = micros() + duration; micros() < stop;)
|
|
85
|
+ tweak_photo_pin();
|
|
86
|
+ }
|
|
87
|
+ else
|
|
88
|
+ delayMicroseconds(duration);
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ inline void spin_photo_pin() {
|
|
92
|
+ static constexpr uint32_t sequence[] = PHOTO_PULSES_US;
|
|
93
|
+ for (uint8_t i = 0; i < COUNT(sequence); i++)
|
|
94
|
+ pulse_photo_pin(sequence[i], !(i & 1));
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ #else
|
|
98
|
+
|
|
99
|
+ constexpr uint8_t NUM_PULSES = 16;
|
|
100
|
+ inline void spin_photo_pin() { for (uint8_t i = NUM_PULSES; i--;) tweak_photo_pin(); }
|
|
101
|
+
|
|
102
|
+ #endif
|
70
|
103
|
#endif
|
71
|
104
|
|
72
|
105
|
/**
|