CON _clkmode = xtal1+pll16x _clkfreq = 80_000_000 'LCD is 320x240 giving 20x15 tiles cols = 20 rows = 15 screensize = cols * rows CON 'Constants for Graphics Demo _stack = ($3000 + $3000 + 200+2*screensize) >> 2 'accomodate display memory and stack x_tiles = 16 y_tiles = 12 paramcount = 14 bitmap_base = $2000 display_base = $5000 lines = 5 thickness = 2 GraphicsXOffset=2 GraphicsYOffset=2 CON 'Note Clock Speed for your setup!! COM11_RX = 4 COM11_TX = 5 COM12_RX = 31 COM12_TX = 30 BAUD_RATE = 9600 VAR long lcd_status 'status: off/visible/invisible read-only (5 contiguous longs) long lcd_enable 'enable: off/on write-only long lcd_videobase 'video base @word write-only long lcd_colorbase 'color base @long write-only long lcd_backlight 'Used to control LCD backlight word screen[screensize] long col, row, color long boxcolor,ptr byte x[lines] byte y[lines] byte xs[lines] byte ys[lines] OBJ uart1 : "FullDuplexSerial" uart2 : "FullDuplexSerial" lcd : "PTP_LcdDriver" 'Modified to drive 3.5" TFT PUB Main 'Start up Display 'clear screen print($100) 'start driver lcd_enable:=1 lcd_videobase := @screen lcd_colorbase := @vgacolors lcd_backlight:=16 '1=bright, 16=medium, 32=dark lcd.start(@lcd_status) col:=1 PrintStr(string("SmartMotor Velocity")) uart2.start(COM11_RX, COM11_TX, 0, BAUD_RATE) uart1.start(COM12_RX, COM12_TX, 0, BAUD_RATE) uart2.str(string("Data Logger v.1")) uart2.tx(10) ' cr/lf uart2.tx(13) 'echo everything out repeat uart2.tx( uart1.rx ) PrintStr((Velocity(4))) PrintStr(uart2.rx) PRI PrintStr(stringptr) '' Print a zero-terminated string repeat strsize(stringptr) print(byte[stringptr++]) PUB Velocity (vel) dira[vel]:=1 PUB print(c) | i, k case c $00..$FF: 'character? k := color << 1 + c & 1 i := k << 10 + $200 + c & $FE screen[row * cols + col] := i screen[(row + 1) * cols + col] := i | 1 if ++col == cols newline $100: 'clear screen? wordfill(@screen, $220, screensize) col := row := 0 $108: 'backspace? if col col-- $10D: 'return? newline $110..$11F: 'select color? color := c & $F PRI newline : i col := 0 if (row += 2) == rows row -= 2 'scroll lines repeat i from 0 to rows-3 ' wordmove(@screen[i*cols], @screen[(i+2)*cols], cols) 'clear new line ' wordfill(@screen[(rows-2)*cols], $200, cols<<1) DAT vgacolors long long $F00CF00C'$F00CF00C 'blue background with yellow letters long $F0F00C0C'$F0F00C0C long $08A808A8 'green long $0808A8A8 long $50005000 'blue long $50500000 long $FC00FC00 'white long $FCFC0000 long $FF80FF80 'red/white long $FFFF8080 long $FF20FF20 'green/white long $FFFF2020 long $FF28FF28 'cyan/white long $FFFF2828 long $00A800A8 'grey/black long $0000A8A8 long $0CFCC000 'Colors for Graphics spcl long $30100020 'greenbox long $3C142828 'cyanbox long $FC54A8A8 'greybox long $3C14FF28 'cyanbox+underscore long 0 [16] DAT 'data for Graphics_Demo vecdef word $4000+$2000/3*0 'triangle word 50 word $8000+$2000/3*1+1 word 50 word $8000+$2000/3*2-1 word 50 word $8000+$2000/3*0 word 50 word 0 vecdef2 word $4000+$2000/12*0 'star word 50 word $8000+$2000/12*1 word 20 word $8000+$2000/12*2 word 50 word $8000+$2000/12*3 word 20 word $8000+$2000/12*4 word 50 word $8000+$2000/12*5 word 20 word $8000+$2000/12*6 word 50 word $8000+$2000/12*7 word 20 word $8000+$2000/12*8 word 50 word $8000+$2000/12*9 word 20 word $8000+$2000/12*10 word 50 word $8000+$2000/12*11 word 20 word $8000+$2000/12*0 word 50 word 0