diff options
| author | Nikita Kostovsky <luntik2012@gmail.com> | 2024-11-24 19:54:52 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <luntik2012@gmail.com> | 2024-11-24 19:54:52 +0100 |
| commit | 53979d9d26c5bb51e86e70eb9c3a998bc50f713c (patch) | |
| tree | 4ab3fb55d37db89a8f0e61135efc69d89d2e4f11 /rotaryencoder.cpp | |
| parent | e21934bca43b8dc68bbcf37e2ad1da6bd5ac6db6 (diff) | |
implement printer controls; implement calibration data collection
Diffstat (limited to 'rotaryencoder.cpp')
| -rw-r--r-- | rotaryencoder.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/rotaryencoder.cpp b/rotaryencoder.cpp index 41d56e8..62ca33d 100644 --- a/rotaryencoder.cpp +++ b/rotaryencoder.cpp @@ -26,7 +26,7 @@ const std::vector<int> encoderTable = { 0, 1, -1, 0, -1, 0, 0, 1, 1, 0, 0, -1, 0, -1, 1, 0 }; -volatile int64_t positionSteps; +volatile int32_t positionSteps; volatile uint8_t state; void pin_isr(void) { @@ -55,8 +55,14 @@ void pin_isr(void) { } } -rotaryencoder::rotaryencoder() +RotaryEncoder::RotaryEncoder() { + if (!m_self) { + m_self = this; + } else { + qWarning() << "normally there should be only one instance of RotaryEncoder"; + } + QElapsedTimer t; t.start(); @@ -101,7 +107,19 @@ rotaryencoder::rotaryencoder() // } } -int64_t rotaryencoder::position() const +RotaryEncoder::~RotaryEncoder() +{ + if (m_self == this) { + m_self = nullptr; + } +} + +RotaryEncoder *RotaryEncoder::instance() +{ + return m_self; +} + +int32_t RotaryEncoder::position() const { return ::positionSteps; } |
