void HbSensorListener::checkCenrepValue()
{
#ifdef Q_OS_SYMBIAN
    CRepository *repository = 0;
    TRAPD(err, repository = CRepository::NewL(KHbSensorCenrepUid));
    if (err) {
        qWarning("HbSensorListener::checkCenrepValue; repository->NewL fails, error code = %d", err);
    } else {
        TInt value = 0;
        TInt err = repository->Get(KHbSensorCenrepKey, value);
        if (err == KErrNone) {
            cenrepValueChanged(value, false);
        } else {
            qWarning("HbSensorListener::checkCenrepValue: repository->Get fails, error code = %d", err);
        }
    delete repository;
    }
    if (!mNotifyHandler) {
        TRAPD(err, mNotifyHandler = HbSensorNotifyHandler::NewL(*this));
        if (err) {
            qWarning("HbSensorListener::HbSensorListener: HbSensorNotifyHandler::NewL failed = %d", err);
        } else {
            TRAPD(err, mNotifyHandler->startObservingL());
            if (err) {
                qWarning("HbSensorListener::HbSensorListener: mNotifyHandler->startObservingL failed = %d", err);
            }
        }
    }
#else
    QSettings mSettings("Nokia", "HbStartUpDeskTopSensors");
    bool enable = mSettings.value("SensorsEnabled").toBool();
    mSettingsEnabled = enable;
    enableSensors(enable, false);
#endif
}
Beispiel #2
0
// Declare Global variables
int main(void) {
  // Set up Create and module
  initializeCommandModule();

  powerOnRobot();
    // Is the Robot on
  byteTx(CmdStart);
    // Start the create
  baud(Baud57600);
    // Set the baud rate for the Create and Command Module
  defineSongs();
    // Define some songs so that we know the robot is on.
  byteTx(CmdControl);
    // Deprecated form of safe mode. I use it because it will
    // turn of all LEDs, so it's essentially a reset.
  byteTx(CmdFull);
    // We are operating in FULL mode.

  // Play the reset song and wait while it plays.
  byteTx(CmdPlay);
  byteTx(RESET_SONG);
  delayMs(750);

  // Turn the power button on to something.
  turnOnPowerButtonLight();
  delayMs(20);


  // Infinite operation loop
  int timerLoop = 0; 
  const int timerLimit = 15;
  
  initializeUSBBuffer();
  initializeRobotBuffer();
  initializeSensorArray();
  
  setLEDs(BOTHLED, FULL);
  enableReports();
  enableSensors();
  
  while(1) {
	pollSensors();
	if(timerLoop == timerLimit){
		compileReport();
		sendUSBBuffer();
		timerLoop = 0;
		delayMs(1);
  	}
	timerLoop++;
	pollRemoteSensors();
	pollRemote();
	executeCommand();
	delayMs(5);
	}
}
Beispiel #3
0
// Declare Global variables
int main(void) {
  // Set up Create and module
  initializeCommandModule();

  powerOnRobot();
    // Is the Robot on
  byteTx(CmdStart);
    // Start the create
  baud(Baud57600);
    // Set the baud rate for the Create and Command Module
  defineSongs();
    // Define some songs so that we know the robot is on.
  byteTx(CmdControl);
    // Deprecated form of safe mode. I use it because it will
    // turn of all LEDs, so it's essentially a reset.
  byteTx(CmdFull);
    // We are operating in FULL mode.

  // Play the reset song and wait while it plays.
  byteTx(CmdPlay);
  byteTx(RESET_SONG);
  delayMs(750);

  // Turn the power button on to something.
  delayMs(20);
  
  initializeUSBBuffer();
  initializeRobotBuffer();
  initializeSensorArray();
  
  setLEDs(BOTHLED, FULL);
  enableReports();
  enableSensors();
  
  int fakeTimer = 0;

  // Infinite operation loop
  while(1) {
	  
	  if (fakeTimer == 4) {
		  compileReport();
		  sendUSBBuffer();
		  fakeTimer = 0;
	  }
	  
	  pollSensors();
	  delayMs(250);
	  
	  fakeTimer++;
	  
  }
}
void HbSensorListener::cenrepValueChanged(TInt aValue, bool notify)
{
    bool enable = (aValue == 0) ? false : true;
    mSettingsEnabled = enable;
    enableSensors(enable, notify);
}