23.11.2012 Views

2 Visual Components Manuals

2 Visual Components Manuals

2 Visual Components Manuals

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction to <strong>Visual</strong> <strong>Components</strong> 2.3<br />

3.3.8.27 Setting the Palette Color − VA_SetPaletteColor<br />

It is possible to dynamically change color values for each individual color using the VA_SetPaletteColor function.<br />

Naturally, this is only possible on an IPC (color or black/white display).<br />

If a palette color is changed, it will remain so until it is either changed again or a warm/cold restart is executed.<br />

3.3.8.27.1 Parameter<br />

I/O Parameter Type Meaning<br />

IN enable BOOL This function is only executed if enable is TRUE.<br />

IN VCHandle UDINT The handle returned by VA_Setup.<br />

IN index UINT Index of the color which should be changed (0−255).<br />

IN color UDINT<br />

New color. The color value is arranged as follows:<br />

Bits 00 − 80 Red value (0−255)<br />

Bits 08 − 16 Green value (0−255)<br />

Bits 16 − 24 Blue value (0−255)<br />

Bits 24 − 32 0<br />

OUT Return Value UINT Not equal to 0 if error occurs<br />

3.3.8.27.2 Example for Automation Basic<br />

(* cyclic program *)<br />

if ready 1 then<br />

VC_HANDLE = VA_Setup(1 "vga") ,<br />

if VC_HANDLE 0 then<br />

ready = 1<br />

endif<br />

endif<br />

if ready = 1 then<br />

if VA_Saccess(1,VC_HANDLE)= 0 then<br />

color = (255 OR SHL(255,8) OR SHL(255,16))<br />

VA_SetPaletteColor(1,VC_HANDLE,color_index, color)<br />

VA_Srelease(1,VC_HANDLE)<br />

endif<br />

endif<br />

3.3.8.27.3 Example for C Programming<br />

#include <br />

#include <br />

#include <br />

UINT _GLOBAL ready;<br />

UINT _GLOBAL color_index<br />

UDINT _GLOBAL color;<br />

unsigned long VC_HANDLE;<br />

_CYCLIC void Cyclic(void)<br />

{<br />

if (!ready)<br />

{<br />

VC_HANDLE = VA_Setup(1 "vga"); ,<br />

if (VC_HANDLE)<br />

ready = 1;<br />

}<br />

if (ready)<br />

{<br />

if (!VA_Saccess(1,VC_HANDLE))<br />

{<br />

color = (0xFF | (0xFF

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!