s_joystick.c File Reference


Detailed Description

AVR32 UC3 Control Panel joystick sensor module.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file s_joystick.c.

#include <string.h>
#include <stdio.h>
#include "compiler.h"
#include "s_joystick.h"
#include "joystick.h"
#include "FreeRTOS.h"

Go to the source code of this file.

Defines

#define JS_EVENT_DOWN   0x10
#define JS_EVENT_LEFT   0x02
#define JS_EVENT_PUSH   0x01
#define JS_EVENT_RIGHT   0x04
#define JS_EVENT_UP   0x08
#define JS_NB_EVENT   32

Functions

Bool b_joystick_get_value (char *buf)
 Get the current joystick state.

Variables

const signed portCHAR * acpc_js_events [JS_NB_EVENT]
static unsigned short x_joystick = 0


Define Documentation

#define JS_EVENT_DOWN   0x10

Definition at line 65 of file s_joystick.c.

Referenced by b_joystick_get_value().

#define JS_EVENT_LEFT   0x02

Definition at line 62 of file s_joystick.c.

Referenced by b_joystick_get_value().

#define JS_EVENT_PUSH   0x01

Mask for events on joystick.

Definition at line 61 of file s_joystick.c.

Referenced by b_joystick_get_value().

#define JS_EVENT_RIGHT   0x04

Definition at line 63 of file s_joystick.c.

Referenced by b_joystick_get_value().

#define JS_EVENT_UP   0x08

Definition at line 64 of file s_joystick.c.

Referenced by b_joystick_get_value().

#define JS_NB_EVENT   32

Max number of events on joystick.

Definition at line 58 of file s_joystick.c.


Function Documentation

Bool b_joystick_get_value ( char *  buf  ) 

Get the current joystick state.

Parameters:
buf char buffer in which the joystick state is stored.
Returns:
TRUE upon success, FALSE if error.

Definition at line 94 of file s_joystick.c.

References acpc_js_events, JS_EVENT_DOWN, JS_EVENT_LEFT, JS_EVENT_PUSH, JS_EVENT_RIGHT, JS_EVENT_UP, and x_joystick.

Referenced by device_full_custom_task().

00095 {
00096     // input is pulled up, if 1 : input is not active
00097     if ( !is_joystick_up() )  { Clr_bits(x_joystick, JS_EVENT_UP); }
00098     else                      { Set_bits(x_joystick, JS_EVENT_UP); }
00099 
00100     if ( !is_joystick_down() ) { Clr_bits(x_joystick, JS_EVENT_DOWN); } 
00101     else                       { Set_bits(x_joystick, JS_EVENT_DOWN); }
00102 
00103     if ( !is_joystick_left() )  { Clr_bits(x_joystick, JS_EVENT_LEFT); } 
00104     else                        { Set_bits(x_joystick, JS_EVENT_LEFT); }
00105 
00106     if ( !is_joystick_right() )  { Clr_bits(x_joystick, JS_EVENT_RIGHT); } 
00107     else                         { Set_bits(x_joystick, JS_EVENT_RIGHT); }
00108 
00109     if ( !is_joystick_pressed() ) { Clr_bits(x_joystick, JS_EVENT_PUSH); } 
00110     else                          { Set_bits(x_joystick, JS_EVENT_PUSH); }
00111 
00112    // Build the log string.
00113    sprintf( buf, "%s\r\n", (portCHAR *)acpc_js_events[x_joystick]);
00114    return TRUE;
00115 }


Variable Documentation

const signed portCHAR* acpc_js_events[JS_NB_EVENT]

Initial value:

 {
   (signed portCHAR *)"RELEASE",(signed portCHAR *)"PRESS",(signed portCHAR *)"LEFT",(signed portCHAR *)"LEFT/PRESS",
   (signed portCHAR *)"RIGHT",(signed portCHAR *)"RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
   (signed portCHAR *)"UP",(signed portCHAR *)"UP/PRESS",(signed portCHAR *)"UP/LEFT",(signed portCHAR *)"UP/LEFT/PRESS",
   (signed portCHAR *)"UP/RIGHT",(signed portCHAR *)"UP/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
   (signed portCHAR *)"DOWN",(signed portCHAR *)"DOWN/PRESS",(signed portCHAR *)"DOWN/LEFT",(signed portCHAR *)"DOWN/LEFT/PRESS",
   (signed portCHAR *)"DOWN/RIGHT",(signed portCHAR *)"DOWN/RIGHT/PRESS",(signed portCHAR *)"?",(signed portCHAR *)"?",
   (signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
   (signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",(signed portCHAR *)"?",
}
Joystick events string, regarding bit field value.

Definition at line 70 of file s_joystick.c.

Referenced by b_joystick_get_value().

unsigned short x_joystick = 0 [static]

Joystick events.

Definition at line 82 of file s_joystick.c.

Referenced by b_joystick_get_value().


Generated on Fri Feb 19 02:22:52 2010 for AVR32 - Control Panel demonstration. by  doxygen 1.5.5