Have you, or anyone else done anything with the backlight so that it can be adjusted dynamically? Everytime I change the value (1-32) I have to reinitialize the display, which causes a very annoying screen flicker.
I'd like to just change the value and have the display adjust the backlight only. That way, I could implment a software controlled ambient light sensor (with the user being able to set the gain.)
I too searched the listing but it seemed fixed at the moment. Probably on a 'things to do' list?
I don't need to adjust BL for now; but once I get on batteries (might be a while the way things are progressing for me), I'll sure want to conserve them.
Bill, the backlight can be changed easily... The backlight level is a variable whose address is passed to the LCD driver. The driver checks this value very often and adjusts the backlight if changed. I don't think there should be any flicker when changing backlight level...
You can just move the Spin code that sets the brightness at the end of the start methode to it's own public methode. Then it will be possible to change this when ever you want by calling this methode.
Bill (Henning)
My Board draws ~150 mA and I power it always from an USB port. I think the PSB has a similar current consumption.
Ariba said...
You can just move the Spin code that sets the brightness at the end of the start methode to it's own public methode. Then it will be possible to change this when ever you want by calling this methode.
That was too easy!!! Thanks Andy!!!
Hey all, here is the simple method I added to Andy's Full Screen Graphics Driver to allow dynamic blacklighting adjustments.
Bill, I'm not sure Spin is fast enough to set the backlight correctly... The PSB and PTP assembly drivers set the backlight at assembly speed during the blanking period of the display. Your spin method may kinda work, but may not work exactly like you think... Anyway, that was my experience.
Doing some tests, it works perfectly. I built a slider that allows the user to drag a thumb across the screen. I used the TouchX value divided by 100. I then trimmed that to 1-32 to fit the parameter range. I found that if I didn't trim it, it would cause the display to shut down.
Now, when I drag the thumb, it does a beautiful job of changing it depending on where you drag the thumb.
EDIT:· By the way, it works because the spin code is the only code that is twiddling the bits for the backlight pin, which is obviously on a different cog then the display driver itself.· Andy's driver doesn't do anything to that pin after the initial spin startup.
Ran out of breakout boards and decided to improve the layout before ordering more... Test run of new boards checks out (and on way to GadgetGangster.com) and so will be ordering a bunch more now.
The only non-cosmetic change was to reduce the spacings between mounting holes. This is because the blade that I cut the boards apart with is much thicker than originally anticipated. Also, I've made a lot of cosmetic improvements. Here's a pic:
I built a slider that allows the user to drag a thumb across the screen. I used the TouchX value divided by 100. I then trimmed that to 1-32 to fit the parameter range. I found that if I didn't trim it, it would cause the display to shut down.
Now, when I drag the thumb, it does a beautiful job of changing it depending on where you drag the thumb.
Bill
Bill- are you willing/able to share your code for this? I have one of Rayman's touch-screen units and I'm having trouble getting off square one. I'm not very familiar with graphics and bitmaps but I'm working on it. Having an example that adjusts the brightness could be really educational.
That would be great. I think I need another way of looking at things to help me understand what's going on. I have the PTP board from Rayman. If that's what you've got too, it should be as simple as downloading your code to the platform to see what it does. I can then work through the code to see how you manage it.
The application I'd like to write is pretty straight forward. Just some menus (text based would be a fine first pass). But getting text boxes (or better yet) small buttons to go where I want and be the color I want AND respond to buttons hasn't worked so far.
I have to admit that Bill's slider sounds pretty cool- downright iPhone like.
Bill- are you willing/able to share your code for this?
Sure, Peter.
The following code is used to read the screen touch location... and if it is within the lower portion of the screen, then I display the text for the slider.
The user slides their finger across the text and I simply read the position of their finger.
'get current touch screen location and pressure
touchx := i2c.gettouchx/16
touchy := i2c.gettouchy/16
touchz := i2c.gettouchz1/1000
'if the pressure is greater than 10, then show slider
if touchz>10
gr.text(0, -25, string("<-- Brightness -->"))
if touchY > 3000 'are they touching the bottom line?
newBrightness := (touchx/100) 'set brightness to 1/100 scale of touch point
if (newBrightness =< 0) 'make sure brightness stays within bounds
newBrightness := 1
if (newBrightness => 33)
newBrightness := 32
newBrightness := 33 - newBrightness
oldBrightness := newBrightness 'store for future use
ifnot (Brightness == newBrightness) 'if they changed... then change display
Brightness := newBrightness
lcd.AdjustBrightness(Brightness)
This is the code for the "AdjustBrightness" method I added to the "TSD_GraphicsDriver" that Andy Schenk wrote for the 4.3" display.
Sorry about the slowness on this matter. For some reason I am unable to transfer the archived file from Windows to my Mac. Wasted too much time trying to fix the problem, so decided I'd just copy from Prop tool to the Mac to let you access it.
Hope this is useful. I was hoping to include Basic with the file but never got that far; thus the file name is a bit confusing.
{{+-----------------------------------------------------+
| Touch-sscreen Basic -TsB by hasdesignn 18 Sep.2010 | rev. 11:17 am 6 Oct.2010
+-----------------------------------------------------+
'PSB Graphics Demo (C) Copyright 2009 Rayslogic.com, LLC
'Based on the Propeller Graphics and Paint ! demos adapted for the PSB Screen }}
CON
_clkmode = xtal1+pll16x
_clkfreq = 80_000_000
QU = 34
'LCD is 480x272 giving 30x17 tiles; divide by 16 for Parallax font)
cols = 30
rows = 17
screensize = cols * rows ' = 510 tiles
'Constants for Graphics Demo
_stack = ($3000 + 100) >> 2 'accomodate display memory and stack
x_tiles = 30 '16
y_tiles = 17 '12
paramcount = 14
bitmap_base = $5000 ' was $2000 no double buffer
display_base = $5000
lines = 5
thickness = 2
GraphicsXOffset=6 ' NEEDED ???
GraphicsYOffset=3
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
long col, row, color, tilex, tiley, colU, rowU
long boxcolor,ptr
'vars for Graphics Demo
long mousex, mousey
long touchx, touchy
' long touchx0,touchdx,touchy0,touchdy 'cal factors
long CurrentColor, bLineMode, bStillDown, LastX, LastY
word screen[screensize]
'for custom characters
word user_charbase
byte colorA, colorB, flagReg, Char, Indexx ' lagReg: lsb = 'cap'key ON;
byte x[lines], y[lines], xs[lines], ys[lines]
OBJ
lcd : "PSB_LcdDriver" 'Modified to drive 4.3" TFT
i2c : "PSB_i2cDriver" ' Rokicki & Dummer's i2c
gr : "graphics" ' Chip Graecey's object
' kbd : "Keyboard" ' Ps/2 keyboard
' mouse : "mouse"
fsrw : "fsrw" '
' sd2 : "SD2.0_FATEngine" 'Kye's SD card engine
PUB Main
'Start up Display
'clear screen
print($100) ' show black on silver
'start driver
lcd_enable:=1
lcd_videobase := @screen
lcd_colorbase := @vgacolors
lcd_backlight:= 22 '1=bright, 16=medium, 32=dark
lcd.start(@lcd_status)
i2c.initialize 'init touch controller ' TSC2003 touch IC
repeat 20
i2c.GetTouchX
GraphicsDemo
PUB GraphicsDemo|i,j,k,dx,dy, kk, pp, pq, rr, numx, numchr,GraphicsColor ' modified
repeat
print($110)
print($100)
printStr(string("KeyBd,Color,Calibrate"))
WaitStylusDown(true)
if tiley < 3
if tilex < 5
TouchKeyBd
if (tilex < 11) and (tilex > 5)
ColorDial
if (tilex < 21) and (tilex > 11)
CalibrateTouchScreen
PUB colorDial | i
colorB := coloReg1
colorA := coloReg1 >> 8
repeat
print($100)
print($11F)
row := 1
repeat i from 0 to 7
printStr(string("The Parallax PROPELLER is # 1 "))
colorLong
WaitStylusDown(true)
if ina[lcd#TouchIrqPin]==0
UpdateColor
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
PUB UpdateColor
if (Tilex < 8) and (tiley > 12)
if tiley < 15
if (tilex == 0)
colorA := ColorA + $10
if (tilex == 1)
colorA := ColorA + 1
if (tilex == 6)
colorB := ColorB + $10
if (tilex == 7)
colorB := ColorB + 1
else
if (tilex == 0)
colorA := ColorA - $10
if (tilex == 1)
colorA := ColorA - 1
if (tilex == 6)
colorB := ColorB - $10
if (tilex == 7)
colorB := ColorB - 1
coloReg1 := colorA<<24 + colorB<<16 + colorA<<8 + colorB
coloReg2 := colorA<<24 + colorA<<16 + colorB<<8 + colorB
colorLong
PUB colorLong
print($110)
col := 0
row := 13
hex (coloReg1,8)
col := 0
row := 15
hex (coloReg2,8)
PUB TouchKeyBd
{{ (272 lines/16 =) 17 tiles high provides 2 data entry lines w/blue background,4 lines display
standard ASCII keyboard layout black on silver, w/ spacebar,control keys in white on green
except for 'cap' key in white on red when locked. When 'cap' has green baclground keys are
lower-case, capitaized when red background. Touch 'sft' prior to each single capital letter;
touch cap' for multiple capital letters. }}
flagReg := 1
' repeat
print($111) ' heading white/yellow on blue
print($100)
col :=0 '
row := 0
colU :=0
rowU :=0
printStr(string(" Touchscreen Basic "))
printStr(string(" 6 Oct.2019 "))
printStr(string(" "))
printStr(string(" "))
repeat
if ((tilex == 0) and (tiley==16)) ' DEBUG control
if (flagReg & $80) > 1
flagReg := flagReg & $7F
else
flagReg := flagReg | $80
if ((tilex >25) and (tiley==16)) ' backlight control
if (tilex < 28) and (lcd_backlight < 32)
lcd_backlight := lcd_backlight + 1
else
if (tilex > 27) and (lcd_backlight > 1)
lcd_backlight := lcd_backlight - 1
ShowKeys
DecodeKey
if flagReg & $80 > 0
print($114) ' white on black for DEBUG data
col := 18
row := 0
PrintStr(string("Index=")) ' show pixel x,y of touch position
hex(Indexx,2)
{{ PrintStr(string("touchx=")) ' show pixel x,y of touch position
dec(touchx)
col := 18
row := 2
PrintStr(string("touchy="))
dec(touchy) }}
col := 18
row := 4
PrintStr(string("tilex=")) ' show Tile number
dec(tilex)
col := 18
row := 6
PrintStr(string("tiley="))
dec(tiley)
col := 18 ' show flag register value
row := 8
PrintStr(string("flagReg="))
hex(flagReg,2)
col := 18 ' show BL value
row := 10
PrintStr(string("BL="))
dec(lcd_backlight)
col := 18 ' show 'Char' value
row := 12
PrintStr(string("Ch="))
hex(Char,2)
print($20)
print(Char)
Waitcnt(cnt+clkfreq/2)
WaitStylusUp
WaitStylusDown(true)
PUB DecodeKey | Index
Char := 0
Index := -50
if tiley == 7 or tiley == 8 ' check top line - numbers, punctuation
if tilex > 1 and tilex < 27
Index := (tilex - 2)/2
elseif tilex > 27 ' check if on BS
Char := $1
' do BS
if tiley == 9 or tiley == 10 ' 2nd line - qwerty..
if tilex > 2 and tilex < 28
Index := (tilex - 3)/2 + 13
elseif tilex < 2 ' check if on TAB
Char := $2
' do TAB
if tiley == 11 or tiley == 12 ' 3rd line - asdfg..
if tilex > 3 and tilex < 25
Index := (tilex - 4)/2 + 26
elseif tilex > 25 ' checkif on RET key
Char := 3
' do RET
elseif tilex < 3 ' check if 'cap' pressed
if (flagReg & 1) == 1
flagReg := flagReg & $FE
else
flagReg := flagReg | 1
if tiley == 13 or tiley == 14 ' 4th line - zxcv..
if tilex > 3 and tilex < 24
Index := (tilex - 5)/2 + 37
elseif tilex < 3 or tilex > 25 ' check if on Shift key
Char := 4
' do single Shift
FlagReg := FlagReg | 2 ' set for single Shift action
FlagReg := FlagReg & $FE
if tiley == 15 or tiley == 16 ' bottom line
if (tilex > 8 and tilex < 21) ' if Spacebar
Char := $20
flagReg := flagReg | 4
{{' Index := 47 }}
elseif (tilex > 3 and tilex < 6) ' check if 'cntl-c' key
Char := 5
' do Cntl-z
elseif (tilex > 6 and tilex < 9) ' check if 'cntl-z' key
Char := 6
' do Cntl-c
elseif tilex > 21 and tilex < 25 ' check if ESC key
Char := 7
' do ESC
if (flagReg & 3 == 1)'' or (flagReg & 2 == 1) ' check flags for Shift Lock or single Shift
Index := Index + 48
Indexx := Index
if (Index > 0) and (FlagReg & 4 == 0)
Char := LookUpZ(Index: "`","1","2","3","4","5","6","7","8","9","0","-","=",{{
}} "q","w","e","r","t","y","u","i","o","p","[","]","\", {{
}} "a","s","d","f","g","h","j","k","l",":","'",{{
}} "z","x","c","v","b","n","m",",",".","/"," ", {{
}} "~","!","@","#","$","%","^","&","*","(",")","_","+", {{
}} "Q","W","E","R","T","Y","U","I","O","P","{","}","|", {{
}} "A","S","D","F","G","H","J","K","L",":",QU,{{
}} "Z","X","C","V","B","N","M","<",">","?"," ")
if Char => $20
print($111) ' heading white/yellow on blue
col:= colU ' restore last position used '
row := rowU
print(Char) ' show last typed character in upper area
if col == cols ' move down two tiles for next row
col++
row := row + 2
colU := col ' save last position
rowU := row
FlagReg := FlagReg & $FD ' restore single Shift
print($110) ' black letters on silver
PUB ShowKeys
print($110) ' black letters on silver
if (flagReg & 1 == 1) or (flagReg & 2 == 1)
col := 0
row := 7
PrintStr(string(" ~ ! @ # $ % ^ & * ( ) _ + "))
print($116) ' bs, tb, ret, sft, spacebar are white on green
PrintStr(string("bs"))
col := 0
row := 9
PrintStr(string("tb"))
print($110)
PrintStr(string(" Q W E R T Y U I O P { } |"))
col := 0
row := 11
print($115) ' 'cap' is white on red if selected, else on green
PrintStr(string("cap"))
print($110)
print($110)
PrintStr(string(" A S D F G H J K L : " , QU," "))
print($116)
PrintStr(string("ret "))
col := 0
row := 13
PrintStr(string("sft"))
print($110)
PrintStr(string(" Z X C V B N M < > ? "))
ELSE
col := 2
row := 7
PrintStr(string("` 1 2 3 4 5 6 7 8 9 0 - = "))
print($116)
PrintStr(string("bs"))
col := 0
row := 9
PrintStr(string("tb"))
print($110)
PrintStr(string(" q w e r t y u i o p [ ] \"))
col := 0
row := 11
print($116)
PrintStr(string("cap"))
print($110)
print($110)
PrintStr(string(" a s d f g h j k l : ' "))
print($116)
PrintStr(string("ret "))
col := 0
row := 13
PrintStr(string("sft"))
print($110)
PrintStr(string(" z x c v b n m , . / "))
print($116)
PrintStr(string("sft "))
col := 9
row := 15
PrintStr(string("[ spacebar ]")) ' cntl opt cmd names/legends unused
print($112)
col := 0
row := 15
PrintStr(string("cntl-z -c"))
col := 22
row := 15
PrintStr(string("esc"))
' col := 0
' row :=
' PrintStr(string(""))
'PUB DUMMY
PUB CalibrateTouchScreen|TLX,TLY,TRX,TRY,TBLX,TBLY,TBRX,TBRY ' touch '+'s to calibrate
repeat
print($100)
row:=6
col:=4
PrintStr(string("Calibrate Touch Screen"))
row:=12
col:=1
PrintStr(string("(Tap and release each point)"))
'Calibrate top-left corner
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
Bitmap1Bit(@CalibrateCursor, 0, 0, 1, 1, 0)
row:=0
col:=3
PrintStr(string(186,144,144,170," Press Here"))
GetTouchCal
TLX:=touchx
TLY:=touchy
'Calibrate top-right corner
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
print($100)
Bitmap1Bit(@CalibrateCursor, cols-1, 0, 1, 1, 0)
row:=0
col:=10
PrintStr(string("Press Here ",169,144,144,187))
GetTouchCal
TRX:=touchx
TRY:=touchy
'Calibrate bottom-left corner
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
print($100)
Bitmap1Bit(@CalibrateCursor, 0, rows-2, 1, 1, 0)
row:=rows-2
col:=3
PrintStr(string(186,144,144,170," Press Here"))
GetTouchCal
TBLX:=touchx
TBLY:=touchy
'Calibrate bottom-right corner
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
print($100)
Bitmap1Bit(@CalibrateCursor, cols-1, rows-2, 1, 1, 0)
row:=rows-2
col:=10
PrintStr(string("Press Here ",169,144,144,187)) ' these are Parallax font characters
GetTouchCal
TBRX:=touchx
TBRY:=touchy
'Calculate touchscreen cal factors
'horizontal pixels between touchpoints = 16*(cols-1)
'vertical pixels between touchpoints=16*(rows-2)
touchdx:=((TRX+TBRX)-(TLX+TBLX))/(32*(cols-1))
touchdy:=((TBLY+TBRY)-(TLY+TRY))/(32*(rows-2))
touchx0:=((TLX+TBLX)/2)-8*touchdx
touchy0:=((TLY+TRY)/2)-16*touchdy
'Now show cross in center and see if cal is good
WaitStylusUp
Waitcnt(cnt+clkfreq/2)
print($100)
Bitmap1Bit(@CalibrateCursor, 15, 8, 1, 1, 0)
row:=5
col:=4
PrintStr(string("Press Here ",5)) ' '5' = Parallax font 'down arrow'
GetTouchCal
WaitStylusUp
' waitcnt(cnt+clkfreq/2)
'Calculate if cal good
'test x is at 15*16+7=247
'test y is at 8*16+15=143
if (||(((touchx-touchx0)/touchdx)-247)<5) and (||(((touchy-touchy0)/touchdy)-143)<5)
'Good Cal
if true
' WaitStylusUp
print($100)
row := 4
col := 10
PrintStr(string(" dx="))
dec(touchdx)
row := 6
col := 10
PrintStr(string(" dy="))
dec(touchdy)
row := 9
col := 10
PrintStr(string(" x0="))
dec(touchx0)
row := 11
col := 10
PrintStr(string(" y0="))
dec(touchy0)
Waitcnt(cnt+clkfreq)
WaitStylusDown(true)
'repeat
' Return
else
Waitcnt(cnt+clkfreq/2)
print($100)
row:=5
col:=4
PrintStr(string("Calibration Failed."))
Waitcnt(cnt+clkfreq)
row:=15
col:=0
PrintStr(string(" X="))
dec((touchx-touchx0)/touchdx)
PrintStr(string(" Y="))
dec((touchy-touchy0)/touchdy)
WaitStylusDown(true)
PUB GetTouchCal|tx,ty 'take 5 samples and average
tx~
ty~
repeat 5
WaitStylusDown(false)
tx+=touchx
ty+=touchy
touchx:=tx/5
touchy:=ty/5
WaitStylusUp
PUB WaitStylusUp
'Wait for stylus to be up
repeat
waitcnt(cnt+clkfreq/100)
if ina[lcd#TouchIrqPin]<>0
return
PUB WaitStylusDown(bCalibrated)|tx,ty,z1,z2,tz
'Wait for stylus to be down then update touchx, touchy and return
repeat
waitcnt(cnt+clkfreq/1000)
if ina[lcd#TouchIrqPin]==0
tx:=i2c.GetTouchX
ty:=i2c.GetTouchY
z1:=i2c.GetTouchZ1
z2:=i2c.GetTouchZ2
'take another x,y reading and average
tx+=i2c.GetTouchX
ty+=i2c.GetTouchY
tx>>=1 ' divide by 2 using shift right
ty>>=1
tz:=tx*(z2-z1)/z1
waitcnt(cnt+clkfreq/1000)
if (tz<90000) and (tz>10000) and (ina[lcd#TouchIrqPin]==0 ) 'You might have to tweak these values for some LCDs...
if bCalibrated==true
'calculate calibrated pixel
touchx:=(tx-touchx0)/touchdx
touchy:=(ty-touchy0)/touchdy
else
'set uncalibrated data
touchx:=tx
touchy:=ty
tilex := touchx/16 ' HASD - these two added to have 'tile' value too
tiley := touchy/16
return
else
bStillDown:=false
else
bStillDown:=false
PRI Bitmap1Bit(pBitmap, xPos, yPos, xSize, ySize, clr)|c,i,j,BmpAddress
row:=yPos
col:=xPos
c:=0
BmpAddress:=pBitmap+user_charbase-@uchar
repeat j from 0 to (ySize-1) step 2
repeat i from 0 to (xSize-1)
screen[row * cols + col] := (clr<<1+1) << 10 + BmpAddress>>6 +c
screen[(row+1) * cols + col] := (clr<<1) << 10 + BmpAddress>>6 +c
c++
col++
row+=2
col:=xPos
PRI Bitmap2Bit(pBitmap, xPos, yPos, xSize, ySize, clr)|c,i,j,BmpAddress
row:=yPos
col:=xPos
c:=0
BmpAddress:=pBitmap+user_charbase-@uchar
repeat j from 0 to (ySize-1)
repeat i from 0 to (xSize-1)
screen[row * cols + col] := (clr) << 10 + BmpAddress>>6 +c
'Print2Bit(c,clr,pBitmap)
c++
col++
row++
col:=xPos
{{
PUB box(left,top,width,height) | x, y, i
ptr := top * cols + left
boxchr($0)
repeat i from 1 to width
boxchr($C)
boxchr($8)
repeat i from 1 to height
ptr := (top + i) * cols + left
boxchr($A)
ptr += width
boxchr($B)
ptr := (top + height + 1) * cols + left
boxchr($1)
repeat i from 1 to width
boxchr($D)
boxchr($9)
PRI boxchr(c): i
screen[ptr++] := boxcolor << 10 + $200 + c }} ' WHAT DOES $200 MEAN ???
'' Print a character
''
'' $00..$FF = character
'' $100 = clear screen
'' $108 = backspace
'' $10D = new line
''$110..$11F = select color
PRI PrintStr(stringptr)
'' Print a zero-terminated string
repeat strsize(stringptr)
print(byte[stringptr++])
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) ' original ' WHAT DOES $220 MEAN ???
wordfill(@screen, $220, screensize) ' hasd
col := row := 0
$108: 'backspace?
if col
col--
$10D: 'return?
newline
$110..$11F: 'select color?
color := c & $F
' New line
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)
PRI dec(value) | i
'' Print a decimal number
if value < 0
-value
print("-")
i := 1_000_000_000
repeat 10
if value => i
print(value / i + "0")
value //= i
result~~
elseif result or i == 1
print("0")
i /= 10
PRI hex(value, digits)
'' Print a hexadecimal number
value <<= (8 - digits) << 2
repeat digits
print(lookupz((value <-= 4) & $F : "0".."9", "A".."F"))
DAT 'Default Touchscreen Calibrations; HASD using B1 LCD average - 5 readings, B2 - 8
touchdx long 121 ' Rayman 123 hasd A 127 B1 123 B2 121
touchdy long 209 ' 206 209 208 208
touchx0 long 3584 ' 2713 2072 2906 3605
touchy0 long 4531 ' 4590 4046 4221 4569
{{ RAM usage TsB lcd i2c gr fsrw
program 3774
Variable 455
Stack/free 3957 }}
DAT 'Bitmap data
padding LONG 7[16] 'alignment padding for the following user defined characters
uchar long
CalibrateCursor long
file "calibrateCursor.dat" '1 tile
ColorButton long
file "button1.dat" '2x2=4 tiles
LineButton long
file "button2.dat" '2x2=4 tiles
DotsButton long
file "button3.dat" '2x2=4 tiles
DAT
vgacolors long ' 1st long pair determines fore-/back-ground after 'print($100)'
long $00A800A8 '0 black on silver
long $0000A8A8
long $F00CF00C '1 blue background with yellow letters
long $F0F00C0C
long $08A808A8 '2 blue on silver
long $0808A8A8
long $50005000 '3 green on black
long $50500000
long $FC00FC00 '4 white on black
long $FCFC0000
long $FF80FF80 '5 white on red
long $FFFF8080
long $FF20FF20 '6 white on green
long $FFFF2020
long $FF28FF28 '7 white on cyan
long $FFFF2828
long $70447044 '8 yellow on purple
long $70704444
long $E084E084 '9 orange on raspberry
long $E0E08484
long $60346034 '10 cranberry o pale yellow
long $60603434
long $F020F020 '11 yellow-orange on green
long $F0F02020
long $AC14AC14 '12 grey-blue on gray
long $ACAC1414
long $50E050E0 '13 green on orange
long $5050E0E0
long $6CB06CB0 '14 lt. blue on yellow
long $6C6CB0B0
coloReg1 long $70007000 '15 for 'Color Dial' use;
coloReg2 long $70700000 ' initially yellow on black
{{ Propeller I/O pin usage
Prop I/O Signal Use I/O Signal Use
--------+--------+----------+---+--------+----------
A00 DO ( SD card) A31* TX (PropPlug)
A01 CLK " SPI A30* RX "
A02 DI " A29* SDA (i2c EEPROM)
A03 CS " A28* SCL (and Touch)
A04 BL/DON (LCD) A27* (PS/2 kEYBOARD)
A05 DE " A26* "
A06 PCLK " A25* (PS/2 MOUSE)
A07 IRQ " A24* "
A08 not used A23 R1 (LCD)
A09 " A22 R0 "
A10 " A21 G1 "
A11 " A20 G0 "
A12 1.1K (TV) A19 B1 "
A13 560 " A18 B0 "
A14 270 " A17 HSync "
A15 560 (audio) " A16 VSync "
* = Hard-wired on Parallax Prop ProtoBoard
}}
Even though this is the 4.3" thread, I'm including the archived file now for the 3.5" version using brightness control.
If you click the lower-left tile, that should bring up some 'debug' variables left over; the source probably has others commented out during 'progress'. I found this debug scheme very handy, though somewhat limited area to display variable values AND still have some 'plot' area remaining useful.
The items at the top, only the left and right ones were implemented to date. Just place holders for the two others.
Anyone else finding this useful, you are welcome to make use of this.
Forgot to mention the 'cursors'. I couldn't resist not including them. Glad the debug button worked well. You'll see in the text lots of commented out other debug variables during development.
I'm involved with a long drawn out project with another fellow. When there are lulls, like awaiting detail on the design, I go off to my projects. The 3.5" LCD I got when Rayman said he got hours of use as an exhibit. That sold me. PTP board and battery holder is a neat way to go. When there is time I have to work on the front end sensor and circutry; for detecting heart pulse signal. A hugely fun project and I learned a lot with this project.
Ok, I've just heard that a couple hundred more lcds are on the way
That's awesome, Ray!!! :-) I don't know how many I've ordered from you in the past (maybe 50?,) but out of all of them, I've only had two with issues (one touch screen was not working and the other would not display all the Reds correctly (one pin was bad.)) I used them in Demo machines and have not had a single return on them.
These screens work perfectly for making small GPS style devices. If you take the case I designed (made by Chuck over at Mountain King) and throw in a Gadget Gangster SD Platform board... backed by one of the Gadget Gangster/Rayman 4.3" Breakout Boards (Soldered directly back to back of the SD Platform)... add a battery and appropriate power connectors (DB9 in my case + switch) you wind up with a very nice looking little device. (See my VirtualHUD Wingman as an example - page 8 of the 2011 Parallax product catalog or here: http://www.virtualhud.com/VirtualHud/images/Wingman_PressRelease1.jpg.)
I wrap the outter edge with a 1/16" foam padding (cut from 14" x 11" craft foam sheets) and use Acetone to glue the case together + Shoo Glue to affix the foam and you wind up with a very professional looking device.
Comments
Have you, or anyone else done anything with the backlight so that it can be adjusted dynamically? Everytime I change the value (1-32) I have to reinitialize the display, which causes a very annoying screen flicker.
I'd like to just change the value and have the display adjust the backlight only. That way, I could implment a software controlled ambient light sensor (with the user being able to set the gain.)
Thanks,
Bill
I don't need to adjust BL for now; but once I get on batteries (might be a while the way things are progressing for me), I'll sure want to conserve them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
I'll grab your code and add it to the backporch portion in his driver... that should do it.
Bill
You can just move the Spin code that sets the brightness at the end of the start methode to it's own public methode. Then it will be possible to change this when ever you want by calling this methode.
Bill (Henning)
My Board draws ~150 mA and I power it always from an USB port. I think the PSB has a similar current consumption.
Andy
Most of the 400 mA is the LCD backlight.· You can save a lot of power by turning it down...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
This thread answered that question. So added a menu for the BL adjustment and it works great on the 3.5" LCD.
Pic attached; the white text on blue is for debug purposes temporarily.
Thanks for the info on BL.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
That was too easy!!! Thanks Andy!!!
Hey all, here is the simple method I added to Andy's Full Screen Graphics Driver to allow dynamic blacklighting adjustments.
Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm
My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
Doing some tests, it works perfectly. I built a slider that allows the user to drag a thumb across the screen. I used the TouchX value divided by 100. I then trimmed that to 1-32 to fit the parameter range. I found that if I didn't trim it, it would cause the display to shut down.
Now, when I drag the thumb, it does a beautiful job of changing it depending on where you drag the thumb.
EDIT:· By the way, it works because the spin code is the only code that is twiddling the bits for the backlight pin, which is obviously on a different cog then the display driver itself.· Andy's driver doesn't do anything to that pin after the initial spin startup.
Bill
Post Edited (wjsteele) : 7/12/2010 2:28:13 PM GMT
The only non-cosmetic change was to reduce the spacings between mounting holes. This is because the blade that I cut the boards apart with is much thicker than originally anticipated. Also, I've made a lot of cosmetic improvements. Here's a pic:
Bill- are you willing/able to share your code for this? I have one of Rayman's touch-screen units and I'm having trouble getting off square one. I'm not very familiar with graphics and bitmaps but I'm working on it. Having an example that adjusts the brightness could be really educational.
Thanks
Peter
I don't know how you planned to change the brightness, but I played with both the 3.5 and 4.3" LCDs and used 'buttons' to change things.
I used the textual '<' and '>' characters to decrease/increase brightness with 0 and 31 limits.
If you're interested I can supply the source.
Harley-
That would be great. I think I need another way of looking at things to help me understand what's going on. I have the PTP board from Rayman. If that's what you've got too, it should be as simple as downloading your code to the platform to see what it does. I can then work through the code to see how you manage it.
The application I'd like to write is pretty straight forward. Just some menus (text based would be a fine first pass). But getting text boxes (or better yet) small buttons to go where I want and be the color I want AND respond to buttons hasn't worked so far.
I have to admit that Bill's slider sounds pretty cool- downright iPhone like.
Thanks,
Peter
Sure, Peter.
The following code is used to read the screen touch location... and if it is within the lower portion of the screen, then I display the text for the slider.
The user slides their finger across the text and I simply read the position of their finger.
This is the code for the "AdjustBrightness" method I added to the "TSD_GraphicsDriver" that Andy Schenk wrote for the 4.3" display.
That's it!
Bill
Sorry about the slowness on this matter. For some reason I am unable to transfer the archived file from Windows to my Mac. Wasted too much time trying to fix the problem, so decided I'd just copy from Prop tool to the Mac to let you access it.
Hope this is useful. I was hoping to include Basic with the file but never got that far; thus the file name is a bit confusing.
Even though this is the 4.3" thread, I'm including the archived file now for the 3.5" version using brightness control.
If you click the lower-left tile, that should bring up some 'debug' variables left over; the source probably has others commented out during 'progress'. I found this debug scheme very handy, though somewhat limited area to display variable values AND still have some 'plot' area remaining useful.
The items at the top, only the left and right ones were implemented to date. Just place holders for the two others.
Anyone else finding this useful, you are welcome to make use of this.
Forgot to mention the 'cursors'. I couldn't resist not including them. Glad the debug button worked well. You'll see in the text lots of commented out other debug variables during development.
I'm involved with a long drawn out project with another fellow. When there are lulls, like awaiting detail on the design, I go off to my projects. The 3.5" LCD I got when Rayman said he got hours of use as an exhibit. That sold me. PTP board and battery holder is a neat way to go. When there is time I have to work on the front end sensor and circutry; for detecting heart pulse signal. A hugely fun project and I learned a lot with this project.
That's awesome, Ray!!! :-) I don't know how many I've ordered from you in the past (maybe 50?,) but out of all of them, I've only had two with issues (one touch screen was not working and the other would not display all the Reds correctly (one pin was bad.)) I used them in Demo machines and have not had a single return on them.
These screens work perfectly for making small GPS style devices. If you take the case I designed (made by Chuck over at Mountain King) and throw in a Gadget Gangster SD Platform board... backed by one of the Gadget Gangster/Rayman 4.3" Breakout Boards (Soldered directly back to back of the SD Platform)... add a battery and appropriate power connectors (DB9 in my case + switch) you wind up with a very nice looking little device. (See my VirtualHUD Wingman as an example - page 8 of the 2011 Parallax product catalog or here: http://www.virtualhud.com/VirtualHud/images/Wingman_PressRelease1.jpg.)
I wrap the outter edge with a 1/16" foam padding (cut from 14" x 11" craft foam sheets) and use Acetone to glue the case together + Shoo Glue to affix the foam and you wind up with a very professional looking device.
Total cost is around $125!
Bill