本文整理汇总了C++中writeTo函数的典型用法代码示例。如果您正苦于以下问题:C++ writeTo函数的具体用法?C++ writeTo怎么用?C++ writeTo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeTo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initAcc
/* =================================================
FUNCTION: initAcc
CREATED: 16-05-2014
DESCRIPTION: initializes the sensor
PARAMETERS: None
GLOBAL VARIABLES: None.
RETURNS: None.
AUTHOR: P. Kantue
================================================== */
void initAcc() {
//Turning on the ADXL345
writeTo(ACC, 0x2D, 0);
writeTo(ACC, 0x2D, 16);
writeTo(ACC, 0x2D, 8);
//by default the device is in +-2g range reading
}
示例2: initGyro
/* =================================================
FUNCTION: initGyro
CREATED: 16-05-2014
DESCRIPTION: initializes the sensor
PARAMETERS: None
GLOBAL VARIABLES: None.
RETURNS: None.
AUTHOR: P. Kantue
================================================== */
void initGyro()
{
writeTo(GYRO, G_PWR_MGM, 0x00);
writeTo(GYRO, G_SMPLRT_DIV, 0x07); // EB, 50, 80, 7F, DE, 23, 20, FF
writeTo(GYRO, G_DLPF_FS, 0x1E); // Full Scale Range +/- 2000 deg/sec, 1KHz, 1E, 19
writeTo(GYRO, G_INT_CFG, 0x00);
}
示例3: bus
void Accelerometer::powerOn() {
Wire.begin(); // join i2c bus (address optional for master)
//Turning on the ADXL345
writeTo(DEVICE, ADXL345_POWER_CTL, 0);
writeTo(DEVICE, ADXL345_POWER_CTL, 16);
writeTo(DEVICE, ADXL345_POWER_CTL, 8);
}
示例4: begin
void CAdxl345::powerOn() {
begin(); // enable I2C Bus
//Turning on the ADXL345
writeTo(DEVICE, ADXL345_POWER_CTL, 0);
writeTo(DEVICE, ADXL345_POWER_CTL, 16);
writeTo(DEVICE, ADXL345_POWER_CTL, 8);
}
示例5: writeTo
void Sensors::initMagnetometer()
{
// Enable the magnetometer
writeTo(HMC5883_ADDRESS_MAG, HMC5883_REGISTER_MAG_MR_REG_M, 0x00);
// Set the gain to +/-1.3 (max sensitivity)
writeTo(HMC5883_ADDRESS_MAG, HMC5883_REGISTER_MAG_CRB_REG_M, 0x20);
}
示例6: be_child
/* does not return */
void be_child(int fd_from_master, int fd_to_master) {
int start = 0, end = 0;
while (1) {
writeTo(fd_to_master, &start);
writeTo(fd_to_master, &end);
/* got EOF from master = exit */
if (readFrom(fd_from_master, &start) == 0) exit(0);
if (readFrom(fd_from_master, &end) == 0) exit(0);
doit(start, end);
}
}
示例7: writeTo
void IMU3000::setSampleRate(byte divider, byte lowpass)
{
//writing divider
writeTo(IMU3000_REG_SMPLRT_DIV,divider);
//writing lowpass rate freq
byte lpf;
readFrom(IMU3000_REG_DLPF, 1, &lpf);
lpf &= ~IMU3000_DLPF_CFG_MASK;
lpf |= lowpass;
writeTo(IMU3000_REG_DLPF, lpf);
}
示例8: writeTo
ISCORE_PLUGIN_SCENARIO_EXPORT void Visitor<Writer<DataStream>>::writeTo(Scenario::StateModel& s)
{
// Common metadata
writeTo(s.metadata);
m_stream >> s.m_eventId
>> s.m_previousConstraint
>> s.m_nextConstraint
>> s.m_heightPercentage;
// Message tree
Process::MessageNode n;
m_stream >> n;
s.m_messageItemModel = new Scenario::MessageItemModel{s.m_stack, s, &s};
s.messages() = n;
// Processes plugins
int32_t process_count;
m_stream >> process_count;
auto& pl = context.components.factory<Process::StateProcessList>();
for(; process_count -- > 0;)
{
s.stateProcesses.add(deserialize_interface(pl, *this, &s));
}
checkDelimiter();
}
示例9: getValue
std::string Element::toString() const {
if (!ok())
return "INVALID-MUTABLE-ELEMENT";
if (hasValue())
return getValue().toString();
const BSONType type = getType();
// The only types that sometimes don't have a value are Object and Array nodes.
dassert((type == mongo::Object) || (type == mongo::Array));
if (type == mongo::Object) {
BSONObjBuilder builder;
writeTo(&builder);
BSONObj obj = builder.obj();
return obj.firstElement().toString();
} else {
// It must be an array.
BSONObjBuilder builder;
BSONArrayBuilder arrayBuilder(builder.subarrayStart(getFieldName()));
writeArrayTo(&arrayBuilder);
arrayBuilder.done();
BSONObj obj = builder.obj();
return obj.firstElement().toString();
}
}
示例10: writeTo
template<> void Visitor<Writer<JSONObject>>::writeTo(Scenario::BaseScenario& base_scenario)
{
writeTo(static_cast<Scenario::BaseScenarioContainer&>(base_scenario));
Deserializer<JSONValue> elementPluginDeserializer(m_obj["PluginsMetadata"]);
base_scenario.pluginModelList = iscore::ElementPluginModelList{elementPluginDeserializer, &base_scenario};
}
示例11: BYTES_TO_BLOCKS
void Node::resize(NodeSize newSize) {
if (size() == newSize) return;
hasChanged_ = true;
// Flush all data blocks, so that IDs of
// deleted blocks aren't updated incorrectly
// at some later time.
cache_.flush();
const size_t oldBlockCount = BYTES_TO_BLOCKS(size());
const size_t newBlockCount = BYTES_TO_BLOCKS(newSize);
// Set the size field.
BlockWriter sizeWriter(cache_.getWriteBlock(BlockPath::Root()), NODE_SIZE_OFFSET);
Binary::WriteUint64(sizeWriter, newSize);
size_ = newSize;
// Replace block IDs with zero for deleted blocks.
if (oldBlockCount > newBlockCount) {
const auto zeroId = BlockId::Zero();
for (size_t i = newBlockCount; i < oldBlockCount; i++) {
const auto path = BlockPath::Index(i);
auto& parentBlock = cache_.getWriteBlock(path.parent());
BlockWriter writer(parentBlock, NodeBlockIdOffset(path));
zeroId.writeTo(writer);
}
}
}
示例12: MYASSERT
int ITG3200::setClockSource(byte _CLKsource) {
int a=0;
a=readFrom( _dev_address,PWR_MGM, 1, &_buff[0]);
MYASSERT(a,"Failed to read clock source\n\r")
a=writeTo( _dev_address,PWR_MGM, ((_buff[0] & ~PWRMGM_CLK_SEL) | _CLKsource));
MYASSERT(a,"Failed to write clock source\n\r")
return 0;
}
示例13: readFrom
void CAdxl345::setRegisterBit(byte regAdress, int bitPos, bool state) {
byte _b;
readFrom(DEVICE, regAdress, 1, &_b);
if (state) {
_b |= (1 << bitPos); // forces nth bit of _b to be 1. all other bits left alone.
} else {
_b &= ~(1 << bitPos); // forces nth bit of _b to be 0. all other bits left alone.
}
writeTo(DEVICE, regAdress, _b);
}
示例14: readFrom
void IMU3000::setRange(byte range)
{
byte rng;
readFrom(IMU3000_REG_DLPF, 1, &rng);
rng &= ~IMU3000_FS_SEL_MASK;
rng |= range;
writeTo(IMU3000_REG_DLPF, rng);
}
示例15: writeTo
/*
* setGain method:
* set HMC5883L_SCALE_FACTOR based on 'fieldRange' value
* write to HMC5883L_ConfigurationRegisterB register the appropriate value for the specified 'fieldRange'
*/
void HMC5883L::setGain(float fieldRange)
{
if (fieldRange==0.88) // Nominal gain configuration (HMC5883L_ConfigurationRegisterB)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 1370.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0x00);
}
else if (fieldRange==1.3)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 1090.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0x20);
}
else if (fieldRange==1.9)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 820.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0x40);
}
else if (fieldRange==2.5)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 660.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0x60);
}
else if (fieldRange==4.0)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 440.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0x80);
}
else if (fieldRange==4.7)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 390.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0xA0);
}
else if (fieldRange==5.6)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 330.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0xC0);
}
else if (fieldRange==8.1)
{
HMC5883L_SCALE_FACTOR = (1000.0f / 230.0f);
writeTo(HMC5883L_ConfigurationRegisterB, 0xE0);
}
else // out of range - return to defaults // default configuration: field range 1.3Ga
{
HMC5883L_SCALE_FACTOR = (1000 / 1090);
writeTo(HMC5883L_ConfigurationRegisterB, 0x20);
}
}