​ ​ ​ ​ Picaxe Tron
Results 1 to 4 of 4

Thread: Picaxe Tron

  1. #1
    Senior Member
    Join Date
    Sep 2016
    Location
    United Kingdom
    Posts
    687

    Default Picaxe Tron

    Messing round with a diddy oled and thought let's do space invaders but too slow, so here's badly filmed Tron.
    I needed a 28x2 because it need 1K for the graphics..if you could call them that.
    There's a deliberate flaw in the picaxes control or it would be impossible to beat unless it ran out of space. It's hard anyway any way. I won once in the video. https://youtu.be/cL46P2ywqKk

  2. #2
    Senior Member
    Join Date
    Sep 2016
    Location
    United Kingdom
    Posts
    687

    Default

    Here's a better video and the code in parts. https://www.youtube.com/watch?v=gGenryUZBa4
    Code:
    ;128x64 oled working 7/11/16
    ;game added 8/2/17
    #picaxe 28x2
    setfreq em64
    ;b52 to b55 used
    symbol x1=b0 ;line variables
    symbol x2=b1
    symbol y1=b2
    symbol y2=b3
    symbol px=b4
    symbol py=b5
    symbol sx=b6
    symbol sy=b7
    symbol dx=b8
    symbol dy=b9
    symbol pixel=b10
    symbol er=w6
    symbol e2=w7
    ;
    SYMBOL  DispNum  = W8 ;print variables
    SYMBOL  row = b18
    SYMBOL  col = b19
    SYMBOL  temp  =b20
    SYMBOL  aByte =b21
    SYMBOL  index = b22
    ;game added
    symbol temp1=b23 ;game variables
    symbol temp2=b24
    symbol x1d=b25
    symbol y1d=b27
    symbol x1p=b28
    symbol y1p=b29
    symbol pset=b30
    symbol x2d=b31
    symbol y2d=b32
    symbol x2p=b33
    symbol y2p=b34
    symbol tx=b35
    symbol ty=b36
    ;
    SYMBOL TWI_BUFFER_LENGTH 		= 32 ;oled control codes	
    SYMBOL SSD1306_LCDWIDTH   		= 128
    SYMBOL SSD1306_LCDHEIGHT            = 64
    SYMBOL SSD1306_SETCONTRAST 		=0x81
    SYMBOL SSD1306_DISPLAYALLON_RESUME 	=0xA4
    SYMBOL SSD1306_DISPLAYALLON 		=0xA5
    SYMBOL SSD1306_NORMALDISPLAY 		=0xA6
    SYMBOL SSD1306_INVERTDISPLAY 		=0xA7
    SYMBOL SSD1306_DISPLAYOFF 		=0xAE
    SYMBOL SSD1306_DISPLAYON 		=0xAF	
    SYMBOL SSD1306_SETDISPLAYOFFSET 	=0xD3
    SYMBOL SSD1306_SETCOMPINS 		=0xDA	
    SYMBOL SSD1306_SETVCOMDETECT 		=0xDB	
    SYMBOL SSD1306_SETDISPLAYCLOCKDIV 	=0xD5
    SYMBOL SSD1306_SETPRECHARGE 		=0xD9
    SYMBOL SSD1306_SETMULTIPLEX 		=0xA8	
    SYMBOL SSD1306_SETLOWCOLUMN 		=0x00
    SYMBOL SSD1306_SETHIGHCOLUMN 		=0x10
    SYMBOL SSD1306_SETSTARTLINE 		=0x40
    SYMBOL SSD1306_MEMORYMODE 		=0x20
    SYMBOL SSD1306_COLUMNADDR 		=0x21
    SYMBOL SSD1306_PAGEADDR   		=0x22		; Page 0-7 represents line 0 - 7
    SYMBOL SSD1306_COMSCANINC 		=0xC0
    SYMBOL SSD1306_COMSCANDEC 		=0xC8
    SYMBOL SSD1306_SEGREMAP 		=0xA0 | 1
    SYMBOL SSD1306_CHARGEPUMP 		=0x8D
    SYMBOL SSD1306_EXTERNALVCC 		=0x1
    SYMBOL SSD1306_SWITCHCAPVCC 		=0x2
    ;Scrolling SYMBOLs
    SYMBOL ACTIVATE_SCROLL 				=0x2F
    SYMBOL DEACTIVATE_SCROLL 			=0x2E
    SYMBOL SET_VERTICAL_SCROLL_AREA 		=0xA3
    SYMBOL RIGHT_HORIZONTAL_SCROLL 		=0x26
    SYMBOL LEFT_HORIZONTAL_SCROLL 		=0x27
    SYMBOL VERT_AND_RIGHT_HORIZONTAL 		=0x29
    SYMBOL VERT_AND_LEFT_HORIZONTAL 		=0x2A   
    ;;**************************************************************   
    SYMBOL  SSD1306_ADDR  = $3C << 1    ; this is the I2C address ($78)
    ;------------------------------
    main:
    dirsb=%00001111
    gosub InitialiseLcd
    gosub clearbuffer
    gosub ClearDisplay
    ;
    let row=5:let col=6:gosub setposition
    eeprom 31, ("PRESS A BUTTON")
    for index = 31 TO 44
    	read index,aByte
    	gosub displayChar
    next index
    do while pinsb=0:random w25:gosub sine:loop ;wait for button press
    gosub clearbuffer
    gosub ClearDisplay
    ;
    ;draw boarder
    x1=0:y1=0:x2=127:y2=0:gosub line
    x1=0:y1=63:x2=127:y2=63:gosub line
    x1=0:y1=0:x2=0:y2=63:gosub line
    x1=127:y1=0:x2=127:y2=63:gosub line
    ;
    ;plot a dot at random y left and right to make picaxe not follow border
    px=1:py=b50/8+16:gosub plot2screenram ;left dot ; must sort out
    random w25
    px=126:py=b50/8+16:gosub plot2screenram ;right dot
    ;random w25 ;optional dots to deflect picaxe
    ;py=1:px=b50/4+32:gosub plot2screenram ;top dot
    ;random w25
    ;py=62:px=b50/4+32:gosub plot2screenram ;bottom dot
    
    ;define start positions and directions
    random w25:y1p=b50/8+16
    random w25:y2p=b50/8+16
    x1p=90:x1d=255:y1d=0:px=x1p:py=y1p:gosub plot2screenram ; plot player
    x2p=30:y2p=40:x2d=1:y2d=0:px=x1p:py=y1p:gosub plot2screenram ; plot picaxe
    start:
    ;
    ;testkeys
    b50=pinsb and 240
    if b50=16 then ;up key pressed
    	x1d=0:y1d=255
    elseif b50=32 then ;down key pressed
    	x1d=0:y1d=1
    elseif b50=64 then ;left key pressed
    	x1d=255:y1d=0
    else if b50=128 then ;right key pressed
    	x1d=1:y1d=0
    endif
    x1p=x1p+x1d:y1p=y1p+y1d ;player direction 
    ;
    ;test pixel ahead
    if x1d=1 then:tx=x1p+1:ty=y1p ;going right
    elseif x1d=255 then:tx=x1p-1:ty=y1p	;going left
    elseif y1d=1 then:ty=y1p+1:tx=x1p ;going down
    else ty=y1p-1:tx=x1p ;going up
    endif
    gosub point
    if pset=0 then:goto player_not_crashed:endif ;no object ahead
    ;
    gosub flashscreen
    gosub clearbuffer
    gosub ClearDisplay
    row=3:col=10:gosub setposition
    eeprom 84, ("YOU LOST")
    for index = 84 TO 91
    	read index,aByte
    	gosub displayChar;
    next index
    pause 4:goto main
    ;
    player_not_crashed:
    px=x1p:py=y1p:gosub plot2screenram ;plot player
    ;
    ;**** picaxe manouver ****
    x2p=x2p+x2d:y2p=y2p+y2d ;picaxe diection
    if x2d=1 then ;going right
    	tx=x2p+1:ty=y2p
    	gosub point
    	if pset>0 then ;object ahead..change direction
    		x2d=0
    		if y1p>=y2p then
    			y2d=1
    		else y2d=255
    		endif
    	endif:goto picaxe_crash_test
    elseif x2d=255 then ;going left
    	tx=x2p-1:ty=y2p
    	gosub point
    	if pset>0 then ;object ahead..change direction
    		x2d=0
    		if y1p>=y2p then
    			y2d=1
    		else y2d=255
    		endif
    	endif:goto picaxe_crash_test	
    endif	
    if y2d=1 then ;going down
    	tx=x2p:ty=y2p+1
    	gosub point
    	if pset>0 then ;object ahead..change direction
    		y2d=0
    		if x1p>=x2p then
    			x2d=1
    		else x2d=255
    		endif:goto picaxe_crash_test
    	endif
    elseif y2d=255 then ;going up
    	tx=x2p:ty=y2p-1
    	gosub point
    	if pset>0 then ;object ahead..change direction
    		y2d=0
    		if x1p>=x2p then
    			x2d=1
    		else x2d=255
    		endif:goto picaxe_crash_test
    	endif	
    endif		
    picaxe_crash_test:
    tx=x2p:ty=y2p:gosub point ;has picaxe crashed?
    if pset=0 then:goto plotpicaxe:endif ;not crashed
    ;picaxe crashed...on purpose
    gosub flashscreen
    gosub clearbuffer
    gosub ClearDisplay
    row = 3:col = 10:gosub setposition
    eeprom 77, ("YOU WIN")
    for index = 77 TO 83
    	read index,aByte
    	gosub displayChar;
    next index
    pause 4:goto main
    plotpicaxe:
    px=x2p:py=y2p:gosub plot2screenram ; plot picaxe
    goto start
    ;************************* end of game code *************************************************************
    Last edited by stan74; 11-02-2017 at 04:10.

  3. #3
    Senior Member
    Join Date
    Sep 2016
    Location
    United Kingdom
    Posts
    687

    Default

    rest of the code
    Code:
    flashscreen:
    for temp=1 to 20
    hi2cout (0,SSD1306_INVERTDISPLAY)
    pause 10
    hi2cout (0,SSD1306_NORMALDISPLAY)
    next temp
    return
    point:
    pixel=ty And 7; pixel position
    ptr=ty And $F8<<4 Or tx
    pset=1<<pixel and @ptr ; pixel
    return
    ; spare ram 56 to 255
    ;----------------------------------------------------------------
    ClearDisplay: ;clears oled screen
    hi2cout (0,SSD1306_PAGEADDR)
    hi2cout (0,0) ;set row=0
    hi2cout (0,7)
    ;	
    hi2cout (0,SSD1306_COLUMNADDR)
    hi2cout (0,0) ;set column=0
    hi2cout (0,127)
    ;
    for ptr=0 to 1023
    	hi2cout (64,0)
    next ptr
    ;
    return
    clearbuffer:
    for ptr=0 to 1023
    	@ptr=0
    next ptr
    return
    sendbuffer:
    hi2cout (0,SSD1306_PAGEADDR)
    hi2cout (0,0) ;set row=0
    hi2cout (0,7)
    ;	
    hi2cout (0,SSD1306_COLUMNADDR)
    hi2cout (0,0) ;set column=0
    hi2cout (0,127)
    ;
    for ptr=0 to 1023
    	hi2cout (64,@ptr);,64,@ptrinc,64,@ptrinc,64,@ptrinc,64,@ptrinc,64,@ptrinc,64,@ptrinc,64,@ptrinc)
    next ptr
    return
    plot2screenram:
    pixel=py and 7
    ptr=py and $F8<<4 Or px
    @ptr=1<<pixel Or @ptr ;in buffer
    ;
    let row=py>>3
    hi2cout (0,SSD1306_PAGEADDR)
    hi2cout (0,row)
    hi2cout (0,7)
    hi2cout (0,SSD1306_COLUMNADDR)
    hi2cout (0,px)
    hi2cout (0,127)
    hi2cout (64,@ptr) ;oled screen byte
    return
    xorplot2screenram:
    pixel=py And 7
    ptr=py And $F8<<4 Or px
    @ptr=1<<pixel xor @ptr ;in buffer
    ;
    row=py>>3
    hi2cout (0,SSD1306_PAGEADDR)
    hi2cout (0,row)
    hi2cout (0,7)
    hi2cout (0,SSD1306_COLUMNADDR)
    hi2cout (0,px)
    hi2cout (0,127)
    hi2cout (64,@ptr) ;oled screen byte
    return
    plot2buffer:
    pixel=py And 7; pixel position
    ptr=py And $F8<<4 Or px
    @ptr=1<<pixel Or @ptr ; screen byte in buffer
    return
    line:
    if x1<x2 then:sx=1:dx=x2-x1:else sx=-1:dx=x1-x2:endif
    if y1<y2 then :sy=1:dy=y2-y1:else sy=-1:dy=y1-y2:endif
    if dx>dy then:er=dx:else er=dy:endif
    dx=dx+dx:dy=dy+dy:py=y1:px=x1
    if dx>dy then
    	do
    ;gosub plot2screenram
    		pixel=py And 7
    		ptr=py And $F8 << 4 Or px
    		@ptr=1<<pixel Or @ptr 
    		row=py>>3
    		hi2cout (0,SSD1306_PAGEADDR)
    		hi2cout (0,row)
    		hi2cout (0,7)
    		hi2cout (0,SSD1306_COLUMNADDR)
    		hi2cout (0,px)
    		hi2cout (0,127)
    		hi2cout (64,@ptr)
    ;
    		er=er-dy
    		if er>32767 then
    			er=er+dx:py=py+sy 
    		endif
    		px=px+sx
    	loop while px<>x2
    else
    	do
    ;gosub plot2screenram			
    		pixel=py And 7
    		ptr=py And $F8 << 4 Or px
    		@ptr=1<<pixel Or @ptr ; screen byte
    		row=py>>3
    		hi2cout (0,SSD1306_PAGEADDR)
    		hi2cout (0,row)
    		hi2cout (0,7)
    		hi2cout (0,SSD1306_COLUMNADDR)
    		hi2cout (0,px)
    		hi2cout (0,127)
    		hi2cout (64,@ptr) ;plot pixel on screen
    ;
    		er=er-dx
    		if er>32767 then
    			er=er+dy:px=px+sx
    		endif
    		py=py+sy		
    	loop while py<>y2
    endif
    return
    xorline:
    if x1<x2 then:sx=1:dx=x2-x1:else sx=-1:dx=x1-x2:endif
    if y1<y2 then:sy=1:dy=y2-y1:else sy=-1:dy=y1-y2:endif
    if dx>dy then:er=dx:else er=dy : endif
    dx=dx+dx:dy=dy+dy:py=y1:px=x1
    if dx>dy then
    	do
    		gosub xorplot2screenram
    		er=er-dy
    		if er>32767 then
    			er=er+dx:py=py+sy 
    		endif
    		px=px+sx
    	loop while px<>x2
    else
    	do
    		gosub xorplot2screenram			
    		er=er-dx
    		if er>32767 then
    			er=er+dy:px=px+sx
    		endif
    		py=py+sy		
    	loop while py<>y2
    endif
    return
    sine:
    eeprom 46, (34,40,46,50,54,58,60,62,62,60,58,54,50,46,40,34,28,22,18,14,10,8,6,6,8,10,14,18,22,28,34)
    x1=0
    read 46,y1:y1=y1/2
    for temp2=1 to 2
    for temp1 = 47 to 76
    read temp1,y2
    y2=y2/2
    x2=x1+2
    gosub xorline
    x1=x2
    y1=y2
    next temp1
    next temp2
    return
    InitialiseLcd:	
    PAUSE 500
    i2cslave SSD1306_ADDR, i2cfast_64, i2cbyte
    	
    for index = 0 TO 23
    	read index,aByte
    	hi2cout (0,aByte)
    next
    		
    eeprom 0, (SSD1306_DISPLAYOFF);                   ; 0xAE
    eeprom 1, (SSD1306_SETDISPLAYCLOCKDIV);           ; 0xD5
    eeprom 2, (0x80);                                 ; the suggested ratio 0x80
    eeprom 3, (SSD1306_SETMULTIPLEX);                 ; 0xA8
    eeprom 4, (0x3F);
    eeprom 5, (SSD1306_SETDISPLAYOFFSET);             ; 0xD3
    eeprom 6, (0x0);                                  ; no offset
    eeprom 7, (SSD1306_SETSTARTLINE);            	  ; line #0
    eeprom 8, (SSD1306_CHARGEPUMP);                   ; 0x8Deeprom 9, (0x14
    eeprom 9, (0x14);						  ; INTERNAL VCC
    eeprom 10, (SSD1306_MEMORYMODE);                  ; 0x20
    eeprom 11, (0x00);                                ; Horiz mode. 0x0 act like ks0108
    eeprom 12, (SSD1306_SEGREMAP);
    eeprom 13, (SSD1306_COMSCANDEC);
    eeprom 14, (SSD1306_SETCOMPINS);                  ; 0xDA
    eeprom 15, (0x12);
    eeprom 16, (SSD1306_SETCONTRAST);                 ; 0x81
    eeprom 17, (0xCF)						  ; INTERNAL VCC
    eeprom 18, (SSD1306_SETPRECHARGE);                ; 0xd9
    eeprom 19, (0xF1)						  ; INTERNAL VCC
    eeprom 20, (SSD1306_SETVCOMDETECT);               ; 0xDB
    eeprom 21, (0x40);
    eeprom 22, (SSD1306_DISPLAYALLON_RESUME);         ; 0xA4
    eeprom 23, (SSD1306_DISPLAYON);                	  ; 0xA4	
    'eeprom 24, (SSD1306_DISPLAYALLON);               ; 0xA5          
    return

  4. #4
    Senior Member
    Join Date
    Sep 2016
    Location
    United Kingdom
    Posts
    687

    Default

    last bit
    Code:
    DirectSendCmd:
    ' Commands are preceeded by a 0 filled byte    
    hi2cout (0,abyte)   
    return
    ;SEND INIT CMD BYTE - SEND CMD BYTE - SEND DATA BYTE
    SetPosition:
    	'20 line x 4 rows is accompished by wrapping the text on each line past 20 characters to two lines down (not next line down). Position 20 (dec) is row 3, col 1
    abyte= SSD1306_PAGEADDR
    hi2cout (0,abyte)
    abyte = row
    hi2cout (0,abyte)
    abyte = 7
    hi2cout (0,abyte)
    	
    abyte= SSD1306_COLUMNADDR
    col = col * 5 ;columns per character
    hi2cout (0,abyte)
    abyte = col
    hi2cout (0,abyte)
    abyte = 127
    hi2cout (0,abyte)
    return
       
    	' STANDARD FONT
    
    	' This is the ASCII Font table 0 starting at space and ending at Z -- lower case is not included (not enough memory)
    	' The first 8 are in program direct writes
    
    	'table (0x00, 0x00, 0x00, 0x00, 0x00)	' Space
    	'table (0x00, 0x00, 0x5F, 0x00, 0x00)	' !
    	'table (0x00, 0x07, 0x00, 0x07, 0x00) 	' "
    	'table (0x14, 0x7F, 0x14, 0x7F, 0x14) 	' #
    	'table (0x24, 0x2A, 0x7F, 0x2A, 0x12) 	' $
    	'table (0x23, 0x13, 0x08, 0x64, 0x62) 	' %
    	'table (0x36, 0x49, 0x56, 0x20, 0x50) 	' &
    	'table (0x00, 0x08, 0x07, 0x03, 0x00) 	' '
    
    	table (0x00, 0x1C, 0x22, 0x41, 0x00) 	' (
    	table (0x00, 0x41, 0x22, 0x1C, 0x00) 	' )
    	table (0x2A, 0x1C, 0x7F, 0x1C, 0x2A) 	' *
    	table (0x08, 0x08, 0x3E, 0x08, 0x08) 	' +
    	table (0x00, 0x80, 0x70, 0x30, 0x00) 	' ,
    	table (0x08, 0x08, 0x08, 0x08, 0x08)	' -
      	table (0x00, 0x00, 0x5F, 0x00, 0x0)		' .
    	table (0x20, 0x10, 0x08, 0x04, 0x02)	' /
    	
    	table (0x3E, 0x51, 0x49, 0x45, 0x3E) 	' 0
    	table (0x00, 0x42, 0x7F, 0x40, 0x00)	; 1
    	table (0x72, 0x49, 0x49, 0x49, 0x46)
    	table (0x21, 0x41, 0x49, 0x4D, 0x33)
    	table (0x18, 0x14, 0x12, 0x7F, 0x10)
    	table (0x27, 0x45, 0x45, 0x45, 0x39)
    	table (0x3C, 0x4A, 0x49, 0x49, 0x31)
    	table (0x41, 0x21, 0x11, 0x09, 0x07)
    	table (0x36, 0x49, 0x49, 0x49, 0x36)
    	table (0x46, 0x49, 0x49, 0x29, 0x1E)
    	table (0x00, 0x00, 0x14, 0x00, 0x00)
    	table (0x00, 0x40, 0x34, 0x00, 0x00)
    	table (0x00, 0x08, 0x14, 0x22, 0x41)
    	table (0x14, 0x14, 0x14, 0x14, 0x14)
    	table (0x00, 0x41, 0x22, 0x14, 0x08)
    	table (0x02, 0x01, 0x59, 0x09, 0x06)
    	table (0x3E, 0x41, 0x5D, 0x59, 0x4E)
    	table (0x7C, 0x12, 0x11, 0x12, 0x7C)
    	table (0x7F, 0x49, 0x49, 0x49, 0x36)
    	table (0x3E, 0x41, 0x41, 0x41, 0x22)
    	table  (0x7F, 0x41, 0x41, 0x41, 0x3E)
    	table  (0x7F, 0x49, 0x49, 0x49, 0x41)
    	table  (0x7F, 0x09, 0x09, 0x09, 0x01)
    	table  (0x3E, 0x41, 0x41, 0x51, 0x73)
    	table  (0x7F, 0x08, 0x08, 0x08, 0x7F)
    	table  (0x00, 0x41, 0x7F, 0x41, 0x00)
    	table  (0x20, 0x40, 0x41, 0x3F, 0x01)
    	table  (0x7F, 0x08, 0x14, 0x22, 0x41)
    	table  (0x7F, 0x40, 0x40, 0x40, 0x40)
    	table  (0x7F, 0x02, 0x1C, 0x02, 0x7F)
    	table  (0x7F, 0x04, 0x08, 0x10, 0x7F)
    	table  (0x3E, 0x41, 0x41, 0x41, 0x3E)
    	table  (0x7F, 0x09, 0x09, 0x09, 0x06)
    	table  (0x3E, 0x41, 0x51, 0x21, 0x5E)
    	table  (0x7F, 0x09, 0x19, 0x29, 0x46)
    	table  (0x26, 0x49, 0x49, 0x49, 0x32)
    	table  (0x03, 0x01, 0x7F, 0x01, 0x03)
    	table  (0x3F, 0x40, 0x40, 0x40, 0x3F)
    	table  (0x1F, 0x20, 0x40, 0x20, 0x1F)
    	table  (0x3F, 0x40, 0x38, 0x40, 0x3F)
    	table  (0x63, 0x14, 0x08, 0x14, 0x63)
    	table  (0x03, 0x04, 0x78, 0x04, 0x03)
    	table  (0x61, 0x59, 0x49, 0x4D, 0x43)	; Z
    	
    
    DISPLAY_FONT:
    gosub cleardisplay
    eeprom 25, (SSD1306_COLUMNADDR)
    eeprom 26, (0)		;   			;Column start address (0 = reset)
    eeprom 27, (127)	 				;Column end address (127 = reset)
    eeprom 28, (SSD1306_PAGEADDR)
    eeprom 29, (0) 					;Page start address (0 = reset)
    eeprom 30, (7) 					;Page end address
    	
    for index = 25 TO 30
    	read index,aByte
    	hi2cout (0,abyte)
    next
    
    Writei2c (0x40, 	0x00, 0x07, 0x00, 0x07, 0x00)
    Writei2c (0x40,	0x14, 0x7F, 0x14, 0x7F, 0x14)
    Writei2c (0x40,	0x24, 0x2A, 0x7F, 0x2A, 0x12)
    Writei2c (0x40,	0x23, 0x13, 0x08, 0x64, 0x62)
    Writei2c (0x40,	0x36, 0x49, 0x56, 0x20, 0x50)
    Writei2c (0x40,	0x00, 0x08, 0x07, 0x03, 0x00)
    Writei2c (0x40,	0x00, 0x1C, 0x22, 0x41, 0x00)
    Writei2c (0x40,	0x00, 0x41, 0x22, 0x1C, 0x00)
    Writei2c (0x40,	0x2A, 0x1C, 0x7F, 0x1C, 0x2A)
    Writei2c (0x40,	0x08, 0x08, 0x3E, 0x08, 0x08)
    Writei2c (0x40,	0x00, 0x80, 0x70, 0x30, 0x00)
    Writei2c (0x40,	0x08, 0x08, 0x08, 0x08, 0x08)
    Writei2c (0x40,	0x00, 0x00, 0x60, 0x60, 0x00)
    Writei2c (0x40,	0x20, 0x10, 0x08, 0x04, 0x02)
    Writei2c (0x40,	0x3E, 0x51, 0x49, 0x45, 0x3E)
    
    
    Writei2c (0x40,	0x00, 0x42, 0x7F, 0x40, 0x00)			; 00
    Writei2c (0x40,	0x72, 0x49, 0x49, 0x49, 0x46)
    Writei2c (0x40,	0x21, 0x41, 0x49, 0x4D, 0x33)
    Writei2c (0x40,	0x18, 0x14, 0x12, 0x7F, 0x10)
    Writei2c (0x40,	0x27, 0x45, 0x45, 0x45, 0x39)
    Writei2c (0x40,	0x3C, 0x4A, 0x49, 0x49, 0x31)
    Writei2c (0x40,	0x41, 0x21, 0x11, 0x09, 0x07)
    Writei2c (0x40,	0x36, 0x49, 0x49, 0x49, 0x36)
    	Writei2c (0x40,	0x46, 0x49, 0x49, 0x29, 0x1E)
    	Writei2c (0x40,	0x00, 0x00, 0x14, 0x00, 0x00)
    	Writei2c (0x40,	0x00, 0x40, 0x34, 0x00, 0x00)
    	Writei2c (0x40,	0x00, 0x08, 0x14, 0x22, 0x41)
    	Writei2c (0x40,	0x14, 0x14, 0x14, 0x14, 0x14)
    	Writei2c (0x40,	0x00, 0x41, 0x22, 0x14, 0x08)
    	Writei2c (0x40,	0x02, 0x01, 0x59, 0x09, 0x06)
    	Writei2c (0x40,	0x3E, 0x41, 0x5D, 0x59, 0x4E)
    	Writei2c (0x40,	0x7C, 0x12, 0x11, 0x12, 0x7C)
    	Writei2c (0x40,	0x7F, 0x49, 0x49, 0x49, 0x36)
    	Writei2c (0x40,	0x3E, 0x41, 0x41, 0x41, 0x22)
    	Writei2c (0x40,	0x7F, 0x41, 0x41, 0x41, 0x3E)
    	Writei2c (0x40,	0x7F, 0x49, 0x49, 0x49, 0x41)
    	Writei2c (0x40,	0x7F, 0x09, 0x09, 0x09, 0x01)
    	Writei2c (0x40,	0x3E, 0x41, 0x41, 0x51, 0x73)
    	Writei2c (0x40,	0x7F, 0x08, 0x08, 0x08, 0x7F)
    	Writei2c (0x40,	0x00, 0x41, 0x7F, 0x41, 0x00)
    	Writei2c (0x40,	0x20, 0x40, 0x41, 0x3F, 0x01)
    	Writei2c (0x40,	0x7F, 0x08, 0x14, 0x22, 0x41)
    	Writei2c (0x40,	0x7F, 0x40, 0x40, 0x40, 0x40)
    	Writei2c (0x40,	0x7F, 0x02, 0x1C, 0x02, 0x7F)
    	Writei2c (0x40,	0x7F, 0x04, 0x08, 0x10, 0x7F)
    	Writei2c (0x40,	0x3E, 0x41, 0x41, 0x41, 0x3E)
    	Writei2c (0x40,	0x7F, 0x09, 0x09, 0x09, 0x06)
    	Writei2c (0x40,	0x3E, 0x41, 0x51, 0x21, 0x5E)
    	Writei2c (0x40,	0x7F, 0x09, 0x19, 0x29, 0x46)
    	Writei2c (0x40,	0x26, 0x49, 0x49, 0x49, 0x32)
    	Writei2c (0x40,	0x03, 0x01, 0x7F, 0x01, 0x03)
    	Writei2c (0x40,	0x3F, 0x40, 0x40, 0x40, 0x3F)
    	Writei2c (0x40,	0x1F, 0x20, 0x40, 0x20, 0x1F)
    	Writei2c (0x40,	0x3F, 0x40, 0x38, 0x40, 0x3F)
    	Writei2c (0x40,	0x63, 0x14, 0x08, 0x14, 0x63)
    	Writei2c (0x40,	0x03, 0x04, 0x78, 0x04, 0x03)
    	Writei2c (0x40,	0x61, 0x59, 0x49, 0x4D, 0x43)			; Z
    	
    	
    	Writei2c (0x40,	0x00, 0x7F, 0x41, 0x41, 0x41)
    	Writei2c (0x40,	0x02, 0x04, 0x08, 0x10, 0x20)
    	Writei2c (0x40,	0x00, 0x41, 0x41, 0x41, 0x7F)
    	Writei2c (0x40,	0x04, 0x02, 0x01, 0x02, 0x04)
    	Writei2c (0x40,	0x40, 0x40, 0x40, 0x40, 0x40)
    	Writei2c (0x40,	0x00, 0x03, 0x07, 0x08, 0x00)
    	Writei2c (0x40,	0x20, 0x54, 0x54, 0x78, 0x40)
    	Writei2c (0x40,	0x7F, 0x28, 0x44, 0x44, 0x38)
    	Writei2c (0x40,	0x38, 0x44, 0x44, 0x44, 0x28)
    	Writei2c (0x40,	0x38, 0x44, 0x44, 0x28, 0x7F)
    	Writei2c (0x40,	0x38, 0x54, 0x54, 0x54, 0x18)
    	Writei2c (0x40,	0x00, 0x08, 0x7E, 0x09, 0x02)
    	Writei2c (0x40,	0x18, 0xA4, 0xA4, 0x9C, 0x78)
    	Writei2c (0x40,	0x7F, 0x08, 0x04, 0x04, 0x78)
    	Writei2c (0x40,	0x00, 0x44, 0x7D, 0x40, 0x00)
    	Writei2c (0x40,	0x20, 0x40, 0x40, 0x3D, 0x00)
    	Writei2c (0x40,	0x7F, 0x10, 0x28, 0x44, 0x00)
    	Writei2c (0x40,	0x00, 0x41, 0x7F, 0x40, 0x00)
    	Writei2c (0x40,	0x7C, 0x04, 0x78, 0x04, 0x78)
    	Writei2c (0x40,	0x7C, 0x08, 0x04, 0x04, 0x78)
    	Writei2c (0x40,	0x38, 0x44, 0x44, 0x44, 0x38)
    	Writei2c (0x40,	0xFC, 0x18, 0x24, 0x24, 0x18)
    	Writei2c (0x40,	0x18, 0x24, 0x24, 0x18, 0xFC)
    	Writei2c (0x40,	0x7C, 0x08, 0x04, 0x04, 0x08)
    	Writei2c (0x40,	0x48, 0x54, 0x54, 0x54, 0x24)
    	Writei2c (0x40,	0x04, 0x04, 0x3F, 0x44, 0x24)
    	Writei2c (0x40,	0x3C, 0x40, 0x40, 0x20, 0x7C)
    	Writei2c (0x40,	0x1C, 0x20, 0x40, 0x20, 0x1C)
    	Writei2c (0x40,	0x3C, 0x40, 0x30, 0x40, 0x3C)
    	Writei2c (0x40,	0x44, 0x28, 0x10, 0x28, 0x44)
    	Writei2c (0x40,	0x4C, 0x90, 0x90, 0x90, 0x7C)
    	Writei2c (0x40,	0x44, 0x64, 0x54, 0x4C, 0x44)
    	Writei2c (0x40,	0x00, 0x08, 0x36, 0x41, 0x00)
    	Writei2c (0x40,	0x00, 0x00, 0x77, 0x00, 0x00)
    	Writei2c (0x40,	0x00, 0x41, 0x36, 0x08, 0x00)
    	Writei2c (0x40,	0x02, 0x01, 0x02, 0x04, 0x02)
    	Writei2c (0x40,	0x3C, 0x26, 0x23, 0x26, 0x3C)
    	Writei2c (0x40,	0x1E, 0xA1, 0xA1, 0x61, 0x12)
    	Writei2c (0x40,	0x3A, 0x40, 0x40, 0x20, 0x7A)
    	Writei2c (0x40,	0x38, 0x54, 0x54, 0x55, 0x59)
    	Writei2c (0x40,	0x21, 0x55, 0x55, 0x79, 0x41)	  
      return
    
    DisplayChar:
    let temp = abyte - " "
    if temp< 8 then
    	if temp=0 then
    	 	writei2c(0x40, 0x00, 0x00, 0x00, 0x00, 0x00)		' space
    	elseif temp=1 then
    		writei2c(0x40, 0x00, 0x00, 0x5F, 0x00, 0x00)		' !
    	elseif temp=2 then
    	 	writei2c(0x40, 0x00, 0x07, 0x00, 0x07, 0x00) 		' "
    	elseif temp=3 then
    	 	writei2c(0x40, 0x14, 0x7F, 0x14, 0x7F, 0x14) 		' #
    	elseif temp=4 then
    	 	writei2c(0x40, 0x24, 0x2A, 0x7F, 0x2A, 0x12) 		' $
    	elseif temp=5 then 
    	 	writei2c(0x40, 0x23, 0x13, 0x08, 0x64, 0x62) 		' %
    	elseif temp=6 then
    	 	writei2c(0x40, 0x36, 0x49, 0x56, 0x20, 0x50) 		' &
    	elseif temp=7 then 
    		writei2c(0x40, 0x00, 0x08, 0x07, 0x03, 0x00) 		' '
    	endif
    return
    endif
    temp = temp - 8
    temp = temp * 5		
    b55 = temp + 4
    for b54 = temp to b55
    	readtable b54, aByte
    	hi2cout (0x40,abyte)
    next b54
    return	
    DisplayNum:
    ;Words are always 5 chars long, but may be zero led.
    b52= 1
    for b53 = 0 to 4         
    	temp = 4-b53
    	aByte = DispNum DIG temp + "0"
    	if aByte="0" and b52=1 then 
    		goto DisplayNumCont ;Don't show leading spaces
    	elseif abyte<>"0" and b52=1 then
    	b52=0
    	endif
    	GOSUB DisplayChar
    DisplayNumCont:
    next b53
    return 
    ;----- demo code -----
    ;
    ;let row = 3
    ;let col = 10
    ;gosub setposition
    ;	
    ;	
    ;eeprom 31, ("0123456789 TEST")
    ;eeprom 46, ("HELLO WORLD")
    ;for index = 31 TO 45
    ;	read index,aByte
    ;	gosub displayChar;
    ;next index
    ;	
    ;let row = 5
    ;let col = 2
    ;gosub setposition
    ;	
    ;for index = 46 to 56
    ;	read index,aByte
    ;	gosub displayChar;
    ;next index
    ;	
    ;let DispNum = 32016		' Display any word sized number.
    ;let row = 6
    ;let col = 8
    ;gosub setposition
    ;gosub displayNum
    ;	
    ;	
    ;	
    ;let row = 1			' Display in top yellow section.
    ;let col = 1
    ;gosub setposition
    ;	
    ;eeprom 57, ("HIGH TEMP - ")
    ;for index = 57 to 68
    ;	read index,aByte
    ;	gosub displayChar;
    ;next index
    ;	
    ;	
    ;DispNum = 180		
    ;	
    ;gosub displayNum
    ;	
    ;let abyte = "C"
    ;gosub displayChar

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •