I have been spending a lot of time with the 'm' (move) token and the 'j' (joint list) token and decided that I wanted more information for the latter. In the current default Nybble.ino, the 'j' token switch case looks like this:
case 'j': { //show the list of current joint angles
printList((int8_t*)currentAng);
break;
}
So, this token accesses the printList() function which has the following code:
template <typename T> void printList(T * arr, byte len = DOF) {
String temp = "";
for (byte i = 0; i < len; i++) {
temp += String(arr[i]);
temp += '\t';
//PT((T)(arr[i]));
//PT('\t');
}
PTL(temp);
}
and it produces a simple bare list of joint angles from joint index 0 to 15 (pose kbalance is shown):
The printList() function is also used by the 'c', 'm', 'u' and 'b' tokens and I didn't want to change their behavior so I made the following new function:
template <typename T> void printJointListTS(T * arr, byte len = DOF)
{
PTL();
//TS Joint Name Header grid
PTF("hPan hTilt tPan NA ");
PTF("rFL rFR rHR rHL ");
PTF("sFL sFR sHR sHL ");
PTLF("kFL kFR kHR kHL");
//TS Min Max Joint Angle grid
PTF(" -58 +112 -25 +32 -59 +110 xxxx xxxx ");
PTF("xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx ");
PTF(" -71 +100 -95 +75 -100 +67 -64 +106 ");
PTLF(" -73 +62 -59 +112 -70 +70 -110 +59");
//TS Create matching jointIndex and jointAngle data grid
for (byte jointIdx = 0; jointIdx < len; jointIdx++)
{
//TS For info on sprintf() function, see See https://www.programiz.com/cpp-programming/library-function/cstdio/sprintf
char jointIdxChars[3]; //TS Expected range is 0 to 15 so need 2 chars plus 1 char for \0 terminating char
sprintf(jointIdxChars, "% 3d", jointIdx); //TS Use space padding of width 3.
char jointAngleChars[4]; //TS Expected range is 000 to 180 so need 3 chars plus 1 char for \0 terminating char
sprintf(jointAngleChars, "%+ 4d", arr[jointIdx]); //TS Use sign with space padding of width 4.
PT(jointIdxChars); PT(": "); PT(jointAngleChars); PT(" "); //TS Char count: 3 + 2 + 3 + 2 = 11 to match test grid
}
PTL();
}
When this new function is substituted into the 'j' token switch case, we get this more informative list (again for pose kbalance):
The first line is a list of joint names, the second line is a list of min and max joint angle values and the third line has colon delimited joint indexes and current joint values with everything lining up nicely due to use of the sprintf() function. Note that the first and second lines are hard coded. In particular, you have to determine the min and max joint angles for your Nybble manually via 'm' token usage.
This adds a new function with significant hard coding of the first 2 lines so what is the memory price?
Memory Change: +2008 bytes (ca. +6%) program memory; +16 bytes SRAM.
Kind of expensive so you might want to add compiler directives (#define, #ifdef) to switch between the original code and this code. Of course, if you turn off the unnecessary code in IRremote.h, and pick up ca. 10% program memory (see here), you might be able to leave this code on all the time. Let me know if you find this useful.