first re-commit.
This commit is contained in:
69
pigbutton.cpp
Normal file
69
pigbutton.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pigbutton.h>
|
||||
|
||||
|
||||
pigButton::pigButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigButton::pigButton( pigpio::bcm_t bcmNo )
|
||||
|
||||
{
|
||||
init( bcmNo );
|
||||
}
|
||||
|
||||
|
||||
pigButton::~pigButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigButton::init( pigpio::bcm_t bcmNo )
|
||||
{
|
||||
_pinIn.init( bcmNo, pull_up );
|
||||
//pinIn.set_callback( this, rising );
|
||||
_pinIn.set_callback( this, falling );
|
||||
_pinIn.set_glitch_filter( 500 );
|
||||
}
|
||||
|
||||
|
||||
void pigButton::change_state( bool newState )
|
||||
{
|
||||
if( newState == state() )
|
||||
return;
|
||||
set_state( newState );
|
||||
sigState( _state );
|
||||
//_pinOut.set_level( _state );
|
||||
}
|
||||
|
||||
|
||||
void pigButton::trigger( pigpio::bcm_t, uint32_t )
|
||||
{
|
||||
//std::cout << "pigButton::trigger: " << (uint32_t) bcm << " : " << level << std::endl;
|
||||
change_state( !state() );
|
||||
}
|
Reference in New Issue
Block a user