Also, hier erstmal der komplette Code:
Code:
'----------------------------------------------------------------------
'Wartet auf ein RC5 Signal, gibt dessen Code auf dem LCD aus und sendet
'bei lautem Geräusch (zB. Klatschen) das empfangene Signal zurück.
'Das Togglebit wird dabei geändert.
'----------------------------------------------------------------------
'
'--------------------------
'------ I/O PORTS ---------
'--------------------------
'- INTERFACE LCD/EXTPORT --
define sdio port[1]
define sclio port[3]
define strobe port[4]
'-- INTERFACE COM/NAV -----
define DATALINE port[1]
define CLOCKLINE port[2]
'---- EIGENE PORTS --------
define BUMPER port[7]
'------- LCD PORTS --------
define D4 port[9]
define D5 port[10]
define D6 port[11]
define D7 port[12]
define RW port[13]
define RS port[14]
define EN port[15]
'---- FREIE PORTS ---------
define FREIP8 port[8]
define FREIP16 port[16]
'--------------------------
'-------- SENSORS ---------
'--------------------------
define LIGHT_L ad[7]
define LIGHT_R ad[6]
define SYS_VOLTS ad[3]
define CHRG_CURRENT ad[2]
define SYS_CURRENT ad[1]
define MIC ad[4]
define TOUCH ad[5]
'---------------------------
'--------- DRIVE -----------
'---------------------------
define SPEED_L da[1]
define SPEED_R da[2]
define REV_L port[6]
define REV_R port[5]
'--------------------------
'----- SYSTEM MEMORY ------
'--------------------------
'---- INTERFACE BUFFER ----
define LBYTE byte[1]
define HBYTE byte[2]
define SUBCMD byte[3]
'---- OPERATION DATA ------
define EXTPORT byte[4]
define LED1_F bit[29]
define LED2_F bit[30]
define LED3_F bit[31]
define LED4_F bit[32]
define SYSTEM_STATUS byte[5]
define ACSL_F bit[33]
define ACSR_F bit[34]
define IR_F bit[35]
'------ LCD BUFFER --------
define LCDByte byte[6]
define LCDVar byte[7]
'--------------------------
'------ USER MEMORY -------
'--------------------------
define i1 byte[8]
define IRHI byte[9]
define IRLO byte[10]
define Sample byte[11]
'---- SYSTEMROUTINEN ------
define PLM_SLOW &H01C4
define SYSTEM &H01C9
define COMNAV &H0154
'-- ERWEITERTE ROUTINEN ---
define REVR &H0101 'ANTRIEB RECHTS RÜCKWÄRTS
define REVL &H0106 'ANTRIEB LINKS RÜCKWÄRTS
define FWDR &H010B 'ANTRIEG RECHTS VORWÄRTS
define FWDL &H0110 'ANTRIEB LINKS VORWÄRTS
define ROTR &H0115 'RECHTS DREHEN
define ROTL &H0119 'LINKS DREHEN
define REV &H011D 'RÜCKWÄRTS
define FWD &H0121 'VORWÄRTS
define COMNAV_STATUS &H0125 'UPDATED ALLE FLAGS IM STATUS-REGISTER
define ACS_LO &H01E1 'ACS POWER
define ACS_HI &H01E9 '
define ACS_MAX &H01F1 '
define SEND_TLM &H014A 'SENDET TELEMETRIE (CH=HBYTE,DATEN=LBYTE)
define SEND_SPEEDR &H0134 'SENDET TLM KANAL 8,PLM RECHTS
define SEND_SPEEDL &H013A 'SENDET TLM KANAL 7,PLM LINKS
define SEND_SYSSTAT &H0144 'SENDET TLM KANAL 0,SYSTEM STATUS
'(FLAGS für ACS,FWD/REV, ACS_LO/HI/MAX)
define LCDON &B00001100
define LCDOFF &B00001000
define LCDCLS &B00000001
define LCDSHIFTR &B00011100
define LCDSHIFTL &B00011000
define LCDCURSHIFTR &B00010100
define LCDCURSHIFTL &B00010000
define LCDCURON &B00001110
define LCDCUROFF &B00001100
define LCDCURBON &B00001111
define LCDCURBOFF &B00001110
define LCDCURHOME &B00000010
define LCDROW1 &B10000000
define LCDROW2 &B11000000
'--------------------------
'--------- INIT -----------
FREIP8=off:FREIP16=off
D4=off:D5=off:D6=off:D7=off:RW=off:RS=off:EN=off
beep 736,2,0
gosub SUBSYS_PWR_ON
pause 50
gosub NO_ACS_INT
SYS ACS_HI
REV_L=on:REV_R=on:SYS PLM_SLOW
beep 368,2,0
gosub RC5
gosub LEDSOFF
gosub LCD_INIT
beep 184,2,0
'--------- MAIN -----------
#loop
gosub GET_IRDATA
if LBYTE and HBYTE=&HFF then goto idle
IRHI=HBYTE:IRLO=LBYTE
gosub irdisp
goto loop
#idle
for i1=1 to 50
if MIC>Sample then Sample=MIC
next
if Sample>=4 then gosub irsnd
Sample=0
goto loop
#irsnd
IRHI=IRHI xor 32:gosub irdisp
HBYTE=IRHI:LBYTE=IRLO
gosub SEND_IRDATA
return
#irdisp
gosub LCD_SETCOMMAND
LCDByte=LCDOFF:gosub LCD_SEND
LCDByte=LCDCLS:gosub LCD_SEND
gosub LCD_SETWRITE
LCDVar=IRHI:gosub LCD_VARSEND3
gosub LCD_SETCOMMAND
LCDByte=LCDROW2:gosub LCD_SEND
gosub LCD_SETWRITE
LCDVar=IRLO:gosub LCD_VARSEND3
gosub LCD_SETCOMMAND
LCDByte=LCDON:gosub LCD_SEND
return
'--------------------------
'------- LCD DRIVER -------
#LCD_INIT
gosub LCD_SETCOMMAND
LCDByte=&B00110011:gosub LCD_SEND
LCDByte=&B00110010:gosub LCD_SEND
LCDByte=&B00101100:gosub LCD_SEND
LCDByte=LCDOFF:gosub LCD_SEND
LCDByte=LCDON:gosub LCD_SEND
LCDByte=&B00000110:gosub LCD_SEND
return
#LCD_SETCOMMAND
RS=off:RW=off
return
#LCD_SETWRITE
RS=on:RW=off
return
#LCD_VARSEND3
LCDByte=(LCDVar/100)+48:gosub LCD_SEND
LCDVar=LCDVar mod 100
#LCD_VARSEND2
LCDByte=(LCDVar/10)+48:gosub LCD_SEND
LCDByte=(LCDVar mod 10)+48
#LCD_SEND
D7=LCDByte and 128
D6=LCDByte and 64
D5=LCDByte and 32
D4=LCDByte and 16
pulse EN
D7=LCDByte and 8
D6=LCDByte and 4
D5=LCDByte and 2
D4=LCDByte and 1
pulse EN
return
'------- LED DRIVER -------
#LED1ON
LED1_F=on:goto EXTPORT_WRITE
#LED1OFF
LED1_F=off and &HEF:goto EXTPORT_WRITE
#LED2ON
LED2_F=on:goto EXTPORT_WRITE
#LED2OFF
LED2_F=off:goto EXTPORT_WRITE
#LED3ON
LED3_F=on:goto EXTPORT_WRITE
#LED3OFF
LED3_F=off:goto EXTPORT_WRITE
#LED4ON
LED4_F=on:goto EXTPORT_WRITE
#LED4OFF
LED4_F=off:goto EXTPORT_WRITE
#LEDSOFF
EXTPORT=EXTPORT and &H0F
#EXTPORT_WRITE
SYS SYSTEM:pulse STROBE:RETURN
'------- COMNAV DRIVER --------
#GET_IRDATA
SUBCMD=1:sys COMNAV:return
#SEND_IRDATA
SUBCMD=0:sys COMNAV:return
#RC5
SUBCMD=4:sys COMNAV:LBYTE= HBYTE and &HFC
HBYTE=00:SUBCMD=2:sys COMNAV:return
#RC5_INT
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE and &HFE)or 2
HBYTE=00:SUBCMD=2:sys COMNAV:return
#REC80
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE or &H01)and&HFD
HBYTE=00:SUBCMD=2:sys COMNAV:return
#REC80_INT
SUBCMD=4:sys COMNAV:LBYTE= (HBYTE or &H03)
HBYTE=00:SUBCMD=2:sys COMNAV:return
#NO_ACS_INT
SUBCMD=4:sys COMNAV:LBYTE= HBYTE and &HFB
HBYTE=00:SUBCMD=2:sys COMNAV:return
#ACS_INT_200
SUBCMD=4:sys COMNAV:LBYTE= HBYTE or &H04
HBYTE=50:SUBCMD=2:sys COMNAV:return
#SUBSYS_PWR_ON
sdio=on:sclio=on:strobe=off:EXTPORT=(EXTPORT and &HFE)or 8
sys SYSTEM:return
#SUBSYS_PWR_OFF
EXTPORT=(EXTPORT and &HF7)or 1:sys SYSTEM
deact sdio:deact sclio:return
#CLR_DISTANCE
SUBCMD=3:sys COMNAV:return
#L_DISTANCE
SUBCMD=6:sys COMNAV:return
#R_DISTANCE
SUBCMD=7:sys COMNAV:return
'----- GERÄTETREIBER ------
'syscode "p5driv.s19"
Und die S19, die unveränderte P5driv.s19:
Code:
S1130101190116A5811B0118A581180117A5811ACA
S11301110119A581ADF920E8ADF020E9ADE720E0B2
S1130121ADED20E6A604B7A3AD29B6A5A4F8BAA1FE
S1130131B7A581A608BE0B2004A607BE0ABFA1B7B6
S1130141A220063FA2B6A5B7A1B6A14939A2493951
S1130151A23FA39BAD54AD38AE0C5A26FDB6A3CD38
S1130161017FB6A2CD017FB6A1CD017F1105130593
S1130171CD0198B7A2CD0198B7A1AD149A815F13AF
S1130181014411012402100112015CA30826F0812B
S1130191130112051005815F0201FD440301FD01F4
S11301A10102AA805CA30826EF81ADE41201AE0A24
S11301B15A26FD1305AE0A0201055A26FA20EB025E
S11301C101FD81A60CB70C81AE0839A411012402EA
S11301D11001150114015A26F139A41601170181E0
S11301E1AD1214A41CA520E0AD0A12A41AA520D8AE
S11001F1AD0220D415A413A41DA51BA581E7
S9030000FC
Auf der mitgelieferten cd hab ich nur Beispiele zum Empfangen von rc5 Signalen gefunden, aber nüx um damit einen Fernseher oderso zu Steuern.
Lesezeichen