Hallo zusammen.
Seit einiger Zeit habe ich die 8x8 LED Matix mit dem Max1219 laufen.
(Danke nochmals an tschoeatsch)
Jetzt gibt es eine 8x8 Matrix WS2812 für ca 2 Euro pro Panel.
Davon habe ich gestern gleich drei zusammengelötet und lasse mir die Einspeisung(grün) meines Balkonkraftwerkes und den Strombezug(rot) anzeigen.
Der Code ist etwas zusammengewürfelt, funktioniert aber gut.
Der ATmega muss mit 16MHz getraktet sein, sonst stimmen die Timings nicht.
An der Ausgabe vom "Bildspeicher" sollte möglichst nichts verändert werden.
Display All
Seit einiger Zeit habe ich die 8x8 LED Matix mit dem Max1219 laufen.
(Danke nochmals an tschoeatsch)
Jetzt gibt es eine 8x8 Matrix WS2812 für ca 2 Euro pro Panel.
Davon habe ich gestern gleich drei zusammengelötet und lasse mir die Einspeisung(grün) meines Balkonkraftwerkes und den Strombezug(rot) anzeigen.
Der Code ist etwas zusammengewürfelt, funktioniert aber gut.
Der ATmega muss mit 16MHz getraktet sein, sonst stimmen die Timings nicht.
An der Ausgabe vom "Bildspeicher" sollte möglichst nichts verändert werden.
Source Code
- $regfile = "m328pdef.dat"
- $crystal = 16000000
- $hwstack = 32
- $swstack = 32
- $framesize = 32
- Const Anzahl_module = 3
- Const Anzahl_spalten = Anzahl_module * 8
- Dim Display_array(anzahl_spalten) As Byte '8 Spalten für jedes Modul
- Dim Temp As Byte , Temp1 As Byte
- Dim Modul As Byte
- Dim Spalte As Word
- Dim Zeile As Byte , Bit_nr As Byte
- Dim Loesch As Byte
- Dim Display_daten As Byte , Display_digit As Byte
- Dim Spalten_nummer As Word , X As Word
- Dim Test As String * 6
- Dim M As Dword
- Dim Z As Byte
- Dim Posled As Integer
- Declare Sub Schreiben(byval Ausgabetext As String , Byval Farbe As Byte , Byval Helligkeit As Byte)
- Dim Zahler_farbe As Byte
- Dim Helligkeit As Byte
- Const N_led = 64 * Anzahl_module
- Dim N As Integer
- Dim G(n_led) As Byte 'Grün-Anteil
- Dim R(n_led) As Byte 'Rot-Anteil
- Dim B(n_led) As Byte 'Blau-Anteil
- Dim Zaehler As Integer
- Config Pinb.2 = Output
- Reset Portb.2 'T_RST = Lo = RESET = 10000 ns
- Waitus 10
- Do
- Incr Zaehler
- If Zaehler = 9999 Then
- Zaehler = 0
- End If
- ' Incr Zahler_farbe
- ' If Zahler_farbe = 4 Then
- ' Zahler_farbe = 1
- ' End If
- ' Incr Helligkeit
- ' If Helligkeit = 255 Then
- ' Helligkeit = 1
- ' End If
- Test = Str(zaehler)
- ' Call Schreiben(test , Zahler_farbe , Helligkeit)
- Call Schreiben(test , 2 , 10)
- Waitms 100
- Loop
- Sub Schreiben(ausgabetext As String , Farbe As Byte , Helligkeit As Byte)
- Local Lang As Byte
- Local Count As Byte
- Local Text As String * 1
- Local Tabelleneinsprung As Word
- Posled = 1
- Lang = Len(ausgabetext)
- Spalten_nummer = 1
- For Count = 1 To Lang 'nacheinander die einzelnen Buchstaben durchgehen
- Text = Mid(ausgabetext , Count , 1) 'Einzelbuchstaben herauspicken
- Tabelleneinsprung = Asc(text) 'Tabelle berechnen minus 32 zeichen.
- Select Case Text
- Case "Ä" : Tabelleneinsprung = &H8E
- Case "Ö" : Tabelleneinsprung = &H99
- Case "Ü" : Tabelleneinsprung = &H9A
- Case "ä" : Tabelleneinsprung = &H84
- Case "ü" : Tabelleneinsprung = &H81
- Case "ö" : Tabelleneinsprung = &H94
- Case "ß" : Tabelleneinsprung = &HE1
- End Select
- Tabelleneinsprung = Tabelleneinsprung - 32
- Tabelleneinsprung = Tabelleneinsprung * 6
- For X = 1 To 6 'das bitmuster spaltenweise in den Speicher schreiben (6 Spalten)
- Display_array(spalten_nummer) = Lookup(tabelleneinsprung , Font_6x8)
- Incr Spalten_nummer : Incr Tabelleneinsprung
- For N = 7 To 0 Step -1
- If Display_array(spalten_nummer).n = 1 And Farbe = 1 Then
- G(posled) = 0
- R(posled) = Helligkeit
- B(posled) = 0
- End If
- If Display_array(spalten_nummer).n = 1 And Farbe = 2 Then
- G(posled) = Helligkeit
- R(posled) = 0
- B(posled) = 0
- End If
- If Display_array(spalten_nummer).n = 1 And Farbe = 3 Then
- G(posled) = 0
- R(posled) = 0
- B(posled) = Helligkeit
- End If
- If Display_array(spalten_nummer).n = 0 Then
- G(posled) = 0
- R(posled) = 0
- B(posled) = 0
- End If
- Incr Posled
- Next N
- Next X
- Next Count
- '__________________________________________________________LED-Array RESET erzeugen:
- Reset Portb.2 'T_RST = Lo = RESET = 10000 ns
- Waitus 30
- '__________________________________________________Das ganze LED-Array mit den neuen Farben beschreiben:
- For N = 1 To N_led
- If G(n).7 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).6 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).5 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).4 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).3 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).2 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).1 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If G(n).0 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).7 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).6 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).5 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).4 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).3 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).2 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).1 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If R(n).0 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).7 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).6 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).5 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).4 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).3 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).2 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).1 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- If B(n).0 = 0 Then : Set Portb.2 : Nop : Nop : Nop : Nop : Reset Portb.2
- Else : Set Portb.2 : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Nop : Reset Portb.2 : End If
- Next N
- End Sub