Пример #1
0
AP_ADC_HIL::AP_ADC_HIL()
{
	// gyros set to zero for calibration
	setGyro(0,0);
	setGyro(1,0);
	setGyro(2,0);

	// accels set to zero for calibration
	setAccel(0,0);
	setAccel(1,0);
	setAccel(2,0);

	// set diff press and temp to zero
	setGyroTemp(0);
	setPressure(0);
}
Пример #2
0
void TransportButton::setState(TransportButton::TransState state)
{
  QKeySequence a=accel();
  button_state=state;
  switch(button_state) {
      case TransportButton::On:
	flashOff();
	if(isEnabled()) {
	  setPixmap(*on_cap);
	}
	break;
      case TransportButton::Off:
	flashOff();
	if(isEnabled()) {
	  setPixmap(*off_cap);
	}
	break;
      case TransportButton::Flashing:
	if(isEnabled()) {
	  flashOn();
	}
	break;
  }
  setAccel(a);
}
Пример #3
0
void QButton::setPixmap( const QPixmap &pixmap )
{
    if ( bpixmap && bpixmap->serialNumber() == pixmap.serialNumber() )
	return;

    bool newSize;
    if ( bpixmap ) {
	newSize = pixmap.width() != bpixmap->width() ||
		  pixmap.height() != bpixmap->height();
	*bpixmap = pixmap;
    } else {
	newSize = TRUE;
	bpixmap = new QPixmap( pixmap );
	CHECK_PTR( bpixmap );
    }
    if ( bpixmap->depth() == 1 && !bpixmap->mask() )
	bpixmap->setMask( *((QBitmap *)bpixmap) );
    if ( !btext.isNull() )
	btext = QString::null;
    if ( autoresize && newSize )
	adjustSize();
    setAccel( 0 );
    if ( autoMask() )
	updateMask();
    update();
    updateGeometry();
}
Пример #4
0
// constructor
RAMBLERBot::RAMBLERBot(): button_(ZUMO_BUTTON)
{
  pinMode(LED_PIN, OUTPUT);
  state_ = ESTOP;
  heading_ = 0;
  setAccel(25);

  headingAvg_.SetWindow(10);
}
Пример #5
0
int QMenuData::insertItem( const QPixmap &pixmap,
			   const QObject *receiver, const char* member,
			   int accel, int id, int index )
{
    int actualID = insertAny( 0, &pixmap, 0, 0, id, index );
    connectItem( actualID, receiver, member );
    if ( accel )
	setAccel( accel, actualID );
    return actualID;
}
Пример #6
0
// Set one channel value
void AP_ADC_HIL::setHIL(int16_t p, int16_t q, int16_t r, int16_t gyroTemp,
                        int16_t aX, int16_t aY, int16_t aZ, int16_t diffPress)
{
    // gyros
    setGyro(0,p);
    setGyro(1,q);
    setGyro(2,r);

    // temp
    setGyroTemp(gyroTemp);

    // accel
    setAccel(0,aX);
    setAccel(1,aY);
    setAccel(2,aZ);

    // differential pressure
    setPressure(diffPress);
}
Пример #7
0
int QMenuData::insertItem( const QIconSet& icon,
			   const QString &text,
			   const QObject *receiver, const char* member,
			   int accel, int id, int index )
{
    int actualID = insertAny( &text, 0, 0, &icon, id, index );
    connectItem( actualID, receiver, member );
    if ( accel )
	setAccel( accel, actualID );
    return actualID;
}
Пример #8
0
void TransportButton::enabledChange(bool oldEnabled)
{
  QKeySequence a=accel();
  if(isEnabled()&&!oldEnabled) {
    setState(button_state);
    update();
  }
  if(!isEnabled()&&oldEnabled) {
    update();
    setAccel(a);
  }
}
Пример #9
0
void MD22::init(boolean transmit) {
	prevM1 = 300;
	prevM2 = 300;

	setMode(modeValue, transmit);
	delayMicroseconds(100);
	setAccel(accelValue, transmit);

	if (transmit) {
		stopAll();
	}
}
ToolBarItem::ToolBarItem( QWidget *parent, QWidget *toolBar,
			  const QString &label, const QString &tagstr,
			  const QIconSet &icon, const QKeySequence &key )
    : QAction( parent )
{
    setIconSet( icon );
    setText( label );
    setAccel( key );
    addTo( toolBar );
    tag = tagstr;
    connect( this, SIGNAL( activated() ), this, SLOT( wasActivated() ) );
}
Пример #11
0
void RDTransportButton::flashClock()
{
  QKeySequence a=accel();
  if(flash_state) {
    flash_state=false;
    setPixmap(*off_cap);
  }
  else {
    flash_state=true;
    setPixmap(*on_cap);
  }
  setAccel(a);
}
Пример #12
0
void RDTransportButton::enabledChange(bool oldEnabled)
{
  QKeySequence a=accel();
  if(isEnabled()&&!oldEnabled) {
    setState(button_state);
    update();
  }
  if(!isEnabled()&&oldEnabled) {
//    setPixmap(*grey_cap);
    update();
    setAccel(a);
  }
}
Пример #13
0
void RDPushButton::tickClock(bool state)
{
  if(!flashing_enabled) {
    return;
  }
  QKeySequence a=accel();
  if(state) {
    flash_state=false;
    QPushButton::setPalette(flash_palette);
  }
  else {
    flash_state=true;
    QPushButton::setPalette(off_palette);
  }
  setAccel(a);
}
Пример #14
0
void RDTransportButton::resizeEvent(QResizeEvent *event)
{
  QKeySequence a=accel();
  drawOnCap();
  drawOffCap();
  switch(button_state) {
      case RDTransportButton::Off:
	setPixmap(*off_cap);
	break;
      case RDTransportButton::On:
	setPixmap(*on_cap);
	break;
      default:
	setPixmap(*off_cap);
	break;
  }
  setAccel(a);
}
Пример #15
0
void Cheerio::processCollision(Car &car) {
    GLdouble speed = car.getSpeed() * 1.1f;
    const auto reverse = (speed / fabs(speed) < 0);

    if( fabs(speed) > cm(2) ) {
        Vector3 orientation = car.getOrientation();

        if (reverse) {
            setOrientation( orientation * -1 );
            setSpeed( speed * -1 );
        } else {
            setOrientation( orientation );
            setSpeed( speed );
        }

        setAccel( cm(-40) );
        car.stop();
    }
}
Пример #16
0
void QButton::setText( const QString &text )
{
    if ( btext == text )
	return;
    btext = text;

    if ( bpixmap ) {
	delete bpixmap;
	bpixmap = 0;
    }

    if ( autoresize )
	adjustSize();

#ifndef QT_NO_ACCEL
    setAccel( QAccel::shortcutKey( btext ) );
#endif

    update();
    updateGeometry();
}
Пример #17
0
void eggManagement2() {
  ///////////////////////////////////
  // Leader checks if there's food(egg)
  ///////////////////////////////////
for(int o=0; o<objcount; o++) {
  for(int f=0; f<foodcount; f++) {
	   setAccel(food[f].acceleration, food[f].velocity, food[f].mass, 0, 0, 0, windvelocity, 0);
	   eulerInt(food[f].position, food[f].velocity, food[f].acceleration, dt);
	   
	  repelAttractVelocity(food[f].position, 
		                   food[f].mass,
						   boid[o].position,
						   food[f].gravity,
							ATTRACT,
							boid[o].velocity);

	  if (food[f].stolen) {
		  boidVelocityMatch(boid[2].velocity, food[f].velocity, 0.5);
		  boidCentering(boid[2].position, food[f].position, food[f].velocity, 0.05);
		  boidAvoidance(boid[2].position, food[f].position, food[f].velocity, 0.5);
		  //boidAvoidance(food[f].position, food[f+1].position, food[f+1].velocity, 0.5);
	  }
	  /////////////////////////////////////////////////////////
	  // if close enough steal food
	  /////////////////////////////////////////////////////////
	  if(distance3d(food[f].position, boid[o].position) <  0.5) {
		  // how long to linger around food before actually taking it
		  linger -= 0.0005; 
		  if(linger < 0.0) {
			  IsFoodPresent		= false;
			  revballgravity	= revball_init;
			  food[f].stolen	= true;
			  food[f].thief		= 1;
			  food[f].gravity	= 0.0;
			  food[f].love		= 0.0;
		  }
	  }
  }
}
}
Пример #18
0
void predatorPolygonCollision() {
	for (int i=0; i<predcount; i++) {
		// Save old position for use in collision detection later
		vec3d pStart = predator[i].position;

		//vec3d Pos, Vel;
		setAccel(predator[i].acceleration, predator[i].velocity, predator[i].mass, xgravity, -ygravity, zgravity, windvelocity, k);
		eulerInt(predator[i].position, predator[i].velocity, predator[i].acceleration, dt);
	
		// Save new position for use in collision detection later
		vec3d pDest = predator[i].position;
	
		// Collision with own habitat
		for(int p=0; p<habcount; p++) {
			detectAndReflect(habitat[p], pStart, pDest, predator[i].velocity, e);
		}

		// Collision with other polygons
		for(int p=0; p<tricount; p++) {
			detectAndReflect(triangle[p], pStart, pDest, predator[i].velocity, e);
			
			// Repellance with other polygons
			if(distance3d(triangle[p].topleft, predator[i].position) < 35.0) {
				repelAttractVelocity(triangle[p].topleft, 
									raMass, 
									predator[i].position, 
									raForce, 
									REPEL,
									predator[i].velocity);
				repelAttractVelocity(triangle[p].topright, 
									raMass, 
									predator[i].position, 
									raForce, 
									REPEL,
									predator[i].velocity);
			}
		}
	}
}
Пример #19
0
void QButton::setText(const QString &text)
{
  if (btext == text)
    return;
  btext = text;
#ifndef QT_NO_ACCEL
  setAccel(QAccel::shortcutKey(text));
#endif

  if (bpixmap) {
    delete bpixmap;
    bpixmap = 0;
  }

  if (autoresize)
    adjustSize();

  update();
  updateGeometry();

#if defined(QT_ACCESSIBILITY_SUPPORT)
  QAccessible::updateAccessibility( this, 0, QAccessible::NameChanged );
#endif
}
Пример #20
0
void GCode::do_m_code()
{
#ifdef USE_MARLIN
// Marlin's only method of synchronizing these sorts of commands is to wait 'till it's cleared out.
  if(!Marlin::isBufferEmpty())
    return;
#endif

  switch(cps[M].getInt())
  {
    case 0: // Finish up and shut down.
    case 18: // 18 used by RepG.
    case 84: // "Stop Idle Hold" == shut down motors.
      SETOBJ(disableAllMotors());
      state = DONE;
      break;
    case 104: // Set Extruder Temperature (Fast)
      SKIPEXTRUDE;
      if(cps[S].isUnused() || TEMPERATURE.setHotend(cps[S].getInt()))
      {
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source);
#endif
        state = DONE;
      }
      break;
    case 105: // Get Extruder Temperature
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source); 
#else
        write_temps_to_host(source);
#endif        
        state = DONE;

      state = DONE;
      break;
#ifndef USE_MBIEC
    case 106: // Fan on
      if(!fanpin.isNull())
      {
        fanpin.setValue(true);
      }
      state = DONE;
      break;
    case 107: // Fan off
      if(!fanpin.isNull())
      {
        fanpin.setValue(false);
      }
      state = DONE;
      break;
#else
    case 106: // Fan on
      if(TEMPERATURE.setFan(true))
        state = DONE;
      break;
    case 107: // Fan off
      if(TEMPERATURE.setFan(false))
        state = DONE;
      break;
#endif
    case 109: // Set Extruder Temperature
      SKIPEXTRUDE;
      if(state != ACTIVE && (cps[S].isUnused() || TEMPERATURE.setHotend(cps[S].getInt())))
        state = ACTIVE;

      if(state == ACTIVE && TEMPERATURE.getHotend() >= TEMPERATURE.getHotendST())
      {
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source);
        write_temps_to_host(source);
#endif        
        state = DONE;
      }

      if(millis() - lastms > 1000)
      {
        lastms = millis();
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source); 
#else
        write_temps_to_host(source);
#endif        
      }
      break;
    case 110: // Set Current Line Number
      GCODES.setLineNumber(cps[S].isUnused() ? 1 : cps[S].getInt());
      state = DONE;
      break;
    case 114: // Get Current Position
#ifndef REPG_COMPAT    
      Host::Instance(source).labelnum("prog ", linenum, false);
      Host::Instance(source).write(' ');
#endif      
      Host::Instance(source).write("C: ");
      SETOBJ(writePositionToHost(*this));
      // TODO
      Host::Instance(source).endl();
      state = DONE;
      break; 
    case 115: // Get Firmware Version and Capabilities
      Host::Instance(source).labelnum("prog ", linenum, false);
      Host::Instance(source).write_P(PSTR(" VERSION:" SJFW_VERSION " FREE_RAM:"));
      Host::Instance(source).write(getFreeRam(),10);
      Host::Instance(source).write_P(PSTR(" FEATURES:0/crc-v2"));
      Host::Instance(source).endl();
      state = DONE;
      break;
    case 116: // Wait on temperatures
      SKIPEXTRUDE;
      if(TEMPERATURE.getHotend() >= TEMPERATURE.getHotendST() && TEMPERATURE.getPlatform() >= TEMPERATURE.getPlatformST())
        state = DONE;

      if(millis() - lastms > 1000)
      {
        lastms = millis();
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source); 
#else
        write_temps_to_host(source);
#endif        
      }
      break;
    case 118: // Choose optional features TODO: implement properly when we have > 1 option
      if(!cps[P].isUnused())
      {
        if(cps[P].getInt() == 1)
          GCODES.enableADVANCED_CRC(source);
        else
          GCODES.disableADVANCED_CRC(source);
      }
    case 140: // Bed Temperature (Fast) 
      SKIPEXTRUDE;
      if(cps[S].isUnused() || TEMPERATURE.setPlatform(cps[S].getInt()))
      {
#ifndef REPG_COMPAT        
        Host::Instance(source).labelnum("prog ", linenum, false); Host::Instance(source).write(' ');  write_temps_to_host(source); 
#endif        
        state = DONE;
      }
      break;
    case 200: // NOT STANDARD - set Steps Per Unit
      SETOBJ(setStepsPerUnit(*this));
      state = DONE;
      break;
    case 201: // NOT STANDARD - set Feedrates
      SETOBJ(setMinimumFeedrate(*this));
      state = DONE;
      break;
    case 202: // NOT STANDARD - set Feedrates
      SETOBJ(setMaximumFeedrate(*this));
      state = DONE;
      break;
    case 203: // NOT STANDARD - set Feedrates
      SETOBJ(setAverageFeedrate(*this));
      state = DONE;
      break;
#ifdef HAS_SD
    case 204: // NOT STANDARD - get next filename from SD
      Host::Instance(source).labelnum("prog ", linenum, false);
      Host::Instance(source).write(' ');
      Host::Instance(source).write(sdcard::getNextfile());
      Host::Instance(source).endl();
      state = DONE;
      break;
    case 205: // NOT STANDARD - print file from last 204
      Host::Instance(source).labelnum("prog ", linenum, false);
      Host::Instance(source).write(sdcard::getCurrentfile());
      if(sdcard::printcurrent())
        Host::Instance(source).write_P(PSTR(" BEGUN"));
      else
        Host::Instance(source).write_P(PSTR(" FAIL"));
     
      Host::Instance(source).endl();
      state = DONE;
      break;
#endif
    case 206: // NOT STANDARD - set accel rate
      SETOBJ(setAccel(*this));
      state = DONE;
      break;
    case 207: // NOT STANDARD - set hotend thermistor pin
      if(!cps[P].isUnused())
        TEMPERATURE.changePinHotend(cps[P].getInt());
      if(!cps[S].isUnused())
        TEMPERATURE.changeOutputPinHotend(cps[S].getInt());
      state = DONE;
      break;
    case 208: // NOT STANDARD - set platform thermistor pin
      if(!cps[P].isUnused())
        TEMPERATURE.changePinPlatform(cps[P].getInt());
      if(!cps[S].isUnused())
        TEMPERATURE.changeOutputPinPlatform(cps[S].getInt());
      state = DONE;
      break;
    case 211: // NOT STANDARD - request temp reports at regular interval
      if(cps[P].isUnused())
        TEMPERATURE.changeReporting(0, Host::Instance(source));
      else
        TEMPERATURE.changeReporting(cps[P].getInt(), Host::Instance(source));
      state = DONE;
      break;
    case 215: // NOT STANDARD - set arbitrary digital pin
      if(!cps[P].isUnused() && !cps[S].isUnused())
      {
        doPinSet(cps[P].getInt(), cps[S].getInt());
      }
      state = DONE;
      break;
    case 216: // NOT STANDARD - set fan pin
      if(!cps[P].isUnused())
      {
        fanpin = Pin(ArduinoMap::getPort(cps[P].getInt()),  ArduinoMap::getPinnum(cps[P].getInt()));
        fanpin.setDirection(true);
        fanpin.setValue(false);
      }
      state = DONE;
      break;
    case 220: // NOT STANDARD - set endstop minimum positions
      SETOBJ(setMinStopPos(*this));
      state = DONE;
      break;
    case 221: // NOT STANDARD - set endstop minimum positions
      SETOBJ(setMaxStopPos(*this));
      state = DONE;
      break;
#ifdef HAS_LCD      
    case 250: // NOT STANDARD - LCD RS pin
      if(!cps[P].isUnused())
        LCDKEYPAD.setRS(cps[P].getInt());
      state = DONE;
      break;
    case 251: // NOT STANDARD - LCD RW pin
      if(!cps[P].isUnused())
        LCDKEYPAD.setRW(cps[P].getInt());
      state = DONE;
      break;
    case 252: // NOT STANDARD - LCD E pin
      if(!cps[P].isUnused())
        LCDKEYPAD.setE(cps[P].getInt());
      state = DONE;
      break;
    case 253: // NOT STANDARD - LCD D pins
      if(!cps[P].isUnused() && !cps[S].isUnused())
        LCDKEYPAD.setD(cps[S].getInt(), cps[P].getInt());
      state = DONE;
      break;
    case 254: // NOT STANDARD - Keypad Row Pins
      if(!cps[P].isUnused() && !cps[S].isUnused())
        LCDKEYPAD.setRowPin(cps[S].getInt(), cps[P].getInt());
      state = DONE;
      break;
    case 255: // NOT STANDARD - Keypad Col Pins
      if(!cps[P].isUnused() && !cps[S].isUnused())
        LCDKEYPAD.setColPin(cps[S].getInt(), cps[P].getInt());
      state = DONE;
      break;
    case 256: // NOT STANDARD - reinit LCD.  This is a temporary 'fix' for the init timing errors
      LCDKEYPAD.reinit();
      state = DONE;
      break;
#endif
    case 300: // NOT STANDARD - set axis STEP pin
      SETOBJ(setStepPins(*this));
      state = DONE;
      break;
    case 301: // NOT STANDARD - set axis DIR pin
      SETOBJ(setDirPins(*this));
      state = DONE;
      break;
    case 302: // NOT STANDARD - set axis ENABLE pin
      SETOBJ(setEnablePins(*this));
      state = DONE;
      break;
    case 304: // NOT STANDARD - set axis MIN pin
      SETOBJ(setMinPins(*this));
      state = DONE;
      break;
    case 305: // NOT STANDARD - set axis MAX pin
      SETOBJ(setMaxPins(*this));
      state = DONE;
      break;
    case 307: // NOT STANDARD - set axis invert
      SETOBJ(setAxisInvert(*this));
      state = DONE;
      break;
    case 308: // NOT STANDARD - set axis disable
      SETOBJ(setAxisDisable(*this));
      state = DONE;
      break;
    case 309: // NOT STANDARD - set global endstop invert, endstop pullups.
      SETOBJ(setEndstopGlobals(cps[P].getInt() == 1 ? true: false, cps[S].getInt() == 1 ? true: false));
      state = DONE;
      break;
    case 310: // NOT STANDARD - report axis configuration status
      SETOBJ(reportConfigStatus(Host::Instance(source)));
      state = DONE;
      break;
    case 350: // NOT STANDARD - change gcode optimization
      if(!cps[P].isUnused() && cps[P].getInt() == 1)
        GCODES.enableOptimize();
      else
        GCODES.disableOptimize();
      state = DONE;
      break;
    case 351: // NOT STANDARD - disable extruder commands (test print option)
      if(!cps[P].isUnused() && cps[P].getInt() == 1)
        DONTRUNEXTRUDER = true;
      else
        DONTRUNEXTRUDER = false;
      state = DONE;
      break;
    // case 400,402 handled by GcodeQueue immediately, not queued.
    case 401: // Execute stored eeprom code.
      Host::Instance(source).write_P(PSTR("EEPROM READ: "));
      if(eeprom::beginRead())
        Host::Instance(source).write_P(PSTR("BEGUN"));
      else
        Host::Instance(source).write_P(PSTR("FAIL"));
      Host::Instance(source).endl();
      state = DONE;
      break;
    // NOT STANDARD - set thermistor table
    case 501: case 502: case 503: case 504: case 505: case 506: case 507: case 508: case 509: case 510:
    case 511: case 512: case 513: case 514: case 515: case 516: case 517: case 518: case 519: case 520:
      if(!cps[P].isUnused() && !cps[S].isUnused())
      {
        TEMPERATURE.changeTempTable(cps[P].getInt(), cps[S].getInt(), cps[M].getInt() - 501);
      }
      state = DONE;
      break;
    default:
      Host::Instance(source).labelnum("warn ", linenum, false);
      Host::Instance(source).write_P(PSTR(" MCODE ")); Host::Instance(source).write(cps[M].getInt(), 10); Host::Instance(source).write_P(PSTR(" NOT SUPPORTED\n"));
      state = DONE;
      break;
  }
#ifndef REPRAP_COMPAT  
  if(state == DONE)
  {
    if(linenum != -1)
      Host::Instance(source).labelnum("done ", linenum, false);
    else
      Host::Instance(source).write_P(PSTR("done "));

    Host::Instance(source).labelnum(" M", cps[M].getInt(), true);
  }
#endif
}
Пример #21
0
void MouseConfig::defaultSettings()
{
  setThreshold(2);
  setAccel(2);
  setHandedness(RIGHT_HANDED);
}
Пример #22
0
bool QAction::qt_property( int id, int f, QVariant* v)
{
    switch ( id - staticMetaObject()->propertyOffset() ) {
    case 0: switch( f ) {
	case 0: setToggleAction(v->asBool()); break;
	case 1: *v = QVariant( this->isToggleAction(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 1: switch( f ) {
	case 0: setOn(v->asBool()); break;
	case 1: *v = QVariant( this->isOn(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 2: switch( f ) {
	case 0: setEnabled(v->asBool()); break;
	case 1: *v = QVariant( this->isEnabled(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 3: switch( f ) {
	case 0: setIconSet(v->asIconSet()); break;
	case 1: *v = QVariant( this->iconSet() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 4: switch( f ) {
	case 0: setText(v->asString()); break;
	case 1: *v = QVariant( this->text() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 5: switch( f ) {
	case 0: setMenuText(v->asString()); break;
	case 1: *v = QVariant( this->menuText() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 6: switch( f ) {
	case 0: setToolTip(v->asString()); break;
	case 1: *v = QVariant( this->toolTip() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 7: switch( f ) {
	case 0: setStatusTip(v->asString()); break;
	case 1: *v = QVariant( this->statusTip() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 8: switch( f ) {
	case 0: setWhatsThis(v->asString()); break;
	case 1: *v = QVariant( this->whatsThis() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 9: switch( f ) {
	case 0: setAccel(v->asKeySequence()); break;
	case 1: *v = QVariant( this->accel() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 10: switch( f ) {
	case 0: setVisible(v->asBool()); break;
	case 1: *v = QVariant( this->isVisible(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    default:
	return QObject::qt_property( id, f, v );
    }
    return TRUE;
}
Пример #23
0
	void SnakeBoss::update()
	{
		//snake update
		float distance, angle;
		float x, y;

		_pieces[0]->setCenter(getX(), getY());
		_pieces[0]->setAngleR(getAngleR());
		_pieces[0]->setSpeed(getSpeed());
		//_pieces[0]->activate();

		for (int i = 1; i < LENGTH; i++)
		{
			distance = myUtil::getDistance(_pieces[i - 1]->getX(), _pieces[i - 1]->getY(), _pieces[i]->getX(), _pieces[i]->getY());
			angle = myUtil::getAngle(_pieces[i - 1]->getX(), _pieces[i - 1]->getY(), _pieces[i]->getX(), _pieces[i]->getY());

			while (angle < 0) angle += M_PI * 2;
			while (angle >(M_PI * 2)) angle -= M_PI * 2;

			if (distance > 45)
			{
				x = cos(angle) * 45;
				y = -sin(angle) * 45;
				_pieces[i]->setCenter(_pieces[i - 1]->getX() + x, _pieces[i - 1]->getY() + y);
				_pieces[i]->setAngleR(angle);
			}
			else
			{
				_pieces[i]->setX(_pieces[i]->getX() - cos(_pieces[i]->getAngleR()) * 9.9);
				_pieces[i]->setY(_pieces[i]->getY() + sin(_pieces[i]->getAngleR()) * 9.9);
			}
			
		}


		//moving
		if (!tileCollision() ||
			getX() < 0 || getX() > MAP_SIZE_X * METER_TO_PIXEL ||
			getY() < 0 || getY() > MAP_SIZE_Y * METER_TO_PIXEL)
		{
			setAccel(0);
			setAccelY(GRAVITY_ACCEL / 2);

			//angle = min(M_PI / 4, abs((myUtil::getDistance(getX(), getY(), _player->getX(), _player->getY()) / (_option.width() / 2)) * (M_PI / 8)));
		}
		else
		{
			angle = min(M_PI, abs((myUtil::getDistance(getX(), getY(), _player->getX(), _player->getY()) / (_option.width() / 2)) * (M_PI)));

			setAccelY(0);
			
			setAccel(METER_TO_PIXEL * 80);
			//setSpeed(METER_TO_PIXEL * 80);
			int direct = 0;
			float destAngle = myUtil::getAngle(getX(), getY(), _player->getX(), _player->getY() - METER_TO_PIXEL * 5);
			float sourAngle = getAngleR();

			while (destAngle < 0) destAngle += M_PI * 2;
			while (destAngle >(M_PI * 2)) destAngle -= M_PI * 2;
			while (sourAngle < 0) sourAngle += M_PI * 2;
			while (sourAngle >(M_PI * 2)) sourAngle -= M_PI * 2;
			while (angle < 0) angle += M_PI * 2;
			while (angle >(M_PI * 2)) angle -= M_PI * 2;

			if (destAngle > sourAngle)
			{
				if (abs(destAngle - sourAngle) < (M_PI / 32)) direct = 0;
				else if (abs(destAngle - sourAngle) > M_PI) direct = 2;
				else direct = 1;
			}
			else
			{
				if (abs(destAngle - sourAngle) < (M_PI / 32)) direct = 0;
				else if (abs(destAngle - sourAngle) > M_PI) direct = 1;
				else direct = 2;
			}

			switch (direct)
			{
			case 1:
				setAngleR(sourAngle + (angle * TIMEMANAGER->getElapsedTime()));
				break;
			case 2:
				setAngleR(sourAngle - (angle * TIMEMANAGER->getElapsedTime()));
				break;
			case 0:
				setAngleR(destAngle);
				break;
			}
		}

		activate();
	}
Пример #24
0
void MouseConfig::GetSettings( void )
{
  int accel_num, accel_den, threshold;
  XGetPointerControl( kapp->getDisplay(), 
		      &accel_num, &accel_den, &threshold );
  accel_num /= accel_den;   // integer acceleration only

  // get settings from X server
  int h = RIGHT_HANDED;
  unsigned char map[5];
  num_buttons = XGetPointerMapping(kapp->getDisplay(), map, 5);
      
  switch (num_buttons)
    {
    case 1:
      /* disable button remapping */
      if (GUI)
	{
	  rightHanded->setEnabled(FALSE);
	  leftHanded->setEnabled(FALSE);
	  handedEnabled = FALSE;
	}
      break;
    case 2:
      if ( (int)map[0] == 1 && (int)map[1] == 2 )
	h = RIGHT_HANDED;
      else if ( (int)map[0] == 2 && (int)map[1] == 1 )
	h = LEFT_HANDED;
      else
	{
	  /* custom button setup: disable button remapping */
	  if (GUI)
	    {
	      rightHanded->setEnabled(FALSE);
	      leftHanded->setEnabled(FALSE);
	    }
	}
      break;
    case 3:
      middle_button = (int)map[1];
      if ( (int)map[0] == 1 && (int)map[2] == 3 )
	h = RIGHT_HANDED;
      else if ( (int)map[0] == 3 && (int)map[2] == 1 )
	h = LEFT_HANDED;
      else
	{
	  /* custom button setup: disable button remapping */
	  if (GUI)
	    {
	      rightHanded->setEnabled(FALSE);
	      leftHanded->setEnabled(FALSE);
	      handedEnabled = FALSE;
	    }
	}
      break;
    default:
      /* custom setup with > 3 buttons: disable button remapping */
      if (GUI)
	{
	  rightHanded->setEnabled(FALSE);
	  leftHanded->setEnabled(FALSE);
	  handedEnabled = FALSE;
	}
      break;
    }

  config->setGroup("Mouse");
  int a = config->readNumEntry("Acceleration",-1);
  if (a == -1)
    accelRate = accel_num;
  else
    accelRate = a;

  int t = config->readNumEntry("Threshold",-1);
  if (t == -1)
    thresholdMove = threshold;
  else
    thresholdMove = t;

  QString key = config->readEntry("MouseButtonMapping");
  if (key == "RightHanded")
    handed = RIGHT_HANDED;
  else if (key == "LeftHanded")
    handed = LEFT_HANDED;
  else if (key == NULL)
    handed = h;

  // the GUI should always show the real values
  if (GUI)
    {
      setAccel(accel_num);
      setThreshold(threshold);
      setHandedness(h);
    }
}
int Q3Action::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: activated(); break;
        case 1: toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: activate(); break;
        case 3: toggle(); break;
        case 4: setOn((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 5: setEnabled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: setDisabled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 7: setVisible((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: internalActivation(); break;
        case 9: toolButtonToggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: objectDestroyed(); break;
        case 11: menuStatusText((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: showStatusText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 13: clearStatusText(); break;
        }
        _id -= 14;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isToggleAction(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isOn(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        case 3: *reinterpret_cast< QIcon*>(_v) = iconSet(); break;
        case 4: *reinterpret_cast< QString*>(_v) = text(); break;
        case 5: *reinterpret_cast< QString*>(_v) = menuText(); break;
        case 6: *reinterpret_cast< QString*>(_v) = toolTip(); break;
        case 7: *reinterpret_cast< QString*>(_v) = statusTip(); break;
        case 8: *reinterpret_cast< QString*>(_v) = whatsThis(); break;
        case 9: *reinterpret_cast< QKeySequence*>(_v) = accel(); break;
        case 10: *reinterpret_cast< bool*>(_v) = isVisible(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setToggleAction(*reinterpret_cast< bool*>(_v)); break;
        case 1: setOn(*reinterpret_cast< bool*>(_v)); break;
        case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 3: setIconSet(*reinterpret_cast< QIcon*>(_v)); break;
        case 4: setText(*reinterpret_cast< QString*>(_v)); break;
        case 5: setMenuText(*reinterpret_cast< QString*>(_v)); break;
        case 6: setToolTip(*reinterpret_cast< QString*>(_v)); break;
        case 7: setStatusTip(*reinterpret_cast< QString*>(_v)); break;
        case 8: setWhatsThis(*reinterpret_cast< QString*>(_v)); break;
        case 9: setAccel(*reinterpret_cast< QKeySequence*>(_v)); break;
        case 10: setVisible(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Пример #26
0
void PlayerMoveComponent::determineDirection(){
	//Je nach dem welche Taste eingegeben wurde wird mit maximaler Beschleunigung in die zugwiesene Richtung beschleunigt
	if(keyStates['w'] || keyStates['W']){
		if(keyStates['a'] || keyStates['A'])
			setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
		else if(keyStates['d'] || keyStates['D'])
			setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
		else setAccel(CVector(0.0,MAX_ACCEL));
		return;
	}

	if(keyStates['a'] || keyStates['A']){
		if(keyStates['w'] || keyStates['W'])
			setAccel(CVector(-MAX_ACCEL,MAX_ACCEL));
		else if(keyStates['s'] || keyStates['S'])
			setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
		else setAccel(CVector(-MAX_ACCEL,0));
		return;
	}

	if(keyStates['s'] || keyStates['S']){
		if(keyStates['d'] || keyStates['D'])
			setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
		else if(keyStates['a'] || keyStates['A'])
			setAccel(CVector(-MAX_ACCEL,-MAX_ACCEL));
		else setAccel(CVector(0,-MAX_ACCEL));
		return;
	}

	if(keyStates['d'] || keyStates['D']){
		if(keyStates['s'] || keyStates['S'])
			setAccel(CVector(MAX_ACCEL,-MAX_ACCEL));
		else if(keyStates['w'] || keyStates['W'])
			setAccel(CVector(MAX_ACCEL,MAX_ACCEL));
		else setAccel(CVector(MAX_ACCEL,0));
		return;
	}

	//Wenn nichts gedrückt wurde, kommt der Spieler langsam zum stehen
	if(velocity!=CVector(0,0)){
		float x = 0.0;
		float y = 0.0;
		if(velocity[0]>0)
			x = -MAX_ACCEL;
		else
			x = MAX_ACCEL;

		if(velocity[1]>0)
			y = -MAX_ACCEL;
		else
			y = MAX_ACCEL;
		setAccel(CVector(x,y));
	}
}
Пример #27
0
/*
 * Configuration de la valeur d'accéleration des moteurs.
 * L'accéleration fonctionne comme suit :
 *
 * If you require a controlled acceleration period for the attached motors to reach there ultimate speed,
 * the MD22 has a register to provide this. It works by inputting a value into the acceleration register
 * which acts as a delay in the power stepping. The amount of steps is the difference between the current
 * speed of the motors and the new speed (from speed 1 and 2 registers). So if the motors were traveling
 * at full speed in the forward direction (255) and were instructed to move at full speed in reverse (0),
 * there would be 255 steps.
 *
 * The acceleration register contains the rate at which the motor board moves through the steps. At 0 (default)
 * the board changes the power (accelerates) at its fastest rate, each step taking 64us. When the acceleration
 * register is loaded with the Slowest setting of 255, the board will change the power output every 16.4ms.
 *
 * So to calculate the time (in seconds) for the acceleration to complete : time = accel reg value * 64us * steps.
 * For example :
 *
 * ----------------------------------------------------------------------------------
 * | Accel reg 	| Time/step	| Current speed	| New speed	| Steps	| Acceleration time	|
 * ----------------------------------------------------------------------------------
 * | 0			| 0			| 0				| 255		| 255	| 0					|
 * ----------------------------------------------------------------------------------
 * | 20			| 1.28ms	| 127			| 255		| 128	| 164ms				|
 * ----------------------------------------------------------------------------------
 * | 50			| 3.2ms		| 80			| 0			| 80	| 256ms				|
 * ----------------------------------------------------------------------------------
 * | 100		| 6.4ms		| 45			| 7			| 38	| 243ms				|
 * ----------------------------------------------------------------------------------
 * | 150		| 9.6ms		| 255			| 5			| 250	| 2.4s				|
 * ----------------------------------------------------------------------------------
 * | 200		| 12.8ms	| 127			| 0			| 127	| 1.63s				|
 * ----------------------------------------------------------------------------------
 * | 255		| 16.32ms	| 65			| 150		| 85	| 1.39s				|
 * ----------------------------------------------------------------------------------
 */
void MD22::setAccel(byte value) {
	setAccel(value, true);
}