Beispiel #1
0
//*****************************************************************************
//
// Provide a simple function so other parts of the application can update
// a status display.
//
//*****************************************************************************
void
SetStatusText(const char *pcTitle, const char *pcLine1, const char *pcLine2,
              const char *pcLine3)
{
    static const char pcBlankLine[] = "                ";

    //
    // Check to see if each parameter was passed, and if so then update its
    // text field on the status dislay.
    //
    pcTitle = pcTitle ? pcTitle : pcBlankLine;
    MenuUpdateText(TEXT_ITEM_STATUS_TITLE, pcTitle);
    pcLine1 = pcLine1 ? pcLine1 : pcBlankLine;
    MenuUpdateText(TEXT_ITEM_STATUS1, pcLine1);
    pcLine2 = pcLine2 ? pcLine2 : pcBlankLine;
    MenuUpdateText(TEXT_ITEM_STATUS2, pcLine2);
    pcLine3 = pcLine3 ? pcLine3 : pcBlankLine;
    MenuUpdateText(TEXT_ITEM_STATUS3, pcLine3);

    //
    // Force a repaint after all the status text fields have been updated.
    //
    WidgetPaint(WIDGET_ROOT);
    WidgetMessageQueueProcess();
}
//*****************************************************************************
//
// This function is called when in VIEW mode.  The acquired data is written
// as text strings which will appear on the eval board display.
//
//*****************************************************************************
static void
UpdateViewerData(const tLogRecord *psRecord)
{
    static char pcViewerBuf[24];
    uint32_t ui32Idx, pui32RTC;
    struct tm sTime;

    //
    // Loop through the analog channels and update the text display strings.
    //
    for(ui32Idx = LOG_ITEM_USER0; ui32Idx <= LOG_ITEM_USER3; ui32Idx++)
    {
        usnprintf(pcViewerBuf, sizeof(pcViewerBuf), " CH%u: %u.%03u V ",
                  ui32Idx - LOG_ITEM_USER0, psRecord->pi16Items[ui32Idx] / 1000,
                  psRecord->pi16Items[ui32Idx] % 1000);
        MenuUpdateText(ui32Idx, pcViewerBuf);
    }

    //
    // Loop through the accel channels and update the text display strings.
    //
    for(ui32Idx = LOG_ITEM_ACCELX; ui32Idx <= LOG_ITEM_ACCELZ; ui32Idx++)
    {
        int16_t i16Accel = psRecord->pi16Items[ui32Idx];
        i16Accel *= (i16Accel < 0) ? -1 : 1;
        usnprintf(pcViewerBuf, sizeof(pcViewerBuf), " %c: %c%d.%02u g ",
                  (ui32Idx - LOG_ITEM_ACCELX) + 'X',
                  psRecord->pi16Items[ui32Idx] < 0 ? '-' : '+',
                  i16Accel / 100, i16Accel % 100);
        MenuUpdateText(ui32Idx, pcViewerBuf);
    }

    //
    // Update the display string for internal temperature.
    //
    usnprintf(pcViewerBuf, sizeof(pcViewerBuf), " INT: %d.%01u C ",
              psRecord->pi16Items[LOG_ITEM_INTTEMP] / 10,
              psRecord->pi16Items[LOG_ITEM_INTTEMP] % 10);
    MenuUpdateText(LOG_ITEM_INTTEMP, pcViewerBuf);

    //
    // Update the display string for external temperature.
    //
    usnprintf(pcViewerBuf, sizeof(pcViewerBuf), " EXT: %d.%01u C ",
              psRecord->pi16Items[LOG_ITEM_EXTTEMP] / 10,
              psRecord->pi16Items[LOG_ITEM_EXTTEMP] % 10);
    MenuUpdateText(LOG_ITEM_EXTTEMP, pcViewerBuf);

    //
    // Update the display string for processor current.
    //
    usnprintf(pcViewerBuf, sizeof(pcViewerBuf), " %u.%01u mA ",
              psRecord->pi16Items[LOG_ITEM_CURRENT] / 10,
              psRecord->pi16Items[LOG_ITEM_CURRENT] % 10);
    MenuUpdateText(LOG_ITEM_CURRENT, pcViewerBuf);

    //
    // Update the display strings for time and data.
    //
    pui32RTC = HibernateRTCGet();
    ulocaltime(pui32RTC, &sTime);
    usnprintf(pcViewerBuf, sizeof(pcViewerBuf), "%4u/%02u/%02u",
              sTime.tm_year+1900, sTime.tm_mon + 1, sTime.tm_mday);
    MenuUpdateText(TEXT_ITEM_DATE, pcViewerBuf);
    usnprintf(pcViewerBuf, sizeof(pcViewerBuf), "%02u:%02u:%02u",
              sTime.tm_hour, sTime.tm_min, sTime.tm_sec);
    MenuUpdateText(TEXT_ITEM_TIME, pcViewerBuf);
}