View previous topic :: View next topic |
Author |
Message |
naicheben
Joined: 18 Nov 2004 Posts: 47 Location: Leck
|
Posted: Mon Dec 13, 2004 11:03 pm Post subject: getrc5 interupt |
|
|
Hello forum,
I want to use the Getrc5() funktion to send remotecontrol commands to a PC via RS232, but I don't want it to wait until a key is pressed on the remotecontroll. Is there a way to catch it by interrupts?
First I thought the serint.bas sample could help me out of this, but it does not, because I still have to call Getrc5() and then it hangs until a key is pressed.
Please help me out of this,
regards Ingmar |
|
Back to top |
|
|
jasreb
Joined: 03 Dec 2004 Posts: 41
|
Posted: Wed Dec 15, 2004 10:38 pm Post subject: |
|
|
You should be able to just use Getrc5 in the main program loop, if there's no data it will just go past and execute the next command. works fine for me anyway in that way. |
|
Back to top |
|
|
naicheben
Joined: 18 Nov 2004 Posts: 47 Location: Leck
|
Posted: Thu Dec 16, 2004 2:05 am Post subject: |
|
|
Thank you for your reply. The problem was,that my mainloop took to much time so I had to do it with interrupts. I solved the problem with a hint out of this forum. I also had to delete the "nosave" after "on int0 receiverc5" and now it works perfect for me.
I didn't notice that it continued in the code, I thought it waited forever. I will check your tip in future. Thank you very much.
regards
Ingmar |
|
Back to top |
|
|
Frankeman
Joined: 11 Aug 2004 Posts: 948 Location: the Netherlands
|
Posted: Thu Dec 16, 2004 5:19 pm Post subject: |
|
|
Hi Ingmar,
Can you tell what the solution was, so other people on this forum can learn a bit from you.
Frank. |
|
Back to top |
|
|
naicheben
Joined: 18 Nov 2004 Posts: 47 Location: Leck
|
Posted: Fri Dec 17, 2004 10:53 pm Post subject: |
|
|
Ok, its a bit nasty code but here is it:
'--------------------------------------------------------------------
' KS108.BAS
' demonstrates the KS108 based graphical display support
'--------------------------------------------------------------------
'some routines to control the display are in the glcdKS108.lib file
$lib "glcdKS108.lib"
$lib "mcsbyte.lbx"
'$sim
'tell the compiler which pin we want to use for the receiver input
Config Rc5 = Pind.2
Enable Interrupts
Enable Int0
'reserve space for variables
Dim Address As Byte , Command As Byte
$crystal = 1843200
$baud = 9600
'First we define that we use a graphic LCD
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Porta , Ce = 3 , Ce2 = 2 , Cd = 5 , Rd = 6 , Enable = 7 , Reset = 4
Dim X As Byte , Y As Byte , Xe As Byte , Ye As Byte
Dim Befehl As String * 6 'Lcdat,Frame,Line,Cls...
Dim Gelaber As String * 15 'gelaber z.B. Lcdat 1,1,uhrzeit
Dim Ausgabe As String * 8
Wait 1 'extra setuptime for the display
Cls
On Int0 Receiverc5 'Nosave (does not work with nosave!!!)
'specify the font we want to use....REAL BIG ONES
Setfont Font16x16 'Inges16x16 selfmade font did not work!!!
'Mainloop
Do
Anfang:
Input "Enter Command" , Gelaber 'Enter LCD-command
Befehl = Left(gelaber , 6)
Ausgabe = Mid(gelaber , 7)
If Befehl = "Lcdat1" Then
Lcdat 1 , 1 , Ausgabe
Goto Anfang
End If
'... and so on
Goto Anfang
End If
Loop
End 'end program
Receiverc5:
Disable Int0
Enable Interrupts
Getrc5(address , Command)
If Address < 255 Then 'every key is to be transmitted
'clear the toggle bit
'the toggle bit toggles on each new received command
'toggle bit is bit 7. Extended RC5 bit is in bit 6
Command = Command And &B01111111
Print "RC5 " ; Address ; "," ; Command
End If
Enable Int0
Return
'include the font for big letters
$include "font16x16.font" |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|