本文整理汇总了C++中setBit函数的典型用法代码示例。如果您正苦于以下问题:C++ setBit函数的具体用法?C++ setBit怎么用?C++ setBit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setBit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:DArtagan,项目名称:electricsheep,代码行数:13,代码来源:Renderer.cpp
示例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
}
开发者ID:ajinkyagorad,项目名称:atmega128aDev,代码行数:22,代码来源:OLED.cpp
示例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;
}
开发者ID:mammothbane,项目名称:wufs,代码行数:18,代码来源:mkfs.wufs.c
示例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;
}
开发者ID:aforren1,项目名称:finger-6,代码行数:42,代码来源:ADC_Module.cpp
示例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);
}
开发者ID:jreinholm,项目名称:TimelapsePlus-Firmware,代码行数:13,代码来源:hardware.cpp
示例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++;
}
}
开发者ID:lukes611,项目名称:phdThesis,代码行数:13,代码来源:BitReaderWriter.cpp
示例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;
}
开发者ID:victorisildur,项目名称:noxim,代码行数:22,代码来源:ProcessingElement.cpp
示例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);
}
开发者ID:MuazSalah,项目名称:beagleboneIO,代码行数:13,代码来源:beaglegpiomem.c
示例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);
}
开发者ID:firmlogik,项目名称:xlogik,代码行数:38,代码来源:spi.cpp
示例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;
}
开发者ID:KudeGit,项目名称:elments_of_programming_interview,代码行数:23,代码来源:bit.cpp
示例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);
}
开发者ID:Xerxes004,项目名称:steganographizer,代码行数:19,代码来源:Steg.cpp
示例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;
}
开发者ID:AlexKraemer,项目名称:RFID_ME_HW_GUI,代码行数:14,代码来源:qwt_plot_curve.cpp
示例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;
}
开发者ID:vineeth001,项目名称:NoximMod,代码行数:23,代码来源:NoximProcessingElement.cpp
示例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...
}
开发者ID:fayce,项目名称:Projet---Tech-Robot-2009,代码行数:14,代码来源:strat.c
示例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);
}
开发者ID:Defrocked,项目名称:CS252,代码行数:23,代码来源:lab6.c
示例16: for
NoximPacket NoximProcessingElement::trafficShuffle()
{
int nbits = (int)log2ceil(
(double)(NoximGlobalParams::mesh_dim_x *
NoximGlobalParams::mesh_dim_y *
NoximGlobalParams::mesh_dim_z ));
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));
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();
// if (p.src_id == p.dst_id)
// cout << "Traffic generator has generated a packet is sent from a node to itself !!! \n";
return p;
}
开发者ID:bniazmand,项目名称:Noxim_Elevator_first,代码行数:23,代码来源:NoximProcessingElement.cpp
示例17: setBit
/* Initialize stuff:
* - Start Vref module
* - Clear all fail flags
* - Internal reference (default: external vcc)
* - Mux between a and b channels (b channels)
* - Calibrate with 32 averages and low speed
* - When first calibration is done it sets:
* - Resolution (default: 10 bits)
* - Conversion speed and sampling time (both set to medium speed)
* - Averaging (set to 4)
*/
void ADC_Module::analog_init() {
// default settings:
/*
- 10 bits resolution
- 4 averages
- vcc reference
- no interrupts
- pga gain=1
- conversion speed = medium
- sampling speed = medium
initiate to 0 (or 1) so the corresponding functions change it to the correct value
*/
analog_res_bits = 0;
analog_max_val = 0;
analog_num_average = 0;
analog_reference_internal = 2;
var_enableInterrupts = 0;
pga_value = 1;
conversion_speed = 0;
sampling_speed = 0;
calibrating = 0;
fail_flag = ADC_ERROR_CLEAR; // clear all errors
num_measurements = 0;
// select b channels
// *ADC_CFG2_muxsel = 1;
setBit(ADC_CFG2, ADC_CFG2_MUXSEL_BIT);
// set reference to vcc
setReference(ADC_REF_3V3);
// set resolution to 10
setResolution(10);
// the first calibration will use 32 averages and lowest speed,
// when this calibration is over the averages and speed will be set to default by wait_for_cal and init_calib will be cleared.
init_calib = 1;
setAveraging(32);
setConversionSpeed(ADC_LOW_SPEED);
setSamplingSpeed(ADC_LOW_SPEED);
// begin init calibration
calibrate();
}
开发者ID:aforren1,项目名称:finger-6,代码行数:60,代码来源:ADC_Module.cpp
示例18: main
//int mgetline(char s[], int lim);
int main() {
unsigned int x;
unsigned char p;
int* x1;
scanf_s("%x\n", &x);
p = getchar();
printf("%x\n", x);
printf("%u\n", p);
x1=setBit(x,p);
printf("%x", x1);
getchar();
return 0;
}
开发者ID:irenams,项目名称:IrenaSt,代码行数:16,代码来源:Zad1(poslednite)(Var2).cpp
示例19: setBit
void CRenderer::Reset( const uint32 _flags )
{
if( isBit( _flags, eShader ) )
m_spSelectedShader = NULL;
if( isBit( _flags, eBlend ) )
m_spSelectedBlend = m_BlendMap[ "none" ];
if( isBit( _flags, eTexture ) )
{
for( uint32 i=0; i<MAX_TEXUNIT; i++ )
m_aspSelectedTextures[ i ] = NULL;
}
if( isBit( _flags, eMatrices ) )
{
m_WorldMat.Identity();
m_ViewMat.Identity();
m_ProjMat.Identity();
setBit( m_bDirtyMatrices, eWorld );
setBit( m_bDirtyMatrices, eView );
setBit( m_bDirtyMatrices, eProjection );
}
}
开发者ID:DArtagan,项目名称:electricsheep,代码行数:24,代码来源:Renderer.cpp
示例20: signals
/*Add a single (at least 8x over-) sampling of the data and clock
lines to the circular buffer.
Note: dataVal and clockVal represent a single bit, but need not
actually be 0 or 1-- they can be 0 and 15, or 0 and 3, or whatever.
Analog signals (0,1,2, or 3) are even OK.
*/
void JRS_PCM_add_sample(JRS_PCM *p,int clockVal,int dataVal)
{
p->data_bits[p->end]=dataVal;
p->clk_bits[p->end]=clockVal;
p->end++;p->len++;
p->end&=PCM_bit_mask;
if (p->len>16)
{/*We have a long string of data and clock bits-- cut them back a bit*/
int trough=clock_trough(p);
setBit(p,extract_bit(p,trough));
p->len=PCM_bit_mask&(p->end-trough);/*Set the new end-of-buffer to the clock trough*/
p->prevTrough=trough;
}
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:22,代码来源:aux_JRS_PCM.c
注:本文中的setBit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论