Ubuntu Platform API  1.2.0
A library helping with tight integration into the Ubuntu platform
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_sensors_api.cpp
/*
* Copyright © 2012 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Ricardo Mendoza <ricardo.mendoza@canonical.com>
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
void on_new_accelerometer_event(UASAccelerometerEvent* event, void* context)
{
printf("%s \n", __PRETTY_FUNCTION__);
printf("\ttime: %" PRIu64 "\n", uas_accelerometer_event_get_timestamp(event));
printf("\tx: %f\n", x);
printf("\ty: %f\n", y);
printf("\tz: %f\n", z);
}
void on_new_proximity_event(UASProximityEvent* event, void* context)
{
printf("%s \n", __PRETTY_FUNCTION__);
printf("\ttime: %" PRIu64 "\n", uas_proximity_event_get_timestamp(event));
{
{
printf("\tdistance: NEAR\n");
break;
}
{
printf("\tdistance: FAR\n");
break;
}
}
}
void on_new_light_event(UASLightEvent* event, void* context)
{
float light = -1.f; uas_light_event_get_light(event, &light);
printf("%s \n", __PRETTY_FUNCTION__);
printf("\ttime: %" PRIu64 "\n", uas_light_event_get_timestamp(event));
printf("\tlight: %f\n", light);
}
int main(int argc, char** argv)
{
on_new_accelerometer_event,
NULL);
on_new_proximity_event,
NULL);
on_new_light_event,
NULL);
ua_sensors_light_enable(ambientlight);
while(true)
{
}
}