GLCD Graphical LCD library

This library makes it easy to use a Graphical LCD (GLCD) with Arduino. This is an extensive modi ication o the ks!"!# library that has hi$her per ormance% more eatures% supports more Arduino boards and is easier to inte$rate with di erent panels. &ketches written or the old library should work with little or no modi ication. The con i$uration mechanism has been chan$ed to acilitate use with a broad ran$e o GLCD chips and ATme$a controllers. &ee the section on sketch mi$ration or details on modi ications or the new library. Table o Contents' GLCD Graphical LCD library Wiring and Configuration: Configuration Troubleshooting Using fonts Using bitmaps Migrating your sketch from ks0108 to the new !C" Methods: "rawing #unctions Te$t #unctions

!C" library

Wiring and Configuration:
(anel characteristics (like pixel hei$ht and width) and the pins used to connect to the panel must be set in a con i$uration ile. Con i$uration iles are provided or the wirin$ shown below% you can chan$e the ile i you want to use di erent wirin$ or panels. This release supports panels usin$ the )&!"!# and &*D"+,! chips. %&0108 family The )&!"!# is a popular controller chip used in GLCD displays% however% wirin$ or these panels is not standardi-ed and it is important to check the datasheet or your panel to con irm how it should be wired. .ncorrect connections o the si$nal lines are the most common cause o problems% and particular care should be taken with the power leads as wirin$ these incorrectly can destroy a panel. /ost GLCD panels re0uire an external preset pot (variable resistor) to set the LCD workin$ volta$e (contrast) and may re0uire a ixed resistor to limit the current in the GLCD 1ersion 2 (3eta) 4un 5 ,!"!

backli$ht. The datasheet or your panel provides speci ic in ormation on the wirin$ and choice o components or this. The table below shows common pinouts or )&!"!# panels. The numbers under the Arduino column are the Arduino pins used in the con i$uration ile provided in the download% i you alter the wirin$ to Arduino pins then you must chan$e the pin assi$nments in the con i$uration ile. The numbers in the (anel A636C columns are the pin numbers o the GLCD display panel
Arduino pins 5V Gnd n/a 5V Gnd n/a 5V Gnd n/a 5V Gnd n/a Mega Sanguino Teensy Teensy ++ 5V Gnd n/a Function +5 volts GND Contrast in Panel Panel Panel A 1 2 3 B 2 1 3 C 13 14 12
Wiper of contrast pot

Comments

8

22 23

0 1 2 3 4 5 ! 7 24 25

0 1 2 3 13 14 15 4 7 8

10 11 12 13 14 15 1! 17 18 1

D0 D1 D2 D3 D4 D5 D! D7 C%&'1 C%&'2 )eset

4 5 ! 7 8

7 8

1 2 3

10 11 4 5 ! 7 14 "alo# 0$ 15 "alo# 1$ )eset 1! "alo# 2$ 17 "alo# 3$

24 25 2! 27 28 2 33 34

10 11 12

4 5 ! 7 8 15 1! 18 10 11
C(ip 1 select C(ip 2 select Connect to reset )ead/+rite Data/,nstr-ction ")%$

10 11 12 13 14 15 1!

13 14 15 1! 17 5 4

35 3!

2! 27

! 5

8

)*W D*,

18 "alo# 4$ n/a

37 n/a

28 n/a n/a

7 n/a

&N Contrast o-t

17 18

! 18 17

&na.le 10/ or 20/ preset

n/a

n/a

n/a

n/a

n/a

0ac/li#(t +5

1

1

1

%ee datas(eet

Gnd

Gnd

Gnd

Gnd

Gnd

0ac/li#(t Gnd

20

20

20

%ee datas(eet

GLCD 1ersion 2 (3eta) 4un 5 ,!"!

The dia$rams show the display9s reset pin connected to the Arduino reset pin and this will automatically reset the display when the Arduino resets. Althou$h the pin number on the GLCD panels are di erent% the correspondin$ unctions are connected to the same Arduino pins in all three examples so the supplied ks!"!#8Con i$.#). The ks!"!# datasheet says the reset pin should be taken low or a brie period a ter power is applied.KS-0108 Pin Connections Table (see your datasheet).-8./ 0f you ha1e a different board then you should follow the pin assignments in the 2in Connections Table abo1e/ &ee the datasheet for your panel for the 1alue of the backlight resistor if one is re3uired/ GLCD 1ersion 2 (3eta) 4un 5 .ote that some panels may unction correctly without re0uirin$ an external reset< in that case you should connect the panel reset pin to =+volts. 'ote: The diagrams that follow are for standard (rduino boards )(Tmega 1*8+.h con i$uration ile should work without chan$e i you wire your panel ollowin$ the appropriate dia$ram. . :ou can also wire the display reset pin to a spare Arduino pin and control reset in so tware by addin$ a de ine to the panel con i$uration ile (see the con i$uration section below).!"! . The ollowin$ illustrations show the wirin$ or these panel types with a standard Arduino ("7#62.

h or the 1)+"."8Con i$.h and an example called /odvk+". The distribution contains a $eneric con i$uration ile named sed"+.&4"15-0 The &*D"+. >ere is the wirin$ or a typical &*D"+." panel.!8Con i$.! uses di erent timin$ and command pins then the )&!"!# and the most common panels have ewer pixels.! (anel' GLCD 1ersion 2 (3eta) 4un 5 .!"! .

A tip or makin$ the physical connections is use a small piece o stripboard with header pins or +1% Ground and ?eset. The picture has an example layout or a type 9A9 panel. GLCD 1ersion 2 (3eta) 4un 5 .!"! .

*xample o Teensy== connected to a )&!"!# panel usin$ a breadboard Configuration . The active con i$uration when the sketch is compiled is selected in a master con i$uration ile named glcd_Config. Althou$h display panel timin$ can also be easily con i$ured% most displays will work without re0uirin$ a con i$uration chan$e or timin$. ( or example% ks!"!#) GLCD 1ersion 2 (3eta) 4un 5 . The de ault con i$uration ile (named Bconfig/ks0108_Panel. you use di erent wirin$ or use a di erent panel type you will need to modi y one o the supplied con i$urations or you can create your own. 'ote that each board type uses a different selection of pins.#x7@ ks!"!# type panel. you are usin$ a standard Arduino board ("7#62. These con i$uration iles set the panel parameters (display hei$ht% and width% timin$% etc) to match your hardware and allows selection o the Arduino pins used to connect to the display.#x7@ )&A!"!# panel wired accordin$ to the pin connections table above% you don9t need to make any chan$es to con i$uration iles.!"! .hB) is or ".h.#) or a /e$a% &an$uino% Teensy% or Teensy==< and you have a ". The panel con i$uration ile namin$ is' B{PANELNAME}_Panel. >owever% you should check the datasheet or your panel to veri y the timin$ values in the panel con i$uration ile. .hB Chere' {PANELNAME} is the $lcd panel type./e$a% &an$uino and Teensy boards can provide aster per ormance by allowin$ all the data pins to be connected to the same port (actual per ormance will vary dependin$ on the panel).

(rocessor type is automatically determined rom the board selected when the sketch is built% this allows Arduino style pin numbers to be mapped to ast direct port .#!) A &an$uino (ATme$a7@@() A Teensy and Teensy== (AT5!G&37@7% AT5!G&3".D*).t will validate the connections and test the memory o GLCD module as well as report the active con i$uration in ormation to the serial port.h includes a panel ile Bconfig/{PANELNAME}_Panel. (in numberin$ or the ollowin$ processor types are supported' A &tandard Arduino (ATme$a#%"7#%2. Eor example% the ks!"!# pin con i$uration ile name or a standard Arduino board is' Bks0108_A"d#ino.hB The e0uivalent ile or the B/e$aB board is' Bks0108_Mega.F used by the library. The syntax used is (. you chan$e the active con i$uration in the master con i$uration ile $lcd8Con i$.hB (the active con i$uration) that in turn includes a board speci ic pin mappin$ ile based on arduino board type% Bconfig/{PANELNAME}_{BOA !NAME}. your display is not workin$ properly then check the in ormation displayed in the serial monitor.hB !C"diags GLCDdia$s is a test sketch included in the examples older. ( or example% ks!"!#) {BOA !NAME} is the name o the board (as selected in the Arduino .hB .h ile or more details. GLCD 1ersion 2 (3eta) 4un 5 . The sketch prints the in ormation the library is usin$ to the serial monitor and you can use this to veri y i the sketch is con i$ured correctly.!"! .#) A /e$a(ATme$a". Eor example% to speci y port D bit 2 you would use (..8(b where (b represents a (F?T and a bitH. .The panel con i$uration ile includes a board speci ic con i$uration ile that speci ies the pins used or each speci ic board type. .#7% ATme$a2. AVR port and pin numbers (ins can also be selected by A1? port and pin number.G@) 0n summary: $lcd8Con i$..h% make sure that one and only one con i$uration ile is included.8D2 The ollowin$ sets $lcdC&*L" (the irst chip select) to port D pin 2 $define glcdC%EL1 P&N_!' &ee the avrio. The pin con i$uration ile namin$ is a ollows' BDPANELNAME}_{BOA !NAME}.hB {PANELNAME} is the $lcd panel type.

h that includes all the distributed bitmaps% so you can include this to make the bitmaps available' GLCD 1ersion 2 (3eta) 4un 5 . ICheck the datasheet or your panel to veri y appropriate timin$ values are set in the con i$uration ile. ICheck contrast volta$e (typically between A2 and A@ volts) on contrastAin pin o LCD panel. The L pixel hi$h system ont uses under +!! bytes% the supplied Arial"@ ont uses ". I?un GLCDdia$s test sketch% see Con i$uration section above.h that includes all the distributed onts% so you can include these iles instead o explicitly includin$ the individual onts $incl#de (fon)s/all-on)s. Eor example% i you create a ont named my ont in a header named my ont. The so tware is called EontCreator. Chile the sketch is operatin$% try $radually adKustin$ the pot throu$h its ran$e.h( // s+s)e* fon) To use the ont in your sketch you select the ont as ollows' . The distribution contains a ile named all3itmaps.!! bytes o pro$ram memory Using bitmaps :ou can use the distributed bitmaps or create your own. Using fonts There is a ree Kava application available that can convert (C onts or use with this library.LC!.!"! .h( // all dis)"i1#)ed fon)s Eont de initions are stored in pro$ram memory and this can be si$ni icant or lar$er onts.%elec)-on).o pixels visible on the display ICheck =+v and Gnd connections between Arduino and GLCD panel ICheck all data and command pins are wired accordin$ to the datasheet and matchin$ the con i$uration settin$s J this is the most common cure to this problem. ICheck the datasheet or your panel to veri y appropriate timin$ values are set in the con i$uration ile. Le t and ri$ht side o ima$e reversed I&wap C&*L" and C&*L. and it can produce a header ile that can be included in your sketch. &ome displays are very sensitive to this settin$.ote that the distribution contains a ile named allEonts. ICheck that sketch has compiled correctly and has downloaded to Arduino.h then copy my ont.Troubleshooting . The header iles should be placed in the directory named onts and included in your sketch. wires (or swap pin assi$nments in the con i$uration ile) Display $arbled ICheck all data and command pins are wired correctly and that these match the settin$ in the con i$uration ile.*+fon)/0 // #se *+fon) .h to the onts directory and in your sketch' $incl#de (fon)s/*+fon).

t now supports more chips and is easier to inte$rate with di erent panels.LC!.ote that included bitmaps will not consume any memory i they are not explicitly re erenced in your sketch with the Drw3itmap unction.bmp% the header is named ima$e.!"! . The $raphical unctions are backwards compatible (except where noted) so existin$ sketches should work with little or no modi ication to the code.or$6 There is a Kava runtime ile ($lcd/ake3itmap.pde is a sketch that can be run usin$ the (rocessin$ environment (its in the bitmaps6utils6$lcd/ake3itmap directory.con. the ima$e can be converted% a header ile is created in the bitmap directory. Eor example% i the ima$e ile name to be converted is named ima$e.Kava) in thee bitmaps6utils64ava directory ?un the utility by loadin$ the pde into (rocessin$ (or click on the Kar ile) and dra$ and drop the ima$e ile to be converted into the window.ma$es are stored in pro$ram memory% a ". Migrating your sketch from ks0108 to the new !C" library The GLCD library is an extensive modi ication o the ks!"!# library.#x7@ pixel ima$e takes "k bytes o lash. A utility named $lcd/ake3itmap converts a $i % Kp$% bmp% t$a or pn$ ile to a header ile that can be read by the $lcd library. :ou can also display your own ima$es in your sketch. your wirin$ does not match the de ault pin GLCD 1ersion 2 (3eta) 4un 5 .Kar) and Kava source ($lcd/ake3itmap.i*age4 54 +/0 where x and y are the desired location o the upper le t ed$e o the bitmap. $lcd/ake3itmap. $lcd/ake3itmap displays the amount o memory re0uired or the ima$e and other use ul in ormation when it does the conversion. Eor more in ormation on (rocessin$% see' http'66processin$. The con i$uration mechanism has been chan$ed to acilitate use with a broad ran$e o GLCD chips and ATme$a controllers.h( // all dis)"i1#)ed 1i)*a2s . . 3ear in mind that each di erent ima$e used in a sketch will reduce the amount o code available to a sketch. . $lcd/ake3itmap window a ter droppin$ an ima$e named arduino.h( and display the ima$e usin$ the ollowin$ code' .h Add the ollowin$ line to the sketch' $incl#de (1i)*a2s/i*age. .$incl#de (1i)*a2s/allBi)*a2s.!"a3Bi)*a2. .

The old library wrapped to the column where the strin$ started% the new library now wraps to the be$innin$ o the text area.h( // s+s)e* fon) to $incl#de (fon)s/%+s)e*-on)657.h( // 89589 1i)*a2 The Arduino.h( // s+s)e* fon) 3itmaps are now in a bitmaps subdirectory and the ile names include the width and hei$ht< so chan$e ' Hinclude BArduino. The distribution includes the system ont and arial"@ onts that were distributed with the previous version% but these are now in a subdirectory called M onts9 so you will need to modi y the include statement' chan$e $incl#de (%+s)e*-on)657. This means that i there are $raphics very close below the character they may be overwritten with the new text ouput code.h bitmap ile was renamed to Arduino. GLCD 1ersion 2 (3eta) 4un 5 . &ee the section on Text Areas to see how you can use this new capability to control where text will wrap on the display.!"! . The workaround is to either move the $raphics obKects so they are not cleared when the text is written or to draw the $raphical obKects a ter the text is displayed.con7@x7@. The new library now sets or clears all pixels o a ont ($lyph)% the old library did not consistently erase pixels in the whitespace below the $lyph.h ile supplied with the old library% but i you chan$ed the Arduino pin numbers you will need to modi y ks!"!#8Con i$ to match your wirin$. Another chan$e is the way a strin$ wraps on the newline character. you are usin$ any o the ollowin$ unctions you should either chan$e the code use the new unction or include $lcd8Deprecated.con.assi$nments you will need to need to modi y the con i$uration iles in the new library to match your wirin$.h to di erentiate it rom other si-e bitmaps supplied or panels o di erent pixel dimensions. Draw1ertLine(x% y% len$th% color) is now' Draw1Line(x% y% len$th% color) Draw>oriLine(x% y% len$th% color) is now ' Draw>Line(x% y% len$th% color) Clear&ysTextLine(row) is now *raseTextLine(row) The character output unctions behave di erently in the new library. The ks!"!#8Con i$%h ile included in the distribution uses exactly the same pins as the ks!"!#8Arduino.hB 66 the bitmap distributed with the ks!"!# lib To $incl#de (1i)*a2s/A"d#ino&con89589.con. &ee the section on Con i$uration or details on the new con i$uration iles.h ile that will convert the old unction name to the new unction. :ou can use the same wirin$ as the old library but the con i$uration ile ormat has chan$ed. .

!%! is the pixel on the upper le t ed$e o the screen Table o contents GLCD Graphical LCD library Wiring and Configuration: Configuration A1? port and pin numbers Troubleshooting Using fonts Using bitmaps Migrating your sketch from ks0108 to the new !C" Methods: .!C" Methods: >ere is a summary o the methods supported by this library.nvert?ect() Draw?ound?ect() DrawCircle EillCircle() Draw3itmap() Te$t #unctions &electEont() &etEontColor() &etText/ode() ClearArea() *raseTextLine(row) *raseTextLine() CursorToN:() Arduino print unctions !C" library GLCD 1ersion 2 (3eta) 4un 5 .nit() &etDisplay/ode() Clear&creen() ?eadData() CriteData() "rawing #unctions Coordinate system (roperties Colors GotoN:() &etDot() Draw1Line() Draw>Line() DrawLine() Draw?ect() Eill?ect() .ote that all coordinates start rom ! unless otherwise noted. .!"! .

nit(..A .1*?T*D)< 66 sets the state to inverted (. &yntax GLCD.1*?T*D) < 66 initiali-e the library to draw li$ht pixels on a dark back$round (arameters .&etDisplay/ode(.1*?T*D) < 66 same as above GLCD.1*?T*D)< 66 sets the state to normal GLCD.nit() < 66 initiali-e the library to draw dark pixels on a li$ht back$round GLCD.&etDisplay/ode(.ote this unction was named &et.umber() (uts8(() Init() Description' This should be called in setup to initiali-e the library prior to callin$ any other unction.nit(.A.F.!"! ..nit(..Text Areas De ineArea() *nhanced print unctions printElash () printElashln () (rint () (rint 8( () CharCidth() &trin$Cidth() &trin$Cidth8(() Le$acy text output unctions (utChar() (uts() (rint.8..T* colored pixels are dark) &yntax GLCD.F.nit with no parameter is the standard initiali-ation% this is identical to' ...nit(.F. The display is cleared and ready or use a ter callin$ .1*?T*D) will invert dark and li$ht pixels when drawn SetDisplayMode() Description' sets the $raphical state to normal (3LAC) colored pixels are dark)% or inverted (C>...nit..1*?T*D) .nverted() in the previous library releases) GLCD 1ersion 2 (3eta) 4un 5 .

CriteData( data)< GLCD 1ersion 2 (3eta) 4un 5 .ClearScreen() Description' *rases all screen pixels (pixels rom !%! to GLCD.Clear&creen()< 66 sets all pixels to C>.>ei$htA ") &yntax GLCD.T* (i . ReadData() Description' ?eturns the data byte at the current x%y location &yntax' GLCD.?eadData()< &ee also' GotoN:()< 66 return the byte o data at the current x%y location WriteData() Description' Crites the $iven byte o data at the current x%y location &yntax' GLCD..ote' .Clear&creen( 3LAC))< 66 clears screen writin$ 3LAC) pixels .1*?T*D mode% then the color C>.!"! .T* will paint the screen 3LAC) and the color 3LAC) will paint the screen C>. the display is in ..Clear&creen(C>.T*.1*?T*D) GLCD.T*)< 66 same as above GLCD.F?/AL mode or 3LAC) i .CidthA"%GLCD.

GLCD.Cidth6.!"! .hei$ht is the hei$ht o the display in pixels GLCD.>ei$htA") GLCD.?i$ht is the ri$htAmost pixel (e0uals GLCD.CenterN is the hori-ontal center (e0uals GLCD.CidthA") GLCD.) GLCD.3ottom is the bottom pixel (e0uals GLCD.>ei$ht6.) GLCD 1ersion 2 (3eta) 4un 5 .Center: is the vertical center (e0uals GLCD."rawing #unctions Coordinate system !%! is the upper le t ed$e o the display.Cidth is the width o the display in pixels GLCD.

T* is a pixel that is not dark 3LAC) is the de ault color Goto!"() Description' moves the $raphics cursor to the $iven x%y coordinates.?i$ht A the display width A" GLCD.T*)< 66 erases the pixel at x%y (arameters x J a value rom ! to GLCD.Draw1ertLine(x% y% hei$ht% C>.CidthA" y A a value ron ! to GLCD.>ei$htA" Dra#VLine() Description' Draws a vertical line &yntax GLCD.Center:A hal o the display hei$ht Colors Two colors are supported in this version.Draw1ertLine(x% y% hei$ht)< 66 draws a 3LAC) line rom x%y to x% y = hei$ht GLCD.>ei$htA" SetDot() Description' sets the pixel at the $iven x%y coordinate to the $iven color &yntax GLCD.3ottom A the display hei$ht A" GLCD.Draw1ertLine(x% y% hei$ht% 3LAC))< 66 as above GLCD.GotoN:(x%y)< (arameters x J a value rom ! to GLCD.!"! .roperties GLCD.>ei$h A the display hei$ht in pixels GLCD.CenterN A hal o the display width GLCD.Cidth A the display width in pixels GLCD. &yntax GLCD.T*)< 66 as above but the pixels on the line are erased GLCD 1ersion 2 (3eta) 4un 5 .&etDot(x%y% C>.CidthA" y A a value ron ! to GLCD.&etDot(x%y% 3LAC))< 66 draws a 3LAC) pixel at x%y GLCD. 3LAC) is a dark pixel% C>.

T* is an optional parameter indicatin$ pixel color% de ault is 3LAC) (.!"! .DrawLine( x"% y"% x.CidthA" y A a value rom ! to GLCD.CidthAxA" 3LAC) or C>.(arameters x J a value rom ! to GLCD.ote this unction was named Draw>oriLine() in the previous library releases) Dra#Line() Description' Draws a line between two coordinates. &yntax GLCD.% 3LAC))< 66 as above GLCD.% y.CidthA" y A a value rom ! to GLCD.ote this unction was named Draw1ertLine() in the previous library releases) Dra#$Line() Description' Draws a hori-ontal lines &yntax GLCD.>ei$htA" hei$ht J a value rom " to GLCD.>ei$htAyA" 3LAC) or C>.DrawLine( x"% y"% x.< 66 draws a 3LAC) line rom x"%y" to x.Draw>oriLine(x% y% width% 3LAC))< 66 as above GLCD. A a value ron ! to GLCD.Draw>oriLine(x% y% width)< 66 draws a 3LAC) line rom x%y to x = width % y GLCD.CidthA" indicatin$ end x coordinate y.% y.CidthA" indicatin$ start x coordinate y" A a value ron ! to GLCD.Draw>oriLine(x% y% width% C>.% y.%y.T*)< 66 as above but the pixels on the line are erased (arameters x J a value rom ! to GLCD.T* is an optional parameter indicatin$ pixel color% de ault is 3LAC) (.>ei$htA" width J a value rom " to GLCD.T*)< 66 as above but the pixels on the line are erased (arameters x" J a value rom ! to GLCD.% C>.DrawLine( x"% y"% x. J a value rom ! to GLCD.T* are optional parameters speci yin$ pixel color% de ault is 3LAC) GLCD 1ersion 2 (3eta) 4un 5 .>ei$htA" indicatin$ end y coordinate 3LAC) or C>. GLCD.>ei$htA" indicatin$ start y coordinate x.

1. The rectan$le is illed usin$ the $iven color (3LAC) i none $iven) (.Draw?ect( x% y% width% hei$ht% 3LAC))< GLCD. 1. The top and bottom ed$es are at + and + : heigh) < 1 GLCD 1ersion 2 (3eta) 4un 5 . The le t and ri$ht ed$es o the inverted area are at 5 and 5 : 3id)h .Eill?ect( x% y% width% hei$ht)< GLCD.Draw?ect( x% y% width% hei$ht% C>.Eill?ect( x% y% width% hei$ht% 3LAC))< GLCD.Draw?ect( x% y% width% hei$ht)< width and hei$ht startin$ at x%y GLCD. 1.T*)< are erased 66 draws a 3LAC) rectan$le o $iven 66 as above 66 as above but the rectan$le pixels (arameters x% y J the x%y coordinates o the rectan$le to be drawn width% hei$ht J the width and hei$ht o the rectan$le %illRect() Description' Eills the interior o a rectan$le speci ied by a pair o coordinates% a width% and a hei$ht.ote that the len$th o the hori-ontal sides will be width=" pixels% the vertical sides will be hei$ht=" pixels &yntax GLCD.Eill?ect( x% y% width% hei$ht% C>.!"! . The resultin$ rectan$le covers an area 3id)h pixels wide by heigh) pixels tall startin$ rom the pixel at x%y. This chan$e was to make the unctionality consistent with the way 4ava and CH create illed rectan$les) &yntax GLCD. The le t and ri$ht ed$es o the rectan$le are at 5 and 5 : 3id)h . The illed rectan$le will be one pixel smaller in width and hei$ht than the old version.T* pixels 3LAC) within the $iven rectan$ular area. The top and bottom ed$es are at + and + : heigh) .T*)< erased 66 as above 66 as above but the rectan$le pixels are In&ertRect() Description' &ets 3LAC) pixels C>.Dra#Rect() Description' Draws a rectan$le o $iven width and hei$ht x%y is the upper le t ed$e o the rectan$le The lower ri$ht ed$e is at x=width% y=hei$ht .ote that Eill?ect behavior has chan$ed rom the previous versions o the library.T* and C>.

!"! .CidthA") y A a value ron ! to GLCD.?i$ht (GLCD..DrawCircle( x% y% r)< 66 draws a 3LAC) circle centered at x%y with radius r GLCD.DrawCircle( x% y% r% C>.T*)< 66 draws a C>.3ottom (GLCD.Draw?ound?ect( x% y% width% hei$ht% radius% C>.Draw?ound?ect( x% y% width% hei$ht% radius)< 66 draws a 3LAC) rectan$le similar to Draw?ect but with corners o the $iven radius GLCD.>ei$htA") radiusA a value rom " to hal the hei$ht or width o the rectan$le %illCircle() Description' Draws a illed in circle centered at x%y with the $iven radius &yntax and (arameters GLCD 1ersion 2 (3eta) 4un 5 .ote that because the circle is drawn rom the center pixel out% the diameter will be . O radius =" pixels.Draw?ound?ect( x% y% width% hei$ht% radius% 3LAC))< 66 as above GLCD.DrawCircle( x% y% r% 3LAC))< 66 as above GLCD.T* circle centered at x%y with radius r (arameters x J a value rom ! to GLCD.nvert?ect( x% y% width% hei$ht)< (arameters As Eill?ect but without the color parameter 66 inverts pixels in the $iven rectan$ular area Dra#RoundRect() Description' Draws a rectan$le with rounded corners &yntax GLCD.&yntax GLCD.T*)< 66 as above but the rectan$le pixels are erased (arameters x%y%width%hei$ht as Draw?ectan$le radiusA a value rom " to hal the hei$ht or width o the rectan$le Dra#Circle Description' Draws a circle centered at x%y with the $iven radius The circle will it inside a rectan$ular area bounded by xAradius%yAradius and x=radius%y=radius . &yntax GLCD.

&etText/ode(&C?FLL8DFC.T* pixels GLCD.&etText/ode() Description' 66 &ets the $iven text mode (currently only scroll direction is supported) &yntax GLCD.Draw3itmap(Obitmap% x% y% 3LAC))< 66 as above GLCD.T*)< 66 inverts pixels Te$t #unctions Select%ont() Description' &elects the ont de inition as the current ont. &yntax GLCD.Draw3itmap(Obitmap% x% y)< GLCD. Eont de initions are stored in pro$ram memory.Draw3itmap(Obitmap% x% y% C>.&etEontColor( 3LAC)) 66 printed output rendered as 3LAC) pixels GLCD.!"! .T*) 66 printed output rendered as C>. &ubse0uent printin$ unctions will use this ont.&electEont( ont) < 66 ont is a ont pointer de ined in a ont de inition ile.) 66 reverse scroll direction% old lines scroll down GLCD 1ersion 2 (3eta) 4un 5 . &yntax GLCD.&etText/ode(&C?FLL8G() 66 normal scroll direction% old lines scroll up GLCD.T*) 66 printed output rendered as C>. 3itmap data is in pro$ram memory (Elash) A utility or creatin$ bitmap header iles% $lcd/ake3imtap% is supplied with the download &yntax GLCD. Futput is rendered usin$ dark pixels.see DrawCircle Dra#'itmap() Description' Draws a bitmap ima$e with the upper le t ed$e at the x%y coordinates.&etEontColor( C>.&electEont( ont% 3LAC)) 66 as above GLCD. :ou can have as many onts de ines as will it in pro$ram memory and can switch between them with this unction.T* pixels Set%ontColor() Description' &ets the color o the currently selected ont. GLCD.&electEont( ont% C>.

&yntax GLCD.CursorToN:( x%y)< GLCD 1ersion 2 (3eta) 4un 5 . Chen variable width onts are used% the column calculation uses the width o the widest character. The cursor is set to the upper le t corner.&etText/ode(&C?FLL8DFC.*raseTextLine(eraseTF8*FL)< GLCD.ClearArea()< 66 clears the text area and sets the cursor to the upper le t corner o the text area *rase(e)tLine(ro#) Description' clears all text on the $iven row within the text area% moves the cursor to the le t position.CursorTo( column% row)< 66 ! based coordinates or character columns and rows Cursor(o!"() Description' moves the text cursor to the coordinates $iven by x%y relative to the upper le t corner. &yntax GLCD. *rase(e)tLine() Description' clears text on the current line% de ault is to clear rom the cursor to the end o the text area &yntax GLCD.Set(e)tMode() Description' 66 &ets the $iven text mode (currently only scroll direction is supported) &yntax GLCD.&etText/ode(&C?FLL8G() 66 normal scroll direction% old lines scroll up GLCD.*raseTextLine(eraseEGLL8L..*)< 66 erase rom cursor to end o line 66 as above 66 erase rom be$innin$ o line to cursor 66 erase the entire line Cursor(o() Description' move the cursor to the $iven row and column.*raseTextLine()< GLCD.!"! .) 66 reverse scroll direction% old lines scroll down ClearArea() Description' clears the current text area usin$ the current ont back$round color.*raseTextLine(eraseE?F/83FL)< GLCD. &yntax GLCD.

GLCD 1ersion 2 (3eta) 4un 5 .arduino.) < 66 prints the binary value o the inte$er GLCD. Draw&trin$8(((ro$/em&trin$% x% y)< Description' as above but the strin$ is de ined in (ro$ram memory ( lash) Arduino print +unctions All o the Arduino print unctions can be used in this library% see' http'66www.Draw&trin$(str% x% y)< Description' prints the $iven strin$ o characters startin$ rom the $iven x and y coordinates. All o these unctions print rom the current cursor position (see GotoN: and CursorTo) GLCD.cc6en6&erial6(rint The unctions work with any selected ont. GLCD. print(inte$er% 3:T*)< 66 prints the A&C.. print( loat% di$its)< 66 prints a loatin$ point number usin$ the $iven number o di$its a ter the decimal point GLCD.!"! . print(inte$er% 3. println(variable)< will wrap to the next line at the end o the print.. print( lash&tr(Pstrin$Q) ) < 66 stores the strin$ in Elash memory ((ro$mem) % no ?A/ is used to store the strin$ GLCD. print(inte$er% FCT) < 66 prints the octal value o the inte$er GLCD. print(inte$er%D*C)< 66 as above GLCD. (rintin$ strin$s usin$ the lash&tr pre ix results in the compiler usin$ lash rather than ?A/ to store the strin$ GLCD. println( lash&tr(Panother strin$Q) ) < 66 as above% but wraps ollowin$ text to the next line (e)t Areas All o the text unctions described above can be applied to a select rectan$ular area o the screen% called a text area. print(Pstrin$Q) < 66 strin$ stored in ?A/' the compiler reserves L bytes o ?A/ (strin$ len$th = ") to store the strin$ GLCD. (rintin$ strin$s can consume a lot o ?A/. print(inte$er% >*N)< 66 prints the hexadecimal value o the inte$er GLCD. print( loat)< 66 prints a loatin$ point number usin$ two decimal places GLCD. character represented by the inte$er GLCD. print(character)< 66 prints the character at the current cursor position GLCD. print(inte$er)< 66 prints the decimal value o the inte$er GLCD. The coordinates are relative to the text areaA use a text area coverin$ the ull display i you want the x%y parameters to be the same as the coordinates or Graphical unctions like GotoN:. print(strin$) < 66 prints the strin$ The println variants o these unctions are also supported.

G>T.G>T% textAreaTF(L*ET%textAreaTF(?. Eor proportional (variable width) onts% the width o widest character is used.% y. scrollDirection can be &C?FLL8G( or &C?FLL8DFC.println(Pa line o textQ)< 66 print a line o text to the text area.Center: A"7% GLCD.Center:="7)< 66 create a text area coverin$ the center 2. De ineArea( x"% y"% columns% rows% ont% scrolldirection)< As above but the hei$ht and width o the area is determined by the number o columns and rows or the $iven ont. pixels o the display All o the text unctons operate on a text area by usin$ the text area name instead o MGLCD9% or example' textTop. The rectan$ular area can be speci ied usin$ either' a prede ined area % an area determined by a $iven number o rows and columns o the $iven ont% or a rectan$ular area speci ied by the upper le t and lower ri$ht pixel coordinates.% i scrollDir is omitted the direction will be &C?FLL8G(.CenterN ="7% GLCD.% y.CenterNA"7% GLCD.&electEont(&ystem+xL)< 66 select the system ont or the text area name textTop textTop. De ineArea( x"% y"% x.% determine the rectan$ular area o the text window GLCD 1ersion 2 (3eta) 4un 5 . Eor example' $Text textTop R $Text(textAreaTF()< 66 create a text area coverin$ the top hal o the display $Text myTextArea R $Text(GLCD.!"! .% scrolldir)< (or width%hei$ht as you pre er As above but x"% y"% x. Text Areas are created usin$ one o the three De ine Area methods described below' De+ineArea() Description' de ines the rectan$ular area or text output.A text area acts like a virtual terminal and text output is displayed within the con ines o a rectan$le $iven in the De ineArea command. &yntax De ineArea( preDe inedArea% scrollDirection)< 66 create a text area usin$ one o the prede ined values preDe inedArea is one o ' textAreaEGLL% textAreaTF(% textArea3FTTF/% textAreaL*ET% textArea?.G>T%textArea3FTTF/L*ET%textArea3FTTF/?. &ee the download sketches or more example usa$e.

Gsers not already amiliar with usin$ print are advised that the standard Arduino print unctions are simpler to use. &yntax GLCD.ClearArea()< 66 clear the text area countdownArea. The ar$ument list types must match the ormat ta$s. rint+. () Description' as (rint above but the ormat strin$ is stored in Elash instead o ?A/ &yntax GLCD.CenterN% GLCD.print(count)< 66 print a di$it in the text area *nhanced print +unctions print%lash () Description' Allocates and prints a strin$ in Elash (pro$ram memory) &yntax GLCD.printElashln( strin$)< rint+ () Description' Crites a se0uence o data ormatted as speci ied by the ormat ar$ument.(rint 8(( ormat% ar$uments T)< &ee (rint () GLCD 1ersion 2 (3eta) 4un 5 .Center:%"%"%Arial8"@)< 66 declare text area or a sin$le di$it countdownArea.(rint ( ormat% ar$uments T)< The ormat strin$ contains text or optional embedded ormat ta$s. The ollowin$ ra$ment ( rom the $lcdDemo example sketch) creates a text area in the center o the screen usin$ the Arial8"@ ont that is holds a sin$le character ( one column wide by one row hi$h)' $Text countdownArea R $Text(GLCD.printElash(strin$)< print%lashln () Description' As printElash but wraps ollowin$ text to the next line &yntax GLCD.!"! .All o the Text unctions listed above can be used with user de ined areas. The ormat strin$ uses standard print () ormatin$ S ta$s% but loatin$ point is not supported.

&yntax GLCD. and have more unctionality. (utChar(c)< 66 print the character c at the current cursor position (same as GLCD. () Description' returns the width in pixels o the $iven strin$ stored in pro$ram memory &yntax byte width R GLCD. The new (utChar() does newline processin$ and will wrap and potentially scroll the text window.print routines. utChar() Description' prints the $iven character at the current cursor position. &trin$Cidth8((($m&trrin$)< Le-acy te)t output +unctions The ollowin$ unctions are supported or backward compatibility with previous library versions% the GLCD.print(character) is used in new applications J it has identical unctionality with the bene it o similar syntax to other arduino print methods.ote that there is a subtle di erence in the way this unction handles the newline character compared to the ks!"!# library.CharWidth() Description' returns the width in pixels o the $iven character includin$ any interA character $ap pixels ollowin$ the character when rendered on the display. . The old (utChar() would treat the newline character Kust like any other character and since many onts donUt don9t have a $lyph de ined or the newline its would be thrown away. &trin$Cidth(strin$)< Strin-Width. CharCidth(c)< Strin-Width() Description' returns the width in pixels o the $iven strin$ in the currently selected ont &yntax byte width R GLCD.print unctions are compatible with &erial.!"! .print(c)< GLCD 1ersion 2 (3eta) 4un 5 . . &yntax byte width R GLCD.t is su$$ested that the Arduino print character unction% GLCD.

&o the new (uts()6(utchar() will wrap " pixel lower than the old (uts() routine. &yntax GLCD.ote that the old library would process newlines in (uts().!"! . . . Also% the old (uts() assumed -ero paddin$ below a ont while the new (uts() handles paddin$ consistently across all the unctions. &ee also printElash which allocates and prints the strin$ in pro$ram memory GLCD 1ersion 2 (3eta) 4un 5 . (uts(strin$)< 66 66 print the strin$ at the current cursor position (same as GLCD.uts() Description' prints the $iven strin$ o characters startin$ rom the current cursor position. () Description' prints a strin$ stored in pro$ram memory startin$ orm the current cursor position.print(number)< uts.umber() &ee GLCD.t would wrap to the text line below the current line but back to the N position where strin$ printin$ started. (uts8((pro$/em&trin$)< .ote that the strin$ bein$ printed must already be de ined as a pro$ram memory strin$.print(strin$)< rint. The new code lets (utChar() process the newlines and so a new line will wrap to the line below but will wrap to the start N position o the text window rather than the N position when the (uts()started. &yntax GLCD.

Sign up to vote on this title
UsefulNot useful