Fixed warnings in Z1 examples

This commit is contained in:
Antonio Lignan 2015-11-24 22:02:05 +01:00
parent ed4c1788a7
commit 830f5fb60d
3 changed files with 6 additions and 41 deletions

View File

@ -42,12 +42,6 @@
#include "dev/i2cmaster.h"
#include "dev/light-ziglet.h"
/*---------------------------------------------------------------------------*/
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
/*---------------------------------------------------------------------------*/
#define SENSOR_READ_INTERVAL (CLOCK_SECOND / 2)
/*---------------------------------------------------------------------------*/
PROCESS(test_process, "Test light ziglet process");
@ -59,19 +53,14 @@ PROCESS_THREAD(test_process, ev, data)
{
PROCESS_BEGIN();
uint16_t light;
/* Initialize driver and set a slower data rate */
light_ziglet_init();
i2c_setrate(I2C_PRESC_100KHZ_LSB, I2C_PRESC_100KHZ_MSB);
while(1) {
etimer_set(&et, SENSOR_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
light = light_ziglet_read();
PRINTF("Light = %u\n", light);
printf("Light = %u\n", light_ziglet_read());
}
PROCESS_END();
}

View File

@ -32,8 +32,7 @@
/*---------------------------------------------------------------------------*/
/**
* \file
* An example of how to use the button and light sensor on
* the Z1 platform.
* An example of how to use the button and read the ADC ports
* \author
* Joakim Eriksson <joakime@sics.se>
*/
@ -44,7 +43,7 @@
#include "dev/leds.h"
#include "dev/z1-phidgets.h"
/*---------------------------------------------------------------------------*/
PROCESS(test_button_process, "Test Button & Phidgets");
PROCESS(test_button_process, "Test Button & ADC");
AUTOSTART_PROCESSES(&test_button_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_button_process, ev, data)

View File

@ -42,12 +42,6 @@
#include "dev/i2cmaster.h"
#include "dev/tmp102.h"
/*---------------------------------------------------------------------------*/
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
/*---------------------------------------------------------------------------*/
#define TMP102_READ_INTERVAL (CLOCK_SECOND / 2)
/*---------------------------------------------------------------------------*/
PROCESS(temp_process, "Test Temperature process");
@ -59,32 +53,15 @@ PROCESS_THREAD(temp_process, ev, data)
{
PROCESS_BEGIN();
int16_t tempint;
uint16_t tempfrac;
int16_t raw;
uint16_t absraw;
int16_t sign;
char minus = ' ';
int16_t temp;
tmp102_init();
while(1) {
etimer_set(&et, TMP102_READ_INTERVAL);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
sign = 1;
PRINTFDEBUG("Reading Temp...\n");
raw = tmp102_read_temp_raw();
absraw = raw;
if(raw < 0) { /* Perform 2C's if sensor returned negative data */
absraw = (raw ^ 0xFFFF) + 1;
sign = -1;
}
tempint = (absraw >> 8) * sign;
tempfrac = ((absraw >> 4) % 16) * 625; /* Info in 1/10000 of degree */
minus = ((tempint == 0) & (sign == -1)) ? '-' : ' ';
PRINTF("Temp = %c%d.%04d\n", minus, tempint, tempfrac);
temp = tmp102_read_temp_x100();
printf("Temp = %d\n", temp);
}
PROCESS_END();
}