fixed embarrassing typos

This commit is contained in:
chris
2025-09-14 11:52:13 +02:00
parent d13b7fa01e
commit a81e8af4c5
52 changed files with 10823 additions and 10873 deletions

View File

@@ -37,7 +37,7 @@ MOVE = mv -f
TAR = tar -cf TAR = tar -cf
COMPRESS = gzip -9f COMPRESS = gzip -9f
DISTNAME = pigbin1.0.0 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++ LINK = g++
LFLAGS = -Wl,-O1 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 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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.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_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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.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_functions.prf \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \ /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf \ /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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.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_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_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.pri \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.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_functions.prf \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \ /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf \
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf \ /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_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.pri:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_printsupport_private.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_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.pri:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_sql_private.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_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.pri:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_widgets_private.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_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_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.pri:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/modules/qt_lib_xml_private.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_functions.prf:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf: /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/features/qt_config.prf:
/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf: /usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++/qmake.conf:
@@ -501,7 +483,7 @@ moc_QtGPIOMain.cpp: QtGPIOMain.h \
pigpin.h \ pigpin.h \
moc_predefs.h \ moc_predefs.h \
/usr/lib/qt5/bin/moc /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_make_all:
compiler_moc_objc_header_clean: compiler_moc_objc_header_clean:

View File

@@ -1,57 +1,57 @@
/*************************************************************************** /***************************************************************************
QtGPIO QtGPIO
Copyright © 2013-2022 christoph holzheuer Copyright © 2013-2022 christoph holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
***************************************************************************/ ***************************************************************************/
#include <QtGPIOMain.h> #include <QtGPIOMain.h>
#include <ui_QtGPIOMain.h> #include <ui_QtGPIOMain.h>
#include <QDebug> #include <QDebug>
QtGPIOMain::QtGPIOMain( QWidget* parent ) QtGPIOMain::QtGPIOMain( QWidget* parent )
: QMainWindow( parent ), _pigDial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 ) : QMainWindow( parent ), _pigDial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 )
{ {
setupUi( this ); setupUi( this );
//_rotaryDial.init( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 ); //_rotaryDial.init( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
//auto lambda = []() { std::cout << "lambda\n"; }; //auto lambda = []() { std::cout << "lambda\n"; };
//_rotaryDial.sigState.connect( lambda ); //_rotaryDial.sigState.connect( lambda );
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 ); //pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
//_rotaryDial.add_state_observer( &myMoo ); //_rotaryDial.add_state_observer( &myMoo );
//_rotaryDial.add_value_observer( &myMoo ); //_rotaryDial.add_value_observer( &myMoo );
//_pigDial.add_state_observer( this ); //_pigDial.add_state_observer( this );
//_pigDial.add_value_observer( this ); //_pigDial.add_value_observer( this );
} }
QtGPIOMain::~QtGPIOMain() QtGPIOMain::~QtGPIOMain()
{ {
} }
void QtGPIOMain::on_state_changed( bool state ) void QtGPIOMain::on_state_changed( bool state )
{ {
qDebug() << "onStateChanged: " << state; qDebug() << "onStateChanged: " << state;
_LED->setChecked( state ); _LED->setChecked( state );
} }
void QtGPIOMain::on_value_changed( int value ) void QtGPIOMain::on_value_changed( int value )
{ {
qDebug() << "on_value_changed: " << value; qDebug() << "on_value_changed: " << value;
_dial->setValue( value ); _dial->setValue( value );
} }

View File

@@ -1,45 +1,44 @@
/*************************************************************************** /***************************************************************************
QtGPIO QtGPIO
Copyright © 2013-2022 christoph holzheuer Copyright © 2013-2022 christoph holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
***************************************************************************/ ***************************************************************************/
#ifndef QPIGPIOMAIN_H #ifndef QPIGPIOMAIN_H
#define QPIGPIOMAIN_H #define QPIGPIOMAIN_H
#include <QMainWindow> #include <QMainWindow>
#include <ui_QtGPIOMain.h> #include <ui_QtGPIOMain.h>
#include <iostream> #include <pigrotarydial.h>
#include <pigrotarydial.h>
class QtGPIOMain : public QMainWindow, private Ui_QtGPIOMain
class QtGPIOMain : public QMainWindow, private Ui_QtGPIOMain {
{ Q_OBJECT
Q_OBJECT
public:
public:
QtGPIOMain( QWidget* parent = nullptr );
QtGPIOMain( QWidget* parent = nullptr ); virtual ~QtGPIOMain();
virtual ~QtGPIOMain();
void on_state_changed( bool state );
void on_state_changed( bool state ); void on_value_changed( int value );
void on_value_changed( int value );
protected:
protected:
pigRotaryDial _pigDial;
pigRotaryDial _pigDial;
};
};
#endif // QPIGPIOMAIN_H
#endif // QPIGPIOMAIN_H

View File

@@ -1,24 +1,24 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/

View File

@@ -1,136 +1,135 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef LIBPIGCORE_H #ifndef LIBPIGCORE_H
#define LIBPIGCORE_H #define LIBPIGCORE_H
#include <string> #include <string>
#include <iostream> #include <signal.hpp>
#include <signal.hpp>
#include <libpigpio.h>
#include <libpigpio.h>
//using namespace pigpio;
//using namespace pigpio;
struct pigI2C;
struct pigI2C;
namespace pigpio
namespace pigpio {
{
class LIBPIGPIO_EXPORT pigCore
class LIBPIGPIO_EXPORT pigCore {
{
public:
public:
/*
/* - sigX einheitlich, geht das
- sigX einheitlich, geht das - stack für sensoren
- stack für sensoren - threaded sensors / actors?
- threaded sensors / actors? - timer flicken
- timer flicken */
*/
virtual int init( const std::string& host ="" , const std::string& port="" ) = 0;
virtual int init( const std::string& host ="" , const std::string& port="" ) = 0;
// pin config
// pin config virtual int set_io_mode( bcm_t bcm, io_t mode ) = 0;
virtual int set_io_mode( bcm_t bcm, io_t mode ) = 0; virtual int get_io_mode( bcm_t bcm ) = 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_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_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;
virtual int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) = 0;
// pin operations
// pin operations virtual int get_level( bcm_t bcm ) = 0;
virtual int get_level( bcm_t bcm ) = 0; virtual int set_level( bcm_t bcm, level_t level ) = 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 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;
virtual int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef ) = 0;
// reality interface
// reality interface virtual int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) = 0;
virtual int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) = 0; virtual int cancel_callback( int cbId ) = 0;
virtual int cancel_callback( int cbId ) = 0;
// software PWM
// software PWM /*
/* set_PWM_dutycycle Start/stop PWM pulses on a GPIO
set_PWM_dutycycle Start/stop PWM pulses on a GPIO set_PWM_frequency Configure PWM frequency for a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO set_PWM_range Configure PWM range 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_dutycycle Get the PWM dutycycle in use on a GPIO get_PWM_frequency Get configured PWM frequency for a GPIO
get_PWM_frequency Get configured PWM frequency for a GPIO get_PWM_range Get configured PWM range for a GPIO
get_PWM_range Get configured PWM range for a GPIO get_PWM_real_range Get underlying PWM range for a GPIO
get_PWM_real_range Get underlying PWM range for a GPIO */
*/
// i2c
// i2c virtual int i2c_open( pigI2C& i2c ) = 0;
virtual int i2c_open( pigI2C& i2c ) = 0; virtual int i2c_close( pigI2C& i2c ) = 0;
virtual int i2c_close( pigI2C& i2c ) = 0; /*
/* virtual int i2c_write_quick( pigI2C& i2c, unsigned bit ) = 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( pigI2C& i2c, unsigned bVal ) = 0; virtual int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) = 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_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_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_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_write_device( pigI2C& i2c, char* buf, unsigned count ) = 0; /*
/* virtual int i2c_read_byte( pigI2C& i2c ) = 0;
virtual int i2c_read_byte( pigI2C& i2c ) = 0; virtual int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) = 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_word_data( pigI2C& i2c, unsigned reg ) = 0; virtual int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) = 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_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_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_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_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;
virtual int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen ) = 0; */
*/
// advanced
// advanced virtual int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) = 0;
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 int hardware_clock( bcm_t bcm, uint32_t clkfreq ) = 0; virtual uint32_t get_current_tick() = 0;
virtual uint32_t get_current_tick() = 0;
// info
// info virtual int get_hardware_revision() = 0;
virtual int get_hardware_revision() = 0; virtual int get_pigpio_version() = 0;
virtual int get_pigpio_version() = 0; virtual unsigned pigpiod_if_version() = 0;
virtual unsigned pigpiod_if_version() = 0;
virtual int show_error( int errNo ) = 0;
virtual int show_error( int errNo ) = 0;
protected:
protected:
int _Pi;
int _Pi;
}; // class pigCore
}; // class pigCore
} // namespace pigpio
} // namespace pigpio
#endif // LIBPIGCORE_H
#endif // LIBPIGCORE_H

View File

@@ -1,407 +1,393 @@
#if defined(unix) || defined(__unix__) || defined(__unix) #if defined(unix) || defined(__unix__) || defined(__unix)
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include <pigpiod_if2.h> #include <pigpiod_if2.h>
#include <libpiglinux.h> #include <libpiglinux.h>
#include <pigi2c.h> #include <pigi2c.h>
using namespace pigpio; using namespace pigpio;
pigLinux::pigLinux() noexcept pigLinux::pigLinux() noexcept
{ {
//::gpioInitialise(); //::gpioInitialise();
/// Connect to Pi. /// Connect to Pi.
constexpr char* optHost = nullptr; constexpr char* optHost = nullptr;
constexpr char* optPort = nullptr; constexpr char* optPort = nullptr;
_Pi = ::pigpio_start( optHost, optPort ); _Pi = ::pigpio_start( optHost, optPort );
if( _Pi < 0 ) if( _Pi < 0 )
std::cout << "-- pigLinux(): FAIL" << std::endl; std::cout << "-- pigLinux(): FAIL" << std::endl;
} }
pigLinux::~pigLinux() pigLinux::~pigLinux()
{ {
//::gpioTerminate(); //::gpioTerminate();
::pigpio_stop( _Pi ); ::pigpio_stop( _Pi );
} }
int pigLinux::init( const std::string& host, const std::string& port ) int pigLinux::init( const std::string& host, const std::string& port )
{ {
//::gpioInitialise(); //::gpioInitialise();
/// Connect to Pi. /// Connect to Pi.
_Pi = ::pigpio_start( host.c_str(), port.c_str() ); _Pi = ::pigpio_start( host.c_str(), port.c_str() );
if( _Pi < 0 ) if( _Pi < 0 )
std::cout << "-- pigLinux(): FAIL" << std::endl; std::cout << "-- pigLinux(): FAIL" << std::endl;
return _Pi; return _Pi;
} }
/// ///
/// pin config /// pin config
/// ///
int pigLinux::set_io_mode( bcm_t bcm, io_t mode ) int pigLinux::set_io_mode( bcm_t bcm, io_t mode )
{ {
int result = ::set_mode( _Pi, (unsigned) bcm, (unsigned) mode ); int result = ::set_mode( _Pi, (unsigned) bcm, (unsigned) mode );
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return result; return result;
} }
int pigLinux::get_io_mode( bcm_t bcm ) int pigLinux::get_io_mode( bcm_t bcm )
{ {
int result = ::get_mode( _Pi, (unsigned) bcm ); int result = ::get_mode( _Pi, (unsigned) bcm );
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return result; return result;
} }
int pigLinux::set_pud_mode( bcm_t bcm, pud_t pud ) int pigLinux::set_pud_mode( bcm_t bcm, pud_t pud )
{ {
int result = ::set_pull_up_down( _Pi, (unsigned) bcm, (unsigned) pud ); int result = ::set_pull_up_down( _Pi, (unsigned) bcm, (unsigned) pud );
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return result; return result;
} }
int pigLinux::set_glitch_filter( bcm_t bcm , uint32_t glitch ) int pigLinux::set_glitch_filter( bcm_t bcm , uint32_t glitch )
{ {
int result = ::set_glitch_filter( _Pi, (unsigned) bcm, glitch ); int result = ::set_glitch_filter( _Pi, (unsigned) bcm, glitch );
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return result; return result;
} }
//Sets a noise filter on a GPIO. //Sets a noise filter on a GPIO.
int pigLinux::set_noise_filter( bcm_t bcm , unsigned steady, unsigned active ) int pigLinux::set_noise_filter( bcm_t bcm , unsigned steady, unsigned active )
{ {
int result = ::set_noise_filter( _Pi, (unsigned) bcm, steady, active ); int result = ::set_noise_filter( _Pi, (unsigned) bcm, steady, active );
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return result; return result;
} }
/// ///
/// pin operations /// pin operations
/// ///
int pigLinux::get_level( bcm_t bcm ) int pigLinux::get_level( bcm_t bcm )
{ {
return ::gpio_read( _Pi, (unsigned) bcm ); return ::gpio_read( _Pi, (unsigned) bcm );
} }
int pigLinux::set_level( bcm_t bcm , level_t level ) int pigLinux::set_level( bcm_t bcm , level_t level )
{ {
int result = ::gpio_write( _Pi, (unsigned) bcm, level ); ; int result = ::gpio_write( _Pi, (unsigned) bcm, level ); ;
if( result < 0 ) if( result < 0 )
return show_error( result ); return show_error( result );
return 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. //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 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 ); ;
int result = ::gpio_trigger( _Pi, (unsigned) bcm, pulseLen, level ); ; if( result < 0 )
if( result < 0 ) return show_error( result );
return show_error( result ); return result;
return result; }
}
int pigLinux::wait_for_edge( bcm_t bcm , edge_t edge, double tout )
int pigLinux::wait_for_edge( bcm_t bcm , edge_t edge, double tout ) {
{ int result = ::wait_for_edge( _Pi, (unsigned) bcm, (unsigned) edge, tout );
//std::cout << " --pigLinux::wait_for_edge: " << (uint32_t) bcm << " : " << (uint32_t) edge << std::endl; if( result < 0 )
return show_error( result );
int result = ::wait_for_edge( _Pi, (unsigned) bcm, (unsigned) edge, tout ); return result;
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 );
int pigLinux::set_callback( bcm_t bcm, pigCall* fn, edge_t edge ) if( result < 0 )
{ return show_error( result );
//std::cout << " --pigLinux::set_callback: " << (uint32_t) bcm << " : " << (uint32_t) edge << std::endl;
return result;
/// 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 pigLinux::cancel_callback( int cbId )
int result = ::callback_ex( _Pi, (unsigned) bcm, (unsigned) edge, trigger, fn ); {
if( result < 0 ) int result = ::callback_cancel( cbId );
return show_error( result ); if( result < 0 )
return show_error( result );
return result; return result;
}
}
///
int pigLinux::cancel_callback( int cbId ) /// ic2
{ ///
int result = ::callback_cancel( cbId );
if( result < 0 ) int pigLinux::i2c_open( pigI2C& i2c )
return show_error( result ); {
return result; int result = i2c.handle = ::i2c_open( _Pi, i2c.bus, i2c.addr, 0 );
} if( result < 0 )
return show_error( result );
return result;
/// }
/// ic2
///
int pigLinux::i2c_close( pigI2C& i2c )
int pigLinux::i2c_open( pigI2C& i2c ) {
{ int result = ::i2c_close( _Pi, i2c.handle );
int result = i2c.handle = ::i2c_open( _Pi, i2c.bus, i2c.addr, 0 ); if( result < 0 )
if( result < 0 ) return show_error( result );
return show_error( result ); return result;
return result; }
}
/*
int pigLinux::i2c_write_quick( pigI2C& i2c, unsigned bit )
int pigLinux::i2c_close( pigI2C& i2c ) {
{ int result = ::i2c_write_quick( _Pi, i2c.handle, bit );
int result = ::i2c_close( _Pi, i2c.handle ); if( result < 0 )
if( result < 0 ) return show_error( result );
return show_error( result ); return result;
return result; }
}
int pigLinux::i2c_write_byte( pigI2C& i2c, unsigned bVal )
/* {
int pigLinux::i2c_write_quick( pigI2C& i2c, unsigned bit ) int result = ::i2c_write_byte( _Pi, i2c.handle, bVal );
{ if( result < 0 )
int result = ::i2c_write_quick( _Pi, i2c.handle, bit ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result;
} int pigLinux::i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
{
int pigLinux::i2c_write_byte( pigI2C& i2c, unsigned bVal ) int result = ::i2c_write_byte_data( _Pi, i2c.handle, reg, val );
{ if( result < 0 )
int result = ::i2c_write_byte( _Pi, i2c.handle, bVal ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result;
} int pigLinux::i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
{
int pigLinux::i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) int result = ::i2c_write_word_data( _Pi, i2c.handle, reg, val );
{ if( result < 0 )
int result = ::i2c_write_byte_data( _Pi, i2c.handle, reg, val ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result;
} int pigLinux::i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
{
int pigLinux::i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) int result = ::i2c_write_block_data( _Pi, i2c.handle, reg, buf, count );
{ if( result < 0 )
int result = ::i2c_write_word_data( _Pi, i2c.handle, reg, val ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result;
} int pigLinux::i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
{
int pigLinux::i2c_write_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 )
int result = ::i2c_write_block_data( _Pi, i2c.handle, reg, buf, count ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result; */
}
int pigLinux::i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
int pigLinux::i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) {
{ int result = ::i2c_write_device( _Pi, i2c.handle, buf, count );
int result = ::i2c_write_i2c_block_data( _Pi, i2c.handle, reg, buf, count ); if( result < 0 )
if( result < 0 ) return show_error( result );
return show_error( result ); return result;
return result; }
}
/*
*/ int pigLinux::i2c_read_byte( pigI2C& i2c )
{
int pigLinux::i2c_write_device( pigI2C& i2c, char* buf, unsigned count ) int result = ::i2c_read_byte( _Pi, i2c.handle );
{ if( result < 0 )
int result = ::i2c_write_device( _Pi, i2c.handle, buf, count ); return show_error( result );
if( result < 0 ) return result;
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 );
int pigLinux::i2c_read_byte( pigI2C& i2c ) if( result < 0 )
{ return show_error( result );
int result = ::i2c_read_byte( _Pi, i2c.handle ); return result;
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 );
int pigLinux::i2c_read_byte_data( pigI2C& i2c, unsigned reg ) if( result < 0 )
{ return show_error( result );
int result = ::i2c_read_byte_data( _Pi, i2c.handle, reg ); return result;
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 );
int pigLinux::i2c_read_word_data( pigI2C& i2c, unsigned reg ) if( result < 0 )
{ return show_error( result );
int result = ::i2c_read_word_data( _Pi, i2c.handle, reg ); return result;
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 );
int pigLinux::i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf ) return result;
{ }
int result = ::i2c_read_block_data( _Pi, i2c.handle, reg, buf );
if( result < 0 )
return show_error( result ); int pigLinux::i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
return result; {
} int result = ::i2c_read_device( _Pi, i2c.handle, buf, count );
if( result < 0 )
int pigLinux::i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) return show_error( result );
{ return result;
int result = ::i2c_read_i2c_block_data( _Pi, i2c.handle, reg, buf, count ); }
if( result < 0 )
return show_error( result ); int pigLinux::i2c_process_call( pigI2C& i2c, unsigned reg, unsigned wVal )
return result; {
} int result = ::i2c_process_call( _Pi, i2c.handle, reg, wVal );
if( result < 0 )
return show_error( result );
int pigLinux::i2c_read_device( pigI2C& i2c, char* buf, unsigned count ) return result;
{ }
int result = ::i2c_read_device( _Pi, i2c.handle, buf, count );
if( result < 0 )
return show_error( result ); int pigLinux::i2c_block_process_call( pigI2C& i2c,unsigned reg, char* buf, unsigned count )
return result; {
} int result = ::i2c_block_process_call( _Pi, i2c.handle, reg, buf, count );
if( result < 0 )
int pigLinux::i2c_process_call( pigI2C& i2c, unsigned reg, unsigned wVal ) return show_error( result );
{ return result;
int result = ::i2c_process_call( _Pi, i2c.handle, reg, wVal ); }
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 )
int pigLinux::i2c_block_process_call( pigI2C& i2c,unsigned reg, char* buf, unsigned count ) return show_error( result );
{ return result;
int result = ::i2c_block_process_call( _Pi, i2c.handle, reg, buf, count ); }
if( result < 0 ) */
return show_error( result );
return result;
} ///
/// advanced
///
int pigLinux::i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
{ //Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work.
int result = ::i2c_zip( _Pi, i2c.handle, inBuf, inLen, outBuf, outLen );
if( result < 0 ) int pigLinux::hardware_PWM( bcm_t bcm , unsigned PWMfreq, uint32_t PWMduty )
return show_error( result ); {
return result; //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;
/// }
/// advanced
/// //Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work.
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work. int pigLinux::hardware_clock( bcm_t bcm , unsigned clkfreq )
{
int pigLinux::hardware_PWM( bcm_t bcm , unsigned PWMfreq, uint32_t PWMduty ) //int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
{ int result = ::hardware_clock( _Pi, (unsigned) bcm, clkfreq );
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty) if( result < 0 )
int result = ::hardware_PWM( _Pi, (unsigned) bcm, PWMfreq, PWMduty ); return show_error( result );
if( result < 0 ) return result;
return show_error( result );
return result; }
}
uint32_t pigLinux::get_current_tick()
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work. {
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
int pigLinux::hardware_clock( bcm_t bcm , unsigned clkfreq ) return ::get_current_tick( _Pi );
{ }
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
int result = ::hardware_clock( _Pi, (unsigned) bcm, clkfreq );
if( result < 0 ) ///
return show_error( result ); /// convenience
return result; ///
}
int pigLinux::show_error( int error )
uint32_t pigLinux::get_current_tick() {
{ std::cout << "Error: " << ::pigpio_error( error ) << std::endl;
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq) return error;
return ::get_current_tick( _Pi ); }
}
/// /// ---
/// convenience
/// //Get the Pi's hardware revision number.
int pigLinux::get_hardware_revision()
int pigLinux::show_error( int error ) {
{ int result = ::get_hardware_revision( _Pi );
if( result < 0 )
std::cout << "Error: " << ::pigpio_error( error ) << std::endl; return show_error( result );
return error; return result;
}
}
//Returns the pigpio version.
/// ---
int pigLinux::get_pigpio_version()
//Get the Pi's hardware revision number. {
int result = ::get_pigpio_version( _Pi );
int pigLinux::get_hardware_revision() if( result < 0 )
{ return show_error( result );
int result = ::get_hardware_revision( _Pi ); return result;
if( result < 0 )
return show_error( result ); }
return result;
//Return the pigpiod_if2 version.
}
unsigned pigLinux::pigpiod_if_version()
//Returns the pigpio version. {
//unsigned pigpiod_if_version(void)
int pigLinux::get_pigpio_version() int result = ::pigpiod_if_version();
{ if( result < 0 )
int result = ::get_pigpio_version( _Pi ); return show_error( result );
if( result < 0 ) return result;
return show_error( result ); }
return result;
#endif
}
//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

View File

@@ -1,126 +1,126 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef LIBPIGLINUX_H #ifndef LIBPIGLINUX_H
#define LIBPIGLINUX_H #define LIBPIGLINUX_H
#if defined(unix) || defined(__unix__) || defined(__unix) #if defined(unix) || defined(__unix__) || defined(__unix)
#include <libpigpio.h> #include <libpigpio.h>
#include <libpigcore.h> #include <libpigcore.h>
namespace pigpio namespace pigpio
{ {
class LIBPIGPIO_EXPORT pigLinux : public pigCore class LIBPIGPIO_EXPORT pigLinux : public pigCore
{ {
friend pigCore& get_instance(); friend pigCore& get_instance();
public: public:
pigLinux( const pigLinux& ) = delete; pigLinux( const pigLinux& ) = delete;
void operator=( const pigLinux& ) = delete; void operator=( const pigLinux& ) = delete;
virtual ~pigLinux(); virtual ~pigLinux();
int init( const std::string& host ="", const std::string& port="" ) override; int init( const std::string& host ="", const std::string& port="" ) override;
// pin config // pin config
int set_io_mode( bcm_t bcm, io_t mode ) override; int set_io_mode( bcm_t bcm, io_t mode ) override;
int get_io_mode( bcm_t bcm ) override; int get_io_mode( bcm_t bcm ) override;
int set_pud_mode( bcm_t bcm, pud_t pud ) 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_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override; int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
// pin operations // pin operations
int get_level( bcm_t bcm ) override; int get_level( bcm_t bcm ) override;
int set_level( bcm_t bcm, level_t level ) 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 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; int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
// interface // interface
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override; int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
int cancel_callback( int cbId ) override; int cancel_callback( int cbId ) override;
// software PWM // software PWM
/* /*
set_PWM_dutycycle Start/stop PWM pulses on a GPIO set_PWM_dutycycle Start/stop PWM pulses on a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO set_PWM_frequency Configure PWM frequency for a GPIO
set_PWM_range Configure PWM range 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_dutycycle Get the PWM dutycycle in use on a GPIO
get_PWM_frequency Get configured PWM frequency for a GPIO get_PWM_frequency Get configured PWM frequency for a GPIO
get_PWM_range Get configured PWM range for a GPIO get_PWM_range Get configured PWM range for a GPIO
get_PWM_real_range Get underlying PWM range for a GPIO get_PWM_real_range Get underlying PWM range for a GPIO
*/ */
// i2c // i2c
int i2c_open( pigI2C& i2c ) override; int i2c_open( pigI2C& i2c ) override;
int i2c_close( pigI2C& i2c ) override; int i2c_close( pigI2C& i2c ) override;
/* /*
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override; int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) 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_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
int i2c_write_word_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_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_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_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
/* /*
int i2c_read_byte( pigI2C& i2c ) override; int i2c_read_byte( pigI2C& i2c ) override;
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override; int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
int i2c_read_word_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_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_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_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) 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_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; int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
*/ */
// advanced // advanced
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override; int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override; int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
uint32_t get_current_tick() override; uint32_t get_current_tick() override;
// info // info
int get_hardware_revision() override; int get_hardware_revision() override;
int get_pigpio_version() override; int get_pigpio_version() override;
unsigned pigpiod_if_version() override; unsigned pigpiod_if_version() override;
int show_error( int errNo ) override; int show_error( int errNo ) override;
private: private:
pigLinux() noexcept; pigLinux() noexcept;
}; };
} // namepace } // namepace
#endif // def linux #endif // def linux
#endif // LIBPIGLINUX_H #endif // LIBPIGLINUX_H

View File

@@ -1,310 +1,311 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <libpigpio.h> #include <libpigpio.h>
#include <pigpin.h> #include <pigpin.h>
#include <pignode.h> #include <pignode.h>
#include <libpigwindows.h> #include <libpigwindows.h>
#include <libpiglinux.h> #include <libpiglinux.h>
namespace pigpio namespace pigpio
{ {
pigCore& get_instance() pigCore& get_instance()
{ {
#if defined(unix) || defined(__unix__) || defined(__unix) #if defined(unix) || defined(__unix__) || defined(__unix)
static pigLinux _Instance; // guaranteed to be destroyed. static pigLinux _Instance; // guaranteed to be destroyed.
#endif //Q_OS_LINUX #endif //Q_OS_LINUX
#ifdef _WIN32 #ifdef _WIN32
static pigWindows _Instance; //guaranteed to be destroyed. static pigWindows _Instance; //guaranteed to be destroyed.
#endif // _WIN32 #endif // _WIN32
return _Instance; return _Instance;
} }
// bcm config // bcm config
int set_io_mode( bcm_t bcm, io_t mode ) int set_io_mode( bcm_t bcm, io_t mode )
{ {
return get_instance().set_io_mode( bcm, mode ); return get_instance().set_io_mode( bcm, mode );
} }
int get_io_mode( bcm_t bcm ) int get_io_mode( bcm_t bcm )
{ {
return get_instance().get_io_mode( bcm ); return get_instance().get_io_mode( bcm );
} }
int set_pud_mode( bcm_t bcm, pud_t pud ) int set_pud_mode( bcm_t bcm, pud_t pud )
{ {
return get_instance().set_pud_mode( bcm, pud ); return get_instance().set_pud_mode( bcm, pud );
} }
int set_glitch_filter(bcm_t bcm, uint32_t glitch ) int set_glitch_filter(bcm_t bcm, uint32_t glitch )
{ {
return get_instance().set_glitch_filter( bcm, glitch ); return get_instance().set_glitch_filter( bcm, glitch );
} }
int set_noise_filter(bcm_t bcm, unsigned steady, unsigned active ) int set_noise_filter(bcm_t bcm, unsigned steady, unsigned active )
{ {
return get_instance().set_noise_filter( bcm, steady, active ); return get_instance().set_noise_filter( bcm, steady, active );
} }
// bcm operations // bcm operations
int get_level( bcm_t bcm ) int get_level( bcm_t bcm )
{ {
return get_instance().get_level( bcm ); return get_instance().get_level( bcm );
} }
int set_level( bcm_t bcm , level_t level ) int set_level( bcm_t bcm , level_t level )
{ {
return get_instance().set_level( bcm, level ); return get_instance().set_level( bcm, level );
} }
int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen )
{ {
return get_instance().trigger_level( bcm, pulseLen, level ); return get_instance().trigger_level( bcm, pulseLen, level );
} }
int wait_for_edge( bcm_t bcm, edge_t edge, double timeout ) int wait_for_edge( bcm_t bcm, edge_t edge, double timeout )
{ {
return get_instance().wait_for_edge( bcm, edge, timeout ); return get_instance().wait_for_edge( bcm, edge, timeout );
} }
// reality interface // reality interface
int set_callback( bcm_t bcm, pigCall* fn, edge_t edge ) int set_callback( bcm_t bcm, pigCall* fn, edge_t edge )
{ {
return get_instance().set_callback( bcm, fn, edge ); return get_instance().set_callback( bcm, fn, edge );
} }
int cancel_callback( int cbId ) int cancel_callback( int cbId )
{ {
return get_instance().cancel_callback( cbId ); return get_instance().cancel_callback( cbId );
} }
// software PWM // software PWM
/* /*
set_PWM_dutycycle Start/stop PWM pulses on a GPIO set_PWM_dutycycle Start/stop PWM pulses on a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO set_PWM_frequency Configure PWM frequency for a GPIO
set_PWM_range Configure PWM range 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_dutycycle Get the PWM dutycycle in use on a GPIO
get_PWM_frequency Get configured PWM frequency for a GPIO get_PWM_frequency Get configured PWM frequency for a GPIO
get_PWM_range Get configured PWM range for a GPIO get_PWM_range Get configured PWM range for a GPIO
get_PWM_real_range Get underlying PWM range for a GPIO get_PWM_real_range Get underlying PWM range for a GPIO
*/ */
// i2c // i2c
int i2c_open( pigI2C& i2c ) int i2c_open( pigI2C& i2c )
{ {
return get_instance().i2c_open( i2c ); return get_instance().i2c_open( i2c );
} }
int i2c_close( pigI2C& i2c ) int i2c_close( pigI2C& i2c )
{ {
return get_instance().i2c_close( i2c ); return get_instance().i2c_close( i2c );
} }
/* /*
int i2c_write_quick( pigI2C& i2c, unsigned bit ) int i2c_write_quick( pigI2C& i2c, unsigned bit )
{ {
return get_instance(). return get_instance().
} }
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) int i2c_write_byte( pigI2C& i2c, unsigned bVal )
{ {
return get_instance(). return get_instance().
} }
int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) int i2c_write_byte_data( pigI2C& i2c, unsigned reg, unsigned val )
{ {
return get_instance(). return get_instance().
} }
int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val ) int i2c_write_word_data( pigI2C& i2c, unsigned reg, unsigned val )
{ {
return get_instance(). return get_instance().
} }
int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) int i2c_write_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
{ {
return get_instance(). return get_instance().
} }
int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count ) int i2c_write_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
{ {
return get_instance(). return get_instance().
} }
*/ */
int i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
{ int i2c_write_device( pigI2C& i2c, char* buf, unsigned count )
return get_instance().i2c_write_device( i2c, buf, count ); {
} return get_instance().i2c_write_device( i2c, buf, count );
}
/*
/*
int i2c_read_byte( pigI2C& i2c )
{ int i2c_read_byte( pigI2C& i2c )
return get_instance(). {
} return get_instance().
}
int i2c_read_byte_data( pigI2C& i2c, unsigned reg )
{ int i2c_read_byte_data( pigI2C& i2c, unsigned reg )
return get_instance(). {
} return get_instance().
}
int i2c_read_word_data( pigI2C& i2c, unsigned reg )
{ int i2c_read_word_data( pigI2C& i2c, unsigned reg )
return get_instance(). {
} return get_instance().
}
int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
{ int i2c_read_block_data( pigI2C& i2c, unsigned reg, char* buf )
return get_instance(). {
} return get_instance().
}
int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
{ int i2c_read_i2c_block_data( pigI2C& i2c, unsigned reg, char* buf, unsigned count )
return get_instance(). {
} return get_instance().
}
int i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
{ int i2c_read_device( pigI2C& i2c, char* buf, unsigned count )
return get_instance(). {
} return get_instance().
}
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal)
{ int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal)
return get_instance(). {
} return get_instance().
}
int i2c_block_process_call( pigI2C& i2c, unsigned i2c_reg, char* buf, unsigned count )
{ int i2c_block_process_call( pigI2C& i2c, unsigned i2c_reg, char* buf, unsigned count )
get_instance().i2c_block_process_call(); {
} get_instance().i2c_block_process_call();
}
int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
{ int i2c_zip( pigI2C& i2c, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen )
get_instance().i2c_zip( i2c, inBuf, inLen, outBuf, outLen ); {
} get_instance().i2c_zip( i2c, inBuf, inLen, outBuf, outLen );
*/ }
*/
// advanced
int hardware_PWM( bcm_t bcm, unsigned PWMfreq, uint32_t PWMduty ) // advanced
{ int hardware_PWM( bcm_t bcm, unsigned PWMfreq, uint32_t PWMduty )
return get_instance().hardware_PWM( bcm, PWMfreq, PWMduty ); {
} return get_instance().hardware_PWM( bcm, PWMfreq, PWMduty );
}
int hardware_clock( bcm_t bcm, unsigned clkfreq )
{ int hardware_clock( bcm_t bcm, unsigned clkfreq )
return get_instance().hardware_clock( bcm, clkfreq ); {
} return get_instance().hardware_clock( bcm, clkfreq );
}
uint32_t get_current_tick()
{ uint32_t get_current_tick()
return get_instance().get_current_tick(); {
} return get_instance().get_current_tick();
}
void show_error( const std::string& msg )
{ void show_error( const std::string& msg )
std::cout << "error: " << msg << std::endl; {
} std::cout << "error: " << msg << std::endl;
}
void show_hint( const std::string& msg )
{ void show_hint( const std::string& msg )
std::cout << "hint: " << msg << std::endl; {
} std::cout << "hint: " << msg << std::endl;
}
///
/// timers ///
/// /// timers
///
void delay_seconds( uint32_t tval )
{ void delay_seconds( uint32_t tval )
std::this_thread::sleep_for(std::chrono::seconds( tval ) ); {
} std::this_thread::sleep_for(std::chrono::seconds( tval ) );
}
void delay_millis( uint32_t tval )
{ void delay_millis( uint32_t tval )
std::this_thread::sleep_for(std::chrono::milliseconds( tval ) ); {
} std::this_thread::sleep_for(std::chrono::milliseconds( tval ) );
}
void delay_micros( uint32_t tval )
{ void delay_micros( uint32_t tval )
std::this_thread::sleep_for(std::chrono::microseconds( tval ) ); {
} std::this_thread::sleep_for(std::chrono::microseconds( tval ) );
}
void wait_loop()
{ void wait_loop()
while( true ) {
delay_seconds( 10 ); 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 ) // 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 ); /// Need a static callback to link with C.
if( receiver ) pigCall* receiver = static_cast<pigCall*>( user );
receiver->trigger( (bcm_t) bcm, level ); /// Call the get_instance callback. if( receiver )
else receiver->trigger( (bcm_t) bcm, level ); /// Call the get_instance callback.
std::cout << "-- ONPULSE FAIL" << (uint32_t) bcm << std::endl; else
} std::cout << "-- ONPULSE FAIL" << (uint32_t) bcm << std::endl;
}
void greet()
{ void greet()
std::cout << "lib:\t" << pigpio::Version << std::endl; {
std::cout << "gpio:\t" << get_instance().get_pigpio_version() << std::endl; std::cout << "lib:\t" << pigpio::Version << std::endl;
std::cout << "hw rev:\t" << get_instance().get_hardware_revision() << std::endl; std::cout << "gpio:\t" << get_instance().get_pigpio_version() << std::endl;
std::cout << "deamon:\t" << get_instance().pigpiod_if_version() << std::endl; std::cout << "hw rev:\t" << get_instance().get_hardware_revision() << std::endl;
std::cout << "\n" << std::endl; std::cout << "deamon:\t" << get_instance().pigpiod_if_version() << std::endl;
} std::cout << "\n" << std::endl;
}
int show_error( int error )
{ int show_error( int error )
return error; {
} return error;
}
} // namespace pigpio
} // namespace pigpio

View File

@@ -1,373 +1,370 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef LIBPIGPIO_H #ifndef LIBPIGPIO_H
#define LIBPIGPIO_H #define LIBPIGPIO_H
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #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_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport) # define Q_DECL_IMPORT __declspec(dllimport)
#else #else
# define Q_DECL_EXPORT __attribute__((visibility("default"))) # define Q_DECL_EXPORT __attribute__((visibility("default")))
# define Q_DECL_IMPORT __attribute__((visibility("default"))) # define Q_DECL_IMPORT __attribute__((visibility("default")))
#endif #endif
#if defined(LIBPIGPIO_LIBRARY) #if defined(LIBPIGPIO_LIBRARY)
# define LIBPIGPIO_EXPORT Q_DECL_EXPORT # define LIBPIGPIO_EXPORT Q_DECL_EXPORT
#else #else
# define LIBPIGPIO_EXPORT Q_DECL_IMPORT # define LIBPIGPIO_EXPORT Q_DECL_IMPORT
#endif #endif
#include <chrono> #include <iostream>
#include <thread> #include <sstream>
#include <iostream> #include <iomanip>
#include <sstream>
#include <iomanip> #include <cstdint>
#include <string>
#include <cstdint> #include <signal.hpp>
#include <string>
#include <signal.hpp> struct pigI2C;
#include <time.h> class pigCall;
struct pigI2C;
class pigCall; namespace pigpio
{
namespace pigpio class pigCore;
{
[[maybe_unused]] const int GlitchDef = 500;
class pigCore; [[maybe_unused]] const double TimeoutDef = 0.2;
[[maybe_unused]] const int GlitchDef = 500; enum class edge_t : uint32_t
[[maybe_unused]] const double TimeoutDef = 0.2; {
rising = 0,
enum class edge_t : uint32_t falling = 1,
{ either = 2,
rising = 0, edge_off = 99
falling = 1, };
either = 2,
edge_off = 99 enum class io_t : uint32_t
}; {
input = 0,
enum class io_t : uint32_t output = 1,
{ io_off = 99
input = 0, };
output = 1,
io_off = 99 enum class bcm_t : uint32_t
}; {
/// left side, pin 1,3 ... 39
enum class bcm_t : uint32_t
{ bcm02 = 2,
/// left side, pin 1,3 ... 39 bcm03 = 3,
bcm04 = 4,
bcm02 = 2,
bcm03 = 3, bcm17 = 17,
bcm04 = 4, bcm27 = 27,
bcm22 = 22,
bcm17 = 17,
bcm27 = 27, bcm10 = 10,
bcm22 = 22, bcm09 = 9,
bcm11 = 11,
bcm10 = 10,
bcm09 = 9, bcm05 = 5,
bcm11 = 11, bcm06 = 6,
bcm13 = 13,
bcm05 = 5,
bcm06 = 6, bcm19 = 19,
bcm13 = 7, bcm26 = 26,
bcm19 = 19, /// right side, pin 2,4 .. 40
bcm26 = 9,
bcm14 = 14,
/// right side, pin 2,4 .. 40 bcm15 = 15,
bcm18 = 18,
bcm14 = 14,
bcm15 = 15, bcm23 = 23,
bcm18 = 18, bcm24 = 24,
bcm23 = 23, bcm25 = 25,
bcm24 = 24, bcm08 = 8,
bcm07 = 7,
bcm25 = 25,
bcm08 = 8, bcm12 = 12,
bcm07 = 07,
bcm16 = 16,
bcm12 = 12, bcm20 = 20,
bcm21 = 21,
bcm16 = 16,
bcm20 = 20, bcm_off = 99
bcm21 = 21,
};
bcm_off = 99
enum class pud_t : uint32_t
}; {
pull_off = 0,
enum class pud_t : uint32_t pull_down = 1,
{ pull_up = 2,
pull_off = 0, };
pull_down = 1,
pull_up = 2,
}; using level_t = uint32_t;
///
using level_t = uint32_t; /// i2c
///
///
/// i2c using i2c_bus_t = uint32_t; // uint8_t ??
/// using i2c_addr_t = uint32_t;
using i2c_flag_t = uint32_t;
using i2c_bus_t = uint32_t; // uint8_t ??
using i2c_addr_t = uint32_t; /// sugar
using i2c_flag_t = uint32_t; [[maybe_unused]] constexpr static edge_t rising = edge_t::rising;
[[maybe_unused]] constexpr static edge_t falling = edge_t::falling;
/// sugar [[maybe_unused]] constexpr static edge_t either = edge_t::either;
[[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 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;
[[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;
/// left side, pin 1,3 ... 39 [[maybe_unused]] constexpr static bcm_t bcm04 = bcm_t::bcm04;
[[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 bcm17 = bcm_t::bcm17;
[[maybe_unused]] constexpr static bcm_t bcm04 = bcm_t::bcm04; [[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 bcm17 = bcm_t::bcm17;
[[maybe_unused]] constexpr static bcm_t bcm27 = bcm_t::bcm27; [[maybe_unused]] constexpr static bcm_t bcm10 = bcm_t::bcm10;
[[maybe_unused]] constexpr static bcm_t bcm22 = bcm_t::bcm22; [[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 bcm10 = bcm_t::bcm10;
[[maybe_unused]] constexpr static bcm_t bcm09 = bcm_t::bcm09; [[maybe_unused]] constexpr static bcm_t bcm05 = bcm_t::bcm05;
[[maybe_unused]] constexpr static bcm_t bcm11 = bcm_t::bcm11; [[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 bcm05 = bcm_t::bcm05;
[[maybe_unused]] constexpr static bcm_t bcm06 = bcm_t::bcm06; [[maybe_unused]] constexpr static bcm_t bcm19 = bcm_t::bcm19;
[[maybe_unused]] constexpr static bcm_t bcm13 = bcm_t::bcm07; [[maybe_unused]] constexpr static bcm_t bcm26 = bcm_t::bcm26;
[[maybe_unused]] constexpr static bcm_t bcm19 = bcm_t::bcm19; /// right side, pin 2,4 .. 40
[[maybe_unused]] constexpr static bcm_t bcm26 = bcm_t::bcm09; [[maybe_unused]] constexpr static bcm_t bcm14 = bcm_t::bcm14;
[[maybe_unused]] constexpr static bcm_t bcm15 = bcm_t::bcm15;
/// right side, pin 2,4 .. 40 [[maybe_unused]] constexpr static bcm_t bcm18 = bcm_t::bcm18;
[[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 bcm23 = bcm_t::bcm23;
[[maybe_unused]] constexpr static bcm_t bcm18 = bcm_t::bcm18; [[maybe_unused]] constexpr static bcm_t bcm24 = bcm_t::bcm24;
[[maybe_unused]] constexpr static bcm_t bcm23 = bcm_t::bcm23; [[maybe_unused]] constexpr static bcm_t bcm25 = bcm_t::bcm25;
[[maybe_unused]] constexpr static bcm_t bcm24 = bcm_t::bcm24; [[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 bcm25 = bcm_t::bcm25;
[[maybe_unused]] constexpr static bcm_t bcm08 = bcm_t::bcm08; [[maybe_unused]] constexpr static bcm_t bcm12 = bcm_t::bcm12;
[[maybe_unused]] constexpr static bcm_t bcm07 = bcm_t::bcm07;
[[maybe_unused]] constexpr static bcm_t bcm16 = bcm_t::bcm16;
[[maybe_unused]] constexpr static bcm_t bcm12 = bcm_t::bcm12; [[maybe_unused]] constexpr static bcm_t bcm20 = bcm_t::bcm20;
[[maybe_unused]] constexpr static bcm_t bcm21 = bcm_t::bcm21;
[[maybe_unused]] constexpr static bcm_t bcm16 = bcm_t::bcm16;
[[maybe_unused]] constexpr static bcm_t bcm20 = bcm_t::bcm20; /// more sugar
[[maybe_unused]] constexpr static bcm_t bcm21 = bcm_t::bcm21;
/// left side, pin 1,3 ... 39
/// more sugar [[maybe_unused]] constexpr static bcm_t pin03 = bcm_t::bcm02;
[[maybe_unused]] constexpr static bcm_t pin05 = bcm_t::bcm03;
/// left side, pin 1,3 ... 39 [[maybe_unused]] constexpr static bcm_t pin07 = bcm_t::bcm04;
[[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 pin11 = bcm_t::bcm17;
[[maybe_unused]] constexpr static bcm_t pin07 = bcm_t::bcm04; [[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 pin11 = bcm_t::bcm17;
[[maybe_unused]] constexpr static bcm_t pin13 = bcm_t::bcm27; [[maybe_unused]] constexpr static bcm_t pin19 = bcm_t::bcm10;
[[maybe_unused]] constexpr static bcm_t pin15 = bcm_t::bcm22; [[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 pin19 = bcm_t::bcm10;
[[maybe_unused]] constexpr static bcm_t pin21 = bcm_t::bcm09; [[maybe_unused]] constexpr static bcm_t pin29 = bcm_t::bcm05;
[[maybe_unused]] constexpr static bcm_t pin23 = bcm_t::bcm11; [[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 pin29 = bcm_t::bcm05;
[[maybe_unused]] constexpr static bcm_t pin31 = bcm_t::bcm06; [[maybe_unused]] constexpr static bcm_t pin35 = bcm_t::bcm19;
[[maybe_unused]] constexpr static bcm_t pin33 = bcm_t::bcm13; [[maybe_unused]] constexpr static bcm_t pin37 = bcm_t::bcm26;
[[maybe_unused]] constexpr static bcm_t pin35 = bcm_t::bcm19; /// right side, pin 2,4 .. 40
[[maybe_unused]] constexpr static bcm_t pin37 = bcm_t::bcm26; [[maybe_unused]] constexpr static bcm_t pin08 = bcm_t::bcm14;
[[maybe_unused]] constexpr static bcm_t pin10 = bcm_t::bcm15;
/// right side, pin 2,4 .. 40 [[maybe_unused]] constexpr static bcm_t pin12 = bcm_t::bcm18;
[[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 pin16 = bcm_t::bcm23;
[[maybe_unused]] constexpr static bcm_t pin12 = bcm_t::bcm18; [[maybe_unused]] constexpr static bcm_t pin18 = bcm_t::bcm24;
[[maybe_unused]] constexpr static bcm_t pin16 = bcm_t::bcm23; [[maybe_unused]] constexpr static bcm_t pin22 = bcm_t::bcm25;
[[maybe_unused]] constexpr static bcm_t pin18 = bcm_t::bcm24; [[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 pin22 = bcm_t::bcm25;
[[maybe_unused]] constexpr static bcm_t pin24 = bcm_t::bcm08; [[maybe_unused]] constexpr static bcm_t pin32 = bcm_t::bcm12;
[[maybe_unused]] constexpr static bcm_t pin26 = bcm_t::bcm07;
[[maybe_unused]] constexpr static bcm_t pin36 = bcm_t::bcm16;
[[maybe_unused]] constexpr static bcm_t pin32 = bcm_t::bcm12; [[maybe_unused]] constexpr static bcm_t pin38 = bcm_t::bcm20;
[[maybe_unused]] constexpr static bcm_t pin40 = bcm_t::bcm21;
[[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
GPIO pin pin GPIO 3 (SCL) 5 6 0V
3V3 1 2 5V 4 7 8 14 (TXD)
2 (SDA) 3 4 5V 0V 9 10 15 (RXD)
3 (SCL) 5 6 0V 17 (ce1) 11 12 18 (ce0)
4 7 8 14 (TXD) 27 13 14 0V
0V 9 10 15 (RXD) 22 15 16 23
17 (ce1) 11 12 18 (ce0) 3V3 17 18 24
27 13 14 0V 10 (MOSI) 19 20 0V
22 15 16 23 9 (MISO) 21 22 25
3V3 17 18 24 11 (SCLK) 23 24 8 (CE0)
10 (MOSI) 19 20 0V 0V 25 26 7 (CE1)
9 (MISO) 21 22 25 .......
11 (SCLK) 23 24 8 (CE0) 0 (ID_SD) 27 28 1 (ID_SC)
0V 25 26 7 (CE1) 5 29 30 0V
....... 6 31 32 12
0 (ID_SD) 27 28 1 (ID_SC) 13 33 34 0V
5 29 30 0V 19 (miso) 35 36 16 (ce2)
6 31 32 12 26 37 38 20 (mosi)
13 33 34 0V 0V 39 40 21 (sclk)
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;
// fragwürdig
[[maybe_unused]] constexpr static level_t low = 0; [[maybe_unused]] constexpr static level_t off = 0;
[[maybe_unused]] constexpr static level_t high = 1; [[maybe_unused]] constexpr static level_t on = 1;
[[maybe_unused]] constexpr static level_t off = 0;
[[maybe_unused]] constexpr static level_t on = 1; //map<bcm> -> pin
// op<
//map<bcm> -> pin [[maybe_unused]] constexpr static uint32_t TimeOut = 2;
// op< [[maybe_unused]] constexpr static const char* Version = "libPiGPIO 0.1.27 / 16.09.2022 2022 chris@sourceworx.org";
[[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="" );
LIBPIGPIO_EXPORT pigCore& get_instance();
// pin config
LIBPIGPIO_EXPORT int init( const std::string& host ="" , const std::string& port="" ); LIBPIGPIO_EXPORT int get_io_mode( bcm_t bcm );
LIBPIGPIO_EXPORT int set_io_mode( bcm_t bcm, io_t mode );
// pin config LIBPIGPIO_EXPORT int set_pud_mode( bcm_t bcm, pud_t pud );
LIBPIGPIO_EXPORT int get_io_mode( bcm_t bcm ); LIBPIGPIO_EXPORT int set_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef );
LIBPIGPIO_EXPORT int set_io_mode( bcm_t bcm, io_t mode ); LIBPIGPIO_EXPORT int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) ;
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 ); // pin operations
LIBPIGPIO_EXPORT int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) ; LIBPIGPIO_EXPORT int get_level( bcm_t bcm );
LIBPIGPIO_EXPORT int set_level( bcm_t bcm, level_t level ) ;
// pin operations LIBPIGPIO_EXPORT int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen );
LIBPIGPIO_EXPORT int get_level( bcm_t bcm ); LIBPIGPIO_EXPORT int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef );
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 ); // reality interface
LIBPIGPIO_EXPORT int wait_for_edge( bcm_t bcm, edge_t edge, double timeout = TimeoutDef ); LIBPIGPIO_EXPORT int set_callback( bcm_t bcm, pigCall* fn, edge_t edge );
LIBPIGPIO_EXPORT int cancel_callback( int cbId );
// reality interface
LIBPIGPIO_EXPORT int set_callback( bcm_t bcm, pigCall* fn, edge_t edge ); // software PWM
LIBPIGPIO_EXPORT int cancel_callback( int cbId ); /*
set_PWM_dutycycle Start/stop PWM pulses on a GPIO
// software PWM set_PWM_frequency Configure PWM frequency for a GPIO
/* set_PWM_range Configure PWM range for a GPIO
set_PWM_dutycycle Start/stop PWM pulses on a GPIO get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO get_PWM_frequency Get configured PWM frequency for a GPIO
set_PWM_range Configure PWM range for a GPIO get_PWM_range Get configured PWM range for a GPIO
get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO get_PWM_real_range Get underlying PWM range for 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 );
// i2c /*
LIBPIGPIO_EXPORT int i2c_open( pigI2C& i2c ); LIBPIGPIO_EXPORT int i2c_write_quick( pigI2C& i2c, uint32_t bit );
LIBPIGPIO_EXPORT int i2c_close( pigI2C& i2c ); 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_quick( pigI2C& i2c, uint32_t bit ); LIBPIGPIO_EXPORT int i2c_write_word_data( pigI2C& i2c, uint32_t reg, uint32_t val );
LIBPIGPIO_EXPORT int i2c_write_byte( pigI2C& i2c, uint32_t bVal ); LIBPIGPIO_EXPORT int i2c_write_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
LIBPIGPIO_EXPORT int i2c_write_byte_data( pigI2C& i2c, uint32_t reg, uint32_t val ); LIBPIGPIO_EXPORT int i2c_write_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
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_device( pigI2C& i2c, 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_read_byte( pigI2C& i2c );
LIBPIGPIO_EXPORT int i2c_write_device( pigI2C& i2c, char* buf, uint32_t count ); 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_byte( pigI2C& i2c ); LIBPIGPIO_EXPORT int i2c_read_block_data( pigI2C& i2c, uint32_t reg, char* buf );
LIBPIGPIO_EXPORT int i2c_read_byte_data( pigI2C& i2c, uint32_t reg ); LIBPIGPIO_EXPORT int i2c_read_i2c_block_data( pigI2C& i2c, uint32_t reg, char* buf, uint32_t count );
LIBPIGPIO_EXPORT int i2c_read_word_data( pigI2C& i2c, uint32_t reg ); LIBPIGPIO_EXPORT int i2c_read_device( pigI2C& i2c, char* buf, uint32_t count );
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_process_call( pigI2C& i2c, uint32_t i2c_reg, uint32_t wVal);
LIBPIGPIO_EXPORT int i2c_read_device( pigI2C& i2c, char* buf, uint32_t count ); 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 );
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 );
// advanced LIBPIGPIO_EXPORT uint32_t get_current_tick();
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 ); // finally
LIBPIGPIO_EXPORT uint32_t get_current_tick(); //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 );
// finally LIBPIGPIO_EXPORT void greet();
//LIBPIGPIO_EXPORT void trigger( int pi, bcm_t pin, level_t level, uint32_t tick, void *user ); LIBPIGPIO_EXPORT void wait_loop();
LIBPIGPIO_EXPORT void trigger( int pi, unsigned bcm, unsigned level, uint32_t tick, void *user );
LIBPIGPIO_EXPORT void greet(); // timer
LIBPIGPIO_EXPORT void wait_loop(); LIBPIGPIO_EXPORT void delay_seconds( uint32_t );
LIBPIGPIO_EXPORT void delay_millis( uint32_t );
// timer LIBPIGPIO_EXPORT void delay_micros( uint32_t );
LIBPIGPIO_EXPORT void delay_seconds( uint32_t );
LIBPIGPIO_EXPORT void delay_millis( uint32_t ); // util
LIBPIGPIO_EXPORT void delay_micros( uint32_t ); template< typename T >
LIBPIGPIO_EXPORT std::string val2str( T value, int fixed=2 )
// util {
template< typename T > std::ostringstream sout;
LIBPIGPIO_EXPORT std::string val2str( T value, int fixed=2 ) sout << std::fixed << std::setprecision( fixed );
{ sout << value;
std::ostringstream sout; return sout.str();
sout << std::fixed << std::setprecision( fixed ); }
sout << value;
return sout.str(); } // namespace
}
using signalBool = sigslot::signal<bool>;
} // namespace using signalInt = sigslot::signal<int>;
using signalFloat = sigslot::signal<double>;
using signalBool = sigslot::signal<bool>;
using signalInt = sigslot::signal<int>;
using signalFloat = sigslot::signal<double>; #endif // LIBPIGPIO_H
#endif // LIBPIGPIO_H

View File

@@ -1,301 +1,301 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
/// --- /// ---
#ifdef _WIN32 #ifdef _WIN32
#include <iostream> #include <iostream>
#include <libpigwindows.h> #include <libpigwindows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
namespace pigpio namespace pigpio
{ {
int pigWindows::init( const std::string& , const std::string& ) int pigWindows::init( const std::string& , const std::string& )
{ {
//::gpioInitialise(); //::gpioInitialise();
return 42; return 42;
} }
// //
// pin config // pin config
// //
int pigWindows::set_io_mode( bcm_t, io_t ) int pigWindows::set_io_mode( bcm_t, io_t )
{ {
//::set_io_mode( _Pi, pin.bcm, pin.mode ); //::set_io_mode( _Pi, pin.bcm, pin.mode );
return 0; return 0;
} }
int pigWindows::get_io_mode( bcm_t ) int pigWindows::get_io_mode( bcm_t )
{ {
return 0; return 0;
} }
int pigWindows::set_pud_mode( bcm_t, pud_t ) int pigWindows::set_pud_mode( bcm_t, pud_t )
{ {
//::set_pud_mode( _Pi, pin.bcm, pin.pud ); //::set_pud_mode( _Pi, pin.bcm, pin.pud );
return 0; return 0;
} }
int pigWindows::set_glitch_filter( bcm_t, uint32_t ) int pigWindows::set_glitch_filter( bcm_t, uint32_t )
{ {
// ::set_glitch_filter( _Pi, pin.bcm, glitch ); // ::set_glitch_filter( _Pi, pin.bcm, glitch );
return 0; return 0;
} }
//Sets a noise filter on a GPIO. //Sets a noise filter on a GPIO.
int pigWindows::set_noise_filter( bcm_t, uint32_t, uint32_t ) int pigWindows::set_noise_filter( bcm_t, uint32_t, uint32_t )
{ {
//int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active) //int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)
return 0; return 0;
} }
/// ///
/// pin operations /// pin operations
/// ///
int pigWindows::get_level( bcm_t ) int pigWindows::get_level( bcm_t )
{ {
return 0; return 0;
} }
int pigWindows::set_level( bcm_t, level_t ) int pigWindows::set_level( bcm_t, level_t )
{ {
return 0; return 0;
} }
int pigWindows::wait_for_edge( bcm_t, edge_t, double ) int pigWindows::wait_for_edge( bcm_t, edge_t, double )
{ {
return 0; 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. //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 pigWindows::trigger_level( bcm_t, level_t, uint32_t )
{ {
//int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level) //int trigger_level(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)
return 0; return 0;
} }
/// ///
/// interface /// interface
/// ///
int pigWindows::set_callback( bcm_t, pigCall*, edge_t ) int pigWindows::set_callback( bcm_t, pigCall*, edge_t )
{ {
//::callback_ex( _Pi, pin.bcm, pin.edge, &pigNode::trigger, (void*) &widget ); //::callback_ex( _Pi, pin.bcm, pin.edge, &pigNode::trigger, (void*) &widget );
//pin.cbId = ::callback_ex( _Pi, pin.bcm, pin.edge, trigger, widget ); //pin.cbId = ::callback_ex( _Pi, pin.bcm, pin.edge, trigger, widget );
return 0; return 0;
} }
int pigWindows::cancel_callback( int ) int pigWindows::cancel_callback( int )
{ {
return 0; return 0;
} }
/// ///
/// ic2 /// ic2
/// ///
int pigWindows::i2c_open( pigI2C& ) int pigWindows::i2c_open( pigI2C& )
{ {
return 0; return 0;
} }
int pigWindows::i2c_close( pigI2C& ) int pigWindows::i2c_close( pigI2C& )
{ {
return 0; return 0;
} }
/* /*
int pigWindows::i2c_write_quick( pigI2C&, unsigned ) int pigWindows::i2c_write_quick( pigI2C&, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_write_byte( pigI2C&, unsigned ) int pigWindows::i2c_write_byte( pigI2C&, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_write_byte_data( pigI2C&, unsigned, unsigned ) int pigWindows::i2c_write_byte_data( pigI2C&, unsigned, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_write_word_data( pigI2C&, unsigned, unsigned ) int pigWindows::i2c_write_word_data( pigI2C&, unsigned, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_write_block_data( pigI2C&, unsigned, char* buf, unsigned count ) int pigWindows::i2c_write_block_data( pigI2C&, unsigned, char* buf, unsigned count )
{ {
return 0; return 0;
} }
int pigWindows::i2c_write_i2c_block_data( pigI2C&, unsigned, char* buf, unsigned count ) int pigWindows::i2c_write_i2c_block_data( pigI2C&, unsigned, char* buf, unsigned count )
{ {
return 0; return 0;
}*/ }*/
int pigWindows::i2c_write_device( pigI2C&, char*, unsigned ) int pigWindows::i2c_write_device( pigI2C&, char*, unsigned )
{ {
return 0; return 0;
} }
/* /*
int pigWindows::i2c_read_byte( pigI2C& ) int pigWindows::i2c_read_byte( pigI2C& )
{ {
return 0; return 0;
} }
int pigWindows::i2c_read_byte_data( pigI2C&, unsigned ) int pigWindows::i2c_read_byte_data( pigI2C&, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_read_word_data( pigI2C&, unsigned ) int pigWindows::i2c_read_word_data( pigI2C&, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_read_block_data( pigI2C&, unsigned, char* ) int pigWindows::i2c_read_block_data( pigI2C&, unsigned, char* )
{ {
return 0; return 0;
} }
int pigWindows::i2c_read_i2c_block_data( pigI2C&, unsigned, char*, unsigned ) int pigWindows::i2c_read_i2c_block_data( pigI2C&, unsigned, char*, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_read_device( pigI2C&, char* buf, unsigned ) int pigWindows::i2c_read_device( pigI2C&, char* buf, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_process_call( pigI2C&, unsigned, unsigned ) int pigWindows::i2c_process_call( pigI2C&, unsigned, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_block_process_call( pigI2C&, unsigned, char*, unsigned ) int pigWindows::i2c_block_process_call( pigI2C&, unsigned, char*, unsigned )
{ {
return 0; return 0;
} }
int pigWindows::i2c_zip( pigI2C&, char*, unsigned, char*, unsigned ) int pigWindows::i2c_zip( pigI2C&, char*, unsigned, char*, unsigned )
{ {
return 0; return 0;
} }
*/ */
/// ///
/// advanced /// advanced
/// ///
//Starts hardware PWM on a GPIO at the specified frequency and dutycycle. Frequencies above 30MHz are unlikely to work. //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 pigWindows::hardware_PWM( bcm_t, uint32_t, uint32_t )
{ {
//int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty) //int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)
return 0; return 0;
} }
/// ///
/// convenience /// convenience
/// ///
int pigWindows::show_error( int error ) int pigWindows::show_error( int error )
{ {
std::cout << "Error: " << std::endl; std::cout << "Error: " << std::endl;
return error; return error;
} }
//Starts a hardware clock on a GPIO at the specified frequency. Frequencies above 30MHz are unlikely to work. //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 pigWindows::hardware_clock( bcm_t, uint32_t )
{ {
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq) //int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
return 0; return 0;
} }
uint32_t pigWindows::get_current_tick() uint32_t pigWindows::get_current_tick()
{ {
//int hardware_clock(int pi, unsigned gpio, unsigned clkfreq) //int hardware_clock(int pi, unsigned gpio, unsigned clkfreq)
return 0; return 0;
} }
//Get the Pi's hardware revision number. //Get the Pi's hardware revision number.
int pigWindows::get_hardware_revision() int pigWindows::get_hardware_revision()
{ {
//uint32_t get_hardware_revision(int pi) //uint32_t get_hardware_revision(int pi)
return 0; return 0;
} }
//Returns the pigpio version. //Returns the pigpio version.
int pigWindows::get_pigpio_version() int pigWindows::get_pigpio_version()
{ {
//uint32_t get_pigpio_version(int pi) //uint32_t get_pigpio_version(int pi)
return 0; return 0;
} }
//Return the pigpiod_if2 version. //Return the pigpiod_if2 version.
unsigned pigWindows::pigpiod_if_version() unsigned pigWindows::pigpiod_if_version()
{ {
//unsigned pigpiod_if_version(void) //unsigned pigpiod_if_version(void)
return 0; return 0;
} }
} // namespace } // namespace
#endif #endif

View File

@@ -1,128 +1,128 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2.h pigpiod_if2.h
by joan2937, pigpio @ abyz.me.uk by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot.h sigslot.h
by 2017 Pierre-Antoine Lacaze by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef LIBPIGWINDOWS_H #ifndef LIBPIGWINDOWS_H
#define LIBPIGWINDOWS_H #define LIBPIGWINDOWS_H
#include <libpigpio.h> #include <libpigpio.h>
#include <libpigcore.h> #include <libpigcore.h>
struct pigI2C; struct pigI2C;
namespace pigpio namespace pigpio
{ {
class LIBPIGPIO_EXPORT pigWindows : public pigCore class LIBPIGPIO_EXPORT pigWindows : public pigCore
{ {
friend pigCore& get_instance(); friend pigCore& get_instance();
public: public:
pigWindows( const pigWindows& ) = delete; pigWindows( const pigWindows& ) = delete;
void operator=( const pigWindows& ) = delete; void operator=( const pigWindows& ) = delete;
virtual ~pigWindows() = default; virtual ~pigWindows() = default;
int init( const std::string& host ="", const std::string& port="" ) override; int init( const std::string& host ="", const std::string& port="" ) override;
// pin config // pin config
int set_io_mode( bcm_t bcm, io_t mode ) override; int set_io_mode( bcm_t bcm, io_t mode ) override;
int get_io_mode( bcm_t bcm ) override; int get_io_mode( bcm_t bcm ) override;
int set_pud_mode( bcm_t bcm, pud_t pud ) 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_glitch_filter( bcm_t bcm, uint32_t glitch = GlitchDef ) override;
int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override; int set_noise_filter( bcm_t bcm, uint32_t steady, uint32_t active ) override;
// pin operations // pin operations
int get_level( bcm_t bcm ) override; int get_level( bcm_t bcm ) override;
int set_level( bcm_t bcm, level_t level ) 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 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; int trigger_level( bcm_t bcm, level_t level, uint32_t pulseLen ) override;
// interface // interface
int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override; int set_callback( bcm_t bcm, pigCall* user, edge_t edge = either ) override;
int cancel_callback( int cbId ) override; int cancel_callback( int cbId ) override;
// software PWM // software PWM
/* /*
set_PWM_dutycycle Start/stop PWM pulses on a GPIO set_PWM_dutycycle Start/stop PWM pulses on a GPIO
set_PWM_frequency Configure PWM frequency for a GPIO set_PWM_frequency Configure PWM frequency for a GPIO
set_PWM_range Configure PWM range 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_dutycycle Get the PWM dutycycle in use on a GPIO
get_PWM_frequency Get configured PWM frequency for a GPIO get_PWM_frequency Get configured PWM frequency for a GPIO
get_PWM_range Get configured PWM range for a GPIO get_PWM_range Get configured PWM range for a GPIO
get_PWM_real_range Get underlying PWM range for a GPIO get_PWM_real_range Get underlying PWM range for a GPIO
*/ */
// i2c // i2c
int i2c_open( pigI2C& i2c ) override; int i2c_open( pigI2C& i2c ) override;
int i2c_close( pigI2C& i2c ) override; int i2c_close( pigI2C& i2c ) override;
/* /*
int i2c_write_quick( pigI2C& i2c, unsigned bit ) override; int i2c_write_quick( pigI2C& i2c, unsigned bit ) override;
int i2c_write_byte( pigI2C& i2c, unsigned bVal ) 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_byte_data( pigI2C& i2c, unsigned reg, unsigned val ) override;
int i2c_write_word_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_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_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_write_device( pigI2C& i2c, char* buf, unsigned count ) override;
/* /*
int i2c_read_byte( pigI2C& i2c ) override; int i2c_read_byte( pigI2C& i2c ) override;
int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override; int i2c_read_byte_data( pigI2C& i2c, unsigned reg ) override;
int i2c_read_word_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_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_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_read_device( pigI2C& i2c, char* buf, unsigned count ) override;
int i2c_process_call( pigI2C& i2c, unsigned i2c_reg, unsigned wVal ) 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_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; int i2c_zip( pigI2C& i2c, char* inBuf, unsigned inLen, char* outBuf, unsigned outLen ) override;
*/ */
// advanced // advanced
int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override; int hardware_PWM( bcm_t bcm, uint32_t PWMfreq, uint32_t PWMduty ) override;
int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override; int hardware_clock( bcm_t bcm, uint32_t clkfreq ) override;
uint32_t get_current_tick() override; uint32_t get_current_tick() override;
// convenience // convenience
int show_error( int error ) override; int show_error( int error ) override;
// info // info
int get_hardware_revision() override; int get_hardware_revision() override;
int get_pigpio_version() override; int get_pigpio_version() override;
unsigned pigpiod_if_version() override; unsigned pigpiod_if_version() override;
private: private:
pigWindows() = default; pigWindows() = default;
}; };
} // namespace pigpio } // namespace pigpio
#endif // LIBPIGWINDOWS_H #endif // LIBPIGWINDOWS_H

342
main.cpp
View File

@@ -1,171 +1,171 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#include <libpigpio.h> #include <libpigpio.h>
#include <pigbutton.h> #include <pigbutton.h>
#include <pigtimer.h> #include <pigtimer.h>
#include <pigrotarydial.h> #include <pigrotarydial.h>
#include <pigchrono.h> #include <pigchrono.h>
#include <pigsonar.h> #include <pigsonar.h>
#include <piglcd.h> #include <piglcd.h>
#include <pigbeeper.h> #include <pigbeeper.h>
#include <pigbuzzer.h> #include <pigbuzzer.h>
#include <pigbutton.h> #include <pigbutton.h>
#include <pigled.h> #include <pigled.h>
#include <QApplication> #include <QApplication>
#include <QtGPIOMain.h> #include <QtGPIOMain.h>
using namespace std; using namespace std;
using namespace pigpio; using namespace pigpio;
void on_level( level_t level ) void on_level( level_t level )
{ {
cout << "on_level:" << level << endl; cout << "on_level:" << level << endl;
} }
namespace qtgpio namespace qtgpio
{ {
// LED // LED
[[maybe_unused]] static const char* const icnRed = ":images/Red.png"; [[maybe_unused]] static const char* const icnRed = ":images/Red.png";
[[maybe_unused]] static const char* const icnGreen = ":images/Green.png"; [[maybe_unused]] static const char* const icnGreen = ":images/Green.png";
/// misc /// misc
[[maybe_unused]] static const char* const version = "Version 0.8.43, 19.10.2022 © 2022 chris@sourceworx.org"; [[maybe_unused]] static const char* const version = "Version 0.8.43, 19.10.2022 © 2022 chris@sourceworx.org";
} }
//#define high true //#define high true
[[maybe_unused]] constexpr static const char* mainVersion = "libPiGPIO 0.2.11 / 19.10.2022 © 2022 chris@sourceworx.org"; [[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; } void funktion( double state ) { std::cout << "free function: " << state << std::endl; }
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {
Q_UNUSED(argc) Q_UNUSED(argc)
Q_UNUSED(argv) Q_UNUSED(argv)
//pigpio::init( "host", "port" ); //pigpio::init( "host", "port" );
greet(); greet();
// Blink is the “Hello World” of the microcontroller world. // Blink is the “Hello World” of the microcontroller world.
// It usually does nothing more than flash an LED or 2. // It usually does nothing more than flash an LED or 2.
// (Gordon Henderson, WiringPi ) // (Gordon Henderson, WiringPi )
pigLCD lcd( 0x27 ); //pigLCD lcd( 0x27 );
lcd.set_backlight( on ); //lcd.set_backlight( on );
lcd.write( 0, 0, "blink!" ); //lcd.write( 0, 0, "blink!" );
/* /*
on_level( 1 ); on_level( 1 );
on_level( true ); on_level( true );
on_level( pigpio::high ); on_level( pigpio::high );
on_level( high ); on_level( high );
*/ */
/* /*
// ein 'Drückschalter' an Pin GPIO 16 // ein 'Drückschalter' an Pin GPIO 16
pigButton button( bcm16 ); pigButton button( bcm16 );
// eine LED und ein Summer an Pin 12 und Pin 23 // eine LED und ein Summer an Pin 12 und Pin 23
pigLED LED( bcm12 ); pigLED LED( bcm12 );
pigBuzzer buzzer( bcm23 ); pigBuzzer buzzer( bcm23 );
// Zustände verknüpfen // Zustände verknüpfen
button.connect_state( LED ); button.connect_state( LED );
button.connect_state( buzzer ); button.connect_state( buzzer );
// 'connect_state' ist die Kurzform von // 'connect_state' ist die Kurzform von
// sigState.connect( &T::change_state, &listener ); // sigState.connect( &T::change_state, &listener );
*/ */
/* /*
pigBeeper beeper( bcm25 ); pigBeeper beeper( bcm25 );
std::vector<double> tnv = { 262.0, 294.0, 330.0, 262.0 }; std::vector<double> tnv = { 262.0, 294.0, 330.0, 262.0 };
std::vector<double> drv = { 0.5, 0.5, 0.5, 0.5 }; std::vector<double> drv = { 0.5, 0.5, 0.5, 0.5 };
beeper.play_tune( tnv, drv ); beeper.play_tune( tnv, drv );
beeper.play_tone( 295, 0.3 ); beeper.play_tone( 295, 0.3 );
*/ */
//pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 ); //pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
//pigRotaryDial dial( board17, board27, board22 ); //pigRotaryDial dial( board17, board27, board22 );
// für die raDIYo-Verdrahtung: // für die raDIYo-Verdrahtung:
pigRotaryDial dialA( bcm16, bcm20, bcm21 ); //pigRotaryDial dialA( bcm16, bcm20, bcm21 );
pigRotaryDial dialB( bcm05, bcm13, bcm06 ); pigRotaryDial dialB( bcm05, bcm13, bcm06 );
dialA.sigValue.connect( [&](int value){ cout << "Dial A: " << value << endl; } ); //dialA.sigValue.connect( [&](int value){ cout << "Dial A: " << value << endl; } );
dialB.sigValue.connect( [&](int value){ cout << "Dial B: " << value << endl; } ); dialB.sigValue.connect( [&](int value){ cout << "Dial B: " << value << endl; } );
/* /*
pigSonar sonar( bcm21, bcm20 ); pigSonar sonar( bcm21, bcm20 );
sonar.sigValue.connect( [&](double dist){ buzzer.buzz( 100, dist*50 ); } ); sonar.sigValue.connect( [&](double dist){ buzzer.buzz( 100, dist*50 ); } );
sonar.start( 20 ); sonar.start( 20 );
while( loop ) while( loop )
{ {
double dist = sonar.distance(); double dist = sonar.distance();
lcd.write( 0, 0, "Dist.: " + val2str( dist) + " cm" ); lcd.write( 0, 0, "Dist.: " + val2str( dist) + " cm" );
if( dist < 20 ) if( dist < 20 )
{ {
buzzer.buzz( 100, dist*50 ); buzzer.buzz( 100, dist*50 );
LED.blink( dist*30 ); LED.blink( dist*30 );
} }
delay_millis( 200 ); delay_millis( 200 );
} }
bool loop = true; bool loop = true;
button.sigState.connect( [&](bool){ loop = false; } ); button.sigState.connect( [&](bool){ loop = false; } );
while( loop ) while( loop )
{ {
lcd.write( 0,0, format_time() ); lcd.write( 0,0, format_time() );
delay_seconds( 1 ); delay_seconds( 1 );
} }
lcd.reset(); lcd.reset();
*/ */
// don't return, just wait forever, handling callbacks // don't return, just wait forever, handling callbacks
wait_loop(); wait_loop();
// alternatively, show button as widgets // alternatively, show button as widgets
QApplication application( argc, argv ); QApplication application( argc, argv );
QtGPIOMain window; QtGPIOMain window;
window.show(); window.show();
return application.exec(); return application.exec();
} }

View File

@@ -1,471 +1,471 @@
#define __DBL_MIN_EXP__ (-1021) #define __DBL_MIN_EXP__ (-1021)
#define __HQ_FBIT__ 15 #define __HQ_FBIT__ 15
#define __cpp_nontype_template_parameter_auto 201606L #define __cpp_nontype_template_parameter_auto 201606L
#define __UINT_LEAST16_MAX__ 0xffff #define __UINT_LEAST16_MAX__ 0xffff
#define __ARM_SIZEOF_WCHAR_T 4 #define __ARM_SIZEOF_WCHAR_T 4
#define __SFRACT_IBIT__ 0 #define __SFRACT_IBIT__ 0
#define __FLT_MIN__ 1.1754943508222875e-38F #define __FLT_MIN__ 1.1754943508222875e-38F
#define __GCC_IEC_559_COMPLEX 2 #define __GCC_IEC_559_COMPLEX 2
#define __cpp_aggregate_nsdmi 201304L #define __cpp_aggregate_nsdmi 201304L
#define __UFRACT_MAX__ 0XFFFFP-16UR #define __UFRACT_MAX__ 0XFFFFP-16UR
#define __UINT_LEAST8_TYPE__ unsigned char #define __UINT_LEAST8_TYPE__ unsigned char
#define __FLT_MAX_EXP__ 128 #define __FLT_MAX_EXP__ 128
#define __DQ_FBIT__ 63 #define __DQ_FBIT__ 63
#define __INTMAX_C(c) c ## LL #define __INTMAX_C(c) c ## LL
#define __ARM_FEATURE_SAT 1 #define __ARM_FEATURE_SAT 1
#define __ULFRACT_FBIT__ 32 #define __ULFRACT_FBIT__ 32
#define __CHAR_BIT__ 8 #define __CHAR_BIT__ 8
#define __USQ_IBIT__ 0 #define __USQ_IBIT__ 0
#define __UINT8_MAX__ 0xff #define __UINT8_MAX__ 0xff
#define __ACCUM_FBIT__ 15 #define __ACCUM_FBIT__ 15
#define __WINT_MAX__ 0xffffffffU #define __WINT_MAX__ 0xffffffffU
#define __FLT32_MIN_EXP__ (-125) #define __FLT32_MIN_EXP__ (-125)
#define __cpp_static_assert 201411L #define __cpp_static_assert 201411L
#define __USFRACT_FBIT__ 8 #define __USFRACT_FBIT__ 8
#define __ORDER_LITTLE_ENDIAN__ 1234 #define __ORDER_LITTLE_ENDIAN__ 1234
#define __SIZE_MAX__ 0xffffffffU #define __SIZE_MAX__ 0xffffffffU
#define __ARM_ARCH_ISA_ARM 1 #define __ARM_ARCH_ISA_ARM 1
#define __WCHAR_MAX__ 0xffffffffU #define __WCHAR_MAX__ 0xffffffffU
#define __LACCUM_IBIT__ 32 #define __LACCUM_IBIT__ 32
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L) #define __DBL_DENORM_MIN__ double(4.9406564584124654e-324L)
#define __GCC_ATOMIC_CHAR_LOCK_FREE 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 1
#define __GCC_IEC_559 2 #define __GCC_IEC_559 2
#define __FLT32X_DECIMAL_DIG__ 17 #define __FLT32X_DECIMAL_DIG__ 17
#define __FLT_EVAL_METHOD__ 0 #define __FLT_EVAL_METHOD__ 0
#define __TQ_IBIT__ 0 #define __TQ_IBIT__ 0
#define __cpp_binary_literals 201304L #define __cpp_binary_literals 201304L
#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK #define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK
#define __FLT64_DECIMAL_DIG__ 17 #define __FLT64_DECIMAL_DIG__ 17
#define __cpp_noexcept_function_type 201510L #define __cpp_noexcept_function_type 201510L
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
#define __cpp_variadic_templates 200704L #define __cpp_variadic_templates 200704L
#define __INTPTR_WIDTH__ 32 #define __INTPTR_WIDTH__ 32
#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL #define __UINT_FAST64_MAX__ 0xffffffffffffffffULL
#define __SIG_ATOMIC_TYPE__ int #define __SIG_ATOMIC_TYPE__ int
#define __DBL_MIN_10_EXP__ (-307) #define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0 #define __FINITE_MATH_ONLY__ 0
#define __ARMEL__ 1 #define __ARMEL__ 1
#define __cpp_variable_templates 201304L #define __cpp_variable_templates 201304L
#define __FLT32X_MAX_EXP__ 1024 #define __FLT32X_MAX_EXP__ 1024
#define __LFRACT_IBIT__ 0 #define __LFRACT_IBIT__ 0
#define __GNUC_PATCHLEVEL__ 1 #define __GNUC_PATCHLEVEL__ 1
#define __FLT32_HAS_DENORM__ 1 #define __FLT32_HAS_DENORM__ 1
#define __USA_FBIT__ 16 #define __USA_FBIT__ 16
#define __UINT_FAST8_MAX__ 0xff #define __UINT_FAST8_MAX__ 0xff
#define __cpp_rvalue_reference 200610L #define __cpp_rvalue_reference 200610L
#define __INT8_C(c) c #define __INT8_C(c) c
#define __INT_LEAST8_WIDTH__ 8 #define __INT_LEAST8_WIDTH__ 8
#define __cpp_variadic_using 201611L #define __cpp_variadic_using 201611L
#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL #define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL
#define __INT16_MAX__ 0x7fff #define __INT16_MAX__ 0x7fff
#define __cpp_attributes 200809L #define __cpp_attributes 200809L
#define __SA_FBIT__ 15 #define __SA_FBIT__ 15
#define __cpp_capture_star_this 201603L #define __cpp_capture_star_this 201603L
#define __APCS_32__ 1 #define __APCS_32__ 1
#define __SHRT_MAX__ 0x7fff #define __SHRT_MAX__ 0x7fff
#define __LDBL_MAX__ 1.7976931348623157e+308L #define __LDBL_MAX__ 1.7976931348623157e+308L
#define __FRACT_MAX__ 0X7FFFP-15R #define __FRACT_MAX__ 0X7FFFP-15R
#define __cpp_if_constexpr 201606L #define __cpp_if_constexpr 201606L
#define __UFRACT_FBIT__ 16 #define __UFRACT_FBIT__ 16
#define __ARM_FP 12 #define __ARM_FP 12
#define __UFRACT_MIN__ 0.0UR #define __UFRACT_MIN__ 0.0UR
#define __UINT_LEAST8_MAX__ 0xff #define __UINT_LEAST8_MAX__ 0xff
#define __GCC_ATOMIC_BOOL_LOCK_FREE 1 #define __GCC_ATOMIC_BOOL_LOCK_FREE 1
#define __UINTMAX_TYPE__ long long unsigned int #define __UINTMAX_TYPE__ long long unsigned int
#define __LLFRACT_EPSILON__ 0x1P-63LLR #define __LLFRACT_EPSILON__ 0x1P-63LLR
#define __linux 1 #define __linux 1
#define __FLT_EVAL_METHOD_TS_18661_3__ 0 #define __FLT_EVAL_METHOD_TS_18661_3__ 0
#define __CHAR_UNSIGNED__ 1 #define __CHAR_UNSIGNED__ 1
#define __UINT32_MAX__ 0xffffffffU #define __UINT32_MAX__ 0xffffffffU
#define __GXX_EXPERIMENTAL_CXX0X__ 1 #define __GXX_EXPERIMENTAL_CXX0X__ 1
#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR #define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR
#define __TA_IBIT__ 64 #define __TA_IBIT__ 64
#define __LDBL_MAX_EXP__ 1024 #define __LDBL_MAX_EXP__ 1024
#define __WINT_MIN__ 0U #define __WINT_MIN__ 0U
#define __INT_LEAST16_WIDTH__ 16 #define __INT_LEAST16_WIDTH__ 16
#define __ULLFRACT_MIN__ 0.0ULLR #define __ULLFRACT_MIN__ 0.0ULLR
#define __SCHAR_MAX__ 0x7f #define __SCHAR_MAX__ 0x7f
#define __WCHAR_MIN__ 0U #define __WCHAR_MIN__ 0U
#define __INT64_C(c) c ## LL #define __INT64_C(c) c ## LL
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK) #define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK)
#define __SIZEOF_INT__ 4 #define __SIZEOF_INT__ 4
#define __FLT32X_MANT_DIG__ 53 #define __FLT32X_MANT_DIG__ 53
#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
#define __USACCUM_IBIT__ 8 #define __USACCUM_IBIT__ 8
#define __cpp_aligned_new 201606L #define __cpp_aligned_new 201606L
#define __USER_LABEL_PREFIX__ #define __USER_LABEL_PREFIX__
#define __STDC_HOSTED__ 1 #define __STDC_HOSTED__ 1
#define __FLT_DIG__ 6 #define __FLT_DIG__ 6
#define __LFRACT_MIN__ (-0.5LR-0.5LR) #define __LFRACT_MIN__ (-0.5LR-0.5LR)
#define __HA_IBIT__ 8 #define __HA_IBIT__ 8
#define __cpp_decltype_auto 201304L #define __cpp_decltype_auto 201304L
#define __FLT32_DIG__ 6 #define __FLT32_DIG__ 6
#define __FLT_EPSILON__ 1.1920928955078125e-7F #define __FLT_EPSILON__ 1.1920928955078125e-7F
#define __GXX_WEAK__ 1 #define __GXX_WEAK__ 1
#define __SHRT_WIDTH__ 16 #define __SHRT_WIDTH__ 16
#define __USFRACT_IBIT__ 0 #define __USFRACT_IBIT__ 0
#define __LDBL_MIN__ 2.2250738585072014e-308L #define __LDBL_MIN__ 2.2250738585072014e-308L
#define __FRACT_MIN__ (-0.5R-0.5R) #define __FRACT_MIN__ (-0.5R-0.5R)
#define __DA_IBIT__ 32 #define __DA_IBIT__ 32
#define __ARM_SIZEOF_MINIMAL_ENUM 4 #define __ARM_SIZEOF_MINIMAL_ENUM 4
#define __FLT32X_HAS_INFINITY__ 1 #define __FLT32X_HAS_INFINITY__ 1
#define __UQQ_FBIT__ 8 #define __UQQ_FBIT__ 8
#define __SIZEOF_LONG__ 4 #define __SIZEOF_LONG__ 4
#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK #define __UACCUM_MAX__ 0XFFFFFFFFP-16UK
#define __STDC_IEC_559__ 1 #define __STDC_IEC_559__ 1
#define __STDC_ISO_10646__ 201706L #define __STDC_ISO_10646__ 201706L
#define __DECIMAL_DIG__ 17 #define __DECIMAL_DIG__ 17
#define __LFRACT_EPSILON__ 0x1P-31LR #define __LFRACT_EPSILON__ 0x1P-31LR
#define __STDC_IEC_559_COMPLEX__ 1 #define __STDC_IEC_559_COMPLEX__ 1
#define __FLT64_EPSILON__ 2.2204460492503131e-16F64 #define __FLT64_EPSILON__ 2.2204460492503131e-16F64
#define __gnu_linux__ 1 #define __gnu_linux__ 1
#define __FLT64_MIN_EXP__ (-1021) #define __FLT64_MIN_EXP__ (-1021)
#define __ARM_PCS_VFP 1 #define __ARM_PCS_VFP 1
#define __LDBL_HAS_QUIET_NAN__ 1 #define __LDBL_HAS_QUIET_NAN__ 1
#define __ULACCUM_IBIT__ 32 #define __ULACCUM_IBIT__ 32
#define __FLT64_MANT_DIG__ 53 #define __FLT64_MANT_DIG__ 53
#define __GXX_RTTI 1 #define __GXX_RTTI 1
#define __UACCUM_EPSILON__ 0x1P-16UK #define __UACCUM_EPSILON__ 0x1P-16UK
#define __GNUC__ 10 #define __GNUC__ 10
#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK #define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK
#define __HQ_IBIT__ 0 #define __HQ_IBIT__ 0
#define __FLT_HAS_DENORM__ 1 #define __FLT_HAS_DENORM__ 1
#define __SIZEOF_LONG_DOUBLE__ 8 #define __SIZEOF_LONG_DOUBLE__ 8
#define __SA_IBIT__ 16 #define __SA_IBIT__ 16
#define __BIGGEST_ALIGNMENT__ 8 #define __BIGGEST_ALIGNMENT__ 8
#define __STDC_UTF_16__ 1 #define __STDC_UTF_16__ 1
#define __INTPTR_TYPE__ int #define __INTPTR_TYPE__ int
#define __FLT64_MAX_10_EXP__ 308 #define __FLT64_MAX_10_EXP__ 308
#define __DBL_DIG__ 15 #define __DBL_DIG__ 15
#define __ULLACCUM_FBIT__ 32 #define __ULLACCUM_FBIT__ 32
#define __GNUC_STDC_INLINE__ 1 #define __GNUC_STDC_INLINE__ 1
#define __DQ_IBIT__ 0 #define __DQ_IBIT__ 0
#define __DBL_MAX__ double(1.7976931348623157e+308L) #define __DBL_MAX__ double(1.7976931348623157e+308L)
#define __ULFRACT_IBIT__ 0 #define __ULFRACT_IBIT__ 0
#define __cpp_raw_strings 200710L #define __cpp_raw_strings 200710L
#define __INT_FAST32_MAX__ 0x7fffffff #define __INT_FAST32_MAX__ 0x7fffffff
#define __DBL_HAS_INFINITY__ 1 #define __DBL_HAS_INFINITY__ 1
#define __HAVE_SPECULATION_SAFE_VALUE 1 #define __HAVE_SPECULATION_SAFE_VALUE 1
#define __cpp_fold_expressions 201603L #define __cpp_fold_expressions 201603L
#define __ACCUM_IBIT__ 16 #define __ACCUM_IBIT__ 16
#define __THUMB_INTERWORK__ 1 #define __THUMB_INTERWORK__ 1
#define __UINT_LEAST32_MAX__ 0xffffffffU #define __UINT_LEAST32_MAX__ 0xffffffffU
#define __ULLACCUM_IBIT__ 32 #define __ULLACCUM_IBIT__ 32
#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK #define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK
#define __cpp_delegating_constructors 200604L #define __cpp_delegating_constructors 200604L
#define __FLT32X_HAS_DENORM__ 1 #define __FLT32X_HAS_DENORM__ 1
#define __INT_FAST16_TYPE__ int #define __INT_FAST16_TYPE__ int
#define __LDBL_HAS_DENORM__ 1 #define __LDBL_HAS_DENORM__ 1
#define __ARM_FEATURE_LDREX 4 #define __ARM_FEATURE_LDREX 4
#define __cplusplus 201703L #define __cplusplus 201703L
#define __cpp_ref_qualifiers 200710L #define __cpp_ref_qualifiers 200710L
#define __FLT32_DECIMAL_DIG__ 9 #define __FLT32_DECIMAL_DIG__ 9
#define __INT_LEAST32_MAX__ 0x7fffffff #define __INT_LEAST32_MAX__ 0x7fffffff
#define __ACCUM_MAX__ 0X7FFFFFFFP-15K #define __ACCUM_MAX__ 0X7FFFFFFFP-15K
#define __DEPRECATED 1 #define __DEPRECATED 1
#define __cpp_rvalue_references 200610L #define __cpp_rvalue_references 200610L
#define __DBL_MAX_EXP__ 1024 #define __DBL_MAX_EXP__ 1024
#define __USACCUM_EPSILON__ 0x1P-8UHK #define __USACCUM_EPSILON__ 0x1P-8UHK
#define __WCHAR_WIDTH__ 32 #define __WCHAR_WIDTH__ 32
#define __FLT32_MAX__ 3.4028234663852886e+38F32 #define __FLT32_MAX__ 3.4028234663852886e+38F32
#define __SFRACT_MAX__ 0X7FP-7HR #define __SFRACT_MAX__ 0X7FP-7HR
#define __FRACT_IBIT__ 0 #define __FRACT_IBIT__ 0
#define __PTRDIFF_MAX__ 0x7fffffff #define __PTRDIFF_MAX__ 0x7fffffff
#define __UACCUM_MIN__ 0.0UK #define __UACCUM_MIN__ 0.0UK
#define __UACCUM_IBIT__ 16 #define __UACCUM_IBIT__ 16
#define __FLT32_HAS_QUIET_NAN__ 1 #define __FLT32_HAS_QUIET_NAN__ 1
#define __GNUG__ 10 #define __GNUG__ 10
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK #define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK
#define __cpp_nsdmi 200809L #define __cpp_nsdmi 200809L
#define __SIZEOF_WINT_T__ 4 #define __SIZEOF_WINT_T__ 4
#define __ARM_FEATURE_UNALIGNED 1 #define __ARM_FEATURE_UNALIGNED 1
#define __LONG_LONG_WIDTH__ 64 #define __LONG_LONG_WIDTH__ 64
#define __cpp_initializer_lists 200806L #define __cpp_initializer_lists 200806L
#define __FLT32_MAX_EXP__ 128 #define __FLT32_MAX_EXP__ 128
#define __ULLACCUM_MIN__ 0.0ULLK #define __ULLACCUM_MIN__ 0.0ULLK
#define __cpp_hex_float 201603L #define __cpp_hex_float 201603L
#define __cpp_threadsafe_static_init 200806L #define __cpp_threadsafe_static_init 200806L
#define __GXX_ABI_VERSION 1014 #define __GXX_ABI_VERSION 1014
#define __UTA_FBIT__ 64 #define __UTA_FBIT__ 64
#define __UFRACT_IBIT__ 0 #define __UFRACT_IBIT__ 0
#define __USQ_FBIT__ 32 #define __USQ_FBIT__ 32
#define __cpp_enumerator_attributes 201411L #define __cpp_enumerator_attributes 201411L
#define __cpp_lambdas 200907L #define __cpp_lambdas 200907L
#define __ARM_FEATURE_QBIT 1 #define __ARM_FEATURE_QBIT 1
#define __INT_FAST64_TYPE__ long long int #define __INT_FAST64_TYPE__ long long int
#define __FLT64_DENORM_MIN__ 4.9406564584124654e-324F64 #define __FLT64_DENORM_MIN__ 4.9406564584124654e-324F64
#define __DBL_MIN__ double(2.2250738585072014e-308L) #define __DBL_MIN__ double(2.2250738585072014e-308L)
#define __SIZEOF_POINTER__ 4 #define __SIZEOF_POINTER__ 4
#define __INT16_TYPE__ short int #define __INT16_TYPE__ short int
#define __DBL_HAS_QUIET_NAN__ 1 #define __DBL_HAS_QUIET_NAN__ 1
#define __FLT32X_EPSILON__ 2.2204460492503131e-16F32x #define __FLT32X_EPSILON__ 2.2204460492503131e-16F32x
#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK) #define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK)
#define __FRACT_FBIT__ 15 #define __FRACT_FBIT__ 15
#define __FLT64_MIN_10_EXP__ (-307) #define __FLT64_MIN_10_EXP__ (-307)
#define __ULLFRACT_EPSILON__ 0x1P-64ULLR #define __ULLFRACT_EPSILON__ 0x1P-64ULLR
#define __REGISTER_PREFIX__ #define __REGISTER_PREFIX__
#define __UINT16_MAX__ 0xffff #define __UINT16_MAX__ 0xffff
#define __ACCUM_MIN__ (-0X1P15K-0X1P15K) #define __ACCUM_MIN__ (-0X1P15K-0X1P15K)
#define __SQ_IBIT__ 0 #define __SQ_IBIT__ 0
#define __UINT8_TYPE__ unsigned char #define __UINT8_TYPE__ unsigned char
#define __UHA_FBIT__ 8 #define __UHA_FBIT__ 8
#define __SFRACT_MIN__ (-0.5HR-0.5HR) #define __SFRACT_MIN__ (-0.5HR-0.5HR)
#define __UTQ_FBIT__ 128 #define __UTQ_FBIT__ 128
#define __DEC_EVAL_METHOD__ 2 #define __DEC_EVAL_METHOD__ 2
#define __FLT_MANT_DIG__ 24 #define __FLT_MANT_DIG__ 24
#define __LDBL_DECIMAL_DIG__ 17 #define __LDBL_DECIMAL_DIG__ 17
#define __VERSION__ "10.2.1 20210110" #define __VERSION__ "10.2.1 20210110"
#define __UINT64_C(c) c ## ULL #define __UINT64_C(c) c ## ULL
#define __cpp_unicode_characters 201411L #define __cpp_unicode_characters 201411L
#define __FRACT_EPSILON__ 0x1P-15R #define __FRACT_EPSILON__ 0x1P-15R
#define __ULACCUM_MIN__ 0.0ULK #define __ULACCUM_MIN__ 0.0ULK
#define _STDC_PREDEF_H 1 #define _STDC_PREDEF_H 1
#define __UDA_FBIT__ 32 #define __UDA_FBIT__ 32
#define __GCC_ATOMIC_INT_LOCK_FREE 2 #define __GCC_ATOMIC_INT_LOCK_FREE 2
#define __FLT_MIN_EXP__ (-125) #define __FLT_MIN_EXP__ (-125)
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __USFRACT_MIN__ 0.0UHR #define __USFRACT_MIN__ 0.0UHR
#define __FLT32_MANT_DIG__ 24 #define __FLT32_MANT_DIG__ 24
#define __ULLFRACT_FBIT__ 64 #define __ULLFRACT_FBIT__ 64
#define __cpp_aggregate_bases 201603L #define __cpp_aggregate_bases 201603L
#define __UQQ_IBIT__ 0 #define __UQQ_IBIT__ 0
#define __SCHAR_WIDTH__ 8 #define __SCHAR_WIDTH__ 8
#define __INT32_C(c) c #define __INT32_C(c) c
#define __ORDER_PDP_ENDIAN__ 3412 #define __ORDER_PDP_ENDIAN__ 3412
#define __UHQ_FBIT__ 16 #define __UHQ_FBIT__ 16
#define __LLACCUM_FBIT__ 31 #define __LLACCUM_FBIT__ 31
#define __INT_FAST32_TYPE__ int #define __INT_FAST32_TYPE__ int
#define __UINT_LEAST16_TYPE__ short unsigned int #define __UINT_LEAST16_TYPE__ short unsigned int
#define unix 1 #define unix 1
#define __DBL_HAS_DENORM__ 1 #define __DBL_HAS_DENORM__ 1
#define __cpp_rtti 199711L #define __cpp_rtti 199711L
#define __SIZE_TYPE__ unsigned int #define __SIZE_TYPE__ unsigned int
#define __UINT64_MAX__ 0xffffffffffffffffULL #define __UINT64_MAX__ 0xffffffffffffffffULL
#define __UDQ_FBIT__ 64 #define __UDQ_FBIT__ 64
#define __INT8_TYPE__ signed char #define __INT8_TYPE__ signed char
#define __cpp_digit_separators 201309L #define __cpp_digit_separators 201309L
#define __ELF__ 1 #define __ELF__ 1
#define __SACCUM_EPSILON__ 0x1P-7HK #define __SACCUM_EPSILON__ 0x1P-7HK
#define __ULFRACT_EPSILON__ 0x1P-32ULR #define __ULFRACT_EPSILON__ 0x1P-32ULR
#define __LLFRACT_FBIT__ 63 #define __LLFRACT_FBIT__ 63
#define __FLT_RADIX__ 2 #define __FLT_RADIX__ 2
#define __INT_LEAST16_TYPE__ short int #define __INT_LEAST16_TYPE__ short int
#define __LDBL_EPSILON__ 2.2204460492503131e-16L #define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __UINTMAX_C(c) c ## ULL #define __UINTMAX_C(c) c ## ULL
#define __SACCUM_MAX__ 0X7FFFP-7HK #define __SACCUM_MAX__ 0X7FFFP-7HK
#define __FLT32X_MIN__ 2.2250738585072014e-308F32x #define __FLT32X_MIN__ 2.2250738585072014e-308F32x
#define __SIG_ATOMIC_MAX__ 0x7fffffff #define __SIG_ATOMIC_MAX__ 0x7fffffff
#define __UACCUM_FBIT__ 16 #define __UACCUM_FBIT__ 16
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
#define __VFP_FP__ 1 #define __VFP_FP__ 1
#define __SIZEOF_PTRDIFF_T__ 4 #define __SIZEOF_PTRDIFF_T__ 4
#define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQUIRE 2
#define __unix__ 1 #define __unix__ 1
#define __INT_WIDTH__ 32 #define __INT_WIDTH__ 32
#define __OPTIMIZE__ 1 #define __OPTIMIZE__ 1
#define __LACCUM_EPSILON__ 0x1P-31LK #define __LACCUM_EPSILON__ 0x1P-31LK
#define __LDBL_DIG__ 15 #define __LDBL_DIG__ 15
#define __FLT32X_MIN_EXP__ (-1021) #define __FLT32X_MIN_EXP__ (-1021)
#define __INT_FAST16_MAX__ 0x7fffffff #define __INT_FAST16_MAX__ 0x7fffffff
#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR #define __LFRACT_MAX__ 0X7FFFFFFFP-31LR
#define __ARM_ARCH_6__ 1 #define __ARM_ARCH_6__ 1
#define __FLT64_DIG__ 15 #define __FLT64_DIG__ 15
#define __UINT_FAST32_MAX__ 0xffffffffU #define __UINT_FAST32_MAX__ 0xffffffffU
#define __UINT_LEAST64_TYPE__ long long unsigned int #define __UINT_LEAST64_TYPE__ long long unsigned int
#define __SFRACT_EPSILON__ 0x1P-7HR #define __SFRACT_EPSILON__ 0x1P-7HR
#define __GCC_ASM_FLAG_OUTPUTS__ 1 #define __GCC_ASM_FLAG_OUTPUTS__ 1
#define __FLT_HAS_QUIET_NAN__ 1 #define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38 #define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 0x7fffffffL #define __LONG_MAX__ 0x7fffffffL
#define __SIZEOF_SIZE_T__ 4 #define __SIZEOF_SIZE_T__ 4
#define __FLT_HAS_INFINITY__ 1 #define __FLT_HAS_INFINITY__ 1
#define __unix 1 #define __unix 1
#define __cpp_unicode_literals 200710L #define __cpp_unicode_literals 200710L
#define __cpp_init_captures 201304L #define __cpp_init_captures 201304L
#define __UINT_FAST16_TYPE__ unsigned int #define __UINT_FAST16_TYPE__ unsigned int
#define __ARM_32BIT_STATE 1 #define __ARM_32BIT_STATE 1
#define __INT_FAST32_WIDTH__ 32 #define __INT_FAST32_WIDTH__ 32
#define __CHAR16_TYPE__ short unsigned int #define __CHAR16_TYPE__ short unsigned int
#define __PRAGMA_REDEFINE_EXTNAME 1 #define __PRAGMA_REDEFINE_EXTNAME 1
#define __SIZE_WIDTH__ 32 #define __SIZE_WIDTH__ 32
#define __INT_LEAST16_MAX__ 0x7fff #define __INT_LEAST16_MAX__ 0x7fff
#define __INT64_MAX__ 0x7fffffffffffffffLL #define __INT64_MAX__ 0x7fffffffffffffffLL
#define __SACCUM_FBIT__ 7 #define __SACCUM_FBIT__ 7
#define __FLT32_DENORM_MIN__ 1.4012984643248171e-45F32 #define __FLT32_DENORM_MIN__ 1.4012984643248171e-45F32
#define __SIG_ATOMIC_WIDTH__ 32 #define __SIG_ATOMIC_WIDTH__ 32
#define __INT_LEAST64_TYPE__ long long int #define __INT_LEAST64_TYPE__ long long int
#define __ARM_FEATURE_CLZ 1 #define __ARM_FEATURE_CLZ 1
#define __INT_LEAST8_TYPE__ signed char #define __INT_LEAST8_TYPE__ signed char
#define __cpp_structured_bindings 201606L #define __cpp_structured_bindings 201606L
#define __SQ_FBIT__ 31 #define __SQ_FBIT__ 31
#define __USFRACT_MAX__ 0XFFP-8UHR #define __USFRACT_MAX__ 0XFFP-8UHR
#define __ARM_ARCH_ISA_THUMB 1 #define __ARM_ARCH_ISA_THUMB 1
#define __INT_FAST8_MAX__ 0x7f #define __INT_FAST8_MAX__ 0x7f
#define __ARM_ARCH 6 #define __ARM_ARCH 6
#define __INTPTR_MAX__ 0x7fffffff #define __INTPTR_MAX__ 0x7fffffff
#define __cpp_sized_deallocation 201309L #define __cpp_sized_deallocation 201309L
#define __cpp_guaranteed_copy_elision 201606L #define __cpp_guaranteed_copy_elision 201606L
#define __QQ_FBIT__ 7 #define __QQ_FBIT__ 7
#define linux 1 #define linux 1
#define __UTA_IBIT__ 64 #define __UTA_IBIT__ 64
#define __FLT64_HAS_QUIET_NAN__ 1 #define __FLT64_HAS_QUIET_NAN__ 1
#define __UINT16_C(c) c #define __UINT16_C(c) c
#define __PTRDIFF_WIDTH__ 32 #define __PTRDIFF_WIDTH__ 32
#define __LDBL_MANT_DIG__ 53 #define __LDBL_MANT_DIG__ 53
#define __SFRACT_FBIT__ 7 #define __SFRACT_FBIT__ 7
#define __cpp_range_based_for 201603L #define __cpp_range_based_for 201603L
#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK) #define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK)
#define __FLT64_HAS_INFINITY__ 1 #define __FLT64_HAS_INFINITY__ 1
#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8 #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8
#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
#define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __GCC_ATOMIC_LONG_LOCK_FREE 2
#define __cpp_nontype_template_args 201411L #define __cpp_nontype_template_args 201411L
#define __UINT16_TYPE__ short unsigned int #define __UINT16_TYPE__ short unsigned int
#define __WCHAR_TYPE__ unsigned int #define __WCHAR_TYPE__ unsigned int
#define __SIZEOF_FLOAT__ 4 #define __SIZEOF_FLOAT__ 4
#define __TQ_FBIT__ 127 #define __TQ_FBIT__ 127
#define __UINTPTR_MAX__ 0xffffffffU #define __UINTPTR_MAX__ 0xffffffffU
#define __INT_FAST64_WIDTH__ 64 #define __INT_FAST64_WIDTH__ 64
#define __cpp_decltype 200707L #define __cpp_decltype 200707L
#define __cpp_nested_namespace_definitions 201411L #define __cpp_nested_namespace_definitions 201411L
#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL #define __INT_FAST64_MAX__ 0x7fffffffffffffffLL
#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
#define __FLT_NORM_MAX__ 3.4028234663852886e+38F #define __FLT_NORM_MAX__ 3.4028234663852886e+38F
#define __FLT32_HAS_INFINITY__ 1 #define __FLT32_HAS_INFINITY__ 1
#define __UINT_FAST64_TYPE__ long long unsigned int #define __UINT_FAST64_TYPE__ long long unsigned int
#define __cpp_inline_variables 201606L #define __cpp_inline_variables 201606L
#define __LACCUM_FBIT__ 31 #define __LACCUM_FBIT__ 31
#define __HA_FBIT__ 7 #define __HA_FBIT__ 7
#define __UHA_IBIT__ 8 #define __UHA_IBIT__ 8
#define __INT64_TYPE__ long long int #define __INT64_TYPE__ long long int
#define __UTQ_IBIT__ 0 #define __UTQ_IBIT__ 0
#define __DBL_MANT_DIG__ 53 #define __DBL_MANT_DIG__ 53
#define __cpp_inheriting_constructors 201511L #define __cpp_inheriting_constructors 201511L
#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL #define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL
#define __WINT_TYPE__ unsigned int #define __WINT_TYPE__ unsigned int
#define __UINT_LEAST32_TYPE__ unsigned int #define __UINT_LEAST32_TYPE__ unsigned int
#define __SIZEOF_SHORT__ 2 #define __SIZEOF_SHORT__ 2
#define __ULLFRACT_IBIT__ 0 #define __ULLFRACT_IBIT__ 0
#define __FLT32_NORM_MAX__ 3.4028234663852886e+38F32 #define __FLT32_NORM_MAX__ 3.4028234663852886e+38F32
#define __LDBL_MIN_EXP__ (-1021) #define __LDBL_MIN_EXP__ (-1021)
#define __GXX_TYPEINFO_EQUALITY_INLINE 0 #define __GXX_TYPEINFO_EQUALITY_INLINE 0
#define __INTMAX_MAX__ 0x7fffffffffffffffLL #define __INTMAX_MAX__ 0x7fffffffffffffffLL
#define __arm__ 1 #define __arm__ 1
#define __FLT64_MAX__ 1.7976931348623157e+308F64 #define __FLT64_MAX__ 1.7976931348623157e+308F64
#define __UDA_IBIT__ 32 #define __UDA_IBIT__ 32
#define __INT_MAX__ 0x7fffffff #define __INT_MAX__ 0x7fffffff
#define __WINT_WIDTH__ 32 #define __WINT_WIDTH__ 32
#define __cpp_template_auto 201606L #define __cpp_template_auto 201606L
#define __INT_LEAST8_MAX__ 0x7f #define __INT_LEAST8_MAX__ 0x7f
#define __INT_LEAST64_WIDTH__ 64 #define __INT_LEAST64_WIDTH__ 64
#define __FLT32X_MAX_10_EXP__ 308 #define __FLT32X_MAX_10_EXP__ 308
#define __LLACCUM_EPSILON__ 0x1P-31LLK #define __LLACCUM_EPSILON__ 0x1P-31LLK
#define __LFRACT_FBIT__ 31 #define __LFRACT_FBIT__ 31
#define __WCHAR_UNSIGNED__ 1 #define __WCHAR_UNSIGNED__ 1
#define __LDBL_MAX_10_EXP__ 308 #define __LDBL_MAX_10_EXP__ 308
#define __ATOMIC_RELAXED 0 #define __ATOMIC_RELAXED 0
#define __DBL_EPSILON__ double(2.2204460492503131e-16L) #define __DBL_EPSILON__ double(2.2204460492503131e-16L)
#define __ARM_FEATURE_SIMD32 1 #define __ARM_FEATURE_SIMD32 1
#define __UINT8_C(c) c #define __UINT8_C(c) c
#define __FLT64_MAX_EXP__ 1024 #define __FLT64_MAX_EXP__ 1024
#define __INT_LEAST32_TYPE__ int #define __INT_LEAST32_TYPE__ int
#define __cpp_return_type_deduction 201304L #define __cpp_return_type_deduction 201304L
#define __SIZEOF_WCHAR_T__ 4 #define __SIZEOF_WCHAR_T__ 4
#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR #define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR
#define __FLT64_NORM_MAX__ 1.7976931348623157e+308F64 #define __FLT64_NORM_MAX__ 1.7976931348623157e+308F64
#define __INT_FAST8_TYPE__ signed char #define __INT_FAST8_TYPE__ signed char
#define __cpp_namespace_attributes 201411L #define __cpp_namespace_attributes 201411L
#define __ULLACCUM_EPSILON__ 0x1P-32ULLK #define __ULLACCUM_EPSILON__ 0x1P-32ULLK
#define __USACCUM_MAX__ 0XFFFFP-8UHK #define __USACCUM_MAX__ 0XFFFFP-8UHK
#define __LDBL_HAS_INFINITY__ 1 #define __LDBL_HAS_INFINITY__ 1
#define __FLT32_MAX_10_EXP__ 38 #define __FLT32_MAX_10_EXP__ 38
#define __UHQ_IBIT__ 0 #define __UHQ_IBIT__ 0
#define __ARM_FEATURE_COPROC 15 #define __ARM_FEATURE_COPROC 15
#define __LLACCUM_IBIT__ 32 #define __LLACCUM_IBIT__ 32
#define __ULFRACT_MIN__ 0.0ULR #define __ULFRACT_MIN__ 0.0ULR
#define __FLT64_HAS_DENORM__ 1 #define __FLT64_HAS_DENORM__ 1
#define __FLT32_EPSILON__ 1.1920928955078125e-7F32 #define __FLT32_EPSILON__ 1.1920928955078125e-7F32
#define __DBL_DECIMAL_DIG__ 17 #define __DBL_DECIMAL_DIG__ 17
#define __STDC_UTF_32__ 1 #define __STDC_UTF_32__ 1
#define __INT_FAST8_WIDTH__ 8 #define __INT_FAST8_WIDTH__ 8
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __FLT32X_MAX__ 1.7976931348623157e+308F32x #define __FLT32X_MAX__ 1.7976931348623157e+308F32x
#define __TA_FBIT__ 63 #define __TA_FBIT__ 63
#define __DBL_NORM_MAX__ double(1.7976931348623157e+308L) #define __DBL_NORM_MAX__ double(1.7976931348623157e+308L)
#define __UDQ_IBIT__ 0 #define __UDQ_IBIT__ 0
#define __INTMAX_WIDTH__ 64 #define __INTMAX_WIDTH__ 64
#define __ORDER_BIG_ENDIAN__ 4321 #define __ORDER_BIG_ENDIAN__ 4321
#define __ARM_FEATURE_DSP 1 #define __ARM_FEATURE_DSP 1
#define __cpp_runtime_arrays 198712L #define __cpp_runtime_arrays 198712L
#define __UINT64_TYPE__ long long unsigned int #define __UINT64_TYPE__ long long unsigned int
#define __ACCUM_EPSILON__ 0x1P-15K #define __ACCUM_EPSILON__ 0x1P-15K
#define __UINT32_C(c) c ## U #define __UINT32_C(c) c ## U
#define __cpp_alias_templates 200704L #define __cpp_alias_templates 200704L
#define __QQ_IBIT__ 0 #define __QQ_IBIT__ 0
#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F #define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
#define __LLFRACT_IBIT__ 0 #define __LLFRACT_IBIT__ 0
#define __INT8_MAX__ 0x7f #define __INT8_MAX__ 0x7f
#define __LONG_WIDTH__ 32 #define __LONG_WIDTH__ 32
#define __INT32_MAX__ 0x7fffffff #define __INT32_MAX__ 0x7fffffff
#define __UINT_FAST32_TYPE__ unsigned int #define __UINT_FAST32_TYPE__ unsigned int
#define __FLT32X_NORM_MAX__ 1.7976931348623157e+308F32x #define __FLT32X_NORM_MAX__ 1.7976931348623157e+308F32x
#define __CHAR32_TYPE__ unsigned int #define __CHAR32_TYPE__ unsigned int
#define __FLT32_MIN_10_EXP__ (-37) #define __FLT32_MIN_10_EXP__ (-37)
#define __FLT_MAX__ 3.4028234663852886e+38F #define __FLT_MAX__ 3.4028234663852886e+38F
#define __cpp_constexpr 201603L #define __cpp_constexpr 201603L
#define __USACCUM_FBIT__ 8 #define __USACCUM_FBIT__ 8
#define __cpp_deduction_guides 201703L #define __cpp_deduction_guides 201703L
#define __INT32_TYPE__ int #define __INT32_TYPE__ int
#define __SIZEOF_DOUBLE__ 8 #define __SIZEOF_DOUBLE__ 8
#define __cpp_exceptions 199711L #define __cpp_exceptions 199711L
#define __FLT_MIN_10_EXP__ (-37) #define __FLT_MIN_10_EXP__ (-37)
#define __UFRACT_EPSILON__ 0x1P-16UR #define __UFRACT_EPSILON__ 0x1P-16UR
#define __FLT64_MIN__ 2.2250738585072014e-308F64 #define __FLT64_MIN__ 2.2250738585072014e-308F64
#define __INT_LEAST32_WIDTH__ 32 #define __INT_LEAST32_WIDTH__ 32
#define __INTMAX_TYPE__ long long int #define __INTMAX_TYPE__ long long int
#define __FLT32X_HAS_QUIET_NAN__ 1 #define __FLT32X_HAS_QUIET_NAN__ 1
#define __ATOMIC_CONSUME 1 #define __ATOMIC_CONSUME 1
#define __GNUC_MINOR__ 2 #define __GNUC_MINOR__ 2
#define __INT_FAST16_WIDTH__ 32 #define __INT_FAST16_WIDTH__ 32
#define __UINTMAX_MAX__ 0xffffffffffffffffULL #define __UINTMAX_MAX__ 0xffffffffffffffffULL
#define __FLT32X_DENORM_MIN__ 4.9406564584124654e-324F32x #define __FLT32X_DENORM_MIN__ 4.9406564584124654e-324F32x
#define __cpp_template_template_args 201611L #define __cpp_template_template_args 201611L
#define __ATOMIC_ACQ_REL 4 #define __ATOMIC_ACQ_REL 4
#define __DBL_MAX_10_EXP__ 308 #define __DBL_MAX_10_EXP__ 308
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __INT16_C(c) c #define __INT16_C(c) c
#define __STDC__ 1 #define __STDC__ 1
#define __FLT32X_DIG__ 15 #define __FLT32X_DIG__ 15
#define __PTRDIFF_TYPE__ int #define __PTRDIFF_TYPE__ int
#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR) #define __LLFRACT_MIN__ (-0.5LLR-0.5LLR)
#define __USACCUM_MIN__ 0.0UHK #define __USACCUM_MIN__ 0.0UHK
#define __FLT32_MIN__ 1.1754943508222875e-38F32 #define __FLT32_MIN__ 1.1754943508222875e-38F32
#define __ATOMIC_SEQ_CST 5 #define __ATOMIC_SEQ_CST 5
#define __DA_FBIT__ 31 #define __DA_FBIT__ 31
#define __EXCEPTIONS 1 #define __EXCEPTIONS 1
#define __UINT32_TYPE__ unsigned int #define __UINT32_TYPE__ unsigned int
#define __FLT32X_MIN_10_EXP__ (-307) #define __FLT32X_MIN_10_EXP__ (-307)
#define __UINTPTR_TYPE__ unsigned int #define __UINTPTR_TYPE__ unsigned int
#define __USA_IBIT__ 16 #define __USA_IBIT__ 16
#define __ARM_EABI__ 1 #define __ARM_EABI__ 1
#define __linux__ 1 #define __linux__ 1
#define __LDBL_MIN_10_EXP__ (-307) #define __LDBL_MIN_10_EXP__ (-307)
#define __cpp_generic_lambdas 201304L #define __cpp_generic_lambdas 201304L
#define __SIZEOF_LONG_LONG__ 8 #define __SIZEOF_LONG_LONG__ 8
#define __ULACCUM_EPSILON__ 0x1P-32ULK #define __ULACCUM_EPSILON__ 0x1P-32ULK
#define __cpp_user_defined_literals 200809L #define __cpp_user_defined_literals 200809L
#define __SACCUM_IBIT__ 8 #define __SACCUM_IBIT__ 8
#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
#define __FLT_DECIMAL_DIG__ 9 #define __FLT_DECIMAL_DIG__ 9
#define __UINT_FAST16_MAX__ 0xffffffffU #define __UINT_FAST16_MAX__ 0xffffffffU
#define __LDBL_NORM_MAX__ 1.7976931348623157e+308L #define __LDBL_NORM_MAX__ 1.7976931348623157e+308L
#define __GCC_ATOMIC_SHORT_LOCK_FREE 1 #define __GCC_ATOMIC_SHORT_LOCK_FREE 1
#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR #define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR
#define __UINT_FAST8_TYPE__ unsigned char #define __UINT_FAST8_TYPE__ unsigned char
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#define __USFRACT_EPSILON__ 0x1P-8UHR #define __USFRACT_EPSILON__ 0x1P-8UHR
#define __ULACCUM_FBIT__ 32 #define __ULACCUM_FBIT__ 32
#define __ATOMIC_RELEASE 3 #define __ATOMIC_RELEASE 3

View File

@@ -1,74 +1,74 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <pigbeeper.h> #include <pigbeeper.h>
#include <iostream> #include <iostream>
pigBeeper::pigBeeper( bcm_t bcmNo ) pigBeeper::pigBeeper( bcm_t bcmNo )
: pigNodeOut( bcmNo , pull_off ) : pigNodeOut( bcmNo , pull_off )
{ {
} }
pigBeeper::~pigBeeper() pigBeeper::~pigBeeper()
{ {
} }
void pigBeeper::play_tone( double freq, double duration ) void pigBeeper::play_tone( double freq, double duration )
{ {
double halveWaveTime = 1 / ( freq * 2 ); double halveWaveTime = 1 / ( freq * 2 );
int ms = (int)( 1000 * halveWaveTime ); int ms = (int)( 1000 * halveWaveTime );
double waves = duration * freq; double waves = duration * freq;
int wv = (int) waves; int wv = (int) waves;
//std::cout << "sleep: " << halveWaveTime << " in micros: " << ms << " waves: " << waves << std::endl; //std::cout << "sleep: " << halveWaveTime << " in micros: " << ms << " waves: " << waves << std::endl;
std::thread thrd( std::thread thrd(
[=]() [=]()
{ {
for( int i=0; i < wv; ++i ) for( int i=0; i < wv; ++i )
{ {
_pinOut.set_level( high ); _pinOut.set_level( high );
delay_millis( ms ); delay_millis( ms );
_pinOut.set_level( low ); _pinOut.set_level( low );
delay_millis( ms ); delay_millis( ms );
} }
} ); } );
thrd.detach(); thrd.detach();
} }
void pigBeeper::play_tune( std::vector<double> frv, std::vector<double> drv ) void pigBeeper::play_tune( std::vector<double> frv, std::vector<double> drv )
{ {
size_t count = std::max( frv.size(), drv.size() ); size_t count = std::max( frv.size(), drv.size() );
for( size_t i=0; i<count; ++i ) for( size_t i=0; i<count; ++i )
{ {
//std::cout << "tone: " << freq[i] << " duration " << duration[i] << std::endl; //std::cout << "tone: " << freq[i] << " duration " << duration[i] << std::endl;
play_tone( frv[i], drv[i] ); play_tone( frv[i], drv[i] );
} }
} }

View File

@@ -1,50 +1,50 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGBEEPER_H #ifndef PIGBEEPER_H
#define PIGBEEPER_H #define PIGBEEPER_H
#include <pignodeout.h> #include <pignodeout.h>
#include <pigstate.h> #include <pigstate.h>
/** /**
* @brief The pigBeeper class * @brief The pigBeeper class
* ein __passiver__ Beeper, muss per PWM angesteuert * ein __passiver__ Beeper, muss per PWM angesteuert
* werden. * werden.
*/ */
class LIBPIGPIO_EXPORT pigBeeper : public pigNodeOut class LIBPIGPIO_EXPORT pigBeeper : public pigNodeOut
{ {
public: public:
explicit pigBeeper( pigpio::bcm_t bcmNo ); explicit pigBeeper( pigpio::bcm_t bcmNo );
virtual ~pigBeeper(); virtual ~pigBeeper();
void play_tone( double freq, double duration ); void play_tone( double freq, double duration );
void play_tune( std::vector<double> frv, std::vector<double> drv ); void play_tune( std::vector<double> frv, std::vector<double> drv );
}; };
#endif // PIGBEEPER_H #endif // PIGBEEPER_H

BIN
pigbin Normal file → Executable file

Binary file not shown.

View File

@@ -1,69 +1,69 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <pigbutton.h> #include <pigbutton.h>
pigButton::pigButton() pigButton::pigButton()
{ {
} }
pigButton::pigButton( pigpio::bcm_t bcmNo ) pigButton::pigButton( pigpio::bcm_t bcmNo )
{ {
init( bcmNo ); init( bcmNo );
} }
pigButton::~pigButton() pigButton::~pigButton()
{ {
} }
void pigButton::init( pigpio::bcm_t bcmNo ) void pigButton::init( pigpio::bcm_t bcmNo )
{ {
_pinIn.init( bcmNo, pull_up ); _pinIn.init( bcmNo, pull_up );
//pinIn.set_callback( this, rising ); //pinIn.set_callback( this, rising );
_pinIn.set_callback( this, falling ); _pinIn.set_callback( this, falling );
_pinIn.set_glitch_filter( 500 ); _pinIn.set_glitch_filter( 500 );
} }
void pigButton::change_state( bool newState ) void pigButton::change_state( bool newState )
{ {
if( newState == state() ) if( newState == state() )
return; return;
set_state( newState ); set_state( newState );
sigState( _state ); sigState( _state );
//_pinOut.set_level( _state ); //_pinOut.set_level( _state );
} }
void pigButton::trigger( pigpio::bcm_t, uint32_t ) void pigButton::trigger( pigpio::bcm_t, uint32_t )
{ {
//std::cout << "pigButton::trigger: " << (uint32_t) bcm << " : " << level << std::endl; //std::cout << "pigButton::trigger: " << (uint32_t) bcm << " : " << level << std::endl;
change_state( !state() ); change_state( !state() );
} }

View File

@@ -1,54 +1,54 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGBUTTON_H #ifndef PIGBUTTON_H
#define PIGBUTTON_H #define PIGBUTTON_H
#include <pignodein.h> #include <pignodein.h>
class LIBPIGPIO_EXPORT pigButton : public pigNodeIn class LIBPIGPIO_EXPORT pigButton : public pigNodeIn
{ {
public: public:
pigButton(); pigButton();
pigButton( pigpio::bcm_t bcmNo ); pigButton( pigpio::bcm_t bcmNo );
virtual ~pigButton(); virtual ~pigButton();
void init( pigpio::bcm_t bcmNo ); void init( pigpio::bcm_t bcmNo );
void change_state( bool newState ) override; void change_state( bool newState ) override;
protected: protected:
virtual void trigger( pigpio::bcm_t bcm, uint32_t level ) override; virtual void trigger( pigpio::bcm_t bcm, uint32_t level ) override;
}; };
#endif // PIGBUTTON_H #endif // PIGBUTTON_H

View File

@@ -1,65 +1,65 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <pigbuzzer.h> #include <pigbuzzer.h>
#include <pignodeout.h> #include <pignodeout.h>
#include <pigstate.h> #include <pigstate.h>
pigBuzzer::pigBuzzer( bcm_t bcmNo ) pigBuzzer::pigBuzzer( bcm_t bcmNo )
: pigNodeOut( bcmNo , pull_off ) : pigNodeOut( bcmNo , pull_off )
{ {
} }
pigBuzzer::~pigBuzzer() pigBuzzer::~pigBuzzer()
{ {
} }
void pigBuzzer::buzz( int millisOn, int millisOff ) void pigBuzzer::buzz( int millisOn, int millisOff )
{ {
/* /*
std::thread thrd( std::thread thrd(
[=]() [=]()
{ {
_pinOut.set_level( high ); _pinOut.set_level( high );
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) ); std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
_pinOut.set_level( low ); _pinOut.set_level( low );
if( millisOff ) if( millisOff )
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) ); std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
} ); } );
thrd.detach(); thrd.detach();
*/ */
_pinOut.set_level( high ); _pinOut.set_level( high );
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) ); std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
_pinOut.set_level( low ); _pinOut.set_level( low );
if( millisOff ) if( millisOff )
std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) ); std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
} }

View File

@@ -1,50 +1,50 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGBUZZER_H #ifndef PIGBUZZER_H
#define PIGBUZZER_H #define PIGBUZZER_H
#include <pignodeout.h> #include <pignodeout.h>
#include <pigstate.h> #include <pigstate.h>
/** /**
* @brief The pigBeeper class * @brief The pigBeeper class
* ein __passiver__ Beeper, muss per PWM angesteuert * ein __passiver__ Beeper, muss per PWM angesteuert
* werden. * werden.
*/ */
class LIBPIGPIO_EXPORT pigBuzzer : public pigNodeOut class LIBPIGPIO_EXPORT pigBuzzer : public pigNodeOut
{ {
public: public:
explicit pigBuzzer( pigpio::bcm_t bcmNo ); explicit pigBuzzer( pigpio::bcm_t bcmNo );
virtual ~pigBuzzer(); virtual ~pigBuzzer();
void buzz( int millisOn, int millisOff = 0 ); void buzz( int millisOn, int millisOff = 0 );
}; };
#endif // PIGBUZZER_H #endif // PIGBUZZER_H

View File

@@ -1,22 +1,22 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/

View File

@@ -1,37 +1,37 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGCALL_H #ifndef PIGCALL_H
#define PIGCALL_H #define PIGCALL_H
#include <libpigpio.h> #include <libpigpio.h>
class pigCall class pigCall
{ {
public: public:
virtual void trigger( pigpio::bcm_t, uint32_t ) = 0; virtual void trigger( pigpio::bcm_t, uint32_t ) = 0;
}; };
#endif // PIGCALL_H #endif // PIGCALL_H

View File

@@ -1,49 +1,49 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <pigchrono.h> #include <pigchrono.h>
//using namespace std::chrono; //using namespace std::chrono;
pigChrono::pigChrono() pigChrono::pigChrono()
: _beg{ _clock::now() } : _beg{ _clock::now() }
{ {
} }
void pigChrono::start() void pigChrono::start()
{ {
_beg = _clock::now(); _beg = _clock::now();
} }
double pigChrono::elapsed_millis() const double pigChrono::elapsed_millis() const
{ {
return (double) duration_cast<milliseconds>( _clock::now() - _beg ).count() ; return (double) duration_cast<milliseconds>( _clock::now() - _beg ).count() ;
} }
double pigChrono::elapsed_micros() const double pigChrono::elapsed_micros() const
{ {
return (double) duration_cast<microseconds>( _clock::now() - _beg ).count() ; return (double) duration_cast<microseconds>( _clock::now() - _beg ).count() ;
} }

View File

@@ -1,53 +1,53 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGCHRONO_H #ifndef PIGCHRONO_H
#define PIGCHRONO_H #define PIGCHRONO_H
#include <chrono> #include <chrono>
#include <libpigpio.h> #include <libpigpio.h>
using namespace std; using namespace std;
using namespace chrono; using namespace chrono;
class LIBPIGPIO_EXPORT pigChrono class LIBPIGPIO_EXPORT pigChrono
{ {
public: public:
pigChrono(); pigChrono();
virtual ~pigChrono() = default; virtual ~pigChrono() = default;
void start(); void start();
double elapsed_millis() const; double elapsed_millis() const;
double elapsed_micros() const; double elapsed_micros() const;
protected: protected:
using _clock = high_resolution_clock; using _clock = high_resolution_clock;
time_point<_clock> _beg; time_point<_clock> _beg;
}; };
#endif // PIGCHRONO_H #endif // PIGCHRONO_H

View File

@@ -1,55 +1,55 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <pigi2c.h> #include <pigi2c.h>
pigI2C::pigI2C() pigI2C::pigI2C()
{ {
} }
pigI2C::pigI2C( i2c_addr_t aaddr, i2c_bus_t abus ) pigI2C::pigI2C( i2c_addr_t aaddr, i2c_bus_t abus )
{ {
init( aaddr, abus ); init( aaddr, abus );
} }
pigI2C::~pigI2C() pigI2C::~pigI2C()
{ {
pigpio::i2c_close( *this ); pigpio::i2c_close( *this );
} }
void pigI2C::init( i2c_addr_t aaddr , i2c_bus_t abus ) void pigI2C::init( i2c_addr_t aaddr , i2c_bus_t abus )
{ {
addr = aaddr; addr = aaddr;
bus = abus; bus = abus;
handle = pigpio::i2c_open( *this ); handle = pigpio::i2c_open( *this );
} }
int pigI2C::i2c_write_device( char* buf, unsigned count ) int pigI2C::i2c_write_device( char* buf, unsigned count )
{ {
return pigpio::i2c_write_device( *this, buf, count ); return pigpio::i2c_write_device( *this, buf, count );
} }

102
pigi2c.h
View File

@@ -1,51 +1,51 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGI2C_H #ifndef PIGI2C_H
#define PIGI2C_H #define PIGI2C_H
#include <libpigpio.h> #include <libpigpio.h>
#include <pigi2c.h> #include <pigi2c.h>
using namespace pigpio; using namespace pigpio;
struct LIBPIGPIO_EXPORT pigI2C struct LIBPIGPIO_EXPORT pigI2C
{ {
i2c_addr_t addr = 0; i2c_addr_t addr = 0;
i2c_bus_t bus = 1; i2c_bus_t bus = 1;
uint32_t handle = 0; uint32_t handle = 0;
pigI2C(); pigI2C();
explicit pigI2C( i2c_addr_t, i2c_bus_t = 1 ); explicit pigI2C( i2c_addr_t, i2c_bus_t = 1 );
virtual ~pigI2C(); virtual ~pigI2C();
void init( i2c_addr_t, i2c_bus_t = 1 ); void init( i2c_addr_t, i2c_bus_t = 1 );
int i2c_write_device( char* buf, unsigned count ); int i2c_write_device( char* buf, unsigned count );
//void dump(); //void dump();
}; };
#endif // PIGI2C_H #endif // PIGI2C_H

View File

@@ -1,12 +1,12 @@
#include "pigi2cnode.h" #include "pigi2cnode.h"
pigI2CNode::pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus ) pigI2CNode::pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus )
{ {
init( aaddr, abus ); init( aaddr, abus );
} }
void pigI2CNode::init( i2c_addr_t aaddr, i2c_bus_t abus ) void pigI2CNode::init( i2c_addr_t aaddr, i2c_bus_t abus )
{ {
_i2c.init( aaddr, abus ); _i2c.init( aaddr, abus );
} }

View File

@@ -1,53 +1,53 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGI2CNODE_H #ifndef PIGI2CNODE_H
#define PIGI2CNODE_H #define PIGI2CNODE_H
#include <libpigpio.h> #include <libpigpio.h>
#include <pignode.h> #include <pignode.h>
#include <pigi2c.h> #include <pigi2c.h>
class LIBPIGPIO_EXPORT pigI2CNode : public pigNode class LIBPIGPIO_EXPORT pigI2CNode : public pigNode
{ {
public: public:
pigI2CNode() = default; pigI2CNode() = default;
pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus ); pigI2CNode( i2c_addr_t aaddr, i2c_bus_t abus );
virtual ~pigI2CNode() = default; virtual ~pigI2CNode() = default;
void init( i2c_addr_t aaddr, i2c_bus_t abus ); void init( i2c_addr_t aaddr, i2c_bus_t abus );
protected: protected:
pigI2C _i2c; pigI2C _i2c;
}; };
#endif // PIGI2CNODE_H #endif // PIGI2CNODE_H

View File

@@ -1,182 +1,182 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <piglcd.h> #include <piglcd.h>
pigLCD::pigLCD( i2c_addr_t addr, i2c_bus_t bus ) pigLCD::pigLCD( i2c_addr_t addr, i2c_bus_t bus )
{ {
init( addr, bus ); init( addr, bus );
} }
pigLCD::~pigLCD() pigLCD::~pigLCD()
{ {
reset(); 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 ) 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 ); _i2c.init( addr, bus );
_width = width; _width = width;
_backlight = bl; _backlight = bl;
_RS = (1<<RS); _RS = (1<<RS);
_E = (1<<E); _E = (1<<E);
_BL = (1<<BL); _BL = (1<<BL);
_B4 = B4; _B4 = B4;
put_inst( 0x33 ); // Initialise 1 put_inst( 0x33 ); // Initialise 1
put_inst( 0x32 ); // Initialise 2 put_inst( 0x32 ); // Initialise 2
put_inst( 0x06 ); // Cursor increment put_inst( 0x06 ); // Cursor increment
put_inst( 0x0C ); // Display on,move_to off, blink off put_inst( 0x0C ); // Display on,move_to off, blink off
put_inst( 0x28 ); // 4-bits, 1 line, 5x8 font put_inst( 0x28 ); // 4-bits, 1 line, 5x8 font
put_inst( 0x01 ); // Clear display put_inst( 0x01 ); // Clear display
//?? move_to( 0,0 ) //?? move_to( 0,0 )
put_inst( _LCD_ROW[0]+0 ); put_inst( _LCD_ROW[0]+0 );
} }
/** /**
* @brief pigLCD::close * @brief pigLCD::close
* Close the LCD (clearing the screen) and release used resources. * Close the LCD (clearing the screen) and release used resources.
*/ */
void pigLCD::reset() void pigLCD::reset()
{ {
put_inst( 0x01 ); // Clear display put_inst( 0x01 ); // Clear display
set_backlight( false ); set_backlight( false );
} }
/** /**
* @brief pigLCD::set_backlight * @brief pigLCD::set_backlight
* @param bl * @param bl
* toogle backlight on or off. * toogle backlight on or off.
*/ */
void pigLCD::set_backlight( bool bl ) void pigLCD::set_backlight( bool bl )
{ {
_backlight = bl; _backlight = bl;
// hack // hack
move_to( 0, 0 ); move_to( 0, 0 );
} }
/** /**
* @brief pigLCD::move_to * @brief pigLCD::move_to
* @param row * @param row
* @param col * @param col
* *
* Position cursor at row and column (0 based). * Position cursor at row and column (0 based).
*/ */
void pigLCD::move_to( int row, int col ) void pigLCD::move_to( int row, int col )
{ {
put_inst( _LCD_ROW[row]+col ); put_inst( _LCD_ROW[row]+col );
} }
/** /**
* @brief pigLCD::write * @brief pigLCD::write
* @param c * @param c
* Write a character at the current cursor postion and * Write a character at the current cursor postion and
* increment the cursor. * increment the cursor.
*/ */
void pigLCD::write( const char c ) void pigLCD::write( const char c )
{ {
put_data( (uint8_t) c ); put_data( (uint8_t) c );
} }
void pigLCD::write( const std::string text ) void pigLCD::write( const std::string text )
{ {
for( const char c : text ) for( const char c : text )
write( c ); write( c );
} }
void pigLCD::write( int row, int col, const std::string text ) void pigLCD::write( int row, int col, const std::string text )
{ {
move_to( row, col ); move_to( row, col );
write( text ); write( text );
} }
void pigLCD::put_byte( uint8_t MSb, uint8_t LSb ) void pigLCD::put_byte( uint8_t MSb, uint8_t LSb )
{ {
if( _backlight ) if( _backlight )
{ {
MSb |= _BL; MSb |= _BL;
LSb |= _BL; LSb |= _BL;
} }
char buf[4]; char buf[4];
buf[0] = (char) MSb | _E; buf[0] = (char) MSb | _E;
buf[1] = (char) MSb & ~_E; buf[1] = (char) MSb & ~_E;
buf[2] = (char) LSb | _E; buf[2] = (char) LSb | _E;
buf[3] = LSb & ~_E; buf[3] = LSb & ~_E;
_i2c.i2c_write_device( buf, 4 ); _i2c.i2c_write_device( buf, 4 );
// self.pi.i2c_write_device(self._h, // self.pi.i2c_write_device(self._h,
// [MSb | self.E, MSb & ~self.E, LSb | self.E, LSb & ~self.E]) */ // [MSb | self.E, MSb & ~self.E, LSb | self.E, LSb & ~self.E]) */
} }
void pigLCD::put_inst( uint8_t bits ) void pigLCD::put_inst( uint8_t bits )
{ {
uint8_t MSN = (bits>>4) & 0x0F; uint8_t MSN = (bits>>4) & 0x0F;
uint8_t LSN = bits & 0x0F; uint8_t LSN = bits & 0x0F;
uint8_t MSb = MSN << _B4; uint8_t MSb = MSN << _B4;
uint8_t LSb = LSN << _B4; uint8_t LSb = LSN << _B4;
put_byte( MSb, LSb ); put_byte( MSb, LSb );
} }
void pigLCD::put_data( uint8_t bits ) void pigLCD::put_data( uint8_t bits )
{ {
uint8_t MSN = (bits>>4) & 0x0F; uint8_t MSN = (bits>>4) & 0x0F;
uint8_t LSN = bits & 0x0F; uint8_t LSN = bits & 0x0F;
uint8_t MSb = (MSN << _B4) | _RS; uint8_t MSb = (MSN << _B4) | _RS;
uint8_t LSb = (LSN << _B4) | _RS; uint8_t LSb = (LSN << _B4) | _RS;
put_byte( MSb, LSb ); put_byte( MSb, LSb );
} }

330
piglcd.h
View File

@@ -1,165 +1,165 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGLCD_H #ifndef PIGLCD_H
#define PIGLCD_H #define PIGLCD_H
//#include <unistd.h> //#include <unistd.h>
//#include <inttypes.h> //#include <inttypes.h>
#include <pigi2cnode.h> #include <pigi2cnode.h>
/* /*
""" """
This class provides simple functions to display text on an I2C LCD This class provides simple functions to display text on an I2C LCD
based on the PCF8574T I2C 8-bit port expander. based on the PCF8574T I2C 8-bit port expander.
PCF8574T P7 P6 P5 P4 P3 P2 P1 P0 PCF8574T P7 P6 P5 P4 P3 P2 P1 P0
HD44780 B7 B6 B5 B4 BL E RW RS HD44780 B7 B6 B5 B4 BL E RW RS
This code defaults to working with an adapter with the above This code defaults to working with an adapter with the above
configuration. configuration.
If yours is different you will have to specify the mapping If yours is different you will have to specify the mapping
when you instantiate the LCD. when you instantiate the LCD.
""" """
""" """
Commands Commands
LCD_CLEARDISPLAY = 0x01 LCD_CLEARDISPLAY = 0x01
LCD_RETURNHOME = 0x02 LCD_RETURNHOME = 0x02
LCD_ENTRYMODESET = 0x04 LCD_ENTRYMODESET = 0x04
LCD_DISPLAYCONTROL = 0x08 LCD_DISPLAYCONTROL = 0x08
LCD_CURSORSHIFT = 0x10 LCD_CURSORSHIFT = 0x10
LCD_FUNCTIONSET = 0x20 LCD_FUNCTIONSET = 0x20
LCD_SETCGRAMADDR = 0x40 LCD_SETCGRAMADDR = 0x40
LCD_SETDDRAMADDR = 0x80 LCD_SETDDRAMADDR = 0x80
Flags for display entry mode Flags for display entry mode
LCD_ENTRYRIGHT = 0x00 LCD_ENTRYRIGHT = 0x00
LCD_ENTRYLEFT = 0x02 LCD_ENTRYLEFT = 0x02
LCD_ENTRYSHIFTINCREMENT = 0x01 LCD_ENTRYSHIFTINCREMENT = 0x01
LCD_ENTRYSHIFTDECREMENT = 0x00 LCD_ENTRYSHIFTDECREMENT = 0x00
Flags for display on/off control Flags for display on/off control
LCD_DISPLAYON = 0x04 LCD_DISPLAYON = 0x04
LCD_DISPLAYOFF = 0x00 LCD_DISPLAYOFF = 0x00
LCD_CURSORON = 0x02 LCD_CURSORON = 0x02
LCD_CURSOROFF = 0x00 LCD_CURSOROFF = 0x00
LCD_BLINKON = 0x01 LCD_BLINKON = 0x01
LCD_BLINKOFF = 0x00 LCD_BLINKOFF = 0x00
Flags for display/cursor shift Flags for display/cursor shift
LCD_DISPLAYMOVE = 0x08 LCD_DISPLAYMOVE = 0x08
LCD_CURSORMOVE = 0x00 LCD_CURSORMOVE = 0x00
LCD_MOVERIGHT = 0x04 LCD_MOVERIGHT = 0x04
LCD_MOVELEFT = 0x00 LCD_MOVELEFT = 0x00
Flags for function set Flags for function set
LCD_8BITMODE = 0x10 LCD_8BITMODE = 0x10
LCD_4BITMODE = 0x00 LCD_4BITMODE = 0x00
LCD_2LINE = 0x08 LCD_2LINE = 0x08
LCD_1LINE = 0x00 LCD_1LINE = 0x00
LCD_5x10DOTS = 0x04 LCD_5x10DOTS = 0x04
LCD_5x8DOTS = 0x00 LCD_5x8DOTS = 0x00
Flags for backlight control Flags for backlight control
LCD_BACKLIGHT = 0x08 LCD_BACKLIGHT = 0x08
LCD_NOBACKLIGHT = 0x00 LCD_NOBACKLIGHT = 0x00
""" """
*/ */
/** /**
* @brief The pigLCD class für //HD44780 * @brief The pigLCD class für //HD44780
* Back-Port von python, siehe: https://abyz.me.uk/rpi/pigpio/code/i2c_lcd_py.zip * Back-Port von python, siehe: https://abyz.me.uk/rpi/pigpio/code/i2c_lcd_py.zip
* *
*/ */
class pigLCD : public pigI2CNode class pigLCD : public pigI2CNode
{ {
//HD44780 //HD44780
public: public:
pigLCD() = default; pigLCD() = default;
pigLCD( i2c_addr_t addr, i2c_bus_t bus = 1 ); pigLCD( i2c_addr_t addr, i2c_bus_t bus = 1 );
virtual ~pigLCD(); virtual ~pigLCD();
void init( i2c_addr_t addr, i2c_bus_t bus=1, int width=16, bool bl=true, 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 ); 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 set_backlight( bool bl );
void move_to( int row, int col ); void move_to( int row, int col );
void write( const char c ); void write( const char c );
void write( const std::string text ); void write( const std::string text );
void write( int row, int col, const std::string text ); void write( int row, int col, const std::string text );
// inwieweit notwendig? // inwieweit notwendig?
void reset(); void reset();
protected: protected:
void put_byte( uint8_t MSb, uint8_t LSb ); void put_byte( uint8_t MSb, uint8_t LSb );
void put_inst( uint8_t bits ); void put_inst( uint8_t bits );
void put_data( uint8_t bits ); void put_data( uint8_t bits );
uint8_t _LCD_ROW[4] = { 0x80, 0xC0, 0x94, 0xD4 }; uint8_t _LCD_ROW[4] = { 0x80, 0xC0, 0x94, 0xD4 };
bool _backlight = false; bool _backlight = false;
int _width = 16; int _width = 16;
//?? Type? //?? Type?
uint8_t _RS; uint8_t _RS;
uint8_t _E; uint8_t _E;
uint8_t _BL; uint8_t _BL;
uint8_t _B4; uint8_t _B4;
/* /*
// GPIO chip i2c address // GPIO chip i2c address
uint8_t i2c=0x27; uint8_t i2c=0x27;
// Control line PINs // Control line PINs
uint8_t en=2; uint8_t en=2;
uint8_t rw=1; uint8_t rw=1;
uint8_t rs=0; uint8_t rs=0;
// Data line PINs // Data line PINs
uint8_t d4=4; uint8_t d4=4;
uint8_t d5=5; uint8_t d5=5;
uint8_t d6=6; uint8_t d6=6;
uint8_t d7=7; uint8_t d7=7;
// Backlight PIN // Backlight PIN
uint8_t bl=3; uint8_t bl=3;
// LCD display size (1x16, 2x16, 4x20) // LCD display size (1x16, 2x16, 4x20)
uint8_t rows=2; uint8_t rows=2;
uint8_t cols=16; uint8_t cols=16;
*/ */
}; };
#endif // PIGLCD_H #endif // PIGLCD_H

View File

@@ -1,59 +1,59 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <pigled.h> #include <pigled.h>
#include <pignodeout.h> #include <pignodeout.h>
#include <pigstate.h> #include <pigstate.h>
pigLED::pigLED( bcm_t bcmNo ) pigLED::pigLED( bcm_t bcmNo )
: pigNodeOut( bcmNo , pull_off ) : pigNodeOut( bcmNo , pull_off )
{ {
} }
pigLED::~pigLED() pigLED::~pigLED()
{ {
} }
void pigLED::blink( int millisOn, int millisOff ) void pigLED::blink( int millisOn, int millisOff )
{ {
if( !millisOff ) if( !millisOff )
millisOff = millisOn; millisOff = millisOn;
std::thread thrd( std::thread thrd(
[=]() [=]()
{ {
_pinOut.set_level( high ); _pinOut.set_level( high );
std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) ); std::this_thread::sleep_for( std::chrono::milliseconds( millisOn ) );
_pinOut.set_level( low ); _pinOut.set_level( low );
//std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) ); //std::this_thread::sleep_for( std::chrono::milliseconds( millisOff ) );
} ); } );
thrd.detach(); thrd.detach();
} }

100
pigled.h
View File

@@ -1,50 +1,50 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGLED_H #ifndef PIGLED_H
#define PIGLED_H #define PIGLED_H
#include <pignodeout.h> #include <pignodeout.h>
#include <pigstate.h> #include <pigstate.h>
/** /**
* @brief The pigBeeper class * @brief The pigBeeper class
* ein __passiver__ Beeper, muss per PWM angesteuert * ein __passiver__ Beeper, muss per PWM angesteuert
* werden. * werden.
*/ */
class LIBPIGPIO_EXPORT pigLED : public pigNodeOut class LIBPIGPIO_EXPORT pigLED : public pigNodeOut
{ {
public: public:
explicit pigLED( pigpio::bcm_t bcmNo ); explicit pigLED( pigpio::bcm_t bcmNo );
virtual ~pigLED(); virtual ~pigLED();
void blink( int millisOn, int millisOff = 0 ); void blink( int millisOn, int millisOff = 0 );
}; };
#endif // PIGLED_H #endif // PIGLED_H

View File

@@ -1,41 +1,41 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <pignode.h> #include <pignode.h>
/** /**
* @brief Maa im Footer pigNode::pigNode * @brief Maa im Footer pigNode::pigNode
*/ */
pigNode::pigNode() pigNode::pigNode()
{ {
} }
pigNode::~pigNode() pigNode::~pigNode()
{ {
} }

View File

@@ -1,49 +1,49 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGNODE_H #ifndef PIGNODE_H
#define PIGNODE_H #define PIGNODE_H
#include <pigcall.h> #include <pigcall.h>
#include <libpigpio.h> #include <libpigpio.h>
/** /**
* @brief im HEADER The pigNode class * @brief im HEADER The pigNode class
*/ */
class pigNode class pigNode
{ {
public: public:
pigNode(); pigNode();
virtual ~pigNode(); virtual ~pigNode();
}; };
#endif // PIGNODE_H #endif // PIGNODE_H

View File

@@ -1,25 +1,25 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <pignodein.h> #include <pignodein.h>

View File

@@ -1,50 +1,50 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGNODEIN_H #ifndef PIGNODEIN_H
#define PIGNODEIN_H #define PIGNODEIN_H
#include <pignode.h> #include <pignode.h>
#include <pigcall.h> #include <pigcall.h>
#include <pigstate.h> #include <pigstate.h>
#include <pigpin.h> #include <pigpin.h>
/** /**
* @brief im HEADER The pigNode class * @brief im HEADER The pigNode class
*/ */
class LIBPIGPIO_EXPORT pigNodeIn : public pigNode, public pigCall, public pigState class LIBPIGPIO_EXPORT pigNodeIn : public pigNode, public pigCall, public pigState
{ {
public: public:
pigNodeIn() = default; pigNodeIn() = default;
virtual ~pigNodeIn() = default; virtual ~pigNodeIn() = default;
protected: protected:
pigPinIn _pinIn; pigPinIn _pinIn;
}; };
#endif // PIGNODEIN_H #endif // PIGNODEIN_H

View File

@@ -1,48 +1,48 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <pignodeout.h> #include <pignodeout.h>
pigNodeOut::pigNodeOut( bcm_t bcmNo, pigpio::pud_t pud ) pigNodeOut::pigNodeOut( bcm_t bcmNo, pigpio::pud_t pud )
: _pinOut( bcmNo, pud ) : _pinOut( bcmNo, pud )
{ {
} }
pigNodeOut::~pigNodeOut() pigNodeOut::~pigNodeOut()
{ {
} }
void pigNodeOut::change_state( bool newState ) void pigNodeOut::change_state( bool newState )
{ {
if( newState == state() ) if( newState == state() )
return; return;
set_state( newState ); set_state( newState );
//sigState( _state ); //sigState( _state );
_pinOut.set_level( _state ); _pinOut.set_level( _state );
} }

View File

@@ -1,57 +1,57 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGNODEOUT_H #ifndef PIGNODEOUT_H
#define PIGNODEOUT_H #define PIGNODEOUT_H
#include <pignode.h> #include <pignode.h>
#include <pigstate.h> #include <pigstate.h>
#include <pigpin.h> #include <pigpin.h>
/** /**
* @brief Eine Signal Senke aka receiver, drain, * @brief Eine Signal Senke aka receiver, drain,
* _empfängt_ status änderungen * _empfängt_ status änderungen
* ein _aktiver_ Buzzer, nur an/aus, keine PWM, oder eben eine LED * ein _aktiver_ Buzzer, nur an/aus, keine PWM, oder eben eine LED
* werden. * werden.
*/ */
class LIBPIGPIO_EXPORT pigNodeOut : public pigNode, public pigState class LIBPIGPIO_EXPORT pigNodeOut : public pigNode, public pigState
{ {
public: public:
explicit pigNodeOut( pigpio::bcm_t bcmNo, pigpio::pud_t pud = pigpio::pull_off ); explicit pigNodeOut( pigpio::bcm_t bcmNo, pigpio::pud_t pud = pigpio::pull_off );
virtual ~pigNodeOut(); virtual ~pigNodeOut();
void change_state( bool newState ) override; void change_state( bool newState ) override;
protected: protected:
pigPinOut _pinOut; pigPinOut _pinOut;
}; };
#endif // PIGNODEOUT_H #endif // PIGNODEOUT_H

View File

@@ -1,182 +1,179 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <pigpin.h> #include <pigpin.h>
#include <libpigcore.h> #include <libpigcore.h>
//using namespace pigpio; pigPin::pigPin( bcm_t bcmNo, io_t modeNo, pud_t pudType )
{
init( bcmNo, modeNo, pudType );
pigPin::pigPin( bcm_t bcmNo, io_t modeNo, pud_t pudType ) }
{
init( bcmNo, modeNo, pudType );
} pigPin::~pigPin()
{
pigPin::~pigPin() }
{
} void pigPin::init( bcm_t bcmNo, io_t modeNo, pud_t pudType )
{
bcm = bcmNo;
void pigPin::init( bcm_t bcmNo, io_t modeNo, pud_t pudType ) set_io_mode( modeNo );
{ set_pud_mode( pudType );
bcm = bcmNo; }
set_io_mode( modeNo );
set_pud_mode( pudType );
} int pigPin::get_level()
{
return pigpio::get_level( bcm );
int pigPin::get_level() }
{
return pigpio::get_level( bcm );
} void pigPin::set_level( level_t level )
{
pigpio::set_level( bcm, level );
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::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 );
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 )
{
// pin config mode = modType;
int pigPin::set_io_mode( io_t modType ) return pigpio::set_io_mode( bcm, mode );
{ }
mode = modType;
return pigpio::set_io_mode( bcm, mode );
} int pigPin::get_io_mode()
{
return pigpio::get_io_mode( bcm );
int pigPin::get_io_mode() }
{
return pigpio::get_io_mode( bcm );
} int pigPin::set_pud_mode( pud_t pudType )
{
pud = pudType;
int pigPin::set_pud_mode( pud_t pudType ) return pigpio::set_pud_mode( bcm, pud );
{ }
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_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 );
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 )
{
// reality interface return pigpio::set_callback( bcm, fn, edge);
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 );
int pigPin::cancel_callback( int cbId ) }
{
return pigpio::cancel_callback( cbId );
} void pigPin::dump()
{
std::cout << "\nPin: " << (uint32_t) bcm << " " << std::endl;
void pigPin::dump() std::cout << "Mode: " << (uint32_t) mode << " " << std::endl;
{ std::cout << "Pud: " << (uint32_t) pud << " " << std::endl;
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() }
{
mode = pigpio::input;
} pigPinIn::pigPinIn( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
: pigPin{ bcmNo, pigpio::input, pudType }
{
pigPinIn::pigPinIn( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
: pigPin{ bcmNo, pigpio::input, pudType }
{ }
} pigPinIn::~pigPinIn()
{
if( cbId > -1 )
pigPinIn::~pigPinIn() pigpio::cancel_callback( cbId );
{ }
if( cbId > -1 )
pigpio::cancel_callback( cbId ); void pigPinIn::init( bcm_t bcmNo, pud_t pudType )
} {
pigPin::init( bcmNo, pigpio::input, pudType );
void pigPinIn::init( bcm_t bcmNo, pud_t pudType ) }
{
pigPin::init( bcmNo, pigpio::input, pudType );
} /// ---
/// --- pigPinOut::pigPinOut()
{
mode = pigpio::output;
pigPinOut::pigPinOut() }
{
mode = pigpio::output;
} pigPinOut::pigPinOut( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
: pigPin{ bcmNo, pigpio::output, pudType }
{
pigPinOut::pigPinOut( pigpio::bcm_t bcmNo, pigpio::pud_t pudType )
: pigPin{ bcmNo, pigpio::output, pudType } }
{
} pigPinOut::~pigPinOut()
{
pigPinOut::~pigPinOut() }
{
void pigPinOut::init( bcm_t bcmNo, pud_t pudType )
} {
pigPin::init( bcmNo, pigpio::output, pudType );
void pigPinOut::init( bcm_t bcmNo, pud_t pudType ) }
{
pigPin::init( bcmNo, pigpio::output, pudType );
}

184
pigpin.h
View File

@@ -1,92 +1,92 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGPIN_H #ifndef PIGPIN_H
#define PIGPIN_H #define PIGPIN_H
#include <libpigpio.h> #include <libpigpio.h>
using namespace pigpio; using namespace pigpio;
//class pigCall; //class pigCall;
struct LIBPIGPIO_EXPORT pigPin struct LIBPIGPIO_EXPORT pigPin
{ {
bcm_t bcm = bcm_t::bcm_off; bcm_t bcm = bcm_t::bcm_off;
io_t mode = io_t::io_off; io_t mode = io_t::io_off;
pud_t pud = pud_t::pull_off; pud_t pud = pud_t::pull_off;
int cbId = -1; int cbId = -1;
pigPin() = default; pigPin() = default;
explicit pigPin( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off ); explicit pigPin( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off );
virtual ~pigPin(); virtual ~pigPin();
// delete copy/assign const? // delete copy/assign const?
void init( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off ); void init( bcm_t bcmNo, io_t modType, pud_t pudType = pull_off );
virtual void dump(); virtual void dump();
// pin operations // pin operations
int get_level(); int get_level();
void set_level( level_t level ); void set_level( level_t level );
int trigger_level( level_t level, uint32_t pulseLen ); int trigger_level( level_t level, uint32_t pulseLen );
int wait_for_edge( edge_t edge, double timeout = TimeoutDef ); int wait_for_edge( edge_t edge, double timeout = TimeoutDef );
// pin config // pin config
int set_io_mode( io_t modType ); int set_io_mode( io_t modType );
int get_io_mode(); int get_io_mode();
int set_pud_mode( pud_t pudType ); int set_pud_mode( pud_t pudType );
int set_glitch_filter( uint32_t glitch = GlitchDef ); int set_glitch_filter( uint32_t glitch = GlitchDef );
int set_noise_filter( uint32_t steady, uint32_t active ); int set_noise_filter( uint32_t steady, uint32_t active );
// reality interface // reality interface
int set_callback( pigCall* fn, edge_t = either ); int set_callback( pigCall* fn, edge_t = either );
int cancel_callback( int cbId ); int cancel_callback( int cbId );
}; };
struct LIBPIGPIO_EXPORT pigPinIn : public pigPin struct LIBPIGPIO_EXPORT pigPinIn : public pigPin
{ {
pigPinIn(); pigPinIn();
pigPinIn( bcm_t bcmNo, pud_t pudType = pull_off ); pigPinIn( bcm_t bcmNo, pud_t pudType = pull_off );
virtual ~pigPinIn(); virtual ~pigPinIn();
void init( bcm_t bcmNo, pud_t pudType = pull_off ); void init( bcm_t bcmNo, pud_t pudType = pull_off );
}; };
struct LIBPIGPIO_EXPORT pigPinOut : public pigPin struct LIBPIGPIO_EXPORT pigPinOut : public pigPin
{ {
pigPinOut(); pigPinOut();
pigPinOut( pigpio::bcm_t bcmNo, pud_t pudType = pull_off ); pigPinOut( pigpio::bcm_t bcmNo, pud_t pudType = pull_off );
virtual ~pigPinOut(); virtual ~pigPinOut();
void init( bcm_t bcmNo, pud_t pudType = pull_off ); void init( bcm_t bcmNo, pud_t pudType = pull_off );
}; };
#endif // PIGPIN_H #endif // PIGPIN_H

View File

@@ -1,129 +1,118 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <pigrotarydial.h> #include <pigrotarydial.h>
/** /**
+---------+ +---------+ 0 +---------+ +---------+ 0
| | | | | | | |
A | | | | A | | | |
| | | | | | | |
+---------+ +---------+ +----- 1 +---------+ +---------+ +----- 1
+---------+ +---------+ 0 +---------+ +---------+ 0
| | | | | | | |
B | | | | B | | | |
| | | | | | | |
----+ +---------+ +---------+ 1 ----+ +---------+ +---------+ 1
*/ */
pigRotaryDial::pigRotaryDial() pigRotaryDial::pigRotaryDial()
{ {
} }
pigRotaryDial::pigRotaryDial( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown ) pigRotaryDial::pigRotaryDial( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
{ {
init( bcmButton, bcmDown, bcmUp ); init( bcmButton, bcmUp, bcmDown );
} }
pigRotaryDial::~pigRotaryDial() pigRotaryDial::~pigRotaryDial()
{ {
} }
void pigRotaryDial::init( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown ) void pigRotaryDial::init( pigpio::bcm_t bcmButton, pigpio::bcm_t bcmUp, pigpio::bcm_t bcmDown )
{ {
pigButton::init( bcmButton ); pigButton::init( bcmButton );
/*
_pinButton.init( bcmButton, pull_up ); _pinUp.init( bcmUp, pull_up );
_pinButton.set_callback( this, falling ); _pinUp.set_callback( this );
_pinButton.set_glitch_filter( 500 ); _pinUp.set_glitch_filter( 1000 );
*/
_pinDown.init( bcmDown, pull_up );
_pinUp.init( bcmUp, pull_up ); _pinDown.set_callback( this );
_pinUp.set_callback( this ); _pinDown.set_glitch_filter( 1000 );
_pinUp.set_glitch_filter( 500 );
_oldState = ( _pinUp.get_level() << 1 ) | _pinDown.get_level();
_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::reset()
{
_state = false;
_value = 0; void pigRotaryDial::trigger( pigpio::bcm_t bcm, uint32_t level )
} {
if( level == pigpio::TimeOut )
return;
void pigRotaryDial::trigger( pigpio::bcm_t bcm, uint32_t level ) if( bcm ==_pinIn.bcm )
{ {
// simply on/off
//std::cout << " -- pigRotaryDial::trigger: " << (uint32_t) bcm << " : " << level << std::endl; toggle_state();
return;
if( level == pigpio::TimeOut ) }
return;
if( bcm ==_pinUp.bcm )
if( bcm ==_pinIn.bcm ) _levUp = level;
{ else
//std::cout << "pigButton::trigger " << (uint32_t) bcm << " : " << level << std::endl; _levDown = level;
// simply on/off
toggle_state(); int newState = _levUp << 1 | _levDown;
return; int inc = Transits[ _oldState << 2 | newState ];
}
if( inc )
if( bcm ==_pinUp.bcm ) {
_levUp = level; _oldState = newState;
else //int detent = _value / 4;
_levDown = level; _value += inc;
int newState = _levUp << 1 | _levDown; //if( detent != ( _step / 4) )
int inc = Transits[ _oldState << 2 | newState ]; // handlePulse( _step / 4 );
//handlePulse( _step );
if( inc )
{ sigValue( _value );
//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 );
}
}

View File

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

View File

@@ -1,215 +1,215 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
pigSonar based on: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C- pigSonar based on: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
***************************************************************************/ ***************************************************************************/
#include <pigsonar.h> #include <pigsonar.h>
#include <iostream> #include <iostream>
/** /**
* @brief pigSonar::pigSonar * @brief pigSonar::pigSonar
* *
* *
* Beschreibung HC-SR04: * Beschreibung HC-SR04:
* Das Ultraschall Modul HC-SR04 eignet sich zur * Das Ultraschall Modul HC-SR04 eignet sich zur
* Entfernungsmessung im Bereich zwischen 2cm und ca. * Entfernungsmessung im Bereich zwischen 2cm und ca.
* 3m mit einer Auflösung von 3mm. Es benötigt nur eine * 3m mit einer Auflösung von 3mm. Es benötigt nur eine
* einfache Versorgungsspannung von 5V bei einer * einfache Versorgungsspannung von 5V bei einer
* Stromaufnahme von <2mA. Nach Triggerung mit einer * Stromaufnahme von <2mA. Nach Triggerung mit einer
* fallenden Flanke (TTL - Pegel) misst das Modul * fallenden Flanke (TTL - Pegel) misst das Modul
* selbstständig die Entfernung und wandelt diese in ein * selbstständig die Entfernung und wandelt diese in ein
* PWM Signal welches am Ausgang zur Verfügung steht. * PWM Signal welches am Ausgang zur Verfügung steht.
* Ein Messintervall hat eine Dauer von 20ms. Es können * Ein Messintervall hat eine Dauer von 20ms. Es können
* also 50 Messungen pro Sekunde durchgeführt werden * also 50 Messungen pro Sekunde durchgeführt werden
* *
* https://www.mikrocontroller.net/attachment/218122/HC-SR04_ultraschallmodul_beschreibung_3.pdf * https://www.mikrocontroller.net/attachment/218122/HC-SR04_ultraschallmodul_beschreibung_3.pdf
*/ */
pigSonar::pigSonar() pigSonar::pigSonar()
{ {
} }
pigSonar::pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo ) pigSonar::pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo )
{ {
init( trigger, echo ); init( trigger, echo );
} }
pigSonar::~pigSonar() pigSonar::~pigSonar()
{ {
//detach_pin( ) //?? doch wg .callback //detach_pin( ) //?? doch wg .callback
} }
void pigSonar::init( pigpio::bcm_t trigger, pigpio::bcm_t echo ) void pigSonar::init( pigpio::bcm_t trigger, pigpio::bcm_t echo )
{ {
_pinEcho.init( echo ); _pinEcho.init( echo );
//_pinEcho.set_callback( this, rising ); //_pinEcho.set_callback( this, rising );
_pinTrig.init( trigger ); _pinTrig.init( trigger );
_pinTrig.set_level( low ); _pinTrig.set_level( low );
delay_millis( 500 ); delay_millis( 500 );
} }
void pigSonar::stop() void pigSonar::stop()
{ {
_active = false; _active = false;
} }
void pigSonar::start( double thresh ) void pigSonar::start( double thresh )
{ {
_active = true; _active = true;
std::thread thrd( std::thread thrd(
[=]() [=]()
{ {
while( _active ) while( _active )
{ {
double dist = distance(); double dist = distance();
if( dist < thresh ) if( dist < thresh )
sigValue( dist ); sigValue( dist );
delay_millis( 50 ); delay_millis( 50 );
} }
} ); } );
thrd.detach(); thrd.detach();
} }
double pigSonar::distance( int timeout ) double pigSonar::distance( int timeout )
{ {
// erholungspause // erholungspause
delay_millis( 10 ); delay_millis( 10 );
// ein 10 ms pulse löst die messung aus // ein 10 ms pulse löst die messung aus
_pinTrig.set_level( high ); _pinTrig.set_level( high );
delay_micros( 10 ); delay_micros( 10 );
_pinTrig.set_level( low ); _pinTrig.set_level( low );
//_timer.start(); //_timer.start();
_now = get_current_tick(); _now = get_current_tick();
// busy waiting ?? // busy waiting ??
while ( _pinEcho.get_level() == low && _timer.elapsed_millis() < timeout ) while ( _pinEcho.get_level() == low && _timer.elapsed_millis() < timeout )
//while ( _pinEcho.get_level() == low ) //while ( _pinEcho.get_level() == low )
; ;
//_timer.start(); //_timer.start();
_now = get_current_tick(); _now = get_current_tick();
while( _pinEcho.get_level() == high ) while( _pinEcho.get_level() == high )
; ;
uint32_t tof = get_current_tick() - _now; uint32_t tof = get_current_tick() - _now;
//double tof = _timer.elapsed_micros(); //double tof = _timer.elapsed_micros();
_dist = 100 * ( ( tof /1000000.0 ) * 340.29 ) / 2; _dist = 100 * ( ( tof /1000000.0 ) * 340.29 ) / 2;
return _dist; return _dist;
} }
/* /*
void pigSonar::trigger( pigpio::bcm_t bcm, uint32_t level ) void pigSonar::trigger( pigpio::bcm_t bcm, uint32_t level )
{ {
double duration = _timer.elapsed_micros(); double duration = _timer.elapsed_micros();
// Convert the time into a distance // Convert the time into a distance
_dist = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343 _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 //double inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135
} }
*/ */
/** /**
Die Variante mit WiringPi ist erheblich genauer. Warum? Timer? Die Variante mit WiringPi ist erheblich genauer. Warum? Timer?
Code: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C- Code: https://github.com/OmarAflak/HC-SR04-Raspberry-Pi-C-
dort: dort:
Distance is 27.4614 cm. Distance is 27.4614 cm.
Distance is 27.4614 cm. Distance is 27.4614 cm.
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.4784 cm. Distance is 27.4784 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.4614 cm.
Distance is 27.4784 cm. Distance is 27.4784 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.4614 cm.
hier (busy wait): hier (busy wait):
distance: 28.21 distance: 28.21
distance: 25.9811 distance: 25.9811
distance: 28.3121 distance: 28.3121
distance: 28.2441 distance: 28.2441
distance: 28.4482 distance: 28.4482
distance: 27.9889 distance: 27.9889
distance: 28.0569 distance: 28.0569
distance: 28.0059 distance: 28.0059
distance: 28.2441 distance: 28.2441
distance: 25.3346 distance: 25.3346
distance: 28.0059 distance: 28.0059
distance: 29.0608 distance: 29.0608
distance: 27.9718 distance: 27.9718
distance: 28.0399 distance: 28.0399
distance: 27.9889 distance: 27.9889
Die eigene Variante _ohne_ busy wating mit callback ist logischerweise Die eigene Variante _ohne_ busy wating mit callback ist logischerweise
auch nicht besser. auch nicht besser.
double Sonar::distance(int timeout) double Sonar::distance(int timeout)
{ {
delay(10); delay(10);
digitalWrite(trigger, HIGH); digitalWrite(trigger, HIGH);
delayMicroseconds(10); delayMicroseconds(10);
digitalWrite(trigger, LOW); digitalWrite(trigger, LOW);
now=micros(); now=micros();
while (digitalRead(echo) == LOW && micros()-now<timeout) while (digitalRead(echo) == LOW && micros()-now<timeout)
; ;
recordPulseLength(); recordPulseLength();
travelTimeUsec = endTimeUsec - startTimeUsec; travelTimeUsec = endTimeUsec - startTimeUsec;
distanceMeters = 100*((travelTimeUsec/1000000.0)*340.29)/2; distanceMeters = 100*((travelTimeUsec/1000000.0)*340.29)/2;
return distanceMeters; return distanceMeters;
} }
void Sonar::recordPulseLength() void Sonar::recordPulseLength()
{ {
startTimeUsec = micros(); startTimeUsec = micros();
while ( digitalRead(echo) == HIGH ) while ( digitalRead(echo) == HIGH )
; ;
endTimeUsec = micros(); endTimeUsec = micros();
} }
*/ */

View File

@@ -1,64 +1,64 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGSONAR_H #ifndef PIGSONAR_H
#define PIGSONAR_H #define PIGSONAR_H
#include <pignode.h> #include <pignode.h>
#include <pigvalue.h> #include <pigvalue.h>
#include <pigpin.h> #include <pigpin.h>
#include <pigchrono.h> #include <pigchrono.h>
#include <pigvalue.h> #include <pigvalue.h>
class LIBPIGPIO_EXPORT pigSonar : public pigNode, public pigValue<double> class LIBPIGPIO_EXPORT pigSonar : public pigNode, public pigValue<double>
{ {
public: public:
pigSonar(); pigSonar();
pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo ); pigSonar( pigpio::bcm_t trigger, pigpio::bcm_t echo );
virtual ~pigSonar(); virtual ~pigSonar();
void init( pigpio::bcm_t trigger, pigpio::bcm_t echo ); void init( pigpio::bcm_t trigger, pigpio::bcm_t echo );
void stop(); void stop();
void start( double thresh = 50000 ); void start( double thresh = 50000 );
double distance( int timeout=10 ); double distance( int timeout=10 );
protected: protected:
pigPinOut _pinTrig; pigPinOut _pinTrig;
pigPinIn _pinEcho; pigPinIn _pinEcho;
pigChrono _timer; pigChrono _timer;
double _dist; double _dist;
uint32_t _now, _lst; uint32_t _now, _lst;
bool _active = false; bool _active = false;
}; };
#endif // PIGSONAR_H #endif // PIGSONAR_H

View File

@@ -1,67 +1,67 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <pigstate.h> #include <pigstate.h>
pigState::pigState( bool state ) pigState::pigState( bool state )
: _state{ state } : _state{ state }
{ {
} }
bool pigState::state() bool pigState::state()
{ {
return _state; return _state;
} }
void pigState::set_state( bool newState ) void pigState::set_state( bool newState )
{ {
_state = newState; _state = newState;
} }
void pigState::toggle_state() void pigState::toggle_state()
{ {
change_state( !state() ); change_state( !state() );
} }
/* /*
void pigState::change_state( bool newState ) void pigState::change_state( bool newState )
{ {
if( newState == state() ) if( newState == state() )
return; return;
set_state( newState ); set_state( newState );
sigState( _state ); sigState( _state );
} }
*/ */
/* /*
void pigState::connect( pigState& listener ) void pigState::connect( pigState& listener )
{ {
sigState.connect( [&](bool state) { listener.change_state( state ); } ); sigState.connect( [&](bool state) { listener.change_state( state ); } );
} }
*/ */

View File

@@ -1,107 +1,107 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGSTATE_H #ifndef PIGSTATE_H
#define PIGSTATE_H #define PIGSTATE_H
#include <libpigpio.h> #include <libpigpio.h>
#include <pigvalue.h> #include <pigvalue.h>
/** /**
* @brief The pigState class * @brief The pigState class
* set_state ist passiv; change_state kann von 'innen' (per Gui) _oder_ von 'aussen' * set_state ist passiv; change_state kann von 'innen' (per Gui) _oder_ von 'aussen'
* (elektrisch) kommen, je nach Zweck der implementierung ... * (elektrisch) kommen, je nach Zweck der implementierung ...
*/ */
class LIBPIGPIO_EXPORT pigState class LIBPIGPIO_EXPORT pigState
{ {
public: public:
signalBool sigState; signalBool sigState;
pigState() = default; pigState() = default;
explicit pigState( bool astate ); explicit pigState( bool astate );
virtual ~pigState() = default; virtual ~pigState() = default;
bool state(); bool state();
virtual void set_state( bool newState ); virtual void set_state( bool newState );
void toggle_state(); void toggle_state();
// passiv (empfänger) oder aktiv (sender): // passiv (empfänger) oder aktiv (sender):
// die implemetierung entscheidet // die implemetierung entscheidet
virtual void change_state( bool newState ) = 0; virtual void change_state( bool newState ) = 0;
template< typename T > template< typename T >
void connect_state( T& listener ) void connect_state( T& listener )
{ {
//sigState.connect( [&](bool state) { T::change_state( state ); } ); //sigState.connect( [&](bool state) { T::change_state( state ); } );
sigState.connect( &T::change_state, &listener ); sigState.connect( &T::change_state, &listener );
} }
protected: protected:
bool _state = false; bool _state = false;
}; };
template< typename V> template< typename V>
class LIBPIGPIO_EXPORT pigRec class LIBPIGPIO_EXPORT pigRec
{ {
public: public:
virtual void change_x( V newValue ) virtual void change_x( V newValue )
{ {
std::cout << "pigRec:" << newValue << std::endl; std::cout << "pigRec:" << newValue << std::endl;
} }
}; };
template< typename V> template< typename V>
class LIBPIGPIO_EXPORT pigFykz class LIBPIGPIO_EXPORT pigFykz
{ {
public: public:
sigslot::signal<V> sigFykz; sigslot::signal<V> sigFykz;
virtual void change_x( V newValue ) virtual void change_x( V newValue )
{ {
std::cout << "pigFykz: " << newValue << std::endl; std::cout << "pigFykz: " << newValue << std::endl;
} }
template< typename T > template< typename T >
void connect_x( T& listener ) void connect_x( T& listener )
{ {
//sigState.connect( [&](bool state) { T::change_state( state ); } ); //sigState.connect( [&](bool state) { T::change_state( state ); } );
sigFykz.connect( &T::change_x, &listener ); sigFykz.connect( &T::change_x, &listener );
} }
}; };
#endif // PIGSTATE_H #endif // PIGSTATE_H

View File

@@ -1,140 +1,140 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <pigtimer.h> #include <pigtimer.h>
pigTimer::pigTimer() pigTimer::pigTimer()
{ {
} }
pigTimer::pigTimer( int timeOn, int timeOff, int repcnt ) pigTimer::pigTimer( int timeOn, int timeOff, int repcnt )
: _timeOn{ timeOn }, _timeOff{ timeOff }, _repcnt{ repcnt } : _timeOn{ timeOn }, _timeOff{ timeOff }, _repcnt{ repcnt }
{ {
if( !_timeOff ) if( !_timeOff )
_timeOff = _timeOn; _timeOff = _timeOn;
} }
pigTimer::~pigTimer() pigTimer::~pigTimer()
{ {
} }
void pigTimer::change_state( bool newState ) void pigTimer::change_state( bool newState )
{ {
set_state( newState ); set_state( newState );
} }
int pigTimer::timeOn() int pigTimer::timeOn()
{ {
return _timeOn; return _timeOn;
} }
void pigTimer::setTimeOn( int timeOn ) void pigTimer::setTimeOn( int timeOn )
{ {
_timeOn = timeOn; _timeOn = timeOn;
// reset?? // reset??
} }
int pigTimer::timeOff() int pigTimer::timeOff()
{ {
return _timeOff; return _timeOff;
} }
void pigTimer::setTimeOff( int timeOff ) void pigTimer::setTimeOff( int timeOff )
{ {
_timeOff = timeOff; _timeOff = timeOff;
} }
int pigTimer::repetitions() int pigTimer::repetitions()
{ {
return _repcnt; return _repcnt;
} }
void pigTimer::setRepetitions( int repcnt ) void pigTimer::setRepetitions( int repcnt )
{ {
_repcnt = repcnt; _repcnt = repcnt;
} }
void pigTimer::start() void pigTimer::start()
{ {
_active = true; _active = true;
// ewig // ewig
if( _repcnt < 1 ) if( _repcnt < 1 )
{ {
while( _active ) while( _active )
sleepCycle(); sleepCycle();
return; return;
} }
// abgezählt // abgezählt
for( int i=0; i<_repcnt; ++i ) for( int i=0; i<_repcnt; ++i )
sleepCycle(); sleepCycle();
} }
void pigTimer::stop() void pigTimer::stop()
{ {
_active = false; _active = false;
} }
void pigTimer::sleepCycle() void pigTimer::sleepCycle()
{ {
sleepThread( _timeOff ); sleepThread( _timeOff );
if( !_active ) if( !_active )
return; return;
sleepThread( _timeOn ); sleepThread( _timeOn );
} }
void pigTimer::sleepThread( int delay ) void pigTimer::sleepThread( int delay )
{ {
std::thread thrd( std::thread thrd(
[=]() [=]()
{ {
if( !_active ) if( !_active )
return; return;
std::this_thread::sleep_for( std::chrono::milliseconds( delay ) ); std::this_thread::sleep_for( std::chrono::milliseconds( delay ) );
toggle_state(); toggle_state();
} ); } );
thrd.detach(); thrd.detach();
} }

View File

@@ -1,68 +1,68 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGTIMER_H #ifndef PIGTIMER_H
#define PIGTIMER_H #define PIGTIMER_H
#include <libpigpio.h> #include <libpigpio.h>
#include <pigstate.h> #include <pigstate.h>
class LIBPIGPIO_EXPORT pigTimer : public pigState class LIBPIGPIO_EXPORT pigTimer : public pigState
{ {
public: public:
pigTimer(); pigTimer();
pigTimer( int timeOn, int timeOff = 0, int repcnt = -1 ); pigTimer( int timeOn, int timeOff = 0, int repcnt = -1 );
virtual ~pigTimer(); virtual ~pigTimer();
void change_state( bool newState ) override; void change_state( bool newState ) override;
int timeOn(); int timeOn();
void setTimeOn( int timeOn ); void setTimeOn( int timeOn );
int timeOff(); int timeOff();
void setTimeOff( int timeOff ); void setTimeOff( int timeOff );
void setRepetitions( int repcnt ); void setRepetitions( int repcnt );
int repetitions(); int repetitions();
void start(); void start();
void stop(); void stop();
protected: protected:
void sleepCycle(); void sleepCycle();
void sleepThread( int delay ); void sleepThread( int delay );
int _timeOn = 0; int _timeOn = 0;
int _timeOff = 0; int _timeOff = 0;
bool _active = false; bool _active = false;
int _repcnt = -1; int _repcnt = -1;
int _count = 0; int _count = 0;
}; };
#endif // PIGTIMER_H #endif // PIGTIMER_H

View File

@@ -1,22 +1,22 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/

View File

@@ -1,84 +1,84 @@
/***************************************************************************** /*****************************************************************************
source::worx libPiGPio source::worx libPiGPio
Copyright © 2022 c.holzheuer Copyright © 2022 c.holzheuer
chris@sourceworx.org chris@sourceworx.org
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
Uses: Uses:
pigpiod_if2 by joan2937, pigpio @ abyz.me.uk pigpiod_if2 by joan2937, pigpio @ abyz.me.uk
https://abyz.me.uk/rpi/pigpio https://abyz.me.uk/rpi/pigpio
sigslot by 2017 Pierre-Antoine Lacaze sigslot by 2017 Pierre-Antoine Lacaze
https://github.com/palacaze/sigslot https://github.com/palacaze/sigslot
***************************************************************************/ ***************************************************************************/
#ifndef PIGVALUE_H #ifndef PIGVALUE_H
#define PIGVALUE_H #define PIGVALUE_H
#include <libpigpio.h> #include <libpigpio.h>
//class rangeVal //class rangeVal
template<class T> template<class T>
class LIBPIGPIO_EXPORT pigValue class LIBPIGPIO_EXPORT pigValue
{ {
public: public:
sigslot::signal<T> sigValue; sigslot::signal<T> sigValue;
pigValue() = default; pigValue() = default;
pigValue( T val ) pigValue( T val )
: _value( val ) : _value( val )
{ {
} }
virtual ~pigValue() = default; virtual ~pigValue() = default;
T value() T value()
{ {
return _value; return _value;
} }
void set_value( T value ) void set_value( T value )
{ {
_value = value; _value = value;
} }
void change_value( T value ) void change_value( T value )
{ {
set_value( value ); set_value( value );
// emit ... // emit ...
} }
template< typename V > template< typename V >
void connect_value( V& listener ) void connect_value( V& listener )
{ {
//sigState.connect( [&](bool state) { T::change_state( state ); } ); //sigState.connect( [&](bool state) { T::change_state( state ); } );
sigValue.connect( &V::change_value, &listener ); sigValue.connect( &V::change_value, &listener );
} }
/* /*
template< typename O > template< typename O >
void add_value_observer( O* target ) void add_value_observer( O* target )
{ {
signal.connect( &O::on_value_changed, target ); signal.connect( &O::on_value_changed, target );
} }
*/ */
protected: protected:
T _value = T(); T _value = T();
}; };
#endif // PIGVALUE_H #endif // PIGVALUE_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,105 +1,105 @@
/******************************************************************************** /********************************************************************************
** Form generated from reading UI file 'QtGPIOMain.ui' ** Form generated from reading UI file 'QtGPIOMain.ui'
** **
** Created by: Qt User Interface Compiler version 5.15.2 ** Created by: Qt User Interface Compiler version 5.15.2
** **
** WARNING! All changes made in this file will be lost when recompiling UI file! ** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/ ********************************************************************************/
#ifndef UI_QTGPIOMAIN_H #ifndef UI_QTGPIOMAIN_H
#define UI_QTGPIOMAIN_H #define UI_QTGPIOMAIN_H
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QtGui/QIcon> #include <QtGui/QIcon>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QDial> #include <QtWidgets/QDial>
#include <QtWidgets/QFrame> #include <QtWidgets/QFrame>
#include <QtWidgets/QHBoxLayout> #include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLCDNumber> #include <QtWidgets/QLCDNumber>
#include <QtWidgets/QMainWindow> #include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar> #include <QtWidgets/QMenuBar>
#include <QtWidgets/QPushButton> #include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar> #include <QtWidgets/QStatusBar>
#include <QtWidgets/QWidget> #include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class Ui_QtGPIOMain class Ui_QtGPIOMain
{ {
public: public:
QWidget *centralwidget; QWidget *centralwidget;
QHBoxLayout *horizontalLayout; QHBoxLayout *horizontalLayout;
QFrame *_frame; QFrame *_frame;
QPushButton *_LED; QPushButton *_LED;
QDial *_dial; QDial *_dial;
QLCDNumber *_display; QLCDNumber *_display;
QMenuBar *menubar; QMenuBar *menubar;
QStatusBar *statusbar; QStatusBar *statusbar;
void setupUi(QMainWindow *QtGPIOMain) void setupUi(QMainWindow *QtGPIOMain)
{ {
if (QtGPIOMain->objectName().isEmpty()) if (QtGPIOMain->objectName().isEmpty())
QtGPIOMain->setObjectName(QString::fromUtf8("QtGPIOMain")); QtGPIOMain->setObjectName(QString::fromUtf8("QtGPIOMain"));
QtGPIOMain->resize(473, 342); QtGPIOMain->resize(473, 342);
centralwidget = new QWidget(QtGPIOMain); centralwidget = new QWidget(QtGPIOMain);
centralwidget->setObjectName(QString::fromUtf8("centralwidget")); centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
centralwidget->setStyleSheet(QString::fromUtf8("")); centralwidget->setStyleSheet(QString::fromUtf8(""));
horizontalLayout = new QHBoxLayout(centralwidget); horizontalLayout = new QHBoxLayout(centralwidget);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
_frame = new QFrame(centralwidget); _frame = new QFrame(centralwidget);
_frame->setObjectName(QString::fromUtf8("_frame")); _frame->setObjectName(QString::fromUtf8("_frame"));
_frame->setStyleSheet(QString::fromUtf8("background: grey")); _frame->setStyleSheet(QString::fromUtf8("background: grey"));
_frame->setFrameShape(QFrame::NoFrame); _frame->setFrameShape(QFrame::NoFrame);
_frame->setFrameShadow(QFrame::Sunken); _frame->setFrameShadow(QFrame::Sunken);
_frame->setLineWidth(10); _frame->setLineWidth(10);
_frame->setMidLineWidth(10); _frame->setMidLineWidth(10);
_LED = new QPushButton(_frame); _LED = new QPushButton(_frame);
_LED->setObjectName(QString::fromUtf8("_LED")); _LED->setObjectName(QString::fromUtf8("_LED"));
_LED->setGeometry(QRect(50, 60, 91, 81)); _LED->setGeometry(QRect(50, 60, 91, 81));
_LED->setStyleSheet(QString::fromUtf8("background: grey")); _LED->setStyleSheet(QString::fromUtf8("background: grey"));
QIcon icon; QIcon icon;
icon.addFile(QString::fromUtf8(":/images/Green.png"), QSize(), QIcon::Normal, QIcon::Off); icon.addFile(QString::fromUtf8(":/images/Green.png"), QSize(), QIcon::Normal, QIcon::Off);
icon.addFile(QString::fromUtf8(":/images/Red.png"), QSize(), QIcon::Normal, QIcon::On); icon.addFile(QString::fromUtf8(":/images/Red.png"), QSize(), QIcon::Normal, QIcon::On);
_LED->setIcon(icon); _LED->setIcon(icon);
_LED->setIconSize(QSize(64, 64)); _LED->setIconSize(QSize(64, 64));
_LED->setCheckable(false); _LED->setCheckable(false);
_LED->setFlat(true); _LED->setFlat(true);
_dial = new QDial(_frame); _dial = new QDial(_frame);
_dial->setObjectName(QString::fromUtf8("_dial")); _dial->setObjectName(QString::fromUtf8("_dial"));
_dial->setGeometry(QRect(130, 60, 80, 80)); _dial->setGeometry(QRect(130, 60, 80, 80));
_display = new QLCDNumber(_frame); _display = new QLCDNumber(_frame);
_display->setObjectName(QString::fromUtf8("_display")); _display->setObjectName(QString::fromUtf8("_display"));
_display->setGeometry(QRect(250, 90, 131, 41)); _display->setGeometry(QRect(250, 90, 131, 41));
_display->setStyleSheet(QString::fromUtf8("background:lightgrey")); _display->setStyleSheet(QString::fromUtf8("background:lightgrey"));
horizontalLayout->addWidget(_frame); horizontalLayout->addWidget(_frame);
QtGPIOMain->setCentralWidget(centralwidget); QtGPIOMain->setCentralWidget(centralwidget);
menubar = new QMenuBar(QtGPIOMain); menubar = new QMenuBar(QtGPIOMain);
menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 473, 26)); menubar->setGeometry(QRect(0, 0, 473, 26));
QtGPIOMain->setMenuBar(menubar); QtGPIOMain->setMenuBar(menubar);
statusbar = new QStatusBar(QtGPIOMain); statusbar = new QStatusBar(QtGPIOMain);
statusbar->setObjectName(QString::fromUtf8("statusbar")); statusbar->setObjectName(QString::fromUtf8("statusbar"));
QtGPIOMain->setStatusBar(statusbar); QtGPIOMain->setStatusBar(statusbar);
retranslateUi(QtGPIOMain); retranslateUi(QtGPIOMain);
QMetaObject::connectSlotsByName(QtGPIOMain); QMetaObject::connectSlotsByName(QtGPIOMain);
} // setupUi } // setupUi
void retranslateUi(QMainWindow *QtGPIOMain) void retranslateUi(QMainWindow *QtGPIOMain)
{ {
QtGPIOMain->setWindowTitle(QCoreApplication::translate("QtGPIOMain", "libPiGPio Widget Demo", nullptr)); QtGPIOMain->setWindowTitle(QCoreApplication::translate("QtGPIOMain", "libPiGPio Widget Demo", nullptr));
_LED->setText(QString()); _LED->setText(QString());
} // retranslateUi } // retranslateUi
}; };
namespace Ui { namespace Ui {
class QtGPIOMain: public Ui_QtGPIOMain {}; class QtGPIOMain: public Ui_QtGPIOMain {};
} // namespace Ui } // namespace Ui
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // UI_QTGPIOMAIN_H #endif // UI_QTGPIOMAIN_H