Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
BUTTON LIBRARY
The Button library contains miscellaneous routines useful for a project development.
External dependencies of Button Library
Library Routines
- Button 
Button
484
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
The following variable
must be defined in all
projects using Button
library:
Description: 
Example : 
var Button_Pin :
sbit; sfr; external;
Declares button pins.
var Button_Pin : sbit
at 
PINB.B0; 
var
Button_Pin_Direction :
sbit; sfr; external;
Declares direction of the
button pin.
var
Button_Pin_Direction
sbit at DDRB.B0;
Prototype
function Button(time_ms : byte; active_state : byte) : byte;
Returns
255
if the pin was in the active state for given period. 
0
otherwise 
Description
The function eliminates the influence of contact flickering upon pressing a but-
ton (debouncing). The Button pin is tested just after the function call and then
again after the debouncing period has expired. If the pin was in the active state
in both cases then the function returns 255 (true).
Parameters : 
time_ms
: debouncing period in milliseconds 
active_state
: determines what is considered as active state. Valid values: 0   
(logical zero) and 1 (logical one) 
Requires
Global variables : 
Button_Pin
: Button pin line 
Button_Pin_Direction
: Direction of the button pin 
must be defined before using this function.