示例#1
0
文件: IO.cpp 项目: Nican/SmartMouse
void setupIOPins(){
    setupDriveControlPins();
    setupSensors();
    pinMode(11, INPUT_PULLDOWN);
    pinMode(12, INPUT_PULLDOWN);
    return;
}
示例#2
0
void setup(void)
{
	Serial.begin(9600);
	setupSensors();
	setupMotors();
	setupPIDControl(25, 0, 1);
	pinMode(BUTTON, INPUT);
	analogWrite(1, 0);
}
MusicWidget::MusicWidget(QWidget *parent)
    : QWidget(parent)
    , m_player(0), m_playlist(0)
    , m_shakeGesture(0), m_turnoverGesture(0)
    , m_bSliderCanUpdate(true)
    , m_bkgndLogo(":/images/bkgnd.png")
    , m_nAutoNextTimer(0)
{
    setFocusPolicy(Qt::StrongFocus);
    setFocus();

    initPlayer();
    setupSensors();
    setupGUI();
}
示例#4
0
int main(int args, char *argv[], char *environ[])
{
	driver = (I2C_COGDRIVER*) malloc(sizeof(I2C_COGDRIVER));
	i2cOpen(driver, SCL_PIN, SDA_PIN, 400000);

	comp = (float*) malloc(3 * sizeof(float));
	acc = (float*) malloc(3 * sizeof(float));
	gyro = (float*) malloc(3 * sizeof(float));

	clock_t previous;
	clock_t current;
	clock_t cyclesElapsed;
	time_ms timeElapsed;

	setupSensors();

	previous = clock();

	while (1)
	{
		readSensors();
		current = clock();

		if (current > previous)
		{
			cyclesElapsed = current - previous;
		}
		else
		{
			cyclesElapsed = current + (UINT_MAX - previous);
		}

		timeElapsed = (time_ms) cyclesElapsed;
		timeElapsed /= 4000;

		//imu_update(timeElapsed, acc, comp, gyro);

		printVectorLine("compass", comp);
		printVectorLine("accelerometer", acc);
		printVectorLine("gyrometer", gyro);
		printMatrixLine("dcm", dcmEst);

		previous = current;
	}
	return 0;
}
示例#5
0
//--------------------------------------------------------------
void ofApp::setup(){
   printf("\n\nhello world from simple i-cubex rpi sensors example\n\n");
   setupSensors();
   for (int i=0; i<100; i++) {
      printf("ANALOG sensors: ");
      for (int s=0; s<8; s++) {
         printf("%4i ",readADC(s));
      }
      printf("\n");
   }
   if (setupOrient3d()) {
      for (int i=0; i<100; i++) {
         Orient3dData data = readOrient3d();
         printf("Orient 3d: bearing %4i    pitch %4i    roll %4i\n",data.bearing, data.pitch, data.roll);
      }   
   }

   printf("\n\ntest complete. exiting app...\n");
   ofExit();
}
示例#6
0
//*****************************************************************************
//
//! board_init
//!
//! \param  none
//!
//! \return none
//!
//! \brief  Initialize the board's interfaces
//
//*****************************************************************************
void board_init()
{
  // Stop WDT
  WDTCTL = WDTPW + WDTHOLD;

  // Init GPIO's
  pio_init();

  // Setup sensors hooked up to the board (if any)
  setupSensors();

  // Start CC3000 State Machine
  resetCC3000StateMachine();
  // Initialize Board and CC3000
  initDriver();

  // Initialize CC3000 Unsolicited Events Timer
  unsolicicted_events_timer_init();
  // Enable interrupts
  __enable_interrupt();

}
示例#7
0
Player::Player(PlatformState& platformState, BoxWorld* world, sf::Vector2f& size, sf::Vector2f& position, ResourceCollection& resource, LightSolver* lightSolver, StatManager& stats)
: Entity(world, size, position)
, mPlatformState(platformState)
, groundCallBack(nullptr)
, leftButton(false)
, rightButton(false)
, downButton(false)
, mResource(resource)
, flashLight(lightSolver->createLight(FLASHLIGHT_SIZE.x, FLASHLIGHT_SIZE.y))
, maskRight(&resource.getTexture("Assets/Shader/mask.png"))
, maskLeft(flipTexture(maskRight))
, activeStreetLight(nullptr)
, collisionFixture(body->GetFixtureList())
, mStats(stats)
, flashLightBody(world->createEntityBody(sf::Vector2f(0.0f, 0.0f), static_cast<sf::Vector2f>(FLASHLIGHT_SIZE), false))
{
	flashLight->setColor(sf::Color(255, 255, 0, 150));
	int group = flashLight->getFilterGroup();
	group |= (1 << 8);
	flashLight->setFilterGroup(group);
	setFilterGroup(getFilterGroup() | (1 << 8));

	setState(PLAYER_STATE::NORMAL);

	/* Walking/run animation */
	auto &walking = mResource.getTexture("Assets/Characters/Stella Left.png");
	sf::Vector2i walkingSize = static_cast<sf::Vector2i>(walking.getSize());
	sf::Vector2i frameSize(256, 256);
	SpriteSheet spritesheet1(frameSize, walkingSize);
	std::vector<sf::IntRect> frames = spritesheet1.getAllFrames();
	mWalking = new Animation(frames,walking);
	
	/* Idle animation */
	auto &idle = mResource.getTexture("Assets/Characters/Stella idle.png");
	sf::Vector2i idleSize = static_cast<sf::Vector2i>(idle.getSize());
	SpriteSheet idleSheet(frameSize,idleSize);
	std::vector<sf::IntRect> idleFrames = idleSheet.getAllFrames();
	mIdle = new Animation(idleFrames,idle);
	
	/* Jump animation */
	auto &jump = mResource.getTexture("Assets/Characters/Stella jump.png");
	sf::Vector2i jumpSize = static_cast<sf::Vector2i>(jump.getSize());
	SpriteSheet jumpSheet(frameSize,jumpSize);
	std::vector<sf::IntRect> jumpFrames = jumpSheet.getAllFrames();
	mJump = new Animation(jumpFrames,jump);

	/* Grab animation */
	auto &grab = mResource.getTexture("Assets/Characters/Stella grab.png");
	sf::Vector2i grabSize = static_cast<sf::Vector2i>(grab.getSize());
	SpriteSheet grabSheet (frameSize, grabSize);
	std::vector<sf::IntRect> grabFrames = grabSheet.getAllFrames();
	mGrab = new Animation(grabFrames,grab);

	/* Fall Animation*/
	auto &fall = mResource.getTexture("Assets/Characters/Stella fall.png");
	sf::Vector2i fallSize = static_cast<sf::Vector2i>(fall.getSize());
	SpriteSheet fallSheet(frameSize, fallSize);
	std::vector<sf::IntRect> fallFrames = jumpSheet.getAllFrames();
	mFall = new Animation(fallFrames,fall);

	/* Hit Animation*/
	auto &hit = mResource.getTexture("Assets/Characters/Stella hit.png");
	sf::Vector2i hitSize = static_cast<sf::Vector2i>(hit.getSize());
	SpriteSheet hitSheet(frameSize, hitSize);
	std::vector<sf::IntRect> hitFrames = hitSheet.getAllFrames();
	mHit = new Animation(hitFrames,hit);

	anime.setAnimation(*mIdle);
	
	updateSpriteOrigin();

	mJumpSound = new sf::Sound;
	mJumpSound->setBuffer(*mResource.getSound("Assets/Sound/Jump.wav"));

	mWalkSound = new sf::Sound;
	mWalkSound->setBuffer(*mResource.getSound("Assets/Sound/Stella_Run_Loop_1.wav"));
	mWalkSound->setVolume(40);

	mHurtSound = new sf::Sound;
	mHurtSound->setBuffer(*mResource.getSound("Assets/Sound/Stella get hurt.wav"));

	setupSensors(position, size);
	body->SetLinearDamping(1.0f);
	/* Set filter for collisions */
	b2Filter filter = collisionFixture->GetFilterData();
	filter.categoryBits = PLAYER;
	//filter.maskBits =ALL, ENEMY_CHASE, ENEMY_ATTACK;
	filter.groupIndex = ALL, ENEMY_CHASE, ENEMY_ATTACK;
	collisionFixture->SetFilterData(filter);
	knockForce = 35;
	toggle = false;
}
示例#8
0
文件: main.cpp 项目: PinkPR/Elec
void setup()
{
	Serial.begin(9600);
	setupSensors();
	setupRF24();
}