Home
PICASO Internal 4DGL Functions
Contents
1. GFX_TOUCH_REGION_X1 103 0x67 touch capture region GFX_TOUCH_REGION_Y 104 0x68 GFX TOUCH REGION X2 105 0x69 GFX TOUCH REGION Y2 106 0x6A GFX CLIP LEFT VAL 107 0x6B left clipping point set with gfx_ClipWindow GFX CLIP TOP VAL 108 Ox6C top clipping point set with gfx ClipWindow GFX CLIP RIGHT VAL 109 Ox6D right clipping point set with gfx_ClipWindow GFX CLIP BOTTOM VAL 110 Ox6E bottom clipping point set with gfx ClipWindow GFX CLIP LEFT 111 Ox6F current clip value reads full size if clipping turned off GFX CLIP TOP 112 0x70 current clip value reads full size if clipping turned off GFX CLIP RIGHT 113 0x71 current clip value reads full size if clipping turned off GFX CLIP BOTTOM 114 0x72 current clip value reads full size if clipping turned off GRAM PIXEL COUNT LO 115 0x73 LO word of count of pixels in the set GRAM area GRAM PIXEL COUNT HI 116 0x74 HI word of count of pixels in the set GRAM area TOUCH RAW X 117 0x75 12 bit raw A2D X value from touch screen TOUCH RAW Y 118 0x76 12 bit raw A2D Y value from touch screen GFX LAST CHAR WIDTH 119 0x77 calculated char width from last call to charWidth function GFX LAST CHAR HEIGHT 120 0x78 calculated height from last call to charHeight function GFX LAST STR WIDTH 121 0x79 calculated width from last call to strWidth function GFX LAST STR HEIGHT 122 0x7A calculated height from last call to strHeight function
2. 191 VIMEEUAC EUR STU 192 2 13 3 sys SetTimer timernum value esses esee nennen enne enne enne nennen nennen nnne 193 2 13 4 sys GetTimer timernum esseessseeeeeeeeeene nennen enne enne nennen senes innen n enne nnn enn 194 2 13 5 sys SetTimerEvent timernum function sssssssseeseeeeeee nennen nnn nre 195 2 13 6 sys EventQueue i eie ee edo tree ORE Ra RR ar n cb vans AE Cie dt eR Pep Souder Ra Rad 196 2 13 7 SYS EventsPostpornel in iices citro tnra na rh va ck eni deor Rr Dae FR HR ame Bra pK e PEE a eaae aaa 197 2 13 8 sys EventsReSUmie uscite tredecim ett eren det deceat ne vue pee e es deoa exe cna tuens ener due xoa 198 2 13 9 SyS Sleep UNITS ssanie elo tree trien oes inoia ena eene casts con eu dede aa eset eade enirn aeuo 199 2 13 10 iterator offset uois coner dI eee erroe perra e E Pe Foto rene tete soda eras AE ee EERE E 200 2 14 SN BEES File FUNCTIONS a ciescccidcecesssetevcnesencheotevenasenesesencdevsssceacncednectenbasdeevsnecedupsensecehiet EEEa 201 2 14 41 FG aea ER A T A EA 202 2 14 2 file Count eM AME enuncia bend xo E ER Roe aaa ERE a aa e aa aaia 203 214 3 file Dir filenamie rete tirare tern renati caste es ai nhe eek eie aE paa v Dae a uda 204 2 14 4 file FindFirst fname esseesees eese enne nennen senes nn nennen 205 2 14 5 file FihidINeXE usen ee ens ee enata eset aeta rena ccu te eheu ena Deep easi et enata neus ea aye dun se eR
3. Description This function requires that an image control has been created with the file LoadlmageControl function Returns index if image touched or returns 1 image not touched If index is passed as 1 the function tests all images and returns 1 if image not touched or returns index Example etal Siecle LO CHme REIS S EID n img Touched Ihndl 1 scan image list looking for a touch if n 1 last n button n img Lighten Ihndl n lighten the button touched img Show Ihndl 1 restore the images endif endif un Z T Z zm TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 286 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 Memory Allocation Functions Summary of Functions in this section e mem Alloc size e mem Allocv size e mem Allocz size e mem Realloc ptr size e mem Free allocation e mem Heap e mem Set ptr char size e mem Copy source destination count e mem Compare ptr1 ptr2 count un Z T Z TE J D QO I S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 287 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 1 mem_Alloc size Syntax mem_Alloc size Arguments size byte size Specifies the number of bytes that s allocated from the heap Returns value Returned value is the pointer W
4. Example var vx 7 vy 7 func main vx 0 10 vy 0 10 vx 1 ESI NIE vx 2 80 vy 2 10 wells BOF sS 257 vx 4 80 vy 4 40 wee ES SOF wis 8e 507 vx 6 10 vy 6 40 un Z fees T Z m TE J D m 2 q Z Y TT Z gfx Polygon 7 vx vy RED repeat forever endfunc This example draws a simple polygon PICASO 2012 4D SYSTEMS Page 89 of 317 www 4dsystems com au Wn Z O U z D Ti Bj D m T a q Z a T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 12 gfx_Triangle x1 y1 x2 y2 x3 y3 colour Syntax gfx_Triangle x1 y1 x2 y2 x3 y3 colour Arguments x1 y1 x2 y2 x3 y3 colour x1 y1 specifies the first vertices of the triangle x2 y2 specifies the second vertices of the triangle x3 y3 specifies the third vertices of the triangle colour Specifies the colour for the triangle The arguments can be a variable array element expression or constant Returns nothing Description Draws a triangle outline between vertices x1 y1 x2 y2 and x3 y3 using the specified colour The line may be tessellated with the gfx LinePattern function Example gfx Triangle 10 10 30 10 20 30 CYAN This example draws a CYAN triangular outline with vertices at 10 10 30 10 20 30 2012 4D SYSTEMS Page 90 of 317 www 4dsystems com au 4D SYSTEMS PICASO INT
5. Returns Returns 16 bit value in the register Description Read a word from the display un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 129 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 7 disp_Sync line Syntax disp_Sync line Arguments line line Scan line Returns Returns 16 bit value in the register Allows the program to synchronise writing to the hardware for flicker free operation Some experimentation may be needed to find an optimum line for disp_Sync depending on the graphics operation The higher the value the slower the throughput A certain point will be reached number of scanlines blanking lines within the vertical retrace period where it will Ls just hang up stopping the entire process Eg in 640x480 mode if the lines value is 507 Description operation will be slowest as its actually right at the end of the blanking period and 508 will cause a hangup situation as it is above the highest scanline value Note Applies to uVGA II GFX module only un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 130 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 Media Functions SD SDHC Memory Card or Serial Flash chip The media can be SD SDHC microSD or serial NAND flash
6. Improvement of img SetlmageControl description un Z T Z m TE J D m T E q Z Y TT Z PICASO 2012 4D SYSTEMS Page 316 of 317 www 4dsystems com au Uu Z O U Z TE a D e Ej q Z a T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 9 Legal Notice Proprietary Information The information contained in this document is the property of 4D Systems Pty Ltd and may be the subject of patents pending or granted and must not be copied or disclosed without prior written permission 4D Systems endeavours to ensure that the information in this document is correct and fairly stated but does not accept liability for any error or omission The development of 4D Systems products and services is continuous and published information may not be up to date It is important to check the current position with 4D Systems 4D Systems reserves the right to modify update or makes changes to Specifications or written material without prior notice at any time All trademarks belong to their respective owners and are recognised and acknowledged Disclaimer of Warranties amp Limitation of Liability 4D Systems makes no warranty either expressed or implied with respect to any product and specifically disclaims all other warranties including without limitation warranties for merchantability non infringement and fitness for any particular purpose Information contained in this publi
7. T c I T Z TE J T I J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS gfx MoveTo xpos 8 ypost5 parsti etie be p set the title text endsub Update for n 20 n MAXBUTTONS n if vButtonState n vOldButtonState n vOldButtonState n vButtonState n gfx Button vButtonState n touchX1 n touchYl n btncolor textcolor font 1 1 buttontexts n redraw the button endif next Do any other update operations here endsub Uf PSS SSS SS SS SSS SSS SS SS SS cocco cocco scan for any button presses ff SaaS SSS SSS SS SS SSS SS SSS SS SS SSS SSS SS SSS SSS SS SSS Scan touchState touch Get TOUCH STATUS save touchscreen status touchX touch Get TOUCH GETX and current position Kouch concha cer OUCH EY if screen touched if touchState TOUCH PRESSED scan the hot spots list while n MAXBUTTONS amp amp r if touchX gt touchX1 n amp amp touchX lt touchX2 n amp amp touchY gt touchY1 n amp amp touchy lt touchY2 n r ntl igarar E wend if any button was pressed ab3E ie lastkey r remeber the button vButtonState r 1 DOWN set it to down state gosub Update update the button action endif endif if touchState TOUCH RELEASED amp amp lastkey if touch released and we remember a previous button press retval lastkey set return value with the button
8. Returns None Description Set a countdown on the selected timer or top up if required There are 8 timers TIMERO to TIMER7 which stop at the count of 0 Maximum timeout period is 65 535 milliseconds or 65 535 seconds A timer can be read with the sys GetTimer timernum function Example eys Settiner THMIRS SOOO 2 SSE Tubwescs for dL hour un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 193 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 4 sys_GetTimer timernum Syntax sys_GetTimer timernum Arguments timernum timernum One of eight timers TIMERO to TIMER7 Returns Value Value Returns 0 if timer has expired or the current countdown value Description Returns O if timer has expired or the current countdown value There are 8 timers TIMERO to TIMER7 which stop at the count of 0 Maximum timeout period is 65 535 milliseconds or 65 535 seconds A timer can be set with the sys SetTimer timernum value function Example t sys GetTimer TIMER2 un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 194 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 5 sys SetTimerEvent timernum function Syntax sys SetTimerEvent timernum function
9. 2012 4D SYSTEMS Page 33 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 6 COS angle Syntax COS angle Arguments angle angle The angle in degrees Note The input value is automatically shifted to lie within 0 359 degrees The arguments can be a variable array element expression or constant Returns result result The cosine in radians of an argument specified in degrees The returned value range is from 127 to 127 which is a more useful representation for graphics work The real sine values vary from 1 0 to 1 0 so appropriate scaling must be done in user code as required Description This function returns the cosine of an angle Example var myvar angle angle 133 myvar COS angle This example returns 86 in variable myvar un Z I T Z em TE J D SI 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 34 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 7 RAND Syntax RAND Arguments none Returns value value Returns a pseudo random signed number ranging from 32768 to 32767 each time the function is called The random number generator may first be seeded by using the SEED number function The seed will generate a pseudo random sequence that is repeatable You can use the modulo operator 96 to return a number within a certain
10. The arguments can only be a variable or an array element Returns nothing Description Given the addresses of two variables varl and var2 the values at these addresses are swapped Example var numberl number2 numberl 33 number2 66 SWAP amp numberl1 amp number2 This example swaps the values in number1 and number2 After the function is executed number1 will hold 66 and number2 will hold 33 un Z j T c zm TE J D T Sj lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 32 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 5 SIN angle Syntax SIN angle Arguments angle angle The angle in degrees Note The input value is automatically shifted to lie within 0 359 degrees The arguments can be a variable array element expression or constant Returns result result The sine in radians of an argument specified in degrees The returned value range is from 127 to 127 which is a more useful representation for graphics work The real sine values vary from 1 0 to 1 0 so appropriate scaling must be done in user code as required Description This function returns the sine of an angle Example var myvar angle angle 133 myvar SIN angle This example returns 92 in variable myvar un Z I T Z em TE J D SI 2 q Z Y TT Z PICASO
11. char Specifies the ASCII character for the test Returns Status 0 Character is not an ASCII lower case letter Status j 1 Character isan ASCII lower case letter Description Tests the character parameter and returns a 1 if the character is an ASCII lower case letter else returns a 0 Valid range abcd wxyz Example Ree Ncc ERR un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 66 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 5 isalpha char Syntax isalpha char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not as ASCII lower or upper case letter Status 1 Character is an ASCII lower or upper case letter Description Tests the character parameter and returns a 1 if the character is an ASCII lower or upper case letter else returns a O Valid range abcd wxyz ABCD WXYZ Example oucu NCC 2 501 un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 67 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 6 isalnum char Syntax isalnum char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not as ASCI
12. 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 GPIO Functions Summary of Functions in this section pin Set mode pin OUTPUT INPUT pin Hl pin pin Hl pin pin LO pin pin Read pin bus In bus Out var bus Set var bus Write var bus Read var un Z T Z TE J D QO I S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 15 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 1 pin_Set mode pin Syntax pin_Set mode pin Arguments mode pin mode A value usually a constant specifying the pin operation pin A value usually a constant specifying the pin number The arguments can be a variable array element expression or constant ul Returns nothing Q Description PICASO GFX2 has limited but powerful I O In There are pre defined constants for mode and pin Z Pin constants Pin number on the PICASO GFX2 chip Remarks T IO1 PIN pin 1 102 PIN pin 64 m IO3 PIN pin 63 IO4 PIN pin 62 also used for BUS RD 105_PIN pin 44 also used for BUS WR BACKLITE Back light control pin Used internally Permanently set as a Output HIGH BACKLITE ON Z LOW BACKLITE OFF 14 AUDIO ENABLE Amplifier Chip control pin Used internally W Permanently set as FE Output c HIGH Amplifier OFF LOW Amplifier ON ul l q mode mode meaning
13. The arguments can be a variable array element expression or constant Returns Count Count Returns the count of bytes actually written Description Writes an ASII string from buffer to a device The ASCII NULL terminator is also written Example c I2C Puts mybuf write an ASCII string from buffer to the I2C bus un Z T Z em TE J D T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 188 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 16 12C_Putn Syntax I2C Putn buffer count Arguments buffer count buffer Storage for the bytes being written to the device count Number of bytes to be written Returns Count Count Returns number of bytes written Description Writes count bytes from the buffer to the device and returns count if function succeeds Example b I2C Putn mybuf count write count bytes from the buffer to the I2C bus un Z I T Z Ti J D S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 189 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 Timer Functions Summary of Functions in this section e sys T e sys T HI e sys SetTimer timernum value e sys GetTimer timernum e sys SetTimerEvent timernum function e sys EventQueue e sys EventsPostpone e sys EventsResume
14. Arguments timernum function timernum One of eight timers TIMERO to TIMER7 function Function to be called Returns Address Returns any previous event function address or zero if there was no previous Address function Description Set a function to be called for selected timer When the timer reaches zero the function is called The called function must not have any parameters and should not have a return value This is necessary because the timer event is invoked asynchronously to the mainline program i e it is not called in the normal way so parameters and return values don t apply Note When a child process is run using the file run or file exec function or if a file was loaded with file Loadfunction and is executed the loaded process gets its own code and memory space therefore any timer that reaches zero that has a timer event attached in the parent code space will fail and cause a crash as an attempt is made to force the program counter to some wild place in the child process There are 2 ways to overcome this problem 1 If a child process will not be requiring the use of any timers or timer events the parent program can simply use the eventsPostpone function before calling or entering the child process Once the parent program regains control the eventsResume function will allow any events in the queue to then be processed The side effect of this method is that several ev
15. BIN14 BIN14Z BIN14ZB BIN15 BIN15Z BIN15ZB BIN16 BIN16Z BIN16ZB Returns field field Returns the the default width of the numeric field digit count usually ignored Description putnum prints a 16bit number in various formats to the current output stream usually the display Example var vi v 05678 putnum HEX v print the number as hex 4 digits putnum BIN v print the number as binary 16 digits 2012 4D SYSTEMS Page 50 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Syntax print Arguments See Description Returns nothing Description 4DGL has a versatile print statement for formatting numbers and strings In it s simplest form print will simply print a number as can be seen below myvar 100 print myvar This will print 100 to the current output device usually the display in TEXT mode Note that if you wish to add a string anywhere within a print statement just place a quoted string expression and you will be able to mix strings and numbers in a variety of formats See the following example print the value of myvar is BIN8 myvar myvar and its 8bit binary representation is Refer the the table in putnum for all the numeric representations available The print statement will accept directives passed in square brackets
16. T c zm TE J D T Sj lt x Z Y TT Z w charwidth W get a characters width h charheight W and height txt FontID 0 back to default font print n W is w pixels wide show width of a character Hf OW im oel vieso print n W is h pixels high show height of a character Jf YY din oisel waits PICASO 2012 4D SYSTEMS Page 55 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 8 charheight char Syntax charheight char Arguments char char The ascii character for the height calculation Returns width width Returns the height of a single character in pixel units Description charheight is used to calculate the height in pixel units for a string based on the currently selected font The font can be proportional or mono spaced Example See example in charwidth un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 56 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 9 strwidth pointer Syntax strwidth pointer Arguments pointer pointer The pointer to a zero 0x00 terminated string Returns width width Returns the width of a string in pixel units Description strwidth returns the width of a zero terminated string in pixe
17. gfx Origin x y gfx Get mode gfx ClipWindow x1 y1 x2 y2 gfx Set function value gfx Set shortcuts gfx PenSize mode e gfx BGcolour colour e gfx ObjectColour colour gfx Clipping mode gfx TransparentColour colour gfx Transparency mode gfx FrameDelay delay gfx ScreenMode delay gfx OutlineColour colour e gfx Contrast value gfx LinePattern pattern gfx ColourMode mode gfx BevelWidth mode gfx BevelShadow value gfx Xorigin offset gfx Yorigin offset uU Z O U z TE a D e A q Z a T Z 2 7 Display I O Functions disp SetReg register data e disp setGRAM x1 y1 x2 y2 e disp WrGRAM colour e disp WriteControl value disp WriteWord value disp ReadWord disp Sync line PICASO 2 8 Media Functions SD SDHC memory Card or Serial Flash chip media Init media SetAdd Hlword LOword media SetSector Hlword LOword media RdSector Destination Address media WrSector Source Address media ReadByte media ReadWord media WriteByte byte val media WriteWord word val 2012 4D SYSTEMS Page 11 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS media Flush media Image x y media Video x y e media VideoFrame x y frameNumber 2 9 Flash Memory chip Functions e flash SIG e flash ID e flash BulkErase e flash BlockErase blockAddress 2 10 SPI Control F
18. PICASO 2012 4D SYSTEMS Page 265 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 17 str_CatN amp ptr str count Syntax str_CatN amp ptr str count Arguments ptr str count ptr Destination string address str Source string address count Number of characters to be concatenated Returns Pointer Pointer Returns pointer to the destination Description The number of characters copied is limited by count The terminating null character in destination is overwritten by the first character of source and a new null character is appended at the end of the new string formed by the concatenation of both in destination Example str CatN amp buf Monday 3 Concatenate Mon with the buf un Z T Z TE J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 266 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 18 str_ByteMove src dest count Syntax str_ByteMove src dest count Arguments src dest count src points to byte aligned source dest points to byte aligned destination count Number of bytes to transfer Returns Pointer Pointer Returns a pointer to the end of the destination which is dest count Description Copy bytes from src to dest stopping only when count is exhausted No terminator is
19. Z Y T Z PICASO 2012 4D SYSTEMS Page 252 of 317 www 4dsystems com au un Z T Z zm TE J D E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 5 str_GetC amp ptr amp var Syntax str_GetC amp ptr amp var Arguments amp ptr amp var ptr Byte pointer to string var Destination for our result The arguments can be a variable array element expression or constant Returns Status Status Returns TRUE if function succeeds advancing ptr Description Get next valid ascii char in a string to myvar NB The address of the pointer must be passed so the function can advance it if required The function returns O if end of string reached Used for extracting single characters from a string Example vear o string pointer var n var char var buffer 100 200 character buffer for a source string func main to buffer print Quick Brown Fox p str Ptr buffer raise a string pointer so we can use the string functions while str GetC amp p amp char print p p char is CHR char print characters wend print End of string endfunc 2012 4D SYSTEMS Page 253 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 6 str_GetByte ptr Syntax str_GetByte ptr Arguments ptr ptr Address of byte array or string Retur
20. amp Ff amp 4 Ss A a Nee ee OD ah SN V V V l l l nb 0 16 digit count BASE usually 2 10 or 16 reserved p ll leading zeros included 0 leading zeros suppressed 1 leading zero blanking sign bit 0 signed 1 unsigned 1 space before unsigned number Pre Defined format constants quick reference un Z T Z m TE J T T J q z Y TT Z DECIMAL UNSIGNED DECIMAL HEX BINARY DEC DECZ DECZB UDEC UDECZ UDECZB HEX HEXZ HEXZB BIN BINZ BINZB DEC1 DEC1Z DEC1ZB UDEC1 UDEC1Z UDECIZB HEX1 HEX1Z HEX1ZB BIN1 BIN1Z BIN1ZB DEC2 DEC22Z DEC2ZB UDEC2 UDEC2Z UDEC2Z2B HEX2 HEX2Z HEX1ZB BIN2 BIN2Z BIN2ZB DEC3 DEC3Z DEC3ZB UDEC3 UDEC3Z UDEC3ZB HEX3 HEX3Z HEX1ZB BIN3 BIN3Z BIN3ZB PICASO DEC4 DEC4Z DECAZB UDEC4 UDEC4Z UDECAZB HEX4 HEX4Z HEX1ZB BINA BINAZ BINAZB DEC5 DEC5Z DEC5ZB UDEC5 UDEC5Z UDEC5ZB BINS BIN5Z BIN5ZB BIN6 BIN6Z BIN6ZB BIN7 BIN7Z BIN7ZB BIN8 BIN8Z BIN8ZB BIN9 BIN9Z BIN9ZB BIN10 BIN10Z BIN10ZB BIN11 BIN11Z BIN11ZB 2012 4D SYSTEMS Page 49 of 317 www 4dsystems com au Wn z T Z m TE J T m I J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS BIN12 BIN12Z BIN12ZB BIN13 BIN13Z BIN13ZB
21. e sys Sleep units e iterator offset un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 190 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 1 sys_T Syntax sys T Arguments None Returns value value Returns the value of system timer LO Word Description Returns the current value of the rolling 32bit system timer 1mse LO word Example 8 aye Tia 7 2 un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 191 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 2 sys T HI Syntax sys T HI Arguments None Returns value value Returns the value of system timer HI Word Description Returns the current value of the rolling 32bit system timer 1mse HI word Example t 8e ewe Was f7 un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 192 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 3 sys_SetTimer timernum value Syntax sys_SetTimer timernum value Arguments timernum value timernum One of eight timers TIMERO to TIMER7 value Countdown period in milliseconds The value can be a variable array element expression or constant
22. 1 0 First Release 20 06 2010 2 0 1 Incorrect heading and discrepancy in the description of bus_Write Function fixed 2 Fixed typing error in the bus_Read Function 3 Erroneous references in sec 2 4 12 to note 5 note 6 note 7 and note 8 removed Proper descriptions added 4 Replaced FONT_SIZE with FONT_ID at several places 5 X_RES is replaced with X_MAX Y_RES is replaced with Y_MAX in sec 2 6 39 6 str_Append is replaced with str_Cat in the example in sec 2 16 16 7 str_Append is replaced with str_CatN in the example in sec 2 16 17 25 10 2010 1 Fixed typing error in Sec 2 19 1 Sec 2 19 2 and Sec 2 19 3 2 Added Details for Transparency functions Sec 2 6 41 3 Added Details for uVGA II GFX related functions in Sec 2 6 41 4 Sec 2 7 7 added disp Sync line command added for uVGA II GFX module 5 Updated SPI modes and SPI speeds Note SPI diagram in Sec 2 10 1 6 Fixed typing error in Sec 2 13 1 and 1 13 2 It s a 32 bit Timer 7 Fixed typing error in the Description in Sec 2 12 1 17 11 2011 1 Removed predefined numbers from table 2 6 41 gfxt Set should only be used with predefined names 2 Transparency Contrast and Multiple Page Display Read Write details updated in Sec 2 6 41 3 Fixed typo in 2 4 10 strheight pointer 4 Added Sec 2 3 11 CY 5 Added Sec 2 3 12 umul_1616 amp res32 val1 val2 6 Added Sec 2 3 13 uadd_3232 amp res32 amp val1 amp val2 7 Added
23. 2 15 2 Snd_Pitch pitch Syntax Snd_Pitch pitch Arguments __ pitch pitch Sample s playback rate Minimum is 4KHz Range is 4000 65535 The arguments can be a variable array element expression or constant Returns value value Returns sample s original sample rate Description Sets the samples playback rate to a different frequency Setting pitch to zero restores the original sample rate Example snd Pitch 7000 Play the wav file with a sample frequency of 7KHz un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 242 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 3 Snd_BufSize var Syntax Snd_BufSize var Arguments var var Specifies the buffer size 0 1024 bytes default 1 2048 bytes 2 4096 bytes The arguments can be a variable array element expression or constant Returns None Description Specify the a memory chunk size for the wavefile buffer default size 1024 bytes Depending on the sample size memory constraints and the sample quality it may be beneficial to change the buffer size from the default size of 1024 bytes This function is for control of a wav buffer see the file PlayWAV function Example snd BufSize 1 allocate a 2k wav buffer un Z I T Z TE J D I 2 q
24. NOTE These registers are accessible with peekW and pokeW functions 2012 4D SYSTEMS Page 304 of 317 www 4dsystems com au un Z T Z m TE J T E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 4 Appendix A Example 4DGL Code platform uOLED 32028 P1 GFX2 ORK KK KKK Ek kk kk kk Kk CK kk kk kk kk CK kk kk kk kk Ok ko ke ke ek kkk Filename Window 4dg Created 2010 06 17 Author 4D Description A simple window object example NB This program should be written to flash so it becomes the top down program OKCKCKCkCk ck kckck kk kk ckck ck ck kck kk ck ck ck ck ckckck k kck ck ck ck ck ck ck ckok ckok Kk ke ke X ke ke x x f inherit A4DGL 16bitColours fnc inherit FONT4 fnt MODE RUNFLASH this prog intended to be front end and run from FLASH STACK 500 make sure stack is big enough for main prog and called functions colour scheme CONST WINDOW COLOR GRAY TITLEBAR COLOR NAVY TITLETXT COLOR CYAN STATUSBAR COLOR GRAY STATUSTXT COLOR YELLOW END ERRETES EA I PE RCM Ew Wl CR SR Rip local global variables PeSe sees ss SSS SSS SS SSS Se Sasa 2 SSS SSS SSS SS Se SS Ss SS SS Ss SS SSeS SSeS SSeS NR jV MD pointer to disk struct we keep 2 copies so we can test for a state var tempstr 20 general purpose string 40 bytes J ssss ss sss sss sss Ss ss SS SS SS SSS SS SS SS SS SS S
25. PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 2 media SetAdd Hlword LOword Syntax media SetAdd Hlword LOword Arguments Hlword LOword specifies the high word upper 2 bytes of a 4 byte media memory byte Hlword address location LOword specifies the low word lower 2 bytes of a 4 byte media memory byte address location The arguments can be a variable array element expression or constant Returns nothing Description Set media memory internal Address pointer for access at a non sector aligned byte address Example media SetAdd 0 513 This example sets the media address to byte 513 which is sector 1 gi byte in sector for subsequent operations 2012 4D SYSTEMS Page 133 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 3 media SetSector Hlword LOword Syntax media SetSector Hlword LOword Arguments Hlword LOword specifies the high word upper 2 bytes of a 4 byte media memory sector Hlword address location LOword specifies the low word lower 2 bytes of a 4 byte media memory sector address location The arguments can be a variable array element expression or constant Returns result Description Set media memory internal Address pointer for sector access Example media SetSector 0 10 This example sets the media address to the 11 sector which is also byt
26. Returns nothing Description Copies an area of a screen from xs ys of size given by width and height parameters and pastes it to another location determined by xd yd un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 111 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 33 gfx_RGBto565 RED GREEN BLUE Syntax gfx_RGBto565 RED GREEN BLUE Arguments RED GREEN BLUE RED 8bit colour value for RED GREEN 8bit colour value for GREEN BLUE 8bit colour value for BLUE The arguments can be a variable array element expression or constant Returns Returns the 16bit RED 5 GREEN 6 BLUE 5 format colour value Description Returns the 16bit RED 5 GREEN 6 BLUE 5 format colour value of a 24bit RED 8 GREEN 8 BLUE 8 format colour un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 112 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 34 gfx_332to565 COLOUR Syntax gfx_332to565 COLOUR Arguments Colour Colour 8bit colour value 3bits for RED 3bits for GREEN 2bits for BLUE Returns Returns the 16bit RED 5 GREEN 6 BLUE 5 format value Description Returns the 16bit RED 5 GREEN 6 BLUE 5 format value of an 8bit RED 3 GREEN 3 BLUE 2 f
27. constant MAXBUTTONS 30 for now maximum number of buttons we want also sets maximum number of files we can exec STACK 500 stack must be large enough to be shared with called program MODE RUNFLASH This is a top down main program and must be run from FLASH NB demo assigns all arrays to MAXBUTTONS The arrays could be dynamically assigned to minimise memory usage There is break even point between extra code and smallish arrays var keyval 0 if no key pressed else 1 n var filenames pointer to byte array that holds the filenames WN Z U Z zj TE x O D T J lt Z a T Z var buttontexts MAXBUTTONS pointers into the filenames array holds the filenames we use as button text var vButtonState MAXBUTTONS button state flag bit 0 up down state var vOldButtonState MAXBUTTONS OLD button state flags bit 0 up down state PICASO we keep 2 copies so we can test for a state change and only redraw when a state change occurs var touchX1 MAXBUTTONS touch regions for the buttons var touchY1 MAXBUTTONS var touchX2 MAXBUTTONS var touchY2 MAXBUTTONS var btnTextColor button text colour var btnBtnColor button background colour var buttoncount actual number of buttons created set by number of 4XE files we find on drive 2012 4D SYSTEMS Page 228 of 317 www 4dsystems com au un Z T Z m Ti
28. 2 eed eet ct ee n ERE ERI Pe RR UE NU E aee rei d on Lene oer Do ERE rene d 65 2 5 4 Islower ch t ener aa a ae ease kun Ree RAN E NER aa saena eaaa a RENE REREE Eod eS 66 EESADNC IhIEISeEE 67 25 6 SAMUI CHAN rus ciere tae r err Pede rhe cae TEE E Dre Rap Cedo cd eue EE oe E aaia E KE a ET aaa 68 Vane ATIS elo dfe aie TA REESE CTETUR EEUU 69 VAST dor er o DES ENERO TDI TETTE E A EE 70 2 5 9 toUupper chal senasis eae Dao LE PER rae TRE o OE a PER NE FECE peor PERS e ER TRE LR Eu pneu 71 2 5 10 tolower char tritt rt a ERR dee REM a CERA EN RE REPE ERAN RS ERROR ERR Meo BTE FER EREE da 72 2 5 11 LObyte V r i icio eie tee Ri eas aa NER KERN ERES XE aa NS CERA ERa ERE aa ERa KR MER eR ERR E RA 73 2 5 12 Hl bytelvar etc Er asd ev RE a NASCE E ER ERR ERREUR FERE 74 25 13 DSCULIUULIS M E 75 Graphics FUFCEIOFNIS 2 eee ce sto eta che PART cente hk UE vua EE RN Ru San FAN eue e ERRARE ARUXRT I REDE N Po sired sasstenievandedeeiasbecbes 76 PAP a CIS op 78 2 6 2 gfx ChangeColour oldColour newColour essent nnns 79 2 6 3 gfx Circle x y r dius colo r sesiis ainai ieaiai a zo RE aaaea aaia 80 2 6 4 gfx CircleFilled x y radius colour esses esee nennen enne enne enne 81 216 5 etx Line x1 y1 x2 y2 colour sei rise ternera ER Hao ueri Go ee F r vedo ane Ye PER aov e 82 2 6 6 gfx Hline y x1 x2 colo
29. 2012 4D SYSTEMS Page 272 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 17 3 touch_Get mode Syntax touch_Get mode Arguments mode mode mode 0 Get Status mode 1 Get X coordinates mode 2 Get Y coordinates Returns Value Value mode 0 Returns the various states of the touch screen 0 INVALID NOTOUCH 1 PRESS 2 RELEASE 3 MOVING mode 1 Returns the X coordinates of the touch mode 2 Returns the Y coordinates of the touch Description Returns various Touch Screen parameters to caller Example State touch Get TOUCH STATUS get touchscreen status x touch Get TOUCH GETX y Be touch Got TOUCH Cm p if state TOUCH_PRESSED Ut See AE mee E if x gt 170 amp amp y gt 280 EXIT button guess Cle p exit 1 endif un Z T Z em TE J D S lt x Z Y TT Z if vertical if x gt 170 amp amp y gt 240 amp amp y lt 270 Horiz button vertical 0 exit 1 endif else i z gt 170 ee y gt 200 amp amp y lt 290 Vere bwcton vertical 1 exit 2 endif endif PICASO endif 2012 4D SYSTEMS Page 273 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 Image Control Functions Summary of Functions in this section e img SetPosition handle index xpos ypos e img Enable handle index e img
30. ON or OFF 13 TEXT ATTRIBUTES Control of functions 9 10 11 12 grouped 16 or BOLD bits can be combined by using logical or of bits 32 or ITALIC nb bits 0 3 and 8 15 are reserved 64 or INVERSE 128 or UNDERLINED 14 TEXT WRAP Sets the pixel position where text wrap will occur at RHS 0 to n OFF or Value The feature automatically resets when screen mode is changed The value is in pixel units Default value is O Single parameter short cuts for the txt Set functions 2012 4D SYSTEMS Page 60 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Function Syntax Function Action value txt_FGcolour Set the text foreground colour Colour 0 65535 txt BGcolour Set the text background colour Colour 0 65535 txt FontlD id Set the required font 0to2 0 or FONT1 system font or 2 Or FONT3 Default fonts FONT1 Note The value could be the name of a custom font included in a FONT2 users program in a data statement See examples in the 4DGL FONT3 Workshop3 IDE ul txt Width multiplier Set the text width multiplier note 6 1 to 16 Default 1 za txt Height multiplier Set the text height multiplier note 6 1 to 16 Default 1 Q txt Xgap pixelcount Set the pixel gap between characters The gap is in pixel units 0 to 32 Default 0 txt_Ygap pixelcount Set the pixel gap between lines The gap is in pixel units 0 to 32 Default 0 LJ txt_D
31. Y TT Z PICASO 2012 4D SYSTEMS Page 255 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 8 str_PutByte ptr val Syntax str_PutByte ptr val Arguments ptr val ptr byte pointer to string val byte value to insert Returns None Description Put a byte value into a string buffer at ptr Similar to POKEB in basic It is not necessary for byte pointer ptr to be word aligned Example var buffer 100 200 character buffer for a source string var p string pointer func main p str Ptr buffer raise a string pointer so we can use the Jf sering Fumctiems str PutByte p 3 A store some values str PutByte p 4 B store some values str PutByte p 5 C store some values str PutByte p 7 D store some values str PutByte p 7 0 string terminator Horime wecslOl Na weesllj va sese Na prime coen owe D s p Be offset to where we placed the chars fprint amp p Ss n print the result nb also understand that the core print service assumes a word aligned address so it starts at pos 4 print STR amp buffer 2 un Z j T c zm TE J D T 2 q Z Y TT Z endfunc PICASO 2012 4D SYSTEMS Page 256 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 9 str_PutWord ptr val Syntax str_
32. Z Y TT Z PICASO 2012 4D SYSTEMS Page 243 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 4 snd_Stop Syntax snd_Stop Arguments None Returns None Description Stop any sound that is currently playing releasing buffers and closing any open wav file This function is for control of a wav buffer see the file_PlayWAV function Example snd_Stop un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 244 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 5 snd_Pause Syntax snd_Pause Arguments None Returns None Description Pause any sound that is currently playing This function is for control of a wav buffer see the file Play WAV function Example snd Pause un Z T Z zm TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 245 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 6 snd_Continue Syntax snd_Continue Arguments None Returns None Description Resume any sound that is currently paused by snd_Pause This function is for control of a wav buffer see the file_PlayWAV function Example snd_Continue un Z T Z Ti J D 2 q Z
33. for further information Description If a FLASH storage device is connected to the SPI port and has been correctly initialised with the spi Init function the memory type and capacity from the flash device can be read using this function The only devices supported so far on the PICASO GFX2 are the M25Pxx range of devices which are 512Kbit to 32Mbit 2M x 8 Serial Flash Memory un Z T Z TE J D QO S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 148 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 9 3 flash_BulkErase Syntax flash_BulkErase Arguments none Returns nothing Erases the entire flash media device The function returns no value and the operation can take up to 80 seconds depending on the size of the flash device Description If a FLASH storage device is connected to the SPI port and has been correctly initialised with the spi Init function the FLASH device can be completely erased using this function The only devices supported so far on the PICASO GFX2 are the M25Pxx range of devices which are 512Kbit to 32Mbit 2M x 8 Serial Flash Memory un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 149 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 9 4 flash_BlockErase blockAddress Syntax flash_BlockErase blo
34. n T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 200 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 FAT16 File Functions Summary of Functions in this section e file Error e file Count filename e file Dir filename e file FindFirst fname e file FindNext e file Exists fname e file Open fname mode e file Close handle e file Read destination size handle e file Seek handle HiWord LoWord e file Index handle Hisize Losize recordnum e file Tell handle amp HiWord amp LoWord e file Write Source size handle e file Size handle amp HiWord amp LoWord e file Image x y handle e file ScreenCapture x y width height handle e file PutC char handle e file GetC handle e file PutW word handle e file GetW handle e file PutS source handle e file GetS String size handle e file Erase fname e file Rewind handle e file LoadFunction fname A4XE e file Run fname AXE arglistptr e file Exec fname AXE arglistptr e file LoadlmageControl fname1 fname2 mode e file Mount e file Unmount e file Play WAV un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 201 of 317 www 4dsystems com au un Z T Z m TE J T T J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 1 file_Error Syntax file_E
35. print if file Exists str Ptr tempstr touch Set TOUCH DISABLE disable the touch screen txt Set TEXT COLOUR ORANGE print NrRUN STR tempstr run the required program pause 500 Gpexe Cabe p file Run str Ptr tempstr 0 just run the prog no args else txt Set TEXT COLOUR RED prime Ne BANDIT SPR Gempsit Je run required program pause 1000 endif endfunc convert the touch co ordinates to a key value returns 0 if no key down else return index 1 n of button wa m xl wl 2 W2 E ig SE P r 0 while n lt buttoncount amp amp r xl touchX1l n yl touchYl n x2 touchX2 n 2012 4D SYSTEMS Page 230 of 317 www 4dsystems com au un Z fees T Z m TE J T J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS y2 touchY2 n ntt if x gt xl amp amp x lt x2 amp amp y gt yl amp amp y lt y2 r n wend return r endfunc func main Wee Ie il SIEGES Sp WH var p S w f redo w 140 f re FONT btnTextColor BLACK btnBtnColor LIGHTGREY Gpexe Ciber p gfx Set BEVEL WIDTH 2 txt Set FONT ID FONT3 princ YSimole cest for filea R nlass EB print Memory available mem Heap n if file_Mount putstr Disk not mounted while file Mount else putstr Disk mounted n endif lSuueiEGimelxbuE G silks Commi
36. q Z Y TT Z PICASO 2012 4D SYSTEMS Page 209 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 9 file_Read destination size handle Syntax file_Read destination size handle Arguments destination size handle destination Destination memory buffer size Number of bytes to be read handle The handle that references the file to be read Returns count count Returns the number of characters read Description Reads the number of bytes specified by size from the file referenced by handle into a destination memory buffer Example res file Read memblock 20 hndl1 un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 210 of 317 www 4dsystems com au un Z T Z m TE J D m T E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 10 file_Seek handle HiWord LoWord Syntax file_Seek handle HiWord LoWord Arguments handle HiWord LoWord handle The handle that references the file HiWord Contains the upper 16bits of the memory pointer into the file LoWord Contains the lower 16bits of the memory pointer into the file Returns Status Status Returns TRUE if ok usually ignored Description Places the file pointer at the required position in a file that has bee
37. y X y specifies the horizontal and vertical position of the top left corner of the clipping window Returns nothing Description Sets relative screen offset for horizontal and vertical for the top left corner for graphics objects Example gfx Offset argl arg2 un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 117 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 39 gfx_Get mode Syntax gfx_Get mode Arguments mode mode mode 0 Current orientations Max X Value X_MAX mode 1 Current orientations Max Y Value Y_MAX mode 2 Left location of Object mode 3 Top location of Object mode 4 Right location of Object mode 5 Bottom location of Object mode 6 Get current internal X position mode 7 Get current internal Y position ModeO Returns the maximum horizontal value of the display Mode1 Returns the maximum vertical value of the display Mode2 Returns the left location of the last drawn object such as a slider or button or an image video Mode3 Returns the top location of the last drawn object such as a slider or button or an image video Mode4 Returns the right location of the last drawn object such as a slider or button or an image video Mode5 Returns the bottom location of the last drawn object such as a slider or button or an image video
38. 0 65535 gfx Clipping mode Turns clipping on off The clipping points are set with gfx_ClipWindow O or 1 ON or OFF gfx TransparentColour colour Colour that needs to be made transparent Colour 0 65535 gfx Transparency mode Turn the transparency ON or OFF 1 or 0 ON or OFF gfx FrameDelay delay Set the inter frame delay for media Videox O to 255msec gfx ScreenMode mode Graphics orientation PORTRAIT PORTRAIT R LANDSCAPE LANDSCAPE R Note Does not apply to uVGA II GFX module 1 or LANDSCAPE 20r LANDSCAPE R 3 or PORTRAIT 4 or PORTRAIT R gfx OutlineColour colour Outline colour for rectangles and circles set to O for no effect Colour 0 65535 gfx Contrast value OLED MODULES Set contrast value 0 display off 1 9 contrast level LCD MODULES contrast O display OFF non zero display ON EXCEPTION uLCD 43 GFX supports Contrast values from 1 9 and 0 to turn the Display off Note Does not apply to uVGA II GFX module Oor OFF 1 to 9 for levels 10r 0 ON or OFF gfx LinePattern pattern Sets the line draw pattern for line drawing If set to zero lines are solid else each 1 bit represents a pixel that is turned off See code examples for further reference O bits for pixels on 1 bits for pixels off gfx ColourMode mode Sets 8 or 16bit colour mode 0 or COLOUR16 Function not available fixed as 16bit mode 1 or
39. 101 102 1O3 104 IO5 constants value CL OUTPUT 0 Pin is set to an output YES YES YES YES YES INPUT 1 Pin is set to an input YES YES YES YES YES Example pin Set OUTPUT IO2 PIN set IO2 to be used as an output pin Set INPUT IOl PIN set IOl to be used as an input 2012 4D SYSTEMS Page 16 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Syntax pin Hl pin Arguments pin pin A value usually a constant specifying the pin number The arguments can be a variable array element expression or constant Returns nothing Description Outputs a High level logic 1 on the appropriate pin that was previously selected as an Output If the pin is not already set to an output it is automatically made an output Example pim SERE OZ PIN output a Logic 1 on IO2 pin un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 17 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 3 pin_LO pin Syntax pin_LO pin Arguments pin pin A value usually a constant specifying the pin number The arguments can be a variable array element expression or constant Returns nothing Description Outputs a Low level logic 0 on the appropriate pin that was previously selected as an Output If the pin is not already set
40. 171 of 317 www 4dsystems com au un Z T Z m Ti J T I J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS txt Set TEXT OPACITY OPAQUE repeat gfx Cls txt _MoveCursor 3 1 reset cursor to line 3 column 2 print Send 440 chars non buffered n pokeW SYSTEM TIMER LO 0 reset timer note that 440 chars at 9600 baud takes approx 453msec sonr Gns im lt ILO Pe gar to COMO putstr The quick brown fox jumps over the lazy dog n 44 chars next print took peekW SYSTEM TIMER _LO Msec n n time spent blocking is only approx lmsec com TXbuffer combuf 440 101 PIN set up the TX buffer com TXbufferHold ON hold the TX buffer til ready note that here the time is only approx i1msec overhead due to buffering print Send 440 chars buffered Win pokeW SYSTEM TIMER LO 0 reset timer for n 0 n 10 n to COM0 putstr THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG n 44 chars next print took peekW SYSTEM TIMER LO Msec n n time spent blocking is only approx 1msec demonstrate how to modify a prepared comms buffer that is still being held to combuf print MY CONTENTS HAVE BEEN CHANGED to combuf 50 print AND CHANGED HERE TOO combuf 218 DAE the last DOG changed here combuf 219 U D nts the last DOG changed here now we are ready to send to buffer n com TXbufferHol
41. 3 14 usub_3232 amp res32 amp vali amp val2 Syntax uadd 3232 amp res32 amp val1 amp val2 Arguments amp res32 amp val1 amp val2 amp res32 Points to 32bit result register amp val1 points to 32bit augend amp val2 points to 32bit addend Returns Value Value Returns 1 on 32bit unsigned overflow carry Carry flag is also set on 32bit unsigned overflow and can be read with the CY function Description Performs an unsigned subtraction of 2 x 32bit values placing the 32bit result in a 2 word array Example Wee greucuwe SEA 2 seedis2 Resmillte 2 9 var p valA 0 0 valA 1 OxFFFF valB 0 0 valB 1 OxEFFF carry usub 3232 Result valA valB p str Ptr Result print 0x Sige ranee iyo aeDA repeat forever This example will print Ox10000000 un Z fees T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 42 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 15 ucmp_3232 amp vali amp val2 Syntax ucmp 3232 amp val1 amp val2 Arguments amp val1 amp val2 amp val1 points to 32bit augend amp val2 points to 32bit addend Returns Value Value 0 if equal 1 if val1 gt val2 1 if val1 lt val2 This function does not affect the carry flag Description Performs an unsigned comparison of 2 x 32bit value
42. 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 9 12C_Nack Syntax I2C Nack Arguments None Returns None Description Calling this function sends an I2C negative acknowledge condition The hardware first release the SDA line high and next releases SCL HI followed by pulling SCL low thus generating a clock pulse NB Data can only change when the clock is low SCL N SDA X Nack Example I2C Nack Send an I2C Negative acknowledge condition un Z I T c Ti J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 182 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 10 12C_AckStatus Syntax I2C AckStatus Arguments None Returns Status Status Device Ack status Description Call this function to get the ACK status from the slave device The state of SDA is returned NB returns the state of SDA after the last clock pulse Previous Clock Pulse SCLX o SDA X Ack Status Example r I2C AckStatus returns the Ack Status un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 183 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 11 I2C AckPoll control Syntax I2C AckPoll control Arguments control control The control w
43. 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 20 1 pause time Syntax pause time Arguments time time A value specifying the delay time in milliseconds The arguments can be a variable array element expression or constant Returns nothing Description Stop execution of the user program for a predetermined amount of time Example if status if fire button pressed pause 30 slow down the loop else un Z I T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 299 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 20 2 lookup8 key byteConstList Syntax lookup8 key byteConstList Arguments key byteConstList key A byte value to search for in a fixed list of constants The key argument can be a variable array element expression or constant byteConstList A comma separated list of constants and strings to be matched against key Note the string of constants may be freely formed see example Returns result result See description Description Search a list of 8 bit constant values for a match with a search value key If found the index of the matching constant is returned in result else result is set to zero Thus if the value is found first in the list result is set to one If second in the list result is set to two etc If not found result is
44. ARE PRU 206 2 14 6 file Exists friam ierant one leen ore Ruin de eh niv te ek eedicostacsoviducstelaph iari aea iaai 207 2 14 7 file Open fname mode eene enne nnne enne nennen nennen senes nnn enn 208 2 14 8 file Close handle o rrr eno ro teneor eade Pla nsa pae iaa aeaa RENE E RR EN Beda 209 2 14 9 file Read destination size handle eese enne 210 2 14 10 file Seek handle HiWord LOWOL c ccccsccsessecsseceseeecseecseceecsaeceeeeecseeeseeeeceaeeseeeesseeeeeeeeee 211 2 14 11 file Index handle Hisize LoSize recordnum seeeeseeeeeeneerenenen ene 212 2 14 12 file Tell handle amp HiWord amp LoWord eeseesseeseeeeneee enne 213 2 14 13 file Write source size handle enne enne nnn 214 2 14 14 file Size handle amp HiWord amp LoWord essere enne nnne enne 215 2 14 15 file Image x y handle oie tc rane orte ck ere to dt e eo aae ER coe Rara oae EUER e Area RET Eva 216 2 14 16 file ScreenCapture x y width height handle enne 217 2 14 17 file PutC char handle sees enne nennen nennen enne enn nennen innen enne 218 2 14 18 file GetC handle d retreat het eo epa ca oak s eo eaa da s cae ae oce a epa c Ehe e aan 219 2 14 19 file PutW word handle sese i 220 u Z u Z TE J O m T J lt x z a T lt PICASO 2 14 20 file GetW liandle i5 riot rir tre tonos caanat
45. COLOUR8 gfx_BevelWidth mode graphics button bevel width 0 None 1 to 15 pixels gfx BevelShadow value graphics button bevel shadow depth 2012 4D SYSTEMS Page 121 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS gfx_Xorigin offset graphics X origin gfx_Yorigin offset graphics Y origin un Z I T c TE J T n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 122 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 Display I O Functions These functions allow direct display access for fast blitting operations Summary of Functions in this section e disp SetReg register data e disp setGRAM x1 y1 x2 y2 e disp WrGRAM colour e disp WriteControl value e disp WriteWord value e disp ReadWord e disp Sync line un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 123 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 1 disp_SetReg register data Syntax disp_SetReg register data Arguments register data register Refer to the display driver data sheet data Refer to the display driver data sheet Returns nothing Description Sets the Display driver IC register un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS
46. J lt Z Y T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 0x11 END ae con func endf func endf func endf word myData myStringl Bert Fred main myString2 baud barney 11 0x2222 0x3333 0x4444 byte myStringl Data String OK n n 0 byte myString2 and forward referenced n n 0 word baud 150 300 600 1200 2400 9600 his constant is a forward reference Stant barney 9876 Fred var str jxesta C euEssumg y eum sux unc Bert var pl var p2 var p3 prine Mine iio were aol jal Wee lo Wasi cer UNI E return Bert was here n unc main var fn a variable for a handle for the function txt_Set FONT ID FONTI fn myData 1 Get function pointer from data statement index prime SIR ea lOO 200 300 5 use it in a statement to prove engine ok fn myData 2 Get function pointer from data statement index icin ABCA nT p execute the Function just shows where main lives print naddress of main code myData 3 n n remember a var can be a handle variable pointer or vector print STR myData 0 pointer table data reference print STR myData 4 repeat forever unc 2012 4D SYSTEMS Page 52 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 6 to outstream Syntax to outstream Arguments outstream outstream A variable or constant specifying
47. J T I J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS var tempstr 20 general purpose string 40 bytes DATA owe dex 1 2 3 4 597 On fob 9 LO ti le END a Redraw the button matrix Only draw buttons that have changed state The top lef corner of the button matrix is set with the xorg and yorg parameters depending on the font and text string width the button matrix dynamically resizes Parameters maxwidth rhs from xorg in pixels to cause wrap at rhs maxwidth maximum matrix width in pixel units buttoncount number of buttons to display font FONT1 to FONT4 xorg yorg top left corner of button array NB The touch detect matrix array is updated when any button changes Sigaren When you need to draw the matrix for the first instance of the matrix you must call with mode 1 to instantiate the buttons call with mode 0 for normal button action func redraw var bcount var font var xorg var yorg var maxwidth var mode var xgap ygap n xl yl x2 y2 xgap 2 ygap 2 xl xorg yl yorg if first set all the buttons to the up state if mode n 0 repeat vButtonState n UP set all the buttons to inverse state vOldButtonState n DOWN so we guarantee they are all drawn in the up state not pressed until t n gt buttoncount endif check all the button states if a change occured draw the new
48. Mode6 Returns the internal X position that was set with MoveTo x y or gfx Set X ORG pos Mode7 Returns the internal Y position that was set with MoveTo x y or gfx Set X ORG pos Returns un Z T Z m Ti J T m I J q z Y TT Z Description Returns various graphics parameters to caller PICASO Example var gfx Get X MAX Returns the maximum horizontal resolution of the display var gfx_Get 0 var gfx Get Y MAX Returns the maximum vertical resolution of the display var gfx_Get 1 var gfx Get RIGHT POS Returns the right location of the last drawn object that only has top left parameters such as a button or an image video var gfx_Get 2 var gfx_Get BOTTOM_POS Returns the bottom location of the last drawn object that only has top left parameters such as a button or an image video var gfx_Get 3 2012 4D SYSTEMS Page 118 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 40 gfx ClipWindow x1 y1 x2 y2 Syntax gfx ClipWindow x1 y1 x2 y2 Arguments X1 y1 x2 y2 x1 y1 specifies the horizontal and vertical position of the top left corner of the clipping window x2 y2 specifies the horizontal and vertical position of the bottom right corner of the clipping window The arguments can be a variable array element expression or constant Returns nothi
49. Returns nothing Description serout Transmits a single byte from the Serial Port COM1 serout1 Transmits a single byte from the Serial Port COM1 The transmission format is No Parity 1 Stop Bit 8 Data Bits N 8 1 The default Baud Rate for COMO is 115 200 bits per second or 115 200 baud The default Baud Rate for COM1 is 9600 bits per second or 9600 baud The baud rate can be changed under program control by using the setbaud function Example serout n Send a linefeed to COMO un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 160 of 317 www 4dsystems com au uU Z O E Z TE a D e Ej q Z a T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 5 com_Init buffer bufsize qualifier Syntax com_Init buffer bufsize qualifier or com1_Init buffer bufsize qualifier Arguments buffer b ufsize qualifier buffer specifies the address of a buffer used for the background buffering service bufsize specifies the byte size of the user array provided for the buffer each array element holds 2 bytes If the buffer size is zero a buffer of 128 words 256 bytes should be provided for automatic packet length mode see below qualifier specifies the qualifying character that must be received to initiate serial data reception and buffer write A zero 0x0
50. SYSTEMS Page 248 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 1 str_Ptr amp var Syntax str_Ptr amp var Arguments var var Pointer to string buffer Returns Pointer Pointer Returned value is the byte pointer to string buffer Description Return a byte pointer to a word region Example var buffer 100 200 character buffer for a source string var p string pointer Wee imp var vars 3 for our results func main to buffer print 0x1234 0b10011001 12345 abacus p str Ptr buffer raise string pointer for the string functions while str GetW amp p amp vars nt 0 read all the numbers till we get a non number print vars 0 An vars 1 Mn vars 2 n print them out endfunc un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 249 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 2 str_GetD amp ptr amp var Syntax str_GetD amp ptr amp var Arguments amp ptr amp var ptr Byte pointer to string var Destination for our result Returns Status Status Description Convert number in a string to DWORD myvar 2 NB The address of the pointer must be passed so the function can advance it if required Example var buffer 100 200 character buffer for a sour
51. Sec 2 3 14 usub_3232 amp res32 amp val1 amp val2 8 Added Sec 2 3 15 ucmp 3232 amp val1 amp val2 9 Added Sec 2 16 18 str ByteMove src dest count 10 Added Sec 2 16 19 str Copy dest src 11 Added Sec 2 16 20 str CopyN dest src count 17 02 2012 1 Fixed typing error in the SWAP command Sec 2 3 4 2 Fixed typing errors in Sec 2 4 10 3 Updated COM1 Default Baud rate details 4 Fixed typing error in Example sys EventsPostpone in Sec 2 13 7 5 Added details to gfx Cls command Sec 2 6 1 6 com TXbuffer and com1 TXbuffer functions have been modified and take an extra parameter It applies to PmmC R29 or above Sec 2 11 11 7 Description updated Image control will now show error box for out of range video frames If frame is set to 1 just a rectangle will be drawn in background colour to blank an image It applies to PmmC R29 or above Sec 2 18 6 8 Description updated Image control will now show error box for out of range video frames Also if frame is set to 1 just a rectangle will be drawn in background colour to blank an image It applies to PmmC R29 or above Sec 2 8 13 08 06 2012 Reformatted minor document updates 12 09 2012 2012 4D SYSTEMS Page 315 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Revision History Continued Revision Revision Content Revision Date 6 1 Fixed minor TOC numbering issue 23 11 2012 1 It is now possible for a p
52. Status 1 If at least one file exists that satisfies the criteria Status 0 If no file satisfies the criteria Description Returns true if at least 1 file exists that satisfies the file argument Wildcards are usually used so if file FindFirst returns true further tests can be made using file FindNext to find all the files that match the wildcard class Note that the stream behaviour is the same as file Dir Example TE Eile f anvelm iicet Mts EB Print File Found endif un Z I T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 205 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 5 file_FindNext Syntax file_FindNext Arguments None Returns Status 1 If more files exist that satisfy the criteria set in the file_FindFirstt fname Status 0 If no more files satisfy the criteria set in the file FindFrist fname Description Returns true if more file exists that satisfies the file argument that was given for file FindFirst Wildcards must be used for file FindFirst else this function willalways return zero as the only occurence will have already been found Note that the stream behaviour is the same as file Dir Example while file FindNext 0 filecount tt wend un Z j T c zm TE J D T Sj lt x Z Y TT Z PICASO 2
53. This function returns the the smaller of value1 and value2 Example var myvar numberl number2 numberl 33 number2 66 myvar MIN numberl number2 This example returns 33 in variable myvar un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 30 of 317 www 4dsystems com au un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 3 MAX value1 value2 Syntax MAX value1 value2 Arguments value1 value2 value1 a variable array element expression or constant value2 a variable array element expression or constant The arguments can be a variable array element expression or constant Returns value value the larger of the two values Description This function returns the the larger of value1 and value2 var myvar numberl number2 Example numberl number2 337 66 myvar MAX numberl number2 This example returns 66 in variable myvar 2012 4D SYSTEMS Page 31 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 4 SWAP amp var1 amp var2 Syntax SWAP amp value1 amp value2 Arguments amp var1 amp var2 amp var1 The address of the first variable amp var2 The address of the second variable
54. Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 36 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 9 SQRT number Syntax SQRT number Arguments number number Specifies the positive number for the SQRT function The arguments can be a variable array element expression or constant Returns value value This function returns the integer square root which is the greatest integer less than or equal to the square root of number Description This function returns the integer square root of a number Example var myvar myvar SQRT 26000 This example returns 161 in variable myvar which is the integer square root of 26000 un Z j T Z zm TE J D n T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 37 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 10 OVF Syntax OVF Arguments none Returns value value the high order 16 bits from certain math and shift functions Description This function returns the high order 16 bits from certain math and shift functions It is extremely useful for calculating 32 bit address offsets for MEDIA access It can be used with the shift operations addition subtraction multiplication and modulus operations Example var loWord hiWord loWord 0x2710 0
55. Z m TE J O D T J lt x Z a T Z of spaces Returns Pointer Returns the position of last extraction point This is useful for processing by Pointer other string functions PICASO Description This function prints a formatted string from elements derived from a structured byte region There is only one input argument the byte region pointer ptr which is automatically advanced as the format specifier string is processed The format string is similar to the C language however there are a few differences including the addition of the indirection token asterix Example var buffer 100 200 character buffer for a source string var p q string pointers wee I var m 20 for our structure example var format a pointer to a format string func main var k 2012 4D SYSTEMS Page 263 of 317 www 4dsystems com au ui Z fees U Z zj TE J O D T J lt Z Y T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS string print example to buffer print nHELLO WORLD q str Ptr buffer raise a string pointer so we can use the fi erring EwacicLome p q ati Pointi Go OC J omily prints first characters Of string putch n new line p i q k str Printf amp p 04s prints 4 leading spaces before string putch n new line jesus yg if required the re
56. a T lt PICASO 2 11 13 com TXcounit reete raa eret rere et rk reader tess nstedscsaceasleesvavdectane tte Re ARE TER Pa FEE UR O AREE RO 170 2 11 14 com TXemptyEvent function esee eene enne enne enne nnn enne nnne innen enne 171 2 12 2C BUS Master FUhCLIORS eoo ue eR copa En ne veh Gea XE Reha EAR EHE ak Ge RE ia SERE a Ea Dine ANEA 173 2 12 1 2C OPEN SPEER EM 174 212 2 N26 Orio m SM 175 212 3 2G a E E 176 212196 SOC ne Ro IRI MEME MEME MEE E MM E E 177 212 5 12C Restart m P 178 2126 2C REIG MEER RUN 179 212 7 12C Write Dyte pue nnee aiene e a a ia aeeoea EN ae AEE Ea E EENE rE REEERE 180 2 128 2E AGK osia e e e EEEE A E AAEE re AE E EEEE EAN 181 2 12 9120 INACK ire oiis aa a E E EE EEEE aE aE EAK Eaa 182 2 12 10 VON o um E M 183 2 12 11 ZG ACKPOI CONEHON E 184 2 529 ANC dB EA EE EEI EAA E NEE ecd Re 185 2 12 13 12C Gets buffer SIZE Jenster cuoi aio aeie a aae aa Pa EEEE a EAEn a eRe EREE EN EE 186 VIP S IA OE C e PREE EE TE E E E E E A A E dea esedeaseeuese 187 2 12 15 12C P ts buffer senses i terrae einas ee aaa ae aaa aa Ea e RENS ON R RR Ee RR EE 188 VINA TUN UE Ea 189 2 13 Timer Functlols ise e E o RR GEGEN EUR EE GRUSS URNA FERE EIN IET G canes sedans 190 EIESINCTNILU
57. at any time when in buffered communications is active to determine the number of characters that are waiting in the buffer Example n com Count get the number of chars available in the buffer un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 164 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 8 com_Full Syntax com_Full or com1_Full Arguments none Returns status status Returns 1 if buffer or queue has become full or is overflowed else returns 0 Description If the queue is not read frequently by the application and characters are still being sent by the host the head will eventually catch up with the tail setting the COM_FULL flag which is read with this function If this flag is set any further characters from the host are discarded however all the characters that were buffered up to this point are readable Example 3r Com Duli e com Comme O 9 com Init mybuf 30 0 buffer full recovery endif un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 165 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 9 com_Error Syntax com_Error or com1_Error Arguments none Returns status status Returns 1 if any low level communications erro
58. be AA55 The media internal address is internally incremented for each of the byte operations un Z j T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 137 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 7 media_ReadWord Syntax media_ReadWord Arguments none Returns word value Description Returns the word value 2 bytes from the current media address The internal byte address will then be internally incremented by one If the address is not aligned the word will still be read correctly Example var myword if media Init media SetAdd 0 510 myword media ReadWord print HEX4 myword endif repeat forever This example initialises the media sets the media byte address to 510 and reads the last word from sector O If the card happens to be formatted the result will be AA55 un Z j T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 138 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 8 media_WriteByte byte_val Syntax media_WriteByte byte_val Arguments byte_val byte_val The lower 8 bits specifies the byte to be written at the current media address location The arguments can be a variable array element expression or constant Returns success success R
59. buffer raise a string pointer so we can use the un Z fees T c zm TE J D 2 q Z Y TT Z string functions p p 13 offset into the buffer a little so we don t see word Q way t oriol pe n i p Vala je show the start point of our search U ik Se 07 a while n 4 A prine NU X STR Siteimegs iim X is at pos p sux Pind amp p strings n An wend print nNOTE p is unchanged p p note that p is unchanged endfunc 2012 4D SYSTEMS Page 261 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 14 str_Length ptr Syntax str_Length ptr Arguments ptr ptr pointer to string buffer Returns Value Value Returns String length Description Returns the length of a string excluding terminator Example var a var b var cello 80 character buffer for a source string var pa pc These will be String pointers to a and c func main un Z T c zm TE J D 2 q Z Y TT Z a mem Alloc 200 allocate a dynamic buffer full of random data mem Set a X 200 fy ilL it Full oF K s pa str Ptr a raise a string pointer str PutByte pat20 0 Now stick a string terminator in the array Change the 20 to be between 0 and 199 b A string constant b is a pointer to a string constant eo lela ocine YAa VASCIIAY Serie
60. byte address while n lt 20 media WriteWord RAND write 20 random words to first 20 wend word locations n 0 while n lt 20 media WriteWord nt 1000 write sequence of 1000 n to next 20 wend word locations media Flush we re finished close the sector media SetAdd 0 1536 40 set the starting byte address n 0 while n lt 8 print result of fist 8 multiplication calcs print HEX4 media ReadWord Nn wend repeat forever This example initialises the media writes some words to the required sector then prints the result from the required location 2012 4D SYSTEMS Page 140 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 10 media_Flush Syntax media_Flush Arguments none returns 0 if Failed Returns returns non zero if OK Description After writing any data to a sector media Flush should be called to ensure that the current sector that is being written is correctly stored back to the media else write operations may be unpredictable Example See the media WriteByte and media WriteWord examples un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 141 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 11 media_Image x y Syntax media_Image x y Arguments X y X y specifies the t
61. called when the COMO or COMI TX buffer is empty This is useful for either reloading the TX buffer setting or clearing a pin to change the direction of eg a RS485 line driver or any other form of traffic control The event function must not have any parameters To disable the event simply call com TXemptyEvent O or com1_TXemptyEvent 0 com_TXbuffer or com1_TXbuffer also resets any active event Example jOleecoism WIC DHS ZIM GRKA KOR KKK KK KKK KK KK IK A KK KK KK ee Description buffered TX servic Use Workshop terminal at 9600 baud to see result Example of Buffered TX service vs Non buffered Also explains the use of COMMS events NB Program must be written to flash so the Workshop Terminal can be used OKCKCKCK kk kk kk kk A AI kk kk KK Kok kk ko kk ke kk oko ke e koe e ke ke e e e x x var combuf 220 buffer for up to 440 bytes run a timer event while we are doing comms func T7Service var private colour OxF800 colour OxF800 gfx RectangleFilled 50 200 80 220 colour sys SetTimer TIMER7 200 endfunc event to capture the buffer empty event func bufEmpty Somme OMM NENNT Neuen nee ESSE SSeNE print n nHELLO WORLD I M EMPTY com TXcount Mn endfunc func main var n r D fh sys SetTimerEvent TIMER7 T7Service run a timer event sys SetTimer TIMER7 150 com TXemptyEvent bufEmpty set to captur buffer empty event setbaud BAUD 9600 2012 4D SYSTEMS Page
62. char print result starting f f Beem 5 L oodd DL repeat forever This example initialises the media writes some bytes to the required sector then prints the result from the required location 2012 4D SYSTEMS Page 139 of 317 www 4dsystems com au Wn z T Z m TE J T m I J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 9 media_WriteWord word_val Syntax media_WriteWord word_val Arguments word val word val The 16 bit word to be written at the current media address location The arguments can be a variable array element expression or constant Returns success success Returns non zero if write was successful Description Note Writing bytes or words to a media sector must start from the beginning of the sector All writes will be incremental until the media Flush function is executed or the sector address rolls over to the next sector When media Flush is called any remaining bytes in the sector will be padded with OxFF destroying the previous contents An attempt to use the media SetAdd function will result in the lower 9 bits being interpreted as zero If the writing rolls over to the next sector the media Flush function is issued automatically internally Example Wee I while media Init 0 wait until a good SD card is found n 0 media SetAdd 0 1536 set the starting
63. characters that were buffered up to this point are readable This is a good way of reading a fixed size packet and not necessarily considered to be an error condition If no characters are removed from the buffer until the COM FULL flag which can be read with the com Full function becomes set it is guaranteed that the bytes will be ordered in the buffer from the start position therefore the buffer can be treated as an array and can be read directly without using serin at all In the latter case the correct action is to process the data from the buffer re initialise the buffer with the com Init function or reset the buffered serial service by issuing the com Reset function which will return serial reception to polled mode and send an acknowledgement to the host traditionally a ACK or 6 to indicate that the application is ready to receive more data and the previous packet has been dealt with or conversely the application may send a negative acknowledgement to indicate that some sort of error occurred or the action could not be completed traditionally a NAK or 16 If any low level errors occur during the buffering service such as framing or over run the internal COM ERROR flag will be set which can be read with the com Error function Note that the COM FULL flag will remain latched to indicate that the buffer did become full and is not reset even if all the characters are read until the 2012 4D SYSTEMS Page 161
64. colour title bar properties edle bar text pointer set default title bar text var private title title bar text pointer var private font FONT3 default font var private titlebarheight 20 default title bar height var private titlebarcolor TITLEBAR COLOR default title bar colour var private titletextcolor TITLETXT COLOR default title text colour status bar properties var private statusbartext status bar text pointer var private statusbarheight 10 default status bar height var private statusbarcolor STATUSBAR COLOR default status bar colour var private statustextcolor STATUSTXT COLOR default status txt colour var private btncolor LIGHTGREY default button colour var private textcolor BLACK default text colour var private ygap 4 vertical gap between buttons var private touchX1 MAXBUTTONS touch regions for the buttons var private touchY1 MAXBUTTONS var private touchX2 MAXBUTTONS var private touchY2 MAXBUTTONS var private vButtonState MAXBUTTONS button state flags bit 0 up down state var private vOldButtonState MAXBUTTONS OLD button state flags bit 0 up down state var private lastkey last button pressed messages var private touchState window touch status var private touchX window x position var private touchY window y position local variables var n X y x1 yl x2 y2 oldFG
65. comedtion un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 176 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 4 I2C Stop Syntax I2C Stop Arguments None Returns None Description Calling this function sends an I2C stop condition The hardware first releases the SCL to high state and then releases the SDA line high SCL SDA Example I2 soe s un Z T Z TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 177 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 5 I2C Restart Syntax I2C Restart Arguments None Returns None Description Calling this function generates a restart condition Example I2C Restart Generates an I2C restart condition un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 178 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 6 I2C Read Syntax I2C Read Arguments None Returns Byte Byte Byte from the I2C Bus in the lower 8 bits Description Calling this function reads a single byte from the I2C bus Note Data can only change when the clock is low ce ee ef ey ee eo A Example c I
66. dest src count Syntax str CopyN dest src count Arguments dest src count dest points to byte aligned destination Src points to byte aligned source count Maximum number of bytes to copy Returns Pointer Pointer Returns a pointer to the 0x00 string terminator at the end of dest which is dest str_Length src Description Copy a string from src to dest stopping only when count is exhausted or end of source string str is encountered 0x00 string terminator The terminator is always appended even if count is zero or src is a null string Example nextplace str CopyN d s 100 un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 269 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 17 Touch Screen Functions Summary of Functions in this section e touch DetectRegion x1 y1 x2 y2 e touch Set mode e touch Get mode Note Touch Screen functions do not apply to uVGA II GFX module un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 270 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 17 1 touch_DetectRegion x1 y1 x2 y2 Syntax touch_DetectRegion x1 y1 x2 y2 Arguments X1 y1 x2 y2 x1 specifies the horizontal position of the top lef
67. device interfaced to the PICASO GFX2 SPI port Summary of Functions in this section e media Init e media SetAdd Hlword LOword e media SetSector Hlword LOword e media RdSector Destination Address e media WrSector Source Address e media ReadByte e media ReadWord e media WriteByte byte val e media WriteWord word val e media Flush e media Image x y e media Video x y e media VideoFrame x y frameNumber un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 131 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 1 media_Init Syntax media_Init Arguments none Returns result result Returns 1 if memory card is present and successfully initialised Returns 0 if no card is present or not able to initialise Description Initialise a uSD SD SDHC memory card for further operations The SD card is connected to the SPI serial peripheral interface of the PICASO GFX2 chip Example while Imedia Init V gfx Cls pause 300 puts Please insert SD card pause 300 wend This example waits for SD card to be inserted and initialised flashing a message if no SD card detected un Z j T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 132 of 317 www 4dsystems com au un Z T Z zm TE J D S lt x Z Y TT Z
68. gfx Circle 110 56 10 PINK head gfx Polyline 5 vx 10 vy 10 BROWN dress gfx Line 104 104 106 90 PINK left arm gix Cine M2 MESRINIEOE right arm gfx Polyline 3 vx 15 vy 15 SALMON dress repeat forever endfunc This example draws a simple scene un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 88 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 11 gfx_Polygon n vx vy colour Syntax gfx_Polygon n vx vy colour Arguments n vx vy colour specifies the number of elements in the x and y arrays specifying the vertices for f the polygon specifies the addresses of the storage of the array of elements for the x m coordinates of the vertices specifies the addresses of the storage of the array of elements for the y wy coordinates of the vertices colour Specifies the colour for the polygon The arguments can be a variable array element expression or constant Returns nothing Description Plots lines between points specified by a pair of arrays using the specified colour The last point is drawn back to the first point completing the polygon The lines may be tessellated with the gfx LinePattern function gfx Polygon can be used to create complex raster graphics by loading the arrays from serial input or from MEDIA with very little code requirement
69. in the media is previously specified with the media SetAdd or media SetSector function If the video is shown partially off screen it may not be displayed correctly Note that showing a video blocks all other processes until the video has finished showing See the media VideoFrame functions for alternatives Example while media Init 0 I weit i mo SD dT dee cte media SetAdd 0x0001 0x3C00 point to the 10 gear clip media Video 10 10 gfx Clipping ON turn off clipping to see the difference media Video 12 50 show video off screen to the left media Video 50 12 show video off screen at the top repeat forever This example plays a video clip at several positions showing the effects of clipping un Z T Z em TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 143 of 317 www 4dsystems com au un Z T Z m TE J T T J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 13 media_VideoFrame x y frameNumber Syntax media_VideoFrame x y frameNumber Arguments X y X Y specifies the top left position where the video clip will be displayed frameNumber Specifies the required frame to be shown The arguments can be a variable array element expression or constant Returns nothing Description Displays a video from the media storage device at
70. not affected Example var argl argl OxAA bus_Set argl Set the bus to value specified to argl un Z I T Z TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 22 of 317 www 4dsystems com au un Z I T Z em TE J D QO E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 8 bus_Write data Syntax bus_Write data Arguments data data The lower 8 bits of data are sent to the bus The argument can be a variable array element expression or constant Returns nothing Description The lower 8 bits of arg1 are placed on the BUS then after a settling delay of approx 5Onsec the BUS WR pin is strobed LO for approx 5Onsec then set back HI The upper 8 bits of arg1 are ignored Note The BUS WR pin is automatically pre set to an output to ensure BUS write integrity Example Wee Caicall p datal 0x05 bus Write datal lBuswr 50ns K 2012 4D SYSTEMS Page 23 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 9 bus_Read Syntax bus_Read Arguments none Returns value value Returns the state of the bus as an 8bit value Description Returns the state of the bus as an 8bit value in to the lower byte of the assigned variable Note The BUS RD and BUS WR pins are not affected The BUS RD pi
71. number vButtonState lastkey 1 UP last button is now UP lastkey 0 clear button memory gosub Update update the button action endif endsub exitfunc return retval endfunc sossssss sss s 555555555 5555 5555555555 55S SS SS SSS SS SS SSS SS SSS SSS SS SSS SSS SSS mount the drive return status message and D will be null if mount fails func init Drive var retry 10 if D file Mount while retry if D file Mount break wend 2012 4D SYSTEMS Page 309 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS if retry return Mount Failed endif return Disk mounted endfunc un Z j T Z TE J T n E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 310 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 5 Appendix B Runtime Error Messages Error Number Meaning Category 1 Failed to receive L during loading process from Workshop Workshop 2 Did not receive valid header info from Workshop Workshop 3 Header size does not match loader info Workshop 4 Could not allocate enough memory for program Workshop 5 Loader checksum error Workshop ul 6 Did not receive header prior to L command Workshop Z 7 Header size entry does not match loader value Workshop 8 Failed to load program from FLASH Internal LJ 9 Could
72. of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS com_Init or com_Reset function is issued e Using a qualifier If a qualifier character is specified after the buffer is initialised with com Init the service will ignore all characters until the qualifier is received and only then initiate the buffer write sequence with incoming data After that point the behaviour is the same as above for the non qualified mode Example com Init combuf 20 0 set up a comms ring buffer maximum 12 characters before overflow Wn z LJ Z J TE J O D T J lt x Z Y T Z PICASO 2012 4D SYSTEMS Page 162 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 6 com_Reset Syntax com_Reset or com1 Reset Arguments none Returns nothing Description Resets the serial communications buffered service and returns it to the default polled mode Example com Reset reset to polled mode un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 163 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 7 com Count Syntax com Count or com1 Count Arguments none Returns count count current count of characters in the communications buffer Description Can be read
73. of inbuilt dials gauges and meters that can simply be placed onto the simulated module display From here each object can have its properties edited and at the click of a button all relevant 4DGL code associated with that object is produced in the user program The user can then write 4DGL code around these objects to utilise them in the way they choose rane an ViSi Genie is a breakthrough in the way 4D Systems graphic display modules and processors are programmed It is an environment like no other a code less programming environment that provides the user with a rapid visual experience enabling a simple GUI application to be written from scratch in literally seconds 2012 4D SYSTEMS Page 313 of 317 ViSi Genie does all the background coding no ADGL to learn it does it all for you Pick and choose the relevant objects to place on the display much like the ViSi Environment See Section 11 2 yet without having to write a single line of code Each object has parameters which can be set and configurable events to animate and drive other objects or communicate with external devices Simply place an object on the screen position and size it to suit set the parameters such as colour range text and finally select the event you wish the object to be associated with it is that simple In seconds you can transform a blank display into a fully animated GUI with moving sliders animated pre
74. of it In case that the size is 0 the memory previously allocated in ptr is deallocated as if a call to mem_Free myvar was made and a NULL pointer is returned Example myvar mem Realloc myptr 100 2012 4D SYSTEMS Page 291 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 5 mem_Free allocation Syntax mem_Free allocation Arguments Allocation allocation specifies the location of memory block to free up Returns Status Returns non zero if function is successful Status Returns 0 if the function fails Description The function de allocates a block of memory previously created with mem Alloc mem AllocV or mem Allocz Example test mem Free myvar un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 292 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 6 mem_Heap Syntax mem_Heap Arguments None Returns Value Value Returns the largest available memory chunk of the heap Description Returns byte size of the largest chunk of memory available in the heap Example howmuch mem Heap un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 293 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2
75. oldBG oldFont r retval save the things we will change Glelrome PESK MI MONI ID z oldFG peekW TEXT COLOUR oldBG peekW TEXT BACKGROUND un Z I T c TE J D I E lt x Z Y TT Z Il functions methods gosub subfunc Initialize Update Scan RedrawTitleBar RedrawStatusBar restore things we changed txt FontID oldFont txt FGcolour oldFG txt BGcolour oldBG PICASO goto exitfunc Linn ERE reset the window and redraw the buttons to the up state f f m SE SSIS Initialize touch Set TOUCH ENABLE enable the touch screen gfx Panel PANEL RAISED xpos ypos windowWidth titlebarheight titlebarcolor draw title bar panel gfx Panel PANEL SUNKEN xpos peekW GFX Y2 windowWidth windowHeight titlebarheight statusbarheight windowcolor draw main window panel gfx Panel PANEL RAISED xpos peekW GFX Y2 windowWidth statusbarheight statusbarcolor draw status bar panel 2012 4D SYSTEMS Page 307 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS X xpostwindowWidth titlebarheight y ypost2 gfx Button BUTTON UP x y OLIVE ORANGE FONTI 1 1 btnexit place the quit button gosub RedrawTitleBar set the title gosub RedrawStatusBar set the status bar text xl xpos 10 yl ypos 30 set position of the first button offset in the window for n 0 n MAXBUTTONS 1 n draw the 4 u
76. ptr e str PutByte ptr val str PutWord ptr val e str Match amp ptr str e str Matchl amp ptr str str Find amp ptr str e str Findl amp ptr str str Length ptr str Printf amp ptr format str Cat amp destination amp Source str CatN amp ptr str count e str ByteMove src dest count str Copy dest src str CopyN dest src count 2 17 Touch Screen Functions Touch functions do not apply to uVGA II GFX module e touch DetectRegion x1 y1 x2 y2 touch Set mode e touch Get mode 2 18 Image Control Functions img SetPosition handle index xpos ypos img Enable handle index e img Disable handle index img Darken handle index img Lighten handle index e img SetWord handle index offset word img GetWord handle index offset img Show handle index img SetAttributes handle index value e img ClearAttributes handle index value img Touched handle index T Z T Z m Ti J T J q z Y TT Z 2 19 Memory Allocation Functions mem Alloc size e mem Allocv size mem Allocz size mem Realloc ptr size mem Free allocation mem Heap mem Set ptr char size mem Copy source destination count mem Compare ptr1 ptr2 count PICASO 2 20 General Purpose Functions pause time lookup8 key byteConstList ookup16 key wordConstList 2012 4D SYSTEMS Page 14 of 317 www 4dsystems com au
77. range eg n RAND 100 will return a random number between 99 and 499 If you are using random number generation for random graphics points or only require a positive number set you will need to use the ABS function so only a positive number is returned eg X1 ABS RAND 96 100 will set co ordinate X1 between O and 99 Note that if the random number generator is not seeded the first number returned after reset or power up will be zero This is normal behavior Description This function returns a pseudo random signed number ranging from 32768 to 432767 Example SEED 1234 print RAND RAND This example will print 3558 1960 to the display un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 35 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 8 SEED number Syntax SEED number Arguments number number Specifies the seed value for the pseudo random number generator The arguments can be a variable array element expression or constant Returns nothing Description This function seeds the pseudo random number generator so it will generate a new repeatable sequence The seed value can be a positive or negative number Example SEED 50 7 print RAND RAND This example will print 30129 27266 to the display un Z T
78. screen shot to file at the current file position The image can later be displayed with file Image The file may be opened in append mode to accumulate multiple images Later the images can be displayed with file Seek The image is saved from x y with respect to top left corner and the capture area is determined by width and height Example file Mount 7 hFile file Open test img a open a file to save the image file ScreenCapture 20 20 100 100 hFile save an area file ScreenCapture 0 0 50 50 hFile save another area file Close hFile now close the file and to display the saved area s hFile file Open test img r open the saved file file Image 20 180 hFile display the image file Image 150 180 hFile display the next image file Close hFile file Unmount finished with file system 2012 4D SYSTEMS Page 217 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 17 file_PutC char handle Syntax file_PutC char handle Arguments char handle char Data byte about to be written handle The handle that references the file to be written to Returns BytesWritten BytesWritten Returns the number of bytes written Description This function writes the byte specified by char to the file at the position indicated by the associated file position pointer and advances the pointer appropriately incre
79. strlen pointer Arguments pointer pointer The pointer to a zero 0x00 terminated string Returns length length Returns the length of a string in character units Description strlen returns the length of a zero terminated string in character units Note that any string constants declared in your program are automatically terminated with a zero as an end marker by the compiler Any string that you create in the DATA section or MEM section must have a zero added as a terminator for this function to work correctly Example See example in charwidth 2012 4D SYSTEMS Page 59 of 317 www 4dsystems com au Uu Z O E Z TE a D e Ej q Z a T Z PICASO 4 D SYSTEMS PICASO INTERNAL ADOL FUNCTIONS 2 4 12 txt_Set function value Syntax txt Set function value Arguments function value function The function number determines the required action for various text control functions Usually a constant but can be a variable array element or expression There are pre defined constants for each of the functions value A variable array element expression or constant holding a value for the selected function Returns nothing Description Given a function number and a value set the required text control parameter such as size colour and other f
80. taches Verte sei eet aces etas Ee a EAEE aa SR ser e RAE Suse A ineunte d eate e PER EST 243 2 15 4 snd StOp c E Lee Ere eigen retener E E eR Ep eerte PEE VAR A A E dea Foro ERAT OR o 244 2 15 5 snd PAUSE ics eoi ea eaaa e eaae aS Rae KM ER RES RE RAP agn EN Ree Re a ARE ARRA e Eiaeai 245 2 15 6 snd Contin el uiie eit tier kiki RE REESE REL e b Sub XE ER KERN aA a EE Ea RE ARR AERRU eaaa EEEE 246 215 7 snd PLAYING erre oee rne Ese rad aate rca rena sud raa ce Yo Py Poker hare He rud espace re EAE aS ranae Pet a Te pape nga 247 2 16 String Class FUNCOMS sneseno rtr ren ite E rrt Errore He Ve Ra e HE Eee i Fas Ege Eier Ren pore Pe Perna 248 2 16 1 Stk PtrF amp V al rore tke eden ctetu ark A eade pae ka anne seda uuo n dex eu xu Reda eu I PUR EN RRA ERN 249 2 16 2 str GetD amp ptr QVI irisi encient enne nnne nennen enn iia aai taaak Pina aE ota RASNA enne 250 2 16 3 str GetW amp ptr Sivan osoin aii E a Nia erii EE ii 251 2 16 4 str GetHexW amp ptr amp var eesesssesseeee eene nennen enne enne nnne nnne nennen nennen serene nnne 252 2 16 5 sti GetC amp ptt amp Var iiuiece riesen nen ee Xu EE Re eR MN AR DEREN RE Ea e AX ea RARE Y ERR XX ERR de ee 253 pIMESS E daMicidiarihisme e mc 254 2516 7 Mcd 255 2 16 8 str PutByte ptr val sees enne nennen nennen enne sinini nennen innen tenni eisni enne 256 2 16 9 str PutWordlptr Valesi terere tirer eerte dece P
81. the 16 bit value that is stored at address Example var myvar myvar peekW SYSTEM TIMER LO This example places the low word of the 32 bit system timer in myvar un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 26 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 2 2 pokeW address word_value Syntax pokeW address word value Arguments address word value address The address of a memory word The address is usually a pre defined system register address constant see the address constants for all the system word sized registers in section 3 table 3 2 word value The 16 bit word value will be stored at address The arguments can be a variable array element expression or constant Returns boolean boolean Returns TRUE if poke address was a legal address usually ignored Description This function writes a 16 bit value to a location specified by address Example pokeW TIMER2 5000 This example sets TIMER2 to 5 seconds un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 27 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Summary of Functions in this section e ABS value e MlIN value1 value2 e MAX valuel1 value2 e SWAP amp var1 amp var2 e SIN angle e COS ang
82. the specified co ordinates The video address is previously specified with the media SetAdd or media SetSector function If the video is shown partially off it may not be displayed correctly The frames can be shown in any order This function gives you great flexibility for showing various icons from an image strip as well as showing videos while doing other tasks media VideoFrame will now show error box for out of range video frames Also if frame is set to 1 just a rectangle will be drawn in background colour to blank an image It applies to PmmC R29 or above Example var frame while media Init 0 wait if no SD card detected while media Init 0 wait if no SD card detected media SetAdd 0x0002 0x3C00 point to the 10 gear image repeat frame 0 start at frame 0 repeat media VideoFrame 30 30 frame display a frame pause peekB IMAGE DELAY pause for the time given in the image header until frame peekW IMG FRAME COUNT loop until we ve shown all the frames forever do it forever This first example shows how to display frames as required while possibly doing other tasks Note that the frame timing although not noticeable in this small example is not correct as the delay commences after the image frame is shown therefore adding the display overheads to the frame delay This second example employs a timer for the framing delay and shows the same movie simultaneously running forwa
83. thing and a contention would occur printing to the wrong position This function should be used wisely if any action that is required would take considerable time it is better to disable any conflicting event functions with a bypass flag then restart the conflicting event by re issuing a timer value Example sys EventsPostpone postpone the event queue un Z T Z TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 197 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 8 sys EventsResume Syntax sys EventsResume Arguments None Returns None Description Resume any postponed events The queue will try to execute any timer events that were incurred during the postponed period Example sys EventsResume resume the event queue un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 198 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 9 sys Sleep units Syntax sys Sleep units Arguments units units Sleep timer units are approx 1 second When in sleep mode timing is controlled by an RC oscillator therefore timing is not totally accurate and should not be relied on for timing purposes The arguments can be a variable array element expression or constant Returns Status
84. to an output it is automatically made an output Example pin LO TOL PIN output a Logic 0 on IOl1 pin un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 18 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 4 pin_Read pin Syntax pin Read pin Arguments pin pin A value usually a constant specifying the pin number The arguments can be a variable array element expression or constant Returns value value Returns a Logic 1 0x0001 or a Logic O 0x0000 or the analogue value of the input pin Description Reads the logic state of the pin that was previously selected as an Input Returns a Low logic 0 or High logic 1 Example if pin Read IOl PIN 1 read the value on TOI calc Threshold else un Z T Z Ti J D SI 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 19 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Syntax bus In Arguments none Returns value value Returns the state of the bus as an 8bit value Description Returns the state of the bus as an 8bit value in to the lower byte of the assigned variable Note The BUS RD and BUS WR pins are not affected Example wari s bue 1m The lower byte of var1 will get loaded with the sta
85. to make it print in various ways for instance if you wish to print a number in 4 digit hex use the HEX4 directive placed in front of the variable to be displayed within the print statement See the following example print myvar as a 4 digit HEX number is HEX4 myvar Note that there are 2 print directives that are not part of the numeric set and will be explained separately these are the STR and CHR directives un Z T Z m Ti J T J q z Y TT lt The STR directive expects a string pointer to follow s Hello World assign a string constant to s print Var s points to a string constant at address s which is STR s The CHR directive prints the character value of a variable print The third character of the string is CHR s 2 PICASO also print The value of myvar as an ASCII charater is CHR myvar Note that you can freely mix string pointers strings variables and expressions within a print statement print can also use the to function to redirect it s output to a different output device other than the screen using the function refer to the to statement for further examples Example platform uOLED 32028 P1 GFX2 VMLIMbMLlMMekaMillllillilKKl DATA STATEMENT VM IM L Lll t i B Ufi DATA 2012 4D SYSTEMS Page 51 of 317 www 4dsystems com au ui Z U Z zj TE J O D
86. 0 indicates no qualifier to be used The argu ments can be a variable array element expression or constant Returns nothing Description This is the initialisation function for the serial communications buffered service Once initialised the service runs in the background capturing and buffering serial data without the user app lication having to constantly poll the serial port This frees up the application to service other tasks MODES OF OPERATION No qualifier simple ring buffer aka circular queue If the qualifier is set to zero the buffer is continually active as a simple circular queue Characters when received from the host are placed in the circular queue at the head of the queue Bytes may be removed from the circular queue from the tail of the queue using the serin function If the tail is the same position as the head there are no bytes in the queue therefore serin will return 1 meaning no character is available also the com Count function can be read at any time to determine the number of characters that are waiting between the tail and head of the queue If the queue is not read frequently by the application and characters are still being sent by the host the head will eventually catch up with the tail setting the internal COM FULL flag which can be read with the com Full function Any further characters from the host are are now discarded however all the
87. 012 4D SYSTEMS Page 206 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 6 file_Exists fname Syntax file_Exists fname Arguments fname fname Name of the file for the search passed as a string Returns Status 1 File found renis 0 File not found Description Tests for the existence of the file provided with the search key Returns TRUE if found Example If file Exists fill 4XE Print File Found endif un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 207 of 317 www 4dsystems com au WN z T z Ti u O D E q z Y T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 7 file_Open fname mode Syntax file_Open fname mode Arguments fname mode fname Name of the file to be opened passed as a string mode FILE READ r FILE WRITE w FILE APPEND a Returns handle handle Returns handle if file exists Sets internal file error number accordingly 0 if no errors Description Returns handle if file exists The file handle that is created is now used as reference for filename for further file functions such as file Close handle etc For FILE WRITE and FILE APPEND modes w and a the file is created if it does not exist If the file is opened for append and it alread
88. 1 isdigit char Syntax isdigit char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not as ASCII digit Status 1 Character is an ASCII digit Description Tests the character parameter and returns a 1 if the character is an ascii digit else returns a O Valid range 0123456789 Example func main var ch Welle GuEBED gfx Cls txt Set FONT ID FONT2 print Serial Input Test n print Download prog to flash n print Then use debug terminal n to COMO print serial input test n now just stay in a loop repeat ch serin if ch 1 preinel CAR em J if a key was received from PC print its ascii value iff iehiga Cla peue Character 16 aia ASCII dglgit p if isxdigit ch print Character is ASCII Hexadecimal if isupper ch print Character is ASCII uppercase letter if islower ch print Character is ASCII uppercase letter if isalpha ch print Character is an ASCII uppercase or lowercase if isalnum ch print Character is an ASCII Alphanumeric if isprint ch print Character is a printable ASCII if isspace ch print Character is a space type character un Z T c zm TE J D T 2 q Z Y TT Z endif PICASO forever endfunc 2012 4D SYSTEMS Page 63 of 317 www 4ds
89. 1 x2 y2 colour x1 y1 specifies the top left corner of the rectangle x2 y2 specifies the bottom right corner of the rectangle colour specifies the colour of the rectangle The arguments can be a variable array element expression or constant Returns nothing Description Draws a rectangle from x1 y1 to x2 y2 using the specified colour The line may be tessellated with the gfx_LinePattern function NB The default PEN_SIZE is set to OUTLINE however if PEN_SIZE is set to SOLID the rectangle will be drawn filled if PEN_SIZE is set to OUTLINE the rectangle will be drawn as an outline If the rectangle is drawn as SOLID the outline colour can be specified with gfx OutlineColour If OUTLINE COLOURis set to 0 no outline is drawn The outline may be tessellated with the gfx LinePattern function Example gfx Rectangle 10 10 30 30 GREEN This example draws a GREEN rectangle from x1 10 y1 10 to x2 30 y2 30 un Z T Z m TE J D m E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 85 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 9 gfx_RectangleFilled x1 y1 x2 y2 colour Syntax gfx_RectangleFilled x1 y1 x2 y2 colour Arguments x1 y1 x2 y2 colour x1 y1 specifies the top left corner of the rectangle x2 y2 specifies the bottom right corner of the rectangle colour speci
90. 10 2 Sp REA M E 153 210 3 Spl Write YEG ctio Gore soe vende durat a a aee ra pma seti ita EEEa ian DEES E a ETTEN 154 2 10 4 spl Disable 2 3 oreet e eee ee dusdebosancnscehcelsseuacasuhcadevete dex qacnadsieladbesesstdccdanstateasteceate 155 2 11 Serial UART Communications FUNCTIONS cccccessecesscesscecesecseceeceeecsseeeceaecseeeeceseceeeeecsaeeeeetecsaeesees 156 2 11 1 setba d rate oi serene coe ere ri eene eere de entes EAEE EAEE eden cobsesenvedinden edbocuns 157 2 11 2 com SetBaud comport baudrate 10 sesseseseeeeeeee eene enne nnne 158 VS NCC EM TIMES 159 TLA SOPOUT CHAP p Eii 160 2 11 5 com_Init buffer bufsize qualifier sese ener nennen nnne 161 2 116 coim ReSeE oci eode erea EAEE Ee E AEN aP EEEE EE A A E A EEEE 163 2 11 7 com COUNt ciui AEA AE T E Red dee E E A E E A eves RR TR RD 164 211 8 c m Fully eite rit tira Eee ERE Re RYE FEBRE ER RES NE R2 RD ex EE FERE RES E Aa oa EN RE RARE R aiie 165 2 11 9 COM EFEOT 11s EA e Ree R E NRRR Re REN E uo XN RE SERRE REX XR SE RRRA KR 166 PM REST DB To oT E EE 167 2 11 11 com TXbuffer buf bufsize pin seeeeseeeeesseeseeeee eene enne enne nennen nennen 168 2 11 12 com TXbufferHold state sseesseses sese seen eene enne enne enne nennen enne nnne 169 u Z u Z TE J O m J lt x z
91. 19 7 mem_Set ptr char size Syntax mem_Set ptr char size Arguments ptr char size ptr specifies the memory block char specifies the value to fill the block with size specifies the size of the block in Bytes Returns Pointer Pointer Returns the pointer Description Fill a block of memory with a byte value Example var mybuf 5 var i func main mem Set mybuf 0x55 5 Only fills half of mybuf for i 0 i lt sizeof mybuf i Show what is in the buffer print Ox HEX mybuf i next mem Set mybuf 0OxAA sizeof mybuf 2 Fill entire buffer print n New line for i 0 i lt sizeof mybuf i reshawa Y Oss Deep T anyone Lat p next repeat forever un Z j T Z zm TE J T n T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 294 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS un Z I T c TE J T n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 295 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 8 mem_Copy source destination count Syntax mem_Copy source destination count Arguments source destination count source specifies the source memory block destination specifies the destination memory block count specifies the size of the blocks Returns Pointer Pointe
92. 2 6 15 gfx_OrbitInit amp x_dest amp y_dest Syntax gfx_OrbitInit amp x_dest amp y dest Arguments x dest y dest x dest specifies the addresses of the storage locations for the orbit calculation y dest The arguments can be a variable array element expression or constant Returns nothing Description Sets up the internal pointers for the gfx Orbit result variables The amp x orb and amp y orb parameters are the addresses of the variables or array elements that are used to store the result from the gfx Orbit function Example var targetX targetY gfx OrbitInit amp targetX amp targetY This example sets the variables that will receive the result from a gfx Orbit function call un Z j T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 93 of 317 www 4dsystems com au un Z T Z m TE J D m T E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 16 gfx_Orbit angle distance Syntax gfx_Orbit angle distance Arguments angle distance angle specifies the angle from the origin to the remote point The angle is specified in degrees distance specifies the distance from the origin to the remote point in pixel units The arguments can be a variable array element expression or constant Returns nothing No
93. 2012 4D SYSTEMS Page 106 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 29 gfx_Button state x y buttonColour txtColour font txtWidth txtHeight text Syntax gfx_Button state x y buttonColour txtColour font txtWidth txtHeight text Arguments state x y buttonColour txtColour font txtWidth txtHeight text state 0 Button depressed 1 Button raised X Y Specifies the top left corner position of the button on the screen buttonColour Button colour txtColour Text Colour font Specifies the Font ID txtWidth specifies the width of the text This value is the font width multiplier and minimum value must be 1 txtHeight specifies the height of the text This value is the font height multiplier and minimum value must be 1 text Specifies the text string The text string must be within the range of printable ascii character set The string may have n characters embedded to create a multiline button Returns nothing Description Draws a 3 dimensional Text Button at screen location defined by x y parameters top left corner The size of the button depends on the font width height and length of the text The button can contain multiple lines of text by having the Xn character embedded in the string for the end of line marker In this case the widest text in the string sets the overall width and the height of the button is set b
94. 2C Read Read a single byte from the I2C Bus un Z I T Z em TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 179 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 7 12C_Write byte Syntax I2C Write byte Arguments X byte byte The byte to be written to the I2C Bus The arguments can be a variable array element expression or constant Returns Status Status Returns True if OK Description Calling this function sends a single byte to the 12C bus SUL A XL JOE CX XS XL XU SL XL Example Status I2C Write bytevalue Send a single byte to the I2C un Z I T c TE J T n T J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 180 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 8 I2C Ack Syntax I2C Ack Arguments None Returns None Description Calling this function sends an I2C acknowledge condition The hardware first pulls the SDA line low and next releases SCL high followed by pulling SCL low again thus generating a clock pulse SDA is then released high NB Data can only change when the clock is low SCL N Ack SDA X Example I2C Ack Send I2C Acknowledge condition un Z I T Z TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 181 of
95. 4D SYSTEMS TURNING TECHNOLOGY INTO ART aN PICASO Internal 4DGL Functions Documen t Date 12 Januar y 2013 Documen t Revision 6 3 LU LJ c LU V LU LL LU V Uncontrolled Copy when printed or downloaded u Z u Z TE J O m T J lt x z a T lt PICASO Contents 1 ADGL Introduction sisi sciciiesssscccesssccscessaccssessseccassacsscessatvccensascccessasccuessassecessscacessaaceeessacccnessaasas 8 2 PICASO Chip Resident Functions SUMIMALPY ccssssceccsssseeccesssseccenssseccacssceceessssccaessssccaasssseeees 9 2 1 GPIO FUNCIONS citet one RE iari EE RE MR da E cpusneedanday cai GNOR AMBIEN A I E 15 2 1 1 pin Set mode pln ccnaseocec tese suere rire cor infect ar had err vae te RE e FRI VERTO Re PEE VE ece RE cr Rr RR ae EET r ai ai 16 2 1 2 rmWnmemm 17 yere 18 ZLA pin TS fe DIM PERTERRITI RUN 19 V EST DUS WN RN E ER 20 2 16 bus Out arg coe GR a eE E Ere tn Geek ba i ER RU RR NR 21 2 1 7 DUS SET ANG TELE 22 2 1283 b s Write Catal CT 23 21 9 b s Read o tree ita eh rente edet caste aidgeteutaatuvbeds severe s TEAT EA EEE ET 24 2 2 System Memory Access Functions eese ene nennen nnne enne nenne entere enne nennen enne enn 25 2 2 BITTE E o o T2143 ERROR TEE cdvechasstdbadeversuancecvessidvecenshcecydaadedssabea deuven
96. 4D SYSTEMS Page 223 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 23 file_Erase fname Syntax file_Erase fname Arguments fname fname Name of the file to be erased Returns Status 1 if successful Status 0 if unsuccessful Description This function erases a file on the disk Note If the function fails the approprialte error number is set in file Error and will usually be error 19 failure during FILE search Example res file Erase myfile txt un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 224 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 24 file_Rewind handle Syntax file_Rewind handle Arguments handle handle The handle that references the file Returns Status Status Returns TRUE if ok usually ignored Description Resets the file pointer to the beginning of a file that has been opened in r read w or a append mode Example res file Rewind hSource un Z j T Z zm TE J D n T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 225 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 25 file_LoadFunction fname 4XE Syntax file_LoadFunction fname 4XE Arguments fname 4XE fnam
97. 53555 pueSter BIBIT Mm simply prince a string constant ab current origin ffo Example 2 print string via pointer ff var p a var for use as a pointer p String Constant n assign a string constant to pointer s putstr p print the string using the pointer Ute siesta ror p f prime OHESSEEMMC Imco tie serine Ld Example 3 printing strings from data table SSssSS SS SS SS SS SS SS SS SS SS SS SSS SS SS SS SS SS SS SSS SSS SEE DATA byte message Week 0 word days sun mon tue wed thu fri sat pointers to data items byte sun Sunday n 0 byte mon Monday n 0 byte tue Tuesday n 0 byte wed Wednesday n 0 byte thu Thursday n 0 byte fri Friday m 0 byte sat Saturday n 0 END veu 3005 putstr 2012 4D SYSTEMS Page 47 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS n 0 while n lt 7 putstr days nt print the days wend un Z T Z em TE J D QO S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 48 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 4 putnum format value Syntax putnum format value Arguments format value format 4 constant that specifies the number format value The number to be printed Number formatting bits supplied by format pre als ale aks al all al
98. ASCIIZ null terminated string from a buffer specified by source to the file at the position indicated by the associated file position pointer and advances the pointer appropriately The file must be previously opened with w write or a append modes Example file PutS mystring hndl un Z I T Z em TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 222 of 317 www 4dsystems com au un Z T Z TE J D I 2 q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 22 file_GetS string size handle Syntax file_GetS string size handle Arguments string size handle string Destination buffer size The maximum number of bytes to be read from the file handle The handle that references the file Returns Count Count Returns the number of characters read from file excluding the null teminator Description This function reads a line of text to a buffer specified by string from a file at the current file position indicated by the associated file position pointer and advances the pointer appropriately Characters are read until either a newline or an EOF is received or until the specified maximum size is reached In all cases the string is null terminated The file must be previously opened with r read mode Example res s file Cots myetrimey 30 Mme 2012
99. ASPPAIMni REA 100 216 23 ghx LineTo xpoSs ypOS eei teet rene toe uento Cork aL AREE XE Rex M eeu BEEYR E aa iaaa TaS NE Eo a pea R ER 101 V CRP P WI EET Ceteri 102 26 25 EIX BOXTO X2 V2 E 103 VA OW SEE Micro di EI 104 2 6 27 gfx Ellipse x y xrad yrad colour seen enne 105 2 6 28 gfx EllipseFilled x y xrad yrad colour eese enne nnne 106 2 6 29 gfx Button state x y buttonColour txtColour font txtWidth txtHeight text 107 2 6 30 gfx Panel state x y Width Height Colour nnne 109 2 6 31 gfx Slider mode x1 y1 x2 y2 colour scale value enne 110 2 6 32 gfx ScreenCopyPaste xs ys xd yd width height sess 111 2 6 33 gfx RGBto565 RED GREEN BLUE sese enne nennen nennen 112 2 6 34 gfx 332to565 COLOUR nrerin eaa iaai ia aiiiar irie i aaan aa 113 2 6 35 gfx Selection index backColour textColour eese enne nnne 114 2 6 36 gfx TriangleFilled x1 y1 x2 y2 x3 y3 colour eese enne enne 115 u Z u Z TE J O m T J lt x z a T lt PICASO 2 6 37 gfx PolygonFilled n vx vy colour enne enne enne enne nnn 116 26 38 21K ONEIN y eC 117 2 6 39 ghe GEL mode see dete e een ridere iie tere Eaa a a Eia AERE Ea eia 118 2 6 40 gfx ClipWi
100. CASO INTERNAL 4DGL FUNCTIONS un Z I T c TE J T n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 282 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 8 img_Show handle index Syntax img_Show handle index Arguments handle index handle Pointer to the Image List index Index of the images in the list Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Enable the displaying of the image entry in the image control Returns TRUE if successful but return value is usually ignored Example img Show hImageList imagenum un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 283 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 9 img_SetAttributes handle index value Syntax img_SetAttributes handle index value Arguments handle index value handle Pointer to the Image List index Index of the images in the list value Refers to various bits in the image control entry see image attribute flags Returns Status Status TRUE or FALSE Description This function SETS one or more bits in the IMAGE_FLAGS field of an image control entry value refers to various bits in the imag
101. ConstList eese seen eene enne nennen nnne nennen nennen 301 3 PICASO EVE System Registers Memory Map ener eese eene nennen nn eene nsns nnne nnns 302 4 Appendix A Example 4DGL Code ee eeee eee eene ee eene n ean h nena na ote n esa rre s sa sooo se ano 305 5 Appendix B Runtime Error Messages eeee eee eene ee eene nnn nnne nn nnne nn nasse s ana sn tena na sse 311 6 Hardware TOONS oue lt serscvecdeczeuedsevbeceesveccecsecneuen sees cdeosscesiec sccocdecsscsaenssuestecsecocuessvesen 312 6 1 4D Programming Cable 1 rrr reo nere rapto Pero o evades e i an ER e aae a o nob ee Pasado ada 312 6 2 Evaluation Display Modules esses sees eee ener nnne ennt ntn nnns seen rnnt en ens iaasa iadnn 312 7 4D Systems Workshop 4 IDE 5 1e eo o ores oo nea u opa o usso nss a oo uaa a oo ends ba oo spas ea prada Donau 312 7 1 Workshop 4 Designer Environment sss nennen nennen entente tenete 312 7 2 Workshop 4 ViSiEnvironmelit iini creo nube Cedo tae ey en PEE FERAE RES ERE Es PER GR AR ERR e E aaia 313 7 3 Workshop 4 ViSi Genie Environment sessseseseeeeneneneeeenneen nennen nennen nennt en nennen enne 313 7 4 Workshop 4 Serial Environment eene enne nennen entere sentent innen nnne enne 313 8 REVISION HISLOL otro iine sneen sorre SNE pope eoa ene NNP IKENIEN AAACN SAPONE NER I
102. Description This function allows a raw unadorned byte read from the SPI device Note The Chip Select line SDCS is lowered automatically un Z T Z m TE J D n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 153 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 10 3 spi_Write byte Syntax spi_Write byte Arguments X byte byte specifies the data byte to be sent to the SPI device The arguments can be a variable array element expression or constant Returns nothing Description This function allows a raw unadorned byte write to the SPI device Note The Chip Select line SDCS is lowered automatically un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 154 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 10 4 spi Disable Syntax spi Disable Arguments none Returns nothing Description This function raises the Chip Select SDCS line of the SPI device disabling it from further activity The CS line will be automatically lowered next time the SPI functions spi Read or spi Write are used and also by action of any of the media functions un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 155 of 317 www 4dsystems com au 4D SYSTE
103. Disable handle index e img Darken handle index e img Lighten handle index e img SetWord handle index offset word e img GetWord handle index offset e img Show handle index e img SetAttributes handle index value e img ClearAttributes handle index value e img Touched handle index un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 274 of 317 www 4dsystems com au un Z T Z em TE J D 2 q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 1 img_SetPosition handle index xpos ypos Syntax img_SetPosition handle index xpos ypos Arguments handle index xpos ypos handle Pointer to the Image List index Index of the images in the list xpos Top left horizontal screen position where image is to be displayed ypos Top left vertical screen position where image is to be displayed Returns Status Status True or False Description This function requires that an image control has been created with the file LoadlmageControl function Sets the position where the image will next be displayed Returns TRUE if index was ok and function was successful the return value is usually ignored You may turn off an image so when img Show is called the image will not be shown This function requires that an image control has been created with the file LoadlmageC
104. EEE EXE IE PERE RSS EENS 315 9 Legal DIIIMEMEEE 317 10 Contact Informiatiori 1 eerie aero ono ra aera sua Eo yao pa sg es og uon Exod EE Ke SERE Ree ERREUR E ER asea UR EA 317 WN Z O Z m LL T Z tV UJ Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 1 4DGL Introduction The 4D Labs family of embedded graphics processors GOLDELOX and PICASO are powered by a highly optimised soft core virtual engine E V E Extensible Virtual Engine EVE is a proprietary high performance virtual processor with an extensive byte code instruction set optimised to execute compiled 4DGL programs 4DGL 4D Graphics Language was specifically developed from ground up for the EVE engine core It is a high level language which is easy to learn and simple to understand yet powerful enough to tackle many embedded graphics applications ADGL is a graphics oriented language allowing rapid application development An extensive library of graphics text and file system functions and the ease of use of a language that combines the best elements and syntax structure of languages such as C Basic Pascal etc Programmers familiar with these languages will feel right at home with 4DGL It includes many familiar instructions such as IF ELSE ENDIF WHILE WEND REPEAT UNTIL GOSUB ENDSUB GOTO as well as a wealth of chip resident internal functions that
105. ERNAL 4DGL FUNCTIONS 2 6 13 gfx_Dot Syntax gfx_Dot Arguments none Returns nothing Description Draws a pixel at at the current origin using the current object colour Example gfx MoveTo 40 50 gfx ObjectColour 0xRED gfx Dot This example draws a RED pixel at 40 50 un Z T Z em TE J D S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 91 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 14 gfx_Bullet radius Syntax gfx_Bullet radius Arguments radius rad specifies the radius of the bullet The arguments can be a variable array element expression or constant Returns nothing Description Draws a circle or bullet point with radius r at at the current origin using the current object colour Note The default PEN_SIZE is set to OUTLINE however if PEN_SIZE is set to SOLID the circle will be drawn filled if PEN_SIZE is set to OUTLINE the circle will be drawn as an outline If the circle is drawn as SOLID the outline colour can be specified with gfx OutlineColour Example gfx MoveTo Opa ODE gfx Bullet 10 Draw a 10pixel radius Bullet at x 30 y 30 un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 92 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS
106. I Alphanumeric character Stat ue 1 Character is an ASCII Alphanumeric character Description Tests the character parameter and returns a 1 if the character is an ASCII Alphanumeric else returns a 0 Valid range abcd wxyz ABCD WXYZ 0123456789 Example Ree Ncc ERR un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 68 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 7 isprint char Syntax isprint char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not a printable ASCII character Status 1 Character is a printable ASCII character Description Tests the character parameter and returns a 1 if the character is a printable ASCII character else returns a O Valid range 0x20 Ox7F Example poucu Ncc ERR un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 69 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 8 isspace char Syntax isspace char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not a space type character Status 1 Character is a space type character Description Tests the character pa
107. MS PICASO INTERNAL 4DGL FUNCTIONS 2 11 Serial UART Communications Functions Summary of Functions in this section setbaud rate e com SetBaud comport baudrate 10 e serin or serin1 e serout char or serout1 char e com Init buffer buffsize qualifier or com Init buffer buffsize qualifier e com Reset or com1 Reset e com Count or com1 Count e com Full or com1 Full e com Error or com1 Error e com Sync or com1 Sync e com TXbuffer buf bufsize pin or comi TXbuffer buf bufsize pin e com TXbufferHold state e com TXcount or com1 TXcount e com TXemptyEvent function or com1 TXemptyEvent function un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 156 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 1 setbaud rate Syntax setbaud rate Arguments rate rate specifies the baud rate divisor value or pre defined constant The arguments can be a variable array element expression or constant ui Returns nothing Description Use this function to set the required baud rate The default Baud Rate for COMO is 115 200 bits per second or 115 200 baud The default Baud Rate for COM1 is 9600 bits per second or 9600 m baud g There are pre defined baud rate constants for most common baud rates u Pre Defi
108. NS 2 6 37 gfx_PolygonFilled n vx vy colour Syntax gfx_PolygonFilled n vx vy colour Arguments n vx vy colour specifies the number of elements in the x and y arrays specifying the vertices for f the polygon specifies the addresses of the storage of the array of elements for the x m coordinates of the vertices specifies the addresses of the storage of the array of elements for the y wy coordinates of the vertices colour Specifies the colour for the polygon The arguments can be a variable array element expression or constant Returns nothing Description Draws a solid Polygon between specified vertices x1 y1 x2 y2 xn yn using the specified colour The last point is drawn back to the first point completing the polygon Vertices must be minimum of 3 and can be specified in any fashion Example ver vallo vys func main vx O 10 vy 0 10 vx 1 Sop wei Be 98 vx 2 80 vy 2 10 vallal se 607 wis se 257 vx 4 80 vy 4 40 vx 5 35 vy 5 50 vx 6 10 vy 6 40 gfx PolygonFilled 7 vx vy RED un Z T Z m TE J D m 2 q Z Y TT Z repeat forever endfunc This example draws a simple filled polygon PICASO 2012 4D SYSTEMS Page 116 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 38 gfx_Origin x y Syntax gfx_Origin x y Arguments X
109. O T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 158 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Syntax serin or serin1 Arguments none Returns char char Returns 1 if no character is available Returns 2 if a framing error or over run has occurred auto cleared Returns positive value 0 to 255 for a valid character received Description serin Receives a character from the Serial Port COMO serin1 Receives a character from the Serial Port COMI The transmission format is No Parity 1 Stop Bit 8 Data Bits N 8 1 The default Baud Rate for COMO is 115 200 bits per second or 115 200 baud The default Baud Rate for COM 1 is 9600 bits per second or 9600 baud The baud rate can be changed under program control by using the setbaud function Example var char char serin test the com port atit enan gt 0 if a valid character is received process char process the character endif un Z fees T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 159 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 4 serout char Syntax serout char or serout 1char Arguments char char specifies the data byte to be sent to the serial port The arguments can be a variable array element expression or constant
110. OS angle RAND SEED number SORT number OVF e umul 1616 amp res32 val1 val2 e uadd 3232 amp res32 amp val1 amp val2 e usub 3232 amp res32 amp val1 amp val2 e ucmp 3232 amp val1 amp val2 un Z T Z m Ti J T I J q z Y TT Z 2 4 Text and String Functions e txt_MoveCursor line column e putch char putstr pointer putnum format value print to outstream charwidth char charheight char strwidth pointer strheight strlen pointer e txt Set function value txt Set shortcuts e txt FGcolour colour e txt BGcolour colour txt FontlD id PICASO 2012 4D SYSTEMS Page 9 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS e txt Width multiplier txt_Height multiplier e txt_Xgap pixelcount e txt Ygap pixelcount e txt Delay millisecs deprecated txt Opacity mode txt Bold mode txt Italic mode txt Inverse mode e txt Underlined mode e txt Attributes value e txt Wrap value 2 5 CType Functions isdigit char isxdigit char isupper char islower char isalpha char isalnum char isprint char isspace char iswhite char e toupper char tolower char LObyte var Hibyte var e ByteSwap var 2 o Graphics Functions gfx Cls gfx ChangeColour oldColour newColour e gfx Cir
111. Page 124 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 2 disp_setGRAM x1 y1 x2 y2 Syntax disp_setGRAM x1 y1 x2 y2 Arguments x1 y1 x2 y2 xi y1 Top left of the GRAM window x2 y2 Bottom right of the GRAM window Returns the LO word of the 32 bit pixel count is returned Prepares the GRAM area for user access The lower 16bits of the pixel count in the selected area is returned This is usually all that is needed unlse GRAM area exceeds 256 2 A copy of the 32bit value can be found in GRAM PIXEL COUNT LO and GRAM PIXEL COUNT HI Description un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 125 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 3 disp_WrGRAM colour Syntax disp_WrGRAM colour Arguments colour colour Pixel color to be populated Returns nothing Data can be written to the GRAM consecutively using this function once the GRAM access Description i P window has been setup un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 126 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 4 disp_WriteControl value Syntax disp_WriteControl value Arguments value value Specifies the 16 bit value to b
112. Page 215 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 15 file Image x y handle Syntax file Image x y handle Arguments x y handle x X position of the image to be displayed y Y position of the image to be displayed handle The handle that references the file containing the image s Returns Returns a copy of the file_Error error code Description Display an image from the file stream at screen location specified by x y top left corner If there is more than 1 image in the file it can be accessed with file Seek Example file Tmege lz yy handle gt un Z T Z zm TE J D T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 216 of 317 www 4dsystems com au un Z T Z m TE J D m T E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 16 file_ScreenCapture x y width height handle Syntax file_ScreenCapture x y width height handle Arguments x y width height handle X X position of the image to be captured y Y position of the image to be captured width Width of the area to be captured height Height of the area to be captured handle The handle that references the file to store the image s Returns Status Status Returns 0 if function successful Description Save an image of the
113. PutWord ptr val Arguments Ptr val ptr byte pointer val value to store Returns None Description Put a word value into a byte buffer at ptr similar to POKEW in basic It is not necessary for byte pointer ptr to be word aligned Example var p string pointer var numbers 10 array for 20 bytes func main p str Ptr numbers raise a string pointer str PutWord p 3 100 poke the array with some numbers str PutWord p 9 200 str PutWord p 12 400 print etr ESSERE BENED E fii ges the array print str GetWord p 9 An prine Site Cemoro x 12 Wa endfunc un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 257 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 10 str_Match amp ptr str Syntax str_Match amp ptr str Arguments ptr str ptr Address of byte pointer to string buffer str Pointer string to match Returns Value Returns 0 if no match else advance ptr to the next position after the match Val ame and returns that value Description Case Sensitive match Compares the string at position ptr in a string buffer to the string str skipping over any leading spaces if required If a match occurs ptr is advanced to the first position past the match else ptr is not altered NB The add
114. S button texts C DATA WOLC IOMEEOMEEIES ESE S2 ists SE lume byte tstl TEST1 0 ioa Oh A In CHO byte tst3 TEST3 0 byte tested qna Ww byte btnexit V0 END ssssss sess sss sss sss ss SS SS SS SS SS SSS SS SSS SS SSS In the main function we establish a simple window and activate it From then on it is a simple matter of polling the window and acting on the number message it returns This greatly simplifies the application as all touch testing is handled by the window itself func main var Wmsg message from window gfx Cls txt Set FONT ID FONT3 print Memory available mem Heap n show biggest chunk we have set some window properties 2012 4D SYSTEMS Page 305 of 317 www 4dsustems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS aWindow title A Test Window aWindow xpos 10 aWindow ypos 60 aWindow font FONT2 aWindow INITIALIZE draw window buttons for the first time pause 500 aWindow statusbartext init Drive mount the disk setting status msg aWindow REDRAW STATUS update the status bar now just stay in a loop getting info from window repeat u Wmsg aWindow SCAN scan for any changes za if return value non zero its a button number Q if Wmsg Lnd switch LJ jf fess a SSS Sa sa inicia Sa Ss a a Se Se 2 would normall do some exit action here Ss but for demo we just r
115. S 2 5 12 Hilbyte var Syntax Hibyte var Arguments var var User variable Returns byte byte Returns the upper byte upper 8 bits of a 16 bit variable Description Returns the upper byte upper 8 bits of a 16 bit variable Example myvar HIbyte myvar2 un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 74 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 13 ByteSwap var Syntax ByteSwap var Arguments var var User variable Returns Status Status Returns the endian swapped value of a 16 bit variable Description Returns the swapped upper and lower bytes of a 16 bit variable Example myvar ByteSwap myvar2 un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 75 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 Graphics Functions Summary of Functions in this section e gfx Cls e gfx ChangeColour oldColour newColour e gfx Circle x y radius colour e gfx CircleFilled x y radius colour e gfx Line x1 y1 x2 y2 colour e gfx Hline y x1 x2 colour e gfx Vline x y1 y2 colour e gfx Rectangle x1 y1 x2 y2 colour e gfx RectangleFilled x1 y1 x2 y2 colour e gfx Polyline n vx vy colour e gfx Polygo
116. SIZE is set to OUTLINE however if PEN SIZE is set to SOLID the circle will be drawn filled if PEN SIZE is set to OUTLINE the circle will be drawn as an outline If the circle is drawn as SOLID the outline colour can be specified with gfx OutlineColour If OUTLINE COLOUR is set to O no outline is drawn Example assuming PEN SIZE is OUTLINE gfx Circle 50 50 30 RED This example draws a BLUE circle outline centred at x 50 y 50 with a radius of 30 pixel units un Z fees T c zm TE J D T Sj lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 80 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 4 gfx_CircleFilled x y radius colour Syntax gfx_CircleFilled x y rad colour Arguments x y rad colour xX y specifies the center of the circle rad specifies the radius of the circle colour specifies the fill colour of the circle The arguments can be a variable array element expression or constant Returns nothing Description Draws a SOLID circle with centre point x1 y1 with radius using the specified colour The outline colour can be specified with gfx OutlineColour f OUTLINE COLOUR is set to O no outline is drawn NB The PEN SIZE is ignored the circle is always drawn SOLID Example if state TOUCH RELEASED if there s a release gfx CircleFilled x y 10 RED we ll draw a sol
117. SO 2012 4D SYSTEMS Page 168 of 317 www 4dsystems com au Wn z U Z Ti a O D T J lt x Z Y T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 12 com_TXbufferHold state Syntax com_TXbufferHold state or com1_TXbufferHold state Arguments state state Specifies the state of the buffer used for the buffering service The arguments can be a variable array element expression or constant Returns count Returns buffer count when called with argument of 1 for example count com_TXbufferHold ON Returns 0 when argument is zero eg com TXbufferHold OFF Description This function is used in conjunction with com TXbuffer It is often necessary to hold off sending serial characters until a complete frame or packet has been built in the output buffer com TXbufferHold ON is used for this to stop the buffer being sent while it is being loaded Normally when using buffered comms the transmit process will begin immediately This is fine unless you are trying to assemble a packet To build a packet and send it later issue a com TXbufferHold ON build the packet when packet is ready issuing com TXbufferHold OFF will release the buffer to the com port Also if using com TXemptyEvent erroneous empty events will occur as the transmit buffer is constantly trying to empty while you are busy trying to fill it Also refer to the pin cont
118. SO INTERNAL 4DGL FUNCTIONS e gfx Contrast value e gfx LinePattern pattern e gfx ColourMode mode e gfx BevelWidth mode e gfx BevelShadow value e gfx Xorigin offset e gfx Yorigin offset un Z I T c TE J T n T J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 77 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 1 gfx_Cls Syntax gfx_Cls Arguments none Returns nothing Clear the screen using the current background colour gfx_Cls command brings some of the settings back to default such as e Transparency turned OFF e Outline colour set to BLACK e Opacity set to OPAQUE e Pen set to OUTLINE e Line patterns set to OFF e Right text margin set to full width e Text magnifications set to 1 e All origins set to 0 0 Description The alternative to maintain settings and clear screen is to draw a filled rectangle with the required background colour Example gfx BGcolour DARKGRAY gfx Cls This example clears the entire display using colour DARKGRAY un Z I T Z em TE J D T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 78 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 2 gfx_ChangeColour oldColour newColour Syntax gfx_ChangeColour oldColour newColour Arguments oldColour newColour oldColour specifies the sample colour
119. ST 100khz 400khz 1mhz The arguments can be a variable array element expression or constant Returns None Description Calling this function configures the I2C module and initialises it to be ready for service The 12C clock speed is specified by the speed parameter Three I2C Speed settings are available to suit various requirements Constant Speed I2C SLOW 100khz I2C MED 400khz I2C FAST 1mhz Example I2C Open I2C MED Open the I2C port in 400KHz mode un Z T Z TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 174 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 2 I2C Close Syntax I2C Close Arguments None Returns None Description Calling this function closes the I2C port and disables the I2C hardware Example I2C Close Close I2C port and Disable the hardware un Z T Z TE J D I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 175 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 3 I2C Start Syntax I2C Start Arguments None Returns None Description Calling this function sends an I2C start condition The hardware first pulls the SDA data line low and next pulls the SCL clock line low SCL A SDA A Example T20 StartUp Sem su T2C start
120. Status Remaining time units when touch screen is touched else returns zero Description Put the display and processor into low power mode for a period of time If units is zero the display goes into sleep mode forever and needs power cycling to re initialize If units is 1 to 65535 the display will sleep for that period of time or will be woken when touch screen is touched The function returns the count of units that are remaining when the screen was touced When returning from sleep mode the display and processor are restored from low power mode Note Sys Sleep was found to have an issue in PmmC s prior to R33 the units value was not always near 1 second This has been corrected in PmmC R33 Example sys Sleep 60 Sleep for 1 minute Wn z O U z TE Bj D e J q Z a T Z PICASO 2012 4D SYSTEMS Page 199 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 10 iterator offset Syntax iterator_ offset Arguments __ offset offset Offset size for the next or command The arguments can be a variable array element expression or constant Returns None Description Setsthe iterator size for the next postinc postdec preinc or predec by a specified value The offset will return to 1 after the next operation Example i ge iterator d0 g un Z j T Z zm TE J D
121. T Z PICASO 2012 4D SYSTEMS Page 213 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 13 file_Write source size handle Syntax file_Write source size handle Arguments source size handle source Source memory buffer size Number of bytes to be written handle The handle that references the file to write Returns count count Returns the number of bytes written Description Writes the number of bytes specified by size from the source buffer into the file referenced by handle Example res file Write memblock 20 hndl1 un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 214 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 14 file_Size handle amp HiWord amp LoWord Syntax file_Size handle amp HiWord amp LoWord Arguments handle HiWord LoWord handle The handle that references the file HiWord Contains the upper 16bits of the file size LoWord Contains the lower 16bits of the file size Returns Status Status Returns TRUE if ok usually ignored Description Reads the 32 bit file size and stores it into 2 variables Example Ie NEL file Size Noure She ten un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS
122. Y TT Z PICASO 2012 4D SYSTEMS Page 246 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 7 snd_Playing Syntax snd Playing Arguments None Returns value value Number of 512 byte blocks to go Description Returns O if sound has finished playing else return number of 512 byte blocks to go This function is for control of a wav buffer see the file PlayWAV function Example count snd Playing un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 247 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 String Class Functions Summary of Functions in this section str_Ptr amp var e str GetD amp ptr amp var e str GetW amp ptr amp var e str GetHexW amp ptr amp var e str GetC amp ptr amp var e str GetByte ptr e str GetWord ptr e str PutByte ptr val e str PutWord ptr val e str Match amp ptr str e str Matchl amp ptr str e str Find amp ptr str e str Findl amp ptr str e str Length ptr e str Printf amp ptr format e str Cat amp destination amp Source e str CatN amp ptr str count e str String char count e str ByteMove src dest count e str Copy dest src e str CopyN dest src count un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D
123. a file that has been opened in r read or a append mode In append mode file Index does not expand a filesize instead the file pointer handle is set to the end position of the file eg assuming the record size is 100 bytes file Index handle O 100 22 will set the file position to 2200 for the file handle so subsequent data may be read from that position onwards with file GetC file GetW file GetS or an image can be displayed with file Image Conversely file PutC file PutW and file PutS can write to the file at the position A FE EOF end of file error will occur if you try to write or read past the end of the file Example res file Index hSource 0 100 22 2012 4D SYSTEMS Page 21e of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 12 file_Tell handle amp HiWord amp LoWord Syntax file_Tell handle amp HiWord amp LoWord Arguments handle amp HiWord amp LoWord handle The handle that references the file HiWord Contains the upper 16bits of the memory pointer into the file LoWord Contains the lower 16bits of the memory pointer into the file Returns Status Status Returns TRUE if ok usually ignored Description Returns the current value of the file pointer Example res file Tell hSource amp HIptr amp LOptr Wn z O E z D Ti Bj D e J q Z a
124. aese spento teh se ofa erae eR cobbareacctandonedboteass 257 2 16 10 str Match amp ptr St rete Det RO HER AR caveaa dese a HE 258 2 16 11 str Matchl amp ptr str ener aee rera Or ERR aa ea na GUERENEN GE IA NN Rar Pass 259 2 16 12 str Find amp ptr str reae ertet ue rn ka ee care kv o Rr Fed da vau Eo YE Eae DR ee BAR ECT Re RED 260 2 16 13 str Findl amp ptt TSi iecit ce rite iren te acre ario tane Ee vane Ee kc Rank oe rov EE aa EO i ii 261 2 16 14 str Length DEN soeben e eere E nmn sab ir aaa a Ei a Eiee a iaa dene ERE EE ERE 262 2 16 15 str Printf amp ptr format cccccccssccssecesscecssecseeeecseceeeeecsecseeeecsaeeseseecseesseseeceaeeseseesseeeseneesed 263 2 16 16 str Cat amp destination amp source ssseseseseeseeeeeeenenee enne nnne nnn enne enne nnn enn 265 2 16 17 str CatN amp ptr str count icersinde enne nennen nennen nennen senes nennen aaiae aa 266 2 16 18 str ByteMove src dest count eene nennen enne nennen enne nn seen serena 267 2 16 19 str Copy dest SiC acusen pono rte rat e EX E A FRE e co Ee Roe Eu Ye PREFERTUR REY TO 268 2 16 20 str CopyN dest src count essen eene nnne nennen nenne nnne enne ne nennen nennen 269 2 17 TOUGH Screen FUNCIONS 2 22 pep Fe eS R re qu c tee aa aexe eene ken eh ee he eRo ches An ekasa xe CU nV ERE E EU Ras Ru o SE FEN ERE RRATR 270 2 17 1 touch DetectRegion x1 y1 x2 y2 c cccscccescccsecseseecssecesececseecseeeeceaeeeeeeecseesseeeec
125. anel state x y Width Height Colour Syntax gfx_Panel state x y Width Height Colour Arguments state x y buttonColour txtColour font txtWidth txtHeight text state 0 recessed 1 raised X y Specifies the top left corner position of the panel on the screen Width specifies the width of the panel Height Specifies the Height of the panel Colour Specifies the colour of the panel Returns nothing Description Draws a 3 dimensional rectangular panel at a screen location defined by x y parameters top left corner The size of the panel is set with the width and height parameters The colour is defined by colour The state parameter determines the appearance of the panel 0 recessed 1 raised Example constant LEFT 15 constant TOP 15 constant WIDTH 100 constant HEIGHT 100 func main Draw a panel gfx Panel RAISED LEFT TOP WIDTH HEIGHT GRAY repeat forever un Z fees T c zm TE J D T 2 q Z Y TT Z endfunc PICASO 2012 4D SYSTEMS Page 109 of 317 www 4dsystems com au un Z T Z m Ti J T I J q z Y TT Z PICASO 4D SYSTEMS 2 6 31 gfx Sli PICASO INTERNAL 4DGL FUNCTIONS der mode x1 y1 x2 y2 colour scale value Syntax gfx_Slider mode x1 y1 x2 y2 colour scale value Arguments mode x1
126. appended it is purely a byte copy and any zeroes encountered will also be copied Example var src dest mybuf1 10 mybuf2 10 string pointers and two 20 byte buffers to mybuf1 putstr TESTING 123 src strPtr mybuf1 dest str_Ptr mybuf2 src 6 move src pointer to G 123 str ByteMove src dest 6 move to second buffer including the zero terminator putstr mybuf2 print result nextpos str ByteMove s d 100 un Z fees T c zm TE J D T Sj lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 267 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 19 str_Copy dest src Syntax str Copy dest src Arguments dest src dest points to byte aligned destination Src points to byte aligned source Returns Pointer Pointer Returns a pointer to the 0x00 string terminator at the end of dest which is dest str Length sro Description Copy a string from src to dest stopping only when the end of source string src is encountered 0x00 terminator The terminator is always appended even if src is an empty string Example nextplace str Copy d s un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 268 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 20 str CopyN
127. ar buffer 100 200 character buffer for a source string var p q string pointers var mny func main EO bUEFer print Umas Sun cases in the Hast rU String tO Parse p str Ptr buffer string pointer to be used I wiwa serine OD ee IS un Z T c zm TE J T n 2 q Z Y TT Z q p if n str Match amp p the Will find the first The Sic Pointi to Yesa Jy print remainder of string else peime Umwexe ifexuelym g OQ endif Uu print startpos q Mnfindpos n Mnendpos p q endfunc L 2012 4D SYSTEMS Page 259 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 12 str_Find amp ptr str Syntax str_Find amp ptr str Arguments ptr str ptr Byte pointer to string buffer str String to find Returns Value Returns 0 if not found Val ne ere ane Returns the position of the find if successful Description Case Sensitive Searches for string str in string buffer pointed to by ptr NB The pointer ptr is not altered Example var buffer 100 200 character buffer for a source string var p string pointer var n var strings 4 for our test strings func main txt Set FONT ID FONT2 strings 0 useful strings 1 string Sering si Dn E RA strings 3 class to buffer print and by the way the string clas
128. arent to access child globals when using file_LoadFunction Sec 2 14 25 updated Example added Applies to PmmC R31 and above 2 sys_SetTimerEvent timernum function description added Sec 2 13 5 3 Sec 2 11 12 com_TXbufferHold state added 4 Sec 2 11 13 com_TXcount Returns part fixed 5 com_TXemptyEvent description updated com_TXemptyEvent Function is changed to com_TXemptyEvent FunctionAddress Added a better example in Sec 2 11 14 6 2 Fixed minor issues in the wording and return types of some functions 17 12 2012 File_ScreenCapture Typo in x and y description Gfx Origin Incorrect description Mem Free Return was incorrect Gfx Get Some modes were not listed these have been added File Image Return was incorrect Media Flush Return was incorrect Sys Sleep Note added File Exists Removed wildcard support description this was not supported File Run File Exec Status should be Value otherwise OK PutW putC Return was incorrect SetBaud Some Errors listed in the SetBaud table were incorrect Updated 6 3 Fixes to str Length example 12 01 2013 Fixes to typo in mem AllocV name and description of size type and return improved Fixes to mem Alloc size type and return improved Addition to type of Size in mem Set command and addition on an example Fixes to sys SetTimerEvent example fix of typo Improvements made to img SetWord and img GetWord constant listings
129. button state and update the touch detect matrix array n 0 repeat if the button state has changed if vButtonState n vOldButtonState n vOldButtonState n vButtonState n if we already have all the co ordinates use them if mode xdi 8e eulos in p yl touchYl n x2 touchX2 n y2 touchY2 n endif draw the button gfx Button vButtonState n Xx yl btnBtnColor btnTextColor font 1 1 buttontexts n update the touch screen regions only during first build if mode 2012 4D SYSTEMS Page 229 of 317 www 4dsystems com au un Z T Z m Ti J T J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS X2 gfx Get RIGHT POS I NEL eB OTR OME OS i touch as alls S C touchYl n yl coucha ml se x27 touchY2 n y2 calculate next button position mL 8e ar xap if xl gt xorg maxwidth xl xorg yl y2 ygap endif endif endif until n gt buttoncount endfunc assess sss ss SS SS SSS SS SSS SSS SSS SS SSS SSS do something with the key data In this example we reconstitute the button name to a file name by appending 4XE and then call the file Run command to run an application func sendkey var p p buttontexts keyval 1 to tempstr str Printf amp p s 4XE txt Set TEXT OPACITY OPAQUE Ex SES ZONT SED FONT4 txt MoveCursor 3 0
130. cation putch n newline un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 46 of 317 www 4dsystems com au Wn z z Ti J O m T J lt x Z Y T Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 3 putstr pointer Syntax putstr pointer Arguments pointer pointer A string constant or pointer to a string The argument can be a string constant or pointer to a string a pointer to an array or a pointer to a data statement Returns source source Returns the pointer to the item that was printed Description putstr prints a string to the current output stream usually the display The argument can be a string constant a pointer to a string a pointer to an array or a pointer to a data statement Note putstr is more efficient than print for printing single strings The output of putstr can be redirected to the communications port the media or memory using the to function A string constant is automatically terminated with a zero A string in a data statement is not automatically terminated with a zero All variables in 4DGL are 16bit if an array is used for holding 8 bit characters each array element packs 1 or 2 characters Example SSS EE E E E E E E EE ETE E EH RESET A EB EORR ES EE EE ESI Example 1 print a string constant assess 3
131. cation regarding device applications and the like is provided only for your convenience and may be superseded by updates It is your responsibility to ensure that your application meets with your specifications In no event shall 4D Systems be liable to the buyer or to any third party for any indirect incidental special consequential punitive or exemplary damages including without limitation lost profits lost savings or loss of business opportunity arising out of or relating to any product or service provided or to be provided by 4D Systems or the use or inability to use the same even if 4D Systems has been advised of the possibility of such damages 4D Systems products are not fault tolerant nor designed manufactured or intended for use or resale as on line control equipment in hazardous environments requiring fail safe performance such as in the operation of nuclear facilities aircraft navigation or communication systems air traffic control direct life support machines or weapons systems in which the failure of the product could lead directly to death personal injury or severe physical or environmental damage High Risk Activities 4D Systems and its suppliers specifically disclaim any expressed or implied warranty of fitness for High Risk Activities Use of 4D Systems products and devices in High Risk Activities and in any other application is entirely at the buyer s risk and the buyer agrees to defend indemnify and h
132. ce string var p string pointer var n var vars 6 for our results func main to buffer print 100000 200000 98765432 abacus p str Ptr buffer raise a string pointer so we can use the string functions while str GetD amp p amp vars n 0 n n42 read all the numbers till we get a non number mennel SE weuss s SA versio wa g show the longs as hex numbers ioxesueuE PRA varsis s LEa wweus 2 Wa g print HEX4 vars 5 HEX4 vars 4 n endfunc un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 250 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 3 str_GetW amp ptr amp var Syntax str_GetW amp ptr amp var Arguments amp ptr amp var ptr byte pointer to string var destination for our result Returns Status Status Returns TRUE if function succeeds advancing ptr Description Convert number in a string to WORD myvar NB The address of the pointer must be passed so the function can advance it if required Example var buffer 100 200 character buffer for a source string var p string pointer var n var vars 3 for our results func main to buffer print 0x1234 0b10011001 12345 abacus p str Ptr buffer raise a string pointer so we can use the string functions wailelstr eee l
133. ckAddress Arguments blockAddress blockAddress The address of the 64k FLASH block to be erased Returns result result Erases the required block in a FLASH media device The function returns no value and the operation can take up to 3 milliseconds Description If a FLASH storage device is connected to the SPI port and has been correctly initialised with the spi Init function the FLASH block can be erased using this function The only devices supported so far on the PICASO GFX2 are the M25Pxx range of devices which are 512Kbit to 32Mbit 2M x 8 Serial Flash Memory E g there are 32 x 64K blocks on a 2Mb flash device un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 150 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 10 SPI Control Functions The SPI functions in this section apply to any general purpose SPI device Summary of Functions in this section e spi Init speed input mode output mode e spi Read e spi Write byte e spi Disable un Z T Z TE J D QO S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 151 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 10 1 spi_Init speed input_mode output_mode Syntax spi Init speed input mode output mode Arguments speed input mode output mode speed Sets the speed o
134. cle x y radius colour e gfx CircleFilled x y radius colour e gfx Line x1 y1 x2 y2 colour gfx Hline y x1 x2 colour gfx Vline x y1 y2 colour gfx Rectangle x1 y1 x2 y2 colour gfx RectangleFilled x1 y1 x2 y2 colour e gfx Polyline n vx vy colour gfx Polygon n vx vy colour e gfx Triangle x1 y1 x2 y2 x3 y3 colour gfx Dot e gfx Bullet radius gfx Orbitlnit amp x dest amp y dest gfx Orbit angle distance e gfx PutPixel x y colour e gfx GetPixel x y gfx MoveTo xpos ypos e gfx MoveRel xoffset yoffset e gfx IncX e gfx IncY gfx LineTo xpos ypos gfx LineRel xpos ypos T Z V c m Ti J T T J q z Y TT Z PICASO 2012 4D SYSTEMS Page 10 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS e gfx BoxTo G2 y2 gfx SetClipRegion e gfx Ellipse x y xrad yrad colour gfx EllipseFilled x y xrad yrad colour e gfx Button state x y buttonColour textColour font textWidth textHeight text e gfx Panel state x y width height colour gfx Slider mode x1 y1 x2 y2 colour scale value e gfx ScreenCopyPaste xs ys xd yd width height gfx RGBto565 RED GREEN BLUE gfx 332to565 COLOURBBIT e gfx Selection index backcolor textcolor gfx TriangleFilled x1 y1 x2 y2 x3 y3 colr gfx PolygonFilled n amp vx amp vy colr
135. d OFF Il release T buffer print TXBuffer is holding n chars n show how many characters were in the buffer watch the buffer empty repeat prime TWX count Dese m j com Mxcoumie h Ne 5 i watch the count as the buffer empties until n print n nTX Empty com TXbuffer 0 0 IO1_PIN done with the buffer release it sys SetTimer TIMERO 3000 pause for 3 seconds non blocking while peekW TMRO forever do it forever com TXbuffer 0 0 0 if done with the pin must release it endfunc 2012 4D SYSTEMS Page 172 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 12C BUS Master Functions Summary of Functions in this section e func 12C_Open Speed e func I2C_Close e funciI2C Start e funcl2C Stop e funcI2C Restart e funcli2C Read e funcl2C Write byte e funcl2C Ack e funcl2C Nack e funcl2C AcksStatus e funcli2C AckPoll control e funciI2C Idle e func I12C_Gets buffer size e funcl2C Getn buffer size e func I12C_Puts buffer e func 12C_Putn buffer count un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 173 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 1 12C_Open Speed Syntax I2C Open Speed Arguments Speed Speed Specifies the I2C bus speed Speed can be I2C SLOW I2C MED I2C FA
136. d by word to the file at the position indicated by the associated file position pointer and advances the pointer appropriately incremented by 2 The file must be previously opened with w write or a append modes Example file PutW 0x1234 hndl 2012 4D SYSTEMS Page 220 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 20 file_GetW handle Syntax file_GetW handle Arguments handle handle The handle that references the file Returns Word Word Returns word sized data read from the file Description This function reads a word 2 bytes from the file at the position indicated by the associated file position pointer and advances the pointer appropriately incremented by 2 The file must be previously opened with r read mode Example myword file GetW hndl un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 221 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 21 file_PutS source handle Syntax file_PutS source handle Arguments source handle source A pointer to the string to be written handle The handle that references the file to be written to Returns count count Returns the number of characters written excluding the null terminator Description This function writes an
137. dByte l irn eee lene rere Rehd b ee eR Yu MERE ca ENTE ERES FERAE RHA Xr RR raga YR EM AREE RR ERR RR 137 2 8 7 media REAAW OF PET neniani i a iE 138 2 8 8 media WriteByte byte val eene enne enne nennen nennen innen enne 139 2 8 9 media_WriteWord WoOrd_Val ceccescessceseeeeeeeeeeeeeceseceeeceaeceaeceaecaaecaeecaeeeaeseeeseeeeerseeeseeeeaeeeaes 140 2 8 10 Media Flush ciaee norena ee iai Pes annt det Pe eR Pee PUn cete s EYE EE vs ee EE 141 2 8 11 media Image x y trea eR Ede Rub Ee ERR ERE RNE Re RE aa ERE HERE Ma ERE EM RE REESE ERE TR RES HER KR RR 142 2 8 12 media Video x y ui iine ntr rh reete e Reano d Feb ya RR REDE ERE DERE RE e ERAN R S ERR akana eataa aaia 143 2 8 13 media VideoFrame x y frameNumber sese enne nnne en 144 2 9 Flash Memory Chip Functions cerro ceto eue perta rb ee kno au EE ce Fa aeaii Dare Erka oika Tan Ei 146 SE NE TE UBUNTU 147 2 9 2 flash ID emeret re reservas ders este vadat eese tanken tie waasstacotieesactesssiesies ee OE 148 29 3 flash BulkEtrasel cicer ene race ttn dde Ert eene terree dessdbed en reves ace Uk eu To ugue PL Yaa e dea ane A 149 2 9 4 flash_BlockErase blIOCKACCress ccccescssssecssscssscecsseceseeecsaeesseeecaeeseseeceeeeseeeecaeeseeeeceeeeeeaeese 150 2 10 SPI Control FUNCOMS ec oi rore eer notes etu pee Eee ue e ees EEEE EE HERR NR REN ERR Moe ER eu RN ERR en 151 2 10 1 spi Init speed input mode output mode sess 152 21
138. doesn t require any 4DGL coding at all it is all done automatically for you Simply lay the display out with the objects you want set the events to drive them and the code is written for you automatically ViSi Genie provides the latest rapid development experience from 4D Systems e A Serial environment is also provided to transform the processor into a slave serial processor allowing the user to control the display from any host microcontroller or device with a serial port The Workshop 4 IDE is available from the 4D Systems website www 4dsystems com au For a comprehensive manual on the Workshop 4 IDE Software refer to its documentation from the 4D Systems website Workshop 4 IDE User Manual pdf 7 1 Workshop 4 Designer Environment Choose the Designer environment to write 4DGL code in its raw form The Designer environment provides the user with a simple yet effective programming environment where pure 4DGL code can be written compiled and downloaded to the PICASO Processor www 4dsystems com au WN c O Z m LL J Z tV UJ Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 7 2 Workshop 4 ViSi Environment ViSi was designed to make the creation of graphical displays a more visual experience ViSi is a great software tool that allows the user to see the instant results of their desired graphical layout Additionally there is a selection
139. dug Ceann Walia mo wero p pe str Ptr c vaise a string pointer so we can use the string functions print a length str Length pa n show length of the dynamic buffer print b length str Length b n show length of the static string print c length str Length pc n show length of the re directed string mem Free a test is over free up the memory repeat forever endfunc PICASO 2012 4D SYSTEMS Page 262 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 15 str_Printf amp ptr format Syntax str_Printf amp ptr format Arguments Ptr format ptr Byte pointer to the input data structure format Format string Note The address of the pointer must be passed so the function can advance it as required Note The format specifier string can be a string pointer allowing dynamic construction of the printing format Format Specifiers c character 96s string of characters 96d signed decimal ld long decimal u unsigned decimal lu long unsigned decimal 96x hex byte X hex word IX hex long b binary word lb long binary word indirection prefix placed after to specify indirect addressing number width description use between and format specifier to set the field width Note If number is preceded by O the result is Left pads with zeroes 0 instead Wn z
140. e aoe 7 count all the executable files on the drive print 4XE File count buttoncount n n buttoncount k holds entry count if n print No 4XE executables Nin critical error nothing to run repeat forever endif filenames mem AllocZ n 13 allocate a buffer for the filenames if filenames print Out of memory n critical error could not allocate buffer repeat forever endif to filenames file Dir 4xe load the filenames array p str Ptr filenames Vi poine to the string assign array of string pointers and truncate filename extensions n 0 while n buttoncount buttontexts nt p save pointer to the string p str Find sp p find end of required string str PutByte p N0 change to 0 D a p E TESI over LAPSEINTI wend touch Set TOUCH ENABLE enable the touch screen 2012 4D SYSTEMS Page 231 of 317 www 4dsystems com au un Z T Z m Ti J T m I J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS redraw buttoncount f 10 80 w 1 draw buttons for the first time now just stay in a loop repeat State touch Get TOUCH STATUS get touchscreen status x touch Get TOUCH GETX Vicia HEOUCHEGCE OUCH RSV if state TOUCH PRESSED if there s a press if keyval readKeys x y vButtonState keyval 1 DOWN put bu
141. e 195 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 6 sys _EventQueue Syntax sys_EventQueue Arguments None Returns Count Count Returns number of events Description returns the max number of events that were pending in the timer queue since the last call to this function This can be used to assess timer event overhead burden especially after or during a sys EventsPostpone action Example tasks sys EventQueue un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 196 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 13 7 sys_EventsPostpone Syntax sys_EventsPostpone Arguments None Returns None Description Postpone any events until the sys EventResume function is executed The timer event queue will continue to queue events but no action will take place until a sys_EventResume function is encountered The queue will continue to receive up to 32 events before discarding any further events This function is required to allow a sequence of instructions or functions to occur that would otherwise be corrupted by an event occurring during the sequence of instructions or functions A good example of this is when you set a position to print if there was no way of locking the current sequence an event may occur which does a similar
142. e 4XE name of the 4DGL application program that is about to be loaded into RAM Returns Pointer Returns a pointer to the memory allocation where the function has been Pointer s loaded from file which can be then used as a function call Description Load a function or program from disk and return a function pointer to the allocation The function can then be invoked just like any other function would be called via a function pointer Parameters may be passed to it in a conventional way The function may be discarded at any time when no longer required thus freeing its memory resources The loaded function can be discarded with mem Free Note that any pointer references passed to the child function may not include references to the parents DATA statements or any static string references Any string or array information must be in the parents global or local memory space The reason for this is that DATA statements and static strincs are contained in the parents CODE segment and cannot be accessed by the child process Note PmmC Rev 31 and above has an added feature where a parent can access the child global Variables when using file LoadFunction fname 4XE Example1 var titlestring 20 var textstring 20 to titlestring putstr My Window Title to textstring putstr My Special Message popupWindow file LoadFunction popupWindowl 4fn if popupWindow goto LoadFunctionFailed could no
143. e Specifies the number of bytes that s allocated from the heap Returns Value Returned value is the pointer to the allocation if successful If function fails Val THE returns a null 0 Description Allocate a block of memory to pointer myvar The block of memory is filled with zeros The block must later be released with mem Free myvar Example myvar mem Allocz 100 un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 290 of 317 www 4dsystems com au un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 4D SYSTEMS 2 19 4 mem PICASO INTERNAL 4DGL FUNCTIONS Realloc amp ptr size Syntax mem_Realloc amp ptr size Arguments ptr size ptr specifies the new location to reallocate the memory block size specifies the number of bytes of the block Returns Status Status See the Description Description The function may move the memory block to a new location in which case the new location is returned The content of the memory block is preserved up to the lesser of the new and old sizes even if the block is moved If the new size is larger the value of the newly allocated portion is indeterminate In case that ptr is NULL the function behaves exactly as mem_Alloc assigning a new block of size bytes and returning a pointer to the beginning
144. e address 5120 for subsequent operations un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 134 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 4 media_RdSector Destination_Address Syntax media_RdSector Destination_Address Arguments Destination_Address Destination Address Destination block pointed to by the internal Sector pointer The argument must be a pointer to an array of size 256 words for the sector data which will be 512 bytes Returns TRUE if media response was TRUE Returns ae Returns 512 bytes 256 words in to a destination block Reads and Returns 512 bytes 256 words into a destination block eg rdblock 256 pointed to Description by the internal Sector pointer After the read the Sector pointer is automatically incremented by 1 Example var rdblock 256 media SetSector 0 10 if media RdSector rdblock Print Data collected endif This example sets a 512 bytes block and collects data from the address pointed to by media SetSector command un Z T Z zm TE J D QO J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 135 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 5 media_WrSector Source_Address Syntax media_WrSector Source_Address Arguments Source Address Source Add
145. e attribute is altered in ALL of the entries in the image list The constant ALL is set to 1 specifically for this purpose Returns Status Status TRUE or FALSE Description Clear various image attribute flags in a image control entry see image attribute flags below Image attribute flags may be combined with the or operators eg img ClearAttributes hndl ALL Y LOCK 1 X LOCK allow all images to move in any direction This function requires that an image control has been created with the file LoadlmageControl function Returns TRUE if index was ok and function was successful the return value is usually ignored Image attribute flags ENABLED 0x8000 bit 15 set for image enabled DARKEN 0x4000 bit 14 display dimmed LIGHTEN 0x2000 bit 13 display bright TOUCHED 0x1000 bit 12 touch test result Y LOCK 0x0800 bit 11 stop Y movement X LOCK 0x0400 bit 10 stop X movement TOPMOST 0x0200 bit 9 draw on top of other images next update STAYONTOP 0x0100 bit 8 draw on top of other images always Example img ClearAttributes hndl 5 value 2012 4D SYSTEMS Page 285 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 11 img_Touched handle index Syntax img_Touched handle index Arguments handle index handle Pointer to the Image List index Index of the images in the list Returns Status Status Returns index or 1
146. e control entry see image attribute flags A 1 bit in the value field SETS the respective bit in the IMAGE FLAGS field of the image control entry ENABLED 0x8000 bit 15 set for image enabled DARKEN 0x4000 bit 14 display dimmed LIGHTEN 0x2000 bit 13 display bright TOUCHED 0x1000 bit 12 touch test result Y LOCK 0x0800 bit 11 stop Y movement X LOCK 0x0400 bit 10 stop X movement TOPMOST 0x0200 bit 9 draw on top of other images next update STAYONTOP 0x0100 bit8 draw on top of other images always img ClearAttributes handle index value Example un Z T Z m TE J D m J q Z Y TT Z img Enable Ihndl SPRITE CAT we ll also use small cat video img SetAttributes Ihndl SPRITE CAT I NOGROUP img SetPosition Ihndl SPRITE CAT 160 180 set its position PICASO 2012 4D SYSTEMS Page 284 of 317 www 4dsystems com au Wn Z U Z m TE J O D x lt x Z a T e PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 10 img_ClearAttributes handle index value Syntax img_ClearAttributes handle index value Arguments handle index value handle Pointer to the Image List index Index of the images in the list value a 1 bit indicates that a bit should be set and a 0 bit indicates that a bit is not altered Note if index is set to 1 th
147. e of the string to be read Returns Count Count Returns the count of bytes actually read Description Reads up to size characters into buffer from an ascii string stored in a device Reads up to the ASCII NULL terminator and includes the terminator Example c I2C Gets buf size read a string from the I2C Bus to buffer up to size characters un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 186 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 14 I2C Getn Syntax I2C Getn buffer count Arguments buffer count buffer Storage for the bytes being read from the device count Number of bytes to be read The arguments can be a variable array element expression or constant Returns Status Status Returns True if block read ok else returns False Description Reads count bytes in to buffer and returns True if function succeeds Example 12C Getn buffer count read I2C count bytes from the I2C Bus to the buffer un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 187 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 15 12C_Puts buffer Syntax I2C Puts buffer Arguments X buffer buffer Storage for the string being written to the device
148. e written to the display control register The arguments can be a variable array element expression or constant Returns nothing Sends a 16 bit value to the display bus Refer to individual data sheets for the display for more Description information This function is used to extend the capabilities of the user code to gain access to the the display hardware un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 127 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 5 disp_WriteWord value Syntax disp_WriteWord value Arguments value value Specifies the value to be written to the display data register The arguments can be a variable array element expression or constant Returns nothing Sends a 16 bit value to the display bus Refer to individual data sheets for the display for more Description information This function is used to extend the capabilities of the user code to gain access to the the display hardware un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 128 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 7 6 disp_ReadWord value Syntax disp_ReadWord value Arguments value value Specifies the value to be read from the display data register
149. eaeeseseesseeeeaeeses 271 2 17 2 touch Set Imode ioni rire Pret e rede een PER aka ed Ue UR Boe Ua eee ERE Pee vinci dE REL E FREE A 272 217 3 touch Get hiod eoe rro nere Ri vna Re CE ER REY EREM NR E Fa RE EM RES ERR RM REA REESE NY RERE NE aaiae 273 2 18 Image Control Functions ntt i ta e a ER RES RR PREHTRAERERE LEER RE RR AR ERE PX a baee 274 2 18 1 img SetPosition handle index XPOS VPOS cccsccesccsscecsseceseeecsecseseecseeeseeeeceaeeseeeesseeseaeeee 275 2 18 2 img Enable handle index eerte ert en Frente aerei Ee Fi re Fen YER eh 276 2 18 3 img Disable handle index sess enne te nennt nnne nre 277 2 18 4 img Darken handle index sess eene enne nnne nennen rnnt reinen enne 278 u Z u Z TE J O m T J lt x z a T lt PICASO 2 18 5 img Lighten handle Index eter ert ret rente tienen eina PRSE e Vl een Vine sere 279 2 18 6 img SetWord handle index offset word sess ener enne 280 2 18 7 img GetWord handle index offset sssssssseseeseseeeeneeenen nnne nre nennen enne 281 2 18 8 img Show handle index sess enne enne innein nennen 283 2 18 9 img SetAttributes handle index value sssseseseseeee eene nnn nennen 284 2 18 10 img ClearAttributes handle index value nennen 285 2 18 11 img Touched handle index sss enne ne
150. elay millisecs Set the delay between character printing not used za txt_Opacity mode Selects whether or not the background pixels are drawn O or TRANSPARENT default mode is OPAQUE 1 or OPAQUE LL txt_Bold mode Embolden text O or 1 ON or OFF txt Italic mode Italic text O or 1 ON or OFF ex txt Inverse mode Inverted text O or 1 ON or OFF OQ txt Underlined mode Underlined text O or 1 ON or OFF txt Attributes value Control of functions 9 10 11 12 grouped 16 orBOLD I bits can be combined by using logical OR of bits 32 or ITALIC nb bits 0 3 and 8 15 are reserved 64 or INVERSE _J 128 or UNDERLINED q txt Wrap Sets the pixel position where text wrap will occur at RHS O to n OFF or Value 2 The feature automatically resets when screen mode is changed v The value is in pixel units Default value is O W z n lt A 2012 4D SYSTEMS Page 61 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 Ctype Functions Summary of Functions in this section e isdigit char e isxdigit char e isupper char e islower char e isalpha char e isalnum char e isprint char e isspace char e iswhite char e toupper char e tolower char e LObyte var e Hlbyte var e ByteSwap var un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 62 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5
151. ents may bank up and will execute immediately once the eventsResume takes place This however disallows a child process to use any timer events in the sub program so method 2 is preferable in this case WN Z O Z m LL T Z tV UJ Z 2 The parent program can disconnect the event s by setting it them to zero prior to child process execution or setting the associated timer to zero so the event wont fire In either case it is necessary to do the following while sys EventQueue to ensure the event queue is empty prior to calling the child process Note also that if just the timer is set to zero the child process cannot use this timer If the timer was now set to a value and the old event still existed when the timer reaches zero the bad parent address event will fire causing a crash PICASO The reverse situation also applies of course the same level of respect is required if a child program needs to use any timer events Method 1 above will not work as the events have been postponed stopping the child process from using any timer events If the child process did an eventsResume in this case everything would crash miserably So the same applies a child that uses any timer events must respect any timers that may be used by the parent and a child must zero the sys SetTimerEvent before returning to the parent Example sys SetTimerEvent TIMER5 myfunc 2012 4D SYSTEMS Pag
152. eo varsia 1 199 p read all the numbers till we get a non number priat Wars L0 ua wees Na varsli Wa prime lem ome str Printf amp p s n numbers extracted now just print remainder of string endfunc un Z T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 251 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 4 str_GetHexW amp ptr amp var Syntax str_GetHexW amp ptr amp var Arguments amp ptr amp var ptr byte pointer to string var destination for our result Returns Status Status Returns TRUE if function succeeds advancing ptr Description Convert hex number in a string to WORD myvar This function is for extracting raw hex words with no Ox prefix Note The address of the pointer must be passed so the function can advance it if required Example var buffer 100 200 character buffer for a source string var p string pointer var n var vars 4 for our results func main to buffer print 1234 5678 9 ABCD p str Ptr buffer raise a string pointer so we can use the string functions while str GetHexW amp p amp vars ntt 0 read all the hex numbers till we get a non number igsesuewE weeues 0 Va swewemp 1 aU 2 vars 2 at sess I VNav p endfunc Wn z O U z D Ti Ej D m J q
153. eset the window ff SS SSS SS SSS SS SSS SSS SSS SS SS SS SS SS SSS TE case Wmsg MAXBUTTONS if it was the exit last button aWindow INITIALIZE Sx break O o update status and title with the button number V J case Wmsg 0 amp amp Wmsg lt MAXBUTTONS to tempstr print Button Wmsg Ss print return value to the temp buffer q to APPEND putstr ver clear string tail a aWindow statusbartext tempstr m use temp buffer for status text aWindow REDRAW STATUS W update the status bar za to tempstr putstr buttontexts Wmsg 1 print the button text to the temp buffer to APPEND putstr s clear string tail aWindow title tempstr Uu P NES mp buster for cicla tet q aWindow REDRAW TITLE H update the title bar LJ break DL default endswitch endif forever endfunc constant MAXBUTTONS 5 4 pushbuttons enumeration for the window s sub functions constant INITIALIZE UPDATE SCAN REDRAW TITLE REDRAW STATUS example for a simple Window object func aWindow var subfunc window properties 2012 4D SYSTEMS Page 306 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS var private xpos ypos window position var private windowWidth 200 default window width var private windowHeight 200 default window height var private windowcolor WINDOW COLOR default window
154. esienstad iniaa a tte Ea a E A a 221 2 14 21 file PutS source handle seien enne enne nennen nennen enn 222 2 14 22 file GetS string size handle nennen trennen rennen enne 223 2 14 23 file Er se fname c cider hee esee eerte de t tek eee e a E Fe Oen Re deas WENN ee ae ru Nn 224 2 14 24 File Rewind handle eoe iot eher eade bn nhe oae eeu eaaa RENE iaia 225 2 14 25 file LoadFunction fname 4XE cccesccsssecssecseceecsseceeececseecseeeecsaeeseseecseeeseeeeceaeeseseesseeseaeeee 226 2 14 26 file Run fname 4XE arglistptr esses enne enne nnne enn 228 2 14 27 file Exec fname 4XE arglistptr ceceeecescceeceeeceeeceeeceeeceaeceaeceaecaeecaeeeaeeeeeseeeeeeseeseeeeaseeaes 233 2 14 28 file LoadlmageControl fname1 fname2 mode renes 234 viola M TOU E M 237 2 14 30 file UnmoUrit reet eso mer piene re aasia eana Ro ERN RE ERR e ERR RR ER RA ea e ERE ERR Ras aga 238 2 14 31 file Play WAV FNAM E 5 eot rha eh rn ruta RE koe o ER Ree ERR adai EN RE eR Re RE NER EEE RYE ER E RR Eai Enea 239 2 15 Sourid Control F hCtiOHs iiiiieer terrre edant korea retro Eae EO TR e ER ee FR DERE Ro Ea EUR KE re EE e SENDER 240 2115 1 Shd Volume V r esintisini epini ia EE PRO SERI u n koe ev Ee R ee RAE e Ee REL Rp 241 2 15 2 Spnd PIteh pItchi i i tocar ta aenean eo ent arenae Rash en kara ca ERE heo s aux ue aa duse agna nt eh enne PRAE ENA 242 2 15 3 Sid BUFSIZE VAT coser
155. eturns non zero if write was successful Description Writes a byte to the current media address that was initially set with media_SetSector Note Writing bytes or words to a media sector must start from the beginning of the sector All writes will be incremental until the media Flush function is executed or the sector address rolls over to the next sector When media Flush is called any remaining bytes in the sector will be padded with OxFF destroying the previous contents An attempt to use the media SetAdd function will result in the lower 9 bits being interpreted as zero If the writing rolls over to the next sector the media Flush function is issued automatically internally Example Welle n enar while media_Init 0 wait if no SD card detected media SetSector 0 2 Be Sete 2 media SetAdd 0 1024 alternatively use media SetAdd lower 9 bits ignored while n 10 media WriteByte ntt 0 write ASCII 0123456789 to the wend first 10 locations to MDA putstr Hello World now write a ascii test string media WriteByte A write a further 3 bytes media WriteByte B mecla ws eByte ed WN z U z J Ti J O D T J lt x Z Y T Z media_WriteByte 0 terminate with zero Q media Flush we re finished close the sector q media SetAdd 0 1024 5 set the starting byte address while char media ReadByte putch
156. f the SPI port input mode Sets the input mode of the SPI port See diagram below output mode Sets the output mode of the SPI port See diagram below The arguments can be a variable array element expression or constant Returns nothing Description Sets up the PICASO GFX2 SPI port to communicate with SPI devices Note The SPI functions in this section are not necessary when using the memory card or serial flash chips interfaced to the SPI port The SPI functions in this section are relevant to those devices other than the memory card and the serial flash chip used for media access SPI MODE ARGUMENTS FOR spi Init SPEED INPUT MODE OUTPUT MODE SCK pin 11 CKMODE 0 SCK pin 11 CKMODE 1 SCK pin 11 CKMODE 2 SCK pin 11 CKMODE 3 pin 13 Corr DX sins X errs X arra XX errs X err X erri X erro un Z T Z zm TE J D QO J q Z tv TT Z START SPI OUTPUT MODES SDI pin 12 RXMODE 0 PICASO SDI pin 12 RXMODE 1 START SPI INPUT MODES sample point spi Init SPI SPEED SPI INPUT MODE SPI OUTPUT MODE 2 SPI SLOW 650 khz 1 SMI MED 4mhz O SPI FAST 16mhz 2012 4D SYSTEMS Page 152 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 10 2 spi Read Syntax spi Read Arguments none Returns byte byte Returns a single data byte from the SPI device
157. fies the colour of the rectangle The arguments can be a variable array element expression or constant Returns nothing Description Draws a SOLID rectangle from x1 y1 to x2 y2 using the specified colour The line may be tessellated with the gfx_LinePattern function The outline colour can be specified with gfx OutlineColour If OUTLINE COLOUR is set to 0 no outline is drawn The outline may be tessellated with the gfx LinePattern function NB The PEN SIZE is ignored the rectangle is always drawn SOLID Example gfx RectangleFilled 30 30 80 80 RED This example draws a filled RED rectangle from x1 30 y1 30 to x2 80 y2 80 un Z T Z TE J D QO I m lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 86 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 10 gfx_Polyline n vx vy colour Syntax gfx_Polyline n vx vy colour Arguments n vx vy colour specifies the number of elements in the x and y arrays specifying the vertices for f the polyline specifies the addresses of the storage of the array of elements for the x li coordinates of the vertices specifies the addresses of the storage of the array of elements for the y wy coordinates of the vertices colour Specifies the colour for the lines The arguments can be a variable array element expression or constant Returns n
158. file Mount repeat putstr Disk not mounted pause 200 Gps GCber n pause 200 Witte file Mowe 7 endif un Z T c zm TE J D T 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 237 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 30 file_Unmount Syntax file_Unmount Arguments None Returns None Description Release any buffers for FAT16 and unmount the Disk File System This function is to be called to close the FAT16 file system Example file Unmount un Z T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 238 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 31 file_PlayWAV fname Syntax file_PlayWAV fname Arguments fname fname Name of the wav file to be opened and played Returns value value If there are no errors returns number of blocks to play 1 to 32767 If errors occurred the following is returned 6 cant play this rate no data chunk found in first rsector no format data no wave chunk signature bad wave file format file not found E NU RU Description Open the wav file decode the header to set the appropriate wave player parameters and set off the playing of the file as a background process See Sound Control Functions for additional pla
159. herit 4DGL 16bitColours fnc func help var x y state print TOUCHE ME touch Set TOUCH ENABLE lets enable the touch screen while touch Get TOUCH STATUS TOUCH PRESSED Wait for touch we ll need a place on the screen to start with gfx MoveTo touch Get TOUCH GETX touch Get TOUCH GETY gfx Set OBJECT COLOUR WHITE this will be our line colour un Z T Z zm TE J D T E lt x Z Y TT Z while 1 state touch Get TOUCH STATUS Look for touch activity X touch Get TOUCH GETX Grab x and the y touch Get TOUCH GETY y coordinates of the touch if state TOUCH PRESSED if there s a press gfx LineTo x y Draw a line from previous spot endif _ l if state TOUCH RELEASED 2 amp ehere s a release Wn gfx CircleFilled x y 10 RED Draw a solid red circle q endif LJ if state TOUCH MOVING if there s movement C gfx PutPixel x y LIGHTGREEN we ll draw a green pixel DL endif wend Repeat forever endfunc 2012 4D SYSTEMS Page 97 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 20 gfx_MoveRel xoffset yoffset Syntax gfx_MoveRel xoffset yoffset Arguments xoffset yoffset xoffset specifies the horizontal offset of the new origin yoffset specifies the vertical offset of the new origin The arguments can be a variable array element expression or consta
160. id red circle of radius 10 on touch release endif un Z T Z zm TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 81 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 5 gfx_Line x1 y1 x2 y2 colour Syntax gfx_Line x1 y1 x2 y2 colour Arguments x1 y1 x2 y2 colour x1 y1 specifies the starting coordinates of the line x2 y2 specifies the ending coordinates of the line colour specifies the colour of the line The arguments can be a variable array element expression or constant Returns nothing Description Draws a line from x1 y1 to x2 y2 using the specified colour The line is drawn using the current object colour The current origin is not altered The line may be tessellated with the gfx LinePattern function Example gfx Line 100 100 39 20 JD p This example draws a RED line from x1 10 y1 10 to x2 100 y2 100 un Z T Z zm TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 82 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 6 gfx_Hline y x1 x2 colour Syntax gfx_Hline y x1 x2 colour Arguments y x1 x2 colour y specifies the vertical position of the horizontal line x1 x2 specifies the horizontal end points of the line colour specifies the colour of the hor
161. ider slidervals 6 Slider print Slider slidervals 8 Slider u silickievalls iL ia p slidervals 3 n sibiderva isikli AANA slidervals 7 n ibsheleseweds L9 z Wa p Q 0 0 rp 7 S HOOBRN Si uu mem Free fncHandle done with sliders release its memory Note Refer to the complete Sample code RUNDEMOS 4DG Wn z O U z 5 TE D m J Z a T Z PICASO 2012 4D SYSTEMS Page 227 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 26 file_Run fname 4XE arglistptr Syntax file_Run fname 4XE arglistptr Arguments fname 4XE arglistptr fname 4XE Iname of the 4DGL child program to be loaded into RAM and executed arglistptr pointer to the list of arguments to pass to the new program Returns Value Value Returns the value from main in the called program Description Any memory allocations in the main FLASH program are released however the stack and globals are maintained func main in the called program accepts the arguments if any If arglistptr is 0 no arguments are passed else arglistptr points to an array the first element containing the number of additional elements in the array which contain the arguments The disk does not need to be mounted file Run automatically mounts the drive Example inherit 4DGL 16bitColours fnc inherit FONT4 fnt
162. idth O pixel to 15pixels 0 None 1 to 15 pixels 2012 4D SYSTEMS Page 120 of 317 www 4dsystems com au WN c O Z m LL T q Z tV UJ Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS SCREEN_RES Set VGA Screen resolution Applies to uVGA II GFX and O for 320x240 uLCD 43 GFX only 1 for 640 x 480 2 for800 x 480 DISPLAY_PAGE Choose Page to be displayed Value depends on theje g OOhex O4hex for resolution set Applies to uVGA II GFX and uLCD 43 GFX 320x240 resolution only resolution set Applies to uVGA II GFX and uLCD 43 GFX only on a uVGA II GFX READ PAGE Choose the Page to be read Value depends on theje g OOhex O4hex for resolution set Applies to uVGA II GFX and uLCD 43 GFX 320x240 resolution only on a uVGA II GFX WRITE PAGE Choose the Page to be written Value depends on theje g OOhex O4hex for 320x240 resolution on a uVGA II GFX Single parameter short cuts for the gfx Set functions Note pen size is set to OUTLINE for normal operation default Function Syntax Function Action value gfx PenSize mode Set the draw mode for gfx LineTo gfx_LineRel O or SOLID gfx Dot gfx Bullet and gfx BoxTo 10r OUTLINE gfx BGcolour colour Set the screen background colour Colour 0 65535 gfx ObjectColour colour Generic colour for gfx_LineTo gfx LineRel gfx Dot gfx Bullet and gfx BoxTo Colour
163. include SERIN SEROUT GFX_LINE GFX_CIRCLE and many more This document covers the internal chip resident functions available for the PICASO Processor This document should be used in conjunction with 4DGL Programmers Reference Manual document Hui Medi Services SD Card Driver I Graphics Functions FAT16 File services WM tro TMR1 TMR2 TMR3 PmmC Loader CoMo M TMR4 TMR5 TMR6 TMR7 EVE Code Loader COMO COM1 Buffered Services COM1 SPI EVE Core Qc Extensible Virtual Engine Sound Generation AUDIO Audio Services A ero Management N Display oror os SRAM FLASH Touch Drivers TOUCH 14K bytes 14K bytes Code Execution User Code GP I O Suo User Variables Storage Services GPIO BUS PICASO Internal Block Diagram 2012 4D SYSTEMS Page 8 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 PICASO Chip Resident Functions Summary The following is a summary of chip resident 4DGL functions within the PICASO graphics processor The document is made up of the following sections 2 1 GPIO Functions pin Set mode pin OUTPUT INPUT pin Hl pin pin LO pin e pin Read pin bus In bus Out var bus Set var e bus Write var bus Read var 2 2 System Memory Access Functions e peekW address e pokeW address word value 2 3 Maths Functions ABS value e MIN valuel1 value2 MAX value1 value2 SWAP amp var1 amp var2 SIN angle C
164. ing the 32bit result in a 2 word array Example wae weds2 2 A var p umul 1616 val32 500 2000 p str Ptr val32 Sti Priati fo Walle p This example prints 1000000 un Z I T Z em TE J D QO T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 40 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 13 uadd_3232 amp res32 amp vali amp val2 Syntax uadd_3232 amp res32 amp val1 amp val2 Arguments amp res32 amp val1 amp val2 amp res32 Points to 32bit result register amp val1 points to 32bit augend amp val2 points to 32bit addend Returns Value Value Returns 1 on 32bit unsigned overflow carry Carry flag is also set on 32bit unsigned overflow and can be read with the CY function Description Performs an unsigned addition of 2 x 32bit values placing the 32bit result in a 2 word array Example Wee carry eu 2 wellsZ2i xeswue D21 9 var p valA 0 0 valA 1 1 valB 0 0 valB 1 1 carry uadd_3232 Result valA valB jp se gtr Bice Result print Ox Sibi Porat Gy WSIS B prints the value at pointer in Hex long format This example will print 0x20000 un Z T Z em TE J D QO T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 41 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2
165. int has completed its action The APPEND argument is used to append the printed output to the same place as the previous redirection This is most useful for building string arrays or adding sequential data to a media stream T Z T Z m Ti J T I J q z Y TT lt PICASO Example Example 1 putstr redirection var burii a buffer that will hold up to 20 bytes chars var S a var for use as a pointer to buf putstr ONE redirect putstr to the buffer to APPEND putstr TWO and add a couple more items to APPEND putstr THREE n joxaEreiese Tome p print the result while media Init 0 wait if no SD SDHC card detected media SetSector 0 2 at sector 2 media SetAdd 0 1024 alternatively use media SetAdd lower 9 bits ignored to MDA putstr Hello World now write a ascii test string media WriteByte A write a further 3 bytes 2012 4D SYSTEMS Page 53 of 317 www 4dsystems com au un Z T Z TE J D E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS media WriteByte B media WriteByte C to MDA putstr buf write the buffer we prepared earlier media WriteByte 0 terminate with ASCII zero mecdstamltwsh y media SetAdd 0 1024 reset the media address while char media ReadByte to COMO putch char
166. ion is similar to file Run however the main program in FLASH retains all memory allocations eg file buffers memory allocated with mem Alloc etc Example file Exec bounce 4xe 0 un Z T Z em TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 233 of 317 www 4dsystems com au un Z T Z m Ti J T I J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 28 file_LoadimageControl fname1 fname2 mode Syntax file LoadlmageControl fname1 fname2 mode Arguments fname1 fname2 mode fname1 the control list filename dat Created from Graphics Composer fname2 the image filename gci Created from Graphics Composer mode mode 0 It is assumed that there is a graphics file with the file extension fname2 gci In this case the images have been stored in a FAT16 file concurrently and the offsets that are derived from the fname1 dat file are saved in the image control so that the image control can open the file gci and use file Seek to get to the position of the image which can then automatically be displayed using file Image xpos ypos hSource Mode 0 builds the image control quickly as it only scans the dat file for the file offsets and saves them in the relevant entries in the image control The penalty is that images take longer to find when displayed due to file See
167. ip Functions The functions in this section only apply to serial SPI NAND flash devices interfaced to the PICASO GFX2 SPI port Summary of Functions in this section e flash SIG e flash ID e flash BulkErase e flash BlockErase blockAddress un Z T Z TE J T n E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 146 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Syntax flash SIG Arguments none Returns signature signature Release from Deep Power down and Read Electronic Signature Only the low order byte is valid the upper byte is ignored Description If a FLASH storage device is connected to the SPI port and has been correctly initialised with the spi Init function the Electronic Signature of the device can be read using this function The only devices supported so far on the PICASO GFX2 are the M25Pxx range of devices which are 512Kbit to 32Mbit 2M x 8 Serial Flash Memory un Z T Z TE J D QO S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 147 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 9 2 flash_ID Syntax flash ID Arguments none Returns type capacity type capacity Reads the memory type and capacity from the serial FLASH device Hi byte contains type and low byte contains capacity Refer to the device data sheet
168. ive value for the required line position newColour Holds a positive value for the required column position The arguments can be a variable array element expression or constant Returns nothing Moves the text cursor to a screen position set by line and column parameters The line and column position is calculated based on the size and scaling factor for the currently selected font When text is outputted to screen it will be displayed from this position The text position Description sag P could also be set with gfx MoveTo if required to set the text position to an exact pixel location Note that lines and columns start from O so line O column O is the top left corner of the display Example txt MoveCursor 4 9 This example moves the text origin to the 5 line and the 10 column un Z T Z em TE J D T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 45 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 2 putch char Syntax putch char Arguments char char Holds a positive value for the required character The arguments can be a variable array element expression or constant Returns nothing Description putch prints single characters to the current output stream usually the display Example var v v 0x39 putch v print the number 9 to the current display lo
169. izontal line The arguments can be a variable array element expression or constant Returns nothing Description Draws a fast horizontal line from x1 to x2 at vertical co ordinate y using colour Example gies blouse 50 10 80 IRD 9 This example draws a fast RED horizontal line at y 50 from x1 10 to x2 80 un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 83 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 7 gfx_Vline x y1 y2 colour Syntax gfx_Vline x y1 y2 colour Arguments x y1 y2 colour x specifies the horizontal position of the vertical line y1 y2 specifies the vertical end points of the line colour specifies the colour of the vertical line The arguments can be a variable array element expression or constant Returns nothing Description Draws a fast vertical line from y1 to y2 at horizontal co ordinate x using colour Example gfx Vline 20 30 OPENS This example draws a fast RED vertical line at x20 from y1 30 to y2 70 un Z T Z em TE J D QO I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 84 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 8 gfx_Rectangle x1 y1 x2 y2 colour Syntax gfx_Rectangle x1 y1 x2 y2 colour Arguments x1 y
170. k overheads mode 1 It is assumed that there is a graphics file with the file extension fname2 gci In this case the images have been stored in a FAT16 file concurrently and the offset of the images are saved in the image control so that image file gci can be mapped to directly The absolute cluster sector is mapped so file seek does not need to be called internally This means that there is no seek time penalty however the image list takes a lot longer to build as all the seeking is done at control build time Mode 2 Not implemented yet Returns Status Returns a handle pointer to the memory allocation to the image control list Status that has been created Returns NULL if function fails Description Reads a control file to create an image list When an image control is loaded an array is built in ram It consists of a 6 word header with the following entries as defined by the constants IMG COUNT 0 IMG ENTRYLEN 1 IMG MODE 2 IMG GCI FILENAME 3 IMG DAT FILENAME 4 IMG GCIFILE HANDLE 5 No images are stored in FLASH or RAM the image control holds the index values for the 2012 4D SYSTEMS Page 234 of 317 www 4dsystems com au un Z T Z m Ti J T J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS absolute storage positions on the uSD card for RAW mode or the cluster sector position for formatted FAT16 mode When an image control is no longle required the
171. l units Note that any string constants declared in your program are automatically terminated with a zero as an end marker by the compiler Any string that you create in the DATA section or MEM section must have a zero added as a terminator for this function to work correctly Example See example in charwidth un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 57 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 10 strheight Syntax strheight Arguments none Returns height height Returns the height of a string in pixel units Description _ strheight returns the height of a zero terminated string in pixel units The strwidth function must be called first which makes available width and height Note that any string constants declared in your program are automatically terminated with a zero as an end marker by the compiler Any string that you create in the DATA section or MEM section must have a zero added as a terminator for this function to work correctly Example See example in charwidth un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 58 of 317 www 4dsystems com au un Z T Z em TE J D T S lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 11 strlen pointer Syntax
172. l value is returned before incrementing The return value can be useful if a function requires the current point before insetting occurs Example var n gfx MoveTo 20 20 n 96 while n gfx ObjectColour n 3 gfx LineRel 20 0 Guess Ime p wend This example draws a simple horizontal gradient using lines un Z j T c zm TE J D T Sj lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 100 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 23 gfx_LineTo xpos ypos Syntax gfx_LineTo xpos ypos Arguments Xpos ypos xpos specifies the horizontal position of the line end as well as the new origin ypos specifies the vertical position of the line end as well as the new origin The arguments can be a variable array element expression or constant Returns nothing Description Draws a line from the current origin to a new position The Origin is then set to the new position The line is drawn using the current object colour The line may be tessellated with the gfx_LinePattern function Example gix Movello dO 20 gfx LineTo 60 70 This example draws a line using the current object colour between x1 10 y1 20 and x2 60 y2 70 The new origin is now set at x 60 y 70 un Z T Z Ti J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 101 of 317 www 4dsy
173. le e RAND e SEED number e SQORT number e OVF e umul 1616 amp res32 val1 val2 e uadd 3232 amp res32 amp val1 amp val2 e usub 3232 amp res32 amp val1 amp val2 e ucmp 3232 amp val1 amp val2 un Z T Z TE J D QO I S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 28 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 1 ABS value Syntax ABS value Arguments value value a variable array element expression or constant The arguments can be a variable array element expression or constant Returns value value Returns the absolute value Description This function returns the absolute value of value Example var myvar number number 100 myvar ABS number 5 This example returns 500 in variable myvar un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 29 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 2 MIN value1 value2 Syntax MIN value1 value2 Arguments value1 value2 value1 a variable array element expression or constant value2 a variable array element expression or constant The arguments can be a variable array element expression or constant Returns value value the smaller of the two values Description
174. memory can be released with mem Free MylmageControlHandle Example finherit A4DGL 16bitColours fnc constant OK ii constant FAIL 0 var p buffer pointer var img handle for the image list var n exit r return true if screen touched also sets ok flag func CheckTouchExit return exit touch Get TOUCH STATUS TOUCH PRESSED if there s a press exit endfunc func main gfx Cls txt Set FONT ID FONT2 txt Set TEXT OPACITY OPAQUE touch Set TOUCH ENABLE enable the touch screen print heap mem Heap bytes n show the heap size r i OK return value exit 0 Wie ziile Mewrme print File error file Error while CheckTouchExit just hang if we didnt get the image list r FAIL goto quit endif prime CAIT bualicing image Mast at p slow build fast execution higher memory requirement img file LoadImageControl GFX2DEMO dat GFX2DEMO gci 1 build image control returning a pointer to structure allocation if img print image control HEX img n show the address of the image control allocation else Dulesiee hauled to buile imags Control ss Wal p while CheckTouchExit 0 just hang if we didnt get the image list r FAIL GOLE Gut endif print Loaded img IMG COUNT images Nn josie Y aiomeln exl Jxolel tO Este Wa 2012 4D SYSTEMS Page 235 of 317 www 4d
175. mented by 1 The file must be previously opened with w write or a append modes Example file PutC A hndl un Z I T Z TE J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 218 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 18 file_GetC handle Syntax file_GetC handle Arguments handle handle The handle that references the file Returns byte byte Returns the data byte read from the file Description This function reads a byte from the file at the position indicated by the associated file position pointer and advances the pointer appropriately incremented by 1 The file must be previously opened with r read mode Example mychar file GetC hndl un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 219 of 317 www 4dsystems com au un Z T Z Ti J D 2 q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 19 file PutW word handle Syntax file PutW word handle Arguments word handle word Data about to be written handle The handle that references the file to be written to Returns BytesWritten BytesWritten Returns the number of bytes written Description This function writes word sized 2 bytes data specifie
176. ments X y xrad yrad colour X y specifies the horizontal and vertical position of the centre of ellipse xrad yrad specifies x radius and y radius of the ellipse colour Specifies the colour for the lines The arguments can be a variable array element expression or constant Returns nothing Description Plots a coloured Ellipse on the screen at centre x y with xradius xrad and yradius yrad if PenSize O Ellipse is Solid if PenSize 1 Ellipse is Outline Example gfx Ellipse 200 80 5 10 YELLOW un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 105 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 28 gfx_EllipseFilled x y xrad yrad colour Syntax gfx_EllipseFilled x y xrad yrad colour Arguments X y xrad yrad colour X y specifies the horizontal and vertical position of the centre of ellipse xrad yrad specifies x radius and y radius of the ellipse colour Specifies the colour for the lines The arguments can be a variable array element expression or constant Returns nothing Description Plots a solid coloured Ellipse on the screen at centre x y with xradius xrad and yradius yrad Example gfx EllipseFilled 200 110 10 5 GREEN un Z T Z TE J D I 2 q Z Y TT Z PICASO
177. mer endfunc 2012 4D SYSTEMS Page 280 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 7 img_GetWord handle index offset Syntax img_GetWord handle index offset Arguments handle index handle Pointer to the Image List index Index of the images in the list offset Offset of the required word in the image entry Returns Value value Returns the image entry in the list Description This function requires that an image control has been created with the file LoadlmageControl function Returns specified word from an image entry un Z T Z m TE J D m E lt x Z Y TT Z IMAGE_LOWORD 0 WORD image address LO IMAGE HIWORD 1 WORD image address HI IMAGE XPOS 2 WORD image location X IMAGE YPOS 3 WORD image location Y IMAGE WIDTH 4 WORD image width IMAGE HEIGHT 5 WORD image height IMAGE FLAGS 6 WORD image flags IMAGE DELAY 7 WORD inter frame delay IMAGE FRAMES 8 NORD number of frames IMAGE INDEX 9 WORD current frame IMAGE CLUSTER 10 WORD image start cluster pos for FAT16 only IMAGE SECTOR 11 WORD image start sector in cluster pos for FAT16 only IMAGE TAG 12 NORD user variable 1 IMAGE TAG2 13 WORD user variable 2 Example myvar img GetWord hndl 5 IMAGE YPOS PICASO 2012 4D SYSTEMS Page 281 of 317 www 4dsystems com au 4D SYSTEMS PI
178. municating serial data to the PC The 4D Programming Cable is available from 4D Systems www 4dsystems com au 4D Programming Cable 6 2 Evaluation Display Modules The following modules available from 4D Systems can be used for evaluation purposes to discover what the PICASO processor has to offer uLCD 24PTU 2 4 Intelligent PICASO Display Other modules such as the 2 8 3 2 and 3 2 Wide verisions are also available Please contact 4D Systems for more information or visit the 4D Systems website www 4dsystems com au 2012 4D SYSTEMS Page 312 of 317 7 4D Systems Workshop 4 IDE Workshop 4 is a comprehensive software IDE that provides an integrated software development platform for all of the 4D family of processors and modules The IDE combines the Editor Compiler Linker and Down Loader to develop complete 4DGL application code All user application code is developed within the Workshop 4 IDE The Workshop 4 IDE supports multiple development environments for the user to cater for different user requirements and skill level e The Designer environment enables the user to write 4DGL code in its natural form e A visual programming experience suitably called ViSi enables drag and drop type placement of objects to assist with 4DGL code generation and allows the user to visualise how the display will look while being developed e An advanced environment called ViSi Genie
179. n Arguments buf bufsize pin buf Specifies the address of a buffer used for the buffering service bufsize Specifies the byte size of the user array provided for the buffer each array element holds 2 bytes pin Specifies the turnaround pin If not required just set pin to zero The arguments can be a variable array element expression or constant Returns None Description Initialise a serial buffer for the COMO or COM1 output The program must declare a var array as a circular buffer When a TX buffer is declared for comms the transmission of characters becomes non blocking The only time blocking will occur is if the buffer has insufficient space to accet the next character in which case the function will wait for buffer space to become available If the TX buffer is no longer required just set the buffer pointer to zero the size in this case doesnt matter and is ignored The function can resize or reallocated to another buffer at any time The buffer is flushed before any changes are made pin designates an IO pin to control a bi directional control device for half duplex mode pin will go HI at the start of a transmission and will return low after the final byte is transmitted Example com TXbuffer mybuf 1024 IO1 PIN set the TX buffer com TXbuffer 0 0 0 revert to non buffered service un Z T Z m TE J D m 2 q Z Y TT Z PICA
180. n n vx vy colour e gfx Triangle x1 y1 x2 y2 x3 y3 colour e gfx Dot e gfx Bullet radius e gfx Orbitlnit amp x dest amp y dest e gfx Orbit angle distance e gfx PutPixel x y colour e gfx GetPixel x y e gfx MoveTo xpos ypos e gfx MoveRel xoffset yoffset e gfx IncX e gfx IncY e gfx LineTo xpos ypos e gfx LineRel xpos ypos e gfx BoxTo G2 y2 e gfx SetClipRegion e gfx Ellipse x y xrad yrad colour e gfx EllipseFilled x y xrad yrad colour e gfx Button state x y buttonColour textColour font textWidth textHeight text e gfx Panel state x y width height colour e gfx Slider mode x1 y1 x2 y2 colour scale value e gfx ScreenCopyPaste xs ys xd yd width height e gfx RGBto565 RED GREEN BLUE e gfx 332to565 COLOURBBIT e gfx Selection index backcolor textcolor e gfx TriangleFilled x1 y1 x2 y2 x3 y3 colr e gfx PolygonFilled n amp vx amp vy colr e gfx Origin x y e gfx Get mode e gfx ClipWindow x1 y1 x2 y2 e gfx Set function value gfx Set shortcuts e gfx PenSize mode e gfx BGcolour colour e gfx ObjectColour colour e gfx Clipping mode e gfx TransparentColour colour e gfx Transparency mode e gfx FrameDelay delay e gfx ScreenMode delay e gfx OutlineColour colour T z T Z m Ti J T m J q z Y TT Z PICASO 2012 4D SYSTEMS Page 76 of 317 www 4dsystems com au 4D SYSTEMS PICA
181. n opened in r read or a append mode In append mode file Seek does not expand a filesize instead the file pointer handle is set to the end position of the file eg assuming the file size is 10000 bytes file Seek handle O 0x1234 will set the file position to 0x00001234 byte position 4660 for the file handle so subsequent data may be read from that position onwards with file GetC file GetW file GetS or an image can be displayed with file Image Conversely file PutC file PutW and file PutS can write to the file at the position A FE EOF end of file error will occur if you try to write or read past the end of the file Example res file Seek hSource 0x0000 0x1234 2012 4D SYSTEMS Page 211 of 317 www 4dsystems com au un Z T Z m TE J D m S lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 11 file_Index handle Hisize LoSize recordnum Syntax file_Index handle Hisize LoSize recordnum Arguments handle Hisize LoSize recordnum handle The handle that references the file Hisize Contains the upper 16bits of the size of the file records LoSize Contains the lower 16bits of the size of the file records recordnum The index of the required record Returns Status Status Returns TRUE if ok usually ignored Description Places the file pointer at the position in
182. n set to LO then after a settling delay of approx 50nsec the BUS is read into the lower 8 bits of the assigned variable the upper 8 bits being set to O the BUS RD pin is then set back to a HI level The BUS RD pin is automatically pre set to an output to ensure BUS write integrity Example varl bus Read 2 The lower byte of var1 will get loaded with the state of the bus l tBusRd 7100ns 4 RD N f DO D7 Data X 4 v un Z T Z Ti J D SI 2 q Z Y TT Z f tsetup 50ns PICASO 2012 4D SYSTEMS Page 24 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 2 System Memory Access Functions Summary of Functions in this section e peekW address e pokeW address word value un Z T Z TE J D QO S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 25 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 2 1 peekW address Syntax peekW address Arguments address address The address of a memory word The address is usually a pre defined system register address constant see the address constants for all the system word sized registers in section 3 table 3 2 The arguments can be a variable array element expression or constant Returns word value word value The 16 bit value stored at address Description This function returns
183. ndex Index of the images in the list Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Disables an image in the image list Returns TRUE if index was ok and function was successful Use this function to turn off an image so that when img Show is called the selected image in the list will not be shown To disable all of the images in the list at the same time set index to 1 Example r img Disable hlImageList imagenum un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 277 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 4 img_Darken handle index Syntax img_Darken handle index Arguments handle index handle Pointer to the Image List index Index of the images in the list Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Darken an image in the image list Returns TRUE if index was ok and function was successful Use this function to darken an image so that when img Show is called the control will take effect To darken all of the images in the list at the same time set index to 1 Note This feature will take effect one time only and when img Sho
184. ndow x1 y1 X2 y2 ssseesesseesseeeee enne enne enne nnne ense nnn nennen enn 119 2 6 41 gix Set f nction value tore t HORROR ERE UR PI ORE I I PRER E KE a EUR PARAT 120 2 7 Display O F nctlons cito ec PR ERR ER ERR ERU ER ELA DE Rt poe bebe ta dd ERE ou 123 2 7 1 disp SetReg register data cerent en tide iet eerte tee bie bare Ege tare Fee Ee Pe 124 2 7 2 disp SELGRAM X1 y1 X2 y2 einer ddd castacesieaseed costinases don eT aae Fe Hr ovens eR eerie Er ERR po o 125 2 7 3 disp WrGRAM colour esses eee eene sene ennt nn nenne nnn sensere nnns 126 2 7 4 disp WriteControl value eseesseeeseeeeeeeeee eene nennen nennen nnne nnn enne nennen senes nnn 127 2 7 5 disp WriteWord value sess nene enne enne nnn enne nennen enne nen rennen enn 128 2 7 6 disp ReadWord Valie iross riti rire open aiaa aea e Pla Fee pe raa aika aiaia 129 277o dis p TIT 130 2 8 Media Functions SD SDHC Memory Card or Serial Flash chip 131 28 1 media iE n 132 2 8 2 media SetAdd Hlword LOword esses eene enne nennen nennen nennen nnne 133 2 8 3 media SetSector Hlword LOword sese eee enne nennen nennen 134 2 8 4 media RdSector Destination Address ennemis 135 2 8 5 media WrSector Source Address eene nennen tnnt nrtn rennen enne 136 2 8 6 media Rea
185. ned Constant Error Actual Baud Rate J BAUD 110 0 00 110 BAUD 300 0 00 300 BAUD 600 0 01 600 QO BAUD 1200 0 03 1200 Y BAUD 2400 0 07 2402 BAUD 4800 0 16 4808 BAUD_9600 0 33 9632 q BAUD 14400 0 168 14423 a BAUD 19200 0 33 19264 v BAUD 31250 0 00 31250 W MIDI 0 00 31250 James BAUD_ 38400 0 33 38527 za BAUD_56000 0 45 56250 BAUD_57600 1 73 58594 BAUD_115200 1 73 117188 Q BAUD 128000 4 638 133929 Uu BAUD 256000 9 86 281250 q BAUD 300000 4 17 312500 UJ BAUD 375000 7 14 401786 BAUD_500000 12 50 562500 CL BAUD 600000 17 19 703125 The baud rate is calculated with the following formula rate divisor 3000000 baud 1 2012 4D SYSTEMS Page 157 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 2 com_SetBaud comport baudrate 10 Syntax com_SetBaud comport baudrate 10 Arguments comport baudrate 10 comport Com port COMO or COM1 baudrate 10 specifies the baud rate The arguments can be a variable array element expression or constant Returns Status Status Returns True if BAUD rate was acceptable Description Use this function to set the required baud rate for the required Com port Example stat com SetBaud COM1 960 To set Coul to 9600 BAUD rate if stat Print Coml set to 9600 BAUD endif un Z I T Z em TE J D Q
186. ng Description Specifies a clipping window region on the screen such that any objects and text placed onto the screen will be clipped and displayed only within that region For the clipping window to take effect Clipping setting must be enabled separately using gfx_Set CLIPPING ON or the shortcut gfx Clipping ON Example var n gfx ClipWindow 10 10 50 50 n 50000 while n gfx PutPixel RAND 100 RAND 100 RAND wend repeat forever This example will draw 50000 random colour pixels only the pixels within the clipping area will be visible un Z T Z em TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 119 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 41 gfx_Set function value Syntax gfx_Set function value Arguments function value function The function number determines the required action for various graphics control functions Usually a constant but can be a variable array element or expression There are pre defined constants for each of the functions value A variable array element expression or constant holding a value for the selected A function O Returns nothing U Description Given a function number and a value set the required graphics control parameter such as size Z colour and other parameters see the Single pa
187. nnen nnne nnne nennen 286 2 19 Memory Allocation Functions eene ette eio erbe enne be earn aao ER dee kao i eonun baee Ska a opo se cea aa auos 287 2 19 1 mem Alloc size esses eene nnn enne nnn nennen nensis nnne 288 2 19 2 mem AlloCv size veces iere eerte tet eh ree ritur rode e Paese eene teh ve ia uera Re MEET vae eo PR TR a ed ia 289 2 19 3 MEM_AIlOCZ SIZE cc cccssecsscccsssecsssesseecssssecseccssssecseecesssecseccssuseceeeceseesseecenssesaeesessesseeeesneeses 290 2 19 4 mem Realloc amp ptr SIZE isei ieaie ine asninn aaaea Eae RR NER ERE RR Re Pe oda 291 2 19 5 memi Free allocation iioii tree er ere inniinn Rr FEL daa oaa oed a eR c E RUNE 292 2 19 6 memi Heap iesiis crei iiesce pecie secedere ne Fr iiaiai da ia riai DK e PRAE e Foe ERR RR 293 2 197 meni Set Ptr char SI26 oneris en enu Ra uasa eek nS aa ER e ae ia Ee i iE aii 294 2 19 8 mem Copy source destination count nennen enne enne nennen 296 2 19 9 mem Compare ptr1 ptr2 count enne enne nennen enses enne enn 297 2 20 General Purpose Functions ccceceecccceesneeceeeeececeeeeeceesaeeecseaaeeeceneeceesaeeeceeauececseneeeeeaeeeeseaeeesneaaeess 298 2 20 1 PAUSE TIME oe oti den resa ein do ERE E RAE BER Re ERES RE Su AERE a SR iaae aa NER REM i RE Eu RER RENE RARE 299 2 20 2 lookup8 key byteConstList ueeseesseee esee enne nnne nennen nennen enne 300 2 20 3 lookup16 key word
188. not allocate code segment File loader Pd 10 Could not load function file from disk File loader 11 Bad header in program file File loader u 12 Header in program file differs from file size File loader J 13 Could not allocate global memory for program file File loader 14 Program File checksum error File loader 15 EVE Stack Overflow System D be ea p EM 16 Unsupported PmmcC function fnc 1 Arg 17 Illegal COMO Event Function address addr ignored T 18 Illegal COM1 Event Function address addr ignored UJ 19 Bad txt Set command number command value 20 Bad gfx Get command number command ignored E 21 Bad txt Set command number command value O 22 Bad address for peekW or pokeW command ignored ul 23 Bad timer number for sys SetTimer or sys GetTimer tnum value q 24 Bad timer number for sys_SetTimerFunction tnum funcaddr LL 2012 4D SYSTEMS Page 311 of 317 www 4dsystems com au un c T Z m TE J T m J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 6 Hardware Tools The following hardware tools are required for full control of the PICASO Processor 6 1 4D Programming Cable The 4D Programming Cable is an essential hardware tool to program customise and test the PICASO Processor The 4D Programming Cable is used to program a new Firmware PmmC and downloading compiled 4DGL code into the processor It even serves as an interface for com
189. ns byte byte Returns the byte value at pointer location Description Get a byte to myvar Similar to PEEKB in basic It is not necessary for byte pointer ptr to be word aligned Example var buffer 100 200 character buffer for a source string var n p func main Tout tenia pei niesen dL 2 3M 9 p str_Ptr buffer get a byte pointer from a word region im ge Of wile sre mere brise print HEX2 str GetByte p n print all the chars hex values wend endfunc un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 254 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 7 str GetWord ptr Syntax str GetWord ptr Arguments ptr ptr Byte pointer Returns Word Word Returns the word at pointer location Description Get a word to myvar Similar to PEEKW in basic It is not necessary for byte pointer ptr to be word aligned Example var p string pointer var buffer 10 array for 20 bytes func main p str Ptr buffer raise a string pointer str PutWord p 3 100 poke the array str PutWord p 9 200 str PutWord p 12 400 print str GetWord p 3 in peek the array pelati Ste Cetiwerd ms 9 Wa pg print str GetWord p 12 An endfunc un Z j T Z zm TE J D E lt x Z
190. nt Returns nothing Description Moves the origin to a new position relative to the old position Example gfx MoveTo 10 20 gfx MoveRel 5 3 gfx Dot This example draws a pixel using the current object colour at x 5 y 17 un Z j T c zm TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 98 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 21 gfx IncX Syntax gfx IncX Arguments none Returns old origin old origin Returns the current X origin before the increment Description Increment the current X origin by 1 pixel unit The original value is returned before incrementing The return value can be useful if a function requires the current point before insetting occurs Example var n gfx MoveTo 20 20 im 3 CI while n gfx ObjectColour n 3 gfx Bullet 2 gfx IncX wend This example draws a simple rounded vertical gradient un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 99 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 22 gfx IncY Syntax gfx IncY Arguments none Returns old Yorigin old Yorigin Returns the current Y origin before the increment Description Increment the current Y origin by 1 pixel unit The origina
191. nt of lines in multiline button GFX_LAST_SELECTION 60 Ox3C Last selected line GFX_HILIGHT_BACKGROUND 61 Ox3D multi button hilite background colour GFX HILIGHT FOREGROUND 62 Ox3E multi button hilite background colour GFX BUTTON FOREGROUND 63 Ox3F store default text colour for hilite line tracker 2012 4D SYSTEMS Page 302 of 317 www 4dsystems com au WN O m U Z uL o O J J lt a Vv W PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS GFX_BUTTON_BACKGROUND 64 0x40 store default button colour for hilite line tracker GFX_BUTTON_MODE 65 0x41 store current buttons mode GFX_TOOLBAR_HEIGHT 66 0x42 height above GFX_STATUSBAR_HEIGHT 67 0x43 height below GFX_LEFT_GUTTER_WIDTH 68 0x44 width to left GFX_RIGHT_GUTTER_WIDTH 69 0x45 width to right GFX_PIXEL_SHIFT 70 0x46 pixel shift for button depress illusion GFX_VECT_X1 71 0x47 gp rect used by multiline button to hilite required line GFX_VECT_Y1 72 0x48 GFX_VECT_X2 73 0x49 GFX_VECT_Y2 74 Ox4A GFX THUMB PERCENT 75 Ox4B size of slider thumb as percentage GFX THUMB BORDER DARK 76 Ox4C darker shadow of thumb GFX THUMB BORDER LIGHT 77 Ox4D lighter shadow of thumb TOUCH XMINCAL 78 Ox4E touch calibration value TOUCH YMINCAL 79 Ox4F touch calibration value TOUCH XMAXCAL 80 0x50 touch calibrati
192. old harmless 4D Systems from any and all damages claims suits or expenses resulting from such use No licenses are conveyed implicitly or otherwise under any 4D Systems intellectual property rights 10 Contact Information For Technical Support support 4dsystems com au For Sales Support sales 4dsystems com au Website www 4dsystems com au Copyright 4D Systems Pty Ltd 2000 2012 2012 4D SYSTEMS Page 317 of 317 www 4dsystems com au
193. on value TOUCH YMAXCAL 81 0x51 touch calibration value IMG WIDTH 82 0x52 width of currently loaded image IMG HEIGHT 83 0x53 height of currently loaded image IMG FRAME DELAY 84 0x54 if image else inter frame delay for movie IMG FLAGS 85 0x55 bit 4 determines colour mode other bits reserved IMG_FRAME_COUNT 86 0x56 count of frames in a movie IMG_PIXEL_COUNT_LO 87 0x57 count of pixels in the current frame IMG_PIXEL_COUNT_HI 88 0x58 count of pixels in the current frame IMG CURRENT FRAME 89 0x59 last frame shown MEDIA ADDRESS LO 90 Ox5A uSD byte address LO MEDIA ADDRESS HI 91 Ox5B uSD byte address HI MEDIA SECTOR LO 92 Ox5C uSD sector address LO MEDIA SECTOR HI 93 Ox5D uSD sector address HI MEDIA SECTOR COUNT 94 Ox5E uSD number of bytes remaining in sector TEXT XPOS 95 Ox5F text current x pixel position TEXT YPOS 96 Ox60 text current y pixel position TEXT MARGIN 97 Ox61 text left pixel pos for carriage return TXT FONT TYPE 98 0x62 font type 0 system font else pointer to user font TXT FONT MAX 99 0x63 max number of chars in font TXT FONT OFFSET 100 0x64 starting offset normally 0x20 TXT_FONT_WIDTH 101 0x65 current font width TXT_FONT_HEIGHT 102 0x66 Current font height 2012 4D SYSTEMS Page 303 of 317 www 4dsystems com au ul c O Z LL T lt Z tV UJ Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS
194. ontrol function Example make a simple window gfx Panel PANEL RAISED 0 0 239 239 GRAY img SetPosition Ihndl BTN EXIT 224 2 set checkout box position img Enable Ihndl BTN EXIT enable checkout box 2012 4D SYSTEMS Page 275 of 317 www 4dsystems com au un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 2 img_Enable handle index Syntax img_Enable handle index Arguments handle index handle Pointer to the Image List index Index of the images in the list Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Enables a selected image in the image list Returns TRUE if index was ok and function was successful This is the default state so when img Show is called all the images in the list will be shown To enable all of the images in the list at the same time set index to 1 To enable a selected image use the image index number Example r img Enable hImageList imagenum 2012 4D SYSTEMS Page 276 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 3 img_Disable handle index Syntax img_Disable handle index Arguments handle index handle Pointer to the Image List i
195. op left position where the image will be displayed The arguments can be a variable array element expression or constant Returns nothing Description Displays an image from the media storage at the specified co ordinates The image address is previously specified with the media SetAdd or media SetSector function If the image is shown partially off screen it may not be displayed correctly Example while media Init 0 wait if no SD card detected media SetAdd 0x0001 OxDAO00 point to the books04 image media Image 10 10 gfx Clipping ON turn off clipping to see the difference media Image 12 50 show image off screen to the left media Image 50 12 show image off screen at the top repeat forever This example draws an image at several positions showing the effects of clipping un Z T Z em TE J D QO T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 142 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 12 media_Video x y Syntax media Video x y Arguments X y X y specifies the top left position where the video clip will be displayed The arguments can be a variable array element expression or constant Returns nothing Description Displays a video clip from the media storage device at the specified co ordinates The video address location
196. ord to the allocation if successful l RE If function fails returns a null 0 Description Allocate a block of memory to pointer myvar The allocated memory contains garbage but is a fast allocation The block must later be released with mem Free myvar Example myvar mem Alloc 100 un Z T Z em TE J D S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 288 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 2 mem AllocV size Syntax mem AllocV size Arguments size Byte size Specifies the number of bytes that s allocated from the heap Returns Value Returned value is the pointer Word to the allocation if successful Val SE If function fails returns a null 0 Description Allocate a block of memory to pointer myvar The block of memory is filled with initial signature values The block starts with A5 5A then fills with incrementing number eg A5 5A 00 01 02 03 FF 00 11 This can be helpful when debugging The block must later be released with mem Free myvar Example myvar mem AllocV 100 un Z T Z TE J D S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 289 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 3 mem_Allocz size Syntax mem_Allocz size Arguments size siz
197. ord to be written to the device The arguments can be a variable array element expression or constant Returns Status Status Device Ack Status Description Call this function to wait for a device to return an ACK during ACK polling The SDA is monitored for an Ack NB returns the state of SDA after the last clock pulse Previous Clock Pulse SCL X ____ SDA X Ack Status Example r I2C AckPoll 0xA0 send the control byte the wait for a device to return poll the device until an ACK is received un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 184 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 12 12C_Idle Syntax I2C Idle Arguments None Returns Status Status Device Ack Status Description Call this function to wait until the 12C bus is inactive NB wait for the bus to become idle SCL X X SDA X__X Example r i I2C Idle Wait until the I2C Bus is inactive un Z I T Z TE J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 185 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 12 13 I2C Gets buffer size Syntax I2C Gets buffer size Arguments buffer size buffer Storage for the string being read from the device Size Maximum siz
198. ormat colour un Z j T Z TE J T n m lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 113 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 35 gfx_Selection index backColour textColour Syntax gfx_Selection index backColour textColour Arguments index backColour textColour index 0 No Selection 1 to n Selected line to be highlighted backColour specifies the colour of the text background textColour specifies the colour of the text The arguments can be a variable array element expression or constant Returns nothing Description Called prior to drawing a text button with gfx Button this function will highlight a text line of a single or multi line button The required line is defined by index and the line will be highlighted with the desired backColour and textColour parameters If the index is O no line will be highlighted in the case of a single line button the index can only be 1 In the case of a multi line button the index corresponds to the line you wish to highlight This allows you to form the basic component for a listbox gfx Selection is persistent i e it does not auto disabled once the button is drawn so you must disable it when not required by issuing gfx Selection 0 0 0 The default condition is no selection Note that on platforms with no display buffering some flicker may be ex
199. ormatting controls This function is extremely useful in a loop to select multiple parameters from a data statement or a control array Note also that each function available for txt Set has a single parameter shortcut function that has the same effect see the Single parameter short cuts for the txt Set functions next page function value Predefined Name Description O TEXT COLOUR Set the text foreground colour Colour 0 65535 1 TEXT HIGHLIGHT Set the text background colour Colour 0 65535 2 FONT ID Set the required font O or FONT1 0 or FONT1 system font 1 or FONT2 2 Or FONT3 Default fonts 2 or FONT3 Note The value could be the name of a custom font included in a users program in a data statement See examples in the 4DGL Workshop3 IDE 3 TEXT WIDTH Set the text width multiplier 1 to 16 Default 21 4 TEXT HEIGHT Set the text height multiplier 1 to 16 Default 21 5 TEXT XGAP Set the pixel gap between characters The gap is in pixel units O to 32 Default 0 6 TEXT YGAP Set the pixel gap between lines The gap is in pixel units 0 to 32 Default 20 7 TEXT PRINTDELAY _ Set the delay between character printing Default Omsec 8 TEXT OPACITY Selects whether or not the background pixels are drawn O or TRANSPARENT default mode is OPAQUE 10r OPAQUE 9 TEXT BOLD Embolden text Oor 1 ON or OFF 10 TEXT ITALIC Italicise text O or 1 ON or OFF 11 TEXT INVERSE Inverted text Oor 1 ON or OFF 12 TEXT_UNDERLINED Underlined text O or 1
200. othing Description Plots lines between points specified by a pair of arrays using the specified colour The lines may be tessellated with the gfx_LinePattern function gfx Polyline can be used to create complex raster graphics by loading the arrays from serial input or from MEDIA with very little code requirement Wn z u Z zj TE J O D T J lt x Z v T Z Example inherit 4DGL 1 Sb LE Colours Enc wee Wel20 AO func main vx 0 36 vy 0 110 Well s S6e wy s Bop vx 2 50 vy 2 80 Wels se 507 wills iil s vx 4 76 vy 4 104 vx 5 85 vy 5 80 O vx 6 94 vy 6 104 Wn vx 7 76 vy 7 70 q vx 8 85 vy 8 76 LU vx 9 94 vy 9 70 We LLO 110 vy 10 66 DL vx 11 110 vy 11 80 wee LZ 1007 Vas s SO vx 13 120 vy 13 90 vx 14 110 vy 14 80 valls se Oise weis 70 vx 16 110 vy 16 76 wes w ge X192 wwiivy ase 70s house gfx Rectangle 6 50 66 110 RED rame gfx Triangle 6 50 36 9 66 50 YELLOW roof gfx Polyline 4 vx vy CYAN door man gfx Circle 85 56 10 BLUE head gfx Line 85 66 85 80 BLUE body 2012 4D SYSTEMS Page 87 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS gfx Polyline 3 vx44 vy 4 CYAN legs gfx Polyline 3 vx 7 vy 7 BLUE arms woman
201. perienced when drawing multiline buttons Example func main Wn Z U Z m TE J O D T x lt x Z a T Z Draw a button as a List Box sunken gfx Selection 3 RED YELLOW pre select Item3 gfx Button DOWN 30 30 GREEN WHITE FONT4 1 1 Ttem1 nItem2 nItem3 nItem4 repeat forever PICASO endfunc 2012 4D SYSTEMS Page 114 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 36 gfx_TriangleFilled x1 y1 x2 y2 x3 y3 colour Syntax gfx_TriangleFilled x1 y1 x2 y2 x3 y3 colour Arguments x1 y1 x2 y2 x3 y3 colour x1 y1 specifies the first vertices of the triangle x2 y2 specifies the second vertices of the triangle x3 y3 specifies the third vertices of the triangle colour Specifies the colour for the triangle The arguments can be a variable array element expression or constant Returns nothing Description Draws a Solid triangle between vertices x1 y1 x2 y2 and x3 y3 using the specified colour Vertices must be specified in an anti clockwise fashion Example gfx TriangleFilled 10 10 30 10 20 30 CYAN This example draws a CYAN Solid triangle with vertices at 10 10 30 10 20 30 un Z T Z TE J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 115 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIO
202. pression or constant wordConstList A comma separated list of constants to be matched against key Returns result result See description Description Search a list of 16 bit constant values for a match with a search value key If found the index of the matching constant is returned in result else result is set to zero Thus if the value is found first in the list result is set to one If second in the list result is set to two etc If not found result is returned with zero Note The lookup16 functions offer a versatile way for returning an index for a given value This is very useful for parameter input checking and where ever you need to check the validity of certain values The entire search list field can be replaced with a single name by using the operator in constant eg constant LEGALVALS 5 10 20 50 100 200 500 1000 2000 5000 10000 Example func main var key r key 5000 r lookupl6 key 5 10 20 50 100 200 500 1000 2000 5000 10000 r lookupl6 key LEGALVALS WENE print nSearch value 5000 nfound at index r else putstr nValue not found endif u z z Ti J O m T J lt x Z Y T Z josestiaue aig kal p 77 sub lee repeat forever endfunc PICASO 2012 4D SYSTEMS Page 301 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 3 PICASO EVE System Registers Memory Map The follo
203. print the stored string to the COM port wend repeat forever 2012 4D SYSTEMS Page 54 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 7 charwidth char Syntax charwidth char Arguments char char The ascii character for the width calculation Returns width width Returns the width of a single character in pixel units Description charwidth is used to calculate the width in pixel units for a string based on the currently selected font The font can be proportional or mono spaced If the total width of the string exceeds 255 pixel units the function will return the wrapped modulo 8 value Example SBS SSS SS SSS SSS SS SS SSS Example ssSs SS SS SS SS SS SS SS SS SS SS SS SSS SS SS SS SS SS SS SSS SSS SSS str HELLO nTHERE note that this string spans 2 lines due fi es eine Ven width strwidth str get the width of the string this will also capture the height height strheight note invoking strwidth also calcs height which we can now read The string above spans 2 lines strheight will calculate height correctly for multiple lines len strlen str the strlen function returns the number of characters in a string print nLength len NB the Mn in HELLO nTHERE is counted as a character txt FontID MS SanSerif8x12 select this font un Z
204. r Returns source Description Copy a block of memory from source to destination Note src can be a string constant eg myptr mem Copy TEST STRING ptr2 12 Example myptr mem Copy ptrl ptr2 100 un Z T Z Ti J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 296 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 19 9 mem_Compare ptr1 ptr2 count Syntax mem_Compare ptr1 ptr2 count Arguments ptr1 ptr2 count ptr1 specifies the 1st memory block ptr2 specifies the 2nd memory block count specifies the number of bytes to compare Returns Value Returns 0 if we have a match 1 if ptr1 lt ptr2 and 1 if ptr2 gt ptr1 Value The comparison is done alphabetically Description Compare two blocks of memory ptr1 and ptr2 Example test mem Compare this block that block 100 un Z I T Z Ti J T n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 297 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 20 General Purpose Functions Summary of Functions in this section e pause time e lookup8 key byteConstList e lookup16 key wordConstList un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 298 of 317 www 4dsystems com au
205. r occurred else returns 0 Description If any low level errors occur during the buffering service such as framing or over run the internal COM_ERROR flag will be set which can be read with this function Example alie ecm Beror O if there were low level comms errors resetMySystem take corrective action endif un Z I T Z em TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 166 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 10 com_Sync Syntax com_Sync or com1_Sync Arguments none Returns status status Returns 1 if the qualifier character has been received else returns 0 Description If a qualifier character is specified when using buffered communications after the buffer is initialized with com_Init the service will ignore all characters until the qualifier is received and only then initiate the buffer write sequence with incoming data com Sync is called to determine if the qualifier character has been received yet Example com Sync reset to polled mode un Z T Z Ti J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 167 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 11 com_TXbuffer buf bufsize pin Syntax com_TXbuffer buf bufsize pin or com1_TXbuffer buf bufsize pi
206. rameter and returns a 1 if the character is any one of the space type character else returns a 0 Valid range space formfeed newline carriage return tab vertical tab Example poucuoNcCoONP EPI un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 70 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 9 toupper char Syntax toupper char Arguments char char Specifies the ASCII character for the test Returns Char ABCD WXYZ If character is lower case letter Char char If character is not a lower case letter Description Tests the character parameter and if the character is a lower case letter it returns the upper case equivalent else returns the passed char Valid range abcd wxyz Example func main var ch Upconvch Loconvch Welle etet gfx Cls txt Set FONT ID FONT2 print Serial Input Testin print Download prog to flash n print Then use debug terminal Nn to COMO print serial input test n now just stay in a loop repeat ch serin if ch 1 printi CHIR cla g if a key was received from PC print its ascii value if isupper ch print Uppercase ASCII found Converting to lowercase Loconvch tolower ch endif if islower ch print Lowercase ASCII found Converting to Uppe
207. rameter short cuts for the gfx_Set functions T below 38 function value T Predefined Name Description o PEN_SIZE Set the draw mode for gfx LineTo gfx LineRel gfx_Dot 0 or SOLID gfx Bullet and gfx BoxTo default mode is OUTLINE 1 or OUTLINE J nb pen size is set to OUTLINE for normal operation BACKGROUND COLOUR _ Set the screen background colour Colour 0 65535 a OBJECT_COLOUR Generic colour for gfx LineTo gfx LineRel gfx Dot Colour 0 65535 gfx Bullet and gfx BoxTo Z CLIPPING Turns clipping on off 1 or 0 ON or OFF Vv The clipping points are set with gfx_ClipWindow UJ TRANSPARENT COLOUR Colour that needs to be made transparent Colour 0 65535 TRANSPARENCY Turn the transparency ON or OFF 1 or 0 ON or OFF FRAME DELAY Set the inter frame delay for media Videoy 0 to 255msec SCREEN MODE Set required screen behaviour orientation 1 or LANDSCAPE Q 2 or LANDSCAPE R Uu Note Does not apply to uVGA II GFX module 3 or PORTRAIT q 4 or PORTRAIT R LJ OUTLINE_COLOUR Outline colour for rectangles and circles Colour 0 65535 C set to O for no effect a CONTRAST OLED MODULES 0 or OFF Set contrast value O display off 1 9 contrast level 1 to 9 for levels LCD MODULES contrast 0 display OFF non zero display ON 1 or 0 ON or OFF EXCEPTION uLCD 43 GFX supports Contrast values from 1 9 and O to turn the Display off Note Does not apply to uVGA II GFX module BEVEL WIDTH Set Button Bevel W
208. rcase Upconvch toupper ch endif un Z T c zm TE J D T 2 q Z Y TT Z endif PICASO forever endfunc 2012 4D SYSTEMS Page 71 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 10 tolower char Syntax tolower char Arguments char char Specifies the ASCII character for the test Returns Status abcd wxyz If character is upper case letter Status char If character is not a upper case letter Description Tests the character parameter and if the character is a lower case letter it returns the upper case equivalent else returns the passed char Valid range ABCD WXYZ Example Refer to Sec 2 5 9 un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 72 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 11 LObyte var Syntax LObyte var Arguments var var User variable Returns byte byte Returns the lower byte lower 8 bit of a 16 bit variable Description Returns the lower byte lower 8 bit of a 16 bit variable Example myvar LObyte myvar2 un Z T Z em TE J D T S q Z Y TT Z PICASO 2012 4D SYSTEMS Page 73 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTION
209. rd and backwards with time left for other tasks as well A number of videos or animated icons can be shown simultaneously using this method var framecount frame delay colr frame 0 show the first frame so we can get the video header info into the system variables and then to our local variables media VideoFrame 30 30 0 framecount peekW IMG FRAME COUNT we can now set some local values delay peekB IMAGE DELAY get the frame count and delay repeat repeat pokeW TIMERO delay set a timer 2012 4D SYSTEMS Page 144 of 317 www 4dsystems com au un Z T Z TE J D E lt x Z Y TT Z PICASO 4D SYSTEMS media VideoFrame 30 30 frame t gfx MoveTo 64 35 print DEC2Z frame gfx MoveTo 64 85 print DEC2Z framecount frame if frame amp 3 0 gfx CircleFilled 80 20 2 colr colr colr OxF800 endif do more here if required while peekW TIMERO until frame peekW IMG FRAME COUNT frame 0 forever media VideoFrame 30 80 framecount PICASO INTERNAL 4DGL FUNCTIONS show next frame print the frame number frame show movie backwards print the frame number a blinking circle fun alternate colour BLACK RED using XOR wait for timer to expire 2012 4D SYSTEMS Page 145 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 9 Flash Memory Ch
210. ress Source memory block of 512bytes The arguments can be a variable array element expression or constant Returns Returns TRUE if media response was TRUE Writes 512 bytes 256 words from a source memory block eg wrblock 256 into the uSD card Description After the write the Sect pointer is automatically incremented by 1 Returns TRUE if uSD response was TRUE Example var wrblock 256 TNE ee prepare block media SetSector 0 10 if media WrSector wrblock Print Data transferred endif This example sets a 512 bytes block and transfers data to the address pointed to by media SetSector command un Z T c Ti J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 136 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 8 6 media_ReadByte Syntax media_ReadByte Arguments none Returns byte value Description Returns the byte value from the current media address The internal byte address will then be internally incremented by one Example var LObyte HIbyte if media Init media SetAdd 0 510 LObyte media ReadByte HIbyte media ReadByte print HEX2 HIbyte HEX2 LObyte endif repeat forever This example initialises the media sets the media byte address to 510 and reads the last 2 bytes from sector O If the card happens to be FAT formatted the result will
211. ress of the pointer must be passed so the function can advance it if required Example var buffer 100 200 character buffer for a source string var p q string pointers var mny func main un Z T c zm TE J T n 2 q Z Y TT Z iuo owWtitese p priar V volres 240 jay sitieding tO PErTSS p str Ptr buffer string pointer to be used with string functions q p if n str Match amp p volts Sis Primi to Uwe Jy print remainder of string else peime mwexe ifxuelym g OQ endif Uu print startpos q Mnfindpos n Mnendpos p q endfunc 2012 4D SYSTEMS Page 258 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 11 str Matchl amp ptr str Syntax str Matchl amp ptr str Arguments ptr str ptr Address of byte pointer to string buffer str Pointer string to match Returns Value Returns 0 if no match else advance ptr to the next position after the match Val MS and returns that value Description Case Insensitive match Compares the string at position ptr in a string buffer to the string str skipping over any leading spaces if required If a match occurs ptr is advanced to the first position past the match else ptr is not altered NB The address of the pointer must be passed so the function can advance it if required Example v
212. returned with zero Note The list of constants cannot be re directed The lookup8 functions offer a versatile way for returning an index for a given value This can be very useful for data entry filtering and parameter input checking and where ever you need to check the validity of certain inputs The entire search list field can be replaced with a single name if you use the operator in constant eg constant HEXVALUES 0123456789ABCDEF Example func main var key r key a 2 ge legisse kev OD eleg 2 4 5 print NnSearch value a nfound as index r key 5 we ge egg kay xD Weile 2 m yp print NnSearch value 5 nfound at index r PUESIE VANSE ra a o Wal p un z T Z m TE J T m J q z Y TT lt key 12000 we will count from 12000 to 12000 only the hex ascii values will give a match value while key lt 12000 r lookup8 key 0123456789ABCDEF hex lookup if r print HEX1 r 1 only print if we got a match in the table PICASO keyctt wend repeat forever endfunc 2012 4D SYSTEMS Page 300 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 20 3 lookup16 key wordConstList Syntax lookup16 key wordConstList Arguments key wordConstList key A word value to search for in a fixed list of constants The key argument can be a variable array element ex
213. rol for com TXbuffer function Example Refer to the com TXemptyEvent functionAddress example 2012 4D SYSTEMS Page 169 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 13 com_TXcount Syntax com_TXcount or com1_TXcount Arguments None Returns count count Returns count of characters Description Return count of characters remaining in COMO or COM1 transmit buffer that was previously allocated with com TXbuffer or com1 TXbuffer Example arg comi TXCount return count of characters in COM1 TX buffer un Z T Z TE J D I 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 170 of 317 www 4dsystems com au un z fees T Z m TE J T m J q Z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 11 14 com_TXemptyEvent function Syntax com TXemptyEvent functionAddress or com1 TXemptyEvent functionAddress Arguments functionAddress fu ctionAddr Address of the Function to be called when COMO TX buffer empty ess Returns Address Returns any previous event function address or zero if there was no previous Address function Description If a comms TX buffer that was previously allocated with com TXbuffer or com1_TXbuffer this function can be used to set up a function to be
214. rror Arguments None Returns Error Code ERROR Error Code ERROR CODE NUMBER ERROR DESCRIPTION tine ennon PI me FE NOT PRESENT 2 i FEPARTTION Tver a RONG parion ape nor farie SES INVALID MER Boot Record invalid i nature FE_INVALID_BR 5 Media notinointad s FE_MEDIA_NOT_MINID i Ei iof n i n for read FE_FILE_NOT_FOUND 7 ini M a se i ae FE_INVALID_FILE 8 Fat attempt to read beyond EOF FE FAT EO 9 s CE Reached the end of file FE_EOF B Invalid cluster value gt maxcls FE_INVALID_CLUSTER 11 R a All root dir entry are taken FE_DIR_FULL ua All clusters in partition are taken FE MEDIA_FULL E e A a FE_FILE_OVERWRITE a c a si p Nu Variance FE CANNOT INIT 15 Mene d T did FE CANNOT READ MERE 1e lioe er iat allocate the FILE MALLOC FAILED 17 str ct FE INVALID MODE WE durae quaes FE FIND ERRBR 2 Failure durin FILE search FE_INVALID_FNAME D etn B FE INVALID MEDIA AD d Pu ams FE_SECTOR_READ_FAIL 22 E den FE SECTOR WRITE FAIL 23 I a E B Sector write fail Description Returns the most recent error code or O if there were no errors Example e file Error 2012 4D SYSTEMS Page 202 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 2 file_Count filename Syntax file_Count filename Arguments filename filename Name of the file s for the search passed as a string Returns Count Count Number of files that match the criteria De
215. s The result of the subtraction is returned Example var carry valA 2 valB 2 Result valA 0 0 valA 1 OxFFFF valB 0 0 valB 1 OxEFFF Result cmp 3232 valA valB vall gt val2 print Result repeat forever This example will print 1 un Z I T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 43 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 Text and String Functions Summary of Functions in this section e txt MoveCursor line column e putch char e putstr pointer e putnum format value e print e to outstream e charwidth char e charheight char e strwidth pointer e strheight e strlen pointer e txt Set function value txt Set shortcuts e txt FGcolour colour e txt BGcolour colour e txt FontlD id e txt Width multiplier e txt Height multiplier e txt Xgap pixelcount e txt Ygap pixelcount e txt Delay millisecs e txt Opacity mode e txt Bold mode e txt Italic mode e txt Inverse mode e txt Underlined mode e txt Attributes value e txt Wrap un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 44 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 4 1 txt MoveCursor line column Syntax txt MoveCursor line column Arguments line column line Holds a posit
216. s a rectangle from the current origin to the new point using the current object colour The top left corner is anchored by the current origin x1 y1 the bottom right corner is specified by x2 y2 Note The default PEN SIZE is set to OUTLINE however if PEN SIZE is set to SOLID the rectangle will be drawn filled if PEN SIZE is set to OUTLINE the rectangle will be drawn as an outline If the circle is drawn as SOLID the outline colour can be specified with gfx OutlineColour If OUTLINE COLOURiis set to O no outline is drawn Example gfx MoveTo 40 40 n 10 warile m gfx_BoxTo 50 50 gfx BoxTo 30 30 wend This example draws 2 boxes anchored from the current origin un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 103 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 26 gfx_SetClipRegion Syntax gfx_SetClipRegion Arguments none Returns nothing Description Forces the clip region to the extent of the last text that was printed or the last image that was shown Example un Z T Z TE J D QO 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 104 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 27 gfx_Ellipse x y xrad yrad colour Syntax gfx_Ellipse x y xrad yrad colour Argu
217. s is rather useful jug p str Ptr buffer raise a string pointer so we can use the un Z T c zm TE J D 2 q Z Y TT Z string functions p p 13 offset into the buffer a little so we don t see word Q way t oriol pe n i p Vala je show the start point of our search U ik Se 07 a while n 4 A prine NU X STR Siteimegs iim X is at pos p sux Pind amp p strings n An wend print nNOTE p is unchanged p p note that p is unchanged endfunc 2012 4D SYSTEMS Page 260 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 13 str Findl amp ptr str Syntax str Findl amp ptr str Arguments ptr str ptr Byte pointer to string buffer str String to find Returns Value Returns 0 if not found Val ne ere ane Returns the position of the find if successful Description Case Insensitive Searches for string str in string buffer pointed to by ptr NB The pointer ptr is not altered Example var buffer 100 200 character buffer for a source string var p string pointer var n var strings 4 for our test strings func main txt Set FONT ID FONT2 strings 0 useful strings 1 string Sering si Dn E RA strings 3 class to buffer print and by the way the string class is rather useful jug p str Ptr
218. scription Returns number of files found that match the criteria The wild card character matches up with any combination of allowable characters and matches up with any single allowable character Example count file Count 4XE Returns number of files with 4XE un Z I T c TE J T n T J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 203 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 3 file_Dir filename Syntax file_Dir filename Arguments filename filename Name of the file s for the search passed as a string Returns Count Count Number of files found that match the criteria Description Streams a string of file names that agree with the search key Returns number of files found that match the criteria The wild card character matches up with any combination of allowable characters and matches up with any single allowable character Example count g file Dir 4XE Returns number of files with 4XE un Z I T c TE J T n J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 204 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 4 file_FindFirst fname Syntax file_FindFirst fname Arguments fname fname Name of the file s for the search passed as a string Returns
219. secedbulaseeertenteds 26 2 2 2 pokeW address word value cccccesecssecsssceescecseceeseecaececeeecaeeseeeecaecseeeecueceeeeecaeseeeeessaeseeeees 27 PM Maths FUNCTIONS e 28 piE MEDIUS 29 2 3 2 MIN Vallied val WEZ m inimsese aiiai aiaiai di iE ni ais 30 2 3 3 P RUIETUSERTCIULVAtL a 31 2 3 4 SWAP amp var1 amp var2 e iiaeaae iniae adei aiee rarena aia aeania Eo E aE 32 PAREEN EI A E E E AA E E A AEAEE E 33 2 3 6 COS ANElE nenede eenia n dee eT a ia laea ie ides araa A 34 PAE ATANI O 35 pins ME 36 pu acobsrnbIi CST E ia 37 MOM TUE 38 Pe P E EA T 39 2 3 12 umul_1616 amp res32 Vall val2 ceeccsscccsscccseecsseceseecsesessseeceeesecsseceeescseecseeeseseeceaeeseseecseeesenees 40 2 3 13 uadd 3232 amp res32 amp val1 amp val2 esisi irsinin eneiniad enne ernst 41 2 3 14 usub 3232 amp res32 amp val1 amp val2 esesseseseeseeee eene nennen nnne nennen nnne nnne nennen nnns 42 2 3 15 ucmp 3232 amp val1 SiVal2 cicicacscssrceecetwcrievsdecdeiscucseassovesstacnstavesonchecvivvedeoversateedsliedestanest TREO REPRE 43 2 4 Text and String Functions iiie eet there teorie retira eee ea EEN ri an Fue Po read arabe eae EUH R ER PUR an 44 2 4 1 txt MoveCursor line column essere nnne enn nnne enne nennen innen 45 DAD UTC CMAN 4er eire oe entere tet fede t
220. sh buttons reset the button states vButtonState n UP vOldButtonState n UP place a button gfx Button BUTTON UP x1 yl btncolor textcolor font 1 1 buttontexts n get the bottom right extent AZ Be gnis fem deir IPOS p y2 gfx Get BOTTOM POS register the button position touchX1 n xl touchYl n yl touchX2 n x2 Touch ml se wg yl y2 ygap move down next EOmEIDCAL in S sep finally register exit button position touchYl n y touchX2 n x 20 touchY2 n y 20 vButtonState n UP vOldButtonState n UP title NO NAME set default title bar text statusbartext status set default status bar text un c js T Z TE J T J q z Y TT Z gosub RedrawStatusBar gosub RedrawTitleBar Do any other initializions here PICASO endsub jaa a a a CMM MM ROM RU RE Update status bar text oa erie ict wisn initiaited A RedrawStatusBar txt FontID FONT1 txt FGcolour statustextcolor txt BGcolour statusbarcolor gfx MoveTo xpost8 ypostwindowHeight 8 putstr statusbartext set the status bar text endsub ff sos SSS SS SS SS SS SS SSS Update status bar text OE PSS SSS SS SS SS SS SS SS SS SS SS SS SS SS SS SSS SSS SSS SSS SSSS RedrawTitleBar txt FontID FONT2 txt FGcolour titletextcolor txt BGcolour titlebarcolor 2012 4D SYSTEMS Page 308 of 317 www 4dsystems com au
221. ss and release buttons and much more All without writing a single line of code ViSi Genie provides the user with a feature rich rapid development environment second to none enr ies Bats Gm _ ie n 5 7 4 Workshop 4 Serial Environment The Serial environment in the Workshop 4 IDE provides the user the ability to transform the PICASO Processor into a slave serial graphics processor This enables the user to use their favourite microcontroller or serial device as the Host without having to learn 4DGL or program in a separate IDE Once the PICASO is configured and downloaded to from the Serial Environment simple graphic commands can be sent from the users host microcontroller to display primitives images sound or even video www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS Refer to the Serial Environment section in the Workshop 4 user manual for a complete listing of all the supported serial commands Workshop 4 IDE User Manual pdf Fle Eat Vew Took Project Optons About ALE oed Kel WN O U Z u QO gt lt Z Vv W lt PICASO 2012 4D SYSTEMS Page 314 of 317 www 4dsystems com au un z LJ Z m TE J T m T J q z Y TT Z PICASO 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 8 Revision History Revision Revision Content Revision Date
222. stems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 24 gfx_LineRel xpos ypos Syntax gfx_LineRel xpos ypos Arguments Xpos ypos xpos specifies the horizontal end point of the line ypos specifies the vertical end point of the line The arguments can be a variable array element expression or constant Returns nothing Description Draws a line from the current origin to a new position The line is drawn using the current object colour The current origin is not altered The line may be tessellated with the gfx_LinePattern function Example gfx LinePattern 0b1100110011001100 gfx MoveTo 10 20 giz Linekel S0 S0 p This example draws a tessellated line using the current object colour between 10 20 and 50 50 Note that gfx LinePattern 0 must be used after this to return line drawing to normal solid lines un Z T Z em TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 102 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 25 gfx_BoxTo x2 y2 Syntax gfx_BoxTo x2 y2 Arguments x2 y2 x2 y2 specifies the diagonally opposed corner of the rectangle to be drawn the top left corner assumed to be x1 y1 is anchored by the current origin The arguments can be a variable array element expression or constant Returns nothing Description Draw
223. systems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS pause 2000 pause 3000 gis Che 2 Hace n 0 while n lt img IMG COUNT amp amp exit go through all images CheckTouchExit if there s a press exit img SetPosition img n ABS RAND 240 ABS RAND 320 spread out the images ntt wend img Show img ALL update the entire control in 1 hit until exit quit mem Free img release the image control file Unmount program must release all resources return r endfunc un Z T Z TE J D T J q Z Y TT Z PICASO 2012 4D SYSTEMS Page 236 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 29 file_Mount Syntax file_Mount Arguments None Returns Status Status Returns true if successful Description Starts up the FAT16 disk file services and allocates a small 20 byte control block for subsequent use When you open a file using file_Open a further 512 44 556 bytes are attached to the FAT16 file control block When you close a file using file_Close the 556 byte allocation is released leaving the 20 byte file control block The file_Mount function must be called before any other FAT16 file related functions can be used The control block and all FAT16 file resources are completely released with file_Unmount Example ad l
224. t corner of the region yl specifies the vertical position of the top left corner of the region x2 specifies the horizontal position of the bottom right corner of the region y2 specifies the vertical position of the bottom right corner of the region Returns None Description Specifies a new touch detect region on the screen This setting will filter out any touch activity outside the region and only touch activity within that region will be reported by the status poll touch Get 0 function un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 271 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 17 2 touch_Set mode Syntax touch_Set mode Arguments mode mode mode 0 Enable Touch Screen touch Set 0 Enables and initialises Touch Screen hardware mode 1 Disable Touch Screen touch Set 1 Disables the Touch Screen Note Touch Screen task runs in the background and disabling it when not in use will free up extra resources for 4DGL CPU cycles mode 2 Default Touch Region touch Set 2 This will reset the current active region to default which is the full screen area Returns None Description Sets various Sets various Touch Screen related parameters Example touch Set TOUCH ENABLE un Z T Z Ti J D I 2 q Z Y TT Z PICASO
225. t load the function un Z T Z m TE J T T J q z v TT lt then elsewhere in your program res popupWindow MYMODE titlestring textstring if res QUIT APPLICATION goto exitApp Later in your program when popupWindow is no longer required for the application PICASO res mem Free popupWindow if res goto FreeFunctionFailed should never happen if memory not corrupted Example2 var fncHandle a var for a handle to sliders2 4dg var slidervals reference var to access global vars in sliders 4dg fncHandle file LoadFunction sliders2 4xe load the function slidervals fncHandle amp 0Ox7FFF note that memory allocations for transient programs are biased with 8000h which must be removed slidervyalstt mote that all globals start ar i slidervals 0 25 set sliders to initial positions slidervals 1 20 slidervals 2 30 slidervals 3 15 slidervals 4 35 slidervals 5 20 2012 4D SYSTEMS Page 226 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS slidervals 6 40 slidervals 7 25 slidervals 8 45 slidervals 9 5 r fncHandle activate the function print Return value Ox HEX r n print the values they may have changed igxesbaue YS acer Slidervals 0 Slider print Slider slidervals 2 Slider print Slider slidervals 4 Slider print Sl
226. te result is stored in the variables that were specified with the gfx Orbitlnit function Description Sets Prior to using this function the destination address of variables for the calculated coordinates must be set using the gfx Orbitlnit function The gfx Orbit function calculates the x y coordinates of a distant point relative to the current origin where the only known parameters are the angle and the distance from the current origin The new coordinates are calculated and then placed in the destination variables that have been previously set with the gfx Orbitlnit function Example Wesue uUo Teu e gfx OrbitInit amp targetX amp targetY gfx MoveTo 30 30 gfx Bullet 5 mark the start point with a small WHITE circle gfx Orbit 30 50 calculate a point 50 pixels away from origin at 30 degrees gfx CircleFilled targetX targetY 3 0xF800 mark the target point with a RED circle See example comments for explanation 2012 4D SYSTEMS Page 94 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 17 gfx_PutPixel x y colour Syntax gfx_PutPixel x y colour Arguments x y colour X y specifies the screen coordinates of the pixel colour Specifies the colour of the pixel The arguments can be a variable array element expression or constant Returns nothing Description Draws a pixel at position x y using the specified colo
227. te of the bus un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 20 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 6 bus_Out arg Syntax bus_Out arg1 Argument arg arg A value usually a constant specifying the pin number The arguments can be a variable array element expression or constant Returns Nothing Description The lower byte of the argument is placed on the 8bit wide bus The upper byte of the argument is ignored Note The BUS_RD and BUS_WR pins are not affected Any BUS pins that are set to inputs are not affected Example Var temp temp 0x0015 bus Out temp Set the Bus output un Z j T c zm TE J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 21 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 1 7 bus_Set arg Syntax bus_Set arg1 Arguments arg arg A value usually a constant specifying the pin number 1 sets a pin to be an input 0 sets a pin to be output The arguments can be a variable array element expression or constant Returns Nothing Description The lower 8 bits of arg1 are placed in the BUS direction register a 1 sets a pin to be an input a 0 sets a pin to be output The upper 8 bits of arg1 are ignored The BUS RD and BUS WR pins are
228. the destination for the putch putstr putnum and print functions Predefined Name Constant putch putstr putnum print redirection APPEND 0x0000 Output is appended to user array if previous redirection was to an array TEXT OxF801 Output is directed to the screen default DSK OxF802 Output is directed to the most recently open file that has been opened in write mode COMO OxFF04 Output is redirected to the COMO default serial port COM1 OxFFO8 Output is redirected to the COM1 auxilliary serial port 12C OxF820 Output is directed to the I2C port Output is directed to the SD SDHC or FLASH media MDA OxFF40 Warning be careful writing to a FAT16 formatted card without checking legal partitioned are else the disk formatting will be destroyed memory pointer Array address Output is redirect to the memory pointer argument Returns nothing Description to sends the printed output to destinations other than the screen Normally print just sends its output to the display in TEXT mode which is the default however the output from print can be sent to streams eg COMO or COMI an open FAT16 file with DSK to raw media with MDA media or to the I2C port with I2C The to function can also stream to a memory array Note that once the to function has taken effect the stream reverts back to the default stream which is TEXT as soon as putch putstr putnum or pr
229. to be changed within the clipping window specifies the new colour to change all occurrences of old colour within the newColour clipping window The arguments can be a variable array element expression or constant Returns nothing Description Changes all oldColour pixels to newColour within the clipping area Example func main txt Width 3 txt Height 5 gfx MoveTo 8 20 jexealae ape p e print the string gfx SetClipRegion force clipping area to extents of text Jf eec jcilineSsel gfx ChangeColour BLACK RED test change of background colour repeat forever endfunc This example prints a test string forces the clipping area to the extent of the text that was printed then changes the background colour un Z T Z em TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 79 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 3 gfx_Circle x y radius colour Syntax gfx_Circle x y rad colour Arguments x y rad colour x y specifies the center of the circle rad specifies the radius of the circle colour specifies the colour of the circle The arguments can be a variable array element expression or constant Returns nothing Description Draws a circle with centre point x1 y1 with radius r using the specified colour NB The default PEN
230. tton in DOWN state redraw buttoncount f 10 80 w 0 draw any button down states endif endif if state TOUCH RELEASED if there s a release if keyval vButtonState keyval 1 UP restore the buttons UP state redraw buttoncount f 10 80 w 0 draw any button up states sendkey do something with the key data keyval 0 because prog main prog gave up all its allocations for file Exec we have lost our file mount info and the directory list so we must re establish these to be able to continue A better approach to ensure total stability for the main program is to reset the system with SystemReset systemReset restart the main program ox goto redo re mount disk reload filenames endif endif forever mem Free filenames no need to release buffer this prog is in flash and never file Unmount Ji auo endfunc 2012 4D SYSTEMS Page 232 of 317 www 4dsustems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 27 file_Exec fname 4XE arglistptr Syntax file Exec fname AXE arglistptr Arguments fname 4XE arglistptr fname 4XE Iname of the 4DGL child program to be loaded into RAM and executed arglistptr pointer to the list of arguments to pass to the new program or O if no arguments Returns Value Value Returns the value from main in the called program Description This funct
231. turn value points to the last source position and is returned for processing by other string functions print structure elements example make a demo structure n 0 m n Mrs Smith muse 2e ZOO p m n 300 mint aS OxAA5 5 m nt 500 make a demo format control string Sks nSd nsd ns01l6b n s04xX format string for printing structure m format print the structure in the required format jo ge Ste Pee im s Il poine to Structure m str_Printf amp p format use the format string to print the StUP5u cturbe endfunc 2012 4D SYSTEMS Page 264 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 16 16 str_Cat amp destination amp source Syntax str_Cat amp destination amp source Arguments destination source destination Destination string address source Source string address Returns Pointer Pointer Returns pointer to the destination Description Appends a copy of the source string to the destination string The terminating null character in destination is overwritten by the first character of source and a new null character is appended at the end of the new string formed by the concatenation of both in destination Example str Cat amp buf Hello Will append buf with Hello un Z T Z Ti J D 2 q Z Y TT Z
232. ueue sys_EventsPostpone sys_EventsResume sys Sleep units iterator offset 2 14 FAT16 File Functions file Error file Count filename file Dir filename file FindFirst fname file FindNext file Exists fname file Open fname mode file Close handle file Read destination size handle file Seek handle HiWord LoWord file Index handle Hisize Losize recordnum file Tell handle amp HiWord amp LoWord file Write Source size handle file Size handle amp HiWord amp LoWord file Image x y handle file ScreenCapture x y width height handle file PutC char handle file GetC handle file PutW word handle file GetW handle file PutS source handle file GetS String size handle file Erase fname file Rewind handle file LoadFunction fname AXE file Run fname 4XE arglistptr file Exec fname 4XE arglistptr file LoadlmageControl fname1 fname2 mode file Mount file Unmount file PlayWAV 2 15 Sound Control Functions Snd Volume var Snd Pitch pitch Snd_BufSize var Snd_Stop Snd_Pause Snd_Continue Snd_Playing 2 16 String Class Functions str_Ptr amp var str_GetD amp ptr amp var str_GetW amp ptr amp var str_GetHexW amp ptr amp var 2012 4D SYSTEMS Page 13 of 317 PICASO INTERNAL 4DGL FUNCTIONS www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS str GetC amp ptr amp var str GetByte ptr e str GetWord
233. ui eoeer sie tnus ee EET Ea aAa eeo sse t aE aE aaae EA 46 2 AS DUTtSEFLDOIDIEOT EAEE E eE Pemex te rte dpne oe Mie Tor ertet EEE AA 47 24 4 putnum format VALUE ieri ero ese ient eget etre Exe pex head ebur veo goce ERR Ee iiiaae aaia 49 2 4 5 DFIDt s tette ter eoe tes tbe ee dore EE ob EE eue e R HERRERA RezN E ue TR E Resa REA RE REEL NN E Fe Pe REN RS 51 2 4 6 to outstream idcirco eter REF DH a vere dU KE Ve Re VERTO Re ERE Were Ree eap e FEM REEL Eia 53 2447 charwidth char Geor ta charus aeneo en euet repeat keen Varna ce hr AA A eue PH ERE pao s 55 24 8 charherghit Chas tocco packt ess aene nh i reno eaa Rusa ees Nensassbicaisnssdiaetanses sicncavaedsvebiccsens i AEE 56 2 4 9 strwidth pOInter e oiii etuer ede erii eo er inet PE ETC ente te nee eR dne raa e Fox Eas men tma PRAET dee YU E RERR ni 57 VI Neto M A NE eA 0 REEL TET P 58 2 4 11 strlen pointer iie Liens enitn rape eher eL a Ras end co EE Rae RR Ae kd ER eE KR EXERSR ARE E NEERUR Rex Ra a RS 59 24 12 txt Set function value erri cicero rne raa aire aaa Fea Ta RV FRa a WEN REGE RETE 60 u Z u Z TE J O m J lt x z a T lt PICASO 225s Ctype FUNCTIONS EMT 62 2 6 2 5 1 Isdigit Chal oett etra teta he detenta ae tantae hr aecotn sa ene ETEA T casas 63 PASSENT y Co Id e DES REPERTUS EE CODI EDO EID METER MEET 64 2 5 3 Isupper ChiaE
234. umb is set to the position that is the proportion of value to the scale parameter used to set the control to the actual value of a variable 2b If value is negative thumb is driven to the graphics position set by the ABSolute of value value used to set thumb to its actual graphical position usually by touch screen 3 The thumb colour is determine by gfx Set OBJECT COLOUR value however if the current object colour is BLACK a darkened shade of the colour parameter is used for the thumb func drawRedSlider gfx Slider 0 rSlider 0 rSlider 1 rSlider 2 rSlider 3 RED 255 valR txt _MoveCursor 1 12 txt Set TEXT OPACITY OPAQUE txt Set TEXT COLOUR RED oime UU E txt MoveCursor 1 12 pexesuaE DDISNCT weeds g endfunc 2012 4D SYSTEMS Page 11O of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 32 gfx_ScreenCopyPaste xs ys xd yd width height Syntax gfx ScreenCopyPaste xs ys xd yd width height Arguments Xs ys xd yd width height XS ys Specifies the horizonal and vertical position of the top left corner of the area to be copied source xd yd Specifies the horizontal and vertical position of the top left corner of where the paste is to be made destination width Specifies the width of the copied area height Specifies the height of the copied area The arguments can be a variable array element expression or constant
235. uments handle index handle Pointer to the Image List index Index of the images in the list offset Offset of the required word in the image entry word The word to be written to the entry Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Set specified word in an image entry Returns TRUE if successful return value usually ignored IMAGE XPOS 2 WORD image location X IMAGE YPOS 3 NORD image location Y IMAGE FLAGS 6 NORD image flags IMAGE DELAY 7 WORD inter frame delay IMAGE INDEX 9 WORD current frame IMAGE TAG 12 WORD user variable 1 IMAGE TAG2 13 WORD user variable 2 Note Not all Constants are listed as some are Read Only Wn Z U Z m TE J O D T x lt x Z a T Z img Show will now show error box for out of range video frames Also if frame is set to 1 just a rectangle will be drawn in background colour to blank an image It applies to PmmC R29 o or above ul lt Example FUNE CEE UJ var private frame 0 start with frame 0 var private image SPRITE CAT cat image can be changed with Q cat image xxx var private speed 30 img SetWord Ihndl image IMAGE INDEX framet t frame frame img GetWord Ihndl image IMAGE FRAMES img Show Ihndl image sys SetTimer TIMER3 speed reset the event ti
236. unctions spi Init speed input mode output mode spi Read Spi Write byte spi Disable 2 11 Serial UART Communications Functions setbaud rate e com SetBaud comport baudrate 10 e serin or serin1 serout char or serout1 char e com Init buffer buffsize qualifier or com1 Init buffer buffsize qualifier com Reset or com1 Reset com Count or com1 Count e com Full or com1 Full com Error or com1 Error e com Sync or com1 Sync com TXbuffer buf bufsize pin or com1_TXbuffer buf bufsize pin com TXcount or com1 TXcount com TXemptyEvent function or com1 TXemptyEvent function 2 12 12C BUS Master Function e func 12C_Open Speed e func 12C_Close e func 12C_Start e func 12C_Stop e func 12C_Restart e func 12C_Read e funcl2C Write byte e func 12C_Ack e func 12C_Nack e func 12C_AckStatus e func 12C_AckPoll control e func 12C_Idle e func 12C_Gets buffer size e func 12C_Getn buffer size e func 12C_Puts buffer e func 12C_Putn buffer count uU Z O U z TE a D e T A q Z a T Z PICASO 2 13 Timer Functions Sys T Sys T HI Sys SetTimer timernum value Sys GetTimer timernum 2012 4D SYSTEMS Page 12 of 317 www 4dsystems com au T Z V c m Ti J T J q z Y TT Z PICASO 4D SYSTEMS sys_SetTimerEvent timernum function sys_EventQ
237. ur essere enne ener nnne ernst nnn sensere nnns 83 2 6 7 gfx Vline x y1 y2 colour esses eene enne ernst nn ntes etes enne nnns 84 2 6 8 gfx Rectangle x1 y1 x2 y2 colour enne nennen enne nennen nennen nnne 85 2 6 9 gfx RectangleFilled x1 y1 x2 y2 colour nre 86 2 6 10 gtx Polyline n vx Vy Colour i rennen aaaea rasa eR cesses saachessvaeebessnacenceoes 87 2 6 11 gfx Polygon n vx vy colour essen nnne nennen nennen nennen sensere 89 2 6 12 gfx Triangle x1 y1 x2 y2 x3 y3 colour eessssesseseseeee enne enne nnne nnne nennen nnns 90 pASMEM u dpi pe 91 2 6 14 gfx Bullet radius rete ree tret tette Ene te ORE REX bete Fema Unger ie ee Eb Pierce 92 2 6 15 gfx Orbitlnit amp x dest amp y dest sssssssssseseseseeeeneeenen nnne nennen enne ennt 93 2 6 16 ghx Orbit angle distance tier re e RR RAE eene Er Ra eR aa CR ERR ERE ER 94 26 17 gfx PutPixellx y CONUN irrin eere erar eua eo eg Y YR Fue er Fac ra REV e Care HUE a ERE Ea rH 95 EXE EE MC UTC iideaacaeeontee 96 2 6 19 gfx MoveTo xpos ypos csscccessecsssesssecseseesseeceseessseecaecsessecsaseseeeecsaeceeseecsueeseeeecsaeceeeeeseaeeeneees 97 2 6 20 gfx MoveRel xoffset yoffset ccccssccsscssscecseeceeseecsecseseecseeeseeeeceaececeeeceaeceeeeeceaeseeeeecsaeseneees 98 ZOD VAP Moi E 99 p
238. ur Example Giese lwnclubxedL s S vtm p This example draws a WHITE pixel at x 32 y 32 un Z T Z zm TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 95 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 18 gfx_GetPixel x y Syntax gfx GetPixel x y Arguments X y X y specifies the screen coordinates of the pixel colour to be returned The arguments can be a variable array element expression or constant Returns colour colour The 8 or 16bit colour of the pixel default 16bit Description Reads the colour value of the pixel at position x y Example gfx PutPixel 20 20 1234 r gfx GetPixel 20 20 joint i 7 This example prints 1234 the colour of the pixel that was previously placed un Z I T c Ti J D I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 96 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 19 gfx_MoveTo xpos ypos Syntax gfx_MoveTo xpos ypos Arguments Xpos ypos xpos specifies the horizontal position of the new origin ypos specifies the vertical position of the new origin The arguments can be a variable array element expression or constant Returns nothing Description Moves the origin to a new position Example in
239. w is called again the darkened image will revert back to normal Example r img Darken hImageList imagenum un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 278 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 5 img_Lighten handle index Syntax img_Lighten handle index Arguments handle index handle Pointer to the Image List index Index of the images in the list Returns Status Status TRUE or FALSE Description This function requires that an image control has been created with the file LoadlmageControl function Lighten an image in the image list Returns TRUE if index was ok and function was successful Use this function to lighten an image so that when img Show is called the control will take effect To lighten all of the images in the list at the same time set index to 1 Note This feature will take effect one time only and when img Show is called again the lightened image will revert back to normal Example r img Lighten hlImageList imagenum un Z T Z TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 279 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 18 6 img_SetWord handle index offset word Syntax img_SetWord handle index offset word Arg
240. wing tables outline in detail the PICASO GFX2 system registers and flags Table 3 1 WORD Size Registers Memory Map gt o ADDRESS USAGE DEC HEX ul RANDOM LO 32 0x20 random generator LO word za RANDOM HI 33 0x21 random generator HI word O SYSTEM_TIMER_LO 34 0x22 1msec system timer LO word e SYSTEM_TIMER_HI 35 0x23 1msec system timer HI word TIMERO 36 0x24 1msec user timer O TIMER1 37 0x25 1msec user timer 1 uL TIMER2 38 0x26 1msec user timer 2 TIMER3 39 0x27 1msec user timer 3 z TIMER4 40 0x28 1msec user timer 3 o TIMER5 41 0x29 1msec user timer 3 I TIMER6 42 Ox2A 1msec user timer 3 TIMER7 43 Ox2B 1msec user timer 3 a SYS_X_MAX 44 Ox2C display hardware X res 1 za SYS_Y_MAX 45 Ox2D display hardware Y res 1 v GFX XMAX 46 Ox2E width of current orientation UJ GFX YMAX 47 Ox2F height of current orientation GFX_LEFT 48 0x30 image left real point m GFX TOP 49 Ox31 image top real point Q GFX RIGHT 50 0x32 image right real point ul GFX BOTTOM 51 0x33 image bottom real point lt GFX_X1 52 0x34 image left clipped point s GFX_Y1 53 0x35 image top clipped point D GFX X2 54 0x36 image right clipped point GFX Y2 55 0x37 image bottom clipped point GFX X ORG 56 0x38 current X origin GFX_Y_ORG 57 0x39 current Y origin GFX_HILITE_LINE 58 Ox3A current multi line button hilite line GFX_LINE_COUNT 59 Ox3B cou
241. x2710 10000 10000 in hex format hiWord OVF print Ox HEX hiWord HEX loWord This example will print 0x05F5E100 to the display which is 100 000 000 in hexadecimal un Z j T Z zm TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 38 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 11 CY Syntax CY Arguments none Returns Status Status Returns Status of carry O or 1 Description This function returns the carry status of an unsigned overflow from any 16 or 32bit additions or subtractions Example var myvar myvar OxFFF8 9 result 1 aieas Oumar apres Wecexexy UU CX Nav g carry 1 This example will print myvar 1 Carry 1 un Z T Z em TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 39 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 3 12 umul_1616 amp res32 val1 val2 Syntax umul 1616 amp res32 val1 val2 Arguments amp res32 val1 val2 amp res32 Points to 32bit result register val1 16bit register or constant val2 16bit register or constant Returns Pointer Pointer Returns a pointer to the 32bit result Carry and overflow are not affected Description Performs an unsigned multiply of 2 x 16bit values plac
242. y control functions Example print nding wav n for n 0 n lt 45 nt t pitch NOTES n print UDEC pitch r snd_Pitch pitch file PlayWAV ding wav while snd Playing pause 500 next un Z T Z zm TE J D T E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 239 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 Sound Control Functions Summary of Functions in this section e Snd Volume var e Snd Pitch pitch e Snd BufSize var e Snd Stop e Snd Pause e Snd Continue e Snd Playing un Z T Z TE J D QO I E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 240 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 15 1 Snd Volume var Syntax Snd Volume var Arguments var var sound playback volume The arguments can be a variable array element expression or constant Returns None Description Set the sound playback volume Var must be in the range from 8 min volume to 127 max volume If var is less than 8 volume is set to 8 and if var 127 it is set to 127 Example snd Volume 127 Set Volume to maximum un Z T Z Ti J D 2 q Z Y TT Z PICASO 2012 4D SYSTEMS Page 241 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS
243. y exists the file pointer is set to the end of the file ready for appending else the file pointer will be set to the start of the newly created file If the file was opened successfully the internal error number is set to O ie no errors and can be read with the file Error function For FILE READ mode r the file must exist else a null handle 0 is returned and the file not found error number is set which can be read with the file Error function Note If a file is opened for write mode w and the file already exists the operation will fail Unlike C and some other languages where the file will be erased ready for re writing when opened for writing 4DGL offers a simple level of protection that ensures that a file must be purposely erased before being re written Example nande z tile Open myrile tat Vie ep 2012 4D SYSTEMS Page 208 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 14 8 file_Close handle Syntax file_Close handle Arguments handle handle the file handle that was created by file_Open fname which is now used as reference handle for fname for further file functions such as in this function to close the file Returns Status 1 File Closed Status 0 File not closed Description Returns TRUE if file closed FALSE if not Example res file Close hndl un Z I T Z TE J D 2
244. y the number of text lines In the case of multiple lines each line is left justified If you wish to centre or right justify the text you will need to prepare the text string according to your requirements un Z T Z m TE J T T J q z Y TT Z Example constant LEFT 30 constant TOP 150 constant TEXTWIDTH 2 constant TEXTHEIGHT 2 func main PICASO Draw a button as a Text Box indented gfx Button DOWN 0 30 GREEN WHITE FONT4 TEXTWIDTH TEXTHEIGHT 4DGL Demo touch _Set TOUCH ENABLE repeat Draw the Push Button raised gfx Button UP LEFT TOP BLUE RED FONT4 TEXTWIDTH TEXTHEIGHT PRESS set touch detect region to that of the push button touch DetectRegion LEFT TOP gfx Get RIGHT POS gfx Get BOTTOM POS Wait until the button is pressed 2012 4D SYSTEMS Page 107 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS while touch Get TOUCH STATUS TOUCH PRESS now redraw the Push Button depressed gfx Button DOWN LEFT TOP BLUE WHITE FONT4 TEXTWIDTH TEXTHEIGHT PRESS Wait until the button is pressed while touch Get TOUCH STATUS TOUCH RELEASE forever endfunc un Z j T Z TE J D E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 108 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 6 30 gfx_P
245. y1 x2 y2 colour scale value mode mode 0 Slider Indented mode 1 Slider Raised mode 2 Slider Hidden background colour x1 y1 specifies the top left corner position of the slider on the screen x2 y2 specifies the bottom right corner position of the slider on the screen colour specifies the colour of the Slider bar Scale scale n sets the full scale range of the slider for the thumb from 0 to n Value if value positive sets the relative position of the thumb on the slider bar else set thumb to ABS position of the negative number If the value parameter was a positive number i e value is a proportion of the scale parameter the true implied x or y axis position of the thumb is returned Returns If the value parameter was a negative number i e thumb is being set to an ABSolute graphics position the actual slider value which is a proportion of the scale parameter is returned Description Draws a vertical or horizontal slider bar on the screen The gfx Slider function has several different modes of operation In order to minimise the amount of graphics functions we need all modes of operation are selected naturally depending on the parameter values Selection rules 1a if x2 x1 y2 y1 slider is assumed to be horizontal ie if width height slider is horizontal 1b if x2 x1 lt y2 y1 slider is assumed to be vertical ie if height lt width slider is horizontal 2a If value is positive th
246. ystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 2 isxdigit char Syntax isxdigit char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not as ASCII hexadecimal digit rens 1 Character is an ASCII hexadecimal digit Description Tests the character parameter and returns a 1 if the character is an ascii hexadecimal digit else returns a O Valid range 0123456789ABCDEF Example oucuM Ncc 2 501 un Z T Z em TE J D S lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 64 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 3 isupper char Syntax isupper char Arguments char char Specifies the ASCII character for the test Returns Status 0 Character is not an ASCII upper case letter Status 1 Character is an ASCII upper case letter Description Tests the character parameter and returns a 1 if the character is an ASCII upper case letter else returns a O Valid range ABCDEF WXYZ Example Rear tO SSC 2 551 un Z T Z em TE J D QO E lt x Z Y TT Z PICASO 2012 4D SYSTEMS Page 65 of 317 www 4dsystems com au 4D SYSTEMS PICASO INTERNAL 4DGL FUNCTIONS 2 5 4 islower char Syntax islower char Arguments char
Download Pdf Manuals
Related Search
Related Contents
卓上発信器取扱説明書 CMシリーズ LG 55LW5600 Energy Guide Copyright © All rights reserved.
Failed to retrieve file