Big characters on HD44780 4x20


Closed Thread
Results 1 to 24 of 24
  1. #1
    Join Date
    Jan 2007
    Posts
    13

    Question Big characters on HD44780 4x20

    Hi! I'm an Italian user, I need to show BIG CHARACTERS on a 4x20 lcd hd44780 compatible. This project is intended to show temperatures in my car. I like lcd style much more than led 7-segment style. I've written some code:

    Code:
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr     CON 1
    Comm    Con $FE
    LINE1   con 2
    LINE2   con $c0
    LINE3   con $94
    LINE4   con $d4
    Dx      con $14
    
    Begin:
            Pause 500       
            LCDOUT  $FE,$40,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F  ' Cust Char #0  
            LCDOUT  $FE,$48,$1F,$1F,$1F,$1F,$00,$00,$00,$00  ' Cust Char #1  
            LCDOUT  $FE,$50,$00,$00,$00,$00,$1F,$1F,$1F,$1F  ' Cust Char #2  
            LCDOUT  $FE,$58,$00,$00,$00,$00,$00,$0E,$0E,$0E  ' Cust Char #3  
            LCDOUT  $FE,$60,$00,$00,$00,$00,$00,$1F,$1F,$1F  ' Cust Char #4  
            LCDOUT  $FE,$68,$1F,$1F,$1F,$00,$00,$00,$00,$00  ' Cust Char #5  
            LCDOUT  $FE,$70,$00,$01,$03,$07,$0F,$1F,$1F,$1F  ' Cust Char #6  
            LCDOUT  $FE,$78,$00,$00,$00,$00,$00,$00,$01,$03  ' Cust Char #7  
    Main:
            LCDOUT comm, clr
            lcdout comm, line1, "T", COMM, LINE2, "E", COMM, LINE3, "S", COMM, LINE4, "T"
            PAUSE 1000
            GOSUB NUMERO11
            PAUSE 1000
            GOSUB NUMERO22
            PAUSE 1000
            GOSUB NUMERO33
            PAUSE 2000
            GOTO MAIN
    
    Numero11:
            lcdout comm, line1, comm, dx, comm, dx, $07, $06, $00
            lcdout comm, line2, comm, dx, comm, dx, comm, dx, comm, dx, $00
            lcdout comm, line3, comm, dx, comm, dx, comm, dx, comm, dx, $00
            lcdout comm, line4, comm, dx, comm, dx, comm, dx, comm, dx, $00        
            RETURN
            
    Numero22:
            LCDOUT comm, LINE1, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $01, $01, $01, $00
            LCDOUT COMM, LINE2, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $02, $02, $02, $00
            LCDOUT COMM, LINE3, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $00, $01, $01, $01
            LCDOUT COMM, LINE4, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $00, $02, $02, $02
            RETURN
    Numero33:
            LCDOUT COMM, LINE1, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $01, $01, $01, $00
            LCDOUT COMM, LINE2, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $04, $04, $00
            LCDOUT COMM, LINE3, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $05, $05, $00
            LCDOUT COMM, LINE4, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, comm, dx, $02, $02, $02, $00
            RETURN      
    end
    It's only a test right now. This code is really too long and too unefficient, so I need your help! How can I write this code to be simpler?

    Sorry for my English!

    Thanks, Francesco

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup there's few different way to improve it, tell us the PIC you're using.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Yup there's few different way to improve it, tell us the PIC you're using.
    Actually i'm using a 16f84a only for testing. The final pic will be a 16f877a.

    Really thank you!

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Will people stopping using 16F84A one day? LOL!

    Anyways, do you mind if i try to do the code for the 16F877A right now as you'll end up using this one anyway?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Will people stopping using 16F84A one day? LOL!

    Anyways, do you mind if i try to do the code for the 16F877A right now as you'll end up using this one anyway?

    I'm only using it because it's the test pic! I've flashed it at least 500 times!

    This is a little bit smaller code:

    Code:
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr     CON 1
    Comm    Con $FE
    LINE1   con 2
    LINE2   con $c0
    LINE3   con $94
    LINE4   con $d4
    Dx      con $14
    
    Begin:
            Pause 500       
      LCDOUT  $FE,$40,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F  ' Cust Char #0  
      LCDOUT  $FE,$48,$1F,$1F,$1F,$1F,$00,$00,$00,$00  ' Cust Char #1  
      LCDOUT  $FE,$50,$00,$00,$00,$00,$1F,$1F,$1F,$1F  ' Cust Char #2  
      LCDOUT  $FE,$58,$00,$00,$00,$0E,$1F,$1F,$1F,$0E  ' Cust Char #3  
      LCDOUT  $FE,$60,$00,$00,$00,$00,$00,$1F,$1F,$1F  ' Cust Char #4  
      LCDOUT  $FE,$68,$1F,$1F,$1F,$00,$00,$00,$00,$00  ' Cust Char #5  
      LCDOUT  $FE,$70,$00,$01,$03,$07,$0F,$1F,$1F,$1F  ' Cust Char #6  
      LCDOUT  $FE,$78,$00,$00,$00,$00,$00,$00,$01,$03  ' Cust Char #7    
    Main:
            LCDOUT comm, clr
            lcdout comm, line1, "T", COMM, LINE2, "E", COMM, LINE3, "S", COMM, LINE4, "T"
            PAUSE 1000
            GOSUB NUMERO11
            PAUSE 1000
            GOSUB NUMERO22
            PAUSE 1000
            GOSUB NUMERO33
            pause 1000
            gosub punto3
            pause 1000
            gosub numero44
            PAUSE 3000
            GOTO MAIN
    
    Numero11:
            lcdout comm, $82, $07, $06, $00
            lcdout comm, $C4, $00
            lcdout comm, $98, $00
            lcdout comm, $D8, $00        
            RETURN
            
    Numero22:
            LCDOUT comm, $86, $01, $01, $01, $00
            LCDOUT comm, $C6, $02, $02, $02, $00
            LCDOUT comm, $9A, $00, $01, $01, $01
            LCDOUT comm, $DA, $00, $02, $02, $02
            RETURN
    Numero33:
            LCDOUT comm, $8B, $01, $01, $01, $00
            LCDOUT comm, $CC, $04, $04, $00
            LCDOUT comm, $A0, $05, $05, $00
            LCDOUT comm, $DF, $02, $02, $02, $00
            RETURN 
    Punto3:
            LCDOUT Comm, $E3, $03
            return
    Numero44:
            lcdout comm, $90, $00
            lcdout COMM, $D0, $00, COMM, $D3, $00
            lcdout COmm, $A4, $01, $01, $01, $00
            lcdout comm, $E7, $00
            return      
    end
    But of course it's not what I want!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK then i'll try with my favourite 16F84A

    OK everybody, the code shrinking competition start RIGHT NOW!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Doh! i miss this line...

    But of course it's not what I want!
    So what do you want? smaller only ?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Doh! i miss this line...



    So what do you want? smaller only ?
    Simply better! I'm working on it, in about 1 hour I will post the result!

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Maybe not FAR BETTER but interesting...
    Code:
    Clr     CON 1
    Comm    Con $FE
    LINE1   con $80  ;2
    LINE2   con $c0
    LINE3   con $94
    LINE4   con $d4
    Dx      con $14
    offset  var byte
    Begin:
            Pause 500       
            LCDOUT  $FE,$40,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F  ' Cust Char #0  
            LCDOUT  $FE,$48,$1F,$1F,$1F,$1F,$00,$00,$00,$00  ' Cust Char #1  
            LCDOUT  $FE,$50,$00,$00,$00,$00,$1F,$1F,$1F,$1F  ' Cust Char #2  
            LCDOUT  $FE,$58,$00,$00,$00,$00,$00,$0E,$0E,$0E  ' Cust Char #3  
            LCDOUT  $FE,$60,$00,$00,$00,$00,$00,$1F,$1F,$1F  ' Cust Char #4  
            LCDOUT  $FE,$68,$1F,$1F,$1F,$00,$00,$00,$00,$00  ' Cust Char #5  
            LCDOUT  $FE,$70,$00,$01,$03,$07,$0F,$1F,$1F,$1F  ' Cust Char #6  
            LCDOUT  $FE,$78,$00,$00,$00,$00,$00,$00,$01,$03  ' Cust Char #7  
    Main:
            offset=0
            LCDOUT comm, clr
            lcdout comm, line1, "T", _
                   COMM, LINE2, "E", _
                   COMM, LINE3, "S", _
                   COMM, LINE4, "T"
            offset=2
            PAUSE 1000
            GOSUB NUMERO2
            PAUSE 1000
            GOSUB NUMERO1
            PAUSE 1000
            GOSUB NUMERO3
            PAUSE 2000
            GOTO MAIN
    
    Numero1:
            LCDOUT COMM,LINE1+offset,7,6,0,_
                   COMM,LINE2+offset+2,0,_
                   COMM,LINE3+offset+2,0,_
                   COMM,LINE4+offset+2,0 
    
            offset=offset+4
            RETURN
    
    Numero2:
            LCDOUT COMM,(LINE1+offset),1,1,1,0,_
                   COMM,(LINE2+offset),2,2,2,0,_
                   COMM,(LINE3+offset),0,1,1,1,_
                   COMM,(LINE4+offset),0,2,2,2                
            offset=offset+5
            RETURN
    
    Numero3:
            LCDOUT COMM,LINE1+offset,1,1,1,0,_
                   COMM,LINE2+offset+1, 4, 4, 0,_
                   COMM,LINE3+offset+1, 5, 5, 0,_
                   COMM,LINE4+offset,$02, $02, $02, $00
            offset=offset+5
            RETURN
    I'm still working on something...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I think this is quite good:

    Code:
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr     CON 1
    Comm    Con $FE
    LINE1   con 2
    LINE2   con $c0
    LINE3   con $94
    LINE4   con $d4
    Offset  VAR BYTE
    
    Begin:
            Pause 500       
      LCDOUT  254,64,31,31,31,31,0,0,0,0       ' Cust Char #0  
      LCDOUT  254,72,0,0,0,0,31,31,31,31       ' Cust Char #1  
      LCDOUT  254,80,31,31,31,15,7,3,1,0       ' Cust Char #2  
      LCDOUT  254,88,31,31,31,30,28,24,16,0    ' Cust Char #3  
      LCDOUT  254,96,0,16,24,28,30,31,31,31    ' Cust Char #4  
      LCDOUT  254,104,0,1,3,7,15,31,31,31      ' Cust Char #5
      LCDOUT  254,112,31,31,31,31,31,31,31,31  ' Cust Char #6   
      LCDOUT  254,120,0,0,0,14,31,31,31,14     ' Cust Char #7  
        
    Main:
            LCDOUT comm, clr
            lcdout comm, line1, "T", COMM, LINE2, "E", COMM, LINE3, "S", COMM, LINE4, "T"
            OFFSET=0
            gOSUB NUMERO0
            OFFSET=5
            GOSUB NUMERO1
            OFFSET=10
            GOSUB NUMERO2
            OFFSET=15
            GOSUB NUMERO3
            PAUSE 9000
            LCDOUT COMM, CLR
            OFFSET=0
            GOSUB NUMERO4
            OFFSET=5
            GOSUB NUMERO5
            OFFSET=10
            GOSUB NUMERO6
            OFFSET=15
            GOSUB NUMERO7
            PAUSE 9000
            LCDOUT COMM, CLR
            OFFSET=0
            GOSUB NUMERO8
            OFFSET=5
            GOSUB NUMERO9
            OFFSET=5
            GOSUB PUNTO
            OFFSET=10
            GOSUB NUMERO0
            PAUSE 9000
            GOTO MAIN       
               
    END
        
    Punto:
            LCDOUT Comm, ($D9 + OFFSET), $07
            return
    Numero0:
            LCDOUT COMM, ($81 + OFFSET), $05, $FF, $FF, $04
            LCDOUT COMM, ($C1 + OFFSET), $FF, COMM, ($C4 + OFFSET), $FF
            LCDOUT COMM, ($95 + OFFSET), $FF, COMM, ($98 + OFFSET), $FF
            LCDOUT COMM, ($D5 + OFFSET), $02, $FF, $FF, $03
            RETURN
    Numero1:
            lcdout comm, ($82 + OFFSET), $05, $FF
            lcdout comm, ($C3 + OFFSET), $FF
            lcdout comm, ($97 + OFFSET), $FF
            lcdout comm, ($D7 + OFFSET), $FF        
            RETURN
            
    Numero2:
            LCDOUT comm, ($81 + OFFSET), $00, $00, $00, $04
            LCDOUT comm, ($C4 + OFFSET), $FF
            LCDOUT comm, ($95 + OFFSET), $05, $00, $00, $00
            LCDOUT comm, ($D5 + OFFSET), $FF, $01, $01, $01
            RETURN
    Numero3:
            LCDOUT comm, ($81 + OFFSET), $00, $00, $00, $04
            LCDOUT comm, ($C2 + OFFSET), $01, $01, $FF
            LCDOUT comm, ($96 + OFFSET), $00, $00, $FF
            LCDOUT comm, ($D5 + OFFSET), $01, $01, $01, $03
            RETURN 
    
    Numero4:
            lcdout comm, ($81 + OFFSET), $FF
            lcdout COMM, ($C1 + OFFSET), $FF, COMM, ($C4 + OFFSET), $FF
            lcdout COmm, ($95 + OFFSET), $00, $00, $00, $FF
            lcdout comm, ($D8 + OFFSET), $FF
            return      
    Numero5:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $00
            LCDOUT COMM, ($C1 + OFFSET), $FF
            LCDOUT COMM, ($95 + OFFSET), $00, $00, $00, $04
            LCDOUT COMM, ($D5 + OFFSET), $01, $01, $01, $03
            RETURN    
    Numero6:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00
            LCDOUT COMM, ($C1 + OFFSET), $FF
            LCDOUT COMM, ($95 + OFFSET), $FF, $00, $00, $04
            LCDOUT COMM, ($D5 + OFFSET), $02, $01, $01, $03
            RETURN
    Numero7:
            LCDOUT COMM, ($81 + OFFSET), $00, $00, $00, $FF
            LCDOUT COMM, ($C3 + OFFSET), $01, $FF
            LCDOUT COMM, ($97 + OFFSET), $00, $FF
            LCDOUT COMM, ($D8 + OFFSET), $FF
            RETURN
    Numero8:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $04
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $03
            LCDOUT COMM, ($95 + OFFSET), $05, $00, $00, $04
            LCDOUT COMM, ($D5 + OFFSET), $02, $01, $01, $03
            RETURN       
    Numero9:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $04
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $FF
            LCDOUT COMM, ($98 + OFFSET), $FF
            LCDOUT COMM, ($D6 + OFFSET), $01, $01, $03
            RETURN
    It's "only" 1002 words and about 900 words w/o the little "show" in Main.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by erpalma View Post
    I think this is quite good:

    Code:
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr     CON 1
    Comm    Con $FE
    LINE1   con 2
    LINE2   con $c0
    LINE3   con $94
    LINE4   con $d4
    Offset  VAR BYTE
    
    Begin:
            Pause 500       
      LCDOUT  254,64,31,31,31,31,0,0,0,0       ' Cust Char #0  
      LCDOUT  254,72,0,0,0,0,31,31,31,31       ' Cust Char #1  
      LCDOUT  254,80,31,31,31,15,7,3,1,0       ' Cust Char #2  
      LCDOUT  254,88,31,31,31,30,28,24,16,0    ' Cust Char #3  
      LCDOUT  254,96,0,16,24,28,30,31,31,31    ' Cust Char #4  
      LCDOUT  254,104,0,1,3,7,15,31,31,31      ' Cust Char #5
      LCDOUT  254,112,31,31,31,31,31,31,31,31  ' Cust Char #6   
      LCDOUT  254,120,0,0,0,14,31,31,31,14     ' Cust Char #7  
        
    Main:
            LCDOUT comm, clr
            lcdout comm, line1, "T", COMM, LINE2, "E", COMM, LINE3, "S", COMM, LINE4, "T"
            OFFSET=0 : gOSUB NUMERO0
            OFFSET=5 : GOSUB NUMERO1
            OFFSET=10 : GOSUB NUMERO2
            OFFSET=15 : GOSUB NUMERO3
            PAUSE 9000 : LCDOUT COMM, CLR
            OFFSET=0 : GOSUB NUMERO4
            OFFSET=5 : GOSUB NUMERO5
            OFFSET=10 : GOSUB NUMERO6
            OFFSET=15 : GOSUB NUMERO7
            PAUSE 9000 : LCDOUT COMM, CLR
            OFFSET=0 : GOSUB NUMERO8
            OFFSET=5 : GOSUB NUMERO9
            OFFSET=5 : GOSUB PUNTO
            OFFSET=10 : GOSUB NUMERO0
            PAUSE 9000 : GOTO MAIN       
               
    END
        
    Punto:
            LCDOUT Comm, ($D9 + OFFSET), $07 : return
    Numero0:
            LCDOUT COMM, ($81 + OFFSET), $05, $FF, $FF, $04
            GOSUB COMBO1
            LCDOUT COMM, ($95 + OFFSET), $FF, COMM, ($98 + OFFSET), $FF
            LCDOUT COMM, ($D5 + OFFSET), $02, $FF, $FF, $03
            RETURN
    Numero1:
            lcdout comm, ($82 + OFFSET), $05, $FF
            lcdout comm, ($C3 + OFFSET), $FF
            lcdout comm, ($97 + OFFSET), $FF
            lcdout comm, ($D7 + OFFSET), $FF        
            RETURN
    Numero2:
            GOSUB COMBO2
            LCDOUT comm, ($C4 + OFFSET), $FF
            LCDOUT comm, ($95 + OFFSET), $05, $00, $00, $00
            LCDOUT comm, ($D5 + OFFSET), $FF, $01, $01, $01
            RETURN
    Numero3:
            GOSUB COMBO2
            LCDOUT comm, ($C2 + OFFSET), $01, $01, $FF
            LCDOUT comm, ($96 + OFFSET), $00, $00, $FF
            GOSUB COMBO3
            RETURN 
    Numero4:
            lcdout comm, ($81 + OFFSET), $FF
            GOSUB COMBO1
            GOSUB COMBO4
            GOSUB COMBO5
            return      
    Numero5:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $00
            GOSUB COMBO6
            GOSUB COMBO4
            GOSUB COMBO3
            RETURN    
    Numero6:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00
            GOSUB COMBO6
            LCDOUT COMM, ($95 + OFFSET), $FF, $00, $00, $04
            GOSUB COMBO7
            RETURN
    Numero7:
            GOSUB COMBO2
            LCDOUT COMM, ($C3 + OFFSET), $01, $FF
            LCDOUT COMM, ($97 + OFFSET), $00, $FF
            GOSUB COMBO5
            RETURN
    Numero8:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $03
            LCDOUT COMM, ($95 + OFFSET), $05, $00, $00, $04
            GOSUB COMBO7
            RETURN       
    Numero9:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $FF
            GOSUB COMBO5
            LCDOUT COMM, ($D6 + OFFSET), $01, $01, $03
            RETURN
    COMBO1:
            LCDOUT COMM, ($C1 + OFFSET), $FF, COMM, ($C4 + OFFSET), $FF
            RETURN
    COMBO2:
            LCDOUT comm, ($81 + OFFSET), $00, $00, $00, $04
            RETURN
    COMBO3:
            LCDOUT comm, ($D5 + OFFSET), $01, $01, $01, $03
            RETURN
    COMBO4:
            LCDOUT comm, ($95 + OFFSET), $00, $00, $00, $FF
            RETURN
    COMBO5:
            LCDOUT comm, ($D8 + OFFSET), $FF
            RETURN
    COMBO6:
            LCDOUT COMM, ($C1 + OFFSET), $FF
            RETURN
    COMBO7:
            LCDOUT COMM, ($D5 + OFFSET), $02, $01, $01, $03
            RETURN
    COMBO8:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $04
            RETURN
    It's "only" 1002 words and about 900 words w/o the little "show" in Main.
    I combined a few of your lcdout statement into gosub's. See how much (if any) code space that saves/uses.

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    It's really bad the poor 16F84A don't support some interesting MPASM feature. Well i admit that i discovered this totally at the end... anyways, here's something 532 Bytes working on a 16F877
    Code:
    DEFINE LOADER_USED 1
    Define OSC 4
    DEFINE LCD_DREG PORTD     ' LCD data port 
    DEFINE LCD_DBIT 4         ' LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTD    ' LCD register select port 
    DEFINE LCD_RSBIT 2        ' LCD register select bit 
    DEFINE LCD_EREG PORTD     ' LCD enable port 
    DEFINE LCD_EBIT 3         ' LCD enable bit 
    DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
    DEFINE LCD_LINES 4        ' Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
    DEFINE LCD_DATAUS 50      ' Data delay time in us 
    
    goto VariableDefinition
    asm
    Comm=0xFE
    EOL=0xFF
    Dx=0x14
    
    CustChar 
            dt  Comm,0x40,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F  ; Cust Char #0  
            dt  Comm,0x48,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00  ; Cust Char #1  
            dt  Comm,0x50,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F  ; Cust Char #2  
            dt  Comm,0x58,0x00,0x00,0x00,0x00,0x00,0x0E,0x0E,0x0E  ; Cust Char #3  
            dt  Comm,0x60,0x00,0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F  ; Cust Char #4  
            dt  Comm,0x68,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00  ; Cust Char #5  
            dt  Comm,0x70,0x00,0x01,0x03,0x07,0x0F,0x1F,0x1F,0x1F  ; Cust Char #6  
            dt  Comm,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03  ; Cust Char #7  
            dt  EOL ; end of Custom character
    
    One     dt 7,6,0,EOL
            dt Comm,Dx,Comm,Dx,0,EOL
            dt Comm,Dx,Comm,Dx,0,EOL
            dt Comm,Dx,Comm,Dx,0,EOL
            dt 4
    
    Two     dt 1,1,1,0,EOL
            dt 2,2,2,0,EOL
            dt 0,1,1,1,EOL
            dt 0,2,2,2,EOL
            dt 5
          
    Three   dt 1,1,1,0,EOL
            dt Comm,Dx,4,4,0,EOL
            dt Comm,Dx,5,5,0,EOL
            dt 2,2,2,0,EOL
            dt 5        
    endasm
    
    VariableDefinition:
        CustChar    con EXT
        One         con EXT
        Two         con EXT
        Three       con EXT
    
        Clr         CON 1
        Comm        Con EXT
        EOL         con EXT
        Dx          con EXT
        Line        var byte[4]
            line[0]=$80
            line[1]=$C0
            line[2]=$94
            line[3]=$D4
        
        offset      var byte
        index       var byte
        Char        var byte
        ActualLine  var byte
        Addr        var word
           
        Number      var byte
        Pattern     var word[10]
            pattern[1]=one
            Pattern[2]=two
            pattern[3]=three
    
        pause 500
    DumpCustChar:
        addr=0
        char=0
        repeat
            lcdout char
            reaDCODE custchar+addr,char
            addr=addr+1
            until char=eol
    
    Main:  
        offset=0
        LCDOUT comm, clr
        pause 500
        lcdout comm, line[0], "T", _
               COMM, LINE[1], "E", _
               COMM, LINE[2], "S", _
               COMM, LINE[3], "T"
        offset=2
        pause 500
        number=3 : gosub displaynumber
        pause 500
        number=1 : gosub displaynumber
        pause 500
        number=2 : gosub displaynumber
        pause 500
        number=1 : gosub displaynumber
        pause 500
        GOTO MAIN
    
    DisplayNumber:
        actualline=0
        index=0
        lcdout comm,line[actualline]+offset
        Loop:
            readcode pattern[number]+index,char
            if char!=eol then 
                if actualline<4 then
                    lcdout char
                    else
                        offset=offset+char
                        Goto GetOut
                    endif
                else
                    actualline=actualline+1
                    if actualline<4 then lcdout comm,line[actualline]+offset
                endif
            index=index+1
            goto loop
        GetOut:
            RETURN
    I'll try your own... and see how much i could Shrink it to do the same thing. Forgive me, i won't try with a 16F84A
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK, a 0000-9999 up-counter, 746 Word on a 16F877A
    Code:
    DEFINE LOADER_USED 1
    Define OSC 4
    DEFINE LCD_DREG PORTD     ' LCD data port 
    DEFINE LCD_DBIT 4         ' LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTD    ' LCD register select port 
    DEFINE LCD_RSBIT 2        ' LCD register select bit 
    DEFINE LCD_EREG PORTD     ' LCD enable port 
    DEFINE LCD_EBIT 3         ' LCD enable bit 
    DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
    DEFINE LCD_LINES 4        ' Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
    DEFINE LCD_DATAUS 50      ' Data delay time in us 
    
    goto VariableDefinition
    asm
    Comm=0xFE
    EOL=0xFC
    Dx=0x14
    
    CustChar 
            dt Comm,64,31,31,31,31,0,0,0,0      ; Cust Char #0  
            dt Comm,72,0,0,0,0,31,31,31,31      ; Cust Char #1  
            dt Comm,80,31,31,31,15,7,3,1,0      ; Cust Char #2  
            dt Comm,88,31,31,31,30,28,24,16,0   ; Cust Char #3  
            dt Comm,96,0,16,24,28,30,31,31,31   ; Cust Char #4  
            dt Comm,104,0,1,3,7,15,31,31,31     ; Cust Char #5  
            dt Comm,112,31,31,31,31,31,31,31,31 ; Cust Char #6  
            dt Comm,120,0,0,0,14,31,31,31,14    ; Cust Char #7  
            dt EOL ; end of Custom character
    
    Zero    dt 5,0xFF,0xFF,4,EOL
            dt 0xFF,Comm,Dx,Comm,Dx,0xFF,EOL
            dt 0XFF,Comm,Dx,Comm,Dx,0xFF,EOL
            dt 2,0xff,0xff,3,EOL
            dt 5
    
    One     dt Comm,Dx,5,0xff,EOL
            dt Comm,Dx,Comm,Dx,0xff,EOL
            dt Comm,Dx,Comm,Dx,0xff,EOL
            dt Comm,Dx,Comm,Dx,0xff,EOL
            dt 5;3
    
    Two     dt 0,0,0,4,EOL
            dt Comm,Dx,Comm,Dx,Comm,Dx,0xff,EOL
            dt 5,0,0,0,EOL
            dt 0xff,1,1,1,EOL
            dt 5
          
    Three   dt 0,0,0,4,EOL
            dt Comm,Dx,1,1,0xff,EOL
            dt Comm,Dx,0,0,0xff,EOL
            dt 1,1,1,3,EOL
            dt 5    
    
    Four    dt 0xff,EOL
            dt 0xff,Comm,Dx,Comm,Dx,0xff,EOL
            dt 0,0,0,0xff,EOL
            dt Comm,Dx,Comm,Dx,Comm,Dx,0xff,EOL
            dt 5    
    
    Five    dt 5,0,0,0,EOL
            dt 0xff,EOL
            dt 0,0,0,4,EOL
            dt 1,1,1,3,EOL
            dt 5    
    
    Six     dt Comm,Dx,5,0,0,EOL
            dt 0xff,EOL
            dt 0xff,0,0,4,EOL
            dt 2,1,1,3,EOL
            dt 5    
    
    Seven   dt 0,0,0,0xff,EOL
            dt Comm,Dx,Comm,Dx,1,0xff,EOL
            dt Comm,Dx,Comm,Dx,0,0xff,EOL
            dt Comm,Dx,Comm,Dx,Comm,Dx,0xff,EOL
            dt 5    
            
    Eight   dt 5,0,0,4,EOL
            dt 2,1,1,3,EOL
            dt 5,0,0,4,EOL
            dt 2,1,1,3,EOL
            dt 5
    
    Nine    dt 5,0,0,4,EOL
            dt 2,1,1,0xff,EOL
            dt Comm,Dx, Comm,Dx,Comm,Dx,0xff,EOL
            dt Comm,Dx,1,1,3,EOL
            dt 5
                    
    Punto   dt EOL
            dt EOL
            dt EOL
            dt 7,EOL
            dt 2
    endasm
    VariableDefinition:
        CustChar    con EXT
        Zero        con EXT
        One         con EXT
        Two         con EXT
        Three       con EXT
        Four        CON EXT
        Five        CON EXT
        Six         CON EXT
        Seven       CON EXT
        Eight       CON EXT
        Nine        CON EXT
        Punto       CON EXT
                
        Clr         CON 1
        Comm        Con EXT
        EOL         con EXT
        Dx          con EXT
        Line        var byte[4]
            line[0]=$80
            line[1]=$C0
            line[2]=$94
            line[3]=$D4
        
        offset      var byte
        index       var byte
        Char        var byte
        ActualLine  var byte
        Addr        var word
        CounterA    var word       
        CounterB    var byte
        Number      var byte
        Pattern     var word[11]
            pattern[0]=zero
            pattern[1]=one
            Pattern[2]=two
            pattern[3]=three
            pattern[4]=four
            Pattern[5]=Five
            Pattern[6]=Six
            Pattern[7]=Seven
            pattern[8]=eight
            pattern[9]=Nine
            pattern[10]=Punto
            
        pause 500
    DumpCustChar:
        addr=0
        char=0
        repeat
            lcdout char
            reaDCODE custchar+addr,char
            addr=addr+1
            until char=eol
    
    Main:  
        countera=0
        repeat
            offset=0
            lcdout comm,clr
            counterb=3
            repeat
                number=countera dig counterb
                gosub displaynumber
                counterb=counterb-1
                until counterb=255
            pause 10
            countera=countera+1
            until countera>9999
            goto main
    
    DisplayNumber:
        actualline=0
        index=0
        lcdout comm,line[actualline]+offset
        Loop:
            readcode pattern[number]+index,char
            if char!=eol then 
                if actualline<4 then
                    lcdout char
                    else
                        offset=offset+char
                        Goto GetOut
                    endif
                else
                    actualline=actualline+1
                    if actualline<4 then lcdout comm,line[actualline]+offset
                endif
            index=index+1
            goto loop
        GetOut:
            RETURN
    Last edited by mister_e; - 4th January 2007 at 00:41.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  14. #14
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK everybody, the code shrinking competition start RIGHT NOW!
    Aww Rats,
    An optimization contest and I missed it.

    Oh well, How could I possibly beat a program with so many DT's in it
    <br>
    DT

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's some DT's... wich are some DT's tricks... by DT itself

    Oh sure there's still other ways... Some DT's could be changed with DA but must develop a different approach. Internal EEPROM.. sir'84 64 Bytes, F877... DOH! seems i missed it 256 Bytes ... OK! OK!

    The challenge is with the complicated 16F84A,Not sure if it turns me on..

    BUT... Oh Darrel... This is a perfect situation to know if those you have on hand works
    Last edited by mister_e; - 4th January 2007 at 04:42.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    OK, a bit better, but there's still place for improvement
    486 words
    Code:
    DEFINE LOADER_USED 1
    Define OSC 4
    DEFINE LCD_DREG PORTD     ' LCD data port 
    DEFINE LCD_DBIT 4         ' LCD data starting bit 0 or 4 
    DEFINE LCD_RSREG PORTD    ' LCD register select port 
    DEFINE LCD_RSBIT 2        ' LCD register select bit 
    DEFINE LCD_EREG PORTD     ' LCD enable port 
    DEFINE LCD_EBIT 3         ' LCD enable bit 
    DEFINE LCD_BITS 4         ' LCD bus size 4 or 8 
    DEFINE LCD_LINES 4        ' Number lines on LCD 
    DEFINE LCD_COMMANDUS 2000 ' Command delay time in us 
    DEFINE LCD_DATAUS 50      ' Data delay time in us 
    
        Clr     CON 1
        Comm    con $FE
        EOL     con $FC
        Dx      con $14
        Line    var byte[4]
            line[0]=$80
            line[1]=$C0
            line[2]=$94
            line[3]=$D4
    
        Zero    data 5,0,0,4,EOL
                data $FF,Comm,Dx,Comm,Dx,$FF,EOL
                data $FF,Comm,Dx,Comm,Dx,$FF,EOL
                data 2,1,1,3,EOL
                data 5
        
        One     data Comm,Dx,5,$ff,EOL
                data Comm,Dx,Comm,Dx,$ff,EOL
                data Comm,Dx,Comm,Dx,$ff,EOL
                data Comm,Dx,Comm,Dx,$ff,EOL
                data 5;3
        
        Two     data 0,0,0,4,EOL
                data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
                data 5,0,0,0,EOL
                data $ff,1,1,1,EOL
                data 5
              
        Three   data 0,0,0,4,EOL
                data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
                data Comm,Dx,0,0,$ff,EOL
                data 1,1,1,3,EOL
                data 5    
        
        Four    data $ff,Comm,Dx,Comm,Dx,$FF,EOL
                data $ff,Comm,Dx,Comm,Dx,$ff,EOL
                data 0,0,0,$ff,EOL
                data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
                data 5    
        
        Five    data $FF,0,0,0,EOL
                data $ff,EOL
                data 0,0,0,4,EOL
                data 1,1,1,3,EOL
                data 5    
        
        Six     data 5,0,0,EOL
                data $ff,EOL
                data $ff,0,0,4,EOL
                data 2,1,1,3,EOL
                data 5    
        
        Seven   data 0,0,0,4,EOL
                data Comm,Dx,Comm,Dx,comm,dx,$ff,EOL
                data Comm,Dx,Comm,Dx,comm,dx,$ff,EOL
                data Comm,Dx,Comm,Dx,Comm,Dx,$ff,EOL
                data 5    
                
        Eight   data 5,0,0,4,EOL
                data 2,1,1,3,EOL
                data 5,0,0,4,EOL
                data 2,1,1,3,EOL
                data 5
        
        Nine    data 5,0,0,4,EOL
                data 2,1,1,$ff,EOL
                data Comm,Dx, Comm,Dx,Comm,Dx,$ff,EOL
                data Comm,Dx,1,1,3,EOL
                data 5
                        
        Punto   data EOL
                data EOL
                data EOL
                data 7,EOL
                data 2
    
        offset      var byte 
        index       var byte 
        Char        var byte 
        ActualLine  var byte 
        CounterA    var word 
        CounterB    var byte 
        Number      var byte 
        Pattern     var word[11]
            pattern[0]=zero
            pattern[1]=one
            Pattern[2]=two
            pattern[3]=three
            pattern[4]=four
            Pattern[5]=Five
            Pattern[6]=Six
            Pattern[7]=Seven
            pattern[8]=eight
            pattern[9]=Nine
            pattern[10]=Punto
            
        pause 500
    DumpCustChar:
        index=0
        repeat
            lookup index,[Comm,64,31,31,31,31,0,0,0,0,_      ; Cust Char #0  
                          Comm,72,0,0,0,0,31,31,31,31,_      ; Cust Char #1  
                          Comm,80,31,31,31,15,7,3,1,0,_      ; Cust Char #2  
                          Comm,88,31,31,31,30,28,24,16,0,_   ; Cust Char #3  
                          Comm,96,0,16,24,28,30,31,31,31,_   ; Cust Char #4  
                          Comm,104,0,1,3,7,15,31,31,31,_     ; Cust Char #5  
                          Comm,112,31,31,31,31,31,31,31,31,_ ; Cust Char #6  
                          Comm,120,0,0,0,14,31,31,31,14],char; Cust Char #7  
            lcdout char
            index=index+1
            until index=80
    
    Main:  
        countera=0
        repeat
            offset=0
            lcdout comm,clr
            counterb=3
            repeat
                number=countera dig counterb
                gosub displaynumber
                counterb=counterb-1
                until counterb=255
            pause 10
            countera=countera+1
            until countera=10000
            goto main
    
    DisplayNumber:
        actualline=0
        index=0
        lcdout comm,line[0]+offset
        Loop:
            read pattern[number]+index,char
            if char!=eol then 
                if actualline<4 then
                    lcdout char
                    else
                        offset=offset+char
                        Goto GetOut
                    endif
                else
                    actualline=actualline+1
                    if actualline<4 then lcdout comm,line[actualline]+offset
                endif
            index=index+1
            goto loop
        GetOut:
            RETURN
    No more asm lines... still nice... but as i said, still place for improvement.
    Last edited by mister_e; - 4th January 2007 at 05:51.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    I combined a few of your lcdout statement into gosub's. See how much (if any) code space that saves/uses.
    Your code is 1162 words instead of 1324 on 16F648A.
    Last edited by erpalma; - 4th January 2007 at 11:28.

  18. #18
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    It's really bad the poor 16F84A don't support some interesting MPASM feature. Well i admit that i discovered this totally at the end... anyways, here's something 532 Bytes working on a 16F877

    I'll try your own... and see how much i could Shrink it to do the same thing. Forgive me, i won't try with a 16F84A
    Your code is wonderful! Now I'm going to understand it! This is one of my first programs with pics! I have so much to learn! Assembly for example is still far away from me! And I need to experiment all the features of picbasic! I'd like to learn something more about eeprom code storage (not in 16f84a )!

  19. #19
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I need a little more help (temp display is now working!) to go on with my project! I need to do a kind of "menu" with a push button. On push I need to change the reading on the display so i need to change the execution. But I need to do it in a cycle, like:
    Temp1 - temp2 - temp3 - voltage - temp1 - temp2...

    How can I do? It's so simple, I know!

    Thanks!

    --EDIT

    It's better to do it with an Interrupt, not a loop.

  20. #20
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

  21. #21
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You could still use an internal Timer/Counter. Let's say RA.4/T0CKI. and poll the TMR0 register value, then use Branch...
    Code:
    IF TMR0>AmountOfRoutine then TMR0=0
    BRANCH TMR0,[Routine0, Routine1,Routine....]
    The count will be done in background.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  22. #22
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    You could still use an internal Timer/Counter. Let's say RA.4/T0CKI. and poll the TMR0 register value, then use Branch...
    Code:
    IF TMR0>AmountOfRoutine then TMR0=0
    BRANCH TMR0,[Routine0, Routine1,Routine....]
    The count will be done in background.
    Could you explain me better this solution? Actually I've solved using a non-background count.

    Do you know a tutorial or a guide to help me understand Timers/Couters in PBP? TNX!
    Last edited by erpalma; - 5th January 2007 at 22:02.

  23. #23
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Update

    Code:
    '	@ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT  	   ' System Clock Options	
    	@ DEVICE pic16F648A, HS_OSC  	   ' System Clock Options	
    
        @ DEVICE pic16F648A, WDT_OFF	   ' Watchdog Timer
    	@ DEVICE pic16F648A, PWRT_ON	   ' Power-On Timer
    	@ DEVICE pic16F648A, BOD_ON       ' Brown-Out Detect
    	@ DEVICE pic16F648A, MCLR_ON	   ' Master Clear Options (Internal)
    	@ DEVICE pic16F648A, LVP_OFF	   ' Low-Voltage Programming
    	@ DEVICE pic16F648A, CPD_OFF       ' Data Memory Code Protect
    	@ DEVICE pic16F648A, PROTECT_OFF   ' Program Code Protection
    
    
    DEFINE OSC 12
    define LCD_LINES 4
    
    Clr             CON 1
    Comm            Con $FE
    LINE1           con 2
    LINE2           con $c0
    LINE3           con $94
    LINE4           con $d4
    Offset          VAR BYTE
    OffsetP         var byte
    Interi          var word
    Decimali_Temp   VAR word
    Temporaneo      var byte
    Valore          VAR byte
    i               var byte
    n               var byte
    Sign            VAR BYTE
    DQ              var portb.1
    Recorded_Temp   var word
    Dummy           var WORD
    Decimali        var BYTE
    Resto           var WORD
    Stat            var bit
    Cold_Bit        VAR Recorded_Temp.Bit11
    Real_Cold       CON 1           
    MyButton        var portb.0
    LongPress       con 50		
    RPM_Port        var portb.2
    RPM             var WORD
    ButtonPress     var word
    x               var byte : x = -1
    
        Mybutton = 1            
        CMCON=%00000111			' Comparators OFF
    	OPTION_REG.7=0			' Enable weak Pull-Ups (used for PressButton)
    
    Begin:
            Pause 500   
            LCDOUT  254,64,31,31,31,31,0,0,0,0       ' Cust Char #0  
            LCDOUT  254,72,0,0,0,0,31,31,31,31       ' Cust Char #1  
            LCDOUT  254,80,31,31,31,15,7,3,1,0       ' Cust Char #2  
            LCDOUT  254,88,31,31,31,30,28,24,16,0    ' Cust Char #3  
            LCDOUT  254,96,0,16,24,28,30,31,31,31    ' Cust Char #4  
            LCDOUT  254,104,0,1,3,7,15,31,31,31      ' Cust Char #5
            'LCDOUT  254,112,31,31,31,31,31,31,31,31  ' Cust Char #6   
            LCDOUT  254,120,0,0,0,0,12,30,30,12      ' Cust Char #7    
        
    Main:
        goto menu
    end       
    
    Elaborazione:
            IF cold_bit = real_cold then Elaborazione_Freddo
            sign = "+"
            gosub elaborazione_common
    return
    
    Elaborazione_Common:
            Dummy  = 625 * recorded_Temp
            Interi = div32 10
            Interi  = (Recorded_Temp & $0FF0) >> 4
            Decimali_Temp = ((Recorded_Temp.Lowbyte & $0F) * 625)
            Decimali = Decimali_Temp / 100
            Resto = Decimali_Temp // 100
            if (resto >= 50) then Decimali = Decimali + 1
    return
    
    Elaborazione_Freddo:
            Sign   = "-"            
            RECORDED_TEMP = ~recorded_Temp + 1
            gosub elaborazione_common
    return
    
    Visualizzazione:
            select case Interi
                case is < 10
                    GOSUB SEGNO
                    n = 0 
                    OFFSET = 5
                    Valore = Interi
                    gosub Cifre 
                    OffsetP = 5 
                    Gosub Punto
                    N = 1
                    OFFSET = 10
                    Valore = Decimali
                    GOSUB Cifre
                case is < 100
                    offset = 0
                    n = 1 
                    Valore = Interi
                    gosub Cifre
                    OffsetP = 5
                    gosub Punto
                    N = 1
                    OFFSET = 10
                    Valore = Decimali
                    GOSUB Cifre
                case is < 200
                    offset = 0
                    n = 2 
                    Valore = Interi
                    gosub Cifre
                    offsetP = 10
                    gosub Punto
                    N = 0
                    OFFSET = 15
                    decimali_temp = decimali
                    Decimali_temp = Decimali / 10
                    Resto = Decimali // 10
                    Decimali = Decimali_temp
                    if (resto >= 5) then Decimali = Decimali + 1 
                    Valore = Decimali
                    GOSUB Cifre
                case is < 1000 
                    offset = 0
                    n = 2 
                    Valore = Interi
                    gosub Cifre
                case else 
                    offset = 0
                    n = 3
                    valore = RPM
                    gosub Cifre
                end select    
    RETURN
    
    Segno:
            SELECT CASE SIGN
                 CASE "+"
                    lcdout comm, $C2, $01, $FF, $01
                    LCDOUT COMM, $96, $00, $FF, $00
                 CASE "-"
                    lcdout comm, $C2, $01, $01, $01
                    LCDOUT COMM, $96, $00, $00, $00 
            END SELECT
    RETURN
    
    Cifre:
           For I = N to 0 STEP -1
            Temporaneo = Valore dig i 
            select case Temporaneo
                case 0 
                    gosub Numero0
                case 1 
                    gosub Numero1
                case 2 
                    gosub Numero2
                case 3 
                    gosub Numero3
                case 4 
                    gosub Numero4
                case 5 
                    gosub Numero5
                case 6 
                    gosub Numero6
                case 7 
                    gosub Numero7
                case 8
                    gosub Numero8
                case 9 
                    gosub Numero9
            end select
            OFFSET = OFFSET + 5
           next I
    return 
    
    GetButton:
    	ButtonPress=0
    	While MyButton=0
    		If ButtonPress<255 then ButtonPress=ButtonPress+1
    		Pause 50 ' This is also our Debounce value
    	Wend
    	If ButtonPress>0 then
    		If ButtonPress=>LongPress then 
    			ButtonPress=2
    		else
                buttonpress = 1	
            endif
        endif
    Return
    
    Bottone:
        gosub getbutton
        if buttonpress = 1 then goto Menu
    return
    
    Temp_Wait:
        GOSUB BOTTONE
        owin dq, 4, [Stat]
            If stat = 0 then Temp_Wait
    return
    
    Menu:
        x = x + 1
        IF x > 5 then x = 0 
        branchl x,[Sommario,Oil_temp,h2o_temp,ext_temp,int_temp,rpm_window]
    return
    
    Temps_Common:
        owin dq, 2, [Recorded_Temp.LOWBYTE,Recorded_Temp.HIGHBYTE]    
        gosub Elaborazione
        gosub visualizzazione    
    return
        
    Sommario:
        gosub bottone
        gosub clrscr
        lcdout "Sommario"
        pause 100
    goto sommario
    
    RPM_Window:
        gosub bottone
        gosub clrscr
    '    gosub Rpm_Count
    '    interi = RPM
    '    gosub visualizzazione
        lcdout "RPM_Window"
        pause 100
    goto rpm_window
    
    H2O_Temp:
            Owout DQ, 1, [$55,$28,$09,$B4,$F5,$00,$00,$00,$28,$44]
            gosub temp_wait
            owout dq, 1, [$55,$28,$09,$B4,$F5,$00,$00,$00,$28,$BE]        
        gosub clrscr
        LCDOUT comm, line1, "T", COMM, LINE2, "H", COMM, LINE3, "2", COMM, LINE4, "0"
        gosub temps_common
    goto h2o_temp
    
    Int_Temp:
        gosub bottone
        gosub clrscr
        sign = "+"
        Interi = 4
        decimali = 73
        gosub visualizzazione
        pause 100
    goto int_temp
    
    Ext_Temp:
        gosub bottone
        gosub clrscr
        Sign = "-"
        Interi = 9
        decimali = 24
        gosub visualizzazione
        pause 100
    goto ext_temp
    
    Oil_Temp:
            Owout DQ, 1, [$55,$28,$87,$8B,$F5,$00,$00,$00,$3A,$44]
            gosub temp_wait
            owout dq, 1, [$55,$28,$87,$8B,$F5,$00,$00,$00,$3A,$BE]          
        gosub clrscr
        LCDOUT comm, line1, "T", COMM, LINE2, "O", COMM, LINE3, "I", COMM, LINE4, "L"
        gosub temps_common
    goto oil_Temp 
    
    Rpm_Count:
        COUNT RPM_PORT, 500, RPM
        RPM = RPM * 2
    RETURN 
    
    Punto:
            LCDOUT Comm, ($D9 + OFFSET), $07 : return
    Numero0:
            LCDOUT COMM, ($81 + OFFSET), $05, $FF, $FF, $04
            GOSUB COMBO1
            LCDOUT COMM, ($95 + OFFSET), $FF, COMM, ($98 + OFFSET), $FF
            LCDOUT COMM, ($D5 + OFFSET), $02, $FF, $FF, $03
            RETURN
    Numero1:
            lcdout comm, ($82 + OFFSET), $05, $FF
            lcdout comm, ($C3 + OFFSET), $FF
            lcdout comm, ($97 + OFFSET), $FF
            lcdout comm, ($D7 + OFFSET), $FF        
            RETURN
    Numero2:
            GOSUB COMBO2
            LCDOUT comm, ($C4 + OFFSET), $FF
            LCDOUT comm, ($95 + OFFSET), $05, $00, $00, $00
            LCDOUT comm, ($D5 + OFFSET), $FF, $01, $01, $01
            RETURN
    Numero3:
            GOSUB COMBO2
            LCDOUT comm, ($C2 + OFFSET), $01, $01, $FF
            LCDOUT comm, ($96 + OFFSET), $00, $00, $FF
            GOSUB COMBO3
            RETURN 
    Numero4:
            lcdout comm, ($81 + OFFSET), $FF
            GOSUB COMBO1
            GOSUB COMBO4
            GOSUB COMBO5
            return      
    Numero5:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $00
            GOSUB COMBO6
            GOSUB COMBO4
            GOSUB COMBO3
            RETURN    
    Numero6:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00
            GOSUB COMBO6
            LCDOUT COMM, ($95 + OFFSET), $FF, $00, $00, $04
            GOSUB COMBO7
            RETURN
    Numero7:
            GOSUB COMBO2
            LCDOUT COMM, ($C3 + OFFSET), $01, $FF
            LCDOUT COMM, ($97 + OFFSET), $00, $FF
            GOSUB COMBO5
            RETURN
    Numero8:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $03
            LCDOUT COMM, ($95 + OFFSET), $05, $00, $00, $04
            GOSUB COMBO7
            RETURN       
    Numero9:
            GOSUB COMBO8
            LCDOUT COMM, ($C1 + OFFSET), $02, $01, $01, $FF
            GOSUB COMBO5
            LCDOUT COMM, ($D6 + OFFSET), $01, $01, $03
            RETURN
    COMBO1:
            LCDOUT COMM, ($C1 + OFFSET), $FF, COMM, ($C4 + OFFSET), $FF
            RETURN
    COMBO2:
            LCDOUT comm, ($81 + OFFSET), $00, $00, $00, $04
            RETURN
    COMBO3:
            LCDOUT comm, ($D5 + OFFSET), $01, $01, $01, $03
            RETURN
    COMBO4:
            LCDOUT comm, ($95 + OFFSET), $00, $00, $00, $FF
            RETURN
    COMBO5:
            LCDOUT comm, ($D8 + OFFSET), $FF
            RETURN
    COMBO6:
            LCDOUT COMM, ($C1 + OFFSET), $FF
            RETURN
    COMBO7:
            LCDOUT COMM, ($D5 + OFFSET), $02, $01, $01, $03
            RETURN
    COMBO8:
            LCDOUT COMM, ($81 + OFFSET), $05, $00, $00, $04
            RETURN
    Clrscr:
        lcdout comm, clr
    return

  24. #24
    Join Date
    Jan 2007
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    I'm still far away from the final code. This is an alpha release . The code is not optimized (~2200 words). Many sections are incomplete (RPM, INT_Temp, Ext_Temp, Clock....), but day by day this little project grow up!

Similar Threads

  1. Only the first 8 characters.
    By timseven in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd September 2009, 01:43
  2. Big big big memory or tiny SDs!
    By Ron Marcus in forum Off Topic
    Replies: 9
    Last Post: - 25th May 2007, 18:02
  3. Led scrolling display: How to mirror characters?
    By mahia2005 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th May 2007, 03:25
  4. LCD 16 characters inline: only first 8 work
    By Mugel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th October 2006, 22:07
  5. LCD 4x20 HD44780
    By inteco in forum mel PIC BASIC
    Replies: 13
    Last Post: - 27th June 2006, 16:52

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