//for debugging void RFM69::readAllRegs() { byte regVal; for (byte regAddr = 1; regAddr <= 0x4F; regAddr++) { select(); SPI.transfer(regAddr & 0x7f); // send address + r/w bit regVal = SPI.transfer(0); unselect(); Serial.print(regAddr, HEX); Serial.print(" - "); Serial.print(regVal,HEX); Serial.print(" - "); Serial.println(regVal,BIN); } unselect(); }
void FaceSelector::selectFace(int object_id, const boost::shared_ptr<glutils::Face>& face) { unselect(); _scene->_currentObject = object_id; _selectedFace = face; _selectedFaceShape = face->shape->clone("Start"); _selectedFaceCopy = *_selectedFace; _selectedFaceName = _selectedFace->name; _selected = true; }
bool CursorSelector::pushed(Action key) { if (key == Action::DELETE) { if (is_selected && !is_block_selected && selected->entity_class != EntityType::BASEWORLD) { Entity* deselect = selected; unselect(); deselect->remove_self(); } } return true; }
GameScreen::GameScreen(unsigned int myID) : Screen(myID), m_iHandler(ConfigOptions::getIHandler()), m_selectedType(RABBIT), m_victor(NB_PLAYERS) { unselect(); m_goldTurnIndicator.SetPosition(0, TURN_INDICATOR_HEIGHT); m_silverTurnIndicator.SetPosition(0, (float) ConfigOptions::nativeHeight() - TURN_INDICATOR_HEIGHT); m_nbMovesSprite.SetPosition(NB_MOVES_X, (float) ConfigOptions::nativeHeight() /2); m_movesBackgroundSprite.SetPosition(NB_BG_X, (float) ConfigOptions::nativeHeight() /2); m_cursor.moveOnSquare(sf::Vector2i(0,0)); m_victorySign.SetPosition(ConfigOptions::getNativeCenter()); m_victorySign.SetColor(sf::Color(255,255,255,1)); }
void PL_SELECTION_TOOL::RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode ) { if( aItem ) { unselect( aItem ); // Inform other potentially interested tools if( !aQuietMode ) m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); } }
//============================================================================= // listenIrq() - only called by listen irq handler //============================================================================= void RFM69_WL::listenIrq(void) { if (DATALEN != 0) return; resetListenReceive(); noInterrupts(); select(); union // union to simplify addressing of long and short parts of time offset { uint32_t l; uint8_t b[4]; } burstRemaining; burstRemaining.l = 0; SPI.transfer(REG_FIFO & 0x7F); PAYLOADLEN = SPI.transfer(0); PAYLOADLEN = PAYLOADLEN > 66 ? 66 : PAYLOADLEN; // precaution TARGETID = SPI.transfer(0); if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode || PAYLOADLEN < 4) // address situation could receive packets that are malformed and don't fit this library's extra fields { resetListenReceive(); goto out; } SENDERID = SPI.transfer(0); burstRemaining.b[0] = SPI.transfer(0); // and get the time remaining burstRemaining.b[1] = SPI.transfer(0); // We've read the target, sender id, and the burst time remaining for a total of 4 bytes DATALEN = PAYLOADLEN - 4; LISTEN_BURST_REMAINING_MS = burstRemaining.l; // if (LISTEN_BURST_REMAINING_MS > (_listenCycleDurationMs + BURST_CYCLE_PADDING_MS)) { // // This happened to me with a presumably bad radio, but still a good sanity check // resetListenReceive(); // return; // } for (uint8_t i = 0; i < DATALEN; i++) { DATA[i] = SPI.transfer(0); } if (DATALEN < RF69_MAX_DATA_LEN) DATA[DATALEN] = 0; // add null at end of string out: unselect(); interrupts(); }
bool GameScreen::select(sf::Vector2i s) { if(m_selectedPiece != NULL_SQUARE) //if a piece is selected { if(m_selectedTarget != NULL_SQUARE) //if an enemy piece is selected { if(!m_highlighter.isHighlighted(s)) //square isn't selectable unselect(); else //square is selectable { bool res = m_game.displace(toSquare(m_selectedPiece), toSquare(s), toSquare(m_selectedTarget), false); unselect(); return res; } } else //no enemy piece selected { if(!m_highlighter.isHighlighted(s)) //square isn't selectable unselect(); else //square is selectable { PiecePtr p = m_game[toSquare(s)]; if (p == nullptr) //no piece here { bool res = m_game.move(toSquare(m_selectedPiece), toSquare(s), false); unselect(); return res; } else selectTarget(s); } } } else //no piece is selected { PiecePtr p = m_game[toSquare(s)]; if (p != nullptr && p->getColor() == m_game.getActivePlayer()) //there is a piece and it can be selected selectPiece(s); } return false; }
void DigitView::selectItemsReplace(Q3CanvasItemList* list) { unselect(); selectionList = *list; ASSERT_ENGAUGE(m_doc != 0); m_doc->selectionListChanged(); removeHandles(); if (selectionList.count() > 0) addHandles(listBounds(&selectionList)); }
void PL_SELECTION_TOOL::RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode ) { if( aList ) { for( EDA_ITEM* item : *aList ) unselect( item ); // Inform other potentially interested tools if( !aQuietMode ) m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); } }
void GText::resetStyle(STYLE newStyle) { _style = newStyle; _default(); if (flagSetted(TITLE)) { title(); } else if (flagSetted(SUBTITLE)) { subtitle(); } else { flagSetted(SELECTED) ? select() : unselect(); flagSetted(VALIDATED) ? validate() : unvalidate(); } }
// -------------------------------------------------------------------------------------------------------- void KSelectionHandler::unselectAllInVector (const PickableVector * pv) { PickableVector::const_iterator iter = pv->begin(); while (iter != pv->end()) { if ((*iter)->getClassId() >= KSelectable::classId()) { unselect((KSelectable*)(*iter)); } iter++; } }
// To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP"); // To disable encryption: radio.encrypt(null) or radio.encrypt(0) // KEY HAS TO BE 16 bytes !!! void RFM69::encrypt(const char* key) { setMode(RF69_MODE_STANDBY); if (key!=0) { select(); SPI.transfer(REG_AESKEY1 | 0x80); for (byte i = 0; i<16; i++) SPI.transfer(key[i]); unselect(); } writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFE) | (key ? 1 : 0)); }
void RFM69::interruptHandler() { //pinMode(4, OUTPUT); //digitalWrite(4, 1); if (_mode == RF69_MODE_RX && (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PAYLOADREADY)) { //RSSI = readRSSI(); setMode(RF69_MODE_STANDBY); select(); SPI.transfer(REG_FIFO & 0x7F); PAYLOADLEN = SPI.transfer(0); PAYLOADLEN = PAYLOADLEN > 66 ? 66 : PAYLOADLEN; // precaution TARGETID = SPI.transfer(0); if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode || PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this libraries extra fields { PAYLOADLEN = 0; unselect(); receiveBegin(); //digitalWrite(4, 0); return; } DATALEN = PAYLOADLEN - 3; SENDERID = SPI.transfer(0); uint8_t CTLbyte = SPI.transfer(0); ACK_RECEIVED = CTLbyte & 0x80; // extract ACK-received flag ACK_REQUESTED = CTLbyte & 0x40; // extract ACK-requested flag for (uint8_t i = 0; i < DATALEN; i++) { DATA[i] = SPI.transfer(0); } if (DATALEN < RF69_MAX_DATA_LEN) DATA[DATALEN] = 0; // add null at end of string unselect(); setMode(RF69_MODE_RX); } RSSI = readRSSI(); //digitalWrite(4, 0); }
medCustomViewContainer::medCustomViewContainer ( QWidget *parent ) : medViewContainer ( parent ), d2 ( new medCustomViewContainerPrivate ) { d2->rowMax = 5; d2->columnMax = 5; d2->preset = 0; // retrieve the list of child containers and connect clicked signal // to warn other containers that another one was clicked medViewContainer *root = this->root(); if ( root ) { QList<medViewContainer *> containers = root->childContainers(); foreach ( medViewContainer *container, containers ) { if ( container->isLeaf() && container!=this ) { connect ( this, SIGNAL ( selected() ), container, SLOT ( unselect() ), Qt::UniqueConnection ); connect ( container, SIGNAL ( selected() ), this, SLOT ( unselect() ), Qt::UniqueConnection ); } } } }
// internal function void RFM69::sendFrame(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK, bool sendACK) { setMode(RF69_MODE_STANDBY); // turn off receiver to prevent reception while filling fifo while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady writeReg(REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_00); // DIO0 is "Packet Sent" if (bufferSize > RF69_MAX_DATA_LEN) bufferSize = RF69_MAX_DATA_LEN; // control byte uint8_t CTLbyte = 0x00; if (sendACK) CTLbyte = RFM69_CTL_SENDACK; else if (requestACK) CTLbyte = RFM69_CTL_REQACK; #ifdef RASPBERRY unsigned char thedata[63]; uint8_t i; for(i = 0; i < 63; i++) thedata[i] = 0; thedata[0] = REG_FIFO | 0x80; thedata[1] = bufferSize + 3; thedata[2] = toAddress; thedata[3] = _address; thedata[4] = CTLbyte; // write to FIFO for(i = 0; i < bufferSize; i++) { thedata[i + 5] = ((char*)buffer)[i]; } wiringPiSPIDataRW(SPI_DEVICE, thedata, bufferSize + 5); #else // write to FIFO select(); SPI.transfer(REG_FIFO | 0x80); SPI.transfer(bufferSize + 3); SPI.transfer(toAddress); SPI.transfer(_address); SPI.transfer(CTLbyte); for (uint8_t i = 0; i < bufferSize; i++) SPI.transfer(((uint8_t*) buffer)[i]); unselect(); #endif // no need to wait for transmit mode to be ready since its handled by the radio setMode(RF69_MODE_TX); uint32_t txStart = millis(); while (digitalRead(_interruptPin) == 0 && millis() - txStart < RF69_TX_LIMIT_MS); // wait for DIO0 to turn HIGH signalling transmission finish //while (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PACKETSENT == 0x00); // wait for ModeReady setMode(RF69_MODE_STANDBY); }
int SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent ) { // Check if there is an item to be selected BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>(); if( item ) { unselect( item ); // Inform other potentially interested tools m_toolMgr->ProcessEvent( UnselectedEvent ); } return 0; }
uint8_t matrix_scan(void) { uint8_t layer = biton32(layer_state); switch (layer) { case 0: all_led_off(); break; case 1: if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) { all_led_off(); caps_lock_led_on(); } break; case 2: all_led_off(); num_lock_led_on(); break; default: break; } for (uint8_t i = 0; i < MATRIX_ROWS; i++) { select(i); uint8_t row = read(i); if (matrix_debouncing[i] != row) { matrix_debouncing[i] = row; if (debouncing) { debug("bounce!: "); debug_hex(debouncing); debug("\n"); } debouncing = DEBOUNCE; } unselect(); } if (debouncing) { if (--debouncing) { _delay_ms(1); } else { for (uint8_t i = 0; i < MATRIX_ROWS; i++) { matrix[i] = matrix_debouncing[i]; } } } return 1; }
void RFM69::writeReg(uint8_t addr, uint8_t value) { #if RASPBERRY //printf("%x %x\n", addr, value); unsigned char thedata[2]; thedata[0] = addr | 0x80; thedata[1] = value; wiringPiSPIDataRW(SPI_DEVICE, thedata, 2); delayMicroseconds(MICROSLEEP_LENGTH); #else select(); SPI.transfer(addr | 0x80); SPI.transfer(value); unselect(); #endif }
void Gamestep3::onclick(Cell* c, bool lbutton) { if(lbutton) { if(c->getValue() > 0) { unselect(); select(c); } } else if(selectedCell != NULL) { Agent* a = new Agent(10, *selectedCell, *c); agents.push_back(a); layerAgent.addElement(a); } }
// behaviour when this cursor item is clicked bool CursorSelector::clicked(Action mouse) { if (!BlockTracing::show_item) { unselect(); return true; } Entity* ent = BlockTracing::selected; if (ent->entity_class == EntityType::SUPEROBJECT || ent->entity_class == EntityType::BASEWORLD || ent->entity_class == EntityType::GAMETEMPLATE) { is_block_selected = true; selected_pos = BlockTracing::pointed_pos; } else { is_block_selected = false; } ent = ent->find_top_level_parent(); select(ent); return true; }
uint8_t RFM69::readReg(uint8_t addr) { #ifdef RASPBERRY unsigned char thedata[2]; thedata[0] = addr & 0x7F; thedata[1] = 0; wiringPiSPIDataRW(SPI_DEVICE, thedata, 2); delayMicroseconds(MICROSLEEP_LENGTH); //printf("%x %x\n", addr, thedata[1]); return thedata[1]; #else select(); SPI.transfer(addr & 0x7F); uint8_t regval = SPI.transfer(0); unselect(); return regval; #endif }
//============================================================================= // sendFrame() - the new one with additional parameters. This packages recv'd RSSI with the packet, if required. //============================================================================= void RFM69_ATC::sendFrame(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK, bool sendACK, bool sendRSSI, int16_t lastRSSI) { setMode(RF69_MODE_STANDBY); // turn off receiver to prevent reception while filling fifo while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady writeReg(REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_00); // DIO0 is "Packet Sent" bufferSize += (sendACK && sendRSSI)?1:0; // if sending ACK_RSSI then increase data size by 1 if (bufferSize > RF69_MAX_DATA_LEN) bufferSize = RF69_MAX_DATA_LEN; // write to FIFO select(); SPI.transfer(REG_FIFO | 0x80); SPI.transfer(bufferSize + 3); SPI.transfer(toAddress); SPI.transfer(_address); // control byte if (sendACK) { // TomWS1: adding logic to return ACK_RSSI if requested SPI.transfer(RFM69_CTL_SENDACK | (sendRSSI?RFM69_CTL_RESERVE1:0)); // TomWS1 TODO: Replace with EXT1 if (sendRSSI) { SPI.transfer(abs(lastRSSI)); //RSSI dBm is negative expected between [-100 .. -20], convert to positive and pass along as single extra header byte bufferSize -=1; // account for the extra ACK-RSSI 'data' byte } } else if (requestACK) { // TODO: add logic to request ackRSSI with ACK - this is when both ends of a transmission would dial power down. May not work well for gateways in multi node networks SPI.transfer(_targetRSSI ? RFM69_CTL_REQACK | RFM69_CTL_RESERVE1 : RFM69_CTL_REQACK); } else SPI.transfer(0x00); for (uint8_t i = 0; i < bufferSize; i++) SPI.transfer(((uint8_t*) buffer)[i]); unselect(); // no need to wait for transmit mode to be ready since its handled by the radio setMode(RF69_MODE_TX); uint32_t txStart = millis(); while (digitalRead(_interruptPin) == 0 && millis() - txStart < RF69_TX_LIMIT_MS); // wait for DIO0 to turn HIGH signalling transmission finish //while (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PACKETSENT == 0x00); // wait for ModeReady setMode(RF69_MODE_STANDBY); }
void PL_SELECTION_TOOL::toggleSelection( EDA_ITEM* aItem ) { if( aItem->IsSelected() ) { unselect( aItem ); // Inform other potentially interested tools m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); } else { if( !m_additive ) ClearSelection(); select( aItem ); // Inform other potentially interested tools m_toolMgr->ProcessEvent( EVENTS::SelectedEvent ); } if( m_frame ) m_frame->GetGalCanvas()->ForceRefresh(); }
// -------------------------------------------------------------------------------------------------------- void KSelectionHandler::picked () { KSelectable * selectable; if (picked_pickable->getClassId() >= KSelectable::classId()) { selectable = (KSelectable *)picked_pickable; } else // try to find selectable parent { const KPickable * parent = picked_pickable; while (parent = getParentOfPickable(parent)) { if (parent->getClassId() >= KSelectable::classId()) { break; } } if (!parent) return; selectable = (KSelectable*)parent; } if (selectable->isSelected()) { unselect(selectable); } else { if ((SDL_GetModState() & KMOD_SHIFT) == false) { unselectAll(); } select(selectable); } }
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) { if( aItem->IsSelected() ) { unselect( aItem ); // Inform other potentially interested tools m_toolMgr->ProcessEvent( UnselectedEvent ); } else { if( !m_additive ) clearSelection(); // Prevent selection of invisible or inactive items if( selectable( aItem ) ) { select( aItem ); // Inform other potentially interested tools m_toolMgr->ProcessEvent( SelectedEvent ); } } }
void Faders::accessFixture(int fixture) { deleteFaders(); if(fixture < m_ptrLightsAvailable->getNumOfFixturesAvailable() && fixture >= 0){ ui->labelFixtureName->setText(m_ptrLightsAvailable->getFixtureName(fixture)); int numberOfFaders = m_ptrLightsAvailable->getNumOfFadersForFixture(fixture); m_SingleFaderArr = new SingleFader[numberOfFaders]; for(int fader = 0; fader < numberOfFaders; fader++) { m_SingleFaderArr[fader].setName(m_ptrLightsAvailable->getFaderName(fixture, fader)); m_SingleFaderArr[fader].setValue(m_LightsStatus.fixtureStatus[fixture].faderValue[fader]); m_SingleFaderArr[fader].setFixtureAndFader(fixture, fader); connect(&m_SingleFaderArr[fader], SIGNAL(valueChanged(int,int,int)), this, SLOT(setFaderFromSlider(int,int,int))); connect(this, SIGNAL(valueChanged(int,int,int)), &m_SingleFaderArr[fader], SLOT(setValue(int,int,int))); ui->horizontalLayout->addWidget(&m_SingleFaderArr[fader]); } emit unselect(GROUP); }
void hWidget::setSelected(bool selFlag) { if(selFlag == true) select(); else unselect(); }
// internal function - interrupt gets called when a packet is received void RFM69::interruptHandler() { #ifdef RASPBERRY unsigned char thedata[67]; char i; for(i = 0; i < 67; i++) thedata[i] = 0; // printf("interruptHandler %d\n", intCount); #endif //pinMode(4, OUTPUT); //digitalWrite(4, 1); if (_mode == RF69_MODE_RX && (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PAYLOADREADY)) { //RSSI = readRSSI(); setMode(RF69_MODE_STANDBY); #ifdef RASPBERRY thedata[0] = REG_FIFO & 0x7F; thedata[1] = 0; // PAYLOADLEN thedata[2] = 0; // TargetID wiringPiSPIDataRW(SPI_DEVICE, thedata, 3); delayMicroseconds(MICROSLEEP_LENGTH); PAYLOADLEN = thedata[1]; PAYLOADLEN = PAYLOADLEN > 66 ? 66 : PAYLOADLEN; // precaution TARGETID = thedata[2]; #else select(); SPI.transfer(REG_FIFO & 0x7F); PAYLOADLEN = SPI.transfer(0); PAYLOADLEN = PAYLOADLEN > 66 ? 66 : PAYLOADLEN; // precaution TARGETID = SPI.transfer(0); #endif if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode || PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this libraries extra fields { PAYLOADLEN = 0; unselect(); receiveBegin(); //digitalWrite(4, 0); return; } #ifdef RASPBERRY DATALEN = PAYLOADLEN - 3; thedata[0] = REG_FIFO & 0x77; thedata[1] = 0; //SENDERID thedata[2] = 0; //CTLbyte; for(i = 0; i< DATALEN; i++) { thedata[i+3] = 0; } wiringPiSPIDataRW(SPI_DEVICE, thedata, DATALEN + 3); SENDERID = thedata[1]; uint8_t CTLbyte = thedata[2]; ACK_RECEIVED = CTLbyte & 0x80; //extract ACK-requested flag ACK_REQUESTED = CTLbyte & 0x40; //extract ACK-received flag for (i= 0; i < DATALEN; i++) { DATA[i] = thedata[i+3]; } #else DATALEN = PAYLOADLEN - 3; SENDERID = SPI.transfer(0); uint8_t CTLbyte = SPI.transfer(0); ACK_RECEIVED = CTLbyte & RFM69_CTL_SENDACK; // extract ACK-received flag ACK_REQUESTED = CTLbyte & RFM69_CTL_REQACK; // extract ACK-requested flag interruptHook(CTLbyte); // TWS: hook to derived class interrupt function for (uint8_t i = 0; i < DATALEN; i++) { DATA[i] = SPI.transfer(0); } #endif if (DATALEN < RF69_MAX_DATA_LEN) DATA[DATALEN] = 0; // add null at end of string unselect(); setMode(RF69_MODE_RX); } RSSI = readRSSI(); //digitalWrite(4, 0); }
void LtsManager::zoomInAbove(Cluster *cluster) { unselect(); m_lts = m_lts->zoomIntoAbove(cluster); emit ltsZoomed(m_lts); }
void LtsManager::zoomInBelow(Cluster *cluster) { unselect(); m_lts = m_lts->zoomIntoBelow(cluster); emit ltsZoomed(m_lts); }