APA102 clear leds ?
+ Reply to Thread
Results 1 to 12 of 12
  1. #1

    Default APA102 clear leds ?

    By chance if anyone knows, I'm using a 12F675 and PBP to run a string of these leds and all is fine except I want to do a loop where they clear and sequence again.

    I know there is a start frame, the actual led frame(s) and an end frame which from what I gather is either is multiple bytes of all 1 or all 0. (I'm using 255, all 1's) Anyway, I want to run a sequence over and over but can't figure out how to extinguish all the leds.

    Is the start frame supposed to do it? (guess not -- because it isn't). I'm using an SK9822 string which is supposedly a clone of APA102 btw.

    Thanks much.

  2. #2
    Join Date
    Sep 2009
    Posts
    749

    Default Re: APA102 clear leds ?

    Just shift out 0's at end of frame...

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,175

    Default Re: APA102 clear leds ?

    Michael, here is a simple way:

    led_num con 287 'number of apa102c's

    SCRATCH VAR WORD
    LEDS VAR WORD

    SHIFTOUT SDA,SCL,1,[0,0,0,0] 'START FRAME
    SCRATCH = (LED_NUM - 1)
    LEDOFF:
    SHIFTOUT SDA,SCL,1,[$F0,$00,$00,$00] 'GLOBAL,OFF
    SCRATCH = SCRATCH - 1
    IF SCRATCH.15 = 0 THEN LEDOFF

    SCRATCH = 8
    EOFOFF:
    SHIFTOUT SDA,SCL,1,[$FF] 'END FRAME
    SCRATCH = SCRATCH - 1
    IF SCRATCH.15 = 0 THEN EOFOFF
    Dave Purola,
    N8NTA
    EN82fn

  4. #4

    Default Re: APA102 clear leds ?

    Thanks Dave, works great ! but I want to understand all of what's going on. I can't get my head around a couple of things that I noted in the code, why 240 ? And I see what scratch is doing but why does it all of a sudden have a value of 8 ? (I'm using 16 leds by the way, which seems to be fine for LED_NUM). Apparently I've also lucked out with these SK9822 which are supposed to be a drop in replacement for the APA102 but there were some things I read that made me apprehensive -- working great though. I've never played with RGB leds -- pretty cool. Do you know if they make an addressable 1 watt RGB power led by chance?

    Thanks for your help.



    SHIFTOUT SDA,SCL,1,[0,0,0,0] 'START FRAME
    SCRATCH = (LED_NUM - 1)
    LEDOFF:
    SHIFTOUT SDA,SCL,1,[240,0,0,0] 'GLOBAL,OFF WHY 240?
    SCRATCH = SCRATCH - 1
    IF SCRATCH.15 = 0 THEN LEDOFF

    SCRATCH = 8 '8 ? WHY?
    EOFOFF:
    SHIFTOUT SDA,SCL,1,[255] 'END FRAME
    SCRATCH = SCRATCH - 1
    IF SCRATCH.15 = 0 THEN EOFOFF

    PAUSE 2000

    GOTO START

  5. #5

    Default Re: APA102 clear leds ?

    Stumped as well on how you would go about shutting off individual leds in the chain? Say i had 30 and want to just extinguish 15? A specific bit in that scratch variable?

  6. #6
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,175

    Default Re: APA102 clear leds ?

    Michael, If you have a string say 24 APA102's and you want to extinguish just the middle 8 then you would have to send the appropriate color's and intensity codes for the upper 8 then, send SHIFTOUT SDA,SCL,1,[$F0,$00,$00,$00]
    8 times then, send the appropriate color's and intensity codes for the lower 8 then, send SHIFTOUT SDA,SCL,1,[255].
    I don't know what you are talking about when you say WHY 240? The code I attached clearly say's $F0. The reason for the 8 times is that I was clearing all 200 some led's in the string. You need to read the data sheet for the parts.
    Last edited by Dave; - 31st December 2018 at 19:09.
    Dave Purola,
    N8NTA
    EN82fn

  7. #7

    Default Re: APA102 clear leds ?

    Yes, I looked at the datasheet but I don't see anything relating to turning off the leds. It shows how to write the start frame, the led frame and end frame and that's it. So in testing --

    Start frame all 0's
    LED frame (brightness and RGB)
    End frame all 1's

    Pause

    Start frame
    Extinguish LED (SF0,0,0,0)
    End frame

    All that works just fine. I just don't know why it does.

    Nothing refers to $F0 (240) in the datasheet at least as far as I can see.
    Maybe I have an incomplete datasheet. https://cdn-shop.adafruit.com/datasheets/APA102.pdf

    And as far as accessing individual LEDS, I'm completely lost on that one. Say I have 16 leds and want to clear LED #7 ? How in the world would you point to it? Yet I see some strips etc that have random rather than "in a row" patterns. Thanks Dave.

  8. #8

    Default Re: APA102 clear leds ?

    Thinking about my question and maybe 240 designates an led frame of 111 + "off" brightness level?

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    1,671

    Default Re: APA102 clear leds ?

    Name:  DS.jpg
Views: 54
Size:  12.0 KB

    A LED FRAME,




    SHIFTOUT SDA,SCL,1,[$FF] 'END FRAME bad wrong
    You will find a lot of bad info about these chips , while a stop frame of one FF byte appears to work it does not really , it looks ok when all leds are written to. but !!! if you want to send a partial frame of n leds then led n+1 gets mucked up . the correct stop frame is x zeros where x= led_num /8 +1
    ie for 16 leds x = 16/2+1=3
    SHIFTOUT SDA,SCL,1,[0,0,0] 'END FRAME
    the data sheet suggests SHIFTOUT SDA,SCL,1,[255,255,255,255] this is totally wrong
    This is more entertaining than Free to Air TV

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    1,671

    Default Re: APA102 clear leds ?

    typical i got that wrong (memory is going) [just watched youtube video again ]https://www.youtube.com/watch?v=I2dFBNI5Q8E
    should be
    x= led_num /2 bits
    ie for 16 leds x = 8 bits
    SHIFTOUT SDA,SCL,1,[0] 'END FRAME will do it
    This is more entertaining than Free to Air TV

  11. #11

    Default Re: APA102 clear leds ?

    Ok thanks. So that 240 (which threw me) is just an LED frame with 0 brightness and no color? That would be the sequence to turn off the LED?

    I'll try that different stop frame because I'm getting some other minor strange things happening (especially with the last LED in the string) but then it may be the SK9822 I'm using which is a clone and have seen some posts that they really aren't the same.

    Thank you.

  12. #12

    Default Re: APA102 clear leds ?

    Thanks for all the help -- got my setup working great now. Seems you can use either all zero or all one for the end frame but I'll go with your recommendation. Never played with these before -- everyone likes a light show. Nice to see I can do it without that friggin' Arduino crap. Seems like the world has become all of these modules and as an old electronics hobbyist, I like PARTS damnit.

Similar Threads

  1. How to clear RCREG
    By xapmanis in forum Serial
    Replies: 3
    Last Post: - 14th November 2014, 02:43
  2. What does CLEAR actually clear?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th August 2014, 13:40
  3. Clear LCD
    By rshaver in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th October 2011, 21:14
  4. Any CLEAR command associated w/ DT_INTS?
    By circuitpro in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st May 2010, 01:22
  5. Does CLEAR Command clear return adrress of a subroutine?
    By sayzer in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th February 2008, 16:25

Members who have read this thread : 15

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts