/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:FDL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. ** ** GNU Free Documentation License ** Alternatively, this file may be used under the terms of the GNU Free ** Documentation License version 1.3 as published by the Free Software ** Foundation and appearing in the file included in the packaging of this ** file. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \example sensors/grueplugin \title Grue Plugin The Grue plugin example demonstrates the creation of a new sensor type, a sensor backend and plugin for the sensors library. Related to this example is the \l{sensors/grueapp}{Grue Application} example. \tableofcontents \section1 Grue Sensor Type The files for this are: \list \o gruesensor.h \o gruesensor_p.h \o gruesensor.cpp \endlist First up is the sensor type. This is the interface for sensors that report on your likelihood of being eaten by a Grue. Such sensors are very important to adventurers, particularly if they are going into dark places as this is where Grues live. The interface is a simple one. It provides only 1 piece of information, your chance of being eaten. For the details on how this is property should be interpreted please see the documentation in gruesensor.cpp. This example was created using the make_sensor.pl script which can be found in src/sensors. As such, it contains some generated code that defines the convenience classes GrueFilter and GrueSensor. \section1 Grue Sensor Backend The files for this are: \list \o gruesensorimpl.h \o gruesensorimpl.cpp \endlist The Grue sensor needs a backend before it can be used. The backend provided is rather basic and it relies on some kind of light sensor to work but it gets the job done. If new hardware that can detect the actual presence of Grues becomes available a backend could be created that supports this hardware and applications using the Grue sensor would be able to use it without any changes. There are a few mandatory parts to a backend. They are the start and stop methods and the setReading call. The start and stop methods are used to start and stop any underlying hardware. In the case of this backend they start and stop a light sensor. In the start method, the backend should be sure to call the sensorStopped() or sensorBusy() methods if it cannot start. \snippet ../../examples/sensors/grueplugin/gruesensorimpl.cpp start The setReading method is needed so that the sensors library knows where the readings are coming from. This backend has a local copy of the reading so it passes a pointer to the function. \snippet ../../examples/sensors/grueplugin/gruesensorimpl.cpp setReading However it is also possible to pass null to the setReading method in which case the sensors library will create an instance and return a pointer. \code // Create a reading instance for us to use m_reading = setReading(0); \endcode The Grue sensor backend also supplies some metadata. The backend checks 2 things, how dark it is and how long you have been in the dark. It uses the readingChanged() signal to know when to check the light sensor's value. Once it is dark, it uses a timer to increase your chance of being eaten. \section1 Grue Sensor Plugin The files for this are: \list \o main.cpp \endlist The Grue sensor backend is delivered as a plugin. The plugin has a factory object that registers the types available and does the actual instantiation of the backend. \sa {sensors/grueapp}{Grue Application} */ /*! \example sensors/grueapp \title Grue Application The Grue application example demonstrates the use of the Grue sensor which was defined and implemented by the \l{sensors/grueplugin}{Grue Plugin} example. The Grue application is a commandline application. It is significant to note that there is no link-time dependency on the Grue plugin. The Grue application uses the generic access feature of the Sensors API. \sa {sensors/grueplugin}{Grue Plugin} */ /*! \example sensors/cubehouse \title Cube House \image cubehouse.png The Cube House example demonstrates the use of the accelerometer to drive a camera to create a pseudo-3D effect. It also demonstrates the use of a filter to smooth out the accelerometer values. The accelerometer is created and the filter is added. \snippet ../../examples/sensors/cubehouse/view.cpp accelerometer When new values are available, the view is recalculated. \snippet ../../examples/sensors/cubehouse/view.cpp accelerometer2 The filter is defined like this. \snippet ../../examples/sensors/cubehouse/view.cpp smoothed */ /*! \example sensors/sensor_explorer \title Sensor Explorer \image sensor_explorer.png The Sensor Explorer example demonstrates how to read the meta-data of available sensors. It was designed as a debugging aid. */