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); }
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; }
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; }
/** 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; } }
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); } } }
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); }
/* 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().
/* 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; }
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; }
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; }
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); } } } }
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); }
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)); }
// gain: Gain value bool AnalogInput::setSlotGain(const Basic::Number* const msg) { bool ok = false; if (msg != nullptr) { ok = setGain( msg->getReal() ); } return ok; }
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); }
void TCS34725Driver::initialize() { setGain(gain_1); setIntegrationTime(time_700ms); setPower(true); // power up cycle with 2,4 ms integration time is 2,4 ms QThread::msleep(3); setAENbit(true); }
/** Power on and prepare for general usage. * This device is ready to use automatically upon power-up. It defaults to * single-shot read mode, P0/N1 mux, 2.048v gain, 128 samples/sec, default * comparator with hysterysis, active-low polarity, non-latching comparator, * and comparater-disabled operation. */ void ADS1115::initialize() { setMultiplexer(ADS1115_MUX_P0_N1); setGain(ADS1115_PGA_2P048); setMode(ADS1115_MODE_SINGLESHOT); setRate(ADS1115_RATE_128); setComparatorMode(ADS1115_COMP_MODE_HYSTERESIS); setComparatorPolarity(ADS1115_COMP_POL_ACTIVE_LOW); setComparatorLatchEnabled(ADS1115_COMP_LAT_NON_LATCHING); setComparatorQueueMode(ADS1115_COMP_QUE_DISABLE); }
void TCS3414CS_init() { setIntegrationTime(I2C_TCS3414CS_INTEGRATION_TIME); setGain(I2C_TCS3414CS_GAIN|I2C_TCS3414CS_PRESCALER); setEnableADC(); _delay_ms(400); #ifdef DEBUG_I2C debug_printf("I2C: i2c_tcs3414cs: init done\n"); #endif }
void SoundEmitter::play(float inTime, float outTime) { float zero = 0; m_origGain = m_internData.volume; if (!Mathf::Equal(zero, inTime)) { m_fadeIn = true; setGain(0.0f); play(); m_fadeInStartTimestamp = m_internData.playTimestamp; m_fadeInEndTimestamp = m_fadeInStartTimestamp + static_cast<uint32_t>(inTime * 1000.0f); } if (getState() != SD_PLAYING_STATE) { play(); } if (!Mathf::Equal(zero, outTime)) { m_fadeOut = true; setGain(0.0f); m_fadeOutEndTimestamp = m_internData.playTimestamp + getDuration(); m_fadeOutStartTimestamp = m_fadeOutEndTimestamp - static_cast<uint32_t>(outTime * 1000.0f); } }
/** 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 HMC5843::initialize() { // write CONFIG_A register I2Cdev::writeByte(devAddr, HMC5843_RA_CONFIG_A, (HMC5843_RATE_10 << (HMC5843_CRA_RATE_BIT - HMC5843_CRA_RATE_LENGTH + 1)) | (HMC5843_BIAS_NORMAL << (HMC5843_CRA_BIAS_BIT - HMC5843_CRA_BIAS_LENGTH + 1))); // write CONFIG_B register setGain(HMC5843_GAIN_1300); // write MODE register setMode(HMC5843_MODE_SINGLE); }
AmbisonicConvolve::AmbisonicConvolve(long anOrder, long aVectorSize) { m_order = Tools::clip_min(anOrder, (long)1); m_number_of_harmonics = m_order * 2 + 1; m_number_of_inputs = m_number_of_harmonics; m_number_of_outputs = m_number_of_harmonics; for(int i = 0; i < m_number_of_harmonics; i++) m_convolution.push_back(new GardnerConvolution()); setGain(1.); }
/** 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() { // write CONFIG_A register setSampleAveraging(HMC5883L_AVERAGING_8); setMeasurementBias(HMC5883L_BIAS_NORMAL); setDataRate(HMC5883L_RATE_15); // write CONFIG_B register setGain(HMC5883L_GAIN_1090); // write MODE register setMode(HMC5883L_MODE_SINGLE); }
/** 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() { // 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); }
bool MasterSynthesizer::setState(const SynthesizerState& ss) { bool result = true; 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; case 3: setMasterTuning(v.data.toDouble()); break; case 4: setDynamicsMethod(v.data.toInt()); break; case 5: setCcToUseIndex(v.data.toInt()); break; default: qDebug("MasterSynthesizer::setState: unknown master id <%d>", v.id); } } } else { Synthesizer* s = synthesizer(g.name()); if (s) { bool r = s->setState(g); result = result && r; } 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); else qDebug("MasterSynthesizer::setState: unknown <%s>", qPrintable(g.name())); } } } return result; }
void isoDriver::autoGain(){ double maxgain = vcc / (2 * ((double)topRange - vref) * R4/(R3+R4)); double mingain = vcc / (2 * ((double)botRange - vref) * R4/(R3+R4)); maxgain = fmin(fabs(mingain) * 0.98, fabs(maxgain) * 0.98); double snap[8] = {64, 32, 16, 8, 4, 2, 1, 0.5}; for (int i=0;i<8;i++){ if (maxgain>snap[i]){ setGain(snap[i]); return; } } }
void Sound::setDefaults() { setPosition(Vector3::ZERO); setDirection(Vector3::UNIT_Y); setPitch(1.f); setGain(1.f, 0.f, 1.f); setLooping(false); setRolloff(1.f); setReferenceDistance(1.f); setCone(360.f,360.f,0.f); setRelative(true); setOffsetSeconds(0.f); rewind(); }
int UnsharpMasking::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: refreshImage(); break; case 1: setGain((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 2; } return _id; }
void SynthControl::updateGui() { masterTuning->setValue(synti->masterTuning()); setGain(synti->gain()); int idx = synti->indexOfEffect(0); effectA->setCurrentIndex(idx); effectStackA->setCurrentIndex(idx); synti->effect(0)->gui()->updateValues(); synti->effect(1)->gui()->updateValues(); idx = synti->indexOfEffect(1); effectB->setCurrentIndex(idx); effectStackB->setCurrentIndex(idx); }
bool PS3EyeTracker::open(const DeviceEnumerator *enumerator) { const TrackerDeviceEnumerator *tracker_enumerator = static_cast<const TrackerDeviceEnumerator *>(enumerator); const char *cur_dev_path = tracker_enumerator->get_path(); bool bSuccess = false; if (getIsOpen()) { SERVER_LOG_WARNING("PS3EyeTracker::open") << "PS3EyeTracker(" << cur_dev_path << ") already open. Ignoring request."; bSuccess = true; } else { const int camera_index = tracker_enumerator->get_camera_index(); SERVER_LOG_INFO("PS3EyeTracker::open") << "Opening PS3EyeTracker(" << cur_dev_path << ", camera_index=" << camera_index << ")"; VideoCapture = new PSEyeVideoCapture(camera_index); if (VideoCapture->isOpened()) { CaptureData = new PSEyeCaptureData; USBDevicePath = enumerator->get_path(); bSuccess = true; } else { SERVER_LOG_ERROR("PS3EyeTracker::open") << "Failed to open PS3EyeTracker(" << cur_dev_path << ", camera_index=" << camera_index << ")"; close(); } } if (bSuccess) { std::string identifier = VideoCapture->getUniqueIndentifier(); std::string config_name = "PS3EyeTrackerConfig_"; config_name.append(identifier); cfg = PS3EyeTrackerConfig(config_name); cfg.load(); setExposure(cfg.exposure); setGain(cfg.gain); } return bSuccess; }
bool FishCampCCD::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) { if (dev != nullptr && strcmp(dev, getDeviceName()) == 0) { if (!strcmp(name, GainNP.name)) { IUUpdateNumber(&GainNP, values, names, n); setGain(GainN[0].value); GainNP.s = IPS_OK; IDSetNumber(&GainNP, nullptr); return true; } } return INDI::CCD::ISNewNumber(dev, name, values, names, n); }