Beispiel #1
0
__interrupt void Timer1_A1(void) {
	if (!(TA1IV & TA1IV_TACCR2)) {
		return;
	}
	pulseGoalOld = pulseGoal;
//	if(debugAscending && debugGoal < 255) {
//		debugGoal++;
//	}
//	else if (debugGoal == 255) {
//		debugAscending= 0;
//		debugGoal--;
//	}
//	else if(!debugAscending && debugGoal > 0) {
//		debugGoal--;
//	}
//	else if(debugGoal == 0) {
//		debugAscending = 1;
//		debugGoal++;
//	}
	pulseGoal = (messageGetServoValue() * SERVO_SCALE_VALUE) + PULSE_OFFSET; // if we are not gripping anything, approach our goal pos.
//	pulseGoal = (debugGoal * SERVO_SCALE_VALUE) + PULSE_OFFSET;
	if (pulseGoalOld < pulseGoal ){		// If we are moving up
		countUp = 1;
	} else if ( pulseGoalOld > pulseGoal) {
		countUp = 0;
	}


	// If our current is too high (ie, we are gripping something) we need to back off until we are "safe"
	if (forceGet()) {
				if (countUp && (pulseGoalOld < servoPWMValue) && (pulseGoal >= servoPWMValue)){ //if we are counting up and have not counted past servoPWMValue
					servoPWMValue = pulseGoal + PULSE_ADJUST;
				} else if (!countUp && (pulseGoalOld > servoPWMValue) && (pulseGoal <= servoPWMValue)){ //if we are couting down have not counted past servoPWMValue
					servoPWMValue = pulseGoal - PULSE_ADJUST;
				}// else {
				//	servoPWMValue = servoPWMValue;
				//}
	} else {
	// if we are moving the "wrong" direction, or if we have low force, increment towards goal
	if (servoPWMValue > (pulseGoal + (PULSE_ADJUST << 1) )) {	// If our value is enough greater than the goal value, go down by ADJUST
				servoPWMValue -= (PULSE_ADJUST << 1);
			} else if (servoPWMValue < (pulseGoal - (PULSE_ADJUST << 1))) {	// If our value is enough less than the goal value, go up by adjust
				servoPWMValue += (PULSE_ADJUST << 1);
			} else {
				servoPWMValue = pulseGoal;	// If we are within range, use the exact value
			}
			//break;

	}


	TA1CCR1 = servoPWMValue;

	servoValue =  (servoPWMValue - PULSE_OFFSET)/SERVO_SCALE_VALUE;	// convert back so that the robot knows what our current position actually is.
}
Beispiel #2
0
Qtwitter::Qtwitter( QWidget *parent ) : MainWindow( parent )
{
  connect( this, SIGNAL(switchModel(QString)), SLOT(setCurrentModel(QString)) );
  connect( this, SIGNAL(switchToPublicTimelineModel()), SLOT(setPublicTimelineModel()) );

  core = new Core( this );
  connect( this, SIGNAL(updateTweets()), core, SLOT(forceGet()) );
  connect( this, SIGNAL(openBrowser(QUrl)), core, SLOT(openBrowser(QUrl)) );
  connect( this, SIGNAL(post(QString,QString,int)), core, SLOT(post(QString,QString,int)) );
  connect( this, SIGNAL(resizeView(int,int)), core, SIGNAL(resizeData(int,int)));
  connect( this, SIGNAL(shortenUrl(QString)), core, SLOT(shortenUrl(QString)));
  connect( core, SIGNAL(twitterAccountsChanged(QList<TwitterAccount>,bool)), this, SLOT(setupTwitterAccounts(QList<TwitterAccount>,bool)) );
  connect( core, SIGNAL(urlShortened(QString)), this, SLOT(replaceUrl(QString)));
  connect( core, SIGNAL(about()), this, SLOT(about()) );
  connect( core, SIGNAL(addReplyString(QString,int)), this, SIGNAL(addReplyString(QString,int)) );
  connect( core, SIGNAL(addRetweetString(QString)), this, SIGNAL(addRetweetString(QString)) );
  connect( core, SIGNAL(errorMessage(QString)), this, SLOT(popupError(QString)) );
  connect( core, SIGNAL(resetUi()), this, SLOT(resetStatusEdit()) );
  connect( core, SIGNAL(requestStarted()), this, SLOT(showProgressIcon()) );
  if ( QSystemTrayIcon::supportsMessages() )
    connect( core, SIGNAL(sendNewsReport(QString)), this, SLOT(popupMessage(QString)) );

  twitpic = new TwitPicView( this );
  connect( twitpic, SIGNAL(uploadPhoto(QString,QString,QString)), core, SLOT(uploadPhoto(QString,QString,QString)) );
  connect( twitpic, SIGNAL(abortUpload()), core, SLOT(abortUploadPhoto()) );
  connect( this, SIGNAL(openTwitPicDialog()), twitpic, SLOT(show()) );
  connect( core, SIGNAL(twitPicResponseReceived()), twitpic, SLOT(resetForm()) );
  connect( core, SIGNAL(twitPicDataSendProgress(int,int)), twitpic, SLOT(showUploadProgress(int,int)) );

  settingsDialog = new Settings( this, core, twitpic, this );
  connect( this, SIGNAL(settingsDialogRequested()), settingsDialog, SLOT( show() ) );

  QSignalMapper *mapper = new QSignalMapper( this );
  mapper->setMapping( qApp, 1 );
  connect( qApp, SIGNAL(aboutToQuit()), mapper, SLOT(map()) );
  connect( mapper, SIGNAL(mapped(int)), settingsDialog, SLOT(saveConfig(int)) );
}