74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
/*****************************************************************************
|
|
|
|
source::worx libPiGPio
|
|
Copyright © 2022 c.holzheuer
|
|
chris@sourceworx.org
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Uses:
|
|
|
|
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
|
|
https://abyz.me.uk/rpi/pigpio
|
|
|
|
sigslot by 2017 Pierre-Antoine Lacaze
|
|
https://github.com/palacaze/sigslot
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
#ifndef PIGROTARYDIAL_H
|
|
#define PIGROTARYDIAL_H
|
|
|
|
|
|
#include <pigbutton.h>
|
|
#include <pigvalue.h>
|
|
|
|
|
|
/**
|
|
* @brief The pigRotaryDial class
|
|
*
|
|
* TODO: flags: step oder detent, inc/dec oder value, set_range range_stop: until 100 or 100->0
|
|
*
|
|
*/
|
|
|
|
class LIBPIGPIO_EXPORT pigRotaryDial : public pigButton, public pigValue<int>
|
|
{
|
|
|
|
public:
|
|
|
|
pigRotaryDial();
|
|
explicit pigRotaryDial( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown );
|
|
virtual ~pigRotaryDial();
|
|
|
|
void init( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown );
|
|
|
|
virtual void reset();
|
|
|
|
protected:
|
|
|
|
void trigger( pigpio::bcm_t bcm, uint32_t level ) override;
|
|
|
|
constexpr const static int Transits[16]=
|
|
{
|
|
/* 0000 0001 0010 0011 0100 0101 0110 0111 */
|
|
0, -1, 1, 0, 1, 0, 0, -1,
|
|
/* 1000 1001 1010 1011 1100 1101 1110 1111 */
|
|
-1, 0, 0, 1, 0, 1, -1, 0
|
|
};
|
|
|
|
pigPinIn _pinDown;
|
|
pigPinIn _pinUp;
|
|
|
|
int _levUp = 0;
|
|
int _levDown = 0;
|
|
int _oldState = -1;
|
|
|
|
};
|
|
|
|
|
|
#endif // PIGROTARYDIAL_H
|