Last active
September 16, 2018 17:46
-
-
Save 7marcus9/5acf6a51887f3ec8a669b28bd94a99e5 to your computer and use it in GitHub Desktop.
APA102 RGB LED (x86 Parport)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE SUB ledInit () | |
DECLARE SUB ledEnd () | |
DECLARE SUB ledSend (bright!, r!, g!, b!) | |
DECLARE SUB sendBit (bit!) | |
DECLARE SUB sendByte (inb!) | |
REM Pin D0 (Pin 2) = DATA | |
REM Pin D1 (Pin 3) = CLOCK | |
CLS | |
FOR n = 0 TO 5000 | |
n = 0 | |
FOR v = 1 TO 255 STEP 5 | |
CALL ledInit | |
CALL ledSend(10, v, 0, 0) | |
CALL ledSend(10, 0, v, 0) | |
CALL ledSend(10, 0, 0, v) | |
CALL ledSend(1, 1, 1, 1) | |
CALL ledEnd | |
NEXT v | |
FOR w = 1 TO 255 STEP 5 | |
v = 256 - w | |
CALL ledInit | |
CALL ledSend(10, v, 0, 0) | |
CALL ledSend(10, 0, v, 0) | |
CALL ledSend(10, 0, 0, v) | |
CALL ledSend(1, 1, 1, 1) | |
CALL ledEnd | |
NEXT w | |
NEXT n | |
END | |
SUB ledEnd | |
CALL sendByte(255) | |
CALL sendByte(255) | |
CALL sendByte(255) | |
CALL sendByte(255) | |
END SUB | |
SUB ledInit | |
CALL sendByte(0) | |
CALL sendByte(0) | |
CALL sendByte(0) | |
CALL sendByte(0) | |
CALL sendByte(0) | |
END SUB | |
SUB ledSend (bright, r, g, b) | |
CALL sendByte(224 + bright) | |
CALL sendByte(g) | |
CALL sendByte(r) | |
CALL sendByte(b) | |
END SUB | |
SUB sendBit (bit) | |
REM PRINT "sending " | |
PRINT bit; | |
IF bit = 0 THEN | |
OUT 888, 0 | |
OUT 888, 2 | |
OUT 888, 0 | |
ELSE | |
OUT 888, 1 | |
OUT 888, 3 | |
OUT 888, 1 | |
END IF | |
END SUB | |
SUB sendByte (inb) | |
FOR i = 1 TO 8 | |
tv1 = INT(inb / (2 ^ (8 - i))) | |
bit = INT(tv1 MOD 2) | |
CALL sendBit(bit) | |
NEXT i | |
PRINT "" | |
END SUB | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment