سلام دوستان، وقت بخیر. برنامه ای دارم که به زبان bascom نوشته شده، میتونید این کد را به فضای codevision انتقال بدید(زبان basic را با C معادل کنید)؟ فایل txt برنامه به پیوست قرار داده شده. مبلغ انجام پروژه هم توافقی خواهد بود.
- - - Updated - - -
این هم کد برنامه(برنامه مربوط به یک گیرنده مادون قرمز هست):
$regfile = "m32def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = _
Pina.6 , Db7 = Pina.7 , Rs = Pina.2 , E = Pina.3
Config Lcd = 16 * 2
Config Pind.2 = Input
Config Timer0 = Timer , Prescale = 256
Config Int0 = Falling
Stop Timer0
Enable Timer0
Enable Int0
Config Timer1 = Timer , Prescale = 1024
Enable Ovf1 : On Ovf1 Refresh : Stop Timer1
Enable Interrupts
On Timer0 Tikers
On Int0 Infrared
Config Pind.2 = Input
Config Pind.3 = Input
Config Pind.6 = Input
Config Portc = Output
Config Pind.5 = Output
Config Pind.7 = Output
Green Alias Portc.1
Yel Alias Portc.0
Rly Alias Portd.5
Bl Alias Portc.2
Rly = 1
Dim Tik As Word
Dim Byt As Byte
Dim Repeat_flag As Bit
Dim Start_flag As Bit
Dim Address As Byte
Dim Command As Byte
Dim Address_1 As Byte
Dim Command_1 As Byte
Dim Address_0 As Byte
Dim Command_0 As Byte
Dim Summa As Word
Dim A As Byte , B As Byte , C As Byte , M As Byte , Z As Byte , Xz As Bit
Dim S As String * 5 , E As Byte
If Z = 1 Then : S = "AUT" : Else : S = "MAN" : End If
Cls
Cursor Off
'################################################# ##############################
Lcd " IR Receiver" : Wait 2 : Cls : Gosub On_off
Do
If Address > 0 Then
Locate 2 , 1 : Lcd "" ; Command : Lcd " "
If Xz = 1 Then : Gosub Read_command : End If
End If
' Waitms 10
Home : Locate 1 , 6 : Lcd "Mode=" ; S : Lcd " "
Locate 2 , 6 : Lcd "Time=" ; A : Lcd " "
Locate 2 , 15 : Lcd "" ; B
Loop
On_off:
Do
If Command = 162 Then : Toggle Xz
If Xz = 1 Then : Bl = 1 : Home : Cls : Lcd " ON " : Else
Cls : Lcd " Good By " : Stop Timer1 : Timer1 = 0 : Wait 2
A = 1 : Bl = 0 : Rly = 1 : Green = 0 : Yel = 0 : End If
Waitms 300
End If
Cursor Off
Loop Until Xz = 1
Return
Refresh:
Stop Timer1 : Incr B : If B > 9 Then : Decr A : B = 0 : End If
If A < 1 Then
Select Case Z
Case 1
A = 0 : B = 0 : Gosub Rly_off
Case 2
A = 0 : B = 0 : Gosub Rly_on
End Select
End If
If A => 1 Then : Timer1 = 18650 : Start Timer1 : End If
Return
Ok:
If Z = 1 Then : Timer1 = 18650 : Start Timer1 : Rly = 0 : End If
If Z = 2 Then : Timer1 = 18650 : Start Timer1 : Rly = 1 : End If
Return
Man_aut:
Incr Z : If Z > 2 Then : Z = 0 : End If
Select Case Z
Case 1
S = "Off_T"
Case 2
S = "0n_T "
Case 0
S = "Man "
End Select
Waitms 300
Return
Read_command:
Select Case Command
Case 162
Gosub On_off
Case 168
Gosub Vol_up
Case 224
Gosub Vol_down
Case 144
Gosub Man_aut
Case 104
Gosub Ok
Case 194
Gosub Rly_on
Case 226
Gosub Rly_off
Case 2
Gosub Yel_led
Case 34
Gosub Green_led
End Select
Return
Vol_up:
Incr A : Waitms 120
If A > 120 Then : A = 120 : End If
Return
Vol_down:
Decr A : Waitms 120
If A < 1 Or A > 120 Then : A = 1 : End If
Return
Rly_on:
Select Case Z
Case 2
Stop Timer1 : Rly = 0
Case 1
Start Timer1
Case 0
Stop Timer1 : Rly = 0
End Select
' If Z = 1 Then : Start Timer1 : Else
' Stop Timer1 : Rly = 0 : End If
' If Z = 2 Then :
Waitms 300
Return
Rly_off:
Rly = 1
Waitms 300
Return
Green_led:
Toggle Green
Waitms 300
Return
Yel_led:
Toggle Yel
Waitms 300
Return
'################################################# ##############################
Tikers:
Timer0 = 253
Incr Tik
If Tik >= 1200 Then
Tik = 0
Repeat_flag = 0
Start_flag = 0
Address_1 = 0
Command_1 = 0
Address_0 = 0
Command_0 = 0
Address = 0
Command = 0
Stop Timer0
End If
Return
'################################################# ##############################
Infrared:
Start Timer0
If Tik >= 139 And Tik < 150 Then
Address = 1
Repeat_flag = 0
Start_flag = 1
Address_1 = 0
Command_1 = 0
Address_0 = 0
Command_0 = 0
End If
If Tik >= 116 And Tik < 139 Then
Address = 2
Repeat_flag = 1
Start_flag = 0
End If
If Tik >= 22 And Tik < 116 And Start_flag = 1 Then
Incr Byt
If Byt < 9 Then
Shift Address_1 , Left
Address_1 = Address_1 + 1
End If
If Byt >= 9 And Byt < 17 Then
Shift Address_0 , Left
Address_0 = Address_0 + 1
End If
If Byt >= 17 And Byt < 25 Then
Shift Command_1 , Left
Command_1 = Command_1 + 1
End If
If Byt >= 25 Then
Shift Command_0 , Left
Command_0 = Command_0 + 1
End If
End If
If Tik >= 10 And Tik < 22 And Start_flag = 1 Then
Incr Byt
If Byt < 9 Then
Shift Address_1 , Left
End If
If Byt >= 9 And Byt < 17 Then
Shift Address_0 , Left
End If
If Byt >= 17 And Byt < 25 Then
Shift Command_1 , Left
End If
If Byt >= 25 Then
Shift Command_0 , Left
End If
End If
Tik = 0
If Byt = 32 Then
Address = Address_1
Command = Command_1
Byt = 0
Repeat_flag = 0
Start_flag = 0
Stop Timer0
End If
Return
'################################################# #############################
End