/** * @brief Sets the speed of the movement. * @param speed the speed in pixels per second (0 means auto, based on the length of the jump) */ void JumpMovement::set_speed(int speed) { if (speed == 0) { set_delay(std::max(4, 14 - length / 10)); } else { set_delay(1000 / speed); } restart(); }
/** * \brief Sets the speed of the movement. * \param speed the speed in pixels per second (0 means auto, based on the length of the jump) */ void JumpMovement::set_speed(int speed) { if (speed == 0) { set_delay(std::max(4, 14 - distance / 10)); } else { set_delay(1000 / speed); } this->speed = speed; restart(); }
static int set_euler_delay(struct yas_state *st, int delay) { if (atomic_read(&st->mag_enable) && atomic_read(&st->euler_enable)) { if (set_delay(st, MIN(st->mag_delay, delay)) < 0) return -EINVAL; } else if (atomic_read(&st->euler_enable)) { if (set_delay(st, delay) < 0) return -EINVAL; } st->euler_delay = delay; return 0; }
static int logo_filter_video(TCModuleInstance *self, TCFrameVideo *frame) { LogoPrivateData *pd = NULL; WorkItem W = { NULL, 0, 0.0 }; TC_MODULE_SELF_CHECK(self, "filter"); TC_MODULE_SELF_CHECK(frame, "filter"); pd = self->userdata; if (frame->id < pd->start || frame->id > pd->end) { /* out of the interval, so skip processing */ return TC_OK; } set_fade(&W, frame->id, pd); set_delay(pd); W.pixels = GetImagePixels(pd->images, 0, 0, pd->images->columns, pd->images->rows); return pd->render(pd, &W, frame); }
void adjust_trg_delay(int old_sweep, int new_sweep) { /* variables */ /* none */ /* multiply by 10 times the ratio of sweep rates */ delay *= (10 * sweep_rates[new_sweep].sample_rate) / sweep_rates[old_sweep].sample_rate; /* now divide the factor of 10 back out */ delay /= 10; /* make sure delay is not out of range */ if (delay > MAX_DELAY) /* delay is too large - set to maximum */ delay = MAX_DELAY; if (delay < MIN_DELAY) /* delay is too small - set to minimum */ delay = MIN_DELAY; /* tell the hardware the new trigger delay */ set_delay(delay); /* all done adjusting the trigger delay - return */ return; }
TITANIUM_PROPERTY_SETTER(Animation, delay) { TITANIUM_ASSERT(argument.IsNumber()); const auto delay = std::chrono::milliseconds(static_cast<std::chrono::milliseconds::rep>(static_cast<std::uint32_t>(argument))); set_delay(delay); return true; }
tower::tower(const tower_attributes &attributes,double posx,double posy,const ALLEGRO_TIMER *timer) { this->attributes=&attributes; this->position=make_pair(posx,posy); this->timer=timer; set_delay(); reset_counter(); active=true; }
DSN_API void dsn_task_call(dsn_task_t task, int delay_milliseconds) { auto t = ((::dsn::task*)(task)); dassert(t->spec().type == TASK_TYPE_COMPUTE, "must be common or timer task"); t->set_delay(delay_milliseconds); t->enqueue(); }
int PressSensor::update_delay(int sensor_type) { if (mEnabled[sensor_type]) { return set_delay(mDelay[sensor_type]); } else return 0; }
timer_task::timer_task(task_code code, uint32_t interval_milliseconds, int hash) : task(code, hash), _interval_milliseconds(interval_milliseconds) { dassert (TASK_TYPE_COMPUTE == spec().type, "this must be a computation type task, please use DEFINE_TASK_CODE to define the task code"); // enable timer randomization to avoid lots of timers execution simultaneously set_delay(::dsn::service::env::random32(0, interval_milliseconds)); }
void i2c::init() { bar_[CNTRL_REG] = 0; set_clk_divider(); set_delay(); set_clkt(); bar_[SLAVE_ADDR_REG] = 0; bar_[DLEN_REG] = 0; }
scpi_result_t scpi_source_VoltageProtectionDelay(scpi_t * context) { Channel *channel = set_channel_from_command_number(context); if (!channel) { return SCPI_RES_ERR; } return set_delay(context, channel->prot_conf.u_delay, channel->OVP_MIN_DELAY, channel->OVP_MAX_DELAY, channel->OVP_DEFAULT_DELAY); }
// set echos void echo::set_echos( f32 echos ) { if( echos < 1.f ) { echos = 1.f; } set_delay( 1.f / echos ); }
void timer_task::enqueue() { // enable timer randomization to avoid lots of timers execution simultaneously if (delay_milliseconds() == 0 && spec().randomize_timer_delay_if_zero) { set_delay(rand::next_u32(0, _interval_milliseconds)); } return task::enqueue(); }
void AudioProcessor::set_state(const AudioProcessorState *state) { if (!state) return; // Channel order set_input_order(state->input_order); set_output_order(state->output_order); // Master gain set_master(state->master); // AGC set_auto_gain(state->auto_gain); set_normalize(state->normalize); set_attack(state->attack); set_release(state->release); // DRC set_drc(state->drc); set_drc_power(state->drc_power); // Matrix // (!) Auto matrix option must be set before setting the matrix // because when auto matrix is on, mixer rejects the new matrix. set_auto_matrix(state->auto_matrix); set_matrix(state->matrix); // Automatrix options set_normalize_matrix(state->normalize_matrix); set_voice_control(state->voice_control); set_expand_stereo(state->expand_stereo); // Automatrix levels set_clev(state->clev); set_slev(state->slev); set_lfelev(state->lfelev); // Input/output gains set_input_gains(state->input_gains); set_output_gains(state->output_gains); // SRC set_src_quality(state->src_quality); set_src_att(state->src_att); // Eqalizer set_eq(state->eq); if (state->eq_master_bands) set_eq_bands(CH_NONE, state->eq_master_bands, state->eq_master_nbands); for (int ch = 0; ch < CH_NAMES; ch++) if (state->eq_bands[ch]) set_eq_bands(ch, state->eq_bands[ch], state->eq_nbands[ch]); // Bass redirection set_bass_redir(state->bass_redir); set_bass_freq(state->bass_freq); set_bass_channels(state->bass_channels); // Delays set_delay(state->delay); set_delay_units(state->delay_units); set_delays(state->delays); // Dithering set_dithering(state->dithering); }
timer_task::timer_task(dsn_task_code_t code, dsn_task_handler_t cb, void* param, uint32_t interval_milliseconds, int hash, service_node* node) : task(code, hash, node), _interval_milliseconds(interval_milliseconds), _cb(cb), _param(param) { dassert (TASK_TYPE_COMPUTE == spec().type, "this must be a computation type task, please use DEFINE_TASK_CODE to define the task code"); // enable timer randomization to avoid lots of timers execution simultaneously set_delay(dsn_random32(0, interval_milliseconds)); }
void timer_task::exec() { _cb(_context); if (_interval_milliseconds > 0) { //_state must be TASK_STATE_RUNNING here dbg_dassert(_state.load(std::memory_order_relaxed) == TASK_STATE_RUNNING, "corrupted timer task state"); _state.store(TASK_STATE_READY, std::memory_order_release); set_delay(_interval_milliseconds); } }
/* Initialize some basic config settings */ void init_default_settings(void) { set_log_file(stdout); set_max_pin_attempts(P1_SIZE + P2_SIZE); set_delay(DEFAULT_DELAY); set_lock_delay(DEFAULT_LOCK_DELAY); set_debug(INFO); set_auto_channel_select(1); set_timeout_is_nack(1); set_oo_send_nack(1); set_wifi_band(BG_BAND); }
void timer_task::exec() { if (dsn_likely(_cb != nullptr)) { _cb(); } // valid interval, we reset task state to READY if (dsn_likely(_interval_milliseconds > 0)) { dassert(set_retry(true), "timer task set retry failed, with state = %s", enum_to_string(state())); set_delay(_interval_milliseconds); } }
void do_quaff( char_data* ch, char* argument ) { obj_data* obj; int level; int duration; int spell; if( *argument == '\0' ) { send( ch, "Quaff what?\r\n" ); return; } if( ( obj = one_object( ch, argument, "quaff", &ch->contents ) ) == NULL ) return; if( obj->pIndexData->item_type != ITEM_POTION ) { send( ch, "You can quaff only potions.\r\n" ); return; } if( ( spell = obj->pIndexData->value[0] ) < 0 || spell >= MAX_SPELL ) { send( ch, "That potion contains a non-existent spell.\r\n" ); bug( "Quaff: Spell out of Range." ); bug( "-- Potion = %s.", obj->Seen_Name( NULL ) ); return; } send( ch, "You quaff %s.\r\n", obj ); send_seen( ch, "%s quaffs %s.\r\n", ch, obj ); if( ( level = obj->value[1] ) < 1 || level > 25 ) { bug( "Quaff: Level out of range." ); bug( "-- Potion = %s", obj->Seen_Name( NULL ) ); level = 1; } if( ( duration = obj->value[2] ) < 1 ) { bug( "Quaff: Duration out of range." ); bug( "-- Potion = %s", obj->Seen_Name( NULL ) ); duration = 1; } set_delay( ch, 10 ); obj->Extract( 1 ); ( *spell_table[ spell ].function )( NULL, ch, NULL, level, duration ); return; }
void PulsingColorAnimation::loadFromJSON(const QJsonObject & obj) { if (obj.contains("fromStart")) set_fromStart(obj["fromStart"].toDouble()); if (obj.contains("duration")) set_duration(obj["duration"].toDouble()); if (obj.contains("lowerColor") and obj.contains("upperColor")) { QColor lowerColor = QColor(obj["lowerColor"].toString()); QColor upperColor = QColor(obj["upperColor"].toString()); set_meanColor(QColor((upperColor.red() + lowerColor.red()) / 2, (upperColor.green() + lowerColor.green()) / 2, (upperColor.blue() + lowerColor.blue()) / 2)); set_varColor(QColor((upperColor.red() - lowerColor.red()) / 2, (upperColor.green() - lowerColor.green()) / 2, (upperColor.blue() - lowerColor.blue()) / 2)); } if (obj.contains("frequency")) set_pulsation(obj["frequency"].toDouble() * 2 * M_PI); if (obj.contains("delay")) set_delay(obj["delay"].toDouble()); if (obj.contains("pulseSignal")) set_pulseSignal(obj["pulseSignal"].toString()); if (obj.contains("priority")) set_priority(obj["priority"].toInt()); }
void timer_task::exec() { task_state RUNNING_STATE = TASK_STATE_RUNNING; _cb(_param); if (_interval_milliseconds > 0) { if (_state.compare_exchange_strong(RUNNING_STATE, TASK_STATE_READY)) { set_delay(_interval_milliseconds); } } }
/** * @brief Creates a fade-in or fade-out transition effect. * @param direction direction of the transition effect (in or out) */ TransitionFade::TransitionFade(Transition::Direction direction): Transition(direction), alpha(-1) { if (direction == OUT) { alpha_start = 256; alpha_limit = 0; alpha_increment = -8; } else { alpha_start = 0; alpha_limit = 256; alpha_increment = 8; } set_delay(20); }
//functions FullConnection(Layer* f, Layer* t, const vector<int>& d = empty_list_of<int>(), FullConnection* s = 0): Connection(make_name(f, t, d), f, t), source(s), paramRange(source ? source->paramRange : WeightContainer::instance().new_parameters(this->from->output_size() * this->to->input_size(), this->from->name, this->to->name, name)) { if (source) { WeightContainer::instance().link_layers(this->from->name, this->to->name, this->name, paramRange.first, paramRange.second); } set_delay(d); assert(num_weights() == (this->from->output_size() * this->to->input_size())); if (this->from->name != "bias" && this->from != this->to && !this->to->source) { this->to->source = this->from; } }
void SpikingGroup::init(NeuronID n, double loadmultiplier, NeuronID total ) { group_name = "SpikingGroup"; unique_id = unique_id_count++; size = n; effective_load_multiplier = loadmultiplier; if ( total > 0 ) { anticipated_total = total; stringstream oss; oss << get_name() << ":: Anticipating " << anticipated_total << " units in total." ; logger->msg(oss.str(),NOTIFICATION); } // setting up default values evolve_locally_bool = true; locked_rank = 0; locked_range = communicator->size(); rank_size = calculate_rank_size(); // set the rank size double fraction = (double)calculate_rank_size(0)*effective_load_multiplier/DEFAULT_MINDISTRIBUTEDSIZE; if ( anticipated_total > 0 ) fraction = (1.*size*effective_load_multiplier)/anticipated_total; if ( fraction >= 0 && fraction < 1. ) { lock_range( fraction ); } else { // ROUNDROBIN which is default locked_rank = 0; locked_range = communicator->size(); stringstream oss; oss << get_name() << ":: Size " << get_rank_size() << " (ROUNDROBIN)"; logger->msg(oss.str(),NOTIFICATION); } stringstream oss; oss << get_name() << ":: Registering delay (MINDELAY=" << MINDELAY << ")"; logger->msg(oss.str(),DEBUG); delay = new SpikeDelay( ); set_delay(MINDELAY+1); evolve_locally_bool = evolve_locally_bool && ( get_rank_size() > 0 ); }
void set_trg_delay(long int d) { /* variables */ /* none */ /* set the trigger delay */ delay = d; /* set the trigger delay in hardware too */ set_delay(delay); /* all done initializing the trigger delay - return */ return; }
bool update(const char * field, std::vector<uint8_t> data) { if (!strcmp(field, "dlpkt")) { return delete_packet(data); } else if (!strcmp(field, "dlcha")) { return delete_channel(data); } else if (!strcmp(field, "pnum")) { return set_pnumber(data); } else if (!strcmp(field, "chan")) { return set_channel(data); } else if (!strcmp(field, "pol")) { set_poll(data); } else if (!strcmp(field, "dir")) { const char * dirStr = byteVec2cstr(data); if (!strcmp(dirStr, "pos")) set_direction(DIR_POS); else if (!strcmp(dirStr, "neg")) set_direction(DIR_NEG); else return false; } else if (!strcmp(field, "data")) { return set_current(data); } else if (!strcmp(field, "wait")) { set_delay(data); } else if (!strcmp(field, "send")) { flag_return = true; send_packets(); } else if (!strcmp(field, "reset")) { send_global_reset(); } else if (!strcmp(field, "glob")) { set_global(); } else if (!strcmp(field, "conn")) { flag_return = true; return connect_serial(); } else if (!strcmp(field, "exit")) { return exit(); } else if (!strcmp(field, "clrpks")) { clear_packets(); } else if (!strcmp(field, "prev")) { if (debug_) preview_packets(); preview_packet_bytes(); flag_return = true; } else { return false; } return true; }
void trg_delay_up() { /* variables */ /* none */ /* increase the trigger delay, if not already the maximum */ if (delay < MAX_DELAY) delay++; /* tell the hardware the new trigger delay */ set_delay(delay); /* all done raising the trigger delay - return */ return; }
void trg_delay_down() { /* variables */ /* none */ /* decrease the trigger delay, if not already the minimum */ if (delay > MIN_DELAY) delay--; /* set the trigger delay for the hardware */ set_delay(delay); /* all done with lowering the trigger delay - return */ return; }
/** * \brief Creates a fade-in or fade-out transition effect. * \param direction direction of the transition effect (in or out) */ TransitionFade::TransitionFade(Transition::Direction direction): Transition(direction), finished(false), alpha(-1), dst_surface(NULL) { if (direction == OUT) { alpha_start = 256; alpha_limit = 0; alpha_increment = -8; } else { alpha_start = 0; alpha_limit = 256; alpha_increment = 8; } set_delay(20); }