Exemple #1
0
void showMinutes(void) {
    //Minutes Tens
    showNumber(minTen);
    PORTC |= MINST;
    _delay_ms(1000);
    PORTC &= ~MINST;

    //Minutes Ones
    showNumber(minOne);
    PORTC |= MINSO;
    _delay_ms(1000);
    PORTC &= ~MINSO;
}
Exemple #2
0
void showHours(void) {
    //Hours Tens
    if (hourTen > 0) {
        showNumber(hourTen);
        PORTC |= HOURT;
        _delay_ms(1000);
        PORTC &= ~HOURT;
    }
    
    //Hours Ones
    showNumber(hourOne);
    PORTC |= HOURO;
    _delay_ms(1000);
    PORTC &= ~HOURO;
}
/*!
  \brief Set the minimum and maximum values

  The maximum is adjusted if necessary to ensure that the range remains valid.
  The value might be modified to be inside of the range.

  \param min Minimum value
  \param max Maximum value

  \sa minimum(), maximum()
 */
void QwtCounter::setRange( double min, double max )
{
    max = qMax( min, max );

    if ( d_data->maximum == max && d_data->minimum == min )
        return;

    d_data->minimum = min;
    d_data->maximum = max;

    setSingleStep( singleStep() );

    const double value = qBound( min, d_data->value, max );

    if ( value != d_data->value )
    {
        d_data->value = value;

        if ( d_data->isValid )
        {
            showNumber( value );
            Q_EMIT valueChanged( value );
        }
    }

    updateButtons();
}
Exemple #4
0
static void DivideGaussian(BigInteger *real, BigInteger *imag)
{
  BigInteger Tmp, norm, realNum, imagNum;
  CopyBigInt(&Tmp, real);
  Tmp.sign = SIGN_POSITIVE;
  BigIntMultiply(real, real, &norm);
  BigIntMultiply(imag, imag, &Tmp);
  BigIntAdd(&norm, &Tmp, &norm);
  BigIntMultiply(&ReValue, real, &realNum);
  BigIntMultiply(&ImValue, imag, &Tmp);
  BigIntAdd(&realNum, &Tmp, &realNum);
  BigIntMultiply(&ImValue, real, &imagNum);
  BigIntMultiply(&ReValue, imag, &Tmp);
  BigIntSubt(&imagNum, &Tmp, &imagNum);
  BigIntRemainder(&realNum, &norm, &Tmp);
  if (Tmp.nbrLimbs == 1 && Tmp.limbs[0].x == 0)
  {
    BigIntRemainder(&imagNum, &norm, &Tmp);
    if (Tmp.nbrLimbs == 1 && Tmp.limbs[0].x == 0)
    {
      BigIntDivide(&realNum, &norm, &ReValue);
      BigIntDivide(&imagNum, &norm, &ImValue);
      w("<li>");
      showNumber(real, imag);
      w("</li>");
    }
  }
}
void QwtCounter::incrementValue( int numSteps )
{
    const double min = d_data->minimum;
    const double max = d_data->maximum;
    double stepSize = d_data->singleStep;

    if ( !d_data->isValid || min >= max || stepSize <= 0.0 )
        return;


#if 1
    stepSize = qMax( stepSize, 1.0e-10 * ( max - min ) );
#endif

    double value = d_data->value + numSteps * stepSize;

    if ( d_data->wrapping )
    {
        const double range = max - min;

        if ( value < min )
        {
            value += ::ceil( ( min - value ) / range ) * range;
        }
        else if ( value > max )
        {
            value -= ::ceil( ( value - max ) / range ) * range;
        }
    }
    else
    {
        value = qBound( min, value, max );
    }

    value = min + qRound( ( value - min ) / stepSize ) * stepSize;

    if ( stepSize > 1e-12 )
    {
        if ( qFuzzyCompare( value + 1.0, 1.0 ) )
        {
            // correct rounding error if value = 0
            value = 0.0;
        }
        else if ( qFuzzyCompare( value, max ) )
        {
            // correct rounding error at the border
            value = max;
        }
    }

    if ( value != d_data->value )
    {
        d_data->value = value;
        showNumber( d_data->value );
        updateButtons();

        Q_EMIT valueChanged( d_data->value );
    }
}
void doLoop() {
    //cascadeLeds(500);

    //test();

    uint8_t gear = getGearFromSwitchPositions();
    showNumber(gear);
}
void CardSprite::onEnter() {
  Sprite::onEnter();

  //画像の表示
  setTexture(getFileName(_card.type));

  //マークと数字の表示
  showNumber();

  //カード位置とタグを指定
  float posX = CARD_1_POS_X + CARD_DISTANCE_X * _posIndex.x;
  float posY = CARD_1_POS_Y + CARD_DISTANCE_Y * _posIndex.y;
  setPosition(posX, posY);
  setTag(_posIndex.x + _posIndex.y + 5 + 1);
}
Exemple #8
0
int main(void) {
	// setup data direction
	ONMASK(xDDR, MASK(x1pin) | MASK(x2pin) | MASK(x4pin));

	int i = 0;
	int dir = 1;
	while (1) {
		showNumber(i);
		// reverse direction @ endpoints (TODO this seems like something that could have an external validity test)
		if (i == 7) dir = -1;
		if (i == 0) dir = 1;
		i += dir;
		_delay_ms(300);
	}
}
Exemple #9
0
int smshttp::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: logIn(); break;
        case 1: showHelp(); break;
        case 2: sendSms(); break;
        case 3: updateChars(); break;
        case 4: showNumber((*reinterpret_cast< int(*)>(_a[1]))); break;
        }
        _id -= 5;
    }
    return _id;
}
void QwtCounter::setValue( double value )
{
    const double vmin = qMin( d_data->minimum, d_data->maximum );
    const double vmax = qMax( d_data->minimum, d_data->maximum );

    value = qBound( vmin, value, vmax );

    if ( !d_data->isValid || value != d_data->value )
    {
        d_data->isValid = true;
        d_data->value = value;

        showNumber( value );
        updateButtons();

        Q_EMIT valueChanged( value );
    }
}
/*! 
  Set the counter to be in valid/invalid state

  When the counter is set to invalid, no numbers are displayed and
  the buttons are disabled.

  \param on If true the counter will be set as valid 

  \sa setValue(), isValid()
*/
void QwtCounter::setValid( bool on )
{
    if ( on != d_data->isValid )
    {
        d_data->isValid = on;

        updateButtons();

        if ( d_data->isValid )
        {
            showNumber( value() );
            Q_EMIT valueChanged( value() );
        }
        else
        {
            d_data->valueEdit->setText( QString::null );
        }
    }   
}   
int main(void)
{
    //factory settings is to divide internal clock 8MHz by 8.
    //don't, and just run at 8 MHz (set the clock divider to 1 so no effect)
    CLKPR = (1<<CLKPCE);
    CLKPR = 0; // Divide by 1

    setup7seg();
    InitADC();
    setupTimer0();

    //start the interrupts
    sei();

    while(1)
    {
        showNumber((uint16_t)(mLatestPower), 0, 2, false);
    }
}
Exemple #13
0
void gaussianText(char *valueText, int doFactorization)
{
  enum eExprErr rc;
#ifndef __EMSCRIPTEN__
  groupLen = 6;
#endif
  rc = ComputeGaussianExpression(valueText, value);
  output[0] = '2';
  ptrOutput = &output[1];
  if (rc == EXPR_OK)
  {
    CopyBigInt(&ReValue, &value[0]);
    CopyBigInt(&ImValue, &value[1]);
    if (doFactorization != '0')
    {
      w(lang ? "<p>Factores de " : "<p>Factors of ");
    }
    else
    {
      w(lang ? "<p>El valor es " : "<p>Value is equal to ");
    }
    showNumber(&ReValue, &ImValue);
    if (doFactorization != '0')
    {
      GaussianFactorization();
    }
  }
  if (rc == EXPR_OK)
  {
    showElapsedTime(&ptrOutput);
  }
  else
  {
    textError(ptrOutput, rc);
    ptrOutput = output + strlen(output);
  }
  strcat(ptrOutput, lang ? "<p>" COPYRIGHT_SPANISH "</p>" :
                           "<p>" COPYRIGHT_ENGLISH "</p>");
}
Exemple #14
0
/**
 * @brief	Main routine for I2C example
 * @return	Function should not exit
 */
int main(void)
{
	int lastState = -1;

	/* Generic Initialization */
	SystemCoreClockUpdate();
	Board_Init();

	Board_LED_Set(0, false);

	/* Setup I2C pin muxing */
	Init_I2C_PinMux();

	/* Allocate I2C handle, setup I2C rate, and initialize I2C
	   clocking */
	setupI2CMaster();

	/* Enable the interrupt for the I2C */
	NVIC_EnableIRQ(I2C_IRQn);

	/* Enable SysTick Timer */
	SysTick_Config(SystemCoreClock / TICKRATE_HZ);

	//ustawiamy przykładowo godzinę 9:31
	volatile int hourH = 0;
	volatile int hourL = 9;
	volatile int minuteH = 3;
	volatile int minuteL = 1;
	volatile int seconds = 0;
	volatile int tickCounter = 0;

	/* Toggle LED on other board via I2C */
	while (1) {

		//zliczanie ticków
		tickCounter++;

		//kolejno warunki na zliczanie sekund, minut, godzin
		//w przypadku taktowania 400 ticków na sekundę
		if(tickCounter == 400) {
			tickCounter = 0;
			seconds = seconds + 1;
		}
		if(seconds == 60) {
			seconds = 0;
			minuteL = minuteL + 1;
		}
		if(minuteL == 10) {
			minuteL = 0;
			minuteH = minuteH + 1;
		}
		if(minuteH == 6) {
			minuteH = 0;
			hourL = hourL + 1;
		}
		if(hourL == 10) {
			hourL = 0;
			hourH = hourH + 1;
		}
		if(hourH == 2 && hourL == 4) {
			minuteH = 0; minuteL = 0;
			hourL = 0; hourH = 0;
		}

		//wyświetlanie aktualnej godziny
		showNumber(minuteL,LED0);
		showNumber(minuteH,LED1);
		showNumber(hourL,LED2);
		showNumber(hourH,LED3);

		/* Handle states */
		switch (state) {
		case 0:
			/* Toggle LED state value */
			ledState = (ledState == 0);
			break;

		case 1:
		default:
			break;
		}

		lastState = state;

		/* Match this board's LED to other boards state */
		Board_LED_Set(0, ledState);
	}
}
SevenSeg & SevenSeg::operator--(void)
{
    if (isNumberValid(_symbol))
        showNumber(number() - 1);
    return *this;
}
int main(void)
{
	//factory settings is to divide internal clock 8MHz by 8.
	//don't, and just run at 8 MHz (set the clock divider to 1 so no effect)
	CLKPR = (1<<CLKPCE);
	CLKPR = 0; // Divide by 1
	
	//PB1 out, PB5 & PB0 in
	DDRB = 0x02;
	//Pullup on PB0 % PB5
	PORTB = (1 << PORTB5) | (1 << PORTB0);
	//just make sure pullups are NOT disabled
	MCUCR |= (0 << PUD);
	
	setupWatchdog();
	
	setup7seg();
	
	int16_t vSpeed = 1000;
	while(1)
	{
		/*
		//1000 run makes it nearly 20 sec
		showWaitAnimation(vSpeed);
		
		vSpeed -= 20;
		if (vSpeed <= 0){
			vSpeed = 1000;
		}
		*/
		
		if (mRemainingOnDuration > ONE_SEC * 60){
			//more convert the seconds to minutes ('1+' to show remaining minutes rounded up)
			uint16_t vMinutes = 1+ (uint16_t)mRemainingOnDuration / (ONE_SEC * 60);
			//mul by 10 to shift for the display only (shows digits _XX_)
			vMinutes *= 10;
			showNumber(vMinutes, 1,2,false);
		}
		else {
			if (mRemainingOnDuration > ONE_SEC * 20){
				//until 20 sec is countdown : show seconds as is
				showNumber((uint16_t)mRemainingOnDuration, 1,2,false);
			}
			else {
				if (mRemainingOnDuration > ONE_SEC){
					//until last sec put the animation
					//1000 run makes it nearly 20 sec
					vSpeed = 1000;
					showWaitAnimation(vSpeed);
							
					vSpeed -= 20;
				}
				else {
					//zero!
					clearDisplay();
				}
			}
		}
		
		
		//check for button press : PB0 -> Add 3 minutes
		if ((~PINB & (1 << PINB0)) != 0){
			clearDisplay();
			//pushed button : turns on if not already anyway and add and extra 3 minutes
			mRemainingOnDuration +=ONE_SEC * 180;
			//max is 10 minutes
			if (mRemainingOnDuration > MAX_DURATION_SEC){
				mRemainingOnDuration = MAX_DURATION_SEC;
			}
			turnOn();
			
			//wait while pressed and wait again 1/2 sec (debouncing) 
			while ((~PINB & (1 << PINB0)) != 0);
			_delay_ms(300);
		}
		
		
		//check for button press : PB5 -> Stop now !
		if ((~PINB & (1 << PINB5)) != 0){
			clearDisplay();
			//pushed button : turns off
			mRemainingOnDuration = 0;
			turnOff();
					
			//wait while pressed and wait again 1/2 sec (debouncing)
			while ((~PINB & (1 << PINB5)) != 0);
			_delay_ms(300);
		}
	}
}