Thanks for pointing me in the right direction. Here's some psuedo-code for what I ended up doing which is working fine. I left out all the serial port set up stuff assuming people can acquire fd as they see fit:
Code: Select all
const unsigned char VK202_CMD_SPINPOSIT[] = {0xfe, 0x47, 20, 1};
const unsigned char VK202_CUSTOMCHAR0[] = {0xfe, 0x4e, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR1[] = {0xfe, 0x4e, 0x01, 0x00, 0x01, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR2[] = {0xfe, 0x4e, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR3[] = {0xfe, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR4[] = {0xfe, 0x4e, 0x04, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR5[] = {0xfe, 0x4e, 0x05, 0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR6[] = {0xfe, 0x4e, 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00};
const unsigned char VK202_CUSTOMCHAR7[] = {0xfe, 0x4e, 0x07, 0x00, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00};
void f_VK202_LoadCustomChars(int fd)
{
write(fd, VK202_CUSTOMCHAR0, sizeof(VK202_CUSTOMCHAR0));
write(fd, VK202_CUSTOMCHAR1, sizeof(VK202_CUSTOMCHAR1));
write(fd, VK202_CUSTOMCHAR2, sizeof(VK202_CUSTOMCHAR2));
write(fd, VK202_CUSTOMCHAR3, sizeof(VK202_CUSTOMCHAR3));
write(fd, VK202_CUSTOMCHAR4, sizeof(VK202_CUSTOMCHAR4));
write(fd, VK202_CUSTOMCHAR5, sizeof(VK202_CUSTOMCHAR5));
write(fd, VK202_CUSTOMCHAR6, sizeof(VK202_CUSTOMCHAR6));
write(fd, VK202_CUSTOMCHAR7, sizeof(VK202_CUSTOMCHAR7));
}
void f_VK202_Throbber(int fd)
{
static char c;
write(fd, VK202_CMD_SPINPOSIT, sizeof(VK202_CMD_SPINPOSIT));
write(fd, &c, 1);
c++;
if( c == 8 ) c = 0;
}
int main(void)
{
//-- Init serial port stuff here
f_VK202_LoadCustomChars(fd);
while(1)
{
//-- Do stuff here
f_VK202_Throbber(fd);
sleep(1);
}
return(1);
}