ws812 matrix rotate


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386

    Default ws812 matrix rotate

    just playing with a ws812 8x8 array and looking for a nice way to rotate a 8x3x8 byte array through 90 degrees, I have left and right shift and up/down sorted but a tidy rotate cw and ccw method is eluding me . any thoughts

    the code here is a work in progress and not very well commented
    Attached Files Attached Files

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    I'm thinking complete new array, an inplace rotate give me brain fade

    for row = 0 to 7
    for column = 0 to 7
    for element = 0 to 2
    new_pixel[column*(7-row)+row*(7-column)+element]= pixel[row*8+column*3+element ]
    next
    next
    next

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    the penny dropped its a 24 byte wide row , had 8x8 burnt into brain

    for row = 0 to 7
    for column = 0 to 7
    for element = 0 to 2
    new_pixel[3*(7-row)+24*column+element]= pixel[row*24+column*3+element ]
    next
    next
    next

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    its so easy when you know how

    to go ccw
    for row = 0 to 7
    for column = 0 to 7
    for element = 0 to 2
    new_pixel[3*(row)+24*(7-column)+element]= pixel[row*24+column*3+element ]
    next
    next
    next

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    Hi Richard, did you mean rotating 2D 90 degrees each time you call the function?
    If so I wish I’d looked a this. It's in my display code, Tetris has to do it I used a lookup table for block rotation,
    but rotated digits for vertical orientation.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    its a 2d 8x8 matrix each element is 24 bits (rgb) the lot rotate 90 deg with each call . the cw and ccw both work flawlessly and are fairly quick too .
    a 45 deg rotate would be interesting.

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: ws812 matrix rotate

    At 8x8 resolution, as you get away from even 90 deg angles, it looks horrible.

Similar Threads

  1. rotate bytes in array
    By Art in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 15th March 2012, 23:59
  2. 2D Matrix Rotation
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th February 2010, 13:34
  3. Help led matrix
    By mosbc69 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 14th April 2008, 20:54
  4. Dipswitch matrix
    By DynamoBen in forum Off Topic
    Replies: 10
    Last Post: - 8th October 2007, 18:11
  5. need help with switch matrix
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th January 2005, 19:59

Members who have read this thread : 1

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