1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| void myfunction(int fingerId, int power)
{
if (FILE_DESCRIPTOR < 0)
{
printf ("Error: serial output non connected when changing finger status :: dll_gloves");
return;
}
//printf("DLLPower: %d \n", power);
if(power < 0 || power > 9)
{
power =0;
printf("Warning: vibration power has to be in between 0 and 9 :: dll_gloves \n");
}
if(fingerId != THUMB_ID && fingerId != INDEX_ID && fingerId != MIDDLE_FINGER_ID && fingerId != HAND_ID)
{
fingerId =THUMB_ID;
printf("Warning: fingerId specified out of bounds :: dll_gloves");
}
char a[1];
sprintf(a,"%d",fingerId);
write(FILE_DESCRIPTOR, &a , 1);
write(FILE_DESCRIPTOR, "1" , 1);
sprintf(a,"%d",power);
write(FILE_DESCRIPTOR, &a , 1);
} |