WAITKEY/de

From MCS Wiki AVR
< WAITKEY(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(Remarks)
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
== (**COPIED FROM ENGLISH PAGE**) === <span class="f_Header">Action</span> =
+
= <span class="f_Header">Funktion</span> =
  
Wait until a character is received.
+
Wartet bis ein Zeichen empfangen wird.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 17: Line 17:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
{| width="548" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="548" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
Line 25: Line 25:
  
 
| valign="top" width="100%" style="width: 417px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 417px; border: 1px solid rgb(0, 0, 0);" |  
Variable that receives the ASCII value of the serial buffer.
+
Variable für Empfang des ASCII-Zeichens aus dem seriellen Buffer.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Can be a numeric variable or a string variable.
+
Kann eine numerische Variable oder eine Zeichenketten-Variable sein.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 36: Line 36:
  
 
| valign="top" width="100%" style="width: 417px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 417px; border: 1px solid rgb(0, 0, 0);" |  
The channel used for the software UART.
+
Für Software-UART benutzter Kanal.
  
 
|}
 
|}
Line 42: Line 42:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
While Inkey() returns a character from the serial buffer too, INKEY() continues when there is no character. Waitkey() waits until there is a character received. This blocks your program.
+
Inkey() gibt ebenfalls ein Zeichen aus dem seriellen Buffer zurück aber Inkey() wartet nicht wenn kein Zeichen im Buffer ist.
 +
 
 +
Waitkey() wartet bis ein Zeichen empfangen wird und blockiert dadurch den Programmablauf.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 48: Line 50:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">See also</span> =
+
= <span class="f_Header">Siehe auch</span> =
  
 
[[INKEY]]&nbsp;,&nbsp;[[ISCHARWAITING]]
 
[[INKEY]]&nbsp;,&nbsp;[[ISCHARWAITING]]
Line 56: Line 58:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Example</span> =
+
= <span class="f_Header">Beispiel</span> =
  
 
<br/><source lang="bascomavr">
 
<br/><source lang="bascomavr">
Line 69: Line 71:
 
   
 
   
 
$regfile = "m48def.dat" ' specify the used micro
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
+
$crystal = 4000000 ' Taktrate
$baud = 19200 ' use baud rate
+
$baud = 19200 ' Baudrate
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$hwstack = 32 ' default use 32 for the hardware stack
 
$swstack = 10 ' default use 10 for the SW stack
 
$swstack = 10 ' default use 10 for the SW stack
Line 77: Line 79:
 
Dim A As Byte , S As String * 2
 
Dim A As Byte , S As String * 2
 
Do
 
Do
  A = Inkey() 'get ascii value from serial port
+
  A = Inkey() 'ASCII-Zeichen von serieller Schnittstelle empfangen
 
's = Inkey()
 
's = Inkey()
If A > 0 Then 'we got something
+
If A > 0 Then 'es wurde etwas empfangen
 
  Print "ASCII code " ; A ; " from serial"
 
  Print "ASCII code " ; A ; " from serial"
 
End If
 
End If
Loop Until A = 27 'until ESC is pressed
+
Loop Until A = 27 'bis ESC gedrückt wird
 
   
 
   
A = Waitkey() 'wait for a key
+
A = Waitkey() 'Auf ein Zeichen warten
 
's = waitkey()
 
's = waitkey()
 
Print Chr(a)
 
Print Chr(a)
 
   
 
   
'wait until ESC is pressed
+
'warten bis ESC gedrückt wird
 
Do
 
Do
 
Loop Until Inkey() = 27
 
Loop Until Inkey() = 27
 
   
 
   
'When you need to receive binary data and the bibary value 0 ,
+
'Wenn binäre Daten und der binäre Wert 0 empfangen werden sollen
'you can use the IScharwaiting() function.
+
'kann man die  IScharwaiting() Funktion benutzen.
'This will return 1 when there is a char waiting and 0 if there is no char waiting.
+
'IScharwaiting() gibt 1 zurück wenn ein Zeichen empfangen wurde und 0 wenn kein Zeichen empfangen wurde.
'You can get the char with inkey or waitkey then.
+
'Man kann das Zeichen dann mit inkey oder waitkey einlesen.
 
End
 
End
 
</source><br/>{{Languages}}
 
</source><br/>{{Languages}}
  
 
[[Category:BASCOM Language Reference/de]]
 
[[Category:BASCOM Language Reference/de]]

Latest revision as of 23:41, 21 February 2013

Contents

Funktion

Wartet bis ein Zeichen empfangen wird.

 

 

Syntax

var = WAITKEY()

var = WAITKEY(#channel)

 

 

Anmerkungen

var

Variable für Empfang des ASCII-Zeichens aus dem seriellen Buffer.

 

Kann eine numerische Variable oder eine Zeichenketten-Variable sein.

#channel

Für Software-UART benutzter Kanal.

 

Inkey() gibt ebenfalls ein Zeichen aus dem seriellen Buffer zurück aber Inkey() wartet nicht wenn kein Zeichen im Buffer ist.

Waitkey() wartet bis ein Zeichen empfangen wird und blockiert dadurch den Programmablauf.

 

 

Siehe auch

INKEY , ISCHARWAITING

 

 

Beispiel


'-----------------------------------------------------------------------------------------
'name : inkey.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demo: INKEY , WAITKEY
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m48def.dat" ' specify the used micro
$crystal = 4000000 ' Taktrate
$baud = 19200 ' Baudrate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Dim A As Byte , S As String * 2
Do
 A = Inkey() 'ASCII-Zeichen von serieller Schnittstelle empfangen
's = Inkey()
If A > 0 Then 'es wurde etwas empfangen
 Print "ASCII code " ; A ; " from serial"
End If
Loop Until A = 27 'bis ESC gedrückt wird
 
A = Waitkey() 'Auf ein Zeichen warten
's = waitkey()
Print Chr(a)
 
'warten bis ESC gedrückt wird
Do
Loop Until Inkey() = 27
 
'Wenn binäre Daten und der binäre Wert 0 empfangen werden sollen
'kann man die  IScharwaiting() Funktion benutzen.
'IScharwaiting() gibt 1 zurück wenn ein Zeichen empfangen wurde und 0 wenn kein Zeichen empfangen wurde.
'Man kann das Zeichen dann mit inkey oder waitkey einlesen.
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language