本文整理汇总了C++中set_range函数的典型用法代码示例。如果您正苦于以下问题:C++ set_range函数的具体用法?C++ set_range怎么用?C++ set_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_range
void Tile::set_air(int air){
airID = air;
if(air==2){
set_range(150);
towerCost+=50;
chargeRate = 40;
upgradeCost = 100;
damage = 20;
}
if(air==3){
set_range(100);
towerCost+=150;
chargeRate = 20;
upgradeCost = 150;
damage = 30;
}
if(air==4){
set_range(125
);
towerCost+=100;
chargeRate = 20;
upgradeCost = 100;
}
if(air==5){
set_range(200);
towerCost+=200;
chargeRate = 20;
upgradeCost = 150;
damage = 100;
}
}
示例2: init
static int init(const struct motion_sensor_t *s)
{
int ret = 0, tmp;
ret = raw_read8(s->addr, LSM6DS0_WHO_AM_I_REG, &tmp);
if (ret)
return EC_ERROR_UNKNOWN;
if (tmp != LSM6DS0_WHO_AM_I)
return EC_ERROR_ACCESS_DENIED;
/*
* This sensor can be powered through an EC reboot, so the state of
* the sensor is unknown here. Initiate software reset to restore
* sensor to default.
* [6] BDU Enable Block Data Update.
* [0] SW_RESET software reset
*
* lsm6ds0 supports both accel & gyro features
* Board will see two virtual sensor devices: accel & gyro.
* Requirement: Accel need be init before gyro.
* SW_RESET is down for accel only!
*/
if (MOTIONSENSE_TYPE_ACCEL == s->type) {
mutex_lock(s->mutex);
ret = raw_read8(s->addr, LSM6DS0_CTRL_REG8, &tmp);
if (ret) {
mutex_unlock(s->mutex);
return EC_ERROR_UNKNOWN;
}
tmp |= (1 | LSM6DS0_BDU_ENABLE);
ret = raw_write8(s->addr, LSM6DS0_CTRL_REG8, tmp);
mutex_unlock(s->mutex);
if (ret)
return EC_ERROR_UNKNOWN;
/* Power Down Gyro */
ret = raw_write8(s->addr,
LSM6DS0_CTRL_REG1_G, 0x0);
if (ret)
return EC_ERROR_UNKNOWN;
ret = set_range(s, s->default_range, 1);
if (ret)
return EC_ERROR_UNKNOWN;
}
if (MOTIONSENSE_TYPE_GYRO == s->type) {
/* Config GYRO Range */
ret = set_range(s, s->default_range, 1);
if (ret)
return EC_ERROR_UNKNOWN;
}
CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n",
s->name, s->type, get_range(s));
return ret;
}
示例3: set_range
void
SliderControl::port_property_changed(const URI& key, const Atom& value)
{
_enable_signal = false;
const Shared::LV2URIMap& uris = App::instance().uris();
if (key == uris.lv2_minimum && value.type() == Atom::FLOAT)
set_range(value.get_float(), _slider->get_adjustment()->get_upper());
else if (key == uris.lv2_maximum && value.type() == Atom::FLOAT)
set_range(_slider->get_adjustment()->get_lower(), value.get_float());
_enable_signal = true;
}
示例4: malloc
void *gen_class(char *inf)
{
if(*inf == '[')
{ inf++;
if(inf[strlen(inf) - 1] == ']') inf[strlen(inf) - 1] = 0;
else return NULL; }
int state;
void *ret = malloc(32);
if(*inf == '^') { memset(ret, 0xFF, 32); state = 0; inf++; }
else { memset(ret, 0x00, 32); state = 1; }
if(*inf == '-')
{ flp_item(ret, '-'); inf++; }
else if(inf[strlen(inf) - 1] == '-')
{ flp_item(ret, '-'); inf[strlen(inf) - 1] = 0; }
while(*inf)
{
if(*inf == '-')
{
set_range(ret, inf[-1], inf[1], state);
}
else set_item(ret, inf[0], state);
inf++;
}
return ret;
}
示例5: lrintf
void
SliderControl::set_value(const Atom& atom)
{
if (_enabled) {
_enable_signal = false;
float val = atom.get_float();
if (_port_model->is_integer())
val = lrintf(val);
if (_slider->get_value() != val) {
const Gtk::Adjustment* range = _slider->get_adjustment();
const float lower = range->get_lower();
const float upper = range->get_upper();
if (val < lower || val > upper)
set_range(min(lower, val), max(lower, val));
_slider->set_value(val);
}
if (_value_spinner->get_value() != val)
_value_spinner->set_value(val);
_enable_signal = true;
}
}
示例6: main
/*programe main entry*/
int main(const int argc, const char *argv[]) {
char option[BUFSIZE];
int to_print[BUFSIZE];
int negate = 0;
int fpos;
int type;
int i;
FILE *fp;
type = get_valid_com(argc, argv, option, &negate, &fpos);
if (type == 0)
return 1;
if (!set_range(option, to_print, negate))
return 2;
for (i = fpos; i < argc; i++) {
if ((fp = fopen(argv[i], "r+b")) == 0) {
perror("fopen");
return 3;
}
if (type == 1)
display_c(fp, to_print);
else
display_f(fp, to_print);
if (fclose(fp) != 0) {
perror("fclose");
return 4;
}
}
return 0;
}
示例7: lis331_attach
int
lis331_attach(struct spi_dev_s *spi, int spi_id)
{
int result = ERROR;
lis331_dev.spi = spi;
SPI_LOCK(lis331_dev.spi, true);
/* verify that the device is attached and functioning */
if (read_reg(ADDR_WHO_AM_I) == WHO_I_AM) {
/* set default configuration */
write_reg(ADDR_CTRL_REG2, 0); /* disable interrupt-generating high-pass filters */
write_reg(ADDR_CTRL_REG3, 0); /* no interrupts - we don't use them */
write_reg(ADDR_CTRL_REG5, 0); /* disable wake-on-interrupt */
set_range(LIS331_RANGE_4G);
set_rate(LIS331_RATE_400Hz); /* takes device out of low-power mode */
/* make ourselves available */
register_driver("/dev/lis331", &lis331_fops, 0666, NULL);
result = 0;
} else {
errno = EIO;
}
SPI_LOCK(lis331_dev.spi, false);
return result;
}
示例8: set_range
void cGtkmmScrollBar::SetRange(int64_t _min, int64_t _max)
{
min = _min;
max = _max;
set_range(min, max);
}
示例9: memset
int
HMC5883::init()
{
int ret = ERROR;
/* do I2C init (and probe) first */
if (I2C::init() != OK)
goto out;
/* allocate basic report buffers */
_num_reports = 2;
_reports = new struct mag_report[_num_reports];
if (_reports == nullptr)
goto out;
_oldest_report = _next_report = 0;
/* get a publish handle on the mag topic */
memset(&_reports[0], 0, sizeof(_reports[0]));
_mag_topic = orb_advertise(ORB_ID(sensor_mag), &_reports[0]);
if (_mag_topic < 0)
debug("failed to create sensor_mag object");
/* set range */
set_range(_range_ga);
ret = OK;
/* sensor is ok, but not calibrated */
_sensor_ok = true;
out:
return ret;
}
示例10: set_localiprange
int set_localiprange (char *word, char *value, int context, void *item)
{
struct lns *lns = (struct lns *) item;
switch (context & ~CONTEXT_DEFAULT)
{
case CONTEXT_LNS:
break;
default:
snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n",
word);
return -1;
}
if (lns->localaddr) {
snprintf (filerr, sizeof (filerr), "'local ip range' and 'local ip' are mutually exclusive\n");
return -1;
}
lns->localrange = set_range (word, value, lns->localrange);
if (!lns->localrange)
return -1;
#ifdef DEBUG_FILE
l2tp_log (LOG_DEBUG, "range start = %x, end = %x, sense=%ud\n",
ntohl (lns->range->start), ntohl (lns->range->end), lns->range->sense);
#endif
return 0;
}
示例11: write_reg
void
FXAS21002C::reset()
{
/* write 0 0 0 000 00 = 0x00 to CTRL_REG1 to place FXOS21002 in Standby
* [6]: RST=0
* [5]: ST=0 self test disabled
* [4-2]: DR[2-0]=000 for 200Hz ODR
* [1-0]: Active=0, Ready=0 for Standby mode
*/
write_reg(FXAS21002C_CTRL_REG1, 0);
/* write 0000 0000 = 0x00 to CTRL_REG0 to configure range and filters
* [7-6]: BW[1-0]=00, LPF 64 @ 800Hz ODR
* [5]: SPIW=0 4 wire SPI
* [4-3]: SEL[1-0]=00 for 10Hz HPF at 200Hz ODR
* [2]: HPF_EN=0 disable HPF
* [1-0]: FS[1-0]=00 for 1600dps (TBD CHANGE TO 2000dps when final trimmed parts available)
*/
write_checked_reg(FXAS21002C_CTRL_REG0, CTRL_REG0_BW_LOW | CTRL_REG0_FS_2000_DPS);
/* write CTRL_REG1 to configure 800Hz ODR and enter Active mode */
write_checked_reg(FXAS21002C_CTRL_REG1, CTRL_REG1_DR_800HZ | CTRL_REG1_ACTIVE);
/* Set the default */
set_samplerate(0);
set_range(FXAS21002C_DEFAULT_RANGE_DPS);
set_onchip_lowpass_filter(FXAS21002C_DEFAULT_ONCHIP_FILTER_FREQ);
_read = 0;
}
示例12: disable_i2c
void
L3GD20::reset()
{
// ensure the chip doesn't interpret any other bus traffic as I2C
disable_i2c();
/* set default configuration */
write_reg(ADDR_CTRL_REG1, REG1_POWER_NORMAL | REG1_Z_ENABLE | REG1_Y_ENABLE | REG1_X_ENABLE);
write_reg(ADDR_CTRL_REG2, 0); /* disable high-pass filters */
write_reg(ADDR_CTRL_REG3, 0); /* no interrupts - we don't use them */
write_reg(ADDR_CTRL_REG4, REG4_BDU);
write_reg(ADDR_CTRL_REG5, 0);
write_reg(ADDR_CTRL_REG5, REG5_FIFO_ENABLE); /* disable wake-on-interrupt */
/* disable FIFO. This makes things simpler and ensures we
* aren't getting stale data. It means we must run the hrt
* callback fast enough to not miss data. */
write_reg(ADDR_FIFO_CTRL_REG, FIFO_CTRL_BYPASS_MODE);
set_samplerate(0); // 760Hz
set_range(L3GD20_DEFAULT_RANGE_DPS);
set_driver_lowpass_filter(L3GD20_DEFAULT_RATE, L3GD20_DEFAULT_FILTER_FREQ);
_read = 0;
}
示例13: lis331_ioctl
static int
lis331_ioctl(struct file *filp, int cmd, unsigned long arg)
{
int result = ERROR;
switch (cmd) {
case LIS331_SETRATE:
if ((arg & REG1_RATE_MASK) == arg) {
set_rate(arg);
result = 0;
lis331_dev.rate = arg;
}
break;
case LIS331_SETRANGE:
if ((arg & REG4_RANGE_MASK) == arg) {
set_range(arg);
result = 0;
}
break;
case LIS331_SETBUFFER:
lis331_dev.buffer = (struct lis331_buffer *)arg;
result = 0;
break;
}
if (result)
errno = EINVAL;
return result;
}
示例14: init
static int init(const struct motion_sensor_t *s)
{
int ret, resol;
struct si114x_drv_data_t *data = SI114X_GET_DATA(s);
/* initialize only once: light must be declared first. */
if (s->type == MOTIONSENSE_TYPE_LIGHT) {
#ifdef CONFIG_ALS_SI114X_CHECK_REVISION
ret = si114x_revisions(s);
if (ret != EC_SUCCESS)
return ret;
#endif
ret = si114x_initialize(s);
if (ret != EC_SUCCESS)
return ret;
data->state = SI114X_IDLE;
resol = 7;
} else {
if (data->state == SI114X_NOT_READY)
return EC_ERROR_ACCESS_DENIED;
resol = 5;
}
set_range(s, s->default_range, 0);
/*
* Sensor is most likely behind a glass.
* Max out the gain to get correct measurement
*/
set_resolution(s, resol, 0);
CPRINTF("[%T %s: MS Done Init type:0x%X range:%d]\n",
s->name, s->type, get_range(s));
return EC_SUCCESS;
}
示例15: while
int16_t
RC_Channel_aux::closest_limit(int16_t angle)
{
// Change scaling to 0.1 degrees in order to avoid overflows in the angle arithmetic
int16_t min = angle_min / 10;
int16_t max = angle_max / 10;
// Make sure the angle lies in the interval [-180 .. 180[ degrees
while (angle < -1800) angle += 3600;
while (angle >= 1800) angle -= 3600;
// Make sure the angle limits lie in the interval [-180 .. 180[ degrees
while (min < -1800) min += 3600;
while (min >= 1800) min -= 3600;
while (max < -1800) max += 3600;
while (max >= 1800) max -= 3600;
// This is done every time because the user might change the min, max values on the fly
set_range(min, max);
// If the angle is outside servo limits, saturate the angle to the closest limit
// On a circle the closest angular position must be carefully calculated to account for wrap-around
if ((angle < min) && (angle > max)){
// angle error if min limit is used
int16_t err_min = min - angle + (angle<min?0:3600); // add 360 degrees if on the "wrong side"
// angle error if max limit is used
int16_t err_max = angle - max + (angle>max?0:3600); // add 360 degrees if on the "wrong side"
angle = err_min<err_max?min:max;
}
servo_out = angle;
// convert angle to PWM using a linear transformation (ignores trimming because the camera limits might not be symmetric)
calc_pwm();
return angle;
}