Joining 5 bit variables and splitting them into 8 bit ones later?


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default Joining 5 bit variables and splitting them into 8 bit ones later?

    Hello.
    I'm using a MAX7219 dot matrix display, 8x8 pixels, 4 daisy chained.
    I want to display some numbers on it. I can use 7x7 pixel font, so 4 digits will fit.
    But I want to use 6x7 pixel font, so can fit 5 digits on screen.
    Each letter graphics are stored in 6 bit codes, like this, for number 8

    001110
    011011
    011011
    001110
    011011
    011011
    001110

    But data to MAX7219 is being sent into 8 bit increments. So if I send it directly, there will be big gaps and each bit displayed only on single 8x8 matrix. So I need to add these 6 bits to each other, and then split them again into 8 bits. Like this:

    001110 001110 001110 001110 should become
    00111000 11100011 10001110
    Any ideas?

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    Don't quite have the thought fully formed, but I'm thinking along the lines of:
    Code:
    FullDigit VAR LONG
    FullDigit = ((Byte1 << 23) + (Byte2 << 17) + (Byte3 << 11)...
    This might compact the bits(?)

    You need 42 bits, but a LONG only has 32. There's an extra line that would have to be dealt with independently. Again, this isn't a "Solution", just food for thought.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    What if I create 32 bit array, write bits in sequence and then read it in appropriate chunks?

  4. #4
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    Something like this?
    Code:
    ' 001110 001110 001110 001110
    FullDisp VAR LONG
    FullDisp.31 = 0
    FullDisp.30 = 0
    FullDisp.29 = 1
    FullDisp.28 = 1
    FullDisp.27 = 1
    FullDisp.26 = 0
    FullDisp.25 = 0
    ... ... ... ... ... ...

  5. #5
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    Yes, but have no idea if can use another variable instead of 31 and other digits.
    Like displayvar.X=Y

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    I suspect this is what you want:
    Code:
    displayvar.0[X]=Y
    But I also suspect we've covered this before so instead of me trying to repeat what's already been covered in detail I just leave it all to Melanie :-)
    http://www.picbasic.co.uk/forum/showthread.php?t=544

Similar Threads

  1. 32 Bit NEC IR Constants/Variables
    By Zebryk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd July 2013, 14:51
  2. Joining variables and displaying on an LCD
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th April 2009, 04:12
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  4. How to tell which PICs can handle 16 bit variables?
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st August 2005, 08:44
  5. Bit variables... typo?
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th November 2004, 18:11

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