Hi, everybody!
I ask to help with finishing of a code.
This code to me was provided by Mike Tschoeatsch.
Now he probably is busy, I ask somebody to help me.
2 matrixes (red-green) connect. The code works perfectly.
I corrected a code for 3 matrixes, and I don't understand where an error. The matrix doesn't work.
Thanks in advance!
Alles anzeigen
Operation of 2 led matrixes: VIDEO
Operation of 3 led matrixes: VIDEO
I ask to help with finishing of a code.
This code to me was provided by Mike Tschoeatsch.
Now he probably is busy, I ask somebody to help me.
2 matrixes (red-green) connect. The code works perfectly.
I corrected a code for 3 matrixes, and I don't understand where an error. The matrix doesn't work.
Thanks in advance!
BASCOM-Quellcode
- $regfile = "m128def.dat"
- $crystal = 12000000 : $hwstack = 80 : $swstack = 80 : $framesize = 80
- Ddrb = &B01001110
- Ddre = &B00010111
- Ddrf = &B00000011
- Shift_clock Alias Portb.1
- D_green Alias Portb.2
- D_red Alias Portb.3
- Port_write Alias Porte.4
- B Alias Portf.0
- A Alias Portf.1
- Config Base = 0
- 'timer for multiplex
- Const Timer2reload = 26
- Config Timer2 = Timer , Prescale = 1024
- Load Timer2 , Timer2reload
- On Ovf2 Display_refresh
- Enable Ovf2
- Start Timer2
- 'PWM ************************************************** *************************
- Config Timer1 = Pwm , Pwm = 8 , Compare B Pwm = Clear Up , Prescale = 1
- '************************************************* ******************************
- Dim Memory_red(192) As Byte , Memory_green(192) As Byte 'memory red/green
- Dim Memory_invisible(192)as Byte 'memory invisible
- Dim Temp_m_r As Byte , Temp_m_g As Byte 'temp memory red/green
- Dim Page_counter As Byte
- Dim C_1 As Byte , D_1 As Byte 'counter in isr
- Dim Character_column As Byte
- Dim Font_byte As Byte
- Dim N_1 As Byte , N_11 As Byte , N_12 As Byte , N_13 As Byte 'counter
- Dim M_1 As Byte , M_2 As Byte , M_22 As Byte
- Dim Sign As String * 1
- Dim Tab_start As Word 'Startwert der Fonttabelle
- Dim X1 As Word
- Dim Inverting As Bit
- Dim Speed As Word
- Dim Text As String * 254
- Dim Trigger As Bit
- Dim Display_on As Bit
- Dim N As Byte 'counterin main
- Dim Inv1 As Bit , Inv As Bit
- Dim Color As Byte , Red As Byte , Green As Byte , Orange As Byte , Invisible As Byte
- Dim Brightness As Byte , Ascii_sign As Byte
- Red = 1 : Green = 2 : Orange = 3 : Invisible = 4
- '**************************************************
- 'user settings
- Inverting = 0
- '**************************************************
- '$sim
- Brightness = 0 'max brightness
- Gosub Clear_memory
- Enable Interrupts
- Do
- Speed = 8
- Color = Red
- Text = "012345678 "
- Gosub Scroll_text_16
- Waitms 100
- Loop
- End
- Shift_left: 'shift the display one column to left
- Inv1 = Inverting Xor Inv
- Trigger = 0
- Bitwait Trigger , Set 'wait untill isr is done
- For N_1 = 0 To 15 'number of row
- N_11 = N_1 + 0
- For N_13 = 1 To 7 'number of column
- Shift Memory_red(n_11) , Right , 1 'shift all bits to left
- N_12 = N_11 + 16
- Memory_red(n_11).7 = Memory_red(n_12).0 'copy left bit of the byte in the right
- N_11 = N_11 + 16
- Next N_13
- Shift Memory_red(n_12) , Right , 1 'last column
- Memory_red(n_12).7 = Inv1
- Next N_1
- Return
- Scroll_text_16:
- Inv1 = Inverting Xor Inv
- For M_1 = 1 To Len(text)
- Sign = Mid(text , M_1 , 1) 'Only one letter
- Tab_start = Asc(sign)
- Tab_start = Tab_start - 32
- Tab_start = Tab_start * 24 'Starting point in the font table
- For Character_column = 0 To 24 Step 2
- Gosub Shift_left
- X1 = Tab_start + Character_column
- Font_byte = Lookup(x1 , Font_12x16)
- For M_2 = 0 To 7
- M_22 = 176 + M_2 'last column, upper byte 112 - 2 display, 176 - 3 display
- Gosub Set_bit
- Next M_2
- X1 = X1 + 1
- Font_byte = Lookup(x1 , Font_12x16)
- For M_2 = 0 To 7
- M_22 = 184 + M_2 'last column, 8 byte under upper byte 120 - 2 display, 184 - 3 display
- Gosub Set_bit
- Next M_2
- Waitms Speed
- Next Character_column
- Next M_1
- Return
- Loads:
- Pwm1b = 255 'switch all leds off
- For D_1 = 1 To 48 '48 bytes are to send 3 display
- Read C_1
- D_red = Memory_red(c_1).0 : D_green = Memory_green(c_1).0 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).1 : D_green = Memory_green(c_1).1 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).2 : D_green = Memory_green(c_1).2 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).3 : D_green = Memory_green(c_1).3 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).4 : D_green = Memory_green(c_1).4 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).5 : D_green = Memory_green(c_1).5 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).6 : D_green = Memory_green(c_1).6 : Shift_clock = 1 : Shift_clock = 0
- D_red = Memory_red(c_1).7 : D_green = Memory_green(c_1).7 : Shift_clock = 1 : Shift_clock = 0
- Next D_1
- Port_write = 1
- Return
- Byte_order_0: '48 bytes
- Data 3 , 7 , 19 , 23 , 11 , 15 , 27 , 31 , 35 , 39 , 51 , 55 , 43 , 47 , 59 , 63
- Data 67 , 71 , 83 , 87 , 75 , 79 , 91 , 95 , 99 , 103 , 115 , 119 , 107 , 111 , 123 , 127
- Data 131 , 135 , 147 , 151 , 139 , 143 , 155 , 159 , 163 , 167 , 179 , 183 , 171 , 175 , 187 , 191
- Byte_order_1:
- Data 2 , 6 , 18 , 22 , 10 , 14 , 26 , 30 , 34 , 38 , 50 , 54 , 42 , 46 , 58 , 62
- Data 66 , 70 , 82 , 86 , 74 , 78 , 90 , 94 , 98 , 102 , 114 , 118 , 106 , 110 , 122 , 126
- Data 130 , 134 , 146 , 150 , 138 , 142 , 154 , 158 , 162 , 166 , 178 , 182 , 170 , 174 , 186 , 190
- Byte_order_2:
- Data 1 , 5 , 17 , 21 , 9 , 13 , 25 , 29 , 33 , 37 , 49 , 53 , 41 , 45 , 57 , 61
- Data 65 , 69 , 81 , 85 , 73 , 77 , 89 , 93 , 97 , 101 , 113 , 117 , 105 , 109 , 121 , 125
- Data 129 , 133 , 145 , 149 , 137 , 141 , 153 , 157 , 161 , 165 , 177 , 181 , 169 , 173 , 185 , 189
- Byte_order_3:
- Data 0 , 4 , 16 , 20 , 8 , 12 , 24 , 28 , 32 , 36 , 48 , 52 , 40 , 44 , 56 , 60
- Data 64 , 68 , 80 , 84 , 72 , 76 , 88 , 92 , 96 , 100 , 112 , 116 , 104 , 108 , 120 , 124
- Data 128 , 132 , 144 , 148 , 136 , 140 , 152 , 156 , 160 , 164 , 176 , 180 , 168 , 172 , 184 , 188
- Set_bit:
- If Color.2 = 1 Then 'invisible
- If Inv1 = 1 Then Memory_invisible(m_22).7 = Not Font_byte.m_2 Else Memory_invisible(m_22).7 = Font_byte.m_2
- Else
- 'write to memory only when color is red or green
- If Color.0 = 1 Then 'red
- If Inv1 = 1 Then Memory_red(m_22).7 = Not Font_byte.m_2 Else Memory_red(m_22).7 = Font_byte.m_2
- Else
- Memory_red(m_22).7 = Inverting
- End If
- End If
- Return
- 'Interrupt service
- Display_refresh: 'show the memory on the display
- Load Timer2 , Timer2reload
- Incr Page_counter
- If Page_counter > 3 Then Page_counter = 0
- Select Case Page_counter
- Case 0:
- Restore Byte_order_0
- Gosub Loads
- A = 0 : B = 0
- Port_write = 0
- Pwm1b = Brightness 'max brightness switch all leds on
- Case 1:
- Restore Byte_order_1
- Gosub Loads
- A = 1 : B = 0
- Port_write = 0
- Pwm1b = Brightness 'max brightness switch all leds on
- Case 2:
- Restore Byte_order_2
- Gosub Loads
- A = 0 : B = 1
- Port_write = 0
- Pwm1b = Brightness 'max brightness switch all leds on
- Case 3:
- Restore Byte_order_3
- Gosub Loads
- A = 1 : B = 1
- Port_write = 0
- Pwm1b = Brightness 'max brightness switch all leds on
- End Select
- Trigger = 1
- Return
- Clear_memory:
- For N_1 = 0 To 191
- Memory_red(n_1) = 0
- Memory_green(n_1) = 0
- Memory_invisible(n_1) = 0
- Next N_1
- Return
Operation of 3 led matrixes: VIDEO