Hier ist meine funktionierende Firmware für den Cube. Der Code wurde mit Bascom / Ponyprog auf den AVR gespeichert.
$regfile = "m32def.dat" 'AVR Chip configuration
$crystal = 16000000 'AVR soll auf 16MHz laufen
Baud = 28800 'Serielle Schnittstelle auf 28.800 Baud setzen
Config Porta = Output 'Kanäle auf Output setzen
Config Portb = Output
Config Portc = Output
Declare Sub Activate_led(byval Led As String)
Declare Sub Demomovie(byval Demo As String , Byval D_speed As String )
Dim Eingabe As String * 364
Dim I As Integer
Dim Leds(64) As String * 3
Dim Count As Integer
Dim Typsetzer As Byte 'typ 0 = led, 1 = speed, 2 = demo
Dim Waiter As Integer
Dim Speed As String * 3
Dim Schnitt As String * 1
Dim Movie As String * 1
Do
Input Eingabe 'Texteingabe für die Darstellung erwarten
If Left(eingabe , 1) = "a" And Right(eingabe , 1) = "z" Then
'Variablen zur¸cksetzen start
Speed = ""
Waiter = 0
Typsetzer = 0
For I = 0 To Count
Leds(i) = ""
Next I
Count = 0
Movie = ""
'Variablen zur¸cksetzen ende
For I = 0 To Len(eingabe) Step 1
Schnitt = Mid(eingabe , I , 1)
Select Case Schnitt
Case "x"
Typsetzer = 0 'auf led setzen
Count = Count + 1
Case "a"
'Typsetzer = 0 'auf led setzen
Case "m"
Typsetzer = 2 'auf demo setzen
Case "s"
Typsetzer = 1 'auf speed setzen
Case "z"
'Typsetzer = 0 'auf led setzen
Exit For
Case Else
If Typsetzer = 1 Then 'wenn speed dann
Speed = Speed + Mid(eingabe , I , 1)
Elseif Typsetzer = 2 Then
Movie = Movie + Mid(eingabe , I , 1)
Else 'wenn led dann
Leds(count) = Leds(count) + Mid(eingabe , I , 1)
End If
End Select
Next I
End If
Waiter = Val(speed)
If Waiter < 1 Then
Waiter = 1
End If
While Ischarwaiting() = 0
If Len(movie) > 0 Then
Call Demomovie(movie , Speed)
Else
For I = 0 To Count Step 1
If Len(leds(i)) > 0 Then
Call Activate_led(leds(i)) 'led anzeigen, 3 Zahlen ¸bergeben als string z.B.: 123
Waitms Waiter
End If
If 0 <> Ischarwaiting() Then
Exit For
Exit While
End If
Next I
End If
Wend
Porta = 0
Portb = 0
Portc = 0
Loop
Sub Activate_led(byval Led As String * 3)
Dim Istx_s As String * 1
Dim Istx As Byte
Dim Isty_s As String * 1
Dim Isty As Byte
Dim Istz_s As String * 1
Dim Istz As Byte
Porta = 0
Portb = 0
Portc = 0
Istx_s = Mid(led , 1 , 1) 'erste Ziffer auslesen
Istx = Val(istx_s) - 1
Isty_s = Mid(led , 2 , 1) 'zweite Ziffer auslesen
Isty = Val(isty_s) - 1
Istz_s = Mid(led , 3 , 1) 'dritte Ziffer auslesen
Istz = Val(istz_s) - 1
Porta.istx = 1
Portb.isty = 1
Portc.istz = 1
End Sub
'//// DEMOMOVIES ////////////////////////////////////////////////////////////////////
Sub Demomovie(byval Demo As String , Byval D_speed As String * 3)
Dim Demomovie As Integer
Demomovie = Val(demo)
Dim Demospeed As Integer
Demospeed = Val(d_speed)
Select Case Demomovie
Case 1
For I = 0 To 7
Porta = 0
Portb = 0
Portc = 0
Porta.i = 1
Portb.i = 1
Portc.i = 1
If 0 <> Ischarwaiting() Then
Exit For
Exit Function
Exit For
Exit While
End If
Waitms Demospeed
If 0 <> Ischarwaiting() Then
Exit For
Exit Function
Exit For
Exit While
End If
Next I
Case 2
Dim Demo2image(56) As String * 3
Demo2image(1) = "111"
Demo2image(2) = "222"
Demo2image(3) = "333"
Demo2image(4) = "444"
Demo2image(5) = "555"
Demo2image(6) = "666"
Demo2image(7) = "777"
Demo2image(8) = "888"
Demo2image(9) = "788"
Demo2image(10) = "688"
Demo2image(11) = "588"
Demo2image(12) = "488"
Demo2image(13) = "388"
Demo2image(14) = "288"
Demo2image(15) = "188"
Demo2image(16) = "277"
Demo2image(17) = "366"
Demo2image(18) = "455"
Demo2image(19) = "544"
Demo2image(20) = "633"
Demo2image(21) = "722"
Demo2image(22) = "811"
Demo2image(23) = "821"
Demo2image(24) = "831"
Demo2image(25) = "841"
Demo2image(26) = "851"
Demo2image(27) = "861"
Demo2image(28) = "871"
Demo2image(29) = "881"
Demo2image(30) = "772"
Demo2image(31) = "663"
Demo2image(32) = "554"
Demo2image(33) = "445"
Demo2image(34) = "336"
Demo2image(35) = "227"
Demo2image(36) = "118"
Demo2image(37) = "218"
Demo2image(38) = "318"
Demo2image(39) = "418"
Demo2image(40) = "518"
Demo2image(41) = "618"
Demo2image(42) = "718"
Demo2image(43) = "818"
Demo2image(44) = "727"
Demo2image(45) = "636"
Demo2image(46) = "545"
Demo2image(47) = "454"
Demo2image(48) = "363"
Demo2image(49) = "272"
Demo2image(50) = "181"
Demo2image(51) = "171"
Demo2image(52) = "161"
Demo2image(53) = "151"
Demo2image(54) = "141"
Demo2image(55) = "131"
Demo2image(56) = "121"
For I = 1 To 56
Call Activate_led(demo2image(i))
If 0 <> Ischarwaiting() Then
Exit For
Exit Function
Exit For
Exit While
End If
Waitms Demospeed
If 0 <> Ischarwaiting() Then
Exit For
Exit Function
Exit For
Exit While
End If
Next I
End Select
End Sub
--TM 22:49, 2. Dez. 2006 (CET)
End