93 lines
2.2 KiB
C++
93 lines
2.2 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 PIGPIN_H
|
|
#define PIGPIN_H
|
|
|
|
|
|
#include <libpigpio.h>
|
|
|
|
using namespace pigpio;
|
|
|
|
//class pigCall;
|
|
|
|
struct LIBPIGPIO_EXPORT pigPin
|
|
{
|
|
|
|
bcm_t bcm = bcm_t::bcm_off;
|
|
io_t mode = io_t::io_off;
|
|
pud_t pud = pud_t::pull_off;
|
|
int cbId = -1;
|
|
|
|
pigPin() = default;
|
|
explicit pigPin( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off );
|
|
virtual ~pigPin();
|
|
// delete copy/assign const?
|
|
|
|
void init( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off );
|
|
virtual void dump();
|
|
|
|
// pin operations
|
|
int get_level();
|
|
void set_level( level_t level );
|
|
int trigger_level( level_t level, uint32_t pulseLen );
|
|
int wait_for_edge( edge_t edge, double timeout = TimeoutDef );
|
|
|
|
// pin config
|
|
int set_io_mode( io_t modType );
|
|
int get_io_mode();
|
|
int set_pud_mode( pud_t pudType );
|
|
|
|
int set_glitch_filter( uint32_t glitch = GlitchDef );
|
|
int set_noise_filter( uint32_t steady, uint32_t active );
|
|
|
|
// reality interface
|
|
int set_callback( pigCall* fn, edge_t = either );
|
|
int cancel_callback( int cbId );
|
|
|
|
};
|
|
|
|
|
|
struct LIBPIGPIO_EXPORT pigPinIn : public pigPin
|
|
{
|
|
pigPinIn();
|
|
pigPinIn( bcm_t bcmNo, pud_t pudType = pull_off );
|
|
virtual ~pigPinIn();
|
|
|
|
void init( bcm_t bcmNo, pud_t pudType = pull_off );
|
|
|
|
};
|
|
|
|
|
|
struct LIBPIGPIO_EXPORT pigPinOut : public pigPin
|
|
{
|
|
pigPinOut();
|
|
pigPinOut( pigpio::bcm_t bcmNo, pud_t pudType = pull_off );
|
|
virtual ~pigPinOut();
|
|
|
|
void init( bcm_t bcmNo, pud_t pudType = pull_off );
|
|
|
|
};
|
|
|
|
|
|
#endif // PIGPIN_H
|