#include "widget.h"
#include "ui_widget.h"
#include <wiringPi.h>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
wiringPiSetup();
pinMode(1,OUTPUT);
mTimer = new QTimer(this);
connect(mTimer,&QTimer::timeout,this,&Widget::slot_setlabel);
}
Widget::~Widget()
{
delete ui;
}
static int temp = 1;
static bool flag = true;
void Widget::on_pushButton_clicked()
{
if(flag)
{
ui->pushButton->setText("Stop");
mTimer->start(100);
flag = false;
}
else
{
flag = true;
mTimer->stop();
ui->pushButton->setText("Start");
}
}
static int currteme = 0;
void Widget::slot_setlabel()
{
if(currteme == 0)
{
digitalWrite(1,HIGH);
}
if(currteme == 100)
{
digitalWrite(1,LOW);
ui->label->setText(QString("count:%1").arg(temp));
temp ++;
}
currteme++;
if(currteme == 300)
{
currteme = 0;
}
}