本文整理汇总了C++中setGain函数的典型用法代码示例。如果您正苦于以下问题:C++ setGain函数的具体用法?C++ setGain怎么用?C++ setGain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setGain函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setGain
void UI::actionGain(int g) {
QString command;
setGain(false);
gain=g;
subRxGain=g;
setGain(true);
command.clear(); QTextStream(&command) << "SetRXOutputGain " << g;
connection.sendCommand(command);
command.clear(); QTextStream(&command) << "SetSubRXOutputGain " << g;
connection.sendCommand(command);
}
示例2: setTiming
boolean TSL2561::begin(void) {
Wire.begin();
// Initialise I2C
Wire.beginTransmission(_addr);
#if ARDUINO >= 100
Wire.write(TSL2561_REGISTER_ID);
#else
Wire.send(TSL2561_REGISTER_ID);
#endif
Wire.endTransmission();
Wire.requestFrom(_addr, 1);
#if ARDUINO >= 100
int x = Wire.read();
#else
int x = Wire.receive();
#endif
//Serial.print("0x"); Serial.println(x, HEX);
if (x & 0x0A ) {
//Serial.println("Found TSL2561");
} else {
return false;
}
_initialized = true;
// Set default integration time and gain
setTiming(_integration);
setGain(_gain);
// Note: by default, the device is in power down mode on bootup
disable();
return true;
}
示例3: read8
boolean Adafruit_TSL2591::begin(void)
{
Wire.begin();
/*
for (uint8_t i=0; i<0x20; i++)
{
uint8_t id = read8(0x12);
Serial.print("$"); Serial.print(i, HEX);
Serial.print(" = 0x"); Serial.println(read8(i), HEX);
}
*/
uint8_t id = read8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID);
if (id == 0x50 )
{
//Serial.println("Found Adafruit_TSL2591");
}
else
{
return false;
}
_initialized = true;
// Set default integration time and gain
setTiming(_integration);
setGain(_gain);
// Note: by default, the device is in power down mode on bootup
disable();
return true;
}
示例4: delayMicroseconds
/** Power on and prepare for general usage.
* This will prepare the magnetometer with default settings, ready for single-
* use mode (very low power requirements). Default settings include 8-sample
* averaging, 15 Hz data output rate, normal measurement bias, a,d 1090 gain (in
* terms of LSB/Gauss). Be sure to adjust any settings you need specifically
* after initialization, especially the gain settings if you happen to be seeing
* a lot of -4096 values (see the datasheet for mor information).
*/
void HMC5883L::initialize() {
// We need to wait a bit...
delayMicroseconds(HMC5883L_READY_FOR_I2C_COMMAND);
// write CONFIG_A register
I2Cdev::writeByte(devAddr, HMC5883L_RA_CONFIG_A,
(HMC5883L_AVERAGING_8 << (HMC5883L_CRA_AVERAGE_BIT - HMC5883L_CRA_AVERAGE_LENGTH + 1)) |
(HMC5883L_RATE_15 << (HMC5883L_CRA_RATE_BIT - HMC5883L_CRA_RATE_LENGTH + 1)) |
(HMC5883L_BIAS_NORMAL << (HMC5883L_CRA_BIAS_BIT - HMC5883L_CRA_BIAS_LENGTH + 1)));
// write CONFIG_B register
setGain(HMC5883L_GAIN_1090);
// write MODE register
setMode(HMC5883L_MODE_SINGLE);
// TODO: Maybe it would be a good idea to use the EEPROM
// to store the scale factors and recover the last valid
// value in case of a calibration fail.
for (uint8_t gain = HMC5883L_GAIN_1370; gain <= HMC5883L_GAIN_220; gain ++) {
scaleFactors[gain][0] = 1.0f;
scaleFactors[gain][1] = 1.0f;
scaleFactors[gain][2] = 1.0f;
}
}
示例5: setGain
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
setGain(getGain());
if (demodulatorPreThread) {
std::string currentDemodType = demodulatorPreThread->getDemodType();
if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
}
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
activeOutput->Hide();
}
#endif
demodulatorPreThread->setDemodType(demod_type_in);
int lastbw = 0;
if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
lastbw = lastModemBandwidth[demod_type_in];
}
if (!lastbw) {
lastbw = Modem::getModemDefaultSampleRate(demod_type_in);
}
if (lastbw) {
setBandwidth(lastbw);
}
}
}
示例6: fopen
void Stream::loadOgg(const char *filename)
{
sound = filename;
file = fopen(filename, "rb");
if (!file)
throw RubyException(rb_eRuntimeError, "Cannot open the stream file.");
ov_open(file, &stream, NULL, 0);
info = ov_info(&stream, -1);
comment = ov_comment(&stream, -1);
format = SAMPLES_FORMAT;
alGenBuffers(2, buffers);
if (alGetError() != AL_NO_ERROR)
throw RubyException(rb_eRuntimeError, "Cannot generate the buffer.");
generateSource();
if (alGetError() != AL_NO_ERROR)
throw RubyException(rb_eRuntimeError, "Cannot generate sources.");
setPos(0.f, 0.f, 0.f);
setVelocity(0.f, 0.f, 0.f);
setDirection(0.f, 0.f, 0.f);
setPitch(1.f);
setGain(1.f);
}
示例7: writeReg
/*
Calibrate which has a few weaknesses.
1. Uses wrong gain for first reading.
2. Uses max instead of max of average when normalizing the axis to one another.
3. Doesn't use neg bias. (possible improvement in measurement).
*/
void HMC58X3::calibrate(unsigned char gain) {
x_scale=1; // get actual values
y_scale=1;
z_scale=1;
writeReg(HMC58X3_R_CONFA, 0x010 + HMC_POS_BIAS); // Reg A DOR=0x010 + MS1,MS0 set to pos bias
setGain(gain);
float x, y, z, mx=0, my=0, mz=0, t=10;
for (int i=0; i<(int)t; i++) {
setMode(1);
getValues(&x,&y,&z);
if (x>mx) mx=x;
if (y>my) my=y;
if (z>mz) mz=z;
}
float max=0;
if (mx>max) max=mx;
if (my>max) max=my;
if (mz>max) max=mz;
x_max=mx;
y_max=my;
z_max=mz;
x_scale=max/mx; // calc scales
y_scale=max/my;
z_scale=max/mz;
writeReg(HMC58X3_R_CONFA, 0x010); // set RegA/DOR back to default
} // calibrate().
示例8: setTiming
/*
Function:
Returns:
Parameters:
Values:
*/
boolean WaspSensorAmbient::begin(void)
{
Wire.begin();
// Initialise I2C
Wire.beginTransmission(_addr);
Wire.send(TSL2561_REGISTER_ID);
Wire.endTransmission();
Wire.requestFrom(_addr, 1);
int x = Wire.receive();
if (x & 0x0A )
{}
else
{
return false;
}
_initialized = true;
// Set default integration time and gain
setTiming(_integration);
setGain(_gain);
// Note: by default, the device is in power down mode on bootup
disable();
return true;
}
示例9: begin
int8_t Magnetometer::begin()
{
uint8_t buff[3];
i2cAddr_ = HMC5833L_I2CADD;
// Join the I2C bus as master
WIRE.begin();
// read the ID registers
if (i2cReadBytes(HMC5833L_REG_IDA, buff, 3) != 0)
return HMC5833L_ERROR_I2CREAD;
// compare the ID registers
if (buff[0] != HMC5833L_REG_IDA_ID || buff[1] != HMC5833L_REG_IDB_ID
|| buff[2] != HMC5833L_REG_IDC_ID)
return HMC5833L_ERROR_WRONG_ID;
// set data rate speed to 30hz
if (i2cWriteByte(HMC5833L_REG_CFGA, 0x14) != 0)
return HMC5833L_ERROR_I2CWRITE;
// set to continuous mode
// single mode not supported by lib
if (i2cWriteByte(HMC5833L_REG_MODE, 0) != 0)
return HMC5833L_ERROR_I2CWRITE;
// set default gain
if (setGain(HMC5833L_GAIN_1090) != 0)
return HMC5833L_ERROR_I2CWRITE;
return 0;
}
示例10: read8
boolean Adafruit_TCS34725::begin(void)
{
if (_juliaspinSet == 0)
{
Wire.begin(I2C_SLAVE, 0x43, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_100);
} else {
Wire1.begin(I2C_SLAVE, 0x43, I2C_PINS_29_30, I2C_PULLUP_EXT, I2C_RATE_100);
}
/* Make sure we're actually connected */
uint8_t x = read8(TCS34725_ID);
if ((x != 0x44) && (x != 0x10))
{
return false;
}
_tcs34725Initialised = true;
/* Set default integration time and gain */
setIntegrationTime(_tcs34725IntegrationTime);
setGain(_tcs34725Gain);
/* Note: by default, the device is in power down mode on bootup */
enable();
return true;
}
示例11: switch
void MasterSynthesizer::setState(const SynthesizerState& ss)
{
for (const SynthesizerGroup& g : ss) {
if (g.name() == "master") {
for (const IdValue& v : g) {
switch (v.id) {
case 0:
setEffect(0, indexOfEffect(0, v.data));
break;
case 1:
setEffect(1, indexOfEffect(1, v.data));
break;
case 2: {
float f = v.data.toDouble();
setGain(f);
}
break;
}
}
}
else {
Synthesizer* s = synthesizer(g.name());
if (s)
s->setState(g);
else {
if (effect(0) && effect(0)->name() == g.name())
effect(0)->setState(g);
else if (effect(1) && effect(1)->name() == g.name())
effect(1)->setState(g);
}
}
}
}
示例12: biquadConfigurationImplementation
void IIRFilter::configureBiquad(int type, double frequency, double dbGain, double q) {
double a0, a1, a2, b0, b1, b2;
biquadConfigurationImplementation(sr, type, frequency, dbGain, q, b0, b1, b2, a0, a1, a2);
double numerator[] = {1, b1/b0, b2/b0};
double denominator[] = {1, a1/a0, a2/a0};
configure(3, numerator, 3, denominator);
setGain(b0/a0);
}
示例13: setInput
void AtemAudioGainCommand::readProperties(boost::property_tree::wptree& pt)
{
AbstractCommand::readProperties(pt);
setInput(QString::fromStdWString(pt.get(L"audiogaininput", Atem::DEFAULT_AUDIO_INPUT.toStdWString())));
setGain(pt.get(L"gain", Atem::DEFAULT_AUDIO_GAIN));
setTriggerOnNext(pt.get(L"triggeronnext", Atem::DEFAULT_TRIGGER_ON_NEXT));
}
示例14: setGain
// gain: Gain value
bool AnalogInput::setSlotGain(const Basic::Number* const msg)
{
bool ok = false;
if (msg != nullptr) {
ok = setGain( msg->getReal() );
}
return ok;
}
示例15: setGain
void KRAudioSource::loadXML(tinyxml2::XMLElement *e)
{
m_audio_sample_name = e->Attribute("sample");
float gain = 1.0f;
if(e->QueryFloatAttribute("gain", &gain) != tinyxml2::XML_SUCCESS) {
gain = 1.0f;
}
setGain(gain);
float pitch = 1.0f;
if(e->QueryFloatAttribute("pitch", &pitch) != tinyxml2::XML_SUCCESS) {
pitch = 1.0f;
}
setPitch(m_pitch);
bool looping = false;
if(e->QueryBoolAttribute("looping", &looping) != tinyxml2::XML_SUCCESS) {
looping = false;
}
setLooping(looping);
bool is3d = true;
if(e->QueryBoolAttribute("is3d", &is3d) != tinyxml2::XML_SUCCESS) {
is3d = true;
}
setIs3D(is3d);
float reference_distance = 1.0f;
if(e->QueryFloatAttribute("reference_distance", &reference_distance) != tinyxml2::XML_SUCCESS) {
reference_distance = 1.0f;
}
setReferenceDistance(reference_distance);
float reverb = 0.0f;
if(e->QueryFloatAttribute("reverb", &reverb) != tinyxml2::XML_SUCCESS) {
reverb = 0.0f;
}
setReverb(reverb);
float rolloff_factor = 2.0f;
if(e->QueryFloatAttribute("rolloff_factor", &rolloff_factor) != tinyxml2::XML_SUCCESS) {
rolloff_factor = 2.0f;
}
setRolloffFactor(rolloff_factor);
m_enable_obstruction = true;
if(e->QueryBoolAttribute("enable_obstruction", &m_enable_obstruction) != tinyxml2::XML_SUCCESS) {
m_enable_obstruction = true;
}
m_enable_occlusion = true;
if(e->QueryBoolAttribute("enable_occlusion", &m_enable_occlusion) != tinyxml2::XML_SUCCESS) {
m_enable_occlusion = true;
}
KRNode::loadXML(e);
}