Please help with the code to draw a box in C

shotsy242

New member
The command to reboot the 835 looks like this and works fine in my C program, now I'd like to take input to draw a box, but there is no good example in the linux sample code, can you help?



Working example for a reboot that I was able to figure out

Command Packet:
type = 0x05 = 5 10
data_length: 3
data[0]: 8
data[1]: 25
data[2]: 48

which in a C program looks like this

int
reboot=0;
if((!strcmp(argv[2],"reboot"))) reboot=1;

if(reboot)
{
outgoing_response.command = 5;
outgoing_response.data[0]=8;
outgoing_response.data[1]=18;
outgoing_response.data[2]=99;
outgoing_response.data_length = 3;
send_packet();
for(k=0;k<=10000;k++)
check_for_packet();
Uninit_Serial();

}

and works fine, how do I do the same with the command packet 28 to draw a box in C?



Command Packet:
type: 0x28 = 40 10
data_length: 7
data[0]: 7 (Draw a Rectangle)
data[1]: x pixel location (top-left)
data[2]: y pixel location (top-left)
data[3]: rectangle width
data[4]: rectangle height
data[5]: line shade
data[6]: fill shade (0 is transparent)


Thanks,

Ken
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Mark

Administrator
To draw a 10x10 pixel box at x20 y25:

outgoing_response.command =40; //command 40
outgoing_response.data[0]=7; //sub-command 7 = draw box
outgoing_response.data[1]=20; //x location
outgoing_response.data[2]=25; //y location
outgoing_response.data[3]=10; //width
outgoing_response.data[4]=10; //height
outgoing_response.data[5]=255; //darkest shade border line
outgoing_response.data[6]=128; //50% shade fill
outgoing_response.data_length = 7;
send_packet();
 
USB LCD Displays - Graphic and Character LCDs with a Keypad
Top