some help with math


Closed Thread
Results 1 to 40 of 65

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    gives 0 when less then 3

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    If you have to check for <3 as well you might be approaching the code size of the lookup table.
    Are all the lookup tables repeating like this? It’s the sort of problem I like,
    certianly a mind F* though.

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    as a test i reversed high to low byte in the font structure

    unfortunately it worked , and this is supported by the data dumps as shown in previous posts , so to make the font common routine work i would have to reverse all the data stucture for each font chr - which if i dont have abetter option will need to be done

    Code:
    
            ' Code for "0"  Asci 48    90 real values _   
    @ dw      0x0000,0x0000,0x00FF,0xFF03,0x0FC0,0xF0FF,0xFF1F,0x1FF8,0xF8FF,0xC33F,0x3FFC,0xFC81;,0x3F   
    @ dw      0x813F,0x7FFC,0xFE00,0x007F,0x7FFE,0xFE00,0x007F,0x7FFE,0xFE00,0x007F,0x7FFE,0xFE00,0x007F   ;swaped low high bytes arround 
    @ dw      0x7FFE,0xFE00,0x007F,0x7FFE,0xFE00,0x813F,0x3FFC,0xFC81,0xC33F,0x1FFC,0xF8FF,0xFF1F;,0xF8  
    @ dw      0x0FF8,0xF0FF,0xFF03,0x00C0,0x00FF,0x0000,0x0000,0x0000

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    If you can write to that area your program could swap the data and write it back,
    then set a flag somewhere in a spare EEPROM bit to flag not to do it again.
    That’s if you can’t write something to spit it out a serial terminal in the format you want it.
    If the pic can read that and also has a serial terminal, you should be able to get it to format the lines as code you have above.

  5. #5
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: some help with math

    sorry richard the result i am seeing does not support what your are saying and the results show on the GLCD and debug terminal show the seqaunce for @ db option and @ dw to be incorrect when using readcode i have at the moment , a it gets 1 byte at a time

    remember the whole goel is to

    a. not change the font original data sequence of values
    b. store only the font data values , and not add any other values to flash to get the data back - unlike pokecode does




    try it for your self

    this is font chr "0" , where the font is 24 bits wide for (X) and 30 lines (Y)high
    LG font values for Common_font routine then are
    Y_scan = 29 ' 30 - Y scan lines - 1 - Cos "for " starts at 1
    X_scan = 3 ' 3 - X scan x 8 bits ( 24 bits)
    Font_lookup = 1 ' Use LG_Font_lookup
    gosub Font_Common ' not using flash chip


    with poke/peek it works ok with this code
    terminal should show the same data format and exact seq as the pokecode data

    Code:
     
            ' Code for "0"  Asci 48    90 real values _   
    pokecode $00,$00,$00,$00,$FF,$00,$03,$FF,$C0,$0F,$FF,$F0,$1F,$FF,$F8,$1F,$FF,$F8,$3F,$C3,$FC,$3F,$81,$FC,$3F,_
             $81,$FC,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,_
             $FE,$7F,$00,$FE,$7F,$00,$FE,$7F,$00,$FE,$3F,$81,$FC,$3F,$81,$FC,$3F,$C3,$FC,$1F,$FF,$F8,$1F,$FF,$F8,_
             $0F,$FF,$F0,$03,$FF,$C0,$00,$FF,$00,$00,$00,$00,$00,$00,$00
    code to place the code on glcd and terminal - terminal should show the address and data in the same sequance as the data input here
    Code:
    '=================== FONT COMMON ROUTINE - pokecode use ========================== 
    ' Assumes gl_x, gl_y,X_scan,Y_scan,Font_lookup   
    ' ALL FONTS MUST BE gl_x = 8 , 16 , 24 etc 
    ' Inv_font = 0 = normal 1= inverse   
    
    Font_Common: 
       x_save = gl_x                ' save the gl_x start point value 
       y_save = gl_y                ' save the gl_y start point value
       gl_yb  = y_save + Y_scan     ' number of y scans for the char from y starting point(0) 
       gl_xb  = 0 
       Address = 0 
       if Font_lookup = 1  then 
    @ GetAddress _LG_Font_Base, _Font_Base_Address                 ; gets base start address of LG_font into  Font_Base_Address varable 
          Font_Index = (LG_font - 45)* (90*2)                       ' remove the ascii chr value 45 offset  0 * font chr length x 2 cos of RETLW INSTRUCTION for each byte read  in index 
           HSEROUT [13,10,"lg Font_Base_Address = ",hex Font_Base_Address," font index = ",dec Font_Index, 13,10]     'debug 
      endif
            
       if Font_lookup = 2  then                                    ' remove the offset of the first symbol $2D / 45  so start at 0 
    @ GetAddress _Med_Font_Base, _Font_Base_Address
            Font_Index = (Med_font - 45)* (40*2)                   ' remove the ascii chr value 45 offset * font chr length in index
       endif                                        
       Address = Font_Base_Address + Font_Index                    'gets you to the start of the glyph
     
       for gl_y = y_save to gl_yb      ' y scan lines, start to finish values
           gl_x = x_save               ' clear x position to start point (keep it an 8bit multiple)
           gosub gl_gaddr              ' Set address
           
          for gl_xb = 1 to X_scan        ' gl_x byte x  X scan bytes on each line
              peekcode Address,gl_byte   ' read the indexed byte in
              HSEROUT [hex Address,"- ",hex gl_byte, ","]  
             glcd_msb = gl_byte         
              glcd_cmd = DATA_WR_INC     ' write and increment
              gosub send_1               ' send to glcd
              Address = Address+2        ' inc address here +2 cos each byte includes intruction code  , as data start at 0  
          next gl_xb                     ' next byte of font
       next gl_y                       ' next scan line of font
       gl_y = y_save                   ' Restore the Y location    
       gl_x = x_save                   ' Restore the X location
     return

    to use @ db data format the poke code data is changed to this format

    Code:
             ' Code for "0"  Asci 48    90 real values _   
    @ db     0x00,0x00,0x00,0x00,0xFF,0x00,0x03,0xFF,0xC0,0x0F,0xFF,0xF0,0x1F,0xFF,0xF8,0x1F,0xFF,0xF8,0x3F,0xC3,0xFC,0x3F,0x81,0xFC,0x3F
    @ db     0x81,0xFC,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00
    @ db     0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x7F,0x00,0xFE,0x3F,0x81,0xFC,0x3F,0x81,0xFC,0x3F,0xC3,0xFC,0x1F,0xFF,0xF8,0x1F,0xFF,0xF8
    @ db     0x0F,0xFF,0xF0,0x03,0xFF,0xC0,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    routine to get this data out and into the corect sequance - BUT THIS DOES NOT WORK AS THE DATA IS OUT OF SEQUANCE cos of readcode of low high reading
    Code:
     Font_Common: 
       x_save = gl_x                ' save the gl_x start point value 
       y_save = gl_y                ' save the gl_y start point value
       gl_yb  = y_save + Y_scan     ' number of y scans for the char from y starting point(0) 
       gl_xb  = 0 
       Address = 0 
       if Font_lookup = 1  then 
    @ GetAddress _LG_Font_Base, _Font_Base_Address                 ; gets base start address of LG_font into  Font_Base_Address varable 
           Font_Index = (LG_font - 45)* 90                          ' remove the ascii chr value 45 offset  0 * font chr length                                                            
         HSEROUT [13,10,"lg Font_Base_Address = ",hex Font_Base_Address," font index = ",dec Font_Index, 13,10]     'debug
       endif
            
       if Font_lookup = 2  then                                    ' remove the offset of the first symbol $2D / 45  so start at 0 
    @ GetAddress _Med_Font_Base, _Font_Base_Address
            Font_Index = (Med_font - 45)*40                        ' remove the ascii chr value 45 offset * font chr length in index
       endif                                        
       Address = Font_Base_Address + Font_Index                    'gets you to the start of the glyph
     
       for gl_y = y_save to gl_yb      ' y scan lines, start to finish values
           gl_x = x_save               ' clear x position to start point (keep it an 8bit multiple)
           gosub gl_gaddr              ' Set address
          for gl_xb = 1 to X_scan       ' gl_xb byte x  X scan bytes can be 2 or 3 on each line
             readcode Address,gl_byte
             HSEROUT [hex Address,"- ",hex gl_byte, ","] 
              glcd_msb = gl_byte         ' put in 1st byte - stored as         
              glcd_cmd = DATA_WR_INC     ' write and increment
              gosub send_1               ' send to glcd
              Address = Address + 1      ' inc address + 1  
          next gl_xb                     ' next byte of font
            
       next gl_y                       ' next scan line of font
       gl_y = y_save                   ' Restore the Y location    
       gl_x = x_save                   ' Restore the X location
     return
    same data joined to make word values ,

    these are stored in flash correct seq in flash as the font data shown here

    recovery routine is same as above - and has the same issue readcode gets the data not in correct seq required


    Code:
    
            ' Code for "0"  Asci 48    90 real values _   
    @ dw     0x0000,0x0000,0xFF00,0x03FF,0xC00F,0xFFF0,0x1FFF,0xF81F,0xFFF8,0x3FC3,0xFC3F,0x81FC        ;,0x3F
    @ dw     0x3F81,0xFC7F,0x00FE,0x7F00,0xFE7F,0x00FE,0x7F00,0xFE7F,0x00FE,0x7F00,0xFE7F,0x00FE,0x7F00
    @ dw     0xFE7F,0x00FE,0x7F00,0xFE7F,0x00FE,0x3F81,0xFC3F,0x81FC,0x3FC3,0xFC1F,0xFFF8,0x1FFF        ;,0xF8
    @ dw     0xF80F,0xFFF0,0x03FF,0xC000,0xFF00,0x0000,0x0000,0x0000

Similar Threads

  1. Help with A/D math!
    By dbodenheimer in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 19th March 2011, 00:51
  2. Math help please...
    By Ioannis in forum General
    Replies: 2
    Last Post: - 20th June 2008, 10:18
  3. PBPL Math...new math takes more cycles...Always?
    By skimask in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th February 2008, 10:22
  4. Math help please!!!
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th August 2007, 14:45
  5. math help
    By houa in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th January 2006, 16:58

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