Exemple #1
0
void RadioMMI::readInput()
{
  long newPos;
  newPos = mEncoder->read();
  if (newPos != mEncoderPosition) {
    if (0 == newPos % 4) {
      if (newPos > mEncoderPosition) {
        mEncoderPosition = newPos;
        onRotateRight();
      } else if(newPos < mEncoderPosition) {
        mEncoderPosition = newPos;
        onRotateLeft();
      }
    }
  }

  if (!buttonPressed()) {
    mButtonState = NOT_PRESSED;
  } else if (buttonPressed()
      && mButtonState == NOT_PRESSED) {
    mButtonState = PRESSED;
    mButtonDownSince = millis();
    onPressed();
  } else if (buttonPressed()
      && mButtonState == PRESSED
      && ((millis() - mButtonDownSince) > 1000)) {
    mButtonState = LONG_PRESSED;
    onLongPressed();
  }
}
void TopBoardConnectors_Controller::setConmutadorPuestaServicio(SingleButton *conmutador,SingleButton *luzLlaveDes,SingleButton *luzLlaveCon, SingleButton *arranqueDes,SingleButton *arranqueCon){
    m_conmutador = conmutador;
    m_conmutador->setButtonImage(QUrl("qrc:/resources/techo_manual_up.png"),QUrl("qrc:/resources/techo_manual_down.png"));

    m_luzLlaveDes = luzLlaveDes;
    m_luzLlaveDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));
    m_luzLlaveDes->setClickeable(false);

    m_luzLlaveCon = luzLlaveCon;
    m_luzLlaveCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_luzLlaveCon->setClickeable(false);

    m_arranqueDes = arranqueDes;
    m_arranqueDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));
    m_arranqueDes->setClickeable(false);

    m_arranqueCon = arranqueCon;
    m_arranqueCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_arranqueCon->setClickeable(false);

    m_conmutadorPuestaServicioStatus = false;
    m_subte->setConmutadorPuestaServicio(m_conmutadorPuestaServicioStatus);

    connect(m_conmutador,SIGNAL(buttonPressed()),this,SLOT(conmutadorPuestaServicioPressed()));
    connect(m_arranqueCon,SIGNAL(buttonPressed()),this,SLOT(conmutadorPuestaServicioAutomaticaConPressed()));
    connect(m_arranqueDes,SIGNAL(buttonPressed()),this,SLOT(conmutadorPuestaServicioAutomaticaDesPressed()));
}
void button_callback(void) {
    if (buttonPressed()) {
        delayMilliseconds(50);   // wait 50ms for debounce
        if(buttonPressed())
        {
            change=1;
        }
    }
}
void LircRemoteControl::commandReceived(const QString &remote, const QString &button, int repeatCounter){
    if(remote == d->name){
        if(lircButtonToRemoteControlButton(button) != RemoteControlButton::Unknown){
            emit buttonPressed(RemoteControlButton(remote, lircButtonToRemoteControlButton(button), repeatCounter));
        } else {
            emit buttonPressed(RemoteControlButton(remote, formatNamespaceButton(button), repeatCounter));
        }
    }
}
void TopBoardConnectors_Controller::setParkingBrake(SingleButton *parkingBrakeCon,SingleButton *parkingBrakeDes)
{
    m_parkingBrakeCon = parkingBrakeCon;
    m_parkingBrakeDes = parkingBrakeDes;

    m_parkingBrakeCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_parkingBrakeDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));

    m_subte->setParkingBrakeConnector(true);
    connect(m_parkingBrakeCon,SIGNAL(buttonPressed()),this,SLOT(parkingBrakeConPressed()));
    connect(m_parkingBrakeDes,SIGNAL(buttonPressed()),this,SLOT(parkingBrakeDesPressed()));
}
Exemple #6
0
void readGrooveboxButtons() {
  if (buttonPressedNew(BUTTON1) && (!buttonPressed(BUTTON4))) {
    // start/stop live sequencer groovebox
    if (!seqRunning) {
      resetGroovebox();
      seqSynchStart = true;
      while ((buttonHeld(BUTTON1)) && (seqSynchStart)) {
	// wait until the button is released or until a MIDI event triggers the start
	if (buttonPressed(BUTTON4)) {
	  // save procedure
	  return;
	}
#ifdef MIDI_ENABLE
	MIDI.read();
#endif
#ifdef USBMIDI_ENABLE
	USBMIDI.read();
#endif
      }
    }
    seqSynchStart = false;
    seqRunning = !seqRunning;
    if (!seqRunning) {
      stopSequencer();
    }
  }

  if (buttonPressedNew(BUTTON2)) {
    // clear the sequence notes on this track.
    for(byte i=0;i<SEQ_LENGTH;i++) {
      seq[i][currentTrack].midiVal = UNSET;
      seq[i][currentTrack].transpose = 0;
    }
  }

  if ((buttonPressedNew(BUTTON3)) && (seqRunning)) {
    seqPreview = !seqPreview;
  }
  if (seqPreview) {
    ledState[PREVIEW_LED] = HIGH;
  }

  if (buttonPressedNew(BUTTON4)) {
    metronomeMode = (metronomeMode + 1) % 3;
    if ((metronomeMode == METRONOME_MODE_OFF) && (metronomeNoteIndex != UNSET)) {
      stopNote(metronomeNoteIndex);
      metronomeNoteIndex = UNSET;
    }
  }


}
void TopBoardConnectors_Controller::setMainCompressor(SingleButton *mainCompressorCon,SingleButton *mainCompressorDes)
{
    m_mainCompressorCon = mainCompressorCon;
    m_mainCompressorDes = mainCompressorDes;

    m_mainCompressorCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_mainCompressorDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));

    m_subte->setMainCompressorConnector(false);

    connect(m_mainCompressorCon,SIGNAL(buttonPressed()),this,SLOT(mainCompressorConPressed()));
    connect(m_mainCompressorDes,SIGNAL(buttonPressed()),this,SLOT(mainCompressorDesPressed()));
}
void TopBoardConnectors_Controller::setLighting(SingleButton *lightingCon,SingleButton *lightingDes)
{
    m_lightingCon = lightingCon;
    m_lightingDes = lightingDes;

    m_lightingCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_lightingDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));

    m_subte->setLightingConnector(false);

    connect(m_lightingCon,SIGNAL(buttonPressed()),this,SLOT(lightingConPressed()));
    connect(m_lightingDes,SIGNAL(buttonPressed()),this,SLOT(lightingDesPressed()));
}
void ToolBarButton::mouseReleaseEvent(QMouseEvent *event)
{
    event->ignore(); // Move event goes to ToolBarWidget

    if (isToggleButton()) {
        // Leave tool buttons pressed
    }
    else {
        // Lift other buttons back to up
        pressed = false;
        repaint();

        if (toolbarwidget->dockingDone) {
            // User was only moving toolbar, do not open dialogs
        }
        else {
            // Open dialogs
            // Send button pressed signal for dialog and undo/new buttons
            if (isDialogButton() || type == ToolBarButton::ENew || type != ToolBarButton::EMMS) {
                emit buttonPressed(type);
            }
        }
    }

    QWidget::mouseReleaseEvent(event);
}
void RaspiLcdWidget::registerKey(QAbstractButton *butt, keyType key)
{
  m_butList.append(butt);
  m_keyList.append(key);
  connect(butt,SIGNAL(pressed()),this,SLOT(buttonPressed()));
  connect(butt,SIGNAL(released()),this,SLOT(buttonReleased()));
}
void TopBoardConnectors_Controller::setBattery(SingleButton *batteryCon, SingleButton *batteryDes)
{
    m_batteryCon = batteryCon;
    m_batteryDes = batteryDes;

    m_batteryCon->setButtonImage(QUrl("qrc:/resources/redON_CON_techo.png"),QUrl("qrc:/resources/red_CON_techo.png"));
    m_batteryDes->setButtonImage(QUrl("qrc:/resources/greenON_DES_techo.png"),QUrl("qrc:/resources/green_DES_techo.png"));

    m_subte->setBatteryConnector(FALSE);

    connect(m_batteryCon,SIGNAL(buttonPressed()),this,SLOT(batteryConPressed()));
    connect(m_batteryDes,SIGNAL(buttonPressed()),this,SLOT(batteryDesPressed()));

    connect(m_batteryCon,SIGNAL(buttonPressed()),this,SIGNAL(batteryCon()));
    connect(m_batteryDes,SIGNAL(buttonPressed()),this,SIGNAL(batteryDes()));
}
int QButtonGroup::insert( QButton *button, int id )
{
    if ( button->group() )
	button->group()->remove( button );

    static int seq_no = -2;
    QButtonItem *bi = new QButtonItem;
    Q_CHECK_PTR( bi );

    if ( id < -1 )
	bi->id = seq_no--;
    else if ( id == -1 )
	bi->id = buttons->count();
    else
	bi->id = id;

    bi->button = button;
    button->setGroup(this);
    buttons->append( bi );

    connect( button, SIGNAL(pressed()) , SLOT(buttonPressed()) );
    connect( button, SIGNAL(released()), SLOT(buttonReleased()) );
    connect( button, SIGNAL(clicked()) , SLOT(buttonClicked()) );
    connect( button, SIGNAL(toggled(bool)) , SLOT(buttonToggled(bool)) );

    if ( button->isToggleButton() && !button->isOn() &&
	 selected() && (selected()->focusPolicy() & TabFocus) != 0 )
	button->setFocusPolicy( (FocusPolicy)(button->focusPolicy() &
					      ~TabFocus) );

    return bi->id;
}
Exemple #13
0
void Button::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    moveBy(0, -1);
    mPressedEffect->setOffset(0, 2);
    if (boundingRect().contains(event->pos()))
        emit buttonPressed();
}
encodingWindow::encodingWindow(QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint)
 {
	ui.setupUi(this);

#ifndef _WIN32
	//check for root privileges
	if (getuid() == 0)
	{
		// set priority to normal, regardless of preferences
		ui.comboBoxPriority->setCurrentIndex(2);
	}
#endif

	connect(ui.checkBoxShutdown, SIGNAL(stateChanged(int)), this, SLOT(shutdownChanged(int)));
	connect(ui.pushButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
	connect(ui.comboBoxPriority, SIGNAL(currentIndexChanged(int)), this, SLOT(priorityChanged(int)));

	// set priority
	uint32_t priority;

	prefs->get(PRIORITY_ENCODING,&priority);	

#ifndef _WIN32
	// check for root privileges
	if (getuid() == 0)
	{
		ui.comboBoxPriority->setCurrentIndex(priority);
	}
#else
	ui.comboBoxPriority->setCurrentIndex(priority);
#endif
 }
int WebcamWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: sliderMoved((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: buttonPressed((*reinterpret_cast< QAbstractButton*(*)>(_a[1]))); break;
        case 2: buttonPressed(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
void updatePaddle1(){

    //check for UP button press
    if (buttonPressed(64))
    {
        if (paddleY[1] > 10)
            paddleY[1] -= PADDLE_SPEED;
    }
    
    //check for DOWN button press
    if (buttonPressed(128))
    {
        if (paddleY[1] < SCREEN_H - PADDLE_HEIGHT - 1)
            paddleY[1] += PADDLE_SPEED;
    }
}
Exemple #17
0
KGncPriceSourceDlg::KGncPriceSourceDlg(const QString &stockName, const QString& gncSource, QWidget * parent) : QDialog(parent), d(new Private)
{
  QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Help);
  QWidget *mainWidget = new QWidget(this);
  QVBoxLayout *mainLayout = new QVBoxLayout;
  setLayout(mainLayout);
  mainLayout->addWidget(mainWidget);
  QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
  okButton->setDefault(true);
  okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
  connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
  connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  d->widget = new KGncPriceSourceDlgDecl();
  mainLayout->addWidget(d->widget);
  // signals and slots connections
  connect(d->widget->buttonsSource, SIGNAL(buttonClicked(int)), this, SLOT(buttonPressed(int)));
  connect(this, SIGNAL(helpClicked()), this, SLOT(slotHelp()));
  // initialize data fields
  d->widget->textStockName->setText(i18n("Investment: %1", stockName));
  d->widget->textGncSource->setText(i18n("Quote source: %1", gncSource));
  d->widget->listKnownSource->clear();
  d->widget->listKnownSource->insertItems(0, WebPriceQuote::quoteSources());
  d->widget->lineUserSource->setText(gncSource);
  d->widget->checkAlwaysUse->setChecked(true);
  d->widget->buttonsSource->setId(d->widget->buttonNoSource, 0);
  d->widget->buttonsSource->setId(d->widget->buttonSelectSource, 1);
  d->widget->buttonsSource->setId(d->widget->buttonUserSource, 2);
  d->widget->buttonsSource->button(0)->setChecked(true);
  mainLayout->addWidget(buttonBox);
  buttonPressed(0);
  return;
}
Exemple #18
0
void ToolBarButton::mouseReleaseEvent(QMouseEvent *event)
{
    event->accept(); // Event does not go to parent ToolBarWidget

    if (isToolButton()) {
        // Leave tool buttons pressed
    }
    else {
        // Lift other buttons back to up
        pressed = false;
        repaint();

        if (acceptMouseMove) {
            // User was only moving toolbar, do not open dialogs
            acceptMouseMove = false;
        }
        else {
            // Open dialogs
            // Send button pressed signal for dialog and undo/new buttons
            if (isDialogButton() || type == ToolBarButton::EUndo || type == ToolBarButton::ENew) {
                emit buttonPressed(type);
            }
        }
    }
}
Exemple #19
0
AbstractEditableWidget::AbstractEditableWidget(QWidget *contentWidget, QWidget* parent)
:   QWidget(parent),
    m_contentWidget(contentWidget)
{
    m_layout = new QHBoxLayout(this);
    m_layout->setContentsMargins(0,0,0,0);

    m_label = new KSqueezedTextLabel(this);
    m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    m_label->setTextElideMode(Qt::ElideRight);
    m_layout->addWidget(m_label);

    m_layout->addWidget(contentWidget);

    m_button = new QToolButton(this);
    m_button->setCheckable(false);
    //m_button->setIconSize(QSize(10,10));
    //m_button->setI (Qt::ToolButtonIconOnly);
    connect(m_button, SIGNAL(pressed()), this, SLOT(buttonPressed()));
    m_layout->addWidget(m_button);

    m_layout->addStretch();
    setLayout(m_layout);

    display();
}
void Client::setup()
{
    authenticated = false;
    error = false;

    buttonTimeout = new QTimer(this);
    connect(buttonTimeout,SIGNAL(timeout()),this,SLOT(exhibitNumberEntered()));
    buttonTimeout->setSingleShot(true);

//    lcd = new LcdController();
    mediaPlayer = new MediaPlayer();
    keypad = new KeypadController();

    // must register own types or Qt wont connect them properly
    qRegisterMetaType<KeypadButton>("KeypadButton");

    QObject::connect(this, SIGNAL(getPin()), keypad, SLOT(pinRequested()));
    QObject::connect(keypad, SIGNAL(forwardButton(KeypadButton)), this, SLOT(buttonPressed(KeypadButton)));
    QObject::connect(keypad, SIGNAL(forwardPincode(QString)), this, SLOT(pincodeReceived(QString)));

    // network lives in a thread so hook up signals
    network = new Network();
    QObject::connect(this, SIGNAL(request(QUrl, QString)), network, SLOT(getRequest(QUrl, QString)));
    QObject::connect(network, SIGNAL(forwardMessage(QString, unsigned int)), this, SLOT(networkReply(QString, unsigned int)));

    // setup location tracker thread
    tracker = new LocationTracker();
    QObject::connect(tracker, SIGNAL(forwardNewLocation(int)), this, SLOT(locationChanged(int)));
}
Exemple #21
0
void processEvents() {
	for(short i=1;i<=36;i++) {
		bool pressed = buttonPressed(i);
		if (lastButtons[i] != pressed) {performButtonAction(i, pressed);} //If changed, perform pressed or released action
		lastButtons[i] = pressed;
	}
	return;
}
Exemple #22
0
QToolButton* ToolHelper::createButton()
{
    QToolButton *but = new QToolButton();
    but->setIcon(KIcon(m_toolFactory->icon()).pixmap(22));
    but->setToolTip(m_toolFactory->toolTip());
    connect(but, SIGNAL(clicked()), this, SLOT(buttonPressed()));
    return but;
}
Exemple #23
0
QWidget* Flags::createEditor(QWidget * parent, const QModelIndex & index)
{
	Q_UNUSED(index);
	QPushButton * bt = new QPushButton(parent);
	bt->setText(tr("Change flags"));
	connect(bt, SIGNAL(pressed()), this, SLOT(buttonPressed()));
	return bt;
}
Exemple #24
0
EditableString::EditableString(QWidget* parent)
:   AbstractEditableWidget(new QLineEdit(), parent),
    m_lineEdit(static_cast<QLineEdit*>(m_contentWidget))
{
    m_contentWidget->setParent(this);
    connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(buttonPressed()));

}
Exemple #25
0
SearchWidget::SearchWidget(QWidget *parent) :
    QWidget(parent)
{
    key_e = new QLineEdit();

    searchButton = new QPushButton();
    filterButton = new QPushButton("filter...");
    QImage temp(":/icons/Search.png");
    searchButton->setIcon(QIcon(QPixmap::fromImage(temp).scaled(20,20)));
    layout = new QHBoxLayout(this);
    layout->addWidget(key_e);
    layout->addWidget(filterButton);
    layout->addWidget(searchButton);
    connect(searchButton,SIGNAL(clicked()),this,SLOT(buttonPressed()));
    connect(key_e,SIGNAL(returnPressed()),this,SLOT(buttonPressed()));
    connect(filterButton,SIGNAL(clicked()),this,SLOT(filterPressed()));
}
Exemple #26
0
//This function speeds up the clock if BTN2 is pressed
//it slows down the clock if BTN3 is pressed
//the number of ticks in the interrupt section of clock.c
//was divided by speedUpdate() to achieve this
unsigned int speedUpdate()
{
	if(buttonPressed(BTN2))
	{
		if(speeds > 10)
			speeds = 10;
		else
			speeds++;
	}
	else if(buttonPressed(BTN3))
	{
		if(speeds>1)
			speeds--;
		else
			speeds =1;	
	}
	return speeds;
}
Exemple #27
0
// BEGIN_TUTORIAL
// The DriveWidget constructor does the normal Qt thing of
// passing the parent widget to the superclass constructor, then
// initializing the member variables.
DriveWidget::DriveWidget(QWidget* parent) :
		QWidget(parent), linear_velocity_(0), angular_velocity_(0), linear_scale_(5), angular_scale_(2) {
	// create push button objects
	pushButton_1 = new QPushButton("Forward", this);
//	pushButton_1->setShortcut();
	pushButton_2 = new QPushButton("Backward", this);
	pushButton_3 = new QPushButton("LeftTurn", this);
	pushButton_4 = new QPushButton("RightTurn", this);
//	pushButton_4->setCheckable(true);
//	pushButton_5 = new QPushButton("Stop",this);
	connect(pushButton_1, SIGNAL( pressed()), this, SLOT( buttonPressed()));
	connect(pushButton_2, SIGNAL( pressed()), this, SLOT( buttonPressed()));
	connect(pushButton_3, SIGNAL( pressed()), this, SLOT( buttonPressed()));
	connect(pushButton_4, SIGNAL( pressed()), this, SLOT( buttonPressed()));
	connect(pushButton_1, SIGNAL( released()), this, SLOT( buttonReleased()));
	connect(pushButton_2, SIGNAL( released()), this, SLOT( buttonReleased()));
	connect(pushButton_3, SIGNAL( released()), this, SLOT( buttonReleased()));
	connect(pushButton_4, SIGNAL( released()), this, SLOT( buttonReleased()));
}
void BackendInterface::setButtonPressed(PowerDevil::BackendInterface::ButtonType type)
{
    if (type == LidClose && !d->isLidClosed) {
        d->isLidClosed = true;
        Q_EMIT lidClosedChanged(true);
    } else if (type == LidOpen && d->isLidClosed) {
        d->isLidClosed = false;
        Q_EMIT lidClosedChanged(false);
    }
    Q_EMIT buttonPressed(type);
}
Exemple #29
0
void KFinder::slotButtonPressed( KFinderButton *_but )
{
    sort = buttonList.findRef( _but );
    QPushButton *but;
    for ( but = buttonList.first(); but != 0L; but = buttonList.next() )
	if ( but != _but )
	    but->setOn( FALSE );
    finderWin->repaint();

    emit buttonPressed( sort );
}
void main(void) {
    initSquareWear();
    setModeOutput(pinC7);
    while(1) {
        if (buttonPressed()) {
            latC7 = 1;
        } else {
            latC7 = 0;
        }
    }
}