From e85e44456b3794958dbdd8dfaa013ee991447e24 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 6 May 2013 13:05:45 -0700 Subject: [PATCH 1/2] Tweaking level indicators for new Invensense --- interface/src/SerialInterface.cpp | 57 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index 5878ab672e..f6125f9414 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -142,31 +142,40 @@ void SerialInterface::renderLevels(int width, int height) { int i; int disp_x = 10; const int GAP = 16; - char val[10]; - for(i = 0; i < NUM_CHANNELS; i++) - { - - // Actual value + char val[40]; + if (!USING_INVENSENSE_MPU9150) { + for(i = 0; i < NUM_CHANNELS; i++) + { + + // Actual value + glLineWidth(2.0); + glColor4f(1, 1, 1, 1); + glBegin(GL_LINES); + glVertex2f(disp_x, height*0.95); + glVertex2f(disp_x, height*(0.25 + 0.75f*getValue(i)/4096)); + glColor4f(1, 0, 0, 1); + glVertex2f(disp_x - 3, height*(0.25 + 0.75f*getValue(i)/4096)); + glVertex2f(disp_x, height*(0.25 + 0.75f*getValue(i)/4096)); + glEnd(); + // Trailing Average value + glBegin(GL_LINES); + glColor4f(1, 1, 1, 1); + glVertex2f(disp_x, height*(0.25 + 0.75f*getTrailingValue(i)/4096)); + glVertex2f(disp_x + 4, height*(0.25 + 0.75f*getTrailingValue(i)/4096)); + glEnd(); + + sprintf(val, "%d", getValue(i)); + drawtext(disp_x-GAP/2, (height*0.95)+2, 0.08, 90, 1.0, 0, val, 0, 1, 0); + + disp_x += GAP; + } + } else { glLineWidth(2.0); glColor4f(1, 1, 1, 1); - glBegin(GL_LINES); - glVertex2f(disp_x, height*0.95); - glVertex2f(disp_x, height*(0.25 + 0.75f*getValue(i)/4096)); - glColor4f(1, 0, 0, 1); - glVertex2f(disp_x - 3, height*(0.25 + 0.75f*getValue(i)/4096)); - glVertex2f(disp_x, height*(0.25 + 0.75f*getValue(i)/4096)); - glEnd(); - // Trailing Average value - glBegin(GL_LINES); - glColor4f(1, 1, 1, 1); - glVertex2f(disp_x, height*(0.25 + 0.75f*getTrailingValue(i)/4096)); - glVertex2f(disp_x + 4, height*(0.25 + 0.75f*getTrailingValue(i)/4096)); - glEnd(); - - sprintf(val, "%d", getValue(i)); - drawtext(disp_x-GAP/2, (height*0.95)+2, 0.08, 90, 1.0, 0, val, 0, 1, 0); - - disp_x += GAP; + //glBegin(GL_LINES); + //glVertex2f(disp_x, height*0.95); + sprintf(val, "Yaw %d, Pitch %d, Roll %d", _lastYaw, _lastPitch, _lastRoll); + drawtext(10, 100, 0.10, 0, 1.0, 0, val, 0, 1, 0); } // Display Serial latency block if (LED) { @@ -198,7 +207,7 @@ void SerialInterface::readData() { int initialSamples = totalSamples; - if (USING_INVENSENSE_MPU9150) { + if (USING_INVENSENSE_MPU9150) { unsigned char gyroBuffer[20]; // ask the invensense for raw gyro data From f39fa3549bba305d9a1d6fd8cbe7f58b01aad349 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 6 May 2013 13:29:02 -0700 Subject: [PATCH 2/2] invensense horizontal lines for RT indicator --- interface/src/SerialInterface.cpp | 33 +++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index f6125f9414..e8ca3b76cd 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -170,12 +170,37 @@ void SerialInterface::renderLevels(int width, int height) { disp_x += GAP; } } else { + const int LEVEL_CORNER_X = 10; + const int LEVEL_CORNER_Y = 200; + + // Draw the text values + sprintf(val, "Yaw %d", _lastYaw); + drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y, 0.10, 0, 1.0, 1, val, 0, 1, 0); + sprintf(val, "Pitch %d", _lastPitch); + drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 15, 0.10, 0, 1.0, 1, val, 0, 1, 0); + sprintf(val, "Roll %d", _lastRoll); + drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 30, 0.10, 0, 1.0, 1, val, 0, 1, 0); + + // Draw the levels as horizontal lines + const int LEVEL_CENTER = 150; glLineWidth(2.0); glColor4f(1, 1, 1, 1); - //glBegin(GL_LINES); - //glVertex2f(disp_x, height*0.95); - sprintf(val, "Yaw %d, Pitch %d, Roll %d", _lastYaw, _lastPitch, _lastRoll); - drawtext(10, 100, 0.10, 0, 1.0, 0, val, 0, 1, 0); + glBegin(GL_LINES); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 3); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastYaw, LEVEL_CORNER_Y - 3); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 12); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastPitch, LEVEL_CORNER_Y + 12); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 27); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _lastRoll, LEVEL_CORNER_Y + 27); + glEnd(); + // Draw green vertical centerline + glColor4f(0, 1, 0, 0.5); + glBegin(GL_LINES); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 6); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 30); + glEnd(); + + } // Display Serial latency block if (LED) {