WAITKEY/de
From MCS Wiki AVR
< WAITKEY(Difference between revisions)
m (1 revision) |
(→Remarks) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | = <span class="f_Header">Funktion</span> = | |
− | + | Wartet bis ein Zeichen empfangen wird. | |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 17: | Line 17: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <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 | + | Variable für Empfang des ASCII-Zeichens aus dem seriellen Buffer. |
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | 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);" | | ||
− | + | Für Software-UART benutzter Kanal. | |
|} | |} | ||
Line 42: | Line 42: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | + | 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;"> </span> | <span style="font-family: Arial;"> </span> | ||
Line 48: | Line 50: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <span class="f_Header">Siehe auch</span> = |
[[INKEY]] , [[ISCHARWAITING]] | [[INKEY]] , [[ISCHARWAITING]] | ||
Line 56: | Line 58: | ||
<span style="font-family: Arial;"> </span> | <span style="font-family: Arial;"> </span> | ||
− | = <span class="f_Header"> | + | = <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 ' | + | $crystal = 4000000 ' Taktrate |
− | $baud = 19200 ' | + | $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() ' | + | A = Inkey() 'ASCII-Zeichen von serieller Schnittstelle empfangen |
's = Inkey() | 's = Inkey() | ||
− | If A > 0 Then ' | + | 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 ' | + | Loop Until A = 27 'bis ESC gedrückt wird |
− | A = Waitkey() ' | + | A = Waitkey() 'Auf ein Zeichen warten |
's = waitkey() | 's = waitkey() | ||
Print Chr(a) | Print Chr(a) | ||
− | ' | + | 'warten bis ESC gedrückt wird |
Do | Do | ||
Loop Until Inkey() = 27 | 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 | 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
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 |
---|