Files
libpigpio/libpigcore.h
2025-08-05 22:33:23 +02:00

137 lines
4.5 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.h
by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio
sigslot.h
by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot
***************************************************************************/
#ifndef LIBPIGCORE_H
#define LIBPIGCORE_H
#include <string>
#include <iostream>
#include <signal.hpp>
#include <libpigpio.h>
//using namespace pigpio;
struct pigI2C;
namespace pigpio
{
class LIBPIGPIO_EXPORT pigCore
{
public:
/*
- sigX einheitlich, geht das
- stack für sensoren
- threaded sensors / actors?
- timer flicken
*/
virtual int init( const std::string& host ="" , const std::string& port="" ) = 0;
// pin config
virtual int set_io_mode( bcm_t bcm, io_t mode ) = 0;
virtual int get_io_mode( bcm_t bcm ) = 0;
virtual int set_pud_mode( bcm_t bcm, pud_t pud ) = 0;
virtual int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) = 0;
virtual int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) = 0;
// pin operations
virtual int get_level( bcm_t bcm ) = 0;
virtual int set_level( bcm_t bcm, level_t level ) = 0;
virtual int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) = 0;
virtual int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef ) = 0;
// reality interface
virtual int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) = 0;
virtual int cancel_callback( int cbId ) = 0;
// software PWM
/*
set_PWM_dutycycle Start/stop PWM pulses on a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO
set_PWM_range Configure PWM range for a GPIO
get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
get_PWM_frequency Get configured PWM frequency for a GPIO
get_PWM_range Get configured PWM range for a GPIO
get_PWM_real_range Get underlying PWM range for a GPIO
*/
// i2c
virtual int i2c_open( pigI2C& i2c ) = 0;
virtual int i2c_close( pigI2C& i2c ) = 0;
/*
virtual int i2c_write_quick( pigI2C& i2c, unsigned bit ) = 0;
virtual int i2c_write_byte( pigI2C& i2c, unsigned bVal ) = 0;
virtual int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) = 0;
virtual int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) = 0;
virtual int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) = 0;
virtual int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) = 0;
*/
virtual int i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) = 0;
/*
virtual int i2c_read_byte( pigI2C& i2c ) = 0;
virtual int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) = 0;
virtual int i2c_read_word_data( pigI2C& i2c, unsigned reg ) = 0;
virtual int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) = 0;
virtual int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) = 0;
virtual int i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) = 0;
virtual int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal) = 0;
virtual int i2c_block_process_call( pigI2C& i2c, unsigned i2c_reg, char* buf, unsigned count ) = 0;
virtual int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen ) = 0;
*/
// advanced
virtual int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) = 0;
virtual int hardware_clock( bcm_t bcm, uint32_t clkfreq ) = 0;
virtual uint32_t get_current_tick() = 0;
// info
virtual int get_hardware_revision() = 0;
virtual int get_pigpio_version() = 0;
virtual unsigned pigpiod_if_version() = 0;
virtual int show_error( int errNo ) = 0;
protected:
int _Pi;
}; // class pigCore
} // namespace pigpio
#endif // LIBPIGCORE_H