void transmitX(int Xdata){ // octet 1 for X ; MSB for X (More Signifiant Bits) // 00000xxx Value (after being shifted 5 times) // || // ||--------> MSB // |---------> X Xmsb = Xdata >> 5 ; // Division by 32, save the 5 Msb bits Serial.print(Xmsb, BYTE); // Send X MSB // octet 0 for X ; LSB for X (Less Signifiant Bits) // xxxxxxxx value // 00011111 & mask (31) // 01000000 + flag // 010xxxxx = result for // 01000000 + 64 for LSB flag // first bit is 0 for X flag Xlsb = Xdata & 31 ; // save the 5 lsb bits Xlsb = Xlsb + 64 ; // set second bit to 1 for lsb marker Serial.print(Xlsb, BYTE); // Send X LSB } void transmitY(int Ydata){ // octet 1 for Y ; MSB for Y (More Significant Bits) // 10000xxx Value (after being shifted 5 times) // || // ||--------> MSB // |---------> 1=>Y Ymsb = Ydata >> 5 ; // Division by 32, save the 5 Msb bits Ymsb = Ymsb + 128 ; // add a bit for Y Serial.print(Ymsb, BYTE); // Send Y MSB // octet 0 for Y ; LSB for Y (Less Significant Bits) // xxxxxxxx value // 00011111 & mask // 000xxxxx = result // 01000000 + 64 for LSB flag // 10000000 + 128 for Y flag Ylsb = Ydata & 31 ; // save the 5 lsb bits Ylsb = Ylsb + 64 ; // set second bit to 1 for lsb marker Ylsb = Ylsb + 128 ; // add a bit for Y Serial.print(Ylsb, BYTE); // Send Y LSB }