adapted for new sensor APIs

This commit is contained in:
joxe 2010-01-14 16:13:45 +00:00
parent e0c0808767
commit 071a9eaa6b

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: button-sensor.c,v 1.4 2007/04/02 14:14:28 fros4943 Exp $ * $Id: button-sensor.c,v 1.5 2010/01/14 16:13:45 joxe Exp $
*/ */
#include "lib/sensors.h" #include "lib/sensors.h"
@ -41,38 +41,6 @@ static struct timer debouncetimer;
char simButtonChanged; char simButtonChanged;
char simButtonIsDown; char simButtonIsDown;
char simButtonIsActive; char simButtonIsActive;
/*---------------------------------------------------------------------------*/
static void
init(void)
{
simButtonIsActive = 1;
timer_set(&debouncetimer, 0);
}
/*---------------------------------------------------------------------------*/
static int
irq(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static void
activate(void)
{
simButtonIsActive = 1;
}
/*---------------------------------------------------------------------------*/
static void
deactivate(void)
{
simButtonIsActive = 0;
}
/*---------------------------------------------------------------------------*/
static int
active(void)
{
return simButtonIsActive;
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static unsigned int static unsigned int
value(int type) value(int type)
@ -81,15 +49,21 @@ value(int type)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
configure(int type, void *c) configure(int type, int c)
{ {
if(type == SENSORS_ACTIVE) {
simButtonIsActive = c;
} else if(type == SENSORS_HW_INIT) {
simButtonIsActive = 1;
timer_set(&debouncetimer, 0);
}
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void * static int
status(int type) status(int type)
{ {
return 0; return (type == SENSORS_ACTIVE) ? simButtonIsActive : 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
@ -116,5 +90,4 @@ SIM_INTERFACE(button_interface,
doInterfaceActionsAfterTick); doInterfaceActionsAfterTick);
SENSORS_SENSOR(button_sensor, BUTTON_SENSOR, SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
init, irq, activate, deactivate, active,
value, configure, status); value, configure, status);