void ModeWidget::initUi() { /* ensure that only one button is selected at a time */ modeGroup = new QButtonGroup(); modeGroup->addButton(zoomButton); modeGroup->addButton(pickButton); modeGroup->addButton(labelButton); cursorGroup = new QButtonGroup(); cursorGroup->addButton(smallCurButton); cursorGroup->addButton(mediumCurButton); cursorGroup->addButton(bigCurButton); cursorGroup->addButton(hugeCurButton); setCursorButtonsVisible(false); zoomButton->setAction(actionZoom); connect(actionZoom, SIGNAL(triggered()), this, SLOT(zoomMode())); labelButton->setAction(actionLabel); connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelMode())); pickButton->setAction(actionPick); connect(actionZoom, SIGNAL(triggered()), this, SLOT(pickMode())); rubberButton->setAction(actionRubber); overrideButton->setAction(actionOverride); }
void Menu::pickSettingToChangeLoop(void){ rotaryEncoder.setRange(0, 0, 2); // mode setting, beer temp, fridge temp uint16_t lastChangeTime = ticks.seconds(); uint8_t blinkTimer = 0; while(ticks.timeSince(lastChangeTime) < MENU_TIMEOUT){ // time out at 10 seconds if(rotaryEncoder.changed()){ lastChangeTime = ticks.seconds(); blinkTimer = 0; } if(blinkTimer == 0){ // print all text again for blinking display.printStationaryText(); } if(blinkTimer == 128){ // blink one of the options by overwriting it with spaces display.printAt_P(0, rotaryEncoder.read(), STR_6SPACES); } if( rotaryEncoder.pushed() ){ rotaryEncoder.resetPushed(); switch(rotaryEncoder.read()){ case 0: pickMode(); return; case 1: // switch to beer constant, because beer setting will be set through display tempControl.setMode(MODE_BEER_CONSTANT); display.printMode(); pickBeerSetting(); return; case 2: // switch to fridge constant, because fridge setting will be set through display tempControl.setMode(MODE_FRIDGE_CONSTANT); display.printMode(); pickFridgeSetting(); return; } } blinkTimer++; wait.millis(3); // delay for blinking } }