Driving WS2812B strips with 12F1822 (40)


+ Reply to Thread
Results 1 to 2 of 2

Thread: Driving WS2812B strips with 12F1822 (40)195 days old

  1. #1
    Member keytapper's Avatar
    Join Date
    Jun 2019
    Posts
    101
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    310.31 MB

    0 Not allowed!

    Default Driving WS2812B strips with 12F1822 (40)

    Hello Forum,
    Herein I enclose a snippet to use as subroutine for driving WS2812S LEDs

    Code:
    '------------------------------------------------------------------------------
    Dim candlecntr As Byte
    
    All_Leds_Change:
        For candlecntr = 0 To MAXCANDLEcnt
            Green[candlecntr] = Var0
            Red[candlecntr] = Var1
            Blue[candlecntr] = Var2
        Next candlecntr
    
    WriteLeds: 'Sub Routine to write data to WS2812
    '-------Timing is important. here don't change anything-------
    
        For candlecntr = 0 To MAXCANDLEcnt 'Controlling 24 leds
            Var0 = Red[candlecntr]
            Var1 = Green[candlecntr]
            Var2 = Blue[candlecntr]
            Clear GIE
            ' Red
            If Var0.7 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.6 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.5 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.4 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.3 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.2 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.1 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var0.0 = 0 Then GoSub LowBit :Else: GoSub Highbit
            'Green
            If Var1.7 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.6 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.5 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.4 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.3 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.2 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.1 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var1.0 = 0 Then GoSub LowBit :Else: GoSub Highbit
            'Blue
            If Var2.7 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.6 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.5 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.4 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.3 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.2 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.1 = 0 Then GoSub LowBit :Else: GoSub Highbit
            If Var2.0 = 0 Then GoSub LowBit :Else: GoSub Highbit
            Set GIE
        Next candlecntr
    Return
    
    
    
    '*****************************************************************************
    'SUB-ROUTINES
    '*****************************************************************************
    
    'High Bit timing routine
    Highbit:
    OutLEDs = TRUE
    
    @NOP
    @NOP
    @NOP
    @NOP
    @NOP
    @NOP
    
    OutLEDs = FALSE
    
    
    '@NOP
    '@NOP
    '@NOP
    '@NOP
    Return
    
    'Low Bit Timing routine
    LowBit:
    OutLEDs = TRUE
    @NOP
    @NOP
    OutLEDs = FALSE
    @NOP
    @NOP
    ' 4 nops removed to compensate for 'IF' statements
    ;@NOP
    ;@NOP
    ;@NOP
    ;@NOP
    Return
    I couldn't test it personally, our friend Giuseppe has the hardware, but anyway everybody's invited to test it.
    Giuseppe found a situation where the compiler didn't include the context restore, no saving the a system variable and no Retfie.

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Junior Member Giuseppe's Avatar
    Join Date
    Jul 2019
    Posts
    25
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    383.45 MB

    0 Not allowed!

    Default Re: Driving WS2812B strips with 12F1822 (40)

    Hi Fulvio I can guarantee that everything works.
    You have to be careful of certain WS2812B LEDs like those larger than 5mm in traditional that don't respond well to commands.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Les has just uploaded WS2812B RGB LED controller library!
      By top204 in forum Proton Users File Server
      Replies: 0
      Last Post: 1st November 2017, 09:49
    2. 12F1822 fuses
      By WimSMulder in forum Proton Plus Compiler v3
      Replies: 3
      Last Post: 28th November 2013, 22:19
    3. 12F1822 Argument out of range
      By normnet in forum Fuse Configurator
      Replies: 8
      Last Post: 24th September 2011, 23:13
    4. 12f1822 support
      By grahamg in forum Pre-Sales and Upgrade Questions
      Replies: 6
      Last Post: 25th March 2011, 21:04

    Posting Permissions

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