INKEY/de

From MCS Wiki AVR
< INKEY(Difference between revisions)
Jump to: navigation, search
(Created page with "= <span class="f_Header">Action</span> = Returns the ASCII value of the first character in the serial input buffer. <span style="font-family: Arial;"> </span> <span st...")
 
(Beispiel)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== (**COPIED FROM ENGLISH PAGE**) === <span class="f_Header">Action</span> =
+
= <span class="f_Header">Funktion</span> =
  
Returns the ASCII value of the first character in the serial input buffer.
+
Gibt den ASCII-Wert des ersten Zeichens aus dem seriellen Buffer zurück.
  
 
<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="488" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="488" 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: 395px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 395px; border: 1px solid rgb(0, 0, 0);" |  
Byte, Integer, Word, Long or String variable.
+
Byte-, Integer-, Word-, Long- oder String-Variable.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="100%" style="width: 395px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 395px; border: 1px solid rgb(0, 0, 0);" |  
A constant number that identifies the opened channel if software UART mode
+
Konstante Nummer des Software-UART-Kanals.
  
 
|}
 
|}
Line 38: Line 38:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
If there is no character waiting, a zero will be returned.
+
Wenn kein Zeichen ansteht dann wird Null zurückgegeben.
  
Use the IsCharWaiting() function to check if there is a byte waiting.
+
Benutzen Sie IsCharWaiting() um zu prüfen ob ein Zeichen ansteht.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The INKEY routine can be used when you have a RS-232 interface on your uP.
+
Die INKEY-Funktion kann benutzt werden wenn eine serielle Schnittstelle benutzt wird.
  
The RS-232 interface can be connected to a comport of your computer.
+
Die serielle Schnittstelle kann mit einem Com-Port eines PCs verglichen werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
As zero(0) will be returned when no character is waiting, the usage is limited when the value of 0 is used in the serial transmission. You can not make a difference between a byte with the value 0 and the case where no data is available.
+
Eine Null (0) wird zurückgegeben wenn kein Zeichen ansteht. Die Funktion eignet sich daher nur bedingt wenn auch Nullen empfangen werden sollen. Man kann nicht unterscheiden zwischen einer empfangenen Null und dem Fall dass kein Zeichen ansteht.
  
In that case you can use IsCharwaiting to deterimine if there is a byte waiting.
+
In so einem Fall kann man IsCharwaiting benutzen um herauszufinden ob ein Zeichen ansteht.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 58: Line 58:
 
<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> =
  
 
[[WAITKEY]]&nbsp;,&nbsp;[[ISCHARWAITING]]
 
[[WAITKEY]]&nbsp;,&nbsp;[[ISCHARWAITING]]
Line 66: Line 66:
 
<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 79: Line 79:
 
   
 
   
 
$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 87: Line 87:
 
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:42, 21 February 2013

Contents

Funktion

Gibt den ASCII-Wert des ersten Zeichens aus dem seriellen Buffer zurück.

 

 

Syntax

var = INKEY()

var = INKEY(#channel)

 

 

Anmerkungen

Var

Byte-, Integer-, Word-, Long- oder String-Variable.

Channel

Konstante Nummer des Software-UART-Kanals.

 

Wenn kein Zeichen ansteht dann wird Null zurückgegeben.

Benutzen Sie IsCharWaiting() um zu prüfen ob ein Zeichen ansteht.

 

Die INKEY-Funktion kann benutzt werden wenn eine serielle Schnittstelle benutzt wird.

Die serielle Schnittstelle kann mit einem Com-Port eines PCs verglichen werden.

 

Eine Null (0) wird zurückgegeben wenn kein Zeichen ansteht. Die Funktion eignet sich daher nur bedingt wenn auch Nullen empfangen werden sollen. Man kann nicht unterscheiden zwischen einer empfangenen Null und dem Fall dass kein Zeichen ansteht.

In so einem Fall kann man IsCharwaiting benutzen um herauszufinden ob ein Zeichen ansteht.

 

 

Siehe auch

WAITKEY , 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