Uncrustified weather meter driver and example

This commit is contained in:
Antonio Lignan 2016-01-19 18:03:16 +01:00
parent 81bec49a40
commit 366f11d5df
2 changed files with 53 additions and 54 deletions

View File

@ -128,14 +128,14 @@ PROCESS_THREAD(test_weather_meter_sensors, ev, data)
wind_speed_avg_2m = weather_meter.value(WEATHER_METER_ANEMOMETER_AVG_X);
wind_speed_max = weather_meter.value(WEATHER_METER_ANEMOMETER_MAX);
#if WEATHER_METER_RAIN_RETURN_TICKS
#if WEATHER_METER_RAIN_RETURN_TICKS
rain *= WEATHER_METER_AUX_RAIN_MM;
if(rain > (WEATHER_METER_AUX_RAIN_MM * 3)) {
printf("Rain: %lu.%lu mm, ", (rain / 10000), (rain % 10000));
#else
#else
if(rain >= 10) {
printf("Rain: %u.%u mm, ", (rain / 10), (rain % 10));
#endif
#endif
} else {
printf("Rain: 0.%lu mm, ", rain);
}

View File

@ -116,7 +116,7 @@ typedef struct {
uint16_t degree;
} wind_vane_mid_point_t;
/* From the datasheet we adjusted the values for a 3V divider, using a 10K
/* From the datasheet we adjusted the values for a 3V divider, using a 10K
* resistor, the check values are the following:
* --------------------+------------------+-------------------------------
* Direction (Degrees) Resistance (Ohms) Voltage (mV)
@ -161,7 +161,7 @@ static int
weather_meter_wind_vane_degrees(uint16_t value)
{
uint8_t i;
for(i=0; i<16; i++) {
for(i = 0; i < 16; i++) {
if(value <= wind_vane_table[i].mid_point) {
return (int)wind_vane_table[i].degree;
} else {
@ -305,7 +305,6 @@ weather_meter_interrupt_handler(uint8_t port, uint8_t pin)
if((port == ANEMOMETER_SENSOR_PORT) && (pin == ANEMOMETER_SENSOR_PIN)) {
weather_sensors.anemometer.ticks++;
process_post(&weather_meter_int_process, anemometer_int_event, NULL);
} else if((port == RAIN_GAUGE_SENSOR_PORT) && (pin == RAIN_GAUGE_SENSOR_PIN)) {
weather_sensors.rain_gauge.ticks++;
aux = weather_sensors.rain_gauge.ticks * WEATHER_METER_AUX_RAIN_MM;
@ -364,11 +363,11 @@ value(int type)
* ticks and calculating on your own with WEATHER_METER_AUX_RAIN_MM
*/
case WEATHER_METER_RAIN_GAUGE:
#if WEATHER_METER_RAIN_RETURN_TICKS
#if WEATHER_METER_RAIN_RETURN_TICKS
return weather_sensors.rain_gauge.ticks;
#else
#else
return weather_sensors.rain_gauge.value;
#endif
#endif
default:
return WEATHER_METER_ERROR;