int MapFile::findEntry(long addr) const { for(int j = 0 ; j < segments() ; ++j) { const MapFileEntry & segment = getSegment(j); long section = segment.section(); long segmentBegin = loadAddress() + (segment.section() << 12) + segment.offset(); long segmentEnd = segmentBegin + segment.length(); if(addr >= segmentBegin && addr < segmentEnd) { for(int i = entries() - 1 ; i >= 0 ; --i) { const MapFileEntry entry = getEntry(i); if(entry.section() == section) { long entryAddr = loadAddress() + (entry.section() << 12) + entry.offset(); if(entryAddr <= addr) return i; } } } } return -1; }
void siteDialog::swapSite(int first, int second) { FQTermParam firstParam; FQTermParam secondParam; loadAddress(config_, first, firstParam); loadAddress(config_, second, secondParam); saveAddress(config_, first, secondParam); saveAddress(config_, second, firstParam); QListWidgetItem* firstItem = ui_.siteList->item(first); QListWidgetItem* secondItem = ui_.siteList->item(second); QString tmpStr = firstItem->text(); firstItem->setText(secondItem->text()); secondItem->setText(tmpStr); }
Radioino::Radioino(byte inputPins[], byte outputPins[], byte analogInputPins[]) { _activityLedPin = RADIOINO_ACTIVIY_LED_PIN; _setupButtonPin = RADIOINO_SETUP_BUTTON_PIN; _setupMode = false; _activityLedState = false; // Load module address loadAddress(); _inputPinsCount = inputPins[0]; _outputPinsCount = outputPins[0]; _analogInputPinsCount = analogInputPins[0]; _inputPins = inputPins+sizeof(byte); // Setup output pins state array _outputPins = new PinState[_outputPinsCount]; for (int i=0; i<_outputPinsCount;i++) { _outputPins[i].number = outputPins[i+1]; // The first by is the count } _analogInputPins = analogInputPins+sizeof(byte); // Alloc strings _command.reserve(50); _response.reserve(255); _value.reserve(3); // Set the pin configuration setupPins(); }
void siteDialog::onSelectSite(QListWidgetItem* current, QListWidgetItem* previous) { int currentRow = ui_.siteList->row(current); int previousRow = ui_.siteList->row(previous); if (currentRow < 0) { ui_.editGroup->setDisabled(true); } else { ui_.editGroup->setEnabled(true); } if (previousRow >= 0){ if (checkModification(previousRow) == QMessageBox::Cancel) { forcedSetCurrentSite(previousRow); return; } saveAddress(config_, previousRow, param_); } if (currentRow >= 0){ loadAddress(config_, currentRow, param_); setUIFromParam(); } }
QMessageBox::StandardButton siteDialog::checkModification(int row) { //with current display FQTermParam originParam; loadAddress(config_, row, originParam); setParamFromUI(); QMessageBox::StandardButton ret = QMessageBox::No; if (!(originParam == param_)) { QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); msgBox.setIcon(QMessageBox::Warning); msgBox.setWindowTitle(tr("Warning")); msgBox.setText(tr("The site configuration has been changed.\nTo save, press Yes.\nTo discard, press No.\nTo continue editing, press Cancel")); switch(ret = static_cast<QMessageBox::StandardButton>(msgBox.exec())) { case QMessageBox::No: param_ = originParam; break; default: break; } ui_.siteList->item(row)->setText(param_.name_); } return ret; }
void processCommand( unsigned char cmd ) { if ( cmd == CMD_SELECT_DEVICE ) { selectedDevice = uart_getc( ); uart_putc( BYTE_CR ); } else if ( cmd == CMD_SHOW_ID ) { uart_puts( AVRISP_IDENTIFIER ); } else if ( cmd == CMD_SOFTWARE_VERSION ) { uart_puts( AVRISP_SWVER ); } else if ( cmd == CMD_HARDWARE_VERSION ) { uart_puts( AVRISP_HWVER ); } else if ( cmd == CMD_LIST_SUPPORTED_DEVICES ) { uart_puts( AVRISP_SUPPORTED_DEVICES ); uart_putc( 0 ); // terminating null character needs to be sent } else if ( cmd == CMD_PROGRAMMER_TYPE ) { uart_putc( AVRISP_PROGRAMMER_TYPE ); } else if ( cmd == CMD_SUPPORTS_AUTOINCREMENT ) { uart_putc( AVRISP_RESP_YES ); } else if ( cmd == CMD_SET_LED ) { LED_on( ); uart_putc( BYTE_CR ); } else if ( cmd == CMD_CLEAR_LED ) { LED_off( ); uart_putc( BYTE_CR ); } else if ( selectedDevice == 0 ) { // require a device for the rest of the commands uart_putc( AVRISP_RESP_UNKNOWN ); return; } // command not specified above if ( cmd == CMD_ENTER_PROGRAM_MODE ) { enableProgramMode( ); } else if ( cmd == CMD_LEAVE_PROGRAM_MODE ) { leaveProgramMode( ); } else if ( cmd == CMD_WRITE_PROG_H ) { writeProgH( ); } else if ( cmd == CMD_WRITE_PROG_L ) { writeProgL( ); } else if ( cmd == CMD_READ_PROG ) { readProg( ); } else if ( cmd == CMD_LOAD_ADDRESS ) { loadAddress( ); } else if ( cmd == CMD_WRITE_DATA ) { writeData( ); } else if ( cmd == CMD_READ_DATA ) { readData( ); } else if ( cmd == CMD_CHIP_ERASE ) { chipErase( ); } else if ( cmd == CMD_WRITE_LOCK_BITS ) { writeLockBits( ); } else if ( cmd == CMD_READ_SIGNATURE ) { readSignature( ); } else if ( cmd == CMD_WRITE_PROGRAM_PAGE ) { writeProgramPage( ); } else if ( cmd == CMD_UNIVERSAL_3 ) { universalWrite3( ); } else if ( cmd == CMD_UNIVERSAL_4 ) { universalWrite4( ); } else if ( cmd == CMD_LOAD_ADDRESS_0 ) { currentAddress = 0; uart_putc( BYTE_CR ); } }
void siteDialog::loadCurrentParam() { if (ui_.siteList->count() == 0) { return; } loadAddress(config_, currentSiteIndex(), param_); }