/***************************************************************************

    QtGPIO
    Copyright © 2013-2022 christoph holzheuer
    chris@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

***************************************************************************/


#include <QtGPIOMain.h>
#include <ui_QtGPIOMain.h>
#include <QDebug>


QtGPIOMain::QtGPIOMain( QWidget* parent )
    : QMainWindow( parent ), _pigDial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 )
{

    setupUi( this );

    //_rotaryDial.init( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
     //auto lambda = []() { std::cout << "lambda\n"; };
    //_rotaryDial.sigState.connect( lambda );


    //pigRotaryDial dial( pigpio::bcm17, pigpio::bcm27, pigpio::bcm22 );
    //_rotaryDial.add_state_observer( &myMoo );
    //_rotaryDial.add_value_observer( &myMoo );

    //_pigDial.add_state_observer( this );
    //_pigDial.add_value_observer( this );

}


QtGPIOMain::~QtGPIOMain()
{

}

void QtGPIOMain::on_state_changed( bool state )
{
    qDebug() << "onStateChanged: " << state;
    _LED->setChecked( state );

}

void QtGPIOMain::on_value_changed( int value )
{
    qDebug() << "on_value_changed: " << value;
    _dial->setValue( value );
}
