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


Results 1 to 24 of 24

Threaded View

  1. #8
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

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

    So here it is, almost finished (not tested in PBP yet, written in notepad).
    Digit data are stored as 4 bit width sequences, each char compromising of 4x8 pixels (width & height). They are stored by pairs in eeprom (1st address holds bitmaps for 1 & 2, 2nd address - for 3 & 4 and so on).
    This routine should display value of 4 digit CNTR variable on screen. It does that by reading 4 bit graphic data from eeprom, adding 1 space between pixels and assembling into 32 bit array, which later should be cut into 4 bytes and sent to MAX7219. For simplicity, code is shown for sending only 1 line. However, I'm stuck, how to read values from 32 bit array and convert them into bytes.
    Code:
    LINE VAR BIT[32] 'line of MAX7219 buffer
    DBIT var byte    'digit bit eeprom address
    DOFF var byte    'digit offset 0 for first, 4 for next
    DSHF var byte    'Shift value for next digit data
    CNTR var word    'Input variable
    Y var byte    'Temporary digit variable
    X var byte    'digit scan variable
    Z var byte    'digit row variable
    BT var bit    'bit variable for font hold
    
    ' decoder routine
    DECODER:
    DSHF=0    'reset char shift variable
    for x=0 to 3 'read all 4 digits
    Y=CNTR DIG X 'EXTRACT VARIABLE DIGIT
    IF Y=1 THEN DBIT=0: DOFF=0 'set the font offset
    IF Y=2 THEN DBIT=0: DOFF=4
    IF Y=3 THEN DBIT=8: DOFF=0
    IF Y=4 THEN DBIT=8: DOFF=4
    IF Y=5 THEN DBIT=16: DOFF=0
    IF Y=6 THEN DBIT=16: DOFF=4
    IF Y=7 THEN DBIT=24: DOFF=0
    IF Y=8 THEN DBIT=24: DOFF=4
    IF Y=9 THEN DBIT=32: DOFF=0
    IF Y=0 THEN DBIT=32: DOFF=4
    
    for Z=0 to 4 'read font data and write into rows
    READ DBIT+DOFF+Z,BT 'read bit from eeprom
    LINE[Z+DSHF]=BT 'write into array
    next
    DSHF=DSHF+5    'increment char shift variable
    
    'now here should extract bits from array and convert into bytes
    'to send to MAX7219, but how?
    next
    Last edited by CuriousOne; - 15th December 2020 at 21:44.

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 : 0

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