; =================================================
; File....... 40X2 3xWS2803
; Purpose.... An untested demo program to show control of a three WS2803 RGB LED drivers
; Author..... Westaust55
; E-mail.....
; Started.... 13-05-2013
; Updated.... DD-MM-YYYY
; =================================================
;
; -----[ Program Description ]---------------------------------------------
; A program to to demonstrate the control of a short string of three WS2803 RGB LED driver chips
;
; -----[ Revision History ]---------------------------------------------------
;
; A = 13-05-2013 First release total program size = 232 bytes
; =================================================
;Modified by Johnhr 14-05-2013 for the 40X2
PATTERN2:
; -----[ Program Code ]----------------------------------------------------
Main2:
DO
WhichIsRed = LED_Index // No_LEDs ; for each loop of the program, this defines a new value 0 to 17 for the 18 RGB LED's. That LED is Red and all others are off
ptr = 0 ; set pointer to first scratchpad location for next datasets
For Counter = 1 TO No_LEDs
IF Counter = WhichIsRed THEN
MemAddr = Red
ELSE
MemAddr = Black
ENDIF
GOSUB FetchColour2 ; Fetch Colour definition from EEPROM and save in next scratchpad location
NEXT Counter
GOSUB SendData2 ; call subroutine to transfer all data to the WS2803 string
PAUSE SeqStep_Delay ; delay to give user time to see the new colour pattern
LED_Index = LED_Index + 1 // 252 ; any multiple of 18 will work if we let counter get to 255 and roll over to 0 then display will "jump"
LOOP ; loop forever
;
; -----[ Subroutines ]-----------------------------------------------------
;
; ***** Subroutine to fetch the data from EEPROM and save into Scratchpad for one RGB LED colour
FetchColour2:
READ MemAddr, LED_Data ; Fetch the Red component of the specified colour
@PtrInc = LED_Data ; save into the scratchpad RAM at required location
INC MemAddr
READ MemAddr, LED_Data ; Fetch the Green component of the specified colour
@PtrInc = LED_Data
INC MemAddr
READ MemAddr, LED_Data ; Fetch the Blue component of the specified colour
@PtrInc = LED_Data
RETURN ; Return after the RGB data for one RGB LED (3 channels) has been placed into the Scratchpad
;
; Subroutine to serially clock out the data through the WS2803 chips for THREE RGB LEDs
; NOTE this is limited to three WS2803 chips without adding more variables/field to the SHIFTOUT command
SendData2:
Ptr = 0
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of first WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of second WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of third WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
RETURN
INC b12
GOTO MAIN
; =================================================
; File....... 40X2 3xWS2803
; Purpose.... An untested demo program to show control of a three WS2803 RGB LED drivers
; Author..... Westaust55
; E-mail.....
; Started.... 13-05-2013
; Updated.... DD-MM-YYYY
; =================================================
;
; -----[ Program Description ]---------------------------------------------
; A program to to demonstrate the control of a short string of three WS2803 RGB LED driver chips
;
; -----[ Revision History ]---------------------------------------------------
;
; A = 13-05-2013 First release total program size = 232 bytes
; =================================================
;Modified by John 14-05-2013 for the 40X2
;
; changed Digital Output Pins
; played with Constants
; added 12 SYMBOLs
; added 12 EEPROMs
; changed a little MAIN code
;
;==================================================
; Define EEPROM locations for some colour data - expand the data and pointer list to suit
'SYMBOL Red1 = $00
'SYMBOL Green1 = $03
'SYMBOL Blue1 = $06
'SYMBOL Red2 = $09
'SYMBOL Green2 = $0C
'SYMBOL Blue2 = $0F
'SYMBOL Red3 = $12
'SYMBOL Green3 = $15
SYMBOL Blue3 = $18
SYMBOL Red4 = $1B
SYMBOL Green4 = $1E
SYMBOL Blue4 = $B4
SYMBOL Red5 = $24
SYMBOL Green5 = $27
SYMBOL Blue5 = $2A
SYMBOL Red6 = $2D
SYMBOL Green6 = $30
SYMBOL Blue6 = $33
; Define some colours with 3 Bytes per colour at quarter intensity - $FF for max intensity
'EEPROM $00, ($3F, $00, $00) ; Red1
'EEPROM $03, ($00, $3F, $00) ; Green1
'EEPROM $06, ($00, $00, $3F) ; Blue1
'EEPROM $09, ($3F, $00, $00) ; Red2
'EEPROM $0C, ($00, $3F, $00) ; Green2
'EEPROM $0F, ($00, $00, $3F) ; Blue2
'EEPROM $12, ($3F, $00, $00) ; Red3
'EEPROM $15, ($00, $3F, $00) ; Green3
EEPROM $18, ($00, $00, $3F) ; Blue3
EEPROM $1B, ($3F, $00, $00) ; Red4
EEPROM $1E, ($00, $3F, $00) ; Green4
EEPROM $21, ($00, $00, $3F) ; Blue4
EEPROM $24, ($3F, $00, $00) ; Red5
EEPROM $27, ($00, $3F, $00) ; Green5
EEPROM $2A, ($00, $00, $3F) ; Blue5
EEPROM $2D, ($3F, $00, $00) ; Red6
EEPROM $30, ($00, $3F, $00) ; Green6
EEPROM $33, ($00, $00, $3F) ; Blue6
PATTERN3:
; -----[ Program Code ]----------------------------------------------------
Main3:
DO
WhichIsRed = LED_Index // No_LEDs ; for each loop of the program, this defines a new value 0 to 17 for the 18 RGB LED's. That LED is Red and all others are off
ptr = 0 ; set pointer to first scratchpad location for next datasets
For Counter = 1 TO No_LEDs
IF Counter = WhichIsRed THEN
MemAddr = Red
ENDIF
GOSUB FetchColour3 ; Fetch Colour definition from EEPROM and save in next scratchpad location
NEXT Counter
GOSUB SendData3 ; call subroutine to transfer all data to the WS2803 string
PAUSE SeqStep_Delay ; delay to give user time to see the new colour pattern
LED_Index = LED_Index + 1 // 252 ; any multiple of 18 will work if we let counter get to 255 and roll over to 0 then display will "jump"
LOOP ; loop forever
;
; -----[ Subroutines ]-----------------------------------------------------
;
; ***** Subroutine to fetch the data from EEPROM and save into Scratchpad for one RGB LED colour
FetchColour3:
READ MemAddr, LED_Data ; Fetch the Red component of the specified colour
@PtrInc = LED_Data ; save into the scratchpad RAM at required location
INC MemAddr
READ MemAddr, LED_Data ; Fetch the Green component of the specified colour
@PtrInc = LED_Data
INC MemAddr
READ MemAddr, LED_Data ; Fetch the Blue component of the specified colour
@PtrInc = LED_Data
RETURN ; Return after the RGB data for one RGB LED (3 channels) has been placed into the Scratchpad
;
; Subroutine to serially clock out the data through the WS2803 chips for THREE RGB LEDs
; NOTE this is limited to three WS2803 chips without adding more variables/field to the SHIFTOUT command
SendData3:
Ptr = 0
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of first WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of second WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc) ; first half of third WS2803
SHIFTOUT SClock,SData,MSBFirst_L, (@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc,@PtrInc)
RETURN
b12 = 0
goto MAIN