Esempio n. 1
0
int main(int argc, char *argv[])
{
    int result = 0;

    QGuiApplication *app = SailfishApp::application(argc, argv);
    QQuickView *view = SailfishApp::createView();

    qmlRegisterType<PlotWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "PlotWidget");
    qmlRegisterType<SatellitePosWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatellitePosWidget");
    qmlRegisterType<SatelliteStrengthWidget>("harbour.messwerk.MesswerkWidgets", 1, 0, "SatelliteStrengthWidget");

    QTimer refreshTimer;

    Accelerometer accelerometer(false);
    Gyroscope gyroscope(false);
    Magnetometer magnetometer(false);
    Rotation rotation(false);
    Light light(false);
    Proximity proximity(true);
    SatelliteInfo satelliteinfo;
    Position position;

    // connect not self-refreshing sensors to the global timer
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &accelerometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &gyroscope, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &magnetometer, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &rotation, SLOT(refresh()));
    QObject::connect(&refreshTimer, SIGNAL(timeout()), &light, SLOT(refresh()));

    QString qml = QString("qml/%1.qml").arg("Messwerk");
    view->rootContext()->setContextProperty("accelerometer", &accelerometer);
    view->rootContext()->setContextProperty("gyroscope", &gyroscope);
    view->rootContext()->setContextProperty("magnetometer", &magnetometer);
    view->rootContext()->setContextProperty("rotationsensor", &rotation);
    view->rootContext()->setContextProperty("lightsensor", &light);
    view->rootContext()->setContextProperty("proximitysensor", &proximity);
    view->rootContext()->setContextProperty("satelliteinfo", &satelliteinfo);
    view->rootContext()->setContextProperty("positionsensor", &position);
    view->rootContext()->setContextProperty("settings", &(Settings::instance()));
    view->setSource(SailfishApp::pathTo(qml));
    view->show();

    refreshTimer.start(100);

    result = app->exec();

    delete view;
    delete app;

    return result;
}
Esempio n. 2
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QScopedPointer<trikControl::BrickInterface> brick(trikControl::BrickFactory::create(".", "."));

    cppExample::Gyroscope gyroscope(*brick);
    QTimer timer;
    timer.setInterval(100);
    timer.setSingleShot(false);

    QObject::connect(&timer, SIGNAL(timeout()), &gyroscope, SLOT(showGyroscopeReading()));
    QObject::connect(brick->keys(), SIGNAL(buttonPressed(int,int)), QCoreApplication::instance(), SLOT(quit()));

    timer.start();

    return app.exec();
}
Esempio n. 3
0
String GY85::getFormattedDataRow() {
  String accelerometerValues = accelerometer();

  delay(10);
  String gyroscopeValues = gyroscope();

  delay(10);
  // in degree Celsius (°C)
  String temperatureValue = temperature();

  delay(10);
  // heading is the angle between the direction in which
  // the sensor nose is pointing
  // and the magnetich north as the reference direction
  // it is provided in degrees (°) in the range 0-360
  String headingValue = heading();

  String dataRow = String();
  dataRow = accelerometerValues + DATA_SEPARATOR + gyroscopeValues + DATA_SEPARATOR + temperatureValue + DATA_SEPARATOR + headingValue;

  return dataRow;
}