input.c File Reference

#include "input.h"

Defines

#define ENTPR   1000
#define PRESS_LONG   1000000

Functions

void voidfunc (void)
void tasten_status (void)
void switch_off (void)
void input_init (void)
 initialises the input
void input_refresh (void)
 refreshes the input

Variables

int8_t joy_adc_ready = 0
void(* taste [8])(void)
void(* taste_long [8])(void)

Define Documentation

#define ENTPR   1000
 

#define PRESS_LONG   1000000
 


Function Documentation

void input_init void   ) 
 

initialises the input

00030                      {
00031     taste[0] = &menu_main_incr;
00032     taste[1] = &menu_start;
00033     taste[2] = &menu_left;
00034     taste[3] = &menu_up;
00035     taste[4] = &menu_down;
00036     taste[5] = &menu_right;
00037     taste[6] = &voidfunc;
00038     taste[7] = &voidfunc;
00039     taste_long[0] = &switch_off;
00040     taste_long[1] = &voidfunc;
00041     taste_long[2] = &voidfunc;
00042     taste_long[3] = &voidfunc;
00043     taste_long[4] = &voidfunc;
00044     taste_long[5] = &voidfunc;
00045     taste_long[6] = &voidfunc;
00046     taste_long[7] = &voidfunc;
00047 }

void input_refresh void   ) 
 

refreshes the input

this function needs to be called regularly in order to register all button events.

Bug:
With prescaler 7 input_refresh() does not get called often enough.
Todo:
Copy code from tasten_status() directly in here?
00054                         {
00055     tasten_status();
00056 }

void switch_off void   ) 
 

00025                      {
00026     disp_off();
00027     PORTA = 0;
00028 }

void tasten_status void   ) 
 

00061                          {
00062     static uint8_t taster = 255;
00063     static uint32_t last_down = 0;
00064 
00065     uint8_t taster_neu = PINC;
00066     uint8_t diff = taster_neu ^ taster; //contains changes; "^" is xor
00067     diff &= taster_neu; //on_release; substitute taster_neu to taster to get on_push
00068 
00069     //if(count < 65535) count++;
00070     double timeFromLastDown = us_time_get_difference_d(last_down);
00071     #define ENTPR 1000
00072     #define PRESS_LONG 1000000
00073     if(timeFromLastDown > ENTPR){   //entprellen: sicherstellen, dass bestimmte Zeit vergangen ist
00074         if     (bit_is_set(diff,0)) taste[0]();     //Taste 1
00075         else if(bit_is_set(diff,1)) taste[1]();     //TASTE 2
00076         else if(bit_is_set(diff,2)) taste[2]();     //TASTE 3
00077         else if(bit_is_set(diff,3)) taste[3]();     //TASTE 4
00078         else if(bit_is_set(diff,4)) taste[4]();     //TASTE 5
00079         else if(bit_is_set(diff,5)) taste[5]();     //TASTE 6
00080         else if(bit_is_set(diff,6)) taste[6]();     //TASTE 7
00081         else if(bit_is_set(diff,7)) taste[7]();     //TASTE 8
00082     }
00083     if(taster != taster_neu) last_down = us_time_get();     //entprelltime neu setzen
00084     timeFromLastDown = us_time_get_difference_d(last_down);
00085     if(timeFromLastDown > PRESS_LONG){
00086         if     (bit_is_clear(taster_neu,0) && bit_is_clear(diff,0)) taste_long[0]();
00087         else if(bit_is_clear(taster_neu,1) && bit_is_clear(diff,1)) taste_long[1]();
00088         else if(bit_is_clear(taster_neu,2) && bit_is_clear(diff,2)) taste_long[2]();
00089         else if(bit_is_clear(taster_neu,3) && bit_is_clear(diff,3)) taste_long[3]();
00090         else if(bit_is_clear(taster_neu,4) && bit_is_clear(diff,4)) taste_long[4]();
00091         else if(bit_is_clear(taster_neu,5) && bit_is_clear(diff,5)) taste_long[5]();
00092         else if(bit_is_clear(taster_neu,6) && bit_is_clear(diff,6)) taste_long[6]();
00093         else if(bit_is_clear(taster_neu,7) && bit_is_clear(diff,7)) taste_long[7]();
00094     }
00095     taster = taster_neu;
00096 }

void voidfunc void   ) 
 

00017 {}


Variable Documentation

int8_t joy_adc_ready = 0
 

void(* taste[8])(void)
 

void(* taste_long[8])(void)
 


Generated on Fri Aug 11 21:47:32 2006 for OpenOsci by  doxygen 1.4.6