Implement battery and temperature sensors.
On the raven, the battery and temperature readings are available from the companion 3290 cpu over the serial line. Modify the existing raven-lcd-interface application to export these sensors.
This commit is contained in:
parent
c792993664
commit
d2528caa85
|
@ -1,4 +1,4 @@
|
|||
raven-lcd-interface_src = raven-lcd.c
|
||||
|
||||
|
||||
CFLAGS+=-DRAVEN_LCD_INTERFACE=1
|
||||
CFLAGS+=-DRAVEN_LCD_INTERFACE=1 -DPLATFORM_HAS_BATTERY -DPLATFORM_HAS_TEMPERATURE
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
* driver chip (ATMega3290P) on the Raven.
|
||||
*
|
||||
* \author Blake Leverett <bleverett@gmail.com>
|
||||
* \author Cristiano De Alti <cristiano_dealti@hotmail.com>
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
@ -69,6 +70,7 @@
|
|||
#endif
|
||||
|
||||
#include "raven-lcd.h"
|
||||
#include "lib/sensors.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
@ -94,6 +96,9 @@ static struct{
|
|||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||
#define PING6_DATALEN 16
|
||||
|
||||
static int battery_value;
|
||||
static int temperature_value;
|
||||
|
||||
void rs232_send(uint8_t port, unsigned char c);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -306,12 +311,14 @@ raven_gui_loop(process_event_t ev, process_data_t data)
|
|||
/* Set temperature string in web server */
|
||||
web_set_temp((char *)cmd.frame);
|
||||
#endif
|
||||
temperature_value = atoi((char *)cmd.frame);
|
||||
break;
|
||||
case SEND_ADC2:
|
||||
#if AVR_WEBSERVER
|
||||
/* Set ext voltage string in web server */
|
||||
web_set_voltage((char *)cmd.frame);
|
||||
#endif
|
||||
battery_value = atoi((char *)cmd.frame);
|
||||
break;
|
||||
case SEND_SLEEP:
|
||||
/* Sleep radio and 1284p. */
|
||||
|
@ -458,6 +465,42 @@ char buf[sizeof(eemem_server_name)+1];
|
|||
raven_lcd_show_text(buf); //must fit in all the buffers or it will be truncated!
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
value_temperature(int type) {
|
||||
return temperature_value;
|
||||
}
|
||||
|
||||
int
|
||||
value_battery(int type) {
|
||||
return battery_value;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
configure(int type, int value) {
|
||||
/* prevent compiler warnings */
|
||||
return type = value = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
status(int type) {
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
case SENSORS_READY:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
SENSORS_SENSOR(temperature_sensor, "Temperature",
|
||||
value_temperature, configure, status);
|
||||
SENSORS_SENSOR(battery_sensor, "Battery",
|
||||
value_battery, configure, status);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(raven_lcd_process, "Raven LCD interface process");
|
||||
PROCESS_THREAD(raven_lcd_process, ev, data)
|
||||
|
|
49
platform/avr-raven/dev/temperature-sensor.h
Normal file
49
platform/avr-raven/dev/temperature-sensor.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Temperature sensor header file.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
* Joakim Eriksson <joakime@sics.se>
|
||||
* Niclas Finne <nfi@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef TEMPERATURE_SENSOR_H_
|
||||
#define TEMPERATURE_SENSOR_H_
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern const struct sensors_sensor temperature_sensor;
|
||||
|
||||
#define TEMPERATURE_SENSOR "Temperature"
|
||||
|
||||
#endif /* TEMPERATURE_SENSOR_H_ */
|
Loading…
Reference in a new issue