if(ButtonWaitForAnyPress(TITLE_DELAY) == BUTTON_ID_ESCAPE)
is actually not what I intended to do, I wanted to check if any button has been hit incidentally without any delay for the rest of the program loop, and just return if it happened or not.
I hope that maybe someone will find out some day what's wrong with my use of checkButtons().
I now again altered your program and attached the gyro to S4.
Code: Select all
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "lms2012.h"
#include "ev3_button.h"
#include "ev3_lcd.h"
//Runtime constants
const int MAX_SAMPLES = 1000;
//Global variables and constants used by the sensor handling functions
#define TITLE_DELAY 1000
IIC *pXgl;
//***************************************************************************************
// Microinfinity XG1300L IMU settings
const char XGL_PORT = 0x3; // The ports are designated as XGL_PORT_NUMBER-1
const int XGL_PACKET_SIZE = 10; // 2(gyyro angle)+2(gyro rate)+2(acc x)+2(acc y)+2(acc z)
int xgl_device_file;
//***************************************************************************************
int init_xg1300l_gyro()
{
//...
(I know there might be an issue concerning sonic reflection noise, but that can be possibly handled by one or two steps after^^)