本文整理汇总了C++中setBit函数的典型用法代码示例。如果您正苦于以下问题:C++ setBit函数的具体用法?C++ setBit怎么用?C++ setBit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setBit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CRenderer::SetTransform( const Base::Math::CMatrix4x4 &_transform, const eMatrixTransformType _type )
{
switch( _type )
{
case eWorld: m_WorldMat = _transform; break;
case eView: m_ViewMat = _transform; break;
case eProjection: m_ProjMat = _transform; break;
default:
g_Log->Warning( "Unknown transformation type..." );
}
setBit( m_bDirtyMatrices, _type );
}
示例2: clrBit
unsigned char OLED::read(void)
{
char data=0;
clrBit(OLED_scl_port,OLED_scl_pin);
setBit(OLED_sda_port,OLED_sda_pin); //make sda high
clrBit(OLED_sda_port,OLED_sda_pin); //make sda input
for(int i=0 ; i<8 ;i++)
{
//make scl high
setBit(OLED_scl_port,OLED_scl_pin);
_delay_us(usDelay);//delay
if(ifHigh(OLED_sda_read,OLED_sda_pin)) //check if sda then update data
{
data|=0x01;
}
clrBit(OLED_scl_port,OLED_scl_pin); //make scl low
_delay_us(usDelay); //delay
data=data<<1; //left shift data
}
//not sending ack!!
return data; //return data
}
示例3: allocBlock
/*
* Find (add allocate) a free data block.
* The approach simply involves a scan of the block map for a zero.
* It's fatal, at this point, if none is found.
*/
int allocBlock(void)
{
int block = findNextClear(BMap, SB->sb_first_block, SB->sb_blocks);
if (block == -1) {
fprintf(stderr,"Could not allocate free data block (necessary).\n");
exit(1);
}
/* mark it as allocated */
setBit(BMap,block);
return block;
}
示例4: clearBit
/* Set the number of averages: 0, 4, 8, 16 or 32.
*
*/
void ADC_Module::setAveraging(uint8_t num) {
if (calibrating) wait_for_cal();
if (num <= 1) {
num = 0;
// *ADC_SC3_avge = 0;
clearBit(ADC_SC3, ADC_SC3_AVGE_BIT);
} else {
// *ADC_SC3_avge = 1;
setBit(ADC_SC3, ADC_SC3_AVGE_BIT);
if (num <= 4) {
num = 4;
// *ADC_SC3_avgs0 = 0;
// *ADC_SC3_avgs1 = 0;
clearBit(ADC_SC3, ADC_SC3_AVGS0_BIT);
clearBit(ADC_SC3, ADC_SC3_AVGS1_BIT);
} else if (num <= 8) {
num = 8;
// *ADC_SC3_avgs0 = 1;
// *ADC_SC3_avgs1 = 0;
setBit(ADC_SC3, ADC_SC3_AVGS0_BIT);
clearBit(ADC_SC3, ADC_SC3_AVGS1_BIT);
} else if (num <= 16) {
num = 16;
// *ADC_SC3_avgs0 = 0;
// *ADC_SC3_avgs1 = 1;
clearBit(ADC_SC3, ADC_SC3_AVGS0_BIT);
setBit(ADC_SC3, ADC_SC3_AVGS1_BIT);
} else {
num = 32;
// *ADC_SC3_avgs0 = 1;
// *ADC_SC3_avgs1 = 1;
setBit(ADC_SC3, ADC_SC3_AVGS0_BIT);
setBit(ADC_SC3, ADC_SC3_AVGS1_BIT);
}
}
analog_num_average = num;
}
示例5: hardware_light_enable
void hardware_light_enable(uint8_t level)
{
hardware_flashlight(0);
if(level > 2)
level = 2;
DDRA &= ~0b00000111; // clear all //
PORTA &= ~0b00000111; // clear all //
setBit(level, DDRA); // Powers Sensor //
clrBit(level, PORTA);
}
示例6: setBit
void BitWriter::addBit(LBit input)
{
setBit(work_on, bitPointer, input);
bitPointer++;
if(bitPointer >= 8)
{
data->push_back(work_on);
work_on = 0x00;
bitPointer = 0;
dataSize++;
}
}
示例7: log2ceil
Packet ProcessingElement::trafficShuffle()
{
int nbits =
(int)
log2ceil((double)
(GlobalParams::mesh_dim_x *
GlobalParams::mesh_dim_y));
int dnode = 0;
for (int i = 0; i < nbits - 1; i++)
setBit(dnode, i + 1, getBit(local_id, i));
setBit(dnode, 0, getBit(local_id, nbits - 1));
Packet p;
p.src_id = local_id;
p.dst_id = dnode;
p.timestamp = sc_time_stamp().to_double() / GlobalParams::clock_period_ps;
p.size = p.flit_left = getRandomSize();
return p;
}
示例8: digitalWrite
void digitalWrite(const PIN pin, unsigned int value) {
unsigned long addr;
unsigned long bitMask;
pinToMem(pin, &addr, &bitMask);
unsigned long reg = getReg(addr + GPIO_DATAOUT);
if (value)
reg = setBit(reg, bitMask);
else
reg = clearBit(reg, bitMask);
setReg(addr + GPIO_DATAOUT,reg);
}
示例9: switch
Cspi::Cspi(u08 spiNum, Cpin* _pinSS, SPI_INTLVL_t _intLevel,
SPI_PRESCALER_t _prescaler, SPI_MODE_t _mode, bool msbFirst,
bool master, bool clk2X) {
switch (spiNum) {
case 0:
base = &SPIC;
break;
case 1:
base = &SPID;
break;
default:
while (1) {
}
break;
}
this->pinSS = _pinSS;
this->intLevel = _intLevel;
this->mode = _mode;
setGroup(base->INTCTRL, SPI_INTLVL_gm, _intLevel);
setGroup(base->CTRL, SPI_PRESCALER_gm, _prescaler);
setGroup(base->CTRL, SPI_MODE_gm, _mode);
if (msbFirst) {
clrBit(base->CTRL, SPI_DORD_bp);
} else {
setBit(base->CTRL, SPI_DORD_bp);
}
if (master) {
setBit(base->CTRL, SPI_MASTER_bp);
} else {
clrBit(base->CTRL, SPI_MASTER_bp);
}
if (clk2X) {
setBit(base->CTRL, SPI_CLK2X_bp);
} else {
clrBit(base->CTRL, SPI_CLK2X_bp);
}
setBit(base->CTRL, SPI_ENABLE_bp);
}
示例10: test
int test (void)
{
size_t a = 0;
for (size_t i = 0; i < 8*sizeof(a); ++i) {
setBit(a, i, true);
if (a != (0x01llu << i)) {
std::cout << "error setting bit " << i << " to true " << std::endl;
}
printBit(a);
a = 0;
}
return 0;
a = ~0;
for (size_t i = 0; i < 8*sizeof(a); ++i) {
setBit(a, i, false);
if (a != (~(0x01llu << i))) {
std::cout << "error setting bit " << i << " to true " << std::endl;
}
a = ~0;
}
return 0;
}
示例11: read
/**
* Scrubs an image of all secret messages so you can hide your tracks!
*
* @param image the image to scrub
*/
void Steg::scrub(const std::string &image)
{
std::vector<char> scrubbedBytes;
read(scrubbedBytes, image);
auto throwOut = getHeaderSize(scrubbedBytes);
for (int i = throwOut; i < scrubbedBytes.size(); i++)
{
// set all low-order bits to 1
setBit(scrubbedBytes.at(i), 0, 1);
}
write(scrubbedBytes, image);
}
示例12: testPixel
inline bool testPixel(const QPoint& pos)
{
if ( !_rect.contains(pos) )
return false;
const int idx = _rect.width() * (pos.y() - _rect.y()) +
(pos.x() - _rect.x());
const bool marked = testBit(idx);
if ( !marked )
setBit(idx, true);
return !marked;
}
示例13: log2ceil
NoximPacket NoximProcessingElement::trafficButterfly()
{
int nbits =
(int)
log2ceil((double)
(NoximGlobalParams::mesh_dim_x *
NoximGlobalParams::mesh_dim_y));
int dnode = 0;
for (int i = 1; i < nbits - 1; i++)
setBit(dnode, i, getBit(local_id, i));
setBit(dnode, 0, getBit(local_id, nbits - 1));
setBit(dnode, nbits - 1, getBit(local_id, 0));
NoximPacket p;
p.src_id = local_id;
p.dst_id = dnode;
p.timestamp = sc_time_stamp().to_double() / 1000;
p.size = p.flit_left = getRandomSize();
return p;
}
示例14: strat_init
void strat_init(struct strategy * strat){
strat->flags = 0;
strat->loaded_elts = 0;
rand_disp_position=0;
strat_flags=0;
setBit(strat_flags,LINT_IS_LOADED); //we got one at the beginning...
//Strat_State = STRAT_GET_ELT_ON_TABLE;
/*everything is fucked up ... playing with emergency behaviour :'( */
Strat_State = STRAT_EMERGENCY_BEHAVIOUR;
current_building_area = 1; //we start by building in our area...
}
示例15: main
int main(){
int x;
bitSet bs = makeBitSet();
printf("display test \n");
displayBitSet(bs);
printf("set test \n");
setBit(&bs, 3);
displayBitSet(bs);
setBit(&bs, 5);
displayBitSet(bs);
printf("value test \n");
x = bitValue(bs, 3);
printf("bit value: %d \n", x);
x = bitValue(bs, 2);
printf("bit value: %d \n", x);
printf("bit clear test \n");
clearBit(&bs, 3);
displayBitSet(bs);
}