From 1e849e7406f37e3aaefe52a6be3eced50bdc1a57 Mon Sep 17 00:00:00 2001 From: Reyad Attiyat Date: Tue, 14 Jul 2015 02:54:04 -0500 Subject: [PATCH] compass: Fix compass not working on Surface Pro 2 The _raw is not needed in the channel name for process_scan_1(). This function looks up the channel from its channel name (in this case "in_rot_from_north_magnetic_tilt_comp"). The channel name is read from the file ending in _en from the scanning_element folder, in build_channel_array(). Closes #38 --- src/drv-iio-buffer-compass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/drv-iio-buffer-compass.c b/src/drv-iio-buffer-compass.c index e62b5d8..4575711 100644 --- a/src/drv-iio-buffer-compass.c +++ b/src/drv-iio-buffer-compass.c @@ -33,6 +33,7 @@ process_scan (IIOSensorData data, DrvData *or_data) { int i; int raw_heading; + char* channel_name = "in_rot_from_north_magnetic_tilt_comp"; gdouble scale; gboolean present_level; CompassReadings readings; @@ -51,7 +52,7 @@ process_scan (IIOSensorData data, DrvData *or_data) return 0; } - process_scan_1 (data.data + or_data->buffer_data->scan_size*i, or_data->buffer_data, "in_rot_from_north_magnetic_tilt_comp_raw", &raw_heading, &scale, &present_level); + process_scan_1 (data.data + or_data->buffer_data->scan_size*i, or_data->buffer_data, channel_name, &raw_heading, &scale, &present_level); readings.heading = raw_heading * scale; g_debug ("Read from IIO: %f (%d times %f scale)", readings.heading, raw_heading, scale);