I'm new to programming in any form of C.
I have a PLC (Teso PC1620) (using a rabbit processor) with an LCD screen (matrix orbital LK204-7T-1U-USB-WB). I'm trying to use the build in horizontal bar/graph function of the LCD.
The code below works but I want to be able to change the length of the bar (6th value in the "bar" array). I tried this with the code commented out instead of the static constant for "bar" this appears not to work and gives random bars on the LCD.
What could cause this and is there maybe an easier/better way to assign the "bar" array.
#use "oempc16xxdrivers.elib" //Include the OEM pro-teso PC16XO driver library
#define DINBUFSIZE 31 //Defining the serial IN buffer size
#define DOUTBUFSIZE 31 //Defining the serial OUT buffer size
void main()
{
static const char clear[] = {254,88}; //Clear LCD command
static const char load[] = {254,104}; //Initialize horizontal bar
static const char bar[] = {254,124,1,1,0,54}; //Place horizontal bar(245,124) column,Row,Direction,Length
auto int percentage;
auto int rxKey;
//auto char bar[6];
IOInit(); //Initialises the PC1600 (PLC).
serDopen(19200L); //Setting the baudrate of the serial port
serDrdFlush(); //Flushes the serial port D input buffer
serDwrFlush(); //Flushes the serial port D transmit buffer
serDwrite(clear,sizeof(clear)); //Clear LCD
serDwrite(load,sizeof(load)); //Initialize horizontal bar
// bar[0] = 254;
// bar[1] = 124;
// bar[2] = 1;
// bar[3] = 1;
// bar[4] = 0;
// bar[5] = 54;
for(;;)
{
rxKey = serDgetc();
percentage = 10;
//bar[5] = percentage;
if (0x42 == rxKey)
{
serDwrite(bar,sizeof(bar));
}
}
serDclose ();
}
Dynamic c Version 9.62
Links:
PLC: http://www.teso.com.au/pro-teso/PC1-Controllers/PC1600-Controller.aspx