; =================================================
; File....... RGB 8x8 LED Matrix Test
; Purpose.... test operation of the set of an 8x8 RGB LED matrix via i2c comms
; Author..... Westaust55
; E-mail.....
; Started.... 07-01-2009
; Updated.... DD-MM-YYYY
; ===============================================
;
; -----[ Program Description ]---------------------------------------------
;
; A program to test operation of the 8 x 8 matrix of RGB LEDs as a
; visual multicolour panel using i2c comms and MCP23017 IO Expanders
;
; -----[ Revision History ]------------------------------------------------
; First coding
;
;
; -----[ I/O Definitions ]-------------------------------------------------
;
;
; -----[ i2c Devices ]-------------------------------------------------------
;
;
; IO EXPANDERS
SYMBOL expand_0 = %01000000 ; %0100 = Chip ID, 000 = Addr 0 - For the 8 Red LED's
SYMBOL expand_1 = %01000010 ; , 001 = Addr 1 - For Keypad Shift LED
SYMBOL expand_6 = %01001100 ; , 110 = Addr 6 - For RGB LED matrix red and green
SYMBOL expand_7 = %01001110 ; , 111 = Addr 7 - For RGB LED matrix blue and common
;
;
; -----[ EEPROM Data ]-----------------------------------------------------
;
; dataset 1 = Red heart no other colours
EEPROM ($99,$FF,$FF,$01)
EEPROM ($00,$FF,$FF,$02)
EEPROM ($00,$FF,$FF,$04)
EEPROM ($81,$FF,$FF,$08)
EEPROM ($81,$FF,$FF,$10)
EEPROM ($C3,$FF,$FF,$20)
EEPROM ($C3,$FF,$FF,$40)
EEPROM ($E7,$FF,$FF,$80)
;
; dataset 2 = red heart with green surround
EEPROM ($99,$66,$FF,$01)
EEPROM ($00,$FF,$FF,$02)
EEPROM ($00,$FF,$FF,$04)
EEPROM ($81,$7E,$FF,$08)
EEPROM ($81,$7E,$FF,$10)
EEPROM ($C3,$3C,$FF,$20)
EEPROM ($C3,$3C,$FF,$40)
EEPROM ($E7,$18,$FF,$80)
;
; dataset 3 = red heart with blue surround
EEPROM ($99,$FF,$66,$01)
EEPROM ($00,$FF,$FF,$02)
EEPROM ($00,$FF,$FF,$04)
EEPROM ($81,$FF,$7E,$08)
EEPROM ($81,$FF,$7E,$10)
EEPROM ($C3,$FF,$3C,$20)
EEPROM ($C3,$FF,$3C,$40)
EEPROM ($E7,$FF,$18,$80)
;
; -----[ Initialization ]--------------------------------------------------
;
Init: setfreq m8
HI2CSETUP i2cmaster, expand_7, i2cslow, i2cbyte
HI2COUT [expand_6], 0, ($00,$00) 'IODIRA,IODIRB set port direction register to output
HI2COUT [expand_6], $12,(%11111111,%11111111) 'turn off Red & Green LEDs (output high)
HI2COUT [expand_7], 0, ($00,$00) 'IODIRA,IODIRB set port direction register to output
HI2COUT [expand_7], $12,(%00000000,%11111111) 'turn off Row dirve (low) andBlue LEDs (high)
;
;
; -----[ Program Code ]----------------------------------------------------
;
Main: HI2CSETUP i2cmaster, expand_1, i2cslow, i2cbyte ; Set up for 9th LED
HI2COUT (0) ; SHIFT LED off
PAUSE 500
HI2COUT (1) ; SHIFT LED on - just blink LED on and off
PAUSE 1000
HI2COUT (0) ; SHIFT LED off
PAUSE 500
HI2CSETUP i2cmaster, expand_0, i2cslow, i2cbyte ; Set up for set of 8 LEDs
HI2COUT (255) ; turn on all LEDs for 1.5 second
PAUSE 1500
HI2COUT (0)
pause 1000
; the above line of code are just to turn of the LED's for the bargraph and keypad shift key
; these LED's use positive logic (1 = ON, 0 = OFF) done by adding a transistor to the expander outputs.
;
;
REDheart:
FOR b2 = 1 TO 100
FOR b0 = 0 TO 7 ; for 8 rows of data (8 x 8 marix display used)
b1 = b0 * 4 ; set pointer for next 4 bytes
READ b1, b6, b7, b8, b9 ; Read each line of data to send to the display
GOSUB shwpattn ; now display the correct LED pattern
NEXT b0
NEXT b2
Greensur:
FOR b2 = 1 TO 100
FOR b0 = 0 TO 7 ; for 8 rows of data (8 x 8 marix display used)
b1 = b0 * 4 + 32 ; set pointer for next 4 bytes
READ b1, b6, b7, b8, b9 ; Read each line of data to send to the display
GOSUB shwpattn ; now display the correct LED pattern
NEXT b0
NEXT b2
Bluesur:
FOR b2 = 1 TO 100
FOR b0 = 0 TO 7 ; for 8 rows of data (8 x 8 marix display used)
b1 = b0 * 4 + 64 ; set pointer for next 4 bytes
READ b1, b6, b7, b8, b9 ; Read each line of data to send to the display
GOSUB shwpattn ; now display the correct LED pattern
NEXT b0
NEXT b2
finish:
HI2COUT [expand_7], $12,($00) ; turn off LED row drive
END
;
; -----[ Subroutines ]----------------------------
;
shwpattn: ; pattern for full circle on LED indicator
HI2COUT [expand_7], $12,($00) ; turn off LED row drive to prevent brief display of previous row on the new row of LED's
HI2COUT [expand_6], $12,(b7,b6) ; green and red columns
HI2COUT [expand_7], $12,(b9,b8) ; row drive and blue column
PAUSE 10
RETURN
;
; =================================================
; THE END
; =================================================