Sweep a servo according to Proximity sensor measure

Dependencies:   Servo X_NUCLEO_6180XA1 mbed

Fork of HelloWorld_6180XA1 by ST

main.cpp

Committer:
gallonm
Date:
2015-10-06
Revision:
8:4c05f7a5bb60
Parent:
7:865f0c23a183
Child:
9:1d0e839edee8

File content as of revision 8:4c05f7a5bb60:

#include "mbed.h"
#include "x_nucleo_6180xa1.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>


#define VL6180X_I2C_SDA I2C_SDA
#define VL6180X_I2C_SCL I2C_SCL

//devo wrappare le funzioni del api.c
//posso creare un`unica funzione che dal main chiama la misura di distanza o luce
//gestisco all`interno della classe sensore con uno switch case e slezionare quindi la modalita di misura
//nel main posso definire con dei define i valori (dello switch case) che permettono di selezionare le varie modalita

#define RANGE_SINGLE_SHOT										1
#define ALS_SINGLE_SHOT											2
#define RANGE_CONTINUOUS										3
#define ALS_CONTINUOUS											4
#define RANGE_CONTINUOUS_ALS_SINGLE_SHOT		5
#define RANGE_SINGLE_SHOT_ALS_CONTINUOUS		6
#define INTERLEAVED MODE										7

void OnErrLog(void){};
void DISP_ExecLoopBody(void){};

DevI2C device_i2c(VL6180X_I2C_SDA, VL6180X_I2C_SCL);
static X_NUCLEO_6180XA1 *board=X_NUCLEO_6180XA1::Instance(&device_i2c);	
	
int main()
{   
	  /*
    uint8_t buf[8]={1,1,1,0,0,0,0,0};
		
		uint8_t x=0xFF;
		uint8_t y=0xF7;
		uint8_t z=0x80;
		uint8_t k=0x17;
		uint8_t g=0xE7;	
		 
	  //imposto GPIO di input e output
		device_i2c.i2c_write(&x, 0x42*2, 0x14, 1);
		device_i2c.i2c_write(&y, 0x42*2, 0x15, 1);
		//disabilito i display e abilito il GPIO0 del sensore top
		device_i2c.i2c_write(&z, 0x42*2, 0x12, 1);
		device_i2c.i2c_write(&g, 0x42*2, 0x13, 1); //spengo gpio0 
		device_i2c.i2c_write(&k, 0x42*2, 0x13, 1); //accendo gpio0
    */
		
		
		
		//X_NUCLEO_6180XA1 board(&device_i2c);
		
		board->InitBoard();
		board->sensor_top->StartMeasurement(RANGE_SINGLE_SHOT);
		
		//board.~X_NUCLEO_6180XA1();

}