fixed embarrassing typos
This commit is contained in:
28
Makefile
28
Makefile
@@ -37,7 +37,7 @@ MOVE = mv -f
|
||||
TAR = tar -cf
|
||||
COMPRESS = gzip -9f
|
||||
DISTNAME = pigbin1.0.0
|
||||
DISTDIR = /home/pi/share/projects.nxt/libPiGPIO/.tmp/pigbin1.0.0
|
||||
DISTDIR = /home/pi/gitea.current/libpigpio/.tmp/pigbin1.0.0
|
||||
LINK = g++
|
||||
LFLAGS = -Wl,-O1
|
||||
LIBS = $(SUBLIBS) -lpigpiod_if2 -lrt -pthread /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so /usr/lib/arm-linux-gnueabihf/libQt5Gui.so /usr/lib/arm-linux-gnueabihf/libQt5Network.so /usr/lib/arm-linux-gnueabihf/libQt5Core.so -lGLESv2 -lpthread -latomic
|
||||
@@ -146,12 +146,6 @@ DIST = /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/spec_pre.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qml.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlmodels.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmltest.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlworkerscript.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quick.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_service_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.pri \
|
||||
@@ -161,11 +155,11 @@ DIST = /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/spec_pre.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_x11extras.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_Qt5Keychain.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_functions.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf \
|
||||
@@ -290,12 +284,6 @@ Makefile: libPiGPIO.pro /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qml.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlmodels.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmltest.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlworkerscript.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quick.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_service_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.pri \
|
||||
@@ -305,11 +293,11 @@ Makefile: libPiGPIO.pro /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_x11extras.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_Qt5Keychain.pri \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_functions.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf \
|
||||
@@ -380,12 +368,6 @@ Makefile: libPiGPIO.pro /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qml.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlmodels.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmltest.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_qmlworkerscript.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quick.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_quickwidgets.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_service_support_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.pri:
|
||||
@@ -395,11 +377,11 @@ Makefile: libPiGPIO.pro /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_vulkan_support_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_x11extras.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xkbcommon_support_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_Qt5Keychain.pri:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_functions.prf:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf:
|
||||
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf:
|
||||
@@ -501,7 +483,7 @@ moc_QtGPIOMain.cpp: QtGPIOMain.h \
|
||||
pigpin.h \
|
||||
moc_predefs.h \
|
||||
/usr/lib/qt5/bin/moc
|
||||
/usr/lib/qt5/bin/moc $(DEFINES) --include /home/pi/share/projects.nxt/libPiGPIO/moc_predefs.h -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -I/home/pi/share/projects.nxt/libPiGPIO -I/home/pi/share/projects.nxt/libPiGPIO -I/home/pi/share/projects.nxt/libPiGPIO/sigslot/include/sigslot -I/usr/include/arm-linux-gnueabihf/qt5 -I/usr/include/arm-linux-gnueabihf/qt5/QtWidgets -I/usr/include/arm-linux-gnueabihf/qt5/QtGui -I/usr/include/arm-linux-gnueabihf/qt5/QtNetwork -I/usr/include/arm-linux-gnueabihf/qt5/QtCore -I/usr/include/c++/10 -I/usr/include/arm-linux-gnueabihf/c++/10 -I/usr/include/c++/10/backward -I/usr/lib/gcc/arm-linux-gnueabihf/10/include -I/usr/local/include -I/usr/include/arm-linux-gnueabihf -I/usr/include QtGPIOMain.h -o moc_QtGPIOMain.cpp
|
||||
/usr/lib/qt5/bin/moc $(DEFINES) --include /home/pi/gitea.current/libpigpio/moc_predefs.h -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -I/home/pi/gitea.current/libpigpio -I/home/pi/gitea.current/libpigpio -I/home/pi/gitea.current/libpigpio/sigslot/include/sigslot -I/usr/include/arm-linux-gnueabihf/qt5 -I/usr/include/arm-linux-gnueabihf/qt5/QtWidgets -I/usr/include/arm-linux-gnueabihf/qt5/QtGui -I/usr/include/arm-linux-gnueabihf/qt5/QtNetwork -I/usr/include/arm-linux-gnueabihf/qt5/QtCore -I/usr/include/c++/10 -I/usr/include/arm-linux-gnueabihf/c++/10 -I/usr/include/c++/10/backward -I/usr/lib/gcc/arm-linux-gnueabihf/10/include -I/usr/local/include -I/usr/include/arm-linux-gnueabihf -I/usr/include QtGPIOMain.h -o moc_QtGPIOMain.cpp
|
||||
|
||||
compiler_moc_objc_header_make_all:
|
||||
compiler_moc_objc_header_clean:
|
||||
|
114
QtGPIOMain.cpp
114
QtGPIOMain.cpp
@@ -1,57 +1,57 @@
|
||||
/***************************************************************************
|
||||
|
||||
QtGPIO
|
||||
Copyright © 2013-2022 christoph 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QtGPIOMain.h>
|
||||
#include <ui_QtGPIOMain.h>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
QtGPIOMain::QtGPIOMain( QWidget* parent )
|
||||
: QMainWindow( parent ), _pigDial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 )
|
||||
{
|
||||
|
||||
setupUi( this );
|
||||
|
||||
//_rotaryDial.init( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//auto lambda = []() { std::cout << "lambda\n"; };
|
||||
//_rotaryDial.sigState.connect( lambda );
|
||||
|
||||
|
||||
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//_rotaryDial.add_state_observer( &myMoo );
|
||||
//_rotaryDial.add_value_observer( &myMoo );
|
||||
|
||||
//_pigDial.add_state_observer( this );
|
||||
//_pigDial.add_value_observer( this );
|
||||
|
||||
}
|
||||
|
||||
|
||||
QtGPIOMain::~QtGPIOMain()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtGPIOMain::on_state_changed( bool state )
|
||||
{
|
||||
qDebug() << "onStateChanged: " << state;
|
||||
_LED->setChecked( state );
|
||||
|
||||
}
|
||||
|
||||
void QtGPIOMain::on_value_changed( int value )
|
||||
{
|
||||
qDebug() << "on_value_changed: " << value;
|
||||
_dial->setValue( value );
|
||||
}
|
||||
/***************************************************************************
|
||||
|
||||
QtGPIO
|
||||
Copyright © 2013-2022 christoph 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QtGPIOMain.h>
|
||||
#include <ui_QtGPIOMain.h>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
QtGPIOMain::QtGPIOMain( QWidget* parent )
|
||||
: QMainWindow( parent ), _pigDial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 )
|
||||
{
|
||||
|
||||
setupUi( this );
|
||||
|
||||
//_rotaryDial.init( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//auto lambda = []() { std::cout << "lambda\n"; };
|
||||
//_rotaryDial.sigState.connect( lambda );
|
||||
|
||||
|
||||
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//_rotaryDial.add_state_observer( &myMoo );
|
||||
//_rotaryDial.add_value_observer( &myMoo );
|
||||
|
||||
//_pigDial.add_state_observer( this );
|
||||
//_pigDial.add_value_observer( this );
|
||||
|
||||
}
|
||||
|
||||
|
||||
QtGPIOMain::~QtGPIOMain()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtGPIOMain::on_state_changed( bool state )
|
||||
{
|
||||
qDebug() << "onStateChanged: " << state;
|
||||
_LED->setChecked( state );
|
||||
|
||||
}
|
||||
|
||||
void QtGPIOMain::on_value_changed( int value )
|
||||
{
|
||||
qDebug() << "on_value_changed: " << value;
|
||||
_dial->setValue( value );
|
||||
}
|
||||
|
89
QtGPIOMain.h
89
QtGPIOMain.h
@@ -1,45 +1,44 @@
|
||||
/***************************************************************************
|
||||
|
||||
QtGPIO
|
||||
Copyright © 2013-2022 christoph 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef QPIGPIOMAIN_H
|
||||
#define QPIGPIOMAIN_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <ui_QtGPIOMain.h>
|
||||
#include <iostream>
|
||||
#include <pigrotarydial.h>
|
||||
|
||||
|
||||
|
||||
class QtGPIOMain : public QMainWindow, private Ui_QtGPIOMain
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QtGPIOMain( QWidget* parent = nullptr );
|
||||
virtual ~QtGPIOMain();
|
||||
|
||||
void on_state_changed( bool state );
|
||||
void on_value_changed( int value );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
pigRotaryDial _pigDial;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QPIGPIOMAIN_H
|
||||
/***************************************************************************
|
||||
|
||||
QtGPIO
|
||||
Copyright © 2013-2022 christoph 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 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef QPIGPIOMAIN_H
|
||||
#define QPIGPIOMAIN_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <ui_QtGPIOMain.h>
|
||||
#include <pigrotarydial.h>
|
||||
|
||||
|
||||
|
||||
class QtGPIOMain : public QMainWindow, private Ui_QtGPIOMain
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QtGPIOMain( QWidget* parent = nullptr );
|
||||
virtual ~QtGPIOMain();
|
||||
|
||||
void on_state_changed( bool state );
|
||||
void on_value_changed( int value );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
pigRotaryDial _pigDial;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QPIGPIOMAIN_H
|
||||
|
@@ -1,24 +1,24 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
271
libpigcore.h
271
libpigcore.h
@@ -1,136 +1,135 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <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
|
||||
|
||||
|
||||
|
||||
|
||||
|
800
libpiglinux.cpp
800
libpiglinux.cpp
@@ -1,407 +1,393 @@
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pigpiod_if2.h>
|
||||
|
||||
#include <libpiglinux.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
using namespace pigpio;
|
||||
|
||||
|
||||
pigLinux::pigLinux() noexcept
|
||||
{
|
||||
//::gpioInitialise();
|
||||
/// Connect to Pi.
|
||||
constexpr char* optHost = nullptr;
|
||||
constexpr char* optPort = nullptr;
|
||||
_Pi = ::pigpio_start( optHost, optPort );
|
||||
if( _Pi < 0 )
|
||||
std::cout << "-- pigLinux(): FAIL" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
pigLinux::~pigLinux()
|
||||
{
|
||||
//::gpioTerminate();
|
||||
::pigpio_stop( _Pi );
|
||||
}
|
||||
|
||||
int pigLinux::init( const std::string& host, const std::string& port )
|
||||
{
|
||||
//::gpioInitialise();
|
||||
/// Connect to Pi.
|
||||
_Pi = ::pigpio_start( host.c_str(), port.c_str() );
|
||||
if( _Pi < 0 )
|
||||
std::cout << "-- pigLinux(): FAIL" << std::endl;
|
||||
return _Pi;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin config
|
||||
///
|
||||
|
||||
int pigLinux::set_io_mode( bcm_t bcm, io_t mode )
|
||||
{
|
||||
int result = ::set_mode( _Pi, (unsigned) bcm, (unsigned) mode );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::get_io_mode( bcm_t bcm )
|
||||
{
|
||||
int result = ::get_mode( _Pi, (unsigned) bcm );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::set_pud_mode( bcm_t bcm, pud_t pud )
|
||||
{
|
||||
int result = ::set_pull_up_down( _Pi, (unsigned) bcm, (unsigned) pud );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_glitch_filter( bcm_t bcm , uint32_t glitch )
|
||||
{
|
||||
int result = ::set_glitch_filter( _Pi, (unsigned) bcm, glitch );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
//Sets a noise filter on a GPIO.
|
||||
int pigLinux::set_noise_filter( bcm_t bcm , unsigned steady, unsigned active )
|
||||
{
|
||||
|
||||
int result = ::set_noise_filter( _Pi, (unsigned) bcm, steady, active );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin operations
|
||||
///
|
||||
|
||||
int pigLinux::get_level( bcm_t bcm )
|
||||
{
|
||||
return ::gpio_read( _Pi, (unsigned) bcm );
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_level( bcm_t bcm , level_t level )
|
||||
{
|
||||
int result = ::gpio_write( _Pi, (unsigned) bcm, level ); ;
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
|
||||
int pigLinux::trigger_level( bcm_t bcm , level_t level, uint32_t pulseLen )
|
||||
{
|
||||
//int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)
|
||||
int result = ::gpio_trigger( _Pi, (unsigned) bcm, pulseLen, level ); ;
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::wait_for_edge( bcm_t bcm , edge_t edge, double tout )
|
||||
{
|
||||
//std::cout << " --pigLinux::wait_for_edge: " << (uint32_t) bcm << " : " << (uint32_t) edge << std::endl;
|
||||
|
||||
int result = ::wait_for_edge( _Pi, (unsigned) bcm, (unsigned) edge, tout );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_callback( bcm_t bcm, pigCall* fn, edge_t edge )
|
||||
{
|
||||
//std::cout << " --pigLinux::set_callback: " << (uint32_t) bcm << " : " << (uint32_t) edge << std::endl;
|
||||
|
||||
/// typedef int (*CBFuncEx_t)(int pi, unsigned user_gpio, unsigned level, uint32_t tick, int * userdata );
|
||||
///int callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, int *userdata)
|
||||
//int result = cbId = ::callback_ex( _Pi, (unsigned) bcm, (unsigned) edge, trigger, widget );
|
||||
//int result = ::callback_ex( _Pi, (unsigned) bcm, (unsigned) edge, trigger, widget );
|
||||
|
||||
int result = ::callback_ex( _Pi, (unsigned) bcm, (unsigned) edge, trigger, fn );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::cancel_callback( int cbId )
|
||||
{
|
||||
int result = ::callback_cancel( cbId );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ic2
|
||||
///
|
||||
|
||||
int pigLinux::i2c_open( pigI2C& i2c )
|
||||
{
|
||||
int result = i2c.handle = ::i2c_open( _Pi, i2c.bus, i2c.addr, 0 );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_close( pigI2C& i2c )
|
||||
{
|
||||
int result = ::i2c_close( _Pi, i2c.handle );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigLinux::i2c_write_quick( pigI2C& i2c, unsigned bit )
|
||||
{
|
||||
int result = ::i2c_write_quick( _Pi, i2c.handle, bit );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_byte( pigI2C& i2c, unsigned bVal )
|
||||
{
|
||||
int result = ::i2c_write_byte( _Pi, i2c.handle, bVal );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
int result = ::i2c_write_byte_data( _Pi, i2c.handle, reg, val );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
int result = ::i2c_write_word_data( _Pi, i2c.handle, reg, val );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_i2c_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
int pigLinux::i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_device( _Pi, i2c.handle, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigLinux::i2c_read_byte( pigI2C& i2c )
|
||||
{
|
||||
int result = ::i2c_read_byte( _Pi, i2c.handle );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_byte_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
int result = ::i2c_read_byte_data( _Pi, i2c.handle, reg );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_word_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
int result = ::i2c_read_word_data( _Pi, i2c.handle, reg );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int pigLinux::i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
|
||||
{
|
||||
int result = ::i2c_read_block_data( _Pi, i2c.handle, reg, buf );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_read_i2c_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_read_device( _Pi, i2c.handle, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_process_call( pigI2C& i2c, unsigned reg, unsigned wVal )
|
||||
{
|
||||
int result = ::i2c_process_call( _Pi, i2c.handle, reg, wVal );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_block_process_call( pigI2C& i2c,unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_block_process_call( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
|
||||
{
|
||||
int result = ::i2c_zip( _Pi, i2c.handle, inBuf, inLen, outBuf, outLen );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///
|
||||
/// advanced
|
||||
///
|
||||
|
||||
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
|
||||
|
||||
int pigLinux::hardware_PWM( bcm_t bcm , unsigned PWMfreq, uint32_t PWMduty )
|
||||
{
|
||||
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
|
||||
int result = ::hardware_PWM( _Pi, (unsigned) bcm, PWMfreq, PWMduty );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
|
||||
|
||||
int pigLinux::hardware_clock( bcm_t bcm , unsigned clkfreq )
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
int result = ::hardware_clock( _Pi, (unsigned) bcm, clkfreq );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
uint32_t pigLinux::get_current_tick()
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return ::get_current_tick( _Pi );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// convenience
|
||||
///
|
||||
|
||||
|
||||
int pigLinux::show_error( int error )
|
||||
{
|
||||
|
||||
std::cout << "Error: " << ::pigpio_error( error ) << std::endl;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
//Get the Pi's hardware revision number.
|
||||
|
||||
int pigLinux::get_hardware_revision()
|
||||
{
|
||||
int result = ::get_hardware_revision( _Pi );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//Returns the pigpio version.
|
||||
|
||||
int pigLinux::get_pigpio_version()
|
||||
{
|
||||
int result = ::get_pigpio_version( _Pi );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//Return the pigpiod_if2 version.
|
||||
|
||||
unsigned pigLinux::pigpiod_if_version()
|
||||
{
|
||||
//unsigned pigpiod_if_version(void)
|
||||
int result = ::pigpiod_if_version();
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pigpiod_if2.h>
|
||||
|
||||
#include <libpiglinux.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
using namespace pigpio;
|
||||
|
||||
|
||||
pigLinux::pigLinux() noexcept
|
||||
{
|
||||
//::gpioInitialise();
|
||||
/// Connect to Pi.
|
||||
constexpr char* optHost = nullptr;
|
||||
constexpr char* optPort = nullptr;
|
||||
_Pi = ::pigpio_start( optHost, optPort );
|
||||
if( _Pi < 0 )
|
||||
std::cout << "-- pigLinux(): FAIL" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
pigLinux::~pigLinux()
|
||||
{
|
||||
//::gpioTerminate();
|
||||
::pigpio_stop( _Pi );
|
||||
}
|
||||
|
||||
int pigLinux::init( const std::string& host, const std::string& port )
|
||||
{
|
||||
//::gpioInitialise();
|
||||
/// Connect to Pi.
|
||||
_Pi = ::pigpio_start( host.c_str(), port.c_str() );
|
||||
if( _Pi < 0 )
|
||||
std::cout << "-- pigLinux(): FAIL" << std::endl;
|
||||
return _Pi;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin config
|
||||
///
|
||||
|
||||
int pigLinux::set_io_mode( bcm_t bcm, io_t mode )
|
||||
{
|
||||
int result = ::set_mode( _Pi, (unsigned) bcm, (unsigned) mode );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::get_io_mode( bcm_t bcm )
|
||||
{
|
||||
int result = ::get_mode( _Pi, (unsigned) bcm );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::set_pud_mode( bcm_t bcm, pud_t pud )
|
||||
{
|
||||
int result = ::set_pull_up_down( _Pi, (unsigned) bcm, (unsigned) pud );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_glitch_filter( bcm_t bcm , uint32_t glitch )
|
||||
{
|
||||
int result = ::set_glitch_filter( _Pi, (unsigned) bcm, glitch );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
//Sets a noise filter on a GPIO.
|
||||
int pigLinux::set_noise_filter( bcm_t bcm , unsigned steady, unsigned active )
|
||||
{
|
||||
|
||||
int result = ::set_noise_filter( _Pi, (unsigned) bcm, steady, active );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin operations
|
||||
///
|
||||
|
||||
int pigLinux::get_level( bcm_t bcm )
|
||||
{
|
||||
return ::gpio_read( _Pi, (unsigned) bcm );
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_level( bcm_t bcm , level_t level )
|
||||
{
|
||||
int result = ::gpio_write( _Pi, (unsigned) bcm, level ); ;
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
|
||||
int pigLinux::trigger_level( bcm_t bcm , level_t level, uint32_t pulseLen )
|
||||
{
|
||||
int result = ::gpio_trigger( _Pi, (unsigned) bcm, pulseLen, level ); ;
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::wait_for_edge( bcm_t bcm , edge_t edge, double tout )
|
||||
{
|
||||
int result = ::wait_for_edge( _Pi, (unsigned) bcm, (unsigned) edge, tout );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::set_callback( bcm_t bcm, pigCall* fn, edge_t edge )
|
||||
{
|
||||
int result = ::callback_ex( _Pi, (unsigned) bcm, (unsigned) edge, trigger, fn );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::cancel_callback( int cbId )
|
||||
{
|
||||
int result = ::callback_cancel( cbId );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ic2
|
||||
///
|
||||
|
||||
int pigLinux::i2c_open( pigI2C& i2c )
|
||||
{
|
||||
int result = i2c.handle = ::i2c_open( _Pi, i2c.bus, i2c.addr, 0 );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_close( pigI2C& i2c )
|
||||
{
|
||||
int result = ::i2c_close( _Pi, i2c.handle );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigLinux::i2c_write_quick( pigI2C& i2c, unsigned bit )
|
||||
{
|
||||
int result = ::i2c_write_quick( _Pi, i2c.handle, bit );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_byte( pigI2C& i2c, unsigned bVal )
|
||||
{
|
||||
int result = ::i2c_write_byte( _Pi, i2c.handle, bVal );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
int result = ::i2c_write_byte_data( _Pi, i2c.handle, reg, val );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
int result = ::i2c_write_word_data( _Pi, i2c.handle, reg, val );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_i2c_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
int pigLinux::i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_write_device( _Pi, i2c.handle, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigLinux::i2c_read_byte( pigI2C& i2c )
|
||||
{
|
||||
int result = ::i2c_read_byte( _Pi, i2c.handle );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_byte_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
int result = ::i2c_read_byte_data( _Pi, i2c.handle, reg );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_word_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
int result = ::i2c_read_word_data( _Pi, i2c.handle, reg );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
|
||||
{
|
||||
int result = ::i2c_read_block_data( _Pi, i2c.handle, reg, buf );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_read_i2c_block_data( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_read_device( _Pi, i2c.handle, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
int pigLinux::i2c_process_call( pigI2C& i2c, unsigned reg, unsigned wVal )
|
||||
{
|
||||
int result = ::i2c_process_call( _Pi, i2c.handle, reg, wVal );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_block_process_call( pigI2C& i2c,unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
int result = ::i2c_block_process_call( _Pi, i2c.handle, reg, buf, count );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int pigLinux::i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
|
||||
{
|
||||
int result = ::i2c_zip( _Pi, i2c.handle, inBuf, inLen, outBuf, outLen );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///
|
||||
/// advanced
|
||||
///
|
||||
|
||||
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
|
||||
|
||||
int pigLinux::hardware_PWM( bcm_t bcm , unsigned PWMfreq, uint32_t PWMduty )
|
||||
{
|
||||
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
|
||||
int result = ::hardware_PWM( _Pi, (unsigned) bcm, PWMfreq, PWMduty );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
|
||||
|
||||
int pigLinux::hardware_clock( bcm_t bcm , unsigned clkfreq )
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
int result = ::hardware_clock( _Pi, (unsigned) bcm, clkfreq );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
uint32_t pigLinux::get_current_tick()
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return ::get_current_tick( _Pi );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// convenience
|
||||
///
|
||||
|
||||
|
||||
int pigLinux::show_error( int error )
|
||||
{
|
||||
std::cout << "Error: " << ::pigpio_error( error ) << std::endl;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
//Get the Pi's hardware revision number.
|
||||
|
||||
int pigLinux::get_hardware_revision()
|
||||
{
|
||||
int result = ::get_hardware_revision( _Pi );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//Returns the pigpio version.
|
||||
|
||||
int pigLinux::get_pigpio_version()
|
||||
{
|
||||
int result = ::get_pigpio_version( _Pi );
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//Return the pigpiod_if2 version.
|
||||
|
||||
unsigned pigLinux::pigpiod_if_version()
|
||||
{
|
||||
//unsigned pigpiod_if_version(void)
|
||||
int result = ::pigpiod_if_version();
|
||||
if( result < 0 )
|
||||
return show_error( result );
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
252
libpiglinux.h
252
libpiglinux.h
@@ -1,126 +1,126 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGLINUX_H
|
||||
#define LIBPIGLINUX_H
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
class LIBPIGPIO_EXPORT pigLinux : public pigCore
|
||||
{
|
||||
|
||||
friend pigCore& get_instance();
|
||||
|
||||
public:
|
||||
|
||||
pigLinux( const pigLinux& ) = delete;
|
||||
void operator=( const pigLinux& ) = delete;
|
||||
|
||||
virtual ~pigLinux();
|
||||
|
||||
int init( const std::string& host ="", const std::string& port="" ) override;
|
||||
|
||||
// pin config
|
||||
int set_io_mode( bcm_t bcm, io_t mode ) override;
|
||||
int get_io_mode( bcm_t bcm ) override;
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud ) override;
|
||||
int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
|
||||
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
|
||||
|
||||
// pin operations
|
||||
int get_level( bcm_t bcm ) override;
|
||||
int set_level( bcm_t bcm, level_t level ) override;
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef ) override;
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
|
||||
|
||||
// interface
|
||||
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
|
||||
int cancel_callback( int cbId ) override;
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c ) override;
|
||||
int i2c_close( pigI2C& i2c ) override;
|
||||
/*
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) override;
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
*/
|
||||
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
/*
|
||||
int i2c_read_byte( pigI2C& i2c ) override;
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) override;
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) override;
|
||||
int i2c_block_process_call( pigI2C& i2c,unsigned i2c_reg, char* buf, unsigned count ) override;
|
||||
int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
|
||||
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
|
||||
uint32_t get_current_tick() override;
|
||||
|
||||
// info
|
||||
int get_hardware_revision() override;
|
||||
int get_pigpio_version() override;
|
||||
unsigned pigpiod_if_version() override;
|
||||
|
||||
int show_error( int errNo ) override;
|
||||
|
||||
private:
|
||||
|
||||
pigLinux() noexcept;
|
||||
|
||||
};
|
||||
|
||||
} // namepace
|
||||
|
||||
#endif // def linux
|
||||
|
||||
#endif // LIBPIGLINUX_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGLINUX_H
|
||||
#define LIBPIGLINUX_H
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
class LIBPIGPIO_EXPORT pigLinux : public pigCore
|
||||
{
|
||||
|
||||
friend pigCore& get_instance();
|
||||
|
||||
public:
|
||||
|
||||
pigLinux( const pigLinux& ) = delete;
|
||||
void operator=( const pigLinux& ) = delete;
|
||||
|
||||
virtual ~pigLinux();
|
||||
|
||||
int init( const std::string& host ="", const std::string& port="" ) override;
|
||||
|
||||
// pin config
|
||||
int set_io_mode( bcm_t bcm, io_t mode ) override;
|
||||
int get_io_mode( bcm_t bcm ) override;
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud ) override;
|
||||
int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
|
||||
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
|
||||
|
||||
// pin operations
|
||||
int get_level( bcm_t bcm ) override;
|
||||
int set_level( bcm_t bcm, level_t level ) override;
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef ) override;
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
|
||||
|
||||
// interface
|
||||
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
|
||||
int cancel_callback( int cbId ) override;
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c ) override;
|
||||
int i2c_close( pigI2C& i2c ) override;
|
||||
/*
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) override;
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
*/
|
||||
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
/*
|
||||
int i2c_read_byte( pigI2C& i2c ) override;
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) override;
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) override;
|
||||
int i2c_block_process_call( pigI2C& i2c,unsigned i2c_reg, char* buf, unsigned count ) override;
|
||||
int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
|
||||
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
|
||||
uint32_t get_current_tick() override;
|
||||
|
||||
// info
|
||||
int get_hardware_revision() override;
|
||||
int get_pigpio_version() override;
|
||||
unsigned pigpiod_if_version() override;
|
||||
|
||||
int show_error( int errNo ) override;
|
||||
|
||||
private:
|
||||
|
||||
pigLinux() noexcept;
|
||||
|
||||
};
|
||||
|
||||
} // namepace
|
||||
|
||||
#endif // def linux
|
||||
|
||||
#endif // LIBPIGLINUX_H
|
||||
|
621
libpigpio.cpp
621
libpigpio.cpp
@@ -1,310 +1,311 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigpin.h>
|
||||
#include <pignode.h>
|
||||
|
||||
#include <libpigwindows.h>
|
||||
#include <libpiglinux.h>
|
||||
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
pigCore& get_instance()
|
||||
{
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
static pigLinux _Instance; // guaranteed to be destroyed.
|
||||
#endif //Q_OS_LINUX
|
||||
#ifdef _WIN32
|
||||
static pigWindows _Instance; //guaranteed to be destroyed.
|
||||
#endif // _WIN32
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
// bcm config
|
||||
int set_io_mode( bcm_t bcm, io_t mode )
|
||||
{
|
||||
return get_instance().set_io_mode( bcm, mode );
|
||||
}
|
||||
|
||||
|
||||
int get_io_mode( bcm_t bcm )
|
||||
{
|
||||
return get_instance().get_io_mode( bcm );
|
||||
}
|
||||
|
||||
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud )
|
||||
{
|
||||
return get_instance().set_pud_mode( bcm, pud );
|
||||
}
|
||||
|
||||
|
||||
int set_glitch_filter(bcm_t bcm, uint32_t glitch )
|
||||
{
|
||||
return get_instance().set_glitch_filter( bcm, glitch );
|
||||
}
|
||||
|
||||
|
||||
int set_noise_filter(bcm_t bcm, unsigned steady, unsigned active )
|
||||
{
|
||||
return get_instance().set_noise_filter( bcm, steady, active );
|
||||
}
|
||||
|
||||
|
||||
// bcm operations
|
||||
int get_level( bcm_t bcm )
|
||||
{
|
||||
return get_instance().get_level( bcm );
|
||||
}
|
||||
|
||||
|
||||
int set_level( bcm_t bcm , level_t level )
|
||||
{
|
||||
return get_instance().set_level( bcm, level );
|
||||
}
|
||||
|
||||
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen )
|
||||
{
|
||||
return get_instance().trigger_level( bcm, pulseLen, level );
|
||||
}
|
||||
|
||||
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout )
|
||||
{
|
||||
return get_instance().wait_for_edge( bcm, edge, timeout );
|
||||
}
|
||||
|
||||
// reality interface
|
||||
int set_callback( bcm_t bcm, pigCall* fn, edge_t edge )
|
||||
{
|
||||
return get_instance().set_callback( bcm, fn, edge );
|
||||
}
|
||||
|
||||
|
||||
int cancel_callback( int cbId )
|
||||
{
|
||||
return get_instance().cancel_callback( cbId );
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().i2c_open( i2c );
|
||||
}
|
||||
|
||||
int i2c_close( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().i2c_close( i2c );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
*/
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().i2c_write_device( i2c, buf, count );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
int i2c_read_byte( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal)
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_block_process_call( pigI2C& i2c, unsigned i2c_reg, char* buf, unsigned count )
|
||||
{
|
||||
get_instance().i2c_block_process_call();
|
||||
}
|
||||
|
||||
int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
|
||||
{
|
||||
get_instance().i2c_zip( i2c, inBuf, inLen, outBuf, outLen );
|
||||
}
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, unsigned PWMfreq, uint32_t PWMduty )
|
||||
{
|
||||
return get_instance().hardware_PWM( bcm, PWMfreq, PWMduty );
|
||||
}
|
||||
|
||||
|
||||
int hardware_clock( bcm_t bcm, unsigned clkfreq )
|
||||
{
|
||||
return get_instance().hardware_clock( bcm, clkfreq );
|
||||
}
|
||||
|
||||
uint32_t get_current_tick()
|
||||
{
|
||||
return get_instance().get_current_tick();
|
||||
}
|
||||
|
||||
void show_error( const std::string& msg )
|
||||
{
|
||||
std::cout << "error: " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void show_hint( const std::string& msg )
|
||||
{
|
||||
std::cout << "hint: " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// timers
|
||||
///
|
||||
|
||||
void delay_seconds( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void delay_millis( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void delay_micros( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::microseconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void wait_loop()
|
||||
{
|
||||
while( true )
|
||||
delay_seconds( 10 );
|
||||
}
|
||||
|
||||
|
||||
// void trigger( int pi, unsigned gpio, unsigned level, uint32_t tick, void *user )
|
||||
void trigger( int, unsigned bcm, unsigned level, uint32_t, void *user )
|
||||
{
|
||||
/// Need a static callback to link with C.
|
||||
pigCall* receiver = static_cast<pigCall*>( user );
|
||||
if( receiver )
|
||||
receiver->trigger( (bcm_t) bcm, level ); /// Call the get_instance callback.
|
||||
else
|
||||
std::cout << "-- ONPULSE FAIL" << (uint32_t) bcm << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void greet()
|
||||
{
|
||||
std::cout << "lib:\t" << pigpio::Version << std::endl;
|
||||
std::cout << "gpio:\t" << get_instance().get_pigpio_version() << std::endl;
|
||||
std::cout << "hw rev:\t" << get_instance().get_hardware_revision() << std::endl;
|
||||
std::cout << "deamon:\t" << get_instance().pigpiod_if_version() << std::endl;
|
||||
std::cout << "\n" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int show_error( int error )
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
} // namespace pigpio
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigpin.h>
|
||||
#include <pignode.h>
|
||||
|
||||
#include <libpigwindows.h>
|
||||
#include <libpiglinux.h>
|
||||
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
pigCore& get_instance()
|
||||
{
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
static pigLinux _Instance; // guaranteed to be destroyed.
|
||||
#endif //Q_OS_LINUX
|
||||
#ifdef _WIN32
|
||||
static pigWindows _Instance; //guaranteed to be destroyed.
|
||||
#endif // _WIN32
|
||||
return _Instance;
|
||||
}
|
||||
|
||||
// bcm config
|
||||
int set_io_mode( bcm_t bcm, io_t mode )
|
||||
{
|
||||
return get_instance().set_io_mode( bcm, mode );
|
||||
}
|
||||
|
||||
|
||||
int get_io_mode( bcm_t bcm )
|
||||
{
|
||||
return get_instance().get_io_mode( bcm );
|
||||
}
|
||||
|
||||
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud )
|
||||
{
|
||||
return get_instance().set_pud_mode( bcm, pud );
|
||||
}
|
||||
|
||||
|
||||
int set_glitch_filter(bcm_t bcm, uint32_t glitch )
|
||||
{
|
||||
return get_instance().set_glitch_filter( bcm, glitch );
|
||||
}
|
||||
|
||||
|
||||
int set_noise_filter(bcm_t bcm, unsigned steady, unsigned active )
|
||||
{
|
||||
return get_instance().set_noise_filter( bcm, steady, active );
|
||||
}
|
||||
|
||||
|
||||
// bcm operations
|
||||
int get_level( bcm_t bcm )
|
||||
{
|
||||
return get_instance().get_level( bcm );
|
||||
}
|
||||
|
||||
|
||||
int set_level( bcm_t bcm , level_t level )
|
||||
{
|
||||
return get_instance().set_level( bcm, level );
|
||||
}
|
||||
|
||||
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen )
|
||||
{
|
||||
return get_instance().trigger_level( bcm, pulseLen, level );
|
||||
}
|
||||
|
||||
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout )
|
||||
{
|
||||
return get_instance().wait_for_edge( bcm, edge, timeout );
|
||||
}
|
||||
|
||||
// reality interface
|
||||
int set_callback( bcm_t bcm, pigCall* fn, edge_t edge )
|
||||
{
|
||||
return get_instance().set_callback( bcm, fn, edge );
|
||||
}
|
||||
|
||||
|
||||
int cancel_callback( int cbId )
|
||||
{
|
||||
return get_instance().cancel_callback( cbId );
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().i2c_open( i2c );
|
||||
}
|
||||
|
||||
int i2c_close( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().i2c_close( i2c );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
*/
|
||||
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().i2c_write_device( i2c, buf, count );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
int i2c_read_byte( pigI2C& i2c )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal)
|
||||
{
|
||||
return get_instance().
|
||||
}
|
||||
|
||||
int i2c_block_process_call( pigI2C& i2c, unsigned i2c_reg, char* buf, unsigned count )
|
||||
{
|
||||
get_instance().i2c_block_process_call();
|
||||
}
|
||||
|
||||
int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
|
||||
{
|
||||
get_instance().i2c_zip( i2c, inBuf, inLen, outBuf, outLen );
|
||||
}
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, unsigned PWMfreq, uint32_t PWMduty )
|
||||
{
|
||||
return get_instance().hardware_PWM( bcm, PWMfreq, PWMduty );
|
||||
}
|
||||
|
||||
|
||||
int hardware_clock( bcm_t bcm, unsigned clkfreq )
|
||||
{
|
||||
return get_instance().hardware_clock( bcm, clkfreq );
|
||||
}
|
||||
|
||||
uint32_t get_current_tick()
|
||||
{
|
||||
return get_instance().get_current_tick();
|
||||
}
|
||||
|
||||
void show_error( const std::string& msg )
|
||||
{
|
||||
std::cout << "error: " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void show_hint( const std::string& msg )
|
||||
{
|
||||
std::cout << "hint: " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// timers
|
||||
///
|
||||
|
||||
void delay_seconds( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void delay_millis( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void delay_micros( uint32_t tval )
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::microseconds( tval ) );
|
||||
}
|
||||
|
||||
|
||||
void wait_loop()
|
||||
{
|
||||
while( true )
|
||||
delay_seconds( 10 );
|
||||
}
|
||||
|
||||
|
||||
// void trigger( int pi, unsigned gpio, unsigned level, uint32_t tick, void *user )
|
||||
void trigger( int, unsigned bcm, unsigned level, uint32_t, void *user )
|
||||
{
|
||||
/// Need a static callback to link with C.
|
||||
pigCall* receiver = static_cast<pigCall*>( user );
|
||||
if( receiver )
|
||||
receiver->trigger( (bcm_t) bcm, level ); /// Call the get_instance callback.
|
||||
else
|
||||
std::cout << "-- ONPULSE FAIL" << (uint32_t) bcm << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void greet()
|
||||
{
|
||||
std::cout << "lib:\t" << pigpio::Version << std::endl;
|
||||
std::cout << "gpio:\t" << get_instance().get_pigpio_version() << std::endl;
|
||||
std::cout << "hw rev:\t" << get_instance().get_hardware_revision() << std::endl;
|
||||
std::cout << "deamon:\t" << get_instance().pigpiod_if_version() << std::endl;
|
||||
std::cout << "\n" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
int show_error( int error )
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
} // namespace pigpio
|
||||
|
743
libpigpio.h
743
libpigpio.h
@@ -1,373 +1,370 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGPIO_H
|
||||
#define LIBPIGPIO_H
|
||||
|
||||
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define Q_DECL_EXPORT __attribute__((visibility("default")))
|
||||
# define Q_DECL_IMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if defined(LIBPIGPIO_LIBRARY)
|
||||
# define LIBPIGPIO_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define LIBPIGPIO_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <signal.hpp>
|
||||
#include <time.h>
|
||||
|
||||
struct pigI2C;
|
||||
class pigCall;
|
||||
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
class pigCore;
|
||||
|
||||
[[maybe_unused]] const int GlitchDef = 500;
|
||||
[[maybe_unused]] const double TimeoutDef = 0.2;
|
||||
|
||||
enum class edge_t : uint32_t
|
||||
{
|
||||
rising = 0,
|
||||
falling = 1,
|
||||
either = 2,
|
||||
edge_off = 99
|
||||
};
|
||||
|
||||
enum class io_t : uint32_t
|
||||
{
|
||||
input = 0,
|
||||
output = 1,
|
||||
io_off = 99
|
||||
};
|
||||
|
||||
enum class bcm_t : uint32_t
|
||||
{
|
||||
/// left side, pin 1,3 ... 39
|
||||
|
||||
bcm02 = 2,
|
||||
bcm03 = 3,
|
||||
bcm04 = 4,
|
||||
|
||||
bcm17 = 17,
|
||||
bcm27 = 27,
|
||||
bcm22 = 22,
|
||||
|
||||
bcm10 = 10,
|
||||
bcm09 = 9,
|
||||
bcm11 = 11,
|
||||
|
||||
bcm05 = 5,
|
||||
bcm06 = 6,
|
||||
bcm13 = 7,
|
||||
|
||||
bcm19 = 19,
|
||||
bcm26 = 9,
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
|
||||
bcm14 = 14,
|
||||
bcm15 = 15,
|
||||
bcm18 = 18,
|
||||
|
||||
bcm23 = 23,
|
||||
bcm24 = 24,
|
||||
|
||||
bcm25 = 25,
|
||||
bcm08 = 8,
|
||||
bcm07 = 07,
|
||||
|
||||
bcm12 = 12,
|
||||
|
||||
bcm16 = 16,
|
||||
bcm20 = 20,
|
||||
bcm21 = 21,
|
||||
|
||||
bcm_off = 99
|
||||
|
||||
};
|
||||
|
||||
enum class pud_t : uint32_t
|
||||
{
|
||||
pull_off = 0,
|
||||
pull_down = 1,
|
||||
pull_up = 2,
|
||||
};
|
||||
|
||||
|
||||
using level_t = uint32_t;
|
||||
|
||||
///
|
||||
/// i2c
|
||||
///
|
||||
|
||||
using i2c_bus_t = uint32_t; // uint8_t ??
|
||||
using i2c_addr_t = uint32_t;
|
||||
using i2c_flag_t = uint32_t;
|
||||
|
||||
/// sugar
|
||||
[[maybe_unused]] constexpr static edge_t rising = edge_t::rising;
|
||||
[[maybe_unused]] constexpr static edge_t falling = edge_t::falling;
|
||||
[[maybe_unused]] constexpr static edge_t either = edge_t::either;
|
||||
|
||||
///---
|
||||
|
||||
[[maybe_unused]] constexpr static io_t input = io_t::input;
|
||||
[[maybe_unused]] constexpr static io_t output = io_t::output;
|
||||
|
||||
///---
|
||||
|
||||
[[maybe_unused]] constexpr static pud_t pull_off = pud_t::pull_off;
|
||||
[[maybe_unused]] constexpr static pud_t pull_down = pud_t::pull_down;
|
||||
[[maybe_unused]] constexpr static pud_t pull_up = pud_t::pull_up;
|
||||
|
||||
///---
|
||||
|
||||
/// left side, pin 1,3 ... 39
|
||||
[[maybe_unused]] constexpr static bcm_t bcm02 = bcm_t::bcm02;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm03 = bcm_t::bcm03;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm04 = bcm_t::bcm04;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm17 = bcm_t::bcm17;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm27 = bcm_t::bcm27;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm22 = bcm_t::bcm22;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm10 = bcm_t::bcm10;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm09 = bcm_t::bcm09;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm11 = bcm_t::bcm11;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm05 = bcm_t::bcm05;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm06 = bcm_t::bcm06;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm13 = bcm_t::bcm07;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm19 = bcm_t::bcm19;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm26 = bcm_t::bcm09;
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
[[maybe_unused]] constexpr static bcm_t bcm14 = bcm_t::bcm04;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm15 = bcm_t::bcm15;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm18 = bcm_t::bcm18;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm23 = bcm_t::bcm23;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm24 = bcm_t::bcm24;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm25 = bcm_t::bcm25;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm08 = bcm_t::bcm08;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm07 = bcm_t::bcm07;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm12 = bcm_t::bcm12;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm16 = bcm_t::bcm16;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm20 = bcm_t::bcm20;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm21 = bcm_t::bcm21;
|
||||
|
||||
/// more sugar
|
||||
|
||||
/// left side, pin 1,3 ... 39
|
||||
[[maybe_unused]] constexpr static bcm_t pin03 = bcm_t::bcm02;
|
||||
[[maybe_unused]] constexpr static bcm_t pin05 = bcm_t::bcm03;
|
||||
[[maybe_unused]] constexpr static bcm_t pin07 = bcm_t::bcm04;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin11 = bcm_t::bcm17;
|
||||
[[maybe_unused]] constexpr static bcm_t pin13 = bcm_t::bcm27;
|
||||
[[maybe_unused]] constexpr static bcm_t pin15 = bcm_t::bcm22;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin19 = bcm_t::bcm10;
|
||||
[[maybe_unused]] constexpr static bcm_t pin21 = bcm_t::bcm09;
|
||||
[[maybe_unused]] constexpr static bcm_t pin23 = bcm_t::bcm11;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin29 = bcm_t::bcm05;
|
||||
[[maybe_unused]] constexpr static bcm_t pin31 = bcm_t::bcm06;
|
||||
[[maybe_unused]] constexpr static bcm_t pin33 = bcm_t::bcm13;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin35 = bcm_t::bcm19;
|
||||
[[maybe_unused]] constexpr static bcm_t pin37 = bcm_t::bcm26;
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
[[maybe_unused]] constexpr static bcm_t pin08 = bcm_t::bcm14;
|
||||
[[maybe_unused]] constexpr static bcm_t pin10 = bcm_t::bcm15;
|
||||
[[maybe_unused]] constexpr static bcm_t pin12 = bcm_t::bcm18;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin16 = bcm_t::bcm23;
|
||||
[[maybe_unused]] constexpr static bcm_t pin18 = bcm_t::bcm24;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin22 = bcm_t::bcm25;
|
||||
[[maybe_unused]] constexpr static bcm_t pin24 = bcm_t::bcm08;
|
||||
[[maybe_unused]] constexpr static bcm_t pin26 = bcm_t::bcm07;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin32 = bcm_t::bcm12;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin36 = bcm_t::bcm16;
|
||||
[[maybe_unused]] constexpr static bcm_t pin38 = bcm_t::bcm20;
|
||||
[[maybe_unused]] constexpr static bcm_t pin40 = bcm_t::bcm21;
|
||||
|
||||
/*
|
||||
|
||||
GPIO pin pin GPIO
|
||||
3V3 1 2 5V
|
||||
2 (SDA) 3 4 5V
|
||||
3 (SCL) 5 6 0V
|
||||
4 7 8 14 (TXD)
|
||||
0V 9 10 15 (RXD)
|
||||
17 (ce1) 11 12 18 (ce0)
|
||||
27 13 14 0V
|
||||
22 15 16 23
|
||||
3V3 17 18 24
|
||||
10 (MOSI) 19 20 0V
|
||||
9 (MISO) 21 22 25
|
||||
11 (SCLK) 23 24 8 (CE0)
|
||||
0V 25 26 7 (CE1)
|
||||
.......
|
||||
0 (ID_SD) 27 28 1 (ID_SC)
|
||||
5 29 30 0V
|
||||
6 31 32 12
|
||||
13 33 34 0V
|
||||
19 (miso) 35 36 16 (ce2)
|
||||
26 37 38 20 (mosi)
|
||||
0V 39 40 21 (sclk)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// fragwürdig
|
||||
[[maybe_unused]] constexpr static level_t low = 0;
|
||||
[[maybe_unused]] constexpr static level_t high = 1;
|
||||
|
||||
[[maybe_unused]] constexpr static level_t off = 0;
|
||||
[[maybe_unused]] constexpr static level_t on = 1;
|
||||
|
||||
|
||||
//map<bcm> -> pin
|
||||
// op<
|
||||
|
||||
[[maybe_unused]] constexpr static uint32_t TimeOut = 2;
|
||||
[[maybe_unused]] constexpr static const char* Version = "libPiGPIO 0.1.27 / 16.09.2022 2022 chris@sourceworx.org";
|
||||
|
||||
|
||||
LIBPIGPIO_EXPORT pigCore& get_instance();
|
||||
|
||||
LIBPIGPIO_EXPORT int init( const std::string& host ="" , const std::string& port="" );
|
||||
|
||||
// pin config
|
||||
LIBPIGPIO_EXPORT int get_io_mode( bcm_t bcm );
|
||||
LIBPIGPIO_EXPORT int set_io_mode( bcm_t bcm, io_t mode );
|
||||
LIBPIGPIO_EXPORT int set_pud_mode( bcm_t bcm, pud_t pud );
|
||||
LIBPIGPIO_EXPORT int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef );
|
||||
LIBPIGPIO_EXPORT int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) ;
|
||||
|
||||
// pin operations
|
||||
LIBPIGPIO_EXPORT int get_level( bcm_t bcm );
|
||||
LIBPIGPIO_EXPORT int set_level( bcm_t bcm, level_t level ) ;
|
||||
LIBPIGPIO_EXPORT int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen );
|
||||
LIBPIGPIO_EXPORT int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef );
|
||||
|
||||
// reality interface
|
||||
LIBPIGPIO_EXPORT int set_callback( bcm_t bcm, pigCall* fn, edge_t edge );
|
||||
LIBPIGPIO_EXPORT int cancel_callback( int cbId );
|
||||
|
||||
// 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
|
||||
LIBPIGPIO_EXPORT int i2c_open( pigI2C& i2c );
|
||||
LIBPIGPIO_EXPORT int i2c_close( pigI2C& i2c );
|
||||
/*
|
||||
LIBPIGPIO_EXPORT int i2c_write_quick( pigI2C& i2c, uint32_t bit );
|
||||
LIBPIGPIO_EXPORT int i2c_write_byte( pigI2C& i2c, uint32_t bVal );
|
||||
LIBPIGPIO_EXPORT int i2c_write_byte_data( pigI2C& i2c, uint32_t reg, uint32_t val );
|
||||
LIBPIGPIO_EXPORT int i2c_write_word_data( pigI2C& i2c, uint32_t reg, uint32_t val );
|
||||
LIBPIGPIO_EXPORT int i2c_write_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_write_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
*/
|
||||
LIBPIGPIO_EXPORT int i2c_write_device( pigI2C& i2c, char* buf, uint32_t count );
|
||||
/*
|
||||
LIBPIGPIO_EXPORT int i2c_read_byte( pigI2C& i2c );
|
||||
LIBPIGPIO_EXPORT int i2c_read_byte_data( pigI2C& i2c, uint32_t reg );
|
||||
LIBPIGPIO_EXPORT int i2c_read_word_data( pigI2C& i2c, uint32_t reg );
|
||||
LIBPIGPIO_EXPORT int i2c_read_block_data( pigI2C& i2c, uint32_t reg, char* buf );
|
||||
LIBPIGPIO_EXPORT int i2c_read_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_read_device( pigI2C& i2c, char* buf, uint32_t count );
|
||||
|
||||
LIBPIGPIO_EXPORT int i2c_process_call( pigI2C& i2c, uint32_t i2c_reg, uint32_t wVal);
|
||||
LIBPIGPIO_EXPORT int i2c_block_process_call( pigI2C& i2c, uint32_t i2c_reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_zip( pigI2C& i2c, char *inBuf, uint32_t inLen, char *outBuf, uint32_t outLen );
|
||||
*/
|
||||
|
||||
// advanced
|
||||
LIBPIGPIO_EXPORT int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) ;
|
||||
LIBPIGPIO_EXPORT int hardware_clock( bcm_t bcm, uint32_t clkfreq );
|
||||
LIBPIGPIO_EXPORT uint32_t get_current_tick();
|
||||
|
||||
// finally
|
||||
//LIBPIGPIO_EXPORT void trigger( int pi, bcm_t pin, level_t level, uint32_t tick, void *user );
|
||||
LIBPIGPIO_EXPORT void trigger( int pi, unsigned bcm, unsigned level, uint32_t tick, void *user );
|
||||
LIBPIGPIO_EXPORT void greet();
|
||||
LIBPIGPIO_EXPORT void wait_loop();
|
||||
|
||||
// timer
|
||||
LIBPIGPIO_EXPORT void delay_seconds( uint32_t );
|
||||
LIBPIGPIO_EXPORT void delay_millis( uint32_t );
|
||||
LIBPIGPIO_EXPORT void delay_micros( uint32_t );
|
||||
|
||||
// util
|
||||
template< typename T >
|
||||
LIBPIGPIO_EXPORT std::string val2str( T value, int fixed=2 )
|
||||
{
|
||||
std::ostringstream sout;
|
||||
sout << std::fixed << std::setprecision( fixed );
|
||||
sout << value;
|
||||
return sout.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
using signalBool = sigslot::signal<bool>;
|
||||
using signalInt = sigslot::signal<int>;
|
||||
using signalFloat = sigslot::signal<double>;
|
||||
|
||||
|
||||
#endif // LIBPIGPIO_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGPIO_H
|
||||
#define LIBPIGPIO_H
|
||||
|
||||
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define Q_DECL_EXPORT __attribute__((visibility("default")))
|
||||
# define Q_DECL_IMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if defined(LIBPIGPIO_LIBRARY)
|
||||
# define LIBPIGPIO_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define LIBPIGPIO_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <signal.hpp>
|
||||
|
||||
struct pigI2C;
|
||||
class pigCall;
|
||||
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
class pigCore;
|
||||
|
||||
[[maybe_unused]] const int GlitchDef = 500;
|
||||
[[maybe_unused]] const double TimeoutDef = 0.2;
|
||||
|
||||
enum class edge_t : uint32_t
|
||||
{
|
||||
rising = 0,
|
||||
falling = 1,
|
||||
either = 2,
|
||||
edge_off = 99
|
||||
};
|
||||
|
||||
enum class io_t : uint32_t
|
||||
{
|
||||
input = 0,
|
||||
output = 1,
|
||||
io_off = 99
|
||||
};
|
||||
|
||||
enum class bcm_t : uint32_t
|
||||
{
|
||||
/// left side, pin 1,3 ... 39
|
||||
|
||||
bcm02 = 2,
|
||||
bcm03 = 3,
|
||||
bcm04 = 4,
|
||||
|
||||
bcm17 = 17,
|
||||
bcm27 = 27,
|
||||
bcm22 = 22,
|
||||
|
||||
bcm10 = 10,
|
||||
bcm09 = 9,
|
||||
bcm11 = 11,
|
||||
|
||||
bcm05 = 5,
|
||||
bcm06 = 6,
|
||||
bcm13 = 13,
|
||||
|
||||
bcm19 = 19,
|
||||
bcm26 = 26,
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
|
||||
bcm14 = 14,
|
||||
bcm15 = 15,
|
||||
bcm18 = 18,
|
||||
|
||||
bcm23 = 23,
|
||||
bcm24 = 24,
|
||||
|
||||
bcm25 = 25,
|
||||
bcm08 = 8,
|
||||
bcm07 = 7,
|
||||
|
||||
bcm12 = 12,
|
||||
|
||||
bcm16 = 16,
|
||||
bcm20 = 20,
|
||||
bcm21 = 21,
|
||||
|
||||
bcm_off = 99
|
||||
|
||||
};
|
||||
|
||||
enum class pud_t : uint32_t
|
||||
{
|
||||
pull_off = 0,
|
||||
pull_down = 1,
|
||||
pull_up = 2,
|
||||
};
|
||||
|
||||
|
||||
using level_t = uint32_t;
|
||||
|
||||
///
|
||||
/// i2c
|
||||
///
|
||||
|
||||
using i2c_bus_t = uint32_t; // uint8_t ??
|
||||
using i2c_addr_t = uint32_t;
|
||||
using i2c_flag_t = uint32_t;
|
||||
|
||||
/// sugar
|
||||
[[maybe_unused]] constexpr static edge_t rising = edge_t::rising;
|
||||
[[maybe_unused]] constexpr static edge_t falling = edge_t::falling;
|
||||
[[maybe_unused]] constexpr static edge_t either = edge_t::either;
|
||||
|
||||
///---
|
||||
|
||||
[[maybe_unused]] constexpr static io_t input = io_t::input;
|
||||
[[maybe_unused]] constexpr static io_t output = io_t::output;
|
||||
|
||||
///---
|
||||
|
||||
[[maybe_unused]] constexpr static pud_t pull_off = pud_t::pull_off;
|
||||
[[maybe_unused]] constexpr static pud_t pull_down = pud_t::pull_down;
|
||||
[[maybe_unused]] constexpr static pud_t pull_up = pud_t::pull_up;
|
||||
|
||||
///---
|
||||
|
||||
/// left side, pin 1,3 ... 39
|
||||
[[maybe_unused]] constexpr static bcm_t bcm02 = bcm_t::bcm02;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm03 = bcm_t::bcm03;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm04 = bcm_t::bcm04;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm17 = bcm_t::bcm17;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm27 = bcm_t::bcm27;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm22 = bcm_t::bcm22;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm10 = bcm_t::bcm10;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm09 = bcm_t::bcm09;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm11 = bcm_t::bcm11;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm05 = bcm_t::bcm05;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm06 = bcm_t::bcm06;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm13 = bcm_t::bcm13;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm19 = bcm_t::bcm19;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm26 = bcm_t::bcm26;
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
[[maybe_unused]] constexpr static bcm_t bcm14 = bcm_t::bcm14;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm15 = bcm_t::bcm15;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm18 = bcm_t::bcm18;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm23 = bcm_t::bcm23;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm24 = bcm_t::bcm24;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm25 = bcm_t::bcm25;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm08 = bcm_t::bcm08;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm07 = bcm_t::bcm07;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm12 = bcm_t::bcm12;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t bcm16 = bcm_t::bcm16;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm20 = bcm_t::bcm20;
|
||||
[[maybe_unused]] constexpr static bcm_t bcm21 = bcm_t::bcm21;
|
||||
|
||||
/// more sugar
|
||||
|
||||
/// left side, pin 1,3 ... 39
|
||||
[[maybe_unused]] constexpr static bcm_t pin03 = bcm_t::bcm02;
|
||||
[[maybe_unused]] constexpr static bcm_t pin05 = bcm_t::bcm03;
|
||||
[[maybe_unused]] constexpr static bcm_t pin07 = bcm_t::bcm04;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin11 = bcm_t::bcm17;
|
||||
[[maybe_unused]] constexpr static bcm_t pin13 = bcm_t::bcm27;
|
||||
[[maybe_unused]] constexpr static bcm_t pin15 = bcm_t::bcm22;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin19 = bcm_t::bcm10;
|
||||
[[maybe_unused]] constexpr static bcm_t pin21 = bcm_t::bcm09;
|
||||
[[maybe_unused]] constexpr static bcm_t pin23 = bcm_t::bcm11;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin29 = bcm_t::bcm05;
|
||||
[[maybe_unused]] constexpr static bcm_t pin31 = bcm_t::bcm06;
|
||||
[[maybe_unused]] constexpr static bcm_t pin33 = bcm_t::bcm13;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin35 = bcm_t::bcm19;
|
||||
[[maybe_unused]] constexpr static bcm_t pin37 = bcm_t::bcm26;
|
||||
|
||||
/// right side, pin 2,4 .. 40
|
||||
[[maybe_unused]] constexpr static bcm_t pin08 = bcm_t::bcm14;
|
||||
[[maybe_unused]] constexpr static bcm_t pin10 = bcm_t::bcm15;
|
||||
[[maybe_unused]] constexpr static bcm_t pin12 = bcm_t::bcm18;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin16 = bcm_t::bcm23;
|
||||
[[maybe_unused]] constexpr static bcm_t pin18 = bcm_t::bcm24;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin22 = bcm_t::bcm25;
|
||||
[[maybe_unused]] constexpr static bcm_t pin24 = bcm_t::bcm08;
|
||||
[[maybe_unused]] constexpr static bcm_t pin26 = bcm_t::bcm07;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin32 = bcm_t::bcm12;
|
||||
|
||||
[[maybe_unused]] constexpr static bcm_t pin36 = bcm_t::bcm16;
|
||||
[[maybe_unused]] constexpr static bcm_t pin38 = bcm_t::bcm20;
|
||||
[[maybe_unused]] constexpr static bcm_t pin40 = bcm_t::bcm21;
|
||||
|
||||
/*
|
||||
|
||||
GPIO pin pin GPIO
|
||||
3V3 1 2 5V
|
||||
2 (SDA) 3 4 5V
|
||||
3 (SCL) 5 6 0V
|
||||
4 7 8 14 (TXD)
|
||||
0V 9 10 15 (RXD)
|
||||
17 (ce1) 11 12 18 (ce0)
|
||||
27 13 14 0V
|
||||
22 15 16 23
|
||||
3V3 17 18 24
|
||||
10 (MOSI) 19 20 0V
|
||||
9 (MISO) 21 22 25
|
||||
11 (SCLK) 23 24 8 (CE0)
|
||||
0V 25 26 7 (CE1)
|
||||
.......
|
||||
0 (ID_SD) 27 28 1 (ID_SC)
|
||||
5 29 30 0V
|
||||
6 31 32 12
|
||||
13 33 34 0V
|
||||
19 (miso) 35 36 16 (ce2)
|
||||
26 37 38 20 (mosi)
|
||||
0V 39 40 21 (sclk)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// fragwürdig
|
||||
[[maybe_unused]] constexpr static level_t low = 0;
|
||||
[[maybe_unused]] constexpr static level_t high = 1;
|
||||
|
||||
[[maybe_unused]] constexpr static level_t off = 0;
|
||||
[[maybe_unused]] constexpr static level_t on = 1;
|
||||
|
||||
|
||||
//map<bcm> -> pin
|
||||
// op<
|
||||
|
||||
[[maybe_unused]] constexpr static uint32_t TimeOut = 2;
|
||||
[[maybe_unused]] constexpr static const char* Version = "libPiGPIO 0.1.27 / 16.09.2022 2022 chris@sourceworx.org";
|
||||
|
||||
|
||||
LIBPIGPIO_EXPORT pigCore& get_instance();
|
||||
|
||||
LIBPIGPIO_EXPORT int init( const std::string& host ="" , const std::string& port="" );
|
||||
|
||||
// pin config
|
||||
LIBPIGPIO_EXPORT int get_io_mode( bcm_t bcm );
|
||||
LIBPIGPIO_EXPORT int set_io_mode( bcm_t bcm, io_t mode );
|
||||
LIBPIGPIO_EXPORT int set_pud_mode( bcm_t bcm, pud_t pud );
|
||||
LIBPIGPIO_EXPORT int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef );
|
||||
LIBPIGPIO_EXPORT int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) ;
|
||||
|
||||
// pin operations
|
||||
LIBPIGPIO_EXPORT int get_level( bcm_t bcm );
|
||||
LIBPIGPIO_EXPORT int set_level( bcm_t bcm, level_t level ) ;
|
||||
LIBPIGPIO_EXPORT int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen );
|
||||
LIBPIGPIO_EXPORT int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef );
|
||||
|
||||
// reality interface
|
||||
LIBPIGPIO_EXPORT int set_callback( bcm_t bcm, pigCall* fn, edge_t edge );
|
||||
LIBPIGPIO_EXPORT int cancel_callback( int cbId );
|
||||
|
||||
// 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
|
||||
LIBPIGPIO_EXPORT int i2c_open( pigI2C& i2c );
|
||||
LIBPIGPIO_EXPORT int i2c_close( pigI2C& i2c );
|
||||
/*
|
||||
LIBPIGPIO_EXPORT int i2c_write_quick( pigI2C& i2c, uint32_t bit );
|
||||
LIBPIGPIO_EXPORT int i2c_write_byte( pigI2C& i2c, uint32_t bVal );
|
||||
LIBPIGPIO_EXPORT int i2c_write_byte_data( pigI2C& i2c, uint32_t reg, uint32_t val );
|
||||
LIBPIGPIO_EXPORT int i2c_write_word_data( pigI2C& i2c, uint32_t reg, uint32_t val );
|
||||
LIBPIGPIO_EXPORT int i2c_write_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_write_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
*/
|
||||
LIBPIGPIO_EXPORT int i2c_write_device( pigI2C& i2c, char* buf, uint32_t count );
|
||||
/*
|
||||
LIBPIGPIO_EXPORT int i2c_read_byte( pigI2C& i2c );
|
||||
LIBPIGPIO_EXPORT int i2c_read_byte_data( pigI2C& i2c, uint32_t reg );
|
||||
LIBPIGPIO_EXPORT int i2c_read_word_data( pigI2C& i2c, uint32_t reg );
|
||||
LIBPIGPIO_EXPORT int i2c_read_block_data( pigI2C& i2c, uint32_t reg, char* buf );
|
||||
LIBPIGPIO_EXPORT int i2c_read_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_read_device( pigI2C& i2c, char* buf, uint32_t count );
|
||||
|
||||
LIBPIGPIO_EXPORT int i2c_process_call( pigI2C& i2c, uint32_t i2c_reg, uint32_t wVal);
|
||||
LIBPIGPIO_EXPORT int i2c_block_process_call( pigI2C& i2c, uint32_t i2c_reg, char* buf, uint32_t count );
|
||||
LIBPIGPIO_EXPORT int i2c_zip( pigI2C& i2c, char *inBuf, uint32_t inLen, char *outBuf, uint32_t outLen );
|
||||
*/
|
||||
|
||||
// advanced
|
||||
LIBPIGPIO_EXPORT int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) ;
|
||||
LIBPIGPIO_EXPORT int hardware_clock( bcm_t bcm, uint32_t clkfreq );
|
||||
LIBPIGPIO_EXPORT uint32_t get_current_tick();
|
||||
|
||||
// finally
|
||||
//LIBPIGPIO_EXPORT void trigger( int pi, bcm_t pin, level_t level, uint32_t tick, void *user );
|
||||
LIBPIGPIO_EXPORT void trigger( int pi, unsigned bcm, unsigned level, uint32_t tick, void *user );
|
||||
LIBPIGPIO_EXPORT void greet();
|
||||
LIBPIGPIO_EXPORT void wait_loop();
|
||||
|
||||
// timer
|
||||
LIBPIGPIO_EXPORT void delay_seconds( uint32_t );
|
||||
LIBPIGPIO_EXPORT void delay_millis( uint32_t );
|
||||
LIBPIGPIO_EXPORT void delay_micros( uint32_t );
|
||||
|
||||
// util
|
||||
template< typename T >
|
||||
LIBPIGPIO_EXPORT std::string val2str( T value, int fixed=2 )
|
||||
{
|
||||
std::ostringstream sout;
|
||||
sout << std::fixed << std::setprecision( fixed );
|
||||
sout << value;
|
||||
return sout.str();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
using signalBool = sigslot::signal<bool>;
|
||||
using signalInt = sigslot::signal<int>;
|
||||
using signalFloat = sigslot::signal<double>;
|
||||
|
||||
|
||||
#endif // LIBPIGPIO_H
|
||||
|
@@ -1,301 +1,301 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <libpigwindows.h>
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
|
||||
int pigWindows::init( const std::string& , const std::string& )
|
||||
{
|
||||
//::gpioInitialise();
|
||||
return 42;
|
||||
}
|
||||
//
|
||||
// pin config
|
||||
//
|
||||
|
||||
int pigWindows::set_io_mode( bcm_t, io_t )
|
||||
{
|
||||
//::set_io_mode( _Pi, pin.bcm, pin.mode );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::get_io_mode( bcm_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::set_pud_mode( bcm_t, pud_t )
|
||||
{
|
||||
//::set_pud_mode( _Pi, pin.bcm, pin.pud );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::set_glitch_filter( bcm_t, uint32_t )
|
||||
{
|
||||
// ::set_glitch_filter( _Pi, pin.bcm, glitch );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Sets a noise filter on a GPIO.
|
||||
int pigWindows::set_noise_filter( bcm_t, uint32_t, uint32_t )
|
||||
{
|
||||
//int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin operations
|
||||
///
|
||||
|
||||
int pigWindows::get_level( bcm_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::set_level( bcm_t, level_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::wait_for_edge( bcm_t, edge_t, double )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
|
||||
int pigWindows::trigger_level( bcm_t, level_t, uint32_t )
|
||||
{
|
||||
//int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// interface
|
||||
///
|
||||
|
||||
int pigWindows::set_callback( bcm_t, pigCall*, edge_t )
|
||||
{
|
||||
//::callback_ex( _Pi, pin.bcm, pin.edge, &pigNode::trigger, (void*) &widget );
|
||||
//pin.cbId = ::callback_ex( _Pi, pin.bcm, pin.edge, trigger, widget );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::cancel_callback( int )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ic2
|
||||
///
|
||||
|
||||
|
||||
int pigWindows::i2c_open( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_close( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigWindows::i2c_write_quick( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_byte( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_byte_data( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_word_data( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_block_data( pigI2C&, unsigned, char* buf, unsigned count )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_i2c_block_data( pigI2C&, unsigned, char* buf, unsigned count )
|
||||
{
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
int pigWindows::i2c_write_device( pigI2C&, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigWindows::i2c_read_byte( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_byte_data( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_word_data( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int pigWindows::i2c_read_block_data( pigI2C&, unsigned, char* )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_i2c_block_data( pigI2C&, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_read_device( pigI2C&, char* buf, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_process_call( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_block_process_call( pigI2C&, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_zip( pigI2C&, char*, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///
|
||||
/// advanced
|
||||
///
|
||||
|
||||
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
|
||||
int pigWindows::hardware_PWM( bcm_t, uint32_t, uint32_t )
|
||||
{
|
||||
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// convenience
|
||||
///
|
||||
|
||||
|
||||
int pigWindows::show_error( int error )
|
||||
{
|
||||
|
||||
std::cout << "Error: " << std::endl;
|
||||
return error;
|
||||
}
|
||||
|
||||
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
|
||||
int pigWindows::hardware_clock( bcm_t, uint32_t )
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pigWindows::get_current_tick()
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Get the Pi's hardware revision number.
|
||||
int pigWindows::get_hardware_revision()
|
||||
{
|
||||
//uint32_t get_hardware_revision(int pi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Returns the pigpio version.
|
||||
int pigWindows::get_pigpio_version()
|
||||
{
|
||||
//uint32_t get_pigpio_version(int pi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Return the pigpiod_if2 version.
|
||||
unsigned pigWindows::pigpiod_if_version()
|
||||
{
|
||||
//unsigned pigpiod_if_version(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <libpigwindows.h>
|
||||
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
|
||||
int pigWindows::init( const std::string& , const std::string& )
|
||||
{
|
||||
//::gpioInitialise();
|
||||
return 42;
|
||||
}
|
||||
//
|
||||
// pin config
|
||||
//
|
||||
|
||||
int pigWindows::set_io_mode( bcm_t, io_t )
|
||||
{
|
||||
//::set_io_mode( _Pi, pin.bcm, pin.mode );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::get_io_mode( bcm_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::set_pud_mode( bcm_t, pud_t )
|
||||
{
|
||||
//::set_pud_mode( _Pi, pin.bcm, pin.pud );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::set_glitch_filter( bcm_t, uint32_t )
|
||||
{
|
||||
// ::set_glitch_filter( _Pi, pin.bcm, glitch );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Sets a noise filter on a GPIO.
|
||||
int pigWindows::set_noise_filter( bcm_t, uint32_t, uint32_t )
|
||||
{
|
||||
//int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// pin operations
|
||||
///
|
||||
|
||||
int pigWindows::get_level( bcm_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::set_level( bcm_t, level_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::wait_for_edge( bcm_t, edge_t, double )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//This function sends a trigger pulse to a GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.
|
||||
int pigWindows::trigger_level( bcm_t, level_t, uint32_t )
|
||||
{
|
||||
//int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// interface
|
||||
///
|
||||
|
||||
int pigWindows::set_callback( bcm_t, pigCall*, edge_t )
|
||||
{
|
||||
//::callback_ex( _Pi, pin.bcm, pin.edge, &pigNode::trigger, (void*) &widget );
|
||||
//pin.cbId = ::callback_ex( _Pi, pin.bcm, pin.edge, trigger, widget );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::cancel_callback( int )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// ic2
|
||||
///
|
||||
|
||||
|
||||
int pigWindows::i2c_open( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_close( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigWindows::i2c_write_quick( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_byte( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_byte_data( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_word_data( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_block_data( pigI2C&, unsigned, char* buf, unsigned count )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_write_i2c_block_data( pigI2C&, unsigned, char* buf, unsigned count )
|
||||
{
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
int pigWindows::i2c_write_device( pigI2C&, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
int pigWindows::i2c_read_byte( pigI2C& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_byte_data( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_word_data( pigI2C&, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int pigWindows::i2c_read_block_data( pigI2C&, unsigned, char* )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_read_i2c_block_data( pigI2C&, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_read_device( pigI2C&, char* buf, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pigWindows::i2c_process_call( pigI2C&, unsigned, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_block_process_call( pigI2C&, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pigWindows::i2c_zip( pigI2C&, char*, unsigned, char*, unsigned )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
///
|
||||
/// advanced
|
||||
///
|
||||
|
||||
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
|
||||
int pigWindows::hardware_PWM( bcm_t, uint32_t, uint32_t )
|
||||
{
|
||||
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// convenience
|
||||
///
|
||||
|
||||
|
||||
int pigWindows::show_error( int error )
|
||||
{
|
||||
|
||||
std::cout << "Error: " << std::endl;
|
||||
return error;
|
||||
}
|
||||
|
||||
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
|
||||
int pigWindows::hardware_clock( bcm_t, uint32_t )
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t pigWindows::get_current_tick()
|
||||
{
|
||||
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Get the Pi's hardware revision number.
|
||||
int pigWindows::get_hardware_revision()
|
||||
{
|
||||
//uint32_t get_hardware_revision(int pi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Returns the pigpio version.
|
||||
int pigWindows::get_pigpio_version()
|
||||
{
|
||||
//uint32_t get_pigpio_version(int pi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//Return the pigpiod_if2 version.
|
||||
unsigned pigWindows::pigpiod_if_version()
|
||||
{
|
||||
//unsigned pigpiod_if_version(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
#endif
|
||||
|
256
libpigwindows.h
256
libpigwindows.h
@@ -1,128 +1,128 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGWINDOWS_H
|
||||
#define LIBPIGWINDOWS_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
struct pigI2C;
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
class LIBPIGPIO_EXPORT pigWindows : public pigCore
|
||||
{
|
||||
|
||||
friend pigCore& get_instance();
|
||||
|
||||
public:
|
||||
|
||||
pigWindows( const pigWindows& ) = delete;
|
||||
void operator=( const pigWindows& ) = delete;
|
||||
|
||||
virtual ~pigWindows() = default;
|
||||
|
||||
int init( const std::string& host ="", const std::string& port="" ) override;
|
||||
|
||||
// pin config
|
||||
int set_io_mode( bcm_t bcm, io_t mode ) override;
|
||||
int get_io_mode( bcm_t bcm ) override;
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud ) override;
|
||||
int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
|
||||
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
|
||||
|
||||
// pin operations
|
||||
int get_level( bcm_t bcm ) override;
|
||||
int set_level( bcm_t bcm, level_t level ) override;
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = 60 ) override;
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
|
||||
|
||||
// interface
|
||||
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
|
||||
int cancel_callback( int cbId ) override;
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c ) override;
|
||||
int i2c_close( pigI2C& i2c ) override;
|
||||
|
||||
/*
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) override;
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
*/
|
||||
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
/*
|
||||
int i2c_read_byte( pigI2C& i2c ) override;
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) override;
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) override;
|
||||
int i2c_block_process_call( pigI2C& i2c,unsigned i2c_reg, char* buf, unsigned count ) override;
|
||||
int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
|
||||
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
|
||||
uint32_t get_current_tick() override;
|
||||
// convenience
|
||||
int show_error( int error ) override;
|
||||
|
||||
// info
|
||||
int get_hardware_revision() override;
|
||||
int get_pigpio_version() override;
|
||||
unsigned pigpiod_if_version() override;
|
||||
|
||||
private:
|
||||
|
||||
pigWindows() = default;
|
||||
|
||||
};
|
||||
|
||||
} // namespace pigpio
|
||||
|
||||
|
||||
#endif // LIBPIGWINDOWS_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 LIBPIGWINDOWS_H
|
||||
#define LIBPIGWINDOWS_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
struct pigI2C;
|
||||
|
||||
namespace pigpio
|
||||
{
|
||||
|
||||
class LIBPIGPIO_EXPORT pigWindows : public pigCore
|
||||
{
|
||||
|
||||
friend pigCore& get_instance();
|
||||
|
||||
public:
|
||||
|
||||
pigWindows( const pigWindows& ) = delete;
|
||||
void operator=( const pigWindows& ) = delete;
|
||||
|
||||
virtual ~pigWindows() = default;
|
||||
|
||||
int init( const std::string& host ="", const std::string& port="" ) override;
|
||||
|
||||
// pin config
|
||||
int set_io_mode( bcm_t bcm, io_t mode ) override;
|
||||
int get_io_mode( bcm_t bcm ) override;
|
||||
int set_pud_mode( bcm_t bcm, pud_t pud ) override;
|
||||
int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
|
||||
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
|
||||
|
||||
// pin operations
|
||||
int get_level( bcm_t bcm ) override;
|
||||
int set_level( bcm_t bcm, level_t level ) override;
|
||||
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = 60 ) override;
|
||||
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
|
||||
|
||||
// interface
|
||||
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
|
||||
int cancel_callback( int cbId ) override;
|
||||
|
||||
// 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
|
||||
int i2c_open( pigI2C& i2c ) override;
|
||||
int i2c_close( pigI2C& i2c ) override;
|
||||
|
||||
/*
|
||||
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
|
||||
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) override;
|
||||
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
|
||||
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
*/
|
||||
|
||||
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
/*
|
||||
int i2c_read_byte( pigI2C& i2c ) override;
|
||||
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_word_data( pigI2C& i2c, unsigned reg ) override;
|
||||
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) override;
|
||||
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) override;
|
||||
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
|
||||
|
||||
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) override;
|
||||
int i2c_block_process_call( pigI2C& i2c,unsigned i2c_reg, char* buf, unsigned count ) override;
|
||||
int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
|
||||
*/
|
||||
|
||||
// advanced
|
||||
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
|
||||
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
|
||||
uint32_t get_current_tick() override;
|
||||
// convenience
|
||||
int show_error( int error ) override;
|
||||
|
||||
// info
|
||||
int get_hardware_revision() override;
|
||||
int get_pigpio_version() override;
|
||||
unsigned pigpiod_if_version() override;
|
||||
|
||||
private:
|
||||
|
||||
pigWindows() = default;
|
||||
|
||||
};
|
||||
|
||||
} // namespace pigpio
|
||||
|
||||
|
||||
#endif // LIBPIGWINDOWS_H
|
||||
|
342
main.cpp
342
main.cpp
@@ -1,171 +1,171 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <ctime>
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigbutton.h>
|
||||
#include <pigtimer.h>
|
||||
#include <pigrotarydial.h>
|
||||
#include <pigchrono.h>
|
||||
#include <pigsonar.h>
|
||||
#include <piglcd.h>
|
||||
#include <pigbeeper.h>
|
||||
#include <pigbuzzer.h>
|
||||
#include <pigbutton.h>
|
||||
#include <pigled.h>
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtGPIOMain.h>
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace pigpio;
|
||||
|
||||
|
||||
|
||||
void on_level( level_t level )
|
||||
{
|
||||
cout << "on_level:" << level << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace qtgpio
|
||||
{
|
||||
// LED
|
||||
[[maybe_unused]] static const char* const icnRed = ":images/Red.png";
|
||||
[[maybe_unused]] static const char* const icnGreen = ":images/Green.png";
|
||||
|
||||
/// misc
|
||||
[[maybe_unused]] static const char* const version = "Version 0.8.43, 19.10.2022 © 2022 chris@sourceworx.org";
|
||||
|
||||
}
|
||||
|
||||
//#define high true
|
||||
[[maybe_unused]] constexpr static const char* mainVersion = "libPiGPIO 0.2.11 / 19.10.2022 © 2022 chris@sourceworx.org";
|
||||
|
||||
void funktion( double state ) { std::cout << "free function: " << state << std::endl; }
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
Q_UNUSED(argc)
|
||||
Q_UNUSED(argv)
|
||||
|
||||
//pigpio::init( "host", "port" );
|
||||
greet();
|
||||
|
||||
// Blink is the “Hello World” of the microcontroller world.
|
||||
// It usually does nothing more than flash an LED or 2.
|
||||
// (Gordon Henderson, WiringPi )
|
||||
|
||||
pigLCD lcd( 0x27 );
|
||||
lcd.set_backlight( on );
|
||||
lcd.write( 0, 0, "blink!" );
|
||||
|
||||
/*
|
||||
on_level( 1 );
|
||||
on_level( true );
|
||||
on_level( pigpio::high );
|
||||
on_level( high );
|
||||
*/
|
||||
|
||||
/*
|
||||
// ein 'Drückschalter' an Pin GPIO 16
|
||||
pigButton button( bcm16 );
|
||||
// eine LED und ein Summer an Pin 12 und Pin 23
|
||||
pigLED LED( bcm12 );
|
||||
pigBuzzer buzzer( bcm23 );
|
||||
// Zustände verknüpfen
|
||||
button.connect_state( LED );
|
||||
button.connect_state( buzzer );
|
||||
// 'connect_state' ist die Kurzform von
|
||||
// sigState.connect( &T::change_state, &listener );
|
||||
*/
|
||||
|
||||
/*
|
||||
pigBeeper beeper( bcm25 );
|
||||
std::vector<double> tnv = { 262.0, 294.0, 330.0, 262.0 };
|
||||
std::vector<double> drv = { 0.5, 0.5, 0.5, 0.5 };
|
||||
beeper.play_tune( tnv, drv );
|
||||
beeper.play_tone( 295, 0.3 );
|
||||
*/
|
||||
|
||||
|
||||
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//pigRotaryDial dial( board17, board27, board22 );
|
||||
|
||||
// für die raDIYo-Verdrahtung:
|
||||
pigRotaryDial dialA( bcm16, bcm20, bcm21 );
|
||||
pigRotaryDial dialB( bcm05, bcm13, bcm06 );
|
||||
|
||||
dialA.sigValue.connect( [&](int value){ cout << "Dial A: " << value << endl; } );
|
||||
dialB.sigValue.connect( [&](int value){ cout << "Dial B: " << value << endl; } );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
pigSonar sonar( bcm21, bcm20 );
|
||||
sonar.sigValue.connect( [&](double dist){ buzzer.buzz( 100, dist*50 ); } );
|
||||
sonar.start( 20 );
|
||||
|
||||
while( loop )
|
||||
{
|
||||
double dist = sonar.distance();
|
||||
lcd.write( 0, 0, "Dist.: " + val2str( dist) + " cm" );
|
||||
|
||||
if( dist < 20 )
|
||||
{
|
||||
buzzer.buzz( 100, dist*50 );
|
||||
LED.blink( dist*30 );
|
||||
}
|
||||
delay_millis( 200 );
|
||||
}
|
||||
|
||||
bool loop = true;
|
||||
button.sigState.connect( [&](bool){ loop = false; } );
|
||||
|
||||
while( loop )
|
||||
{
|
||||
lcd.write( 0,0, format_time() );
|
||||
delay_seconds( 1 );
|
||||
}
|
||||
|
||||
lcd.reset();
|
||||
|
||||
*/
|
||||
|
||||
// don't return, just wait forever, handling callbacks
|
||||
wait_loop();
|
||||
|
||||
// alternatively, show button as widgets
|
||||
QApplication application( argc, argv );
|
||||
QtGPIOMain window;
|
||||
window.show();
|
||||
return application.exec();
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <ctime>
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigbutton.h>
|
||||
#include <pigtimer.h>
|
||||
#include <pigrotarydial.h>
|
||||
#include <pigchrono.h>
|
||||
#include <pigsonar.h>
|
||||
#include <piglcd.h>
|
||||
#include <pigbeeper.h>
|
||||
#include <pigbuzzer.h>
|
||||
#include <pigbutton.h>
|
||||
#include <pigled.h>
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtGPIOMain.h>
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace pigpio;
|
||||
|
||||
|
||||
|
||||
void on_level( level_t level )
|
||||
{
|
||||
cout << "on_level:" << level << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace qtgpio
|
||||
{
|
||||
// LED
|
||||
[[maybe_unused]] static const char* const icnRed = ":images/Red.png";
|
||||
[[maybe_unused]] static const char* const icnGreen = ":images/Green.png";
|
||||
|
||||
/// misc
|
||||
[[maybe_unused]] static const char* const version = "Version 0.8.43, 19.10.2022 © 2022 chris@sourceworx.org";
|
||||
|
||||
}
|
||||
|
||||
//#define high true
|
||||
[[maybe_unused]] constexpr static const char* mainVersion = "libPiGPIO 0.2.11 / 19.10.2022 © 2022 chris@sourceworx.org";
|
||||
|
||||
void funktion( double state ) { std::cout << "free function: " << state << std::endl; }
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
Q_UNUSED(argc)
|
||||
Q_UNUSED(argv)
|
||||
|
||||
//pigpio::init( "host", "port" );
|
||||
greet();
|
||||
|
||||
// Blink is the “Hello World” of the microcontroller world.
|
||||
// It usually does nothing more than flash an LED or 2.
|
||||
// (Gordon Henderson, WiringPi )
|
||||
|
||||
//pigLCD lcd( 0x27 );
|
||||
//lcd.set_backlight( on );
|
||||
//lcd.write( 0, 0, "blink!" );
|
||||
|
||||
/*
|
||||
on_level( 1 );
|
||||
on_level( true );
|
||||
on_level( pigpio::high );
|
||||
on_level( high );
|
||||
*/
|
||||
|
||||
/*
|
||||
// ein 'Drückschalter' an Pin GPIO 16
|
||||
pigButton button( bcm16 );
|
||||
// eine LED und ein Summer an Pin 12 und Pin 23
|
||||
pigLED LED( bcm12 );
|
||||
pigBuzzer buzzer( bcm23 );
|
||||
// Zustände verknüpfen
|
||||
button.connect_state( LED );
|
||||
button.connect_state( buzzer );
|
||||
// 'connect_state' ist die Kurzform von
|
||||
// sigState.connect( &T::change_state, &listener );
|
||||
*/
|
||||
|
||||
/*
|
||||
pigBeeper beeper( bcm25 );
|
||||
std::vector<double> tnv = { 262.0, 294.0, 330.0, 262.0 };
|
||||
std::vector<double> drv = { 0.5, 0.5, 0.5, 0.5 };
|
||||
beeper.play_tune( tnv, drv );
|
||||
beeper.play_tone( 295, 0.3 );
|
||||
*/
|
||||
|
||||
|
||||
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
|
||||
//pigRotaryDial dial( board17, board27, board22 );
|
||||
|
||||
// für die raDIYo-Verdrahtung:
|
||||
//pigRotaryDial dialA( bcm16, bcm20, bcm21 );
|
||||
pigRotaryDial dialB( bcm05, bcm13, bcm06 );
|
||||
|
||||
//dialA.sigValue.connect( [&](int value){ cout << "Dial A: " << value << endl; } );
|
||||
dialB.sigValue.connect( [&](int value){ cout << "Dial B: " << value << endl; } );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
pigSonar sonar( bcm21, bcm20 );
|
||||
sonar.sigValue.connect( [&](double dist){ buzzer.buzz( 100, dist*50 ); } );
|
||||
sonar.start( 20 );
|
||||
|
||||
while( loop )
|
||||
{
|
||||
double dist = sonar.distance();
|
||||
lcd.write( 0, 0, "Dist.: " + val2str( dist) + " cm" );
|
||||
|
||||
if( dist < 20 )
|
||||
{
|
||||
buzzer.buzz( 100, dist*50 );
|
||||
LED.blink( dist*30 );
|
||||
}
|
||||
delay_millis( 200 );
|
||||
}
|
||||
|
||||
bool loop = true;
|
||||
button.sigState.connect( [&](bool){ loop = false; } );
|
||||
|
||||
while( loop )
|
||||
{
|
||||
lcd.write( 0,0, format_time() );
|
||||
delay_seconds( 1 );
|
||||
}
|
||||
|
||||
lcd.reset();
|
||||
|
||||
*/
|
||||
|
||||
// don't return, just wait forever, handling callbacks
|
||||
wait_loop();
|
||||
|
||||
// alternatively, show button as widgets
|
||||
QApplication application( argc, argv );
|
||||
QtGPIOMain window;
|
||||
window.show();
|
||||
return application.exec();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
942
moc_predefs.h
942
moc_predefs.h
@@ -1,471 +1,471 @@
|
||||
#define __DBL_MIN_EXP__ (-1021)
|
||||
#define __HQ_FBIT__ 15
|
||||
#define __cpp_nontype_template_parameter_auto 201606L
|
||||
#define __UINT_LEAST16_MAX__ 0xffff
|
||||
#define __ARM_SIZEOF_WCHAR_T 4
|
||||
#define __SFRACT_IBIT__ 0
|
||||
#define __FLT_MIN__ 1.1754943508222875e-38F
|
||||
#define __GCC_IEC_559_COMPLEX 2
|
||||
#define __cpp_aggregate_nsdmi 201304L
|
||||
#define __UFRACT_MAX__ 0XFFFFP-16UR
|
||||
#define __UINT_LEAST8_TYPE__ unsigned char
|
||||
#define __FLT_MAX_EXP__ 128
|
||||
#define __DQ_FBIT__ 63
|
||||
#define __INTMAX_C(c) c ## LL
|
||||
#define __ARM_FEATURE_SAT 1
|
||||
#define __ULFRACT_FBIT__ 32
|
||||
#define __CHAR_BIT__ 8
|
||||
#define __USQ_IBIT__ 0
|
||||
#define __UINT8_MAX__ 0xff
|
||||
#define __ACCUM_FBIT__ 15
|
||||
#define __WINT_MAX__ 0xffffffffU
|
||||
#define __FLT32_MIN_EXP__ (-125)
|
||||
#define __cpp_static_assert 201411L
|
||||
#define __USFRACT_FBIT__ 8
|
||||
#define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
#define __SIZE_MAX__ 0xffffffffU
|
||||
#define __ARM_ARCH_ISA_ARM 1
|
||||
#define __WCHAR_MAX__ 0xffffffffU
|
||||
#define __LACCUM_IBIT__ 32
|
||||
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
|
||||
#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L)
|
||||
#define __GCC_ATOMIC_CHAR_LOCK_FREE 1
|
||||
#define __GCC_IEC_559 2
|
||||
#define __FLT32X_DECIMAL_DIG__ 17
|
||||
#define __FLT_EVAL_METHOD__ 0
|
||||
#define __TQ_IBIT__ 0
|
||||
#define __cpp_binary_literals 201304L
|
||||
#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK
|
||||
#define __FLT64_DECIMAL_DIG__ 17
|
||||
#define __cpp_noexcept_function_type 201510L
|
||||
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
|
||||
#define __cpp_variadic_templates 200704L
|
||||
#define __INTPTR_WIDTH__ 32
|
||||
#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL
|
||||
#define __SIG_ATOMIC_TYPE__ int
|
||||
#define __DBL_MIN_10_EXP__ (-307)
|
||||
#define __FINITE_MATH_ONLY__ 0
|
||||
#define __ARMEL__ 1
|
||||
#define __cpp_variable_templates 201304L
|
||||
#define __FLT32X_MAX_EXP__ 1024
|
||||
#define __LFRACT_IBIT__ 0
|
||||
#define __GNUC_PATCHLEVEL__ 1
|
||||
#define __FLT32_HAS_DENORM__ 1
|
||||
#define __USA_FBIT__ 16
|
||||
#define __UINT_FAST8_MAX__ 0xff
|
||||
#define __cpp_rvalue_reference 200610L
|
||||
#define __INT8_C(c) c
|
||||
#define __INT_LEAST8_WIDTH__ 8
|
||||
#define __cpp_variadic_using 201611L
|
||||
#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL
|
||||
#define __INT16_MAX__ 0x7fff
|
||||
#define __cpp_attributes 200809L
|
||||
#define __SA_FBIT__ 15
|
||||
#define __cpp_capture_star_this 201603L
|
||||
#define __APCS_32__ 1
|
||||
#define __SHRT_MAX__ 0x7fff
|
||||
#define __LDBL_MAX__ 1.7976931348623157e+308L
|
||||
#define __FRACT_MAX__ 0X7FFFP-15R
|
||||
#define __cpp_if_constexpr 201606L
|
||||
#define __UFRACT_FBIT__ 16
|
||||
#define __ARM_FP 12
|
||||
#define __UFRACT_MIN__ 0.0UR
|
||||
#define __UINT_LEAST8_MAX__ 0xff
|
||||
#define __GCC_ATOMIC_BOOL_LOCK_FREE 1
|
||||
#define __UINTMAX_TYPE__ long long unsigned int
|
||||
#define __LLFRACT_EPSILON__ 0x1P-63LLR
|
||||
#define __linux 1
|
||||
#define __FLT_EVAL_METHOD_TS_18661_3__ 0
|
||||
#define __CHAR_UNSIGNED__ 1
|
||||
#define __UINT32_MAX__ 0xffffffffU
|
||||
#define __GXX_EXPERIMENTAL_CXX0X__ 1
|
||||
#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR
|
||||
#define __TA_IBIT__ 64
|
||||
#define __LDBL_MAX_EXP__ 1024
|
||||
#define __WINT_MIN__ 0U
|
||||
#define __INT_LEAST16_WIDTH__ 16
|
||||
#define __ULLFRACT_MIN__ 0.0ULLR
|
||||
#define __SCHAR_MAX__ 0x7f
|
||||
#define __WCHAR_MIN__ 0U
|
||||
#define __INT64_C(c) c ## LL
|
||||
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
|
||||
#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK)
|
||||
#define __SIZEOF_INT__ 4
|
||||
#define __FLT32X_MANT_DIG__ 53
|
||||
#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
|
||||
#define __USACCUM_IBIT__ 8
|
||||
#define __cpp_aligned_new 201606L
|
||||
#define __USER_LABEL_PREFIX__
|
||||
#define __STDC_HOSTED__ 1
|
||||
#define __FLT_DIG__ 6
|
||||
#define __LFRACT_MIN__ (-0.5LR-0.5LR)
|
||||
#define __HA_IBIT__ 8
|
||||
#define __cpp_decltype_auto 201304L
|
||||
#define __FLT32_DIG__ 6
|
||||
#define __FLT_EPSILON__ 1.1920928955078125e-7F
|
||||
#define __GXX_WEAK__ 1
|
||||
#define __SHRT_WIDTH__ 16
|
||||
#define __USFRACT_IBIT__ 0
|
||||
#define __LDBL_MIN__ 2.2250738585072014e-308L
|
||||
#define __FRACT_MIN__ (-0.5R-0.5R)
|
||||
#define __DA_IBIT__ 32
|
||||
#define __ARM_SIZEOF_MINIMAL_ENUM 4
|
||||
#define __FLT32X_HAS_INFINITY__ 1
|
||||
#define __UQQ_FBIT__ 8
|
||||
#define __SIZEOF_LONG__ 4
|
||||
#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK
|
||||
#define __STDC_IEC_559__ 1
|
||||
#define __STDC_ISO_10646__ 201706L
|
||||
#define __DECIMAL_DIG__ 17
|
||||
#define __LFRACT_EPSILON__ 0x1P-31LR
|
||||
#define __STDC_IEC_559_COMPLEX__ 1
|
||||
#define __FLT64_EPSILON__ 2.2204460492503131e-16F64
|
||||
#define __gnu_linux__ 1
|
||||
#define __FLT64_MIN_EXP__ (-1021)
|
||||
#define __ARM_PCS_VFP 1
|
||||
#define __LDBL_HAS_QUIET_NAN__ 1
|
||||
#define __ULACCUM_IBIT__ 32
|
||||
#define __FLT64_MANT_DIG__ 53
|
||||
#define __GXX_RTTI 1
|
||||
#define __UACCUM_EPSILON__ 0x1P-16UK
|
||||
#define __GNUC__ 10
|
||||
#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK
|
||||
#define __HQ_IBIT__ 0
|
||||
#define __FLT_HAS_DENORM__ 1
|
||||
#define __SIZEOF_LONG_DOUBLE__ 8
|
||||
#define __SA_IBIT__ 16
|
||||
#define __BIGGEST_ALIGNMENT__ 8
|
||||
#define __STDC_UTF_16__ 1
|
||||
#define __INTPTR_TYPE__ int
|
||||
#define __FLT64_MAX_10_EXP__ 308
|
||||
#define __DBL_DIG__ 15
|
||||
#define __ULLACCUM_FBIT__ 32
|
||||
#define __GNUC_STDC_INLINE__ 1
|
||||
#define __DQ_IBIT__ 0
|
||||
#define __DBL_MAX__ double(1.7976931348623157e+308L)
|
||||
#define __ULFRACT_IBIT__ 0
|
||||
#define __cpp_raw_strings 200710L
|
||||
#define __INT_FAST32_MAX__ 0x7fffffff
|
||||
#define __DBL_HAS_INFINITY__ 1
|
||||
#define __HAVE_SPECULATION_SAFE_VALUE 1
|
||||
#define __cpp_fold_expressions 201603L
|
||||
#define __ACCUM_IBIT__ 16
|
||||
#define __THUMB_INTERWORK__ 1
|
||||
#define __UINT_LEAST32_MAX__ 0xffffffffU
|
||||
#define __ULLACCUM_IBIT__ 32
|
||||
#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK
|
||||
#define __cpp_delegating_constructors 200604L
|
||||
#define __FLT32X_HAS_DENORM__ 1
|
||||
#define __INT_FAST16_TYPE__ int
|
||||
#define __LDBL_HAS_DENORM__ 1
|
||||
#define __ARM_FEATURE_LDREX 4
|
||||
#define __cplusplus 201703L
|
||||
#define __cpp_ref_qualifiers 200710L
|
||||
#define __FLT32_DECIMAL_DIG__ 9
|
||||
#define __INT_LEAST32_MAX__ 0x7fffffff
|
||||
#define __ACCUM_MAX__ 0X7FFFFFFFP-15K
|
||||
#define __DEPRECATED 1
|
||||
#define __cpp_rvalue_references 200610L
|
||||
#define __DBL_MAX_EXP__ 1024
|
||||
#define __USACCUM_EPSILON__ 0x1P-8UHK
|
||||
#define __WCHAR_WIDTH__ 32
|
||||
#define __FLT32_MAX__ 3.4028234663852886e+38F32
|
||||
#define __SFRACT_MAX__ 0X7FP-7HR
|
||||
#define __FRACT_IBIT__ 0
|
||||
#define __PTRDIFF_MAX__ 0x7fffffff
|
||||
#define __UACCUM_MIN__ 0.0UK
|
||||
#define __UACCUM_IBIT__ 16
|
||||
#define __FLT32_HAS_QUIET_NAN__ 1
|
||||
#define __GNUG__ 10
|
||||
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
|
||||
#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK
|
||||
#define __cpp_nsdmi 200809L
|
||||
#define __SIZEOF_WINT_T__ 4
|
||||
#define __ARM_FEATURE_UNALIGNED 1
|
||||
#define __LONG_LONG_WIDTH__ 64
|
||||
#define __cpp_initializer_lists 200806L
|
||||
#define __FLT32_MAX_EXP__ 128
|
||||
#define __ULLACCUM_MIN__ 0.0ULLK
|
||||
#define __cpp_hex_float 201603L
|
||||
#define __cpp_threadsafe_static_init 200806L
|
||||
#define __GXX_ABI_VERSION 1014
|
||||
#define __UTA_FBIT__ 64
|
||||
#define __UFRACT_IBIT__ 0
|
||||
#define __USQ_FBIT__ 32
|
||||
#define __cpp_enumerator_attributes 201411L
|
||||
#define __cpp_lambdas 200907L
|
||||
#define __ARM_FEATURE_QBIT 1
|
||||
#define __INT_FAST64_TYPE__ long long int
|
||||
#define __FLT64_DENORM_MIN__ 4.9406564584124654e-324F64
|
||||
#define __DBL_MIN__ double(2.2250738585072014e-308L)
|
||||
#define __SIZEOF_POINTER__ 4
|
||||
#define __INT16_TYPE__ short int
|
||||
#define __DBL_HAS_QUIET_NAN__ 1
|
||||
#define __FLT32X_EPSILON__ 2.2204460492503131e-16F32x
|
||||
#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK)
|
||||
#define __FRACT_FBIT__ 15
|
||||
#define __FLT64_MIN_10_EXP__ (-307)
|
||||
#define __ULLFRACT_EPSILON__ 0x1P-64ULLR
|
||||
#define __REGISTER_PREFIX__
|
||||
#define __UINT16_MAX__ 0xffff
|
||||
#define __ACCUM_MIN__ (-0X1P15K-0X1P15K)
|
||||
#define __SQ_IBIT__ 0
|
||||
#define __UINT8_TYPE__ unsigned char
|
||||
#define __UHA_FBIT__ 8
|
||||
#define __SFRACT_MIN__ (-0.5HR-0.5HR)
|
||||
#define __UTQ_FBIT__ 128
|
||||
#define __DEC_EVAL_METHOD__ 2
|
||||
#define __FLT_MANT_DIG__ 24
|
||||
#define __LDBL_DECIMAL_DIG__ 17
|
||||
#define __VERSION__ "10.2.1 20210110"
|
||||
#define __UINT64_C(c) c ## ULL
|
||||
#define __cpp_unicode_characters 201411L
|
||||
#define __FRACT_EPSILON__ 0x1P-15R
|
||||
#define __ULACCUM_MIN__ 0.0ULK
|
||||
#define _STDC_PREDEF_H 1
|
||||
#define __UDA_FBIT__ 32
|
||||
#define __GCC_ATOMIC_INT_LOCK_FREE 2
|
||||
#define __FLT_MIN_EXP__ (-125)
|
||||
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
#define __USFRACT_MIN__ 0.0UHR
|
||||
#define __FLT32_MANT_DIG__ 24
|
||||
#define __ULLFRACT_FBIT__ 64
|
||||
#define __cpp_aggregate_bases 201603L
|
||||
#define __UQQ_IBIT__ 0
|
||||
#define __SCHAR_WIDTH__ 8
|
||||
#define __INT32_C(c) c
|
||||
#define __ORDER_PDP_ENDIAN__ 3412
|
||||
#define __UHQ_FBIT__ 16
|
||||
#define __LLACCUM_FBIT__ 31
|
||||
#define __INT_FAST32_TYPE__ int
|
||||
#define __UINT_LEAST16_TYPE__ short unsigned int
|
||||
#define unix 1
|
||||
#define __DBL_HAS_DENORM__ 1
|
||||
#define __cpp_rtti 199711L
|
||||
#define __SIZE_TYPE__ unsigned int
|
||||
#define __UINT64_MAX__ 0xffffffffffffffffULL
|
||||
#define __UDQ_FBIT__ 64
|
||||
#define __INT8_TYPE__ signed char
|
||||
#define __cpp_digit_separators 201309L
|
||||
#define __ELF__ 1
|
||||
#define __SACCUM_EPSILON__ 0x1P-7HK
|
||||
#define __ULFRACT_EPSILON__ 0x1P-32ULR
|
||||
#define __LLFRACT_FBIT__ 63
|
||||
#define __FLT_RADIX__ 2
|
||||
#define __INT_LEAST16_TYPE__ short int
|
||||
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
|
||||
#define __UINTMAX_C(c) c ## ULL
|
||||
#define __SACCUM_MAX__ 0X7FFFP-7HK
|
||||
#define __FLT32X_MIN__ 2.2250738585072014e-308F32x
|
||||
#define __SIG_ATOMIC_MAX__ 0x7fffffff
|
||||
#define __UACCUM_FBIT__ 16
|
||||
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
|
||||
#define __VFP_FP__ 1
|
||||
#define __SIZEOF_PTRDIFF_T__ 4
|
||||
#define __ATOMIC_ACQUIRE 2
|
||||
#define __unix__ 1
|
||||
#define __INT_WIDTH__ 32
|
||||
#define __OPTIMIZE__ 1
|
||||
#define __LACCUM_EPSILON__ 0x1P-31LK
|
||||
#define __LDBL_DIG__ 15
|
||||
#define __FLT32X_MIN_EXP__ (-1021)
|
||||
#define __INT_FAST16_MAX__ 0x7fffffff
|
||||
#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR
|
||||
#define __ARM_ARCH_6__ 1
|
||||
#define __FLT64_DIG__ 15
|
||||
#define __UINT_FAST32_MAX__ 0xffffffffU
|
||||
#define __UINT_LEAST64_TYPE__ long long unsigned int
|
||||
#define __SFRACT_EPSILON__ 0x1P-7HR
|
||||
#define __GCC_ASM_FLAG_OUTPUTS__ 1
|
||||
#define __FLT_HAS_QUIET_NAN__ 1
|
||||
#define __FLT_MAX_10_EXP__ 38
|
||||
#define __LONG_MAX__ 0x7fffffffL
|
||||
#define __SIZEOF_SIZE_T__ 4
|
||||
#define __FLT_HAS_INFINITY__ 1
|
||||
#define __unix 1
|
||||
#define __cpp_unicode_literals 200710L
|
||||
#define __cpp_init_captures 201304L
|
||||
#define __UINT_FAST16_TYPE__ unsigned int
|
||||
#define __ARM_32BIT_STATE 1
|
||||
#define __INT_FAST32_WIDTH__ 32
|
||||
#define __CHAR16_TYPE__ short unsigned int
|
||||
#define __PRAGMA_REDEFINE_EXTNAME 1
|
||||
#define __SIZE_WIDTH__ 32
|
||||
#define __INT_LEAST16_MAX__ 0x7fff
|
||||
#define __INT64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __SACCUM_FBIT__ 7
|
||||
#define __FLT32_DENORM_MIN__ 1.4012984643248171e-45F32
|
||||
#define __SIG_ATOMIC_WIDTH__ 32
|
||||
#define __INT_LEAST64_TYPE__ long long int
|
||||
#define __ARM_FEATURE_CLZ 1
|
||||
#define __INT_LEAST8_TYPE__ signed char
|
||||
#define __cpp_structured_bindings 201606L
|
||||
#define __SQ_FBIT__ 31
|
||||
#define __USFRACT_MAX__ 0XFFP-8UHR
|
||||
#define __ARM_ARCH_ISA_THUMB 1
|
||||
#define __INT_FAST8_MAX__ 0x7f
|
||||
#define __ARM_ARCH 6
|
||||
#define __INTPTR_MAX__ 0x7fffffff
|
||||
#define __cpp_sized_deallocation 201309L
|
||||
#define __cpp_guaranteed_copy_elision 201606L
|
||||
#define __QQ_FBIT__ 7
|
||||
#define linux 1
|
||||
#define __UTA_IBIT__ 64
|
||||
#define __FLT64_HAS_QUIET_NAN__ 1
|
||||
#define __UINT16_C(c) c
|
||||
#define __PTRDIFF_WIDTH__ 32
|
||||
#define __LDBL_MANT_DIG__ 53
|
||||
#define __SFRACT_FBIT__ 7
|
||||
#define __cpp_range_based_for 201603L
|
||||
#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK)
|
||||
#define __FLT64_HAS_INFINITY__ 1
|
||||
#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8
|
||||
#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
|
||||
#define __GCC_ATOMIC_LONG_LOCK_FREE 2
|
||||
#define __cpp_nontype_template_args 201411L
|
||||
#define __UINT16_TYPE__ short unsigned int
|
||||
#define __WCHAR_TYPE__ unsigned int
|
||||
#define __SIZEOF_FLOAT__ 4
|
||||
#define __TQ_FBIT__ 127
|
||||
#define __UINTPTR_MAX__ 0xffffffffU
|
||||
#define __INT_FAST64_WIDTH__ 64
|
||||
#define __cpp_decltype 200707L
|
||||
#define __cpp_nested_namespace_definitions 201411L
|
||||
#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
|
||||
#define __FLT_NORM_MAX__ 3.4028234663852886e+38F
|
||||
#define __FLT32_HAS_INFINITY__ 1
|
||||
#define __UINT_FAST64_TYPE__ long long unsigned int
|
||||
#define __cpp_inline_variables 201606L
|
||||
#define __LACCUM_FBIT__ 31
|
||||
#define __HA_FBIT__ 7
|
||||
#define __UHA_IBIT__ 8
|
||||
#define __INT64_TYPE__ long long int
|
||||
#define __UTQ_IBIT__ 0
|
||||
#define __DBL_MANT_DIG__ 53
|
||||
#define __cpp_inheriting_constructors 201511L
|
||||
#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __WINT_TYPE__ unsigned int
|
||||
#define __UINT_LEAST32_TYPE__ unsigned int
|
||||
#define __SIZEOF_SHORT__ 2
|
||||
#define __ULLFRACT_IBIT__ 0
|
||||
#define __FLT32_NORM_MAX__ 3.4028234663852886e+38F32
|
||||
#define __LDBL_MIN_EXP__ (-1021)
|
||||
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
|
||||
#define __INTMAX_MAX__ 0x7fffffffffffffffLL
|
||||
#define __arm__ 1
|
||||
#define __FLT64_MAX__ 1.7976931348623157e+308F64
|
||||
#define __UDA_IBIT__ 32
|
||||
#define __INT_MAX__ 0x7fffffff
|
||||
#define __WINT_WIDTH__ 32
|
||||
#define __cpp_template_auto 201606L
|
||||
#define __INT_LEAST8_MAX__ 0x7f
|
||||
#define __INT_LEAST64_WIDTH__ 64
|
||||
#define __FLT32X_MAX_10_EXP__ 308
|
||||
#define __LLACCUM_EPSILON__ 0x1P-31LLK
|
||||
#define __LFRACT_FBIT__ 31
|
||||
#define __WCHAR_UNSIGNED__ 1
|
||||
#define __LDBL_MAX_10_EXP__ 308
|
||||
#define __ATOMIC_RELAXED 0
|
||||
#define __DBL_EPSILON__ double(2.2204460492503131e-16L)
|
||||
#define __ARM_FEATURE_SIMD32 1
|
||||
#define __UINT8_C(c) c
|
||||
#define __FLT64_MAX_EXP__ 1024
|
||||
#define __INT_LEAST32_TYPE__ int
|
||||
#define __cpp_return_type_deduction 201304L
|
||||
#define __SIZEOF_WCHAR_T__ 4
|
||||
#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR
|
||||
#define __FLT64_NORM_MAX__ 1.7976931348623157e+308F64
|
||||
#define __INT_FAST8_TYPE__ signed char
|
||||
#define __cpp_namespace_attributes 201411L
|
||||
#define __ULLACCUM_EPSILON__ 0x1P-32ULLK
|
||||
#define __USACCUM_MAX__ 0XFFFFP-8UHK
|
||||
#define __LDBL_HAS_INFINITY__ 1
|
||||
#define __FLT32_MAX_10_EXP__ 38
|
||||
#define __UHQ_IBIT__ 0
|
||||
#define __ARM_FEATURE_COPROC 15
|
||||
#define __LLACCUM_IBIT__ 32
|
||||
#define __ULFRACT_MIN__ 0.0ULR
|
||||
#define __FLT64_HAS_DENORM__ 1
|
||||
#define __FLT32_EPSILON__ 1.1920928955078125e-7F32
|
||||
#define __DBL_DECIMAL_DIG__ 17
|
||||
#define __STDC_UTF_32__ 1
|
||||
#define __INT_FAST8_WIDTH__ 8
|
||||
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
#define __FLT32X_MAX__ 1.7976931348623157e+308F32x
|
||||
#define __TA_FBIT__ 63
|
||||
#define __DBL_NORM_MAX__ double(1.7976931348623157e+308L)
|
||||
#define __UDQ_IBIT__ 0
|
||||
#define __INTMAX_WIDTH__ 64
|
||||
#define __ORDER_BIG_ENDIAN__ 4321
|
||||
#define __ARM_FEATURE_DSP 1
|
||||
#define __cpp_runtime_arrays 198712L
|
||||
#define __UINT64_TYPE__ long long unsigned int
|
||||
#define __ACCUM_EPSILON__ 0x1P-15K
|
||||
#define __UINT32_C(c) c ## U
|
||||
#define __cpp_alias_templates 200704L
|
||||
#define __QQ_IBIT__ 0
|
||||
#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
|
||||
#define __LLFRACT_IBIT__ 0
|
||||
#define __INT8_MAX__ 0x7f
|
||||
#define __LONG_WIDTH__ 32
|
||||
#define __INT32_MAX__ 0x7fffffff
|
||||
#define __UINT_FAST32_TYPE__ unsigned int
|
||||
#define __FLT32X_NORM_MAX__ 1.7976931348623157e+308F32x
|
||||
#define __CHAR32_TYPE__ unsigned int
|
||||
#define __FLT32_MIN_10_EXP__ (-37)
|
||||
#define __FLT_MAX__ 3.4028234663852886e+38F
|
||||
#define __cpp_constexpr 201603L
|
||||
#define __USACCUM_FBIT__ 8
|
||||
#define __cpp_deduction_guides 201703L
|
||||
#define __INT32_TYPE__ int
|
||||
#define __SIZEOF_DOUBLE__ 8
|
||||
#define __cpp_exceptions 199711L
|
||||
#define __FLT_MIN_10_EXP__ (-37)
|
||||
#define __UFRACT_EPSILON__ 0x1P-16UR
|
||||
#define __FLT64_MIN__ 2.2250738585072014e-308F64
|
||||
#define __INT_LEAST32_WIDTH__ 32
|
||||
#define __INTMAX_TYPE__ long long int
|
||||
#define __FLT32X_HAS_QUIET_NAN__ 1
|
||||
#define __ATOMIC_CONSUME 1
|
||||
#define __GNUC_MINOR__ 2
|
||||
#define __INT_FAST16_WIDTH__ 32
|
||||
#define __UINTMAX_MAX__ 0xffffffffffffffffULL
|
||||
#define __FLT32X_DENORM_MIN__ 4.9406564584124654e-324F32x
|
||||
#define __cpp_template_template_args 201611L
|
||||
#define __ATOMIC_ACQ_REL 4
|
||||
#define __DBL_MAX_10_EXP__ 308
|
||||
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
|
||||
#define __INT16_C(c) c
|
||||
#define __STDC__ 1
|
||||
#define __FLT32X_DIG__ 15
|
||||
#define __PTRDIFF_TYPE__ int
|
||||
#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR)
|
||||
#define __USACCUM_MIN__ 0.0UHK
|
||||
#define __FLT32_MIN__ 1.1754943508222875e-38F32
|
||||
#define __ATOMIC_SEQ_CST 5
|
||||
#define __DA_FBIT__ 31
|
||||
#define __EXCEPTIONS 1
|
||||
#define __UINT32_TYPE__ unsigned int
|
||||
#define __FLT32X_MIN_10_EXP__ (-307)
|
||||
#define __UINTPTR_TYPE__ unsigned int
|
||||
#define __USA_IBIT__ 16
|
||||
#define __ARM_EABI__ 1
|
||||
#define __linux__ 1
|
||||
#define __LDBL_MIN_10_EXP__ (-307)
|
||||
#define __cpp_generic_lambdas 201304L
|
||||
#define __SIZEOF_LONG_LONG__ 8
|
||||
#define __ULACCUM_EPSILON__ 0x1P-32ULK
|
||||
#define __cpp_user_defined_literals 200809L
|
||||
#define __SACCUM_IBIT__ 8
|
||||
#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
|
||||
#define __FLT_DECIMAL_DIG__ 9
|
||||
#define __UINT_FAST16_MAX__ 0xffffffffU
|
||||
#define __LDBL_NORM_MAX__ 1.7976931348623157e+308L
|
||||
#define __GCC_ATOMIC_SHORT_LOCK_FREE 1
|
||||
#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR
|
||||
#define __UINT_FAST8_TYPE__ unsigned char
|
||||
#define _GNU_SOURCE 1
|
||||
#define __USFRACT_EPSILON__ 0x1P-8UHR
|
||||
#define __ULACCUM_FBIT__ 32
|
||||
#define __ATOMIC_RELEASE 3
|
||||
#define __DBL_MIN_EXP__ (-1021)
|
||||
#define __HQ_FBIT__ 15
|
||||
#define __cpp_nontype_template_parameter_auto 201606L
|
||||
#define __UINT_LEAST16_MAX__ 0xffff
|
||||
#define __ARM_SIZEOF_WCHAR_T 4
|
||||
#define __SFRACT_IBIT__ 0
|
||||
#define __FLT_MIN__ 1.1754943508222875e-38F
|
||||
#define __GCC_IEC_559_COMPLEX 2
|
||||
#define __cpp_aggregate_nsdmi 201304L
|
||||
#define __UFRACT_MAX__ 0XFFFFP-16UR
|
||||
#define __UINT_LEAST8_TYPE__ unsigned char
|
||||
#define __FLT_MAX_EXP__ 128
|
||||
#define __DQ_FBIT__ 63
|
||||
#define __INTMAX_C(c) c ## LL
|
||||
#define __ARM_FEATURE_SAT 1
|
||||
#define __ULFRACT_FBIT__ 32
|
||||
#define __CHAR_BIT__ 8
|
||||
#define __USQ_IBIT__ 0
|
||||
#define __UINT8_MAX__ 0xff
|
||||
#define __ACCUM_FBIT__ 15
|
||||
#define __WINT_MAX__ 0xffffffffU
|
||||
#define __FLT32_MIN_EXP__ (-125)
|
||||
#define __cpp_static_assert 201411L
|
||||
#define __USFRACT_FBIT__ 8
|
||||
#define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
#define __SIZE_MAX__ 0xffffffffU
|
||||
#define __ARM_ARCH_ISA_ARM 1
|
||||
#define __WCHAR_MAX__ 0xffffffffU
|
||||
#define __LACCUM_IBIT__ 32
|
||||
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
|
||||
#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L)
|
||||
#define __GCC_ATOMIC_CHAR_LOCK_FREE 1
|
||||
#define __GCC_IEC_559 2
|
||||
#define __FLT32X_DECIMAL_DIG__ 17
|
||||
#define __FLT_EVAL_METHOD__ 0
|
||||
#define __TQ_IBIT__ 0
|
||||
#define __cpp_binary_literals 201304L
|
||||
#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK
|
||||
#define __FLT64_DECIMAL_DIG__ 17
|
||||
#define __cpp_noexcept_function_type 201510L
|
||||
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
|
||||
#define __cpp_variadic_templates 200704L
|
||||
#define __INTPTR_WIDTH__ 32
|
||||
#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL
|
||||
#define __SIG_ATOMIC_TYPE__ int
|
||||
#define __DBL_MIN_10_EXP__ (-307)
|
||||
#define __FINITE_MATH_ONLY__ 0
|
||||
#define __ARMEL__ 1
|
||||
#define __cpp_variable_templates 201304L
|
||||
#define __FLT32X_MAX_EXP__ 1024
|
||||
#define __LFRACT_IBIT__ 0
|
||||
#define __GNUC_PATCHLEVEL__ 1
|
||||
#define __FLT32_HAS_DENORM__ 1
|
||||
#define __USA_FBIT__ 16
|
||||
#define __UINT_FAST8_MAX__ 0xff
|
||||
#define __cpp_rvalue_reference 200610L
|
||||
#define __INT8_C(c) c
|
||||
#define __INT_LEAST8_WIDTH__ 8
|
||||
#define __cpp_variadic_using 201611L
|
||||
#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL
|
||||
#define __INT16_MAX__ 0x7fff
|
||||
#define __cpp_attributes 200809L
|
||||
#define __SA_FBIT__ 15
|
||||
#define __cpp_capture_star_this 201603L
|
||||
#define __APCS_32__ 1
|
||||
#define __SHRT_MAX__ 0x7fff
|
||||
#define __LDBL_MAX__ 1.7976931348623157e+308L
|
||||
#define __FRACT_MAX__ 0X7FFFP-15R
|
||||
#define __cpp_if_constexpr 201606L
|
||||
#define __UFRACT_FBIT__ 16
|
||||
#define __ARM_FP 12
|
||||
#define __UFRACT_MIN__ 0.0UR
|
||||
#define __UINT_LEAST8_MAX__ 0xff
|
||||
#define __GCC_ATOMIC_BOOL_LOCK_FREE 1
|
||||
#define __UINTMAX_TYPE__ long long unsigned int
|
||||
#define __LLFRACT_EPSILON__ 0x1P-63LLR
|
||||
#define __linux 1
|
||||
#define __FLT_EVAL_METHOD_TS_18661_3__ 0
|
||||
#define __CHAR_UNSIGNED__ 1
|
||||
#define __UINT32_MAX__ 0xffffffffU
|
||||
#define __GXX_EXPERIMENTAL_CXX0X__ 1
|
||||
#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR
|
||||
#define __TA_IBIT__ 64
|
||||
#define __LDBL_MAX_EXP__ 1024
|
||||
#define __WINT_MIN__ 0U
|
||||
#define __INT_LEAST16_WIDTH__ 16
|
||||
#define __ULLFRACT_MIN__ 0.0ULLR
|
||||
#define __SCHAR_MAX__ 0x7f
|
||||
#define __WCHAR_MIN__ 0U
|
||||
#define __INT64_C(c) c ## LL
|
||||
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
|
||||
#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK)
|
||||
#define __SIZEOF_INT__ 4
|
||||
#define __FLT32X_MANT_DIG__ 53
|
||||
#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
|
||||
#define __USACCUM_IBIT__ 8
|
||||
#define __cpp_aligned_new 201606L
|
||||
#define __USER_LABEL_PREFIX__
|
||||
#define __STDC_HOSTED__ 1
|
||||
#define __FLT_DIG__ 6
|
||||
#define __LFRACT_MIN__ (-0.5LR-0.5LR)
|
||||
#define __HA_IBIT__ 8
|
||||
#define __cpp_decltype_auto 201304L
|
||||
#define __FLT32_DIG__ 6
|
||||
#define __FLT_EPSILON__ 1.1920928955078125e-7F
|
||||
#define __GXX_WEAK__ 1
|
||||
#define __SHRT_WIDTH__ 16
|
||||
#define __USFRACT_IBIT__ 0
|
||||
#define __LDBL_MIN__ 2.2250738585072014e-308L
|
||||
#define __FRACT_MIN__ (-0.5R-0.5R)
|
||||
#define __DA_IBIT__ 32
|
||||
#define __ARM_SIZEOF_MINIMAL_ENUM 4
|
||||
#define __FLT32X_HAS_INFINITY__ 1
|
||||
#define __UQQ_FBIT__ 8
|
||||
#define __SIZEOF_LONG__ 4
|
||||
#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK
|
||||
#define __STDC_IEC_559__ 1
|
||||
#define __STDC_ISO_10646__ 201706L
|
||||
#define __DECIMAL_DIG__ 17
|
||||
#define __LFRACT_EPSILON__ 0x1P-31LR
|
||||
#define __STDC_IEC_559_COMPLEX__ 1
|
||||
#define __FLT64_EPSILON__ 2.2204460492503131e-16F64
|
||||
#define __gnu_linux__ 1
|
||||
#define __FLT64_MIN_EXP__ (-1021)
|
||||
#define __ARM_PCS_VFP 1
|
||||
#define __LDBL_HAS_QUIET_NAN__ 1
|
||||
#define __ULACCUM_IBIT__ 32
|
||||
#define __FLT64_MANT_DIG__ 53
|
||||
#define __GXX_RTTI 1
|
||||
#define __UACCUM_EPSILON__ 0x1P-16UK
|
||||
#define __GNUC__ 10
|
||||
#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK
|
||||
#define __HQ_IBIT__ 0
|
||||
#define __FLT_HAS_DENORM__ 1
|
||||
#define __SIZEOF_LONG_DOUBLE__ 8
|
||||
#define __SA_IBIT__ 16
|
||||
#define __BIGGEST_ALIGNMENT__ 8
|
||||
#define __STDC_UTF_16__ 1
|
||||
#define __INTPTR_TYPE__ int
|
||||
#define __FLT64_MAX_10_EXP__ 308
|
||||
#define __DBL_DIG__ 15
|
||||
#define __ULLACCUM_FBIT__ 32
|
||||
#define __GNUC_STDC_INLINE__ 1
|
||||
#define __DQ_IBIT__ 0
|
||||
#define __DBL_MAX__ double(1.7976931348623157e+308L)
|
||||
#define __ULFRACT_IBIT__ 0
|
||||
#define __cpp_raw_strings 200710L
|
||||
#define __INT_FAST32_MAX__ 0x7fffffff
|
||||
#define __DBL_HAS_INFINITY__ 1
|
||||
#define __HAVE_SPECULATION_SAFE_VALUE 1
|
||||
#define __cpp_fold_expressions 201603L
|
||||
#define __ACCUM_IBIT__ 16
|
||||
#define __THUMB_INTERWORK__ 1
|
||||
#define __UINT_LEAST32_MAX__ 0xffffffffU
|
||||
#define __ULLACCUM_IBIT__ 32
|
||||
#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK
|
||||
#define __cpp_delegating_constructors 200604L
|
||||
#define __FLT32X_HAS_DENORM__ 1
|
||||
#define __INT_FAST16_TYPE__ int
|
||||
#define __LDBL_HAS_DENORM__ 1
|
||||
#define __ARM_FEATURE_LDREX 4
|
||||
#define __cplusplus 201703L
|
||||
#define __cpp_ref_qualifiers 200710L
|
||||
#define __FLT32_DECIMAL_DIG__ 9
|
||||
#define __INT_LEAST32_MAX__ 0x7fffffff
|
||||
#define __ACCUM_MAX__ 0X7FFFFFFFP-15K
|
||||
#define __DEPRECATED 1
|
||||
#define __cpp_rvalue_references 200610L
|
||||
#define __DBL_MAX_EXP__ 1024
|
||||
#define __USACCUM_EPSILON__ 0x1P-8UHK
|
||||
#define __WCHAR_WIDTH__ 32
|
||||
#define __FLT32_MAX__ 3.4028234663852886e+38F32
|
||||
#define __SFRACT_MAX__ 0X7FP-7HR
|
||||
#define __FRACT_IBIT__ 0
|
||||
#define __PTRDIFF_MAX__ 0x7fffffff
|
||||
#define __UACCUM_MIN__ 0.0UK
|
||||
#define __UACCUM_IBIT__ 16
|
||||
#define __FLT32_HAS_QUIET_NAN__ 1
|
||||
#define __GNUG__ 10
|
||||
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
|
||||
#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK
|
||||
#define __cpp_nsdmi 200809L
|
||||
#define __SIZEOF_WINT_T__ 4
|
||||
#define __ARM_FEATURE_UNALIGNED 1
|
||||
#define __LONG_LONG_WIDTH__ 64
|
||||
#define __cpp_initializer_lists 200806L
|
||||
#define __FLT32_MAX_EXP__ 128
|
||||
#define __ULLACCUM_MIN__ 0.0ULLK
|
||||
#define __cpp_hex_float 201603L
|
||||
#define __cpp_threadsafe_static_init 200806L
|
||||
#define __GXX_ABI_VERSION 1014
|
||||
#define __UTA_FBIT__ 64
|
||||
#define __UFRACT_IBIT__ 0
|
||||
#define __USQ_FBIT__ 32
|
||||
#define __cpp_enumerator_attributes 201411L
|
||||
#define __cpp_lambdas 200907L
|
||||
#define __ARM_FEATURE_QBIT 1
|
||||
#define __INT_FAST64_TYPE__ long long int
|
||||
#define __FLT64_DENORM_MIN__ 4.9406564584124654e-324F64
|
||||
#define __DBL_MIN__ double(2.2250738585072014e-308L)
|
||||
#define __SIZEOF_POINTER__ 4
|
||||
#define __INT16_TYPE__ short int
|
||||
#define __DBL_HAS_QUIET_NAN__ 1
|
||||
#define __FLT32X_EPSILON__ 2.2204460492503131e-16F32x
|
||||
#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK)
|
||||
#define __FRACT_FBIT__ 15
|
||||
#define __FLT64_MIN_10_EXP__ (-307)
|
||||
#define __ULLFRACT_EPSILON__ 0x1P-64ULLR
|
||||
#define __REGISTER_PREFIX__
|
||||
#define __UINT16_MAX__ 0xffff
|
||||
#define __ACCUM_MIN__ (-0X1P15K-0X1P15K)
|
||||
#define __SQ_IBIT__ 0
|
||||
#define __UINT8_TYPE__ unsigned char
|
||||
#define __UHA_FBIT__ 8
|
||||
#define __SFRACT_MIN__ (-0.5HR-0.5HR)
|
||||
#define __UTQ_FBIT__ 128
|
||||
#define __DEC_EVAL_METHOD__ 2
|
||||
#define __FLT_MANT_DIG__ 24
|
||||
#define __LDBL_DECIMAL_DIG__ 17
|
||||
#define __VERSION__ "10.2.1 20210110"
|
||||
#define __UINT64_C(c) c ## ULL
|
||||
#define __cpp_unicode_characters 201411L
|
||||
#define __FRACT_EPSILON__ 0x1P-15R
|
||||
#define __ULACCUM_MIN__ 0.0ULK
|
||||
#define _STDC_PREDEF_H 1
|
||||
#define __UDA_FBIT__ 32
|
||||
#define __GCC_ATOMIC_INT_LOCK_FREE 2
|
||||
#define __FLT_MIN_EXP__ (-125)
|
||||
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
#define __USFRACT_MIN__ 0.0UHR
|
||||
#define __FLT32_MANT_DIG__ 24
|
||||
#define __ULLFRACT_FBIT__ 64
|
||||
#define __cpp_aggregate_bases 201603L
|
||||
#define __UQQ_IBIT__ 0
|
||||
#define __SCHAR_WIDTH__ 8
|
||||
#define __INT32_C(c) c
|
||||
#define __ORDER_PDP_ENDIAN__ 3412
|
||||
#define __UHQ_FBIT__ 16
|
||||
#define __LLACCUM_FBIT__ 31
|
||||
#define __INT_FAST32_TYPE__ int
|
||||
#define __UINT_LEAST16_TYPE__ short unsigned int
|
||||
#define unix 1
|
||||
#define __DBL_HAS_DENORM__ 1
|
||||
#define __cpp_rtti 199711L
|
||||
#define __SIZE_TYPE__ unsigned int
|
||||
#define __UINT64_MAX__ 0xffffffffffffffffULL
|
||||
#define __UDQ_FBIT__ 64
|
||||
#define __INT8_TYPE__ signed char
|
||||
#define __cpp_digit_separators 201309L
|
||||
#define __ELF__ 1
|
||||
#define __SACCUM_EPSILON__ 0x1P-7HK
|
||||
#define __ULFRACT_EPSILON__ 0x1P-32ULR
|
||||
#define __LLFRACT_FBIT__ 63
|
||||
#define __FLT_RADIX__ 2
|
||||
#define __INT_LEAST16_TYPE__ short int
|
||||
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
|
||||
#define __UINTMAX_C(c) c ## ULL
|
||||
#define __SACCUM_MAX__ 0X7FFFP-7HK
|
||||
#define __FLT32X_MIN__ 2.2250738585072014e-308F32x
|
||||
#define __SIG_ATOMIC_MAX__ 0x7fffffff
|
||||
#define __UACCUM_FBIT__ 16
|
||||
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
|
||||
#define __VFP_FP__ 1
|
||||
#define __SIZEOF_PTRDIFF_T__ 4
|
||||
#define __ATOMIC_ACQUIRE 2
|
||||
#define __unix__ 1
|
||||
#define __INT_WIDTH__ 32
|
||||
#define __OPTIMIZE__ 1
|
||||
#define __LACCUM_EPSILON__ 0x1P-31LK
|
||||
#define __LDBL_DIG__ 15
|
||||
#define __FLT32X_MIN_EXP__ (-1021)
|
||||
#define __INT_FAST16_MAX__ 0x7fffffff
|
||||
#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR
|
||||
#define __ARM_ARCH_6__ 1
|
||||
#define __FLT64_DIG__ 15
|
||||
#define __UINT_FAST32_MAX__ 0xffffffffU
|
||||
#define __UINT_LEAST64_TYPE__ long long unsigned int
|
||||
#define __SFRACT_EPSILON__ 0x1P-7HR
|
||||
#define __GCC_ASM_FLAG_OUTPUTS__ 1
|
||||
#define __FLT_HAS_QUIET_NAN__ 1
|
||||
#define __FLT_MAX_10_EXP__ 38
|
||||
#define __LONG_MAX__ 0x7fffffffL
|
||||
#define __SIZEOF_SIZE_T__ 4
|
||||
#define __FLT_HAS_INFINITY__ 1
|
||||
#define __unix 1
|
||||
#define __cpp_unicode_literals 200710L
|
||||
#define __cpp_init_captures 201304L
|
||||
#define __UINT_FAST16_TYPE__ unsigned int
|
||||
#define __ARM_32BIT_STATE 1
|
||||
#define __INT_FAST32_WIDTH__ 32
|
||||
#define __CHAR16_TYPE__ short unsigned int
|
||||
#define __PRAGMA_REDEFINE_EXTNAME 1
|
||||
#define __SIZE_WIDTH__ 32
|
||||
#define __INT_LEAST16_MAX__ 0x7fff
|
||||
#define __INT64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __SACCUM_FBIT__ 7
|
||||
#define __FLT32_DENORM_MIN__ 1.4012984643248171e-45F32
|
||||
#define __SIG_ATOMIC_WIDTH__ 32
|
||||
#define __INT_LEAST64_TYPE__ long long int
|
||||
#define __ARM_FEATURE_CLZ 1
|
||||
#define __INT_LEAST8_TYPE__ signed char
|
||||
#define __cpp_structured_bindings 201606L
|
||||
#define __SQ_FBIT__ 31
|
||||
#define __USFRACT_MAX__ 0XFFP-8UHR
|
||||
#define __ARM_ARCH_ISA_THUMB 1
|
||||
#define __INT_FAST8_MAX__ 0x7f
|
||||
#define __ARM_ARCH 6
|
||||
#define __INTPTR_MAX__ 0x7fffffff
|
||||
#define __cpp_sized_deallocation 201309L
|
||||
#define __cpp_guaranteed_copy_elision 201606L
|
||||
#define __QQ_FBIT__ 7
|
||||
#define linux 1
|
||||
#define __UTA_IBIT__ 64
|
||||
#define __FLT64_HAS_QUIET_NAN__ 1
|
||||
#define __UINT16_C(c) c
|
||||
#define __PTRDIFF_WIDTH__ 32
|
||||
#define __LDBL_MANT_DIG__ 53
|
||||
#define __SFRACT_FBIT__ 7
|
||||
#define __cpp_range_based_for 201603L
|
||||
#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK)
|
||||
#define __FLT64_HAS_INFINITY__ 1
|
||||
#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8
|
||||
#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
|
||||
#define __GCC_ATOMIC_LONG_LOCK_FREE 2
|
||||
#define __cpp_nontype_template_args 201411L
|
||||
#define __UINT16_TYPE__ short unsigned int
|
||||
#define __WCHAR_TYPE__ unsigned int
|
||||
#define __SIZEOF_FLOAT__ 4
|
||||
#define __TQ_FBIT__ 127
|
||||
#define __UINTPTR_MAX__ 0xffffffffU
|
||||
#define __INT_FAST64_WIDTH__ 64
|
||||
#define __cpp_decltype 200707L
|
||||
#define __cpp_nested_namespace_definitions 201411L
|
||||
#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
|
||||
#define __FLT_NORM_MAX__ 3.4028234663852886e+38F
|
||||
#define __FLT32_HAS_INFINITY__ 1
|
||||
#define __UINT_FAST64_TYPE__ long long unsigned int
|
||||
#define __cpp_inline_variables 201606L
|
||||
#define __LACCUM_FBIT__ 31
|
||||
#define __HA_FBIT__ 7
|
||||
#define __UHA_IBIT__ 8
|
||||
#define __INT64_TYPE__ long long int
|
||||
#define __UTQ_IBIT__ 0
|
||||
#define __DBL_MANT_DIG__ 53
|
||||
#define __cpp_inheriting_constructors 201511L
|
||||
#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL
|
||||
#define __WINT_TYPE__ unsigned int
|
||||
#define __UINT_LEAST32_TYPE__ unsigned int
|
||||
#define __SIZEOF_SHORT__ 2
|
||||
#define __ULLFRACT_IBIT__ 0
|
||||
#define __FLT32_NORM_MAX__ 3.4028234663852886e+38F32
|
||||
#define __LDBL_MIN_EXP__ (-1021)
|
||||
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
|
||||
#define __INTMAX_MAX__ 0x7fffffffffffffffLL
|
||||
#define __arm__ 1
|
||||
#define __FLT64_MAX__ 1.7976931348623157e+308F64
|
||||
#define __UDA_IBIT__ 32
|
||||
#define __INT_MAX__ 0x7fffffff
|
||||
#define __WINT_WIDTH__ 32
|
||||
#define __cpp_template_auto 201606L
|
||||
#define __INT_LEAST8_MAX__ 0x7f
|
||||
#define __INT_LEAST64_WIDTH__ 64
|
||||
#define __FLT32X_MAX_10_EXP__ 308
|
||||
#define __LLACCUM_EPSILON__ 0x1P-31LLK
|
||||
#define __LFRACT_FBIT__ 31
|
||||
#define __WCHAR_UNSIGNED__ 1
|
||||
#define __LDBL_MAX_10_EXP__ 308
|
||||
#define __ATOMIC_RELAXED 0
|
||||
#define __DBL_EPSILON__ double(2.2204460492503131e-16L)
|
||||
#define __ARM_FEATURE_SIMD32 1
|
||||
#define __UINT8_C(c) c
|
||||
#define __FLT64_MAX_EXP__ 1024
|
||||
#define __INT_LEAST32_TYPE__ int
|
||||
#define __cpp_return_type_deduction 201304L
|
||||
#define __SIZEOF_WCHAR_T__ 4
|
||||
#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR
|
||||
#define __FLT64_NORM_MAX__ 1.7976931348623157e+308F64
|
||||
#define __INT_FAST8_TYPE__ signed char
|
||||
#define __cpp_namespace_attributes 201411L
|
||||
#define __ULLACCUM_EPSILON__ 0x1P-32ULLK
|
||||
#define __USACCUM_MAX__ 0XFFFFP-8UHK
|
||||
#define __LDBL_HAS_INFINITY__ 1
|
||||
#define __FLT32_MAX_10_EXP__ 38
|
||||
#define __UHQ_IBIT__ 0
|
||||
#define __ARM_FEATURE_COPROC 15
|
||||
#define __LLACCUM_IBIT__ 32
|
||||
#define __ULFRACT_MIN__ 0.0ULR
|
||||
#define __FLT64_HAS_DENORM__ 1
|
||||
#define __FLT32_EPSILON__ 1.1920928955078125e-7F32
|
||||
#define __DBL_DECIMAL_DIG__ 17
|
||||
#define __STDC_UTF_32__ 1
|
||||
#define __INT_FAST8_WIDTH__ 8
|
||||
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
#define __FLT32X_MAX__ 1.7976931348623157e+308F32x
|
||||
#define __TA_FBIT__ 63
|
||||
#define __DBL_NORM_MAX__ double(1.7976931348623157e+308L)
|
||||
#define __UDQ_IBIT__ 0
|
||||
#define __INTMAX_WIDTH__ 64
|
||||
#define __ORDER_BIG_ENDIAN__ 4321
|
||||
#define __ARM_FEATURE_DSP 1
|
||||
#define __cpp_runtime_arrays 198712L
|
||||
#define __UINT64_TYPE__ long long unsigned int
|
||||
#define __ACCUM_EPSILON__ 0x1P-15K
|
||||
#define __UINT32_C(c) c ## U
|
||||
#define __cpp_alias_templates 200704L
|
||||
#define __QQ_IBIT__ 0
|
||||
#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
|
||||
#define __LLFRACT_IBIT__ 0
|
||||
#define __INT8_MAX__ 0x7f
|
||||
#define __LONG_WIDTH__ 32
|
||||
#define __INT32_MAX__ 0x7fffffff
|
||||
#define __UINT_FAST32_TYPE__ unsigned int
|
||||
#define __FLT32X_NORM_MAX__ 1.7976931348623157e+308F32x
|
||||
#define __CHAR32_TYPE__ unsigned int
|
||||
#define __FLT32_MIN_10_EXP__ (-37)
|
||||
#define __FLT_MAX__ 3.4028234663852886e+38F
|
||||
#define __cpp_constexpr 201603L
|
||||
#define __USACCUM_FBIT__ 8
|
||||
#define __cpp_deduction_guides 201703L
|
||||
#define __INT32_TYPE__ int
|
||||
#define __SIZEOF_DOUBLE__ 8
|
||||
#define __cpp_exceptions 199711L
|
||||
#define __FLT_MIN_10_EXP__ (-37)
|
||||
#define __UFRACT_EPSILON__ 0x1P-16UR
|
||||
#define __FLT64_MIN__ 2.2250738585072014e-308F64
|
||||
#define __INT_LEAST32_WIDTH__ 32
|
||||
#define __INTMAX_TYPE__ long long int
|
||||
#define __FLT32X_HAS_QUIET_NAN__ 1
|
||||
#define __ATOMIC_CONSUME 1
|
||||
#define __GNUC_MINOR__ 2
|
||||
#define __INT_FAST16_WIDTH__ 32
|
||||
#define __UINTMAX_MAX__ 0xffffffffffffffffULL
|
||||
#define __FLT32X_DENORM_MIN__ 4.9406564584124654e-324F32x
|
||||
#define __cpp_template_template_args 201611L
|
||||
#define __ATOMIC_ACQ_REL 4
|
||||
#define __DBL_MAX_10_EXP__ 308
|
||||
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
|
||||
#define __INT16_C(c) c
|
||||
#define __STDC__ 1
|
||||
#define __FLT32X_DIG__ 15
|
||||
#define __PTRDIFF_TYPE__ int
|
||||
#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR)
|
||||
#define __USACCUM_MIN__ 0.0UHK
|
||||
#define __FLT32_MIN__ 1.1754943508222875e-38F32
|
||||
#define __ATOMIC_SEQ_CST 5
|
||||
#define __DA_FBIT__ 31
|
||||
#define __EXCEPTIONS 1
|
||||
#define __UINT32_TYPE__ unsigned int
|
||||
#define __FLT32X_MIN_10_EXP__ (-307)
|
||||
#define __UINTPTR_TYPE__ unsigned int
|
||||
#define __USA_IBIT__ 16
|
||||
#define __ARM_EABI__ 1
|
||||
#define __linux__ 1
|
||||
#define __LDBL_MIN_10_EXP__ (-307)
|
||||
#define __cpp_generic_lambdas 201304L
|
||||
#define __SIZEOF_LONG_LONG__ 8
|
||||
#define __ULACCUM_EPSILON__ 0x1P-32ULK
|
||||
#define __cpp_user_defined_literals 200809L
|
||||
#define __SACCUM_IBIT__ 8
|
||||
#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
|
||||
#define __FLT_DECIMAL_DIG__ 9
|
||||
#define __UINT_FAST16_MAX__ 0xffffffffU
|
||||
#define __LDBL_NORM_MAX__ 1.7976931348623157e+308L
|
||||
#define __GCC_ATOMIC_SHORT_LOCK_FREE 1
|
||||
#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR
|
||||
#define __UINT_FAST8_TYPE__ unsigned char
|
||||
#define _GNU_SOURCE 1
|
||||
#define __USFRACT_EPSILON__ 0x1P-8UHR
|
||||
#define __ULACCUM_FBIT__ 32
|
||||
#define __ATOMIC_RELEASE 3
|
||||
|
148
pigbeeper.cpp
148
pigbeeper.cpp
@@ -1,74 +1,74 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigbeeper.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
pigBeeper::pigBeeper( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigBeeper::~pigBeeper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigBeeper::play_tone( double freq, double duration )
|
||||
{
|
||||
double halveWaveTime = 1 / ( freq * 2 );
|
||||
int ms = (int)( 1000 * halveWaveTime );
|
||||
double waves = duration * freq;
|
||||
int wv = (int) waves;
|
||||
//std::cout << "sleep: " << halveWaveTime << " in micros: " << ms << " waves: " << waves << std::endl;
|
||||
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
for( int i=0; i < wv; ++i )
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
delay_millis( ms );
|
||||
_pinOut.set_level( low );
|
||||
delay_millis( ms );
|
||||
}
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigBeeper::play_tune( std::vector<double> frv, std::vector<double> drv )
|
||||
{
|
||||
size_t count = std::max( frv.size(), drv.size() );
|
||||
for( size_t i=0; i<count; ++i )
|
||||
{
|
||||
//std::cout << "tone: " << freq[i] << " duration " << duration[i] << std::endl;
|
||||
play_tone( frv[i], drv[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigbeeper.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
pigBeeper::pigBeeper( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigBeeper::~pigBeeper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigBeeper::play_tone( double freq, double duration )
|
||||
{
|
||||
double halveWaveTime = 1 / ( freq * 2 );
|
||||
int ms = (int)( 1000 * halveWaveTime );
|
||||
double waves = duration * freq;
|
||||
int wv = (int) waves;
|
||||
//std::cout << "sleep: " << halveWaveTime << " in micros: " << ms << " waves: " << waves << std::endl;
|
||||
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
for( int i=0; i < wv; ++i )
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
delay_millis( ms );
|
||||
_pinOut.set_level( low );
|
||||
delay_millis( ms );
|
||||
}
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigBeeper::play_tune( std::vector<double> frv, std::vector<double> drv )
|
||||
{
|
||||
size_t count = std::max( frv.size(), drv.size() );
|
||||
for( size_t i=0; i<count; ++i )
|
||||
{
|
||||
//std::cout << "tone: " << freq[i] << " duration " << duration[i] << std::endl;
|
||||
play_tone( frv[i], drv[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
100
pigbeeper.h
100
pigbeeper.h
@@ -1,50 +1,50 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBEEPER_H
|
||||
#define PIGBEEPER_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigBeeper : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigBeeper( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigBeeper();
|
||||
|
||||
void play_tone( double freq, double duration );
|
||||
void play_tune( std::vector<double> frv, std::vector<double> drv );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGBEEPER_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBEEPER_H
|
||||
#define PIGBEEPER_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigBeeper : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigBeeper( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigBeeper();
|
||||
|
||||
void play_tone( double freq, double duration );
|
||||
void play_tune( std::vector<double> frv, std::vector<double> drv );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGBEEPER_H
|
||||
|
138
pigbutton.cpp
138
pigbutton.cpp
@@ -1,69 +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() );
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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() );
|
||||
}
|
||||
|
108
pigbutton.h
108
pigbutton.h
@@ -1,54 +1,54 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBUTTON_H
|
||||
#define PIGBUTTON_H
|
||||
|
||||
#include <pignodein.h>
|
||||
|
||||
class LIBPIGPIO_EXPORT pigButton : public pigNodeIn
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
pigButton();
|
||||
pigButton( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigButton();
|
||||
|
||||
void init( pigpio::bcm_t bcmNo );
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void trigger( pigpio::bcm_t bcm, uint32_t level ) override;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGBUTTON_H
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBUTTON_H
|
||||
#define PIGBUTTON_H
|
||||
|
||||
#include <pignodein.h>
|
||||
|
||||
class LIBPIGPIO_EXPORT pigButton : public pigNodeIn
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
pigButton();
|
||||
pigButton( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigButton();
|
||||
|
||||
void init( pigpio::bcm_t bcmNo );
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void trigger( pigpio::bcm_t bcm, uint32_t level ) override;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGBUTTON_H
|
||||
|
||||
|
||||
|
||||
|
130
pigbuzzer.cpp
130
pigbuzzer.cpp
@@ -1,65 +1,65 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigbuzzer.h>
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
pigBuzzer::pigBuzzer( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigBuzzer::~pigBuzzer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigBuzzer::buzz( int millisOn, int millisOff )
|
||||
{
|
||||
/*
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
if( millisOff )
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
} );
|
||||
thrd.detach();
|
||||
*/
|
||||
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
if( millisOff )
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigbuzzer.h>
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
pigBuzzer::pigBuzzer( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigBuzzer::~pigBuzzer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigBuzzer::buzz( int millisOn, int millisOff )
|
||||
{
|
||||
/*
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
if( millisOff )
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
} );
|
||||
thrd.detach();
|
||||
*/
|
||||
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
if( millisOff )
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
|
||||
}
|
||||
|
100
pigbuzzer.h
100
pigbuzzer.h
@@ -1,50 +1,50 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBUZZER_H
|
||||
#define PIGBUZZER_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigBuzzer : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigBuzzer( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigBuzzer();
|
||||
|
||||
void buzz( int millisOn, int millisOff = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGBUZZER_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGBUZZER_H
|
||||
#define PIGBUZZER_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigBuzzer : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigBuzzer( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigBuzzer();
|
||||
|
||||
void buzz( int millisOn, int millisOff = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGBUZZER_H
|
||||
|
44
pigcall.cpp
44
pigcall.cpp
@@ -1,22 +1,22 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
74
pigcall.h
74
pigcall.h
@@ -1,37 +1,37 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGCALL_H
|
||||
#define PIGCALL_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
|
||||
class pigCall
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual void trigger( pigpio::bcm_t, uint32_t ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGCALL_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGCALL_H
|
||||
#define PIGCALL_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
|
||||
class pigCall
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual void trigger( pigpio::bcm_t, uint32_t ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGCALL_H
|
||||
|
@@ -1,49 +1,49 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigchrono.h>
|
||||
|
||||
|
||||
//using namespace std::chrono;
|
||||
|
||||
pigChrono::pigChrono()
|
||||
: _beg{ _clock::now() }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigChrono::start()
|
||||
{
|
||||
_beg = _clock::now();
|
||||
}
|
||||
|
||||
|
||||
double pigChrono::elapsed_millis() const
|
||||
{
|
||||
return (double) duration_cast<milliseconds>( _clock::now() - _beg ).count() ;
|
||||
}
|
||||
|
||||
|
||||
double pigChrono::elapsed_micros() const
|
||||
{
|
||||
return (double) duration_cast<microseconds>( _clock::now() - _beg ).count() ;
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigchrono.h>
|
||||
|
||||
|
||||
//using namespace std::chrono;
|
||||
|
||||
pigChrono::pigChrono()
|
||||
: _beg{ _clock::now() }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigChrono::start()
|
||||
{
|
||||
_beg = _clock::now();
|
||||
}
|
||||
|
||||
|
||||
double pigChrono::elapsed_millis() const
|
||||
{
|
||||
return (double) duration_cast<milliseconds>( _clock::now() - _beg ).count() ;
|
||||
}
|
||||
|
||||
|
||||
double pigChrono::elapsed_micros() const
|
||||
{
|
||||
return (double) duration_cast<microseconds>( _clock::now() - _beg ).count() ;
|
||||
}
|
||||
|
106
pigchrono.h
106
pigchrono.h
@@ -1,53 +1,53 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGCHRONO_H
|
||||
#define PIGCHRONO_H
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <libpigpio.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace chrono;
|
||||
|
||||
class LIBPIGPIO_EXPORT pigChrono
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigChrono();
|
||||
virtual ~pigChrono() = default;
|
||||
|
||||
void start();
|
||||
double elapsed_millis() const;
|
||||
double elapsed_micros() const;
|
||||
|
||||
protected:
|
||||
|
||||
using _clock = high_resolution_clock;
|
||||
time_point<_clock> _beg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGCHRONO_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGCHRONO_H
|
||||
#define PIGCHRONO_H
|
||||
|
||||
|
||||
#include <chrono>
|
||||
#include <libpigpio.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace chrono;
|
||||
|
||||
class LIBPIGPIO_EXPORT pigChrono
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigChrono();
|
||||
virtual ~pigChrono() = default;
|
||||
|
||||
void start();
|
||||
double elapsed_millis() const;
|
||||
double elapsed_micros() const;
|
||||
|
||||
protected:
|
||||
|
||||
using _clock = high_resolution_clock;
|
||||
time_point<_clock> _beg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGCHRONO_H
|
||||
|
110
pigi2c.cpp
110
pigi2c.cpp
@@ -1,55 +1,55 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigi2c.h>
|
||||
|
||||
pigI2C::pigI2C()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigI2C::pigI2C( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
init( aaddr, abus );
|
||||
}
|
||||
|
||||
|
||||
pigI2C::~pigI2C()
|
||||
{
|
||||
pigpio::i2c_close( *this );
|
||||
}
|
||||
|
||||
|
||||
void pigI2C::init( i2c_addr_t aaddr , i2c_bus_t abus )
|
||||
{
|
||||
addr = aaddr;
|
||||
bus = abus;
|
||||
|
||||
handle = pigpio::i2c_open( *this );
|
||||
}
|
||||
|
||||
|
||||
int pigI2C::i2c_write_device( char* buf, unsigned count )
|
||||
{
|
||||
return pigpio::i2c_write_device( *this, buf, count );
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigi2c.h>
|
||||
|
||||
pigI2C::pigI2C()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigI2C::pigI2C( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
init( aaddr, abus );
|
||||
}
|
||||
|
||||
|
||||
pigI2C::~pigI2C()
|
||||
{
|
||||
pigpio::i2c_close( *this );
|
||||
}
|
||||
|
||||
|
||||
void pigI2C::init( i2c_addr_t aaddr , i2c_bus_t abus )
|
||||
{
|
||||
addr = aaddr;
|
||||
bus = abus;
|
||||
|
||||
handle = pigpio::i2c_open( *this );
|
||||
}
|
||||
|
||||
|
||||
int pigI2C::i2c_write_device( char* buf, unsigned count )
|
||||
{
|
||||
return pigpio::i2c_write_device( *this, buf, count );
|
||||
}
|
||||
|
102
pigi2c.h
102
pigi2c.h
@@ -1,51 +1,51 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGI2C_H
|
||||
#define PIGI2C_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
using namespace pigpio;
|
||||
|
||||
struct LIBPIGPIO_EXPORT pigI2C
|
||||
{
|
||||
|
||||
i2c_addr_t addr = 0;
|
||||
i2c_bus_t bus = 1;
|
||||
uint32_t handle = 0;
|
||||
|
||||
pigI2C();
|
||||
explicit pigI2C( i2c_addr_t, i2c_bus_t = 1 );
|
||||
virtual ~pigI2C();
|
||||
|
||||
void init( i2c_addr_t, i2c_bus_t = 1 );
|
||||
|
||||
int i2c_write_device( char* buf, unsigned count );
|
||||
//void dump();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGI2C_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGI2C_H
|
||||
#define PIGI2C_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
using namespace pigpio;
|
||||
|
||||
struct LIBPIGPIO_EXPORT pigI2C
|
||||
{
|
||||
|
||||
i2c_addr_t addr = 0;
|
||||
i2c_bus_t bus = 1;
|
||||
uint32_t handle = 0;
|
||||
|
||||
pigI2C();
|
||||
explicit pigI2C( i2c_addr_t, i2c_bus_t = 1 );
|
||||
virtual ~pigI2C();
|
||||
|
||||
void init( i2c_addr_t, i2c_bus_t = 1 );
|
||||
|
||||
int i2c_write_device( char* buf, unsigned count );
|
||||
//void dump();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGI2C_H
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#include "pigi2cnode.h"
|
||||
|
||||
pigI2CNode::pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
init( aaddr, abus );
|
||||
}
|
||||
|
||||
|
||||
void pigI2CNode::init( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
_i2c.init( aaddr, abus );
|
||||
}
|
||||
#include "pigi2cnode.h"
|
||||
|
||||
pigI2CNode::pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
init( aaddr, abus );
|
||||
}
|
||||
|
||||
|
||||
void pigI2CNode::init( i2c_addr_t aaddr, i2c_bus_t abus )
|
||||
{
|
||||
_i2c.init( aaddr, abus );
|
||||
}
|
||||
|
106
pigi2cnode.h
106
pigi2cnode.h
@@ -1,53 +1,53 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGI2CNODE_H
|
||||
#define PIGI2CNODE_H
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pignode.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigI2CNode : public pigNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigI2CNode() = default;
|
||||
pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus );
|
||||
virtual ~pigI2CNode() = default;
|
||||
|
||||
void init( i2c_addr_t aaddr, i2c_bus_t abus );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
pigI2C _i2c;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGI2CNODE_H
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGI2CNODE_H
|
||||
#define PIGI2CNODE_H
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pignode.h>
|
||||
#include <pigi2c.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigI2CNode : public pigNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigI2CNode() = default;
|
||||
pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus );
|
||||
virtual ~pigI2CNode() = default;
|
||||
|
||||
void init( i2c_addr_t aaddr, i2c_bus_t abus );
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
pigI2C _i2c;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // PIGI2CNODE_H
|
||||
|
||||
|
||||
|
364
piglcd.cpp
364
piglcd.cpp
@@ -1,182 +1,182 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <piglcd.h>
|
||||
|
||||
|
||||
|
||||
pigLCD::pigLCD( i2c_addr_t addr, i2c_bus_t bus )
|
||||
{
|
||||
init( addr, bus );
|
||||
}
|
||||
|
||||
|
||||
pigLCD::~pigLCD()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::init( i2c_addr_t addr, i2c_bus_t bus, int width, bool bl, uint8_t RS, uint8_t , uint8_t E, uint8_t BL, uint8_t B4 )
|
||||
{
|
||||
_i2c.init( addr, bus );
|
||||
|
||||
_width = width;
|
||||
_backlight = bl;
|
||||
|
||||
_RS = (1<<RS);
|
||||
_E = (1<<E);
|
||||
_BL = (1<<BL);
|
||||
_B4 = B4;
|
||||
|
||||
put_inst( 0x33 ); // Initialise 1
|
||||
put_inst( 0x32 ); // Initialise 2
|
||||
put_inst( 0x06 ); // Cursor increment
|
||||
put_inst( 0x0C ); // Display on,move_to off, blink off
|
||||
put_inst( 0x28 ); // 4-bits, 1 line, 5x8 font
|
||||
put_inst( 0x01 ); // Clear display
|
||||
//?? move_to( 0,0 )
|
||||
put_inst( _LCD_ROW[0]+0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::close
|
||||
* Close the LCD (clearing the screen) and release used resources.
|
||||
*/
|
||||
|
||||
void pigLCD::reset()
|
||||
{
|
||||
put_inst( 0x01 ); // Clear display
|
||||
set_backlight( false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::set_backlight
|
||||
* @param bl
|
||||
* toogle backlight on or off.
|
||||
*/
|
||||
|
||||
void pigLCD::set_backlight( bool bl )
|
||||
{
|
||||
_backlight = bl;
|
||||
// hack
|
||||
move_to( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::move_to
|
||||
* @param row
|
||||
* @param col
|
||||
*
|
||||
* Position cursor at row and column (0 based).
|
||||
*/
|
||||
|
||||
void pigLCD::move_to( int row, int col )
|
||||
{
|
||||
put_inst( _LCD_ROW[row]+col );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::write
|
||||
* @param c
|
||||
* Write a character at the current cursor postion and
|
||||
* increment the cursor.
|
||||
*/
|
||||
|
||||
void pigLCD::write( const char c )
|
||||
{
|
||||
put_data( (uint8_t) c );
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::write( const std::string text )
|
||||
{
|
||||
for( const char c : text )
|
||||
write( c );
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::write( int row, int col, const std::string text )
|
||||
{
|
||||
move_to( row, col );
|
||||
write( text );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void pigLCD::put_byte( uint8_t MSb, uint8_t LSb )
|
||||
{
|
||||
|
||||
if( _backlight )
|
||||
{
|
||||
MSb |= _BL;
|
||||
LSb |= _BL;
|
||||
}
|
||||
|
||||
char buf[4];
|
||||
buf[0] = (char) MSb | _E;
|
||||
buf[1] = (char) MSb & ~_E;
|
||||
buf[2] = (char) LSb | _E;
|
||||
buf[3] = LSb & ~_E;
|
||||
_i2c.i2c_write_device( buf, 4 );
|
||||
|
||||
// self.pi.i2c_write_device(self._h,
|
||||
// [MSb | self.E, MSb & ~self.E, LSb | self.E, LSb & ~self.E]) */
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::put_inst( uint8_t bits )
|
||||
{
|
||||
|
||||
uint8_t MSN = (bits>>4) & 0x0F;
|
||||
uint8_t LSN = bits & 0x0F;
|
||||
|
||||
uint8_t MSb = MSN << _B4;
|
||||
uint8_t LSb = LSN << _B4;
|
||||
|
||||
put_byte( MSb, LSb );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::put_data( uint8_t bits )
|
||||
{
|
||||
|
||||
uint8_t MSN = (bits>>4) & 0x0F;
|
||||
uint8_t LSN = bits & 0x0F;
|
||||
|
||||
uint8_t MSb = (MSN << _B4) | _RS;
|
||||
uint8_t LSb = (LSN << _B4) | _RS;
|
||||
|
||||
put_byte( MSb, LSb );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <piglcd.h>
|
||||
|
||||
|
||||
|
||||
pigLCD::pigLCD( i2c_addr_t addr, i2c_bus_t bus )
|
||||
{
|
||||
init( addr, bus );
|
||||
}
|
||||
|
||||
|
||||
pigLCD::~pigLCD()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::init( i2c_addr_t addr, i2c_bus_t bus, int width, bool bl, uint8_t RS, uint8_t , uint8_t E, uint8_t BL, uint8_t B4 )
|
||||
{
|
||||
_i2c.init( addr, bus );
|
||||
|
||||
_width = width;
|
||||
_backlight = bl;
|
||||
|
||||
_RS = (1<<RS);
|
||||
_E = (1<<E);
|
||||
_BL = (1<<BL);
|
||||
_B4 = B4;
|
||||
|
||||
put_inst( 0x33 ); // Initialise 1
|
||||
put_inst( 0x32 ); // Initialise 2
|
||||
put_inst( 0x06 ); // Cursor increment
|
||||
put_inst( 0x0C ); // Display on,move_to off, blink off
|
||||
put_inst( 0x28 ); // 4-bits, 1 line, 5x8 font
|
||||
put_inst( 0x01 ); // Clear display
|
||||
//?? move_to( 0,0 )
|
||||
put_inst( _LCD_ROW[0]+0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::close
|
||||
* Close the LCD (clearing the screen) and release used resources.
|
||||
*/
|
||||
|
||||
void pigLCD::reset()
|
||||
{
|
||||
put_inst( 0x01 ); // Clear display
|
||||
set_backlight( false );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::set_backlight
|
||||
* @param bl
|
||||
* toogle backlight on or off.
|
||||
*/
|
||||
|
||||
void pigLCD::set_backlight( bool bl )
|
||||
{
|
||||
_backlight = bl;
|
||||
// hack
|
||||
move_to( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::move_to
|
||||
* @param row
|
||||
* @param col
|
||||
*
|
||||
* Position cursor at row and column (0 based).
|
||||
*/
|
||||
|
||||
void pigLCD::move_to( int row, int col )
|
||||
{
|
||||
put_inst( _LCD_ROW[row]+col );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief pigLCD::write
|
||||
* @param c
|
||||
* Write a character at the current cursor postion and
|
||||
* increment the cursor.
|
||||
*/
|
||||
|
||||
void pigLCD::write( const char c )
|
||||
{
|
||||
put_data( (uint8_t) c );
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::write( const std::string text )
|
||||
{
|
||||
for( const char c : text )
|
||||
write( c );
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::write( int row, int col, const std::string text )
|
||||
{
|
||||
move_to( row, col );
|
||||
write( text );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void pigLCD::put_byte( uint8_t MSb, uint8_t LSb )
|
||||
{
|
||||
|
||||
if( _backlight )
|
||||
{
|
||||
MSb |= _BL;
|
||||
LSb |= _BL;
|
||||
}
|
||||
|
||||
char buf[4];
|
||||
buf[0] = (char) MSb | _E;
|
||||
buf[1] = (char) MSb & ~_E;
|
||||
buf[2] = (char) LSb | _E;
|
||||
buf[3] = LSb & ~_E;
|
||||
_i2c.i2c_write_device( buf, 4 );
|
||||
|
||||
// self.pi.i2c_write_device(self._h,
|
||||
// [MSb | self.E, MSb & ~self.E, LSb | self.E, LSb & ~self.E]) */
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::put_inst( uint8_t bits )
|
||||
{
|
||||
|
||||
uint8_t MSN = (bits>>4) & 0x0F;
|
||||
uint8_t LSN = bits & 0x0F;
|
||||
|
||||
uint8_t MSb = MSN << _B4;
|
||||
uint8_t LSb = LSN << _B4;
|
||||
|
||||
put_byte( MSb, LSb );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLCD::put_data( uint8_t bits )
|
||||
{
|
||||
|
||||
uint8_t MSN = (bits>>4) & 0x0F;
|
||||
uint8_t LSN = bits & 0x0F;
|
||||
|
||||
uint8_t MSb = (MSN << _B4) | _RS;
|
||||
uint8_t LSb = (LSN << _B4) | _RS;
|
||||
|
||||
put_byte( MSb, LSb );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
330
piglcd.h
330
piglcd.h
@@ -1,165 +1,165 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGLCD_H
|
||||
#define PIGLCD_H
|
||||
|
||||
//#include <unistd.h>
|
||||
//#include <inttypes.h>
|
||||
|
||||
#include <pigi2cnode.h>
|
||||
/*
|
||||
"""
|
||||
This class provides simple functions to display text on an I2C LCD
|
||||
based on the PCF8574T I2C 8-bit port expander.
|
||||
|
||||
PCF8574T P7 P6 P5 P4 P3 P2 P1 P0
|
||||
HD44780 B7 B6 B5 B4 BL E RW RS
|
||||
|
||||
This code defaults to working with an adapter with the above
|
||||
configuration.
|
||||
|
||||
If yours is different you will have to specify the mapping
|
||||
when you instantiate the LCD.
|
||||
"""
|
||||
|
||||
"""
|
||||
Commands
|
||||
|
||||
LCD_CLEARDISPLAY = 0x01
|
||||
LCD_RETURNHOME = 0x02
|
||||
LCD_ENTRYMODESET = 0x04
|
||||
LCD_DISPLAYCONTROL = 0x08
|
||||
LCD_CURSORSHIFT = 0x10
|
||||
LCD_FUNCTIONSET = 0x20
|
||||
LCD_SETCGRAMADDR = 0x40
|
||||
LCD_SETDDRAMADDR = 0x80
|
||||
|
||||
Flags for display entry mode
|
||||
|
||||
LCD_ENTRYRIGHT = 0x00
|
||||
LCD_ENTRYLEFT = 0x02
|
||||
LCD_ENTRYSHIFTINCREMENT = 0x01
|
||||
LCD_ENTRYSHIFTDECREMENT = 0x00
|
||||
|
||||
Flags for display on/off control
|
||||
|
||||
LCD_DISPLAYON = 0x04
|
||||
LCD_DISPLAYOFF = 0x00
|
||||
LCD_CURSORON = 0x02
|
||||
LCD_CURSOROFF = 0x00
|
||||
LCD_BLINKON = 0x01
|
||||
LCD_BLINKOFF = 0x00
|
||||
|
||||
Flags for display/cursor shift
|
||||
|
||||
LCD_DISPLAYMOVE = 0x08
|
||||
LCD_CURSORMOVE = 0x00
|
||||
LCD_MOVERIGHT = 0x04
|
||||
LCD_MOVELEFT = 0x00
|
||||
|
||||
Flags for function set
|
||||
|
||||
LCD_8BITMODE = 0x10
|
||||
LCD_4BITMODE = 0x00
|
||||
LCD_2LINE = 0x08
|
||||
LCD_1LINE = 0x00
|
||||
LCD_5x10DOTS = 0x04
|
||||
LCD_5x8DOTS = 0x00
|
||||
|
||||
Flags for backlight control
|
||||
|
||||
LCD_BACKLIGHT = 0x08
|
||||
LCD_NOBACKLIGHT = 0x00
|
||||
"""
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief The pigLCD class für //HD44780
|
||||
* Back-Port von python, siehe: https://abyz.me.uk/rpi/pigpio/code/i2c_lcd_py.zip
|
||||
*
|
||||
*/
|
||||
|
||||
class pigLCD : public pigI2CNode
|
||||
{
|
||||
//HD44780
|
||||
public:
|
||||
|
||||
pigLCD() = default;
|
||||
pigLCD( i2c_addr_t addr, i2c_bus_t bus = 1 );
|
||||
virtual ~pigLCD();
|
||||
|
||||
void init( i2c_addr_t addr, i2c_bus_t bus=1, int width=16, bool bl=true,
|
||||
uint8_t RS=0, uint8_t RW=1, uint8_t E=2, uint8_t BL=3, uint8_t B4=4 );
|
||||
|
||||
void set_backlight( bool bl );
|
||||
void move_to( int row, int col );
|
||||
void write( const char c );
|
||||
void write( const std::string text );
|
||||
void write( int row, int col, const std::string text );
|
||||
|
||||
|
||||
// inwieweit notwendig?
|
||||
void reset();
|
||||
|
||||
protected:
|
||||
|
||||
void put_byte( uint8_t MSb, uint8_t LSb );
|
||||
void put_inst( uint8_t bits );
|
||||
void put_data( uint8_t bits );
|
||||
|
||||
uint8_t _LCD_ROW[4] = { 0x80, 0xC0, 0x94, 0xD4 };
|
||||
|
||||
bool _backlight = false;
|
||||
int _width = 16;
|
||||
|
||||
//?? Type?
|
||||
uint8_t _RS;
|
||||
uint8_t _E;
|
||||
uint8_t _BL;
|
||||
uint8_t _B4;
|
||||
/*
|
||||
// GPIO chip i2c address
|
||||
uint8_t i2c=0x27;
|
||||
// Control line PINs
|
||||
uint8_t en=2;
|
||||
uint8_t rw=1;
|
||||
uint8_t rs=0;
|
||||
|
||||
// Data line PINs
|
||||
uint8_t d4=4;
|
||||
uint8_t d5=5;
|
||||
uint8_t d6=6;
|
||||
uint8_t d7=7;
|
||||
|
||||
// Backlight PIN
|
||||
uint8_t bl=3;
|
||||
|
||||
// LCD display size (1x16, 2x16, 4x20)
|
||||
uint8_t rows=2;
|
||||
uint8_t cols=16;
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGLCD_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGLCD_H
|
||||
#define PIGLCD_H
|
||||
|
||||
//#include <unistd.h>
|
||||
//#include <inttypes.h>
|
||||
|
||||
#include <pigi2cnode.h>
|
||||
/*
|
||||
"""
|
||||
This class provides simple functions to display text on an I2C LCD
|
||||
based on the PCF8574T I2C 8-bit port expander.
|
||||
|
||||
PCF8574T P7 P6 P5 P4 P3 P2 P1 P0
|
||||
HD44780 B7 B6 B5 B4 BL E RW RS
|
||||
|
||||
This code defaults to working with an adapter with the above
|
||||
configuration.
|
||||
|
||||
If yours is different you will have to specify the mapping
|
||||
when you instantiate the LCD.
|
||||
"""
|
||||
|
||||
"""
|
||||
Commands
|
||||
|
||||
LCD_CLEARDISPLAY = 0x01
|
||||
LCD_RETURNHOME = 0x02
|
||||
LCD_ENTRYMODESET = 0x04
|
||||
LCD_DISPLAYCONTROL = 0x08
|
||||
LCD_CURSORSHIFT = 0x10
|
||||
LCD_FUNCTIONSET = 0x20
|
||||
LCD_SETCGRAMADDR = 0x40
|
||||
LCD_SETDDRAMADDR = 0x80
|
||||
|
||||
Flags for display entry mode
|
||||
|
||||
LCD_ENTRYRIGHT = 0x00
|
||||
LCD_ENTRYLEFT = 0x02
|
||||
LCD_ENTRYSHIFTINCREMENT = 0x01
|
||||
LCD_ENTRYSHIFTDECREMENT = 0x00
|
||||
|
||||
Flags for display on/off control
|
||||
|
||||
LCD_DISPLAYON = 0x04
|
||||
LCD_DISPLAYOFF = 0x00
|
||||
LCD_CURSORON = 0x02
|
||||
LCD_CURSOROFF = 0x00
|
||||
LCD_BLINKON = 0x01
|
||||
LCD_BLINKOFF = 0x00
|
||||
|
||||
Flags for display/cursor shift
|
||||
|
||||
LCD_DISPLAYMOVE = 0x08
|
||||
LCD_CURSORMOVE = 0x00
|
||||
LCD_MOVERIGHT = 0x04
|
||||
LCD_MOVELEFT = 0x00
|
||||
|
||||
Flags for function set
|
||||
|
||||
LCD_8BITMODE = 0x10
|
||||
LCD_4BITMODE = 0x00
|
||||
LCD_2LINE = 0x08
|
||||
LCD_1LINE = 0x00
|
||||
LCD_5x10DOTS = 0x04
|
||||
LCD_5x8DOTS = 0x00
|
||||
|
||||
Flags for backlight control
|
||||
|
||||
LCD_BACKLIGHT = 0x08
|
||||
LCD_NOBACKLIGHT = 0x00
|
||||
"""
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief The pigLCD class für //HD44780
|
||||
* Back-Port von python, siehe: https://abyz.me.uk/rpi/pigpio/code/i2c_lcd_py.zip
|
||||
*
|
||||
*/
|
||||
|
||||
class pigLCD : public pigI2CNode
|
||||
{
|
||||
//HD44780
|
||||
public:
|
||||
|
||||
pigLCD() = default;
|
||||
pigLCD( i2c_addr_t addr, i2c_bus_t bus = 1 );
|
||||
virtual ~pigLCD();
|
||||
|
||||
void init( i2c_addr_t addr, i2c_bus_t bus=1, int width=16, bool bl=true,
|
||||
uint8_t RS=0, uint8_t RW=1, uint8_t E=2, uint8_t BL=3, uint8_t B4=4 );
|
||||
|
||||
void set_backlight( bool bl );
|
||||
void move_to( int row, int col );
|
||||
void write( const char c );
|
||||
void write( const std::string text );
|
||||
void write( int row, int col, const std::string text );
|
||||
|
||||
|
||||
// inwieweit notwendig?
|
||||
void reset();
|
||||
|
||||
protected:
|
||||
|
||||
void put_byte( uint8_t MSb, uint8_t LSb );
|
||||
void put_inst( uint8_t bits );
|
||||
void put_data( uint8_t bits );
|
||||
|
||||
uint8_t _LCD_ROW[4] = { 0x80, 0xC0, 0x94, 0xD4 };
|
||||
|
||||
bool _backlight = false;
|
||||
int _width = 16;
|
||||
|
||||
//?? Type?
|
||||
uint8_t _RS;
|
||||
uint8_t _E;
|
||||
uint8_t _BL;
|
||||
uint8_t _B4;
|
||||
/*
|
||||
// GPIO chip i2c address
|
||||
uint8_t i2c=0x27;
|
||||
// Control line PINs
|
||||
uint8_t en=2;
|
||||
uint8_t rw=1;
|
||||
uint8_t rs=0;
|
||||
|
||||
// Data line PINs
|
||||
uint8_t d4=4;
|
||||
uint8_t d5=5;
|
||||
uint8_t d6=6;
|
||||
uint8_t d7=7;
|
||||
|
||||
// Backlight PIN
|
||||
uint8_t bl=3;
|
||||
|
||||
// LCD display size (1x16, 2x16, 4x20)
|
||||
uint8_t rows=2;
|
||||
uint8_t cols=16;
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGLCD_H
|
||||
|
118
pigled.cpp
118
pigled.cpp
@@ -1,59 +1,59 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigled.h>
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
pigLED::pigLED( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigLED::~pigLED()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLED::blink( int millisOn, int millisOff )
|
||||
{
|
||||
if( !millisOff )
|
||||
millisOff = millisOn;
|
||||
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
//std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigled.h>
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
pigLED::pigLED( bcm_t bcmNo )
|
||||
: pigNodeOut( bcmNo , pull_off )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigLED::~pigLED()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigLED::blink( int millisOn, int millisOff )
|
||||
{
|
||||
if( !millisOff )
|
||||
millisOff = millisOn;
|
||||
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
_pinOut.set_level( high );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
|
||||
_pinOut.set_level( low );
|
||||
//std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
}
|
||||
|
100
pigled.h
100
pigled.h
@@ -1,50 +1,50 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGLED_H
|
||||
#define PIGLED_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigLED : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigLED( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigLED();
|
||||
|
||||
void blink( int millisOn, int millisOff = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGLED_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGLED_H
|
||||
#define PIGLED_H
|
||||
|
||||
#include <pignodeout.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
/**
|
||||
* @brief The pigBeeper class
|
||||
* ein __passiver__ Beeper, muss per PWM angesteuert
|
||||
* werden.
|
||||
*/
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigLED : public pigNodeOut
|
||||
{
|
||||
public:
|
||||
|
||||
explicit pigLED( pigpio::bcm_t bcmNo );
|
||||
virtual ~pigLED();
|
||||
|
||||
void blink( int millisOn, int millisOff = 0 );
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGLED_H
|
||||
|
82
pignode.cpp
82
pignode.cpp
@@ -1,41 +1,41 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignode.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Maa im Footer pigNode::pigNode
|
||||
*/
|
||||
|
||||
|
||||
pigNode::pigNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigNode::~pigNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignode.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Maa im Footer pigNode::pigNode
|
||||
*/
|
||||
|
||||
|
||||
pigNode::pigNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigNode::~pigNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
98
pignode.h
98
pignode.h
@@ -1,49 +1,49 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODE_H
|
||||
#define PIGNODE_H
|
||||
|
||||
#include <pigcall.h>
|
||||
#include <libpigpio.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief im HEADER The pigNode class
|
||||
*/
|
||||
|
||||
class pigNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigNode();
|
||||
virtual ~pigNode();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGNODE_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODE_H
|
||||
#define PIGNODE_H
|
||||
|
||||
#include <pigcall.h>
|
||||
#include <libpigpio.h>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief im HEADER The pigNode class
|
||||
*/
|
||||
|
||||
class pigNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigNode();
|
||||
virtual ~pigNode();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGNODE_H
|
||||
|
@@ -1,25 +1,25 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignodein.h>
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignodein.h>
|
||||
|
||||
|
||||
|
100
pignodein.h
100
pignodein.h
@@ -1,50 +1,50 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODEIN_H
|
||||
#define PIGNODEIN_H
|
||||
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigcall.h>
|
||||
#include <pigstate.h>
|
||||
#include <pigpin.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief im HEADER The pigNode class
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigNodeIn : public pigNode, public pigCall, public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigNodeIn() = default;
|
||||
virtual ~pigNodeIn() = default;
|
||||
|
||||
protected:
|
||||
|
||||
pigPinIn _pinIn;
|
||||
|
||||
};
|
||||
#endif // PIGNODEIN_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODEIN_H
|
||||
#define PIGNODEIN_H
|
||||
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigcall.h>
|
||||
#include <pigstate.h>
|
||||
#include <pigpin.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief im HEADER The pigNode class
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigNodeIn : public pigNode, public pigCall, public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigNodeIn() = default;
|
||||
virtual ~pigNodeIn() = default;
|
||||
|
||||
protected:
|
||||
|
||||
pigPinIn _pinIn;
|
||||
|
||||
};
|
||||
#endif // PIGNODEIN_H
|
||||
|
@@ -1,48 +1,48 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignodeout.h>
|
||||
|
||||
|
||||
pigNodeOut::pigNodeOut( bcm_t bcmNo, pigpio::pud_t pud )
|
||||
: _pinOut( bcmNo, pud )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigNodeOut::~pigNodeOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pigNodeOut::change_state( bool newState )
|
||||
{
|
||||
if( newState == state() )
|
||||
return;
|
||||
set_state( newState );
|
||||
//sigState( _state );
|
||||
_pinOut.set_level( _state );
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pignodeout.h>
|
||||
|
||||
|
||||
pigNodeOut::pigNodeOut( bcm_t bcmNo, pigpio::pud_t pud )
|
||||
: _pinOut( bcmNo, pud )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigNodeOut::~pigNodeOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pigNodeOut::change_state( bool newState )
|
||||
{
|
||||
if( newState == state() )
|
||||
return;
|
||||
set_state( newState );
|
||||
//sigState( _state );
|
||||
_pinOut.set_level( _state );
|
||||
}
|
||||
|
114
pignodeout.h
114
pignodeout.h
@@ -1,57 +1,57 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODEOUT_H
|
||||
#define PIGNODEOUT_H
|
||||
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigstate.h>
|
||||
#include <pigpin.h>
|
||||
|
||||
/**
|
||||
* @brief Eine Signal Senke aka receiver, drain,
|
||||
* _empfängt_ status änderungen
|
||||
* ein _aktiver_ Buzzer, nur an/aus, keine PWM, oder eben eine LED
|
||||
* werden.
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigNodeOut : public pigNode, public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
explicit pigNodeOut( pigpio::bcm_t bcmNo, pigpio::pud_t pud = pigpio::pull_off );
|
||||
virtual ~pigNodeOut();
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
protected:
|
||||
|
||||
pigPinOut _pinOut;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGNODEOUT_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGNODEOUT_H
|
||||
#define PIGNODEOUT_H
|
||||
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigstate.h>
|
||||
#include <pigpin.h>
|
||||
|
||||
/**
|
||||
* @brief Eine Signal Senke aka receiver, drain,
|
||||
* _empfängt_ status änderungen
|
||||
* ein _aktiver_ Buzzer, nur an/aus, keine PWM, oder eben eine LED
|
||||
* werden.
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigNodeOut : public pigNode, public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
explicit pigNodeOut( pigpio::bcm_t bcmNo, pigpio::pud_t pud = pigpio::pull_off );
|
||||
virtual ~pigNodeOut();
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
protected:
|
||||
|
||||
pigPinOut _pinOut;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGNODEOUT_H
|
||||
|
361
pigpin.cpp
361
pigpin.cpp
@@ -1,182 +1,179 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigpin.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
|
||||
//using namespace pigpio;
|
||||
|
||||
|
||||
pigPin::pigPin( bcm_t bcmNo, io_t modeNo, pud_t pudType )
|
||||
{
|
||||
init( bcmNo, modeNo, pudType );
|
||||
}
|
||||
|
||||
|
||||
pigPin::~pigPin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigPin::init( bcm_t bcmNo, io_t modeNo, pud_t pudType )
|
||||
{
|
||||
bcm = bcmNo;
|
||||
set_io_mode( modeNo );
|
||||
set_pud_mode( pudType );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::get_level()
|
||||
{
|
||||
return pigpio::get_level( bcm );
|
||||
}
|
||||
|
||||
|
||||
void pigPin::set_level( level_t level )
|
||||
{
|
||||
pigpio::set_level( bcm, level );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::trigger_level( unsigned level, unsigned pulseLen )
|
||||
{
|
||||
return pigpio::trigger_level( bcm, pulseLen, level );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::wait_for_edge( pigpio::edge_t edge, double timeout )
|
||||
{
|
||||
return pigpio::wait_for_edge( bcm, edge, timeout );
|
||||
}
|
||||
|
||||
|
||||
// pin config
|
||||
int pigPin::set_io_mode( io_t modType )
|
||||
{
|
||||
mode = modType;
|
||||
return pigpio::set_io_mode( bcm, mode );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::get_io_mode()
|
||||
{
|
||||
return pigpio::get_io_mode( bcm );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_pud_mode( pud_t pudType )
|
||||
{
|
||||
pud = pudType;
|
||||
return pigpio::set_pud_mode( bcm, pud );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_glitch_filter( uint32_t glitch )
|
||||
{
|
||||
return pigpio::set_glitch_filter( bcm, glitch );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_noise_filter( uint32_t steady, uint32_t active )
|
||||
{
|
||||
return pigpio::set_noise_filter( bcm, steady, active );
|
||||
}
|
||||
|
||||
// reality interface
|
||||
int pigPin::set_callback( pigCall* fn, edge_t edge )
|
||||
{
|
||||
return pigpio::set_callback( bcm, fn, edge);
|
||||
}
|
||||
|
||||
int pigPin::cancel_callback( int cbId )
|
||||
{
|
||||
return pigpio::cancel_callback( cbId );
|
||||
}
|
||||
|
||||
|
||||
void pigPin::dump()
|
||||
{
|
||||
std::cout << "\nPin: " << (uint32_t) bcm << " " << std::endl;
|
||||
std::cout << "Mode: " << (uint32_t) mode << " " << std::endl;
|
||||
std::cout << "Pud: " << (uint32_t) pud << " " << std::endl;
|
||||
}
|
||||
|
||||
/// ---
|
||||
|
||||
|
||||
pigPinIn::pigPinIn()
|
||||
{
|
||||
mode = pigpio::input;
|
||||
}
|
||||
|
||||
|
||||
pigPinIn::pigPinIn( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
|
||||
: pigPin{ bcmNo, pigpio::input, pudType }
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigPinIn::~pigPinIn()
|
||||
{
|
||||
if( cbId > -1 )
|
||||
pigpio::cancel_callback( cbId );
|
||||
}
|
||||
|
||||
void pigPinIn::init( bcm_t bcmNo, pud_t pudType )
|
||||
{
|
||||
pigPin::init( bcmNo, pigpio::input, pudType );
|
||||
}
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
|
||||
pigPinOut::pigPinOut()
|
||||
{
|
||||
mode = pigpio::output;
|
||||
}
|
||||
|
||||
|
||||
pigPinOut::pigPinOut( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
|
||||
: pigPin{ bcmNo, pigpio::output, pudType }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigPinOut::~pigPinOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigPinOut::init( bcm_t bcmNo, pud_t pudType )
|
||||
{
|
||||
pigPin::init( bcmNo, pigpio::output, pudType );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigpin.h>
|
||||
#include <libpigcore.h>
|
||||
|
||||
|
||||
pigPin::pigPin( bcm_t bcmNo, io_t modeNo, pud_t pudType )
|
||||
{
|
||||
init( bcmNo, modeNo, pudType );
|
||||
}
|
||||
|
||||
|
||||
pigPin::~pigPin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigPin::init( bcm_t bcmNo, io_t modeNo, pud_t pudType )
|
||||
{
|
||||
bcm = bcmNo;
|
||||
set_io_mode( modeNo );
|
||||
set_pud_mode( pudType );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::get_level()
|
||||
{
|
||||
return pigpio::get_level( bcm );
|
||||
}
|
||||
|
||||
|
||||
void pigPin::set_level( level_t level )
|
||||
{
|
||||
pigpio::set_level( bcm, level );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::trigger_level( unsigned level, unsigned pulseLen )
|
||||
{
|
||||
return pigpio::trigger_level( bcm, pulseLen, level );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::wait_for_edge( pigpio::edge_t edge, double timeout )
|
||||
{
|
||||
return pigpio::wait_for_edge( bcm, edge, timeout );
|
||||
}
|
||||
|
||||
|
||||
// pin config
|
||||
int pigPin::set_io_mode( io_t modType )
|
||||
{
|
||||
mode = modType;
|
||||
return pigpio::set_io_mode( bcm, mode );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::get_io_mode()
|
||||
{
|
||||
return pigpio::get_io_mode( bcm );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_pud_mode( pud_t pudType )
|
||||
{
|
||||
pud = pudType;
|
||||
return pigpio::set_pud_mode( bcm, pud );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_glitch_filter( uint32_t glitch )
|
||||
{
|
||||
return pigpio::set_glitch_filter( bcm, glitch );
|
||||
}
|
||||
|
||||
|
||||
int pigPin::set_noise_filter( uint32_t steady, uint32_t active )
|
||||
{
|
||||
return pigpio::set_noise_filter( bcm, steady, active );
|
||||
}
|
||||
|
||||
// reality interface
|
||||
int pigPin::set_callback( pigCall* fn, edge_t edge )
|
||||
{
|
||||
return pigpio::set_callback( bcm, fn, edge);
|
||||
}
|
||||
|
||||
int pigPin::cancel_callback( int cbId )
|
||||
{
|
||||
return pigpio::cancel_callback( cbId );
|
||||
}
|
||||
|
||||
|
||||
void pigPin::dump()
|
||||
{
|
||||
std::cout << "\nPin: " << (uint32_t) bcm << " " << std::endl;
|
||||
std::cout << "Mode: " << (uint32_t) mode << " " << std::endl;
|
||||
std::cout << "Pud: " << (uint32_t) pud << " " << std::endl;
|
||||
}
|
||||
|
||||
/// ---
|
||||
|
||||
|
||||
pigPinIn::pigPinIn()
|
||||
{
|
||||
mode = pigpio::input;
|
||||
}
|
||||
|
||||
|
||||
pigPinIn::pigPinIn( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
|
||||
: pigPin{ bcmNo, pigpio::input, pudType }
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigPinIn::~pigPinIn()
|
||||
{
|
||||
if( cbId > -1 )
|
||||
pigpio::cancel_callback( cbId );
|
||||
}
|
||||
|
||||
void pigPinIn::init( bcm_t bcmNo, pud_t pudType )
|
||||
{
|
||||
pigPin::init( bcmNo, pigpio::input, pudType );
|
||||
}
|
||||
|
||||
|
||||
/// ---
|
||||
|
||||
|
||||
pigPinOut::pigPinOut()
|
||||
{
|
||||
mode = pigpio::output;
|
||||
}
|
||||
|
||||
|
||||
pigPinOut::pigPinOut( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
|
||||
: pigPin{ bcmNo, pigpio::output, pudType }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigPinOut::~pigPinOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigPinOut::init( bcm_t bcmNo, pud_t pudType )
|
||||
{
|
||||
pigPin::init( bcmNo, pigpio::output, pudType );
|
||||
}
|
||||
|
||||
|
||||
|
184
pigpin.h
184
pigpin.h
@@ -1,92 +1,92 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
@@ -1,129 +1,118 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigrotarydial.h>
|
||||
|
||||
/**
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
A | | | |
|
||||
| | | |
|
||||
+---------+ +---------+ +----- 1
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
B | | | |
|
||||
| | | |
|
||||
----+ +---------+ +---------+ 1
|
||||
|
||||
*/
|
||||
|
||||
pigRotaryDial::pigRotaryDial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigRotaryDial::pigRotaryDial( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
|
||||
{
|
||||
init( bcmButton, bcmDown, bcmUp );
|
||||
}
|
||||
|
||||
|
||||
pigRotaryDial::~pigRotaryDial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigRotaryDial::init( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
|
||||
{
|
||||
|
||||
pigButton::init( bcmButton );
|
||||
/*
|
||||
_pinButton.init( bcmButton, pull_up );
|
||||
_pinButton.set_callback( this, falling );
|
||||
_pinButton.set_glitch_filter( 500 );
|
||||
*/
|
||||
|
||||
_pinUp.init( bcmUp, pull_up );
|
||||
_pinUp.set_callback( this );
|
||||
_pinUp.set_glitch_filter( 500 );
|
||||
|
||||
_pinDown.init( bcmDown, pull_up );
|
||||
_pinDown.set_callback( this );
|
||||
_pinDown.set_glitch_filter( 500 );
|
||||
|
||||
_oldState = ( _pinUp.get_level() << 1 ) | _pinDown.get_level();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigRotaryDial::reset()
|
||||
{
|
||||
_state = false;
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pigRotaryDial::trigger( pigpio::bcm_t bcm, uint32_t level )
|
||||
{
|
||||
|
||||
//std::cout << " -- pigRotaryDial::trigger: " << (uint32_t) bcm << " : " << level << std::endl;
|
||||
|
||||
if( level == pigpio::TimeOut )
|
||||
return;
|
||||
|
||||
if( bcm ==_pinIn.bcm )
|
||||
{
|
||||
//std::cout << "pigButton::trigger " << (uint32_t) bcm << " : " << level << std::endl;
|
||||
// simply on/off
|
||||
toggle_state();
|
||||
return;
|
||||
}
|
||||
|
||||
if( bcm ==_pinUp.bcm )
|
||||
_levUp = level;
|
||||
else
|
||||
_levDown = level;
|
||||
|
||||
int newState = _levUp << 1 | _levDown;
|
||||
int inc = Transits[ _oldState << 2 | newState ];
|
||||
|
||||
if( inc )
|
||||
{
|
||||
//std::cout << "dial: " << inc << std::endl;
|
||||
_oldState = newState;
|
||||
//int detent = _value / 4;
|
||||
_value += inc;
|
||||
|
||||
//if( detent != ( _step / 4) )
|
||||
// handlePulse( _step / 4 );
|
||||
//handlePulse( _step );
|
||||
|
||||
|
||||
sigValue( _value );
|
||||
}
|
||||
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigrotarydial.h>
|
||||
|
||||
/**
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
A | | | |
|
||||
| | | |
|
||||
+---------+ +---------+ +----- 1
|
||||
|
||||
+---------+ +---------+ 0
|
||||
| | | |
|
||||
B | | | |
|
||||
| | | |
|
||||
----+ +---------+ +---------+ 1
|
||||
|
||||
*/
|
||||
|
||||
pigRotaryDial::pigRotaryDial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigRotaryDial::pigRotaryDial( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
|
||||
{
|
||||
init( bcmButton, bcmUp, bcmDown );
|
||||
}
|
||||
|
||||
|
||||
pigRotaryDial::~pigRotaryDial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigRotaryDial::init( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
|
||||
{
|
||||
|
||||
pigButton::init( bcmButton );
|
||||
|
||||
_pinUp.init( bcmUp, pull_up );
|
||||
_pinUp.set_callback( this );
|
||||
_pinUp.set_glitch_filter( 1000 );
|
||||
|
||||
_pinDown.init( bcmDown, pull_up );
|
||||
_pinDown.set_callback( this );
|
||||
_pinDown.set_glitch_filter( 1000 );
|
||||
|
||||
_oldState = ( _pinUp.get_level() << 1 ) | _pinDown.get_level();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigRotaryDial::reset()
|
||||
{
|
||||
_state = false;
|
||||
_value = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pigRotaryDial::trigger( pigpio::bcm_t bcm, uint32_t level )
|
||||
{
|
||||
if( level == pigpio::TimeOut )
|
||||
return;
|
||||
|
||||
if( bcm ==_pinIn.bcm )
|
||||
{
|
||||
// simply on/off
|
||||
toggle_state();
|
||||
return;
|
||||
}
|
||||
|
||||
if( bcm ==_pinUp.bcm )
|
||||
_levUp = level;
|
||||
else
|
||||
_levDown = level;
|
||||
|
||||
int newState = _levUp << 1 | _levDown;
|
||||
int inc = Transits[ _oldState << 2 | newState ];
|
||||
|
||||
if( inc )
|
||||
{
|
||||
_oldState = newState;
|
||||
//int detent = _value / 4;
|
||||
_value += inc;
|
||||
|
||||
//if( detent != ( _step / 4) )
|
||||
// handlePulse( _step / 4 );
|
||||
//handlePulse( _step );
|
||||
|
||||
sigValue( _value );
|
||||
}
|
||||
|
||||
}
|
||||
|
146
pigrotarydial.h
146
pigrotarydial.h
@@ -1,73 +1,73 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
430
pigsonar.cpp
430
pigsonar.cpp
@@ -1,215 +1,215 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
pigSonar based on: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <pigsonar.h>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* @brief pigSonar::pigSonar
|
||||
*
|
||||
*
|
||||
* Beschreibung HC-SR04:
|
||||
* Das Ultraschall Modul HC-SR04 eignet sich zur
|
||||
* Entfernungsmessung im Bereich zwischen 2cm und ca.
|
||||
* 3m mit einer Auflösung von 3mm. Es benötigt nur eine
|
||||
* einfache Versorgungsspannung von 5V bei einer
|
||||
* Stromaufnahme von <2mA. Nach Triggerung mit einer
|
||||
* fallenden Flanke (TTL - Pegel) misst das Modul
|
||||
* selbstständig die Entfernung und wandelt diese in ein
|
||||
* PWM Signal welches am Ausgang zur Verfügung steht.
|
||||
* Ein Messintervall hat eine Dauer von 20ms. Es können
|
||||
* also 50 Messungen pro Sekunde durchgeführt werden
|
||||
*
|
||||
* https://www.mikrocontroller.net/attachment/218122/HC-SR04_ultraschallmodul_beschreibung_3.pdf
|
||||
*/
|
||||
|
||||
pigSonar::pigSonar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigSonar::pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo )
|
||||
{
|
||||
init( trigger, echo );
|
||||
}
|
||||
|
||||
|
||||
pigSonar::~pigSonar()
|
||||
{
|
||||
//detach_pin( ) //?? doch wg .callback
|
||||
}
|
||||
|
||||
|
||||
void pigSonar::init( pigpio::bcm_t trigger, pigpio::bcm_t echo )
|
||||
{
|
||||
|
||||
_pinEcho.init( echo );
|
||||
//_pinEcho.set_callback( this, rising );
|
||||
|
||||
_pinTrig.init( trigger );
|
||||
_pinTrig.set_level( low );
|
||||
|
||||
delay_millis( 500 );
|
||||
|
||||
}
|
||||
|
||||
void pigSonar::stop()
|
||||
{
|
||||
_active = false;
|
||||
}
|
||||
|
||||
void pigSonar::start( double thresh )
|
||||
{
|
||||
_active = true;
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
while( _active )
|
||||
{
|
||||
double dist = distance();
|
||||
if( dist < thresh )
|
||||
sigValue( dist );
|
||||
delay_millis( 50 );
|
||||
}
|
||||
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
}
|
||||
|
||||
|
||||
double pigSonar::distance( int timeout )
|
||||
{
|
||||
|
||||
// erholungspause
|
||||
delay_millis( 10 );
|
||||
|
||||
// ein 10 ms pulse löst die messung aus
|
||||
_pinTrig.set_level( high );
|
||||
delay_micros( 10 );
|
||||
_pinTrig.set_level( low );
|
||||
|
||||
//_timer.start();
|
||||
_now = get_current_tick();
|
||||
// busy waiting ??
|
||||
while ( _pinEcho.get_level() == low && _timer.elapsed_millis() < timeout )
|
||||
//while ( _pinEcho.get_level() == low )
|
||||
;
|
||||
|
||||
//_timer.start();
|
||||
_now = get_current_tick();
|
||||
while( _pinEcho.get_level() == high )
|
||||
;
|
||||
|
||||
uint32_t tof = get_current_tick() - _now;
|
||||
//double tof = _timer.elapsed_micros();
|
||||
_dist = 100 * ( ( tof /1000000.0 ) * 340.29 ) / 2;
|
||||
|
||||
return _dist;
|
||||
}
|
||||
|
||||
/*
|
||||
void pigSonar::trigger( pigpio::bcm_t bcm, uint32_t level )
|
||||
{
|
||||
double duration = _timer.elapsed_micros();
|
||||
// Convert the time into a distance
|
||||
_dist = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343
|
||||
//double inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Die Variante mit WiringPi ist erheblich genauer. Warum? Timer?
|
||||
Code: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
|
||||
|
||||
dort:
|
||||
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
|
||||
hier (busy wait):
|
||||
|
||||
distance: 28.21
|
||||
distance: 25.9811
|
||||
distance: 28.3121
|
||||
distance: 28.2441
|
||||
distance: 28.4482
|
||||
distance: 27.9889
|
||||
distance: 28.0569
|
||||
distance: 28.0059
|
||||
distance: 28.2441
|
||||
distance: 25.3346
|
||||
distance: 28.0059
|
||||
distance: 29.0608
|
||||
distance: 27.9718
|
||||
distance: 28.0399
|
||||
distance: 27.9889
|
||||
|
||||
|
||||
Die eigene Variante _ohne_ busy wating mit callback ist logischerweise
|
||||
auch nicht besser.
|
||||
|
||||
double Sonar::distance(int timeout)
|
||||
{
|
||||
delay(10);
|
||||
|
||||
digitalWrite(trigger, HIGH);
|
||||
delayMicroseconds(10);
|
||||
digitalWrite(trigger, LOW);
|
||||
|
||||
now=micros();
|
||||
|
||||
while (digitalRead(echo) == LOW && micros()-now<timeout)
|
||||
;
|
||||
recordPulseLength();
|
||||
|
||||
travelTimeUsec = endTimeUsec - startTimeUsec;
|
||||
distanceMeters = 100*((travelTimeUsec/1000000.0)*340.29)/2;
|
||||
|
||||
return distanceMeters;
|
||||
}
|
||||
|
||||
void Sonar::recordPulseLength()
|
||||
{
|
||||
startTimeUsec = micros();
|
||||
while ( digitalRead(echo) == HIGH )
|
||||
;
|
||||
endTimeUsec = micros();
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
pigSonar based on: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <pigsonar.h>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* @brief pigSonar::pigSonar
|
||||
*
|
||||
*
|
||||
* Beschreibung HC-SR04:
|
||||
* Das Ultraschall Modul HC-SR04 eignet sich zur
|
||||
* Entfernungsmessung im Bereich zwischen 2cm und ca.
|
||||
* 3m mit einer Auflösung von 3mm. Es benötigt nur eine
|
||||
* einfache Versorgungsspannung von 5V bei einer
|
||||
* Stromaufnahme von <2mA. Nach Triggerung mit einer
|
||||
* fallenden Flanke (TTL - Pegel) misst das Modul
|
||||
* selbstständig die Entfernung und wandelt diese in ein
|
||||
* PWM Signal welches am Ausgang zur Verfügung steht.
|
||||
* Ein Messintervall hat eine Dauer von 20ms. Es können
|
||||
* also 50 Messungen pro Sekunde durchgeführt werden
|
||||
*
|
||||
* https://www.mikrocontroller.net/attachment/218122/HC-SR04_ultraschallmodul_beschreibung_3.pdf
|
||||
*/
|
||||
|
||||
pigSonar::pigSonar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
pigSonar::pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo )
|
||||
{
|
||||
init( trigger, echo );
|
||||
}
|
||||
|
||||
|
||||
pigSonar::~pigSonar()
|
||||
{
|
||||
//detach_pin( ) //?? doch wg .callback
|
||||
}
|
||||
|
||||
|
||||
void pigSonar::init( pigpio::bcm_t trigger, pigpio::bcm_t echo )
|
||||
{
|
||||
|
||||
_pinEcho.init( echo );
|
||||
//_pinEcho.set_callback( this, rising );
|
||||
|
||||
_pinTrig.init( trigger );
|
||||
_pinTrig.set_level( low );
|
||||
|
||||
delay_millis( 500 );
|
||||
|
||||
}
|
||||
|
||||
void pigSonar::stop()
|
||||
{
|
||||
_active = false;
|
||||
}
|
||||
|
||||
void pigSonar::start( double thresh )
|
||||
{
|
||||
_active = true;
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
while( _active )
|
||||
{
|
||||
double dist = distance();
|
||||
if( dist < thresh )
|
||||
sigValue( dist );
|
||||
delay_millis( 50 );
|
||||
}
|
||||
|
||||
} );
|
||||
thrd.detach();
|
||||
|
||||
}
|
||||
|
||||
|
||||
double pigSonar::distance( int timeout )
|
||||
{
|
||||
|
||||
// erholungspause
|
||||
delay_millis( 10 );
|
||||
|
||||
// ein 10 ms pulse löst die messung aus
|
||||
_pinTrig.set_level( high );
|
||||
delay_micros( 10 );
|
||||
_pinTrig.set_level( low );
|
||||
|
||||
//_timer.start();
|
||||
_now = get_current_tick();
|
||||
// busy waiting ??
|
||||
while ( _pinEcho.get_level() == low && _timer.elapsed_millis() < timeout )
|
||||
//while ( _pinEcho.get_level() == low )
|
||||
;
|
||||
|
||||
//_timer.start();
|
||||
_now = get_current_tick();
|
||||
while( _pinEcho.get_level() == high )
|
||||
;
|
||||
|
||||
uint32_t tof = get_current_tick() - _now;
|
||||
//double tof = _timer.elapsed_micros();
|
||||
_dist = 100 * ( ( tof /1000000.0 ) * 340.29 ) / 2;
|
||||
|
||||
return _dist;
|
||||
}
|
||||
|
||||
/*
|
||||
void pigSonar::trigger( pigpio::bcm_t bcm, uint32_t level )
|
||||
{
|
||||
double duration = _timer.elapsed_micros();
|
||||
// Convert the time into a distance
|
||||
_dist = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343
|
||||
//double inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Die Variante mit WiringPi ist erheblich genauer. Warum? Timer?
|
||||
Code: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
|
||||
|
||||
dort:
|
||||
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
Distance is 27.4784 cm.
|
||||
Distance is 27.4614 cm.
|
||||
|
||||
hier (busy wait):
|
||||
|
||||
distance: 28.21
|
||||
distance: 25.9811
|
||||
distance: 28.3121
|
||||
distance: 28.2441
|
||||
distance: 28.4482
|
||||
distance: 27.9889
|
||||
distance: 28.0569
|
||||
distance: 28.0059
|
||||
distance: 28.2441
|
||||
distance: 25.3346
|
||||
distance: 28.0059
|
||||
distance: 29.0608
|
||||
distance: 27.9718
|
||||
distance: 28.0399
|
||||
distance: 27.9889
|
||||
|
||||
|
||||
Die eigene Variante _ohne_ busy wating mit callback ist logischerweise
|
||||
auch nicht besser.
|
||||
|
||||
double Sonar::distance(int timeout)
|
||||
{
|
||||
delay(10);
|
||||
|
||||
digitalWrite(trigger, HIGH);
|
||||
delayMicroseconds(10);
|
||||
digitalWrite(trigger, LOW);
|
||||
|
||||
now=micros();
|
||||
|
||||
while (digitalRead(echo) == LOW && micros()-now<timeout)
|
||||
;
|
||||
recordPulseLength();
|
||||
|
||||
travelTimeUsec = endTimeUsec - startTimeUsec;
|
||||
distanceMeters = 100*((travelTimeUsec/1000000.0)*340.29)/2;
|
||||
|
||||
return distanceMeters;
|
||||
}
|
||||
|
||||
void Sonar::recordPulseLength()
|
||||
{
|
||||
startTimeUsec = micros();
|
||||
while ( digitalRead(echo) == HIGH )
|
||||
;
|
||||
endTimeUsec = micros();
|
||||
}
|
||||
|
||||
*/
|
||||
|
128
pigsonar.h
128
pigsonar.h
@@ -1,64 +1,64 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGSONAR_H
|
||||
#define PIGSONAR_H
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigvalue.h>
|
||||
#include <pigpin.h>
|
||||
#include <pigchrono.h>
|
||||
#include <pigvalue.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigSonar : public pigNode, public pigValue<double>
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
pigSonar();
|
||||
pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo );
|
||||
virtual ~pigSonar();
|
||||
|
||||
void init( pigpio::bcm_t trigger, pigpio::bcm_t echo );
|
||||
|
||||
void stop();
|
||||
void start( double thresh = 50000 );
|
||||
|
||||
double distance( int timeout=10 );
|
||||
|
||||
protected:
|
||||
|
||||
pigPinOut _pinTrig;
|
||||
pigPinIn _pinEcho;
|
||||
|
||||
pigChrono _timer;
|
||||
double _dist;
|
||||
uint32_t _now, _lst;
|
||||
bool _active = false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGSONAR_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGSONAR_H
|
||||
#define PIGSONAR_H
|
||||
|
||||
#include <pignode.h>
|
||||
#include <pigvalue.h>
|
||||
#include <pigpin.h>
|
||||
#include <pigchrono.h>
|
||||
#include <pigvalue.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigSonar : public pigNode, public pigValue<double>
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
pigSonar();
|
||||
pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo );
|
||||
virtual ~pigSonar();
|
||||
|
||||
void init( pigpio::bcm_t trigger, pigpio::bcm_t echo );
|
||||
|
||||
void stop();
|
||||
void start( double thresh = 50000 );
|
||||
|
||||
double distance( int timeout=10 );
|
||||
|
||||
protected:
|
||||
|
||||
pigPinOut _pinTrig;
|
||||
pigPinIn _pinEcho;
|
||||
|
||||
pigChrono _timer;
|
||||
double _dist;
|
||||
uint32_t _now, _lst;
|
||||
bool _active = false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // PIGSONAR_H
|
||||
|
134
pigstate.cpp
134
pigstate.cpp
@@ -1,67 +1,67 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigstate.h>
|
||||
|
||||
|
||||
pigState::pigState( bool state )
|
||||
: _state{ state }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool pigState::state()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
void pigState::set_state( bool newState )
|
||||
{
|
||||
_state = newState;
|
||||
}
|
||||
|
||||
void pigState::toggle_state()
|
||||
{
|
||||
change_state( !state() );
|
||||
}
|
||||
|
||||
/*
|
||||
void pigState::change_state( bool newState )
|
||||
{
|
||||
if( newState == state() )
|
||||
return;
|
||||
set_state( newState );
|
||||
sigState( _state );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
void pigState::connect( pigState& listener )
|
||||
{
|
||||
sigState.connect( [&](bool state) { listener.change_state( state ); } );
|
||||
}
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 <pigstate.h>
|
||||
|
||||
|
||||
pigState::pigState( bool state )
|
||||
: _state{ state }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool pigState::state()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
void pigState::set_state( bool newState )
|
||||
{
|
||||
_state = newState;
|
||||
}
|
||||
|
||||
void pigState::toggle_state()
|
||||
{
|
||||
change_state( !state() );
|
||||
}
|
||||
|
||||
/*
|
||||
void pigState::change_state( bool newState )
|
||||
{
|
||||
if( newState == state() )
|
||||
return;
|
||||
set_state( newState );
|
||||
sigState( _state );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
void pigState::connect( pigState& listener )
|
||||
{
|
||||
sigState.connect( [&](bool state) { listener.change_state( state ); } );
|
||||
}
|
||||
*/
|
||||
|
||||
|
214
pigstate.h
214
pigstate.h
@@ -1,107 +1,107 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGSTATE_H
|
||||
#define PIGSTATE_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigvalue.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief The pigState class
|
||||
* set_state ist passiv; change_state kann von 'innen' (per Gui) _oder_ von 'aussen'
|
||||
* (elektrisch) kommen, je nach Zweck der implementierung ...
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
signalBool sigState;
|
||||
|
||||
pigState() = default;
|
||||
explicit pigState( bool astate );
|
||||
virtual ~pigState() = default;
|
||||
|
||||
bool state();
|
||||
virtual void set_state( bool newState );
|
||||
void toggle_state();
|
||||
|
||||
// passiv (empfänger) oder aktiv (sender):
|
||||
// die implemetierung entscheidet
|
||||
virtual void change_state( bool newState ) = 0;
|
||||
|
||||
template< typename T >
|
||||
void connect_state( T& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigState.connect( &T::change_state, &listener );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool _state = false;
|
||||
|
||||
};
|
||||
|
||||
template< typename V>
|
||||
class LIBPIGPIO_EXPORT pigRec
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual void change_x( V newValue )
|
||||
{
|
||||
std::cout << "pigRec:" << newValue << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template< typename V>
|
||||
class LIBPIGPIO_EXPORT pigFykz
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
sigslot::signal<V> sigFykz;
|
||||
|
||||
virtual void change_x( V newValue )
|
||||
{
|
||||
std::cout << "pigFykz: " << newValue << std::endl;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void connect_x( T& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigFykz.connect( &T::change_x, &listener );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGSTATE_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGSTATE_H
|
||||
#define PIGSTATE_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigvalue.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief The pigState class
|
||||
* set_state ist passiv; change_state kann von 'innen' (per Gui) _oder_ von 'aussen'
|
||||
* (elektrisch) kommen, je nach Zweck der implementierung ...
|
||||
*/
|
||||
|
||||
class LIBPIGPIO_EXPORT pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
signalBool sigState;
|
||||
|
||||
pigState() = default;
|
||||
explicit pigState( bool astate );
|
||||
virtual ~pigState() = default;
|
||||
|
||||
bool state();
|
||||
virtual void set_state( bool newState );
|
||||
void toggle_state();
|
||||
|
||||
// passiv (empfänger) oder aktiv (sender):
|
||||
// die implemetierung entscheidet
|
||||
virtual void change_state( bool newState ) = 0;
|
||||
|
||||
template< typename T >
|
||||
void connect_state( T& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigState.connect( &T::change_state, &listener );
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
bool _state = false;
|
||||
|
||||
};
|
||||
|
||||
template< typename V>
|
||||
class LIBPIGPIO_EXPORT pigRec
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual void change_x( V newValue )
|
||||
{
|
||||
std::cout << "pigRec:" << newValue << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template< typename V>
|
||||
class LIBPIGPIO_EXPORT pigFykz
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
sigslot::signal<V> sigFykz;
|
||||
|
||||
virtual void change_x( V newValue )
|
||||
{
|
||||
std::cout << "pigFykz: " << newValue << std::endl;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void connect_x( T& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigFykz.connect( &T::change_x, &listener );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // PIGSTATE_H
|
||||
|
280
pigtimer.cpp
280
pigtimer.cpp
@@ -1,140 +1,140 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigtimer.h>
|
||||
|
||||
|
||||
pigTimer::pigTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigTimer::pigTimer( int timeOn, int timeOff, int repcnt )
|
||||
: _timeOn{ timeOn }, _timeOff{ timeOff }, _repcnt{ repcnt }
|
||||
{
|
||||
if( !_timeOff )
|
||||
_timeOff = _timeOn;
|
||||
}
|
||||
|
||||
|
||||
pigTimer::~pigTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigTimer::change_state( bool newState )
|
||||
{
|
||||
set_state( newState );
|
||||
}
|
||||
|
||||
int pigTimer::timeOn()
|
||||
{
|
||||
return _timeOn;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setTimeOn( int timeOn )
|
||||
{
|
||||
_timeOn = timeOn;
|
||||
// reset??
|
||||
}
|
||||
|
||||
|
||||
int pigTimer::timeOff()
|
||||
{
|
||||
return _timeOff;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setTimeOff( int timeOff )
|
||||
{
|
||||
_timeOff = timeOff;
|
||||
}
|
||||
|
||||
|
||||
int pigTimer::repetitions()
|
||||
{
|
||||
return _repcnt;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setRepetitions( int repcnt )
|
||||
{
|
||||
_repcnt = repcnt;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::start()
|
||||
{
|
||||
_active = true;
|
||||
// ewig
|
||||
if( _repcnt < 1 )
|
||||
{
|
||||
while( _active )
|
||||
sleepCycle();
|
||||
return;
|
||||
}
|
||||
|
||||
// abgezählt
|
||||
for( int i=0; i<_repcnt; ++i )
|
||||
sleepCycle();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::stop()
|
||||
{
|
||||
_active = false;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::sleepCycle()
|
||||
{
|
||||
|
||||
sleepThread( _timeOff );
|
||||
|
||||
if( !_active )
|
||||
return;
|
||||
|
||||
sleepThread( _timeOn );
|
||||
|
||||
|
||||
}
|
||||
void pigTimer::sleepThread( int delay )
|
||||
{
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
if( !_active )
|
||||
return;
|
||||
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( delay ) );
|
||||
|
||||
toggle_state();
|
||||
|
||||
} );
|
||||
thrd.detach();
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
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 <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <pigtimer.h>
|
||||
|
||||
|
||||
pigTimer::pigTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pigTimer::pigTimer( int timeOn, int timeOff, int repcnt )
|
||||
: _timeOn{ timeOn }, _timeOff{ timeOff }, _repcnt{ repcnt }
|
||||
{
|
||||
if( !_timeOff )
|
||||
_timeOff = _timeOn;
|
||||
}
|
||||
|
||||
|
||||
pigTimer::~pigTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pigTimer::change_state( bool newState )
|
||||
{
|
||||
set_state( newState );
|
||||
}
|
||||
|
||||
int pigTimer::timeOn()
|
||||
{
|
||||
return _timeOn;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setTimeOn( int timeOn )
|
||||
{
|
||||
_timeOn = timeOn;
|
||||
// reset??
|
||||
}
|
||||
|
||||
|
||||
int pigTimer::timeOff()
|
||||
{
|
||||
return _timeOff;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setTimeOff( int timeOff )
|
||||
{
|
||||
_timeOff = timeOff;
|
||||
}
|
||||
|
||||
|
||||
int pigTimer::repetitions()
|
||||
{
|
||||
return _repcnt;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::setRepetitions( int repcnt )
|
||||
{
|
||||
_repcnt = repcnt;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::start()
|
||||
{
|
||||
_active = true;
|
||||
// ewig
|
||||
if( _repcnt < 1 )
|
||||
{
|
||||
while( _active )
|
||||
sleepCycle();
|
||||
return;
|
||||
}
|
||||
|
||||
// abgezählt
|
||||
for( int i=0; i<_repcnt; ++i )
|
||||
sleepCycle();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::stop()
|
||||
{
|
||||
_active = false;
|
||||
}
|
||||
|
||||
|
||||
void pigTimer::sleepCycle()
|
||||
{
|
||||
|
||||
sleepThread( _timeOff );
|
||||
|
||||
if( !_active )
|
||||
return;
|
||||
|
||||
sleepThread( _timeOn );
|
||||
|
||||
|
||||
}
|
||||
void pigTimer::sleepThread( int delay )
|
||||
{
|
||||
std::thread thrd(
|
||||
[=]()
|
||||
{
|
||||
if( !_active )
|
||||
return;
|
||||
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( delay ) );
|
||||
|
||||
toggle_state();
|
||||
|
||||
} );
|
||||
thrd.detach();
|
||||
}
|
||||
|
136
pigtimer.h
136
pigtimer.h
@@ -1,68 +1,68 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGTIMER_H
|
||||
#define PIGTIMER_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigTimer : public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigTimer();
|
||||
pigTimer( int timeOn, int timeOff = 0, int repcnt = -1 );
|
||||
virtual ~pigTimer();
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
int timeOn();
|
||||
void setTimeOn( int timeOn );
|
||||
|
||||
int timeOff();
|
||||
void setTimeOff( int timeOff );
|
||||
|
||||
void setRepetitions( int repcnt );
|
||||
int repetitions();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
|
||||
void sleepCycle();
|
||||
void sleepThread( int delay );
|
||||
|
||||
int _timeOn = 0;
|
||||
int _timeOff = 0;
|
||||
|
||||
bool _active = false;
|
||||
int _repcnt = -1;
|
||||
int _count = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGTIMER_H
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGTIMER_H
|
||||
#define PIGTIMER_H
|
||||
|
||||
#include <libpigpio.h>
|
||||
#include <pigstate.h>
|
||||
|
||||
|
||||
class LIBPIGPIO_EXPORT pigTimer : public pigState
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pigTimer();
|
||||
pigTimer( int timeOn, int timeOff = 0, int repcnt = -1 );
|
||||
virtual ~pigTimer();
|
||||
|
||||
void change_state( bool newState ) override;
|
||||
|
||||
int timeOn();
|
||||
void setTimeOn( int timeOn );
|
||||
|
||||
int timeOff();
|
||||
void setTimeOff( int timeOff );
|
||||
|
||||
void setRepetitions( int repcnt );
|
||||
int repetitions();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
|
||||
void sleepCycle();
|
||||
void sleepThread( int delay );
|
||||
|
||||
int _timeOn = 0;
|
||||
int _timeOff = 0;
|
||||
|
||||
bool _active = false;
|
||||
int _repcnt = -1;
|
||||
int _count = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGTIMER_H
|
||||
|
||||
|
44
pigvalue.cpp
44
pigvalue.cpp
@@ -1,22 +1,22 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
168
pigvalue.h
168
pigvalue.h
@@ -1,84 +1,84 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGVALUE_H
|
||||
#define PIGVALUE_H
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
|
||||
//class rangeVal
|
||||
|
||||
template<class T>
|
||||
class LIBPIGPIO_EXPORT pigValue
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
sigslot::signal<T> sigValue;
|
||||
|
||||
pigValue() = default;
|
||||
pigValue( T val )
|
||||
: _value( val )
|
||||
{
|
||||
|
||||
}
|
||||
virtual ~pigValue() = default;
|
||||
|
||||
T value()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void set_value( T value )
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
void change_value( T value )
|
||||
{
|
||||
set_value( value );
|
||||
// emit ...
|
||||
}
|
||||
|
||||
template< typename V >
|
||||
void connect_value( V& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigValue.connect( &V::change_value, &listener );
|
||||
}
|
||||
/*
|
||||
template< typename O >
|
||||
void add_value_observer( O* target )
|
||||
{
|
||||
signal.connect( &O::on_value_changed, target );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
T _value = T();
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGVALUE_H
|
||||
/*****************************************************************************
|
||||
|
||||
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 PIGVALUE_H
|
||||
#define PIGVALUE_H
|
||||
|
||||
|
||||
#include <libpigpio.h>
|
||||
|
||||
//class rangeVal
|
||||
|
||||
template<class T>
|
||||
class LIBPIGPIO_EXPORT pigValue
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
sigslot::signal<T> sigValue;
|
||||
|
||||
pigValue() = default;
|
||||
pigValue( T val )
|
||||
: _value( val )
|
||||
{
|
||||
|
||||
}
|
||||
virtual ~pigValue() = default;
|
||||
|
||||
T value()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void set_value( T value )
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
void change_value( T value )
|
||||
{
|
||||
set_value( value );
|
||||
// emit ...
|
||||
}
|
||||
|
||||
template< typename V >
|
||||
void connect_value( V& listener )
|
||||
{
|
||||
//sigState.connect( [&](bool state) { T::change_state( state ); } );
|
||||
sigValue.connect( &V::change_value, &listener );
|
||||
}
|
||||
/*
|
||||
template< typename O >
|
||||
void add_value_observer( O* target )
|
||||
{
|
||||
signal.connect( &O::on_value_changed, target );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
T _value = T();
|
||||
|
||||
};
|
||||
|
||||
#endif // PIGVALUE_H
|
||||
|
11066
qrc_QtGPIO.cpp
11066
qrc_QtGPIO.cpp
File diff suppressed because it is too large
Load Diff
210
ui_QtGPIOMain.h
210
ui_QtGPIOMain.h
@@ -1,105 +1,105 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'QtGPIOMain.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.15.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_QTGPIOMAIN_H
|
||||
#define UI_QTGPIOMAIN_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDial>
|
||||
#include <QtWidgets/QFrame>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QLCDNumber>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QStatusBar>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_QtGPIOMain
|
||||
{
|
||||
public:
|
||||
QWidget *centralwidget;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QFrame *_frame;
|
||||
QPushButton *_LED;
|
||||
QDial *_dial;
|
||||
QLCDNumber *_display;
|
||||
QMenuBar *menubar;
|
||||
QStatusBar *statusbar;
|
||||
|
||||
void setupUi(QMainWindow *QtGPIOMain)
|
||||
{
|
||||
if (QtGPIOMain->objectName().isEmpty())
|
||||
QtGPIOMain->setObjectName(QString::fromUtf8("QtGPIOMain"));
|
||||
QtGPIOMain->resize(473, 342);
|
||||
centralwidget = new QWidget(QtGPIOMain);
|
||||
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
|
||||
centralwidget->setStyleSheet(QString::fromUtf8(""));
|
||||
horizontalLayout = new QHBoxLayout(centralwidget);
|
||||
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
|
||||
_frame = new QFrame(centralwidget);
|
||||
_frame->setObjectName(QString::fromUtf8("_frame"));
|
||||
_frame->setStyleSheet(QString::fromUtf8("background: grey"));
|
||||
_frame->setFrameShape(QFrame::NoFrame);
|
||||
_frame->setFrameShadow(QFrame::Sunken);
|
||||
_frame->setLineWidth(10);
|
||||
_frame->setMidLineWidth(10);
|
||||
_LED = new QPushButton(_frame);
|
||||
_LED->setObjectName(QString::fromUtf8("_LED"));
|
||||
_LED->setGeometry(QRect(50, 60, 91, 81));
|
||||
_LED->setStyleSheet(QString::fromUtf8("background: grey"));
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/images/Green.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
icon.addFile(QString::fromUtf8(":/images/Red.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
_LED->setIcon(icon);
|
||||
_LED->setIconSize(QSize(64, 64));
|
||||
_LED->setCheckable(false);
|
||||
_LED->setFlat(true);
|
||||
_dial = new QDial(_frame);
|
||||
_dial->setObjectName(QString::fromUtf8("_dial"));
|
||||
_dial->setGeometry(QRect(130, 60, 80, 80));
|
||||
_display = new QLCDNumber(_frame);
|
||||
_display->setObjectName(QString::fromUtf8("_display"));
|
||||
_display->setGeometry(QRect(250, 90, 131, 41));
|
||||
_display->setStyleSheet(QString::fromUtf8("background:lightgrey"));
|
||||
|
||||
horizontalLayout->addWidget(_frame);
|
||||
|
||||
QtGPIOMain->setCentralWidget(centralwidget);
|
||||
menubar = new QMenuBar(QtGPIOMain);
|
||||
menubar->setObjectName(QString::fromUtf8("menubar"));
|
||||
menubar->setGeometry(QRect(0, 0, 473, 26));
|
||||
QtGPIOMain->setMenuBar(menubar);
|
||||
statusbar = new QStatusBar(QtGPIOMain);
|
||||
statusbar->setObjectName(QString::fromUtf8("statusbar"));
|
||||
QtGPIOMain->setStatusBar(statusbar);
|
||||
|
||||
retranslateUi(QtGPIOMain);
|
||||
|
||||
QMetaObject::connectSlotsByName(QtGPIOMain);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QMainWindow *QtGPIOMain)
|
||||
{
|
||||
QtGPIOMain->setWindowTitle(QCoreApplication::translate("QtGPIOMain", "libPiGPio Widget Demo", nullptr));
|
||||
_LED->setText(QString());
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class QtGPIOMain: public Ui_QtGPIOMain {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_QTGPIOMAIN_H
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'QtGPIOMain.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.15.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_QTGPIOMAIN_H
|
||||
#define UI_QTGPIOMAIN_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QDial>
|
||||
#include <QtWidgets/QFrame>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QLCDNumber>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMenuBar>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QStatusBar>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_QtGPIOMain
|
||||
{
|
||||
public:
|
||||
QWidget *centralwidget;
|
||||
QHBoxLayout *horizontalLayout;
|
||||
QFrame *_frame;
|
||||
QPushButton *_LED;
|
||||
QDial *_dial;
|
||||
QLCDNumber *_display;
|
||||
QMenuBar *menubar;
|
||||
QStatusBar *statusbar;
|
||||
|
||||
void setupUi(QMainWindow *QtGPIOMain)
|
||||
{
|
||||
if (QtGPIOMain->objectName().isEmpty())
|
||||
QtGPIOMain->setObjectName(QString::fromUtf8("QtGPIOMain"));
|
||||
QtGPIOMain->resize(473, 342);
|
||||
centralwidget = new QWidget(QtGPIOMain);
|
||||
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
|
||||
centralwidget->setStyleSheet(QString::fromUtf8(""));
|
||||
horizontalLayout = new QHBoxLayout(centralwidget);
|
||||
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
|
||||
_frame = new QFrame(centralwidget);
|
||||
_frame->setObjectName(QString::fromUtf8("_frame"));
|
||||
_frame->setStyleSheet(QString::fromUtf8("background: grey"));
|
||||
_frame->setFrameShape(QFrame::NoFrame);
|
||||
_frame->setFrameShadow(QFrame::Sunken);
|
||||
_frame->setLineWidth(10);
|
||||
_frame->setMidLineWidth(10);
|
||||
_LED = new QPushButton(_frame);
|
||||
_LED->setObjectName(QString::fromUtf8("_LED"));
|
||||
_LED->setGeometry(QRect(50, 60, 91, 81));
|
||||
_LED->setStyleSheet(QString::fromUtf8("background: grey"));
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/images/Green.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
icon.addFile(QString::fromUtf8(":/images/Red.png"), QSize(), QIcon::Normal, QIcon::On);
|
||||
_LED->setIcon(icon);
|
||||
_LED->setIconSize(QSize(64, 64));
|
||||
_LED->setCheckable(false);
|
||||
_LED->setFlat(true);
|
||||
_dial = new QDial(_frame);
|
||||
_dial->setObjectName(QString::fromUtf8("_dial"));
|
||||
_dial->setGeometry(QRect(130, 60, 80, 80));
|
||||
_display = new QLCDNumber(_frame);
|
||||
_display->setObjectName(QString::fromUtf8("_display"));
|
||||
_display->setGeometry(QRect(250, 90, 131, 41));
|
||||
_display->setStyleSheet(QString::fromUtf8("background:lightgrey"));
|
||||
|
||||
horizontalLayout->addWidget(_frame);
|
||||
|
||||
QtGPIOMain->setCentralWidget(centralwidget);
|
||||
menubar = new QMenuBar(QtGPIOMain);
|
||||
menubar->setObjectName(QString::fromUtf8("menubar"));
|
||||
menubar->setGeometry(QRect(0, 0, 473, 26));
|
||||
QtGPIOMain->setMenuBar(menubar);
|
||||
statusbar = new QStatusBar(QtGPIOMain);
|
||||
statusbar->setObjectName(QString::fromUtf8("statusbar"));
|
||||
QtGPIOMain->setStatusBar(statusbar);
|
||||
|
||||
retranslateUi(QtGPIOMain);
|
||||
|
||||
QMetaObject::connectSlotsByName(QtGPIOMain);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QMainWindow *QtGPIOMain)
|
||||
{
|
||||
QtGPIOMain->setWindowTitle(QCoreApplication::translate("QtGPIOMain", "libPiGPio Widget Demo", nullptr));
|
||||
_LED->setText(QString());
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class QtGPIOMain: public Ui_QtGPIOMain {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_QTGPIOMAIN_H
|
||||
|
Reference in New Issue
Block a user