void QProgressBar::reset() { progress_val = -1; percentage = -1; setIndicator(progress_str, progress_val, total_steps); update(); }
void Q3ProgressBar::reset() { progress_val = -1; percentage = -1; setIndicator(progress_str, progress_val, total_steps); repaint(); }
int main() { // Set output pins // B0 (indicator) // dmx output is set by library DDRB |= BV(DDB0); // Initialize dmx Attiny45::setTimer0Prescaler(DMX_PRESCALER); DmxSimple.maxChannel(DMX_CHANNELS); sei(); // White is not used DmxSimple.write(DMX_FAN_CHANNEL+4, 0x00); // Master brightness full always DmxSimple.write(DMX_FAN_CHANNEL, 0xff); // Set auto/sound mode and stroboscope off DmxSimple.write(DMX_FAN_CHANNEL+5, 0x00); DmxSimple.write(DMX_FAN_CHANNEL+6, 0x00); // Set initial color uint8_t initialColor[3] = {INITIAL_RED, INITIAL_GREEN, INITIAL_BLUE}; setColor(initialColor, initialColor, 0); _delay_ms(INITIAL_DELAY); bool indicatorLit = false; uint64_t counter = 0; uint8_t colorSequenceCounter = 0; uint8_t gradient = 1; while(true) { counter += 1; _delay_ms(LOOP_DELAY); if(counter % INDICATOR_HALF_PERIOD == 0) { indicatorLit = !indicatorLit; setIndicator(indicatorLit); } if(counter % COLOR_PERIOD == 0) { uint8_t currentPosition = colorSequenceCounter % COLOR_SEQUENCE_LENGTH; uint8_t nextPosition = (colorSequenceCounter + 1) % COLOR_SEQUENCE_LENGTH; uint8_t * current = colorSequence[currentPosition]; uint8_t * next = colorSequence[nextPosition]; setColor(current, next, gradient); if (gradient == next[3]) { colorSequenceCounter++; gradient = 0; } else { gradient++; } } } }
void QProgressBar::setTotalSteps( int totalSteps ) { total_steps = totalSteps; if ( isVisible() ) { if ( setIndicator(progress_str, progress_val, total_steps) ) repaint( FALSE ); } }
void QProgressBar::setProgress( int progress ) { if ( progress <= progress_val ) return; progress_val = progress; if ( isVisible() ) { if ( setIndicator(progress_str, progress_val, total_steps) ) repaint( FALSE ); } }
void QProgressBar::setTotalSteps( int totalSteps ) { bool clear = totalSteps != total_steps; total_steps = totalSteps; if ( isVisible() ) { if ( setIndicator(progress_str, progress_val, total_steps) ) { repaint( clear ); if ( autoMask() ) updateMask(); } } }
void Q3ProgressBar::setTotalSteps(int totalSteps) { total_steps = totalSteps; // Current progress is invalid if larger than total if (total_steps < progress_val) progress_val = -1; if (isVisible() && (setIndicator(progress_str, progress_val, total_steps) || !total_steps)) repaint(); }
void QProgressBar::show() { setIndicator( progress_str, progress_val, total_steps ); // ### 2.0: Move this next stuff to styleChange() if ( style() == MotifStyle ) { setFrameStyle(QFrame::WinPanel | QFrame::Sunken); setLineWidth( 2 ); } else { setFrameStyle(QFrame::NoFrame); setLineWidth( 1 ); } QFrame::show(); }
void QProgressBar::setProgress( int progress ) { if ( progress == progress_val || progress < 0 || ( ( progress > total_steps ) && total_steps ) ) return; progress_val = progress; setIndicator( progress_str, progress_val, total_steps ); repaint( FALSE ); #if defined(QT_ACCESSIBILITY_SUPPORT) QAccessible::updateAccessibility( this, 0, QAccessible::ValueChanged ); #endif }
void QProgressBar::setProgress( int progress ) { if ( progress == progress_val || progress < 0 || progress > total_steps ) return; bool needClearing = progress < progress_val; progress_val = progress; if ( !isVisible() ) return; if ( setIndicator( progress_str, progress_val, total_steps ) ) needClearing = TRUE; repaint( needClearing ); if ( autoMask() ) updateMask(); }
Character::Character(Object *object, Object *indicator, glm::vec3 position, glm::vec3 velocity, uint32_t material, uint32_t imaterial) { setObject(object); setIndicator(indicator); setPosition(position); setVelocity(velocity); setMaterial(material); setIMaterial(imaterial); setOrientation(glm::vec3(0, 5, 0)); cflag = false; bflag = false; uflag = false; rflag = false; idir = 0.001f; ipos = glm::vec3(position); ipos.y += 0.4f; }
void Q3ProgressBar::setProgress(int progress) { if (progress == progress_val || progress < 0 || ((progress > total_steps) && total_steps)) return; int old_progress_val = progress_val; progress_val = progress; if (setIndicator(progress_str, progress_val, total_steps) || ( total_steps == 0 || (width() * progress_val / total_steps != width() * old_progress_val / total_steps ))) repaint(); #ifndef QT_NO_ACCESSIBILITY QAccessible::updateAccessibility(this, 0, QAccessible::ValueChanged); #endif }
void Timer::onUpdateActivity(float dt) { if( _active ) _time += dt; // decompose time int mm = int( _time / 60 ); int ss = int( _time - mm * 60 ); int ms = int( 1000 * ( _time - ss - mm * 60 ) ); // minutes int units = mm; // digits pickup int digit = units % 10; setIndicator( _window->getPanel()->find( "MM0" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "MM1" ), digit ); // seconds units = ss; // digits pickup digit = units % 10; setIndicator( _window->getPanel()->find( "SS0" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "SS1" ), digit ); // milliseconds units = ms; // digits pickup digit = units % 10; setIndicator( _window->getPanel()->find( "MSS0" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "MSS1" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "MSS2" ), digit ); }
int main() { #ifdef DEBUG /* TODO: implement debugging Debug debug(DEBUG_FREQ); */ #endif // Set output pins: B0 (indicator), B1 (motor), B2 (lamp) DDRB |= BV(DDB0) | BV(DDB1) | BV(DDB2); // Initialize non-inverted pwm in pin OC0B (PB1) TCCR0A |= BV(WGM01) | BV(WGM00); TCCR0A |= BV(COM0B1); Attiny13::setTimer0Prescaler(Attiny13::PSV_64); // Initialize human as not doing anything. OCR0B = 0xff; bool indicatorLit = false; uint16_t counter = 0; while(true) { counter += 1; _delay_ms(LOOP_DELAY); // Read sensors and re-activate human if pig is detected if(pollSensors()) { humanInactivityDelay = HUMAN_DELAY; } runHuman(); if(counter % INDICATOR_HALF_PERIOD == 0) { indicatorLit = !indicatorLit; setIndicator(indicatorLit); } } }
int main() { DDRB |= _BV(5); PORTB &= ~_BV(5); ///////////////////////////// // Set up the analogue input setupAdcOnPin(0); adcStartConversion(); // Start ADC measurement pulseSetFrameBuffer(frameBuffer, NUM_LEDS); const uint8_t pulseCount = 10; uint8_t pulseIdx = 0; struct cPulse pulses[pulseCount]; memset(pulses, 0, sizeof(struct cPulse) * pulseCount); for (int i = 0; i < pulseCount; i += 2) { pulses[i].direction = 1; } uint8_t sampleHistory[HISTORY_COUNT]; memset(sampleHistory, 0, HISTORY_COUNT); int8_t startingPosition = 0; while(1) { ++toggle; toggle = toggle % 50; setIndicator(toggle == 0); // Hist = = = = = // Wind - - // Copy - - for (int i = 0; i < (HISTORY_COUNT - WINDOW_SIZE); ++i) { sampleHistory[i] = sampleHistory[i + WINDOW_SIZE]; } for (int i = 0; i < WINDOW_SIZE; ++i) { adcStartConversion(); _delay_us(500); adcWaitReady(); sampleHistory[WINDOW_START + i] = ADCH; } uint8_t historicalPeak = findPeak(sampleHistory, 0, WINDOW_START); uint8_t currentPeak = findPeak(sampleHistory, WINDOW_START, WINDOW_SIZE); if (isPulseDetected(historicalPeak, currentPeak)) { // Generate a new pulse if (++pulseIdx >= pulseCount) pulseIdx = 0; pulses[pulseIdx].colour.h = rand() % MAX_HUE; pulses[pulseIdx].colour.s = (MAX_SAT / 2) + (rand() % (MAX_SAT / 2)); pulses[pulseIdx].colour.v = MAX_VAL; pulses[pulseIdx].position = startingPosition; startingPosition -= 3; if (startingPosition < 0) startingPosition += NUM_LEDS; } pulseClearFrameBuffer(); for (int i = 0; i < pulseCount; ++i) { pulseUpdate(pulses + i); pulseRender(pulses + i); } ws2812_setleds(frameBuffer, 40); // Blocks for ~1.2ms _delay_ms(2); // The sensor line will be noisy for a little while } }
/*! \reimp */ void Q3ProgressBar::setVisible(bool visible) { if (visible) setIndicator(progress_str, progress_val, total_steps); QFrame::setVisible(visible); }
/*! \reimp */ void QProgressBar::show() { setIndicator( progress_str, progress_val, total_steps ); QFrame::show(); }
void Altimeter::onUpdateActivity(float dt) { _timeout -= dt; if( _timeout < 0 ) _timeout = 0; if( _timeout > 0 ) { // reset HUD resetIndicator( _window->getPanel()->find( "Digit5" ) ); resetIndicator( _window->getPanel()->find( "Digit4" ) ); resetIndicator( _window->getPanel()->find( "Digit3" ) ); resetIndicator( _window->getPanel()->find( "Digit2" ) ); resetIndicator( _window->getPanel()->find( "Digit1" ) ); resetIndicator( _window->getPanel()->find( "Digit0" ) ); resetIndicator( _window->getPanel()->find( "AuDigit5" ) ); resetIndicator( _window->getPanel()->find( "AuDigit4" ) ); resetIndicator( _window->getPanel()->find( "AuDigit3" ) ); resetIndicator( _window->getPanel()->find( "AuDigit2" ) ); resetIndicator( _window->getPanel()->find( "AuDigit1" ) ); resetIndicator( _window->getPanel()->find( "AuDigit0" ) ); } else { // retrieve parent actor altitude Matrix4f parentPose = _parent->getPose(); float altitude = parentPose[3][1]; // draw signum digit setSignumIndicator( _window->getPanel()->find( "Digit5" ), altitude ); // absolute units conversion float meters = fabs( altitude ) * 0.01f; int units = int( meters ); // digits pickup int digit = units % 10; setIndicator( _window->getPanel()->find( "Digit0" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "Digit1" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "Digit2" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "Digit3" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "Digit4" ), digit ); // update audible altimeter gui::IGuiPanel* auCaption = _window->getPanel()->find( "AuCaption" ); assert( auCaption && auCaption->getStaticText() ); if( _state->mode ) { auCaption->getStaticText()->setText( Gameplay::iLanguage->getUnicodeString(217) ); } else { auCaption->getStaticText()->setText( Gameplay::iLanguage->getUnicodeString(216) ); } // audible altimeter signum indicator setSignumIndicator( _window->getPanel()->find( "AuDigit5" ), _state->altitude ); // absolute units conversion meters = fabs( _state->altitude ) * 0.01f; units = int( meters ); // digits pickup digit = units % 10; setIndicator( _window->getPanel()->find( "AuDigit0" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "AuDigit1" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "AuDigit2" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "AuDigit3" ), digit ); units = units / 10; digit = units % 10; setIndicator( _window->getPanel()->find( "AuDigit4" ), digit ); // helpers act _acAMTimeout -= dt; _acIWATimeout -= dt; _acDWATimeout -= dt; if( _acAMTimeout < 0 ) _acAMTimeout = 0; if( _acIWATimeout < 0 ) _acIWATimeout = 0; if( _acDWATimeout < 0 ) _acDWATimeout = 0; // altimeter control ActionChannel* acAM = Gameplay::iGameplay->getActionChannel( ::iaAltimeterMode ); ActionChannel* acIWA = Gameplay::iGameplay->getActionChannel( ::iaIncreaseWarningAltitude ); ActionChannel* acDWA = Gameplay::iGameplay->getActionChannel( ::iaDecreaseWarningAltitude ); assert( acAM ); assert( acIWA ); assert( acDWA ); if( !acAM->getTrigger() ) _acAMTimeout = 0; if( !acIWA->getTrigger() ) _acIWATimeout = 0; if( !acDWA->getTrigger() ) _acDWATimeout = 0; if( acAM->getTrigger() && _acAMTimeout == 0 ) { _acAMTimeout = acAMTimeout; if( _state->mode ) { _toneSound->release(); _toneSound = NULL; } _state->mode = !_state->mode; if( _state->mode ) { _toneSound = Gameplay::iAudio->createStaticSound( "./res/sounds/hud/aualt0.ogg" ); _toneSound->setLoop( true ); } } if( acIWA->getTrigger() && _acIWATimeout == 0 ) { _acIWATimeout = acXWATimeout; _state->altitude += 1000; } if( acDWA->getTrigger() && _acDWATimeout == 0 ) { _acDWATimeout = acXWATimeout; _state->altitude -= 1000; } // play tone sound if( altitude < _state->altitude && _toneSound ) { if( !_toneSound->isPlaying() ) _toneSound->play(); } else if( _toneSound ) { if( _toneSound->isPlaying() ) _toneSound->stop(); } } }