void hubInit(void) { initIO(); calculatePeriod(); hubLUTInit(); initRows(); hubOrientation = HUB_ROTATE_0; hubSetOrient(hubOrientation); clearScreen(); //fillScreen(COLOR_RGB(255, 255, 255)); hubTestBmp(); screenRedraw(); // 100 Hz * 16 Phases HUB_TIMER_CLK_ENABLE(); TIM_ClockConfigTypeDef sClockSourceConfig; hubtim.Instance = HUB_TIMER; hubtim.Init.Prescaler = HUB_PRESCALER - 1; hubtim.Init.CounterMode = TIM_COUNTERMODE_UP; hubtim.Init.Period = period0 - 1; hubtim.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&hubtim); sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; HAL_TIM_ConfigClockSource(&hubtim, &sClockSourceConfig); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn); HAL_TIM_Base_Start_IT(&hubtim); // Timer 2 for NOE HUB_TIMER2_CLK_ENABLE(); TIM_OC_InitTypeDef sConfigOC; hubtim2.Instance = HUB_TIMER2; hubtim2.Init.Prescaler = 0; hubtim2.Init.CounterMode = TIM_COUNTERMODE_UP; hubtim2.Init.Period = 0xffff; hubtim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&hubtim2); HAL_TIM_OC_Init(&hubtim2); sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = period2Min; sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; HAL_TIM_OC_ConfigChannel(&hubtim2, &sConfigOC, NOE_TIM_CHANNEL); HAL_TIM_PWM_Start(&hubtim2, NOE_TIM_CHANNEL); }
int main(void) { // initialize IO int rows[] = {ROW1, ROW2, ROW3, ROW4}; int cols[] = {COL1, COL2, COL3}; initColumns(cols); // set keypad columns as outputs initRows(rows); // set keypad rows as inputs initDisplay(); // initialize a 4 LED display on port D // initialize interrupts PCICR |= (1 << PCIE0); // set bit 0 of PCICR for(int i = 0; i < NUM_ROWS; i++){ PCMSK0 |= (1 << rows[i]); // allow row pins to trigger interrupts } sei(); while(1) { _delay_us(5); } }
bool ListEntity::init() { bool bRet=false; do { if (!Layer::init()) { break; } initBg(); initSortButton(); initRows(); initPageSwitch(); addChild(menu); updateRows(); bRet=true; }while(0); return bRet; }
DimstackCustomization::DimstackCustomization(XmdvToolMainWnd *mainwnd, QMdiSubWindow *window) : QDialog(window) { //save references to main window, viewManager and pID mainWnd = mainwnd; viewManager = mainWnd->getViewManager(); pID = viewManager->getActiveViewWindow()->getPipelineID(); //get the VisDimstack ViewDisplay *vd = viewManager->getActiveViewWindow()->getViewDisplay();; assert(typeid(*vd) == typeid(VisDimstack)); VisDimstack *visDimstack = dynamic_cast<VisDimstack *>(vd); //use it to set the lengths of the arrays selectionCardinalityLabels.resize(visDimstack->m_dim_size); selectionSliders.resize(visDimstack->m_dim_size); //set default value of 10 for maximum bins in a dimension maxBins = 10; //set up the dialog if (objectName().isEmpty()) setObjectName(QString::fromUtf8("dimstackCustomizationDialog")); resize(300,360); //setFixedSize(QSize::QSize (300, 360)); setWindowTitle(QString::fromUtf8("Dimension Stacking Customization")); setAttribute(Qt::WA_DeleteOnClose, false); windowLayout = new QGridLayout(this); maxBinsLabel = new QLabel(this); maxBinsLabel->setObjectName(QString::fromUtf8("maxBinsLabel")); maxBinsLabel->setText(QString::fromUtf8("Maximum Number of Bins")); //maxBinsLabel->setGeometry(QRect(10, 10, 121, 16)); windowLayout->addWidget(maxBinsLabel, 0, 0); binSelectionArea = new QScrollArea(this); binSelectionArea->setObjectName(QString::fromUtf8("binSelectionArea")); //binSelectionArea->setGeometry(QRect(9, 39, 290, 280)); windowLayout->addWidget(binSelectionArea, 1, 0, 1, -1); selectionAreaContents = new QWidget(binSelectionArea); selectionTable = new QFormLayout(); selectionTable->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); //add the top row to the selection table nameTitle = new QLabel(selectionAreaContents); nameTitle->setObjectName(QString::fromUtf8("nameTitle")); nameTitle->setText(QString::fromUtf8("Fieldname")); nameTitle->setFrameStyle(QFrame::Panel | QFrame::Raised); numBinsTitle = new QLabel(selectionAreaContents); numBinsTitle->setObjectName(QString::fromUtf8("numBinsTitle")); numBinsTitle->setText(QString::fromUtf8("Number of Bins")); numBinsTitle->setFrameStyle(QFrame::Panel | QFrame::Raised); //selectionTable->setVerticalSpacing(0); selectionTable->addRow(nameTitle, numBinsTitle); //dynamically add the rest of the rows here //(and while we're at it we set maxBins to the highest cardinality // of a dimension if it exceeds the default of 10) initRows(visDimstack); //set the layout after it has been populated //and set the contents of the scroll area selectionAreaContents->setLayout(selectionTable); binSelectionArea->setWidget(selectionAreaContents); //now maxBins is equal to the maximum number of bins of all dimensions in the dataset //generate the field for specifying max number of bins maxBinsEdit = new QLineEdit(this); maxBinsEdit->setObjectName(QString::fromUtf8("maxBinsEdit")); maxBinsEdit->setText(QString::number(maxBins)); //maxBinsEdit->setGeometry(QRect(140, 10, 113, 20)); windowLayout->addWidget(maxBinsEdit, 0, 1); //connect the max number of bins specified to the max range of the slider connect(maxBinsEdit, SIGNAL(returnPressed()), this, SLOT(updateSliderRange())); applyButton = new QPushButton(this); applyButton->setObjectName(QString::fromUtf8("applyButton")); applyButton->setText(QString::fromUtf8("Apply")); applyButton->setDefault(false); //applyButton->setGeometry(QRect(10, 330, 161, 24)); windowLayout->addWidget(applyButton, 2, 0); connect(applyButton, SIGNAL(clicked()), this, SLOT(applyChanges())); windowLayout->setVerticalSpacing(4); setLayout(windowLayout); }
int main(void) { // initialize int rows[] = {ROW1, ROW2, ROW3, ROW4}; int cols[] = {COL1, COL2, COL3}; int count; // counter variable used for loops int count_queue; // Keep track of how many characters are // in the queue int code_is_correct; int lock_state = 2; // initialized lock variable to intermediate status // initialize interrupts PCICR |= (1 << PCIE0); // set bit 0 of PCICR for(int i = 0; i < NUM_ROWS; i++){ PCMSK0 |= (1 << rows[i]); // allow row pins to trigger interrupts } sei(); // global interrupt enable // Initializing arrays int enter_code[16] = {'E','N','T','E','R',' ','C','O','D','E',' ',' ',' ',' ',' ',' '}; int incorrect_code[16] = {'I','N','C','O','R','R','E','C','T',' ','C','O','D','E',' ',' '}; int unlocked_menu_1[16] = {'#',' ','-',' ','T','O',' ','L','O','C','K',' ',' ',' ',' ',' ',}; int unlocked_menu_2[16] = {'*',' ','-',' ','S','E','T',' ','N','E','W',' ','C','O','D','E',}; int new_code_menu[16] = {'S','E','T',' ','N','E','W',' ','C','O','D','E',' ',' ',' ',' ',}; int cancel_code_change[16] = {' ',' ','-','-','C','A','N','C','E','L','E','D','-','-',' ',' ',}; int current_code[9]; initRows(rows); // set keypad rows as inputs initColumns(cols); // set keypad columns as outputs initializeLCD(); // set up LCD and initialize in 4 bit mode clearKeyQueue(); count_queue = 0; // Ensure we're locked to start with. while (lock_state != 1) { lock_state = lock(2); } // wait loop while(1) { // Print greeting clearLCD(); writeLCDline(enter_code,1); cursorPosition(2); // While box is in locked state while (lock_state == 1) { // Wait for a key press while(key_queue[count_queue] == '\0'); // Now that we have a key press we need to look at what was pressed. // Is the first key in the queue a '#'... if(key_queue[0] == '#'){ clearLCD(); clearKeyQueue(); count_queue = 0; // ...or is the first key in the queue a digit?... } else if(key_queue[0] >= '0' && key_queue[0] <= '9'){ // QUESTION: DO WE NEED TO MANUALLY SHIFT THE QUEUE?? writeLCDcharacter(key_queue[0]); ++count_queue; // ...or if first key in the queue isn't a digit or '#' then // it must be the '*' } else { count = 0; code_is_correct = 1; // Checks the current queue code with the correct code while(key_queue[count] != '\0'){ if(key_queue[count] != current_code[count]) code_is_correct = 0; } if(!code_is_correct){ clearLCD(); writeLCDline(incorrect_code,1); _delay_ms(5000); clearKeyQueue(); count_queue = 0; clearLCD(); }else{ // Unlock the box lock_state = unlock(lock_state); } } } // End while (lock_state == 1) // While box is in unlocked state while (lock_state == 0 ) { // Write unlocked menu clearLCD(); writeLCDline(unlocked_menu_1, 1); writeLCDline(unlocked_menu_2, 2); clearKeyQueue(); count_queue = 0; // Wait for keypress while(key_queue[count_queue] == '\0'); // Now that we have a key press we need to look at what was pressed. // Is the first key in the queue a '#'... if(key_queue[0] == '#'){ lock_state = lock(lock_state); clearKeyQueue(); count_queue = 0; // ...or is the first key in the queue a '*'? } else if(key_queue[0] == '*'){ clearLCD(); clearKeyQueue(); count_queue = 0; writeLCDline(new_code_menu, 1); cursorPosition(2); // Now we start entering the new code. An '*' indicates that we're // done entering the code. while(key_queue[0] != '*') { clearKeyQueue(); // Wait for keypress while(key_queue[count_queue] == '\0'); // Was the latest key pressed between 0 and 9, AND has the user // entered less than the max number (8) of digits allowed for the // code. if(key_queue[0] >= '0' && key_queue[0] <= '9' && count_queue < 9){ // QUESTION: DO WE NEED TO MANUALLY SHIFT THE QUEUE?? writeLCDcharacter(key_queue[0]); ++count_queue; // If the latest key pressed is '*' then lets write the new // code to eeprom } else if (key_queue[0] == '*') { writeTOeeprom(); // Otherwise the only key left is '#', so that's what must've been // pressed. :) } else { clearLCD(); writeLCDline(cancel_code_change,1); _delay_ms(5000); clearKeyQueue(); count_queue = 0; clearLCD(); } } } } // End while (lock_state == 0 ) } // End while(1); } // End main();
int main(void) { // initialize // short int testcode[9] = {'3','2','1','\0','\0','\0','\0','\0','\0'}; int rows[] = {ROW1, ROW2, ROW3, ROW4}; int cols[] = {COL1, COL2, COL3}; volatile int count_queue; // Keep track of how many characters are // in the queue int code_is_correct; initializeMotorPins(); initializeKeypadInterrupts(rows); sei(); // global interrupt enable initRows(rows); // set keypad rows as inputs initColumns(cols); // set keypad columns as outputs initializeLCD(); // set up LCD and initialize in 4 bit mode BacklightLCD(1); clearKeyQueue(); //writeLCDcharacter('x'); // Ensure we're locked to start with. while (lock_state != 1) { lock_state = lock(2); } initializeTimeout(); // wait loop while(1) { // Print greeting clearLCD(); writeLCDline(enter_code,1); cursorPosition(2); readFROMeeprom(current_code); /* // TESTING MOTOR while(1){ lock(1); _delay_ms(100); unlock(1); _delay_ms(100); } // END TESTING MOTOR */ // While box is in locked state while (lock_state == 1) { // Wait for a key press while(key_queue[count_queue] == '\0'); // Now that we have a key press we need to look at what was pressed. // Is the first key in the queue a '#'... if(key_queue[0] == '#'){ clearLCD(); writeLCDline(enter_code,1); cursorPosition(2); clearKeyQueue(); count_queue = 0; //testfun(1); // ...or is the first key in the queue a digit?... } else if((key_queue[0] >= '0') && (key_queue[0] <= '9') && (count_queue < 8)){ writeLCDcharacter(key_queue[0]); count_queue++; // ...or if first key in the queue isn't a digit or '#' then // it must be the '*' } else if(key_queue[0] == '*') { count = 0; code_is_correct = 1; popKey(); clearLCD(); cursorPosition(1); for(int i = 0; i < 10; i++){ writeLCDcharacter(key_queue[i]); } cursorPosition(2); for(int i = 0; i < 9; i++){ writeLCDcharacter(current_code[i]); } _delay_ms(1000); // Checks the current queue code with the correct code while(key_queue[count] != '\0'){ if(key_queue[count] != current_code[count]) code_is_correct = 0; ++count; } if(!code_is_correct && count > 0){ clearLCD(); writeLCDline(incorrect_code,1); _delay_ms(5000); clearKeyQueue(); count_queue = 0; clearLCD(); writeLCDline(enter_code,1); cursorPosition(2); }else if(code_is_correct && count > 0){ // Unlock the box lock_state = unlock(lock_state); } } } // End while (lock_state == 1) // While box is in unlocked state while (lock_state == 0 ) { // Write unlocked menu clearLCD(); writeLCDline(unlocked_menu_1, 1); writeLCDline(unlocked_menu_2, 2); clearKeyQueue(); count_queue = 0; // Wait for key press while(key_queue[count_queue] == '\0'); // Now that we have a key press we need to look at what was pressed. // Is the first key in the queue a '#'... if(key_queue[0] == '#'){ lock_state = lock(lock_state); clearKeyQueue(); count_queue = 0; writeLCDline(enter_code,1); cursorPosition(2); // ...or is the first key in the queue a '*'? } else if(key_queue[0] == '*'){ clearLCD(); clearKeyQueue(); count_queue = 0; writeLCDline(new_code_menu, 1); cursorPosition(2); // Now we start entering the new code. An '*' indicates that we're // done entering the code. while(key_queue[0] != '*') { // Wait for key press while(key_queue[count_queue] == '\0'); // Was the latest key pressed between 0 and 9, AND has the user // entered less than the max number (8) of digits allowed for the // code. if(key_queue[0] >= '0' && key_queue[0] <= '9' && count_queue < 9){ // QUESTION: DO WE NEED TO MANUALLY SHIFT THE QUEUE?? writeLCDcharacter(key_queue[0]); ++count_queue; // If the latest key pressed is '*' then lets write the new // code to eeprom } else if (key_queue[0] == '*') { popKey(); writeTOeeprom(key_queue); break; // Otherwise the only key left is '#', so that's what must've been // pressed. :) } else if(key_queue[0] == '#') { clearLCD(); writeLCDline(cancel_code_change,1); _delay_ms(5000); clearKeyQueue(); count_queue = 0; clearLCD(); break; } } } } // End while (lock_state == 0 ) } // End while(1); } // End main();