本文整理汇总了C++中set_range函数的典型用法代码示例。如果您正苦于以下问题:C++ set_range函数的具体用法?C++ set_range怎么用?C++ set_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_range函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:wwong412,项目名称:pic10c,代码行数:32,代码来源:Tile.cpp
示例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;
}
开发者ID:Basavaraja-MS,项目名称:ec_local,代码行数:60,代码来源:accelgyro_lsm6ds0.c
示例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;
}
开发者ID:pgiblock,项目名称:ingen,代码行数:13,代码来源:Controls.cpp
示例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;
}
开发者ID:sspry,项目名称:libsmallr,代码行数:28,代码来源:regex.c
示例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;
}
}
开发者ID:pgiblock,项目名称:ingen,代码行数:25,代码来源:Controls.cpp
示例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;
}
开发者ID:yl10030270,项目名称:C_code,代码行数:30,代码来源:Asn2.c
示例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;
}
开发者ID:aliniger,项目名称:px4_nxbuilder_orca,代码行数:32,代码来源:drv_lis331.c
示例8: set_range
void cGtkmmScrollBar::SetRange(int64_t _min, int64_t _max)
{
min = _min;
max = _max;
set_range(min, max);
}
开发者ID:pilkch,项目名称:diesel,代码行数:7,代码来源:gtkmmscrollbar.cpp
示例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;
}
开发者ID:davidbuzz,项目名称:Firmware,代码行数:34,代码来源:hmc5883.cpp
示例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;
}
开发者ID:aunoor,项目名称:xl2tpd,代码行数:27,代码来源:file.c
示例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;
}
开发者ID:airmind,项目名称:OpenMindPX,代码行数:33,代码来源:fxas21002c.cpp
示例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;
}
开发者ID:rutmarti,项目名称:Firmware,代码行数:26,代码来源:l3gd20.cpp
示例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;
}
开发者ID:aliniger,项目名称:px4_nxbuilder_orca,代码行数:31,代码来源:drv_lis331.c
示例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;
}
开发者ID:fishbaoz,项目名称:chrome-ec,代码行数:35,代码来源:als_si114x.c
示例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;
}
开发者ID:Artoko,项目名称:ardupilotdev,代码行数:35,代码来源:RC_Channel_aux.cpp
示例16: switch
/*
setup a channels aux servo function
*/
void SRV_Channel::aux_servo_function_setup(void)
{
if (type_setup) {
return;
}
switch (function) {
case k_flap:
case k_flap_auto:
case k_egg_drop:
set_range(100);
break;
case k_heli_rsc:
case k_heli_tail_rsc:
case k_motor_tilt:
case k_boost_throttle:
set_range(1000);
break;
case k_aileron_with_input:
case k_elevator_with_input:
case k_aileron:
case k_elevator:
case k_dspoilerLeft1:
case k_dspoilerLeft2:
case k_dspoilerRight1:
case k_dspoilerRight2:
case k_rudder:
case k_steering:
case k_flaperon_left:
case k_flaperon_right:
case k_tiltMotorLeft:
case k_tiltMotorRight:
case k_elevon_left:
case k_elevon_right:
case k_vtail_left:
case k_vtail_right:
set_angle(4500);
break;
case k_throttle:
case k_throttleLeft:
case k_throttleRight:
// fixed wing throttle
set_range(100);
break;
default:
break;
}
}
开发者ID:Javiercerna,项目名称:ardupilot,代码行数:50,代码来源:SRV_Channel_aux.cpp
示例17: set_range
FieldTile::FieldTile(Board<Tile>* board_in, size_t i, size_t j, size_t i_max, size_t j_max)
{
is_only_water = false;
board = board_in;
set_range(i,j,i_max,j_max);
find_land_state();
area = (i_max-i)*(j_max-j);
}
开发者ID:thisiscian,项目名称:MSC-ProgrammingSkills-hare-and-puma,代码行数:8,代码来源:field_tile.cpp
示例18: RingBuffer
int
BMA180::init()
{
int ret = ERROR;
/* do SPI init (and probe) first */
if (SPI::init() != OK)
goto out;
/* allocate basic report buffers */
_reports = new RingBuffer(2, sizeof(accel_report));
if (_reports == nullptr)
goto out;
/* advertise sensor topic */
struct accel_report zero_report;
memset(&zero_report, 0, sizeof(zero_report));
_accel_topic = orb_advertise(ORB_ID(sensor_accel), &zero_report);
/* perform soft reset (p48) */
write_reg(ADDR_RESET, SOFT_RESET);
/* wait 10 ms (datasheet incorrectly lists 10 us on page 49) */
usleep(10000);
/* enable writing to chip config */
modify_reg(ADDR_CTRL_REG0, 0, REG0_WRITE_ENABLE);
/* disable I2C interface */
modify_reg(ADDR_HIGH_DUR, HIGH_DUR_DIS_I2C, 0);
/* switch to low-noise mode */
modify_reg(ADDR_TCO_Z, TCO_Z_MODE_MASK, 0);
/* disable 12-bit mode */
modify_reg(ADDR_OFFSET_T, OFFSET_T_READOUT_12BIT, 0);
/* disable shadow-disable mode */
modify_reg(ADDR_GAIN_Y, GAIN_Y_SHADOW_DIS, 0);
/* disable writing to chip config */
modify_reg(ADDR_CTRL_REG0, REG0_WRITE_ENABLE, 0);
if (set_range(4)) warnx("Failed setting range");
if (set_lowpass(75)) warnx("Failed setting lowpass");
if (read_reg(ADDR_CHIP_ID) == CHIP_ID) {
ret = OK;
} else {
ret = ERROR;
}
out:
return ret;
}
开发者ID:Userskii,项目名称:Firmware,代码行数:58,代码来源:bma180.cpp
示例19: set_range
fixed
TaskMinTarget::f(const fixed p)
{
// set task targets
set_range(p);
res = tm.glide_solution(aircraft);
return res.time_elapsed - t_remaining;
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:9,代码来源:TaskMinTarget.cpp
示例20: main
int main() {
iterator i,end;
set_range(i,end);
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
std::cout.put('\n');
return 0;
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:11,代码来源:shared_iterator_example1.cpp
注:本文中的set_range函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论