void Block::remove(uint32_t type) { resetWire(); auto it = std::remove_if(m_subBlocks.begin(), m_subBlocks.end(), [type] (const Block& subBlock) { return subBlock.type() == type; }); m_subBlocks.resize(it - m_subBlocks.begin()); }
char readDHT11(char mode) { long poc=0; int j,i; char data[5]; for(i=0;i<5;i++) data[i] = 0; //startovaci signal pre prenos PORTX = LOW; delay_ms(20); PORTX = HIGH; delay_us(1); DDRX = INPUT; //test komunikacie od dht11 TCNT0 = 0; while(PINX == 1) if(TCNT0 > 50){ resetWire(); return DHT11_ERROR;} TCNT0 = 0; while(PINX == 0) if(TCNT0 > 180){ resetWire(); return DHT11_ERROR;} TCNT0 = 0; while(PINX == 1) if(TCNT0 > 180){ resetWire(); return DHT11_ERROR;} //-------------------------- for(i=0;i<5;i++){ for(j=7;j>=0;j--){ TCNT0 = 0; while(PINX == 0) if(TCNT0 > 120){ resetWire(); return DHT11_ERROR; } TCNT0 = 0; while(PINX == 1) if(TCNT0 > 180){ resetWire(); return DHT11_ERROR;} if(TCNT0 > 90) data[i]|=1<<j; } } resetWire(); if((data[0]+data[1]+data[2]+data[3]) != data[4])return DHT11_ERROR; if (mode == 't') return data[2]; else return data[0]; }
Block::element_iterator Block::insert(Block::element_const_iterator pos, const Block& element) { resetWire(); #ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR return m_subBlocks.insert(pos, element); #else element_iterator it = m_subBlocks.begin(); std::advance(it, std::distance(m_subBlocks.cbegin(), pos)); return m_subBlocks.insert(it, element); #endif }
Block::element_iterator Block::erase(Block::element_const_iterator position) { resetWire(); #ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR return m_subBlocks.erase(position); #else element_iterator it = m_subBlocks.begin(); std::advance(it, std::distance(m_subBlocks.cbegin(), position)); return m_subBlocks.erase(it); #endif }
Block::element_iterator Block::erase(Block::element_const_iterator first, Block::element_const_iterator last) { resetWire(); #ifdef NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR return m_subBlocks.erase(first, last); #else element_iterator itStart = m_subBlocks.begin(); element_iterator itEnd = m_subBlocks.begin(); std::advance(itStart, std::distance(m_subBlocks.cbegin(), first)); std::advance(itEnd, std::distance(m_subBlocks.cbegin(), last)); return m_subBlocks.erase(itStart, itEnd); #endif }
inline void Block::push_back(const Block& element) { resetWire(); m_subBlocks.push_back(element); }
inline Block::element_iterator Block::erase(Block::element_iterator first, Block::element_iterator last) { resetWire(); return m_subBlocks.erase(first, last); }
inline Block::element_iterator Block::erase(Block::element_iterator position) { resetWire(); return m_subBlocks.erase(position); }