Hello!
On your forum I found code for controlling RGB matrices. Slightly redesigned to control the QiangLi Q6.6Eco matrices together with the Atmega2560 controller.
Collected a scoreboard in which 12 matrices. 2x6.
The problem is that the image does not appear immediately, but gradually. The image is gradually displayed from top to bottom. If I increase the value in the timer, the scoreboard starts flickering.
How do I get information out instantly?
Thank you in advance!
Display All
QiangLi Q6.6 test1
On your forum I found code for controlling RGB matrices. Slightly redesigned to control the QiangLi Q6.6Eco matrices together with the Atmega2560 controller.
Collected a scoreboard in which 12 matrices. 2x6.
The problem is that the image does not appear immediately, but gradually. The image is gradually displayed from top to bottom. If I increase the value in the timer, the scoreboard starts flickering.
How do I get information out instantly?
Thank you in advance!
Source Code
- $regfile = "m2560def.dat"
- $crystal = 16000000
- $hwstack = 80
- $swstack = 80
- $framesize = 80
- Const Scan = 6
- Const Row = 24
- Const Scan2 = 6
- Const Dy_num_h = 2
- Const Dy_num_v = 5
- Const Timer0reload = 48
- Config Timer0 = Timer , Prescale = 1024
- Load Timer0 , Timer0reload
- On Ovf0 Display_refresh
- Enable Ovf0
- Start Timer0
- 'PWM ************************************************** *************************
- Config Timer1 = Pwm , Pwm = 8 , Compare_b_pwm = Clear_down , Prescale = 1
- '************************************************* ******************************
- Const R_scan = Scan * Row
- Const Scan_1 = Scan * 2
- Const Scan_page = Scan - 1
- Const Bytes_in_row = Scan * Dy_num_h
- Const Row_num = Row * Dy_num_v
- Const Row_num1 = Row_num - 1
- Const Mem_size = Row_num * Bytes_in_row
- Const Mem_size_1 = Mem_size - 1
- Const Dy_offset = Dy_num_h * R_scan
- Const Channel_offset = Scan_1 * Bytes_in_row
- Const Mem_offset_1 = Scan * Bytes_in_row
- P_r1 Alias Porta.0 : Config P_r1 = Output
- P_g1 Alias Porta.1 : Config P_g1 = Output
- P_b1 Alias Porta.2 : Config P_b1 = Output
- P_r2 Alias Porta.3 : Config P_r2 = Output
- P_g2 Alias Porta.4 : Config P_g2 = Output
- P_b2 Alias Porta.5 : Config P_b2 = Output
- Dout_port Alias Porta
- Const Dout_pin_r1 = Pa0
- Const Dout_pin_g1 = Pa1
- Const Dout_pin_b1 = Pa2
- Const Dout_pin_r2 = Pa3
- Const Dout_pin_g2 = Pa4
- Const Dout_pin_b2 = Pa5
- P_a Alias Porte.5 : Config P_a = Output
- P_b Alias Porte.4 : Config P_b = Output
- P_c Alias Porte.3 : Config P_c = Output
- P_d Alias Portb.7 : Config P_d = Output
- P_ckl Alias Portc.6 : Config P_ckl = Output
- Shift_clock_port Alias Portc : Const Shift_clock_pin = Pc6
- P_lat Alias Porth.4 : Config P_lat = Output
- P_oe Alias Portb.6 : Config P_oe = Output
- '***
- Config Base = 0
- Declare Sub Shift6out(byreg R18 As Byte , Byreg R19 As Byte , Byreg R20 As Byte , Byreg R21 As Byte , Byreg R22 As Byte , Byreg R23 As Byte )
- Declare Sub Txt_6_8(byval X As Word , Byval Y As Word , Byval Color As Byte)
- Dim Memory_red(mem_size) , Memory_green(mem_size) , Memory_blue(mem_size) As Byte
- Dim Brightness , Red , Green , Blue , Yellow , Magenta , Cyan , White , Page_counter , Z_0 , Z_1 As Byte
- Red = 1 : Green = 2 : Yellow = 3 : Blue = 4 : Magenta = 5 : Cyan = 6 : White = 7
- Dim N_1 , Tab_start , Page_offset , B_1 , St_byte_1 , St_byte_2 , St_byte_3 , St_byte_4 As Word
- Dim Text As String * 50
- Dim F , S As Byte
- Enable Interrupts
- Gosub Clear_memory
- Brightness = 255
- Text = "1234567890ABCDEF"
- S = 1
- For F = 0 To 112 Step 8
- Call Txt_6_8(0 , F , S)
- S = S + 1
- If S = 8 Then S = 1
- Next
- Do
- Loop
- End
- Display_refresh:
- Load Timer0 , Timer0reload
- Incr Page_counter
- If Page_counter > Scan_page Then
- Page_counter = 0
- P_c = 1
- End If
- Page_offset = Page_counter * Bytes_in_row
- For Z_0 = 1 To Dy_num_v
- St_byte_1 = Mem_offset_1 + Page_offset : St_byte_2 = Page_offset
- St_byte_3 = St_byte_1 + Channel_offset : St_byte_4 = St_byte_2 + Channel_offset
- For Z_1 = 1 To Dy_num_h
- For B_1 = 1 To Scan2
- Shift6out Memory_red(st_byte_1) , Memory_green(st_byte_1) , Memory_blue(st_byte_1) , Memory_red(st_byte_3) , Memory_green(st_byte_3) , Memory_blue(st_byte_3)
- Incr St_byte_1 : Incr St_byte_3
- Next B_1
- For B_1 = 1 To Scan2
- Shift6out Memory_red(st_byte_2) , Memory_green(st_byte_2) , Memory_blue(st_byte_2) , Memory_red(st_byte_4) , Memory_green(st_byte_4) , Memory_blue(st_byte_4)
- Incr St_byte_2 : Incr St_byte_4
- Next B_1
- Next Z_1
- Page_offset = Page_offset + Dy_offset
- Next Z_0
- Pwm1b = 0
- Waitus 40
- P_lat = 1 : P_lat = 0
- P_a = 1 : P_a = 0
- P_c = 0
- Pwm1b = Brightness
- Return
- Sub Shift6out(byreg R18 As Byte , Byreg R19 As Byte , Byreg R20 As Byte , Byreg R21 As Byte , Byreg R22 As Byte , Byreg R23 As Byte)
- $asm
- LDI r17,8
- Loop_shift2out:
- in R16, dout_port
- BST r18,7
- BLD r16,Dout_pin_r1
- BST r19,7
- bld r16,Dout_pin_g1
- BST r20,7
- bld r16,Dout_pin_b1
- BST r21,7
- BLD r16,Dout_pin_r2
- BST r22,7
- bld r16,Dout_pin_g2
- BST r23,7
- bld r16,Dout_pin_b2
- LSl r18
- LSl r19
- lsl r20
- lsl r21
- lsl r22
- lsl r23
- Out Dout_port , R16
- SBI shift_clock_Port, shift_clock_Pin
- dec r17
- CBI shift_clock_Port, shift_clock_Pin
- BRnE loop_shift2out
- $end Asm
- End Sub
- Clear_memory:
- For N_1 = 0 To Mem_size_1
- Memory_red(n_1) = 0
- Memory_green(n_1) = 0
- Memory_blue(n_1) = 0
- Next N_1
- Return
- Sub Txt_6_8(byval X As Word , Byval Y As Word , Byval Color As Byte)
- Local Col As Word , Mem_byte_num As Word , Max_baseline As Byte , Y1 As Word , X1 As Word
- Local Character_column As Byte , Letter_num As Byte , Sign As String * 1 , Bit_num As Byte
- Local Font_byte As Byte , Bit_counter As Byte
- Max_baseline = Row_num - 8
- If Y > Max_baseline Then Y = Max_baseline
- Y1 = Row_num1 - Y 'y1 counts from upper row
- For Letter_num = 1 To Len(text)
- Sign = Mid(text , Letter_num , 1) 'Only one letter
- Tab_start = Asc(sign)
- Tab_start = Tab_start - 32
- Tab_start = Tab_start * 6 'Starting point in the font table
- For Character_column = 0 To 5
- Bit_num = X Mod 8 : Bit_num = 7 -bit_num 'bit-number of byte
- Col = X / 8 'number of byte-column
- Mem_byte_num = Y1 * Bytes_in_row
- Mem_byte_num = Mem_byte_num + Col
- If Mem_byte_num > Mem_size_1 Then Exit Sub 'there is no space, you are ready
- X1 = Tab_start + Character_column
- Font_byte = Lookup(x1 , Font_6x8)
- For Bit_counter = 0 To 7
- If Color.0 = 1 Then Memory_red(mem_byte_num).bit_num = Font_byte.bit_counter
- If Color.1 = 1 Then Memory_green(mem_byte_num).bit_num = Font_byte.bit_counter
- If Color.2 = 1 Then Memory_blue(mem_byte_num).bit_num = Font_byte.bit_counter
- Mem_byte_num = Mem_byte_num - Bytes_in_row 'jump one row up
- Next Bit_counter
- Incr X
- Next Character_column
- Next Letter_num
- End Sub
- Font_6x8:
- Data 0 , 0 , 0 , 0 , 0 , 0 ' <SPACE>
- Data 0 , 0 , 96 , 250 , 96 , 0 ' !
- Data 0 , 224 , 192 , 0 , 224 , 192 ' "
- Data 0 , 48 , 72 , 72 , 48 , 0 ' #
- Data 60 , 66 , 153 , 36 , 66 , 24 ' $
- Data 24 , 66 , 36 , 153 , 66 , 60 ' %
- Data 0 , 16 , 84 , 84 , 56 , 16 ' &
- Data 0 , 0 , 224 , 192 , 0 , 0 ' <ZAP>
- Data 48 , 96 , 255 , 255 , 96 , 48 ' (
- Data 12 , 6 , 255 , 255 , 6 , 12 ' )
- Data 8 , 42 , 28 , 28 , 42 , 8 ' *
- Data 8 , 8 , 62 , 8 , 8 , 0 ' +
- Data 0 , 0 , 7 , 6 , 0 , 0 ' ,
- Data 8 , 8 , 8 , 8 , 8 , 0 ' -
- Data 0 , 0 , 3 , 3 , 0 , 0 ' .
- Data 2 , 4 , 8 , 16 , 32 , 64 ' /
- Data 62 , 69 , 73 , 81 , 62 , 0 ' 0
- Data 0 , 33 , 127 , 1 , 0 , 0 ' 1
- Data 35 , 69 , 73 , 73 , 49 , 0 ' 2
- Data 34 , 73 , 73 , 73 , 54 , 0 ' 3
- Data 12 , 20 , 36 , 127 , 4 , 0 ' 4
- Data 114 , 81 , 81 , 81 , 78 , 0 ' 5
- Data 30 , 41 , 73 , 73 , 6 , 0 ' 6
- Data 96 , 71 , 72 , 80 , 96 , 0 ' 7
- Data 54 , 73 , 73 , 73 , 54 , 0 ' 8
- Data 48 , 73 , 73 , 74 , 60 , 0 ' 9
- Data 0 , 0 , 54 , 54 , 0 , 0 ' :
- Data 0 , 0 , 55 , 54 , 0 , 0 ' ;
- Data 8 , 20 , 34 , 65 , 0 , 0 ' <
- Data 36 , 36 , 36 , 36 , 36 , 0 ' =
- Data 0 , 65 , 34 , 20 , 8 , 0 ' >
- Data 32 , 64 , 77 , 72 , 48 , 0 ' ?
- Data 62 , 65 , 93 , 85 , 60 , 0 ' @
- Data 63 , 68 , 68 , 68 , 63 , 0 ' A
- Data 127 , 73 , 73 , 73 , 54 , 0 ' B
- Data 62 , 65 , 65 , 65 , 34 , 0 ' C
- Data 127 , 65 , 65 , 65 , 62 , 0 ' D
- Data 127 , 73 , 73 , 73 , 65 , 0 ' E
- Data 127 , 72 , 72 , 72 , 64 , 0 ' F
QiangLi Q6.6 test1
The post was edited 1 time, last by Raimond Longer ().