void MainWindow::initServoBoard()
{
    this->ui->actionSave_Sequence->setVisible(true);
    this->ui->actionLoad_Sequence->setVisible(true);
    this->ui->actionSave_Sequence_As->setVisible(true);
    this->ui->actionSet_Global_Values->setVisible(true);
    this->ui->actionKeep_Edits_Automatically->setVisible(true);
    if (!this->servoControl)
    {
        servoControl = new ServoboardController(this->port,this->servotab,this);
    }
    connect(this->ui->actionLoad_Sequence,SIGNAL(triggered()),servoControl,SLOT(loadFile()));
    connect(this->ui->actionSave_Sequence,SIGNAL(triggered()),servoControl,SLOT(saveFile()));
    connect(this->ui->actionSave_Sequence_As,SIGNAL(triggered()),servoControl,SLOT(saveFileAs()));
    connect(this->servotab,SIGNAL(newPositionToSequence(Position*)),
            servoControl,SLOT(newPositionForSequence(Position*)));
    connect(this->ui->actionSet_Global_Values,SIGNAL(triggered()),
            servoControl,SLOT(globalVariableSetRequested()));
    connect(this->servotab,SIGNAL(playSequence()),servoControl,SLOT(playCurrentSequence()));
    connect(this->servotab,SIGNAL(playPosition(Position*)),this->servoControl,SLOT(playPosition(Position*)));
    connect(this->ui->actionKeep_Edits_Automatically,SIGNAL(toggled(bool)),
            servoControl,SLOT(suppressChangeNotifications(bool)));

    connect(this->servotab,SIGNAL(pauseSequence()),this->servoControl,SLOT(pauseSequence()));
    connect(this->servotab,SIGNAL(stopSequence()),this->servoControl,SLOT(stopSequence()));


}
示例#2
0
文件: entity.cpp 项目: nadult/FreeFT
	void Entity::resetAnimState() {
		m_dir_angle = 0.0f;
		m_seq_idx = -1;
		m_oseq_idx = -1;

		DASSERT(!m_sprite.isPartial());
		playSequence(0, false);
	}
示例#3
0
	void Door::initialize() {
		m_close_time = -1.0;
		m_update_anim = false;
		
		m_state = DoorState::closed;
		playSequence(m_proto.seq_ids[m_state], false);
		m_bbox = computeBBox(m_state);
		initializeOpenDir();
	}
示例#4
0
	bool Turret::animate(TurretAction::Type action) {
		int seq_id = m_proto.anim_idx[action];
		if(seq_id == -1)
			return false;

		m_action = action;
		playSequence(seq_id);
		return true;

		return true;
	}
示例#5
0
	bool Turret::animateDeath(DeathId::Type death) {
		int anim_id =
			death == DeathId::explode? TurretAction::death_explode :
			death == DeathId::electrify? TurretAction::death_electrify : TurretAction::death;
		int seq_id = m_proto.anim_idx[anim_id];
		if(seq_id == -1)
			return false;

		playSequence(seq_id);
		m_action = TurretAction::death;
		return true;
	}
示例#6
0
文件: Lab_3.c 项目: Lars139/Archive
int main (void) 
{
	setup(); //initialize all ports, registers, etc.
	
	//this is the song data for playing zelda
	const char zelda[49] = {Asp, F, F, F, Asp, Asp, Ch, Dh, Dhsp, Fh, Fh, Fh, Fh, Fhsp, Ghsp, Ahsp, Ahsp, Ahsp, Ahsp, Ahsp, Ghsp, Fhsp, Ghsp, Fhsp, Ghsp, Ghsp, Fhsp, Fh, Fh, Fh, Dhsp, Dhsp, Fh, Fhsp, Fhsp, Fh, Dhsp, Chsp, Chsp, Dhsp, Fh, Fh, Dhsp, Chsp, Ch, Ch, Dh, Eh, Eh};
	
	int i = 0;
	while(TRUE)		// loops program infinitely 
	{
		if (bit_is_clear(PINB, 1)) //if special button is pushed, enter "zelda mode"
		{
			playSequence (zelda); // zelda (by itself without [index] is a pointer to the first memory address of the sequence array
		}
		else //normal mode
		{
			if (ADCH < 5) 
				cli(); // turn off the interrupts if the piano is not really being pushed
			else 
				sei(); // turn on interrupts if piano is being pushed
			
			//This section splits up the range of the piano into eight notes, a C-major scale
			
			if ((ADCH >= 5) && (ADCH <= 16))
				OCR1A = Ch;
			else if ((ADCH >= 18) && (ADCH <= 38))
				OCR1A = B;
			else if ((ADCH >= 40) && (ADCH <= 60))
				OCR1A = A;
			else if ((ADCH >= 62) && (ADCH <= 120))
				OCR1A = G;
			else if ((ADCH >= 122) && (ADCH <= 165))
				OCR1A = F;
			else if ((ADCH >= 167) && (ADCH <= 191))
				OCR1A = E;
			else if ((ADCH >= 193) && (ADCH <= 222))
				OCR1A = D;			
			else if (ADCH >222)
				OCR1A = C;
		}
	}
}
示例#7
0
	void Container::think() {
		if(m_proto.is_always_opened)
			return;

		if(m_target_state != m_state) {
			if(m_state == ContainerState::closed && m_target_state == ContainerState::opened) {
				m_state = ContainerState::opening;
				m_update_anim = true;
			}
			if(m_state == ContainerState::opened && m_target_state == ContainerState::closed) {
				m_state = ContainerState::closing;
				m_update_anim = true;
			}
		}
		if(m_update_anim) {
			replicate();
			playSequence(m_proto.seq_ids[m_state]);
			m_update_anim = false;
		}
	}
示例#8
0
	void Door::think() {
		const float2 dir = actualDir();
		
		if(m_update_anim) {
			replicate();
			playSequence(m_proto.seq_ids[m_state]);
			m_update_anim = false;
		}
		if(classId() == DoorClassId::sliding && m_state == DoorState::opened_in && currentTime() > m_close_time) {
			FBox bbox = computeBBox(DoorState::closed);
			if((bool)findAny(bbox + pos(), {Flags::entity | Flags::colliding, ref()})) {
				m_close_time = currentTime() + 1.5;
			}
			else {
				m_bbox = bbox;
				m_state = DoorState::closing_in;
				m_update_anim = true;
			}
		}
	}
示例#9
0
文件: item.cpp 项目: dreamsxin/FreeFT
	ItemEntity::ItemEntity(Stream &sr) :EntityImpl(sr), m_item(m_proto) {
		m_count = sr.decodeInt();
		ASSERT(m_count > 0);
		playSequence(m_proto.seq_ids[0], false);
	}
示例#10
0
文件: item.cpp 项目: dreamsxin/FreeFT
	ItemEntity::ItemEntity(const XMLNode &node) :EntityImpl(node), m_item(m_proto) {
		m_count = node.intAttrib("item_count");
		playSequence(m_proto.seq_ids[0], false);
	}
示例#11
0
文件: item.cpp 项目: dreamsxin/FreeFT
	ItemEntity::ItemEntity(const Item &item, int count)
			:EntityImpl(item.proto()), m_item(item), m_count(count) {
		DASSERT(count >= 1);
		playSequence(m_proto.seq_ids[0], false);
	}
示例#12
0
	void Container::initialize() {
		m_update_anim = false;
		m_state = m_target_state = m_proto.is_always_opened? ContainerState::opened : ContainerState::closed;
		if(!m_proto.is_always_opened)
			playSequence(m_proto.seq_ids[m_state], false);
	}
示例#13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    timer = new QTimer();
    ui->glWidget->setMainWindow(this);

    /// Collision interpretation modes.
    ui->optionCollisionCombo->clear();
    ui->optionCollisionCombo->addItem(tr("All collisions"));
    ui->optionCollisionCombo->addItem(tr("First collision"));
    ui->optionCollisionCombo->setCurrentIndex(0);

    /// Character shapes display options.
    ui->optionShowPlayerSolidCombo->clear();
    ui->optionShowPlayerSolidCombo->addItem(tr("Hide"));
    ui->optionShowPlayerSolidCombo->addItem(tr("Wireframe"));
    ui->optionShowPlayerSolidCombo->addItem(tr("Fill"));
    ui->optionShowPlayerSolidCombo->setCurrentIndex(0);

    /// Object shapes display options.
    ui->optionShowObjectSolidCombo->clear();
    ui->optionShowObjectSolidCombo->addItem(tr("Wireframe"));
    ui->optionShowObjectSolidCombo->addItem(tr("Fill"));
    ui->optionShowObjectSolidCombo->setCurrentIndex(0);

    /// Character shapes for physical model.
    ui->optionPlayerShapeCombo->clear();
    ui->optionPlayerShapeCombo->addItem(tr("Point"));
    ui->optionPlayerShapeCombo->addItem(tr("Line segment"));
    ui->optionPlayerShapeCombo->addItem(tr("Triangle"));
    ui->optionPlayerShapeCombo->setCurrentIndex(1);

    /// Application logic criterias.
    ui->optionCriteriaCombo->clear();
    ui->optionCriteriaCombo->addItem(tr("Consider all objects"));
    ui->optionCriteriaCombo->addItem(tr("Consider other than green objects"));
    ui->optionCriteriaCombo->addItem(tr("Consider green objects only"));
    ui->optionCriteriaCombo->setCurrentIndex(0);

    /// connections - comboboxes
    connect(ui->optionCollisionCombo,SIGNAL(currentIndexChanged(int)), this, SLOT(collisionModeChanged()));
    connect(ui->optionCriteriaCombo,SIGNAL(currentIndexChanged(int)), this, SLOT(collisionModeChanged()));
    connect(ui->optionShowPlayerSolidCombo,SIGNAL(currentIndexChanged(int)), this, SLOT(optionsFromGui()));
    connect(ui->optionShowObjectSolidCombo,SIGNAL(currentIndexChanged(int)), this, SLOT(optionsFromGui()));
    connect(ui->optionPlayerShapeCombo,SIGNAL(currentIndexChanged(int)), this, SLOT(collisionMeshChanged()));

    /// connections - buttons
    connect(ui->optionVectorCheck,SIGNAL(clicked()), this, SLOT(optionsFromGui()));
    connect(ui->optionPlaneCheck,SIGNAL(clicked()), this, SLOT(optionsFromGui()));
    connect(ui->playerPosCenterButton,SIGNAL(clicked()), this, SLOT(centerPlayer()));

    /// connections - edits
    connect(ui->playerPosXEdit,SIGNAL(textChanged(QString)), this, SLOT(playerPosFromGui()));
    connect(ui->playerPosYEdit,SIGNAL(textChanged(QString)), this, SLOT(playerPosFromGui()));
    connect(ui->playerPosZEdit,SIGNAL(textChanged(QString)), this, SLOT(playerPosFromGui()));
    connect(ui->playerPosRadEdit,SIGNAL(valueChanged(double)), this, SLOT(playerPosFromGui()));
    connect(ui->optionVectorLengthEdit,SIGNAL(valueChanged(double)), this, SLOT(playerPosFromGui()));
    connect(ui->optionVectorBackEdit,SIGNAL(valueChanged(double)), this, SLOT(playerPosFromGui()));

    /// connections - menu actions
    connect(ui->actionExit,SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionAbout,SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionAboutQt,SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->actionLoad,SIGNAL(triggered()), this, SLOT(loadSituation()));
    connect(ui->actionSave,SIGNAL(triggered()), this, SLOT(saveSituation()));
    connect(ui->actionCaptureSituation,SIGNAL(triggered()), this, SLOT(captureSituation()));
    connect(ui->actionPlaySequence,SIGNAL(triggered()), this, SLOT(playSequence()));
    connect(ui->actionToFirstSituation,SIGNAL(triggered()), this, SLOT(toFirstSituation()));
    connect(ui->actionNextSituation,SIGNAL(triggered()), this, SLOT(nextSituation()));
    connect(ui->actionPreviousSituation,SIGNAL(triggered()), this, SLOT(previousSituation()));

    /// connections - timer timeout
    connect(timer, SIGNAL(timeout()), this, SLOT(sequenceTimeout()));

    /// connections - from glWidget
    connect(ui->glWidget, SIGNAL(playerPosChanged()), this, SLOT(playerPosToGui()));
    connect(ui->glWidget, SIGNAL(glInitialized()), this, SLOT(collisionModeChanged()));

    ui->collisionTree->header()->resizeSections(QHeaderView::ResizeToContents);
    optionsFromGui();
}
示例#14
0
void Alarm::playLowSignal(unsigned long currentTime) {
  playSequence(currentTime, SIGNAL_FREQ, SIGNAL_BEEPS,
               SIGNAL_DURATION, SIGNAL_SEPARATION, SIGNAL_RESET);
}
示例#15
0
void Alarm::playLowVolt(unsigned long currentTime) {
  playSequence(currentTime, ALARM_FREQ, ALARM_BEEPS, ALARM_DURATION,
               ALARM_SEPARATION, ALARM_RESET);
}