⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prodtestcoord.c

📁 Micro controladores jennic wireless networking zigbee
💻 C
📖 第 1 页 / 共 5 页
字号:
       If showing only three nodes, they appear as follows:
         Info      Node 0
         Node 1    Node 2
    */
    if (sDemoData.sGui.bShowFourNodes)
    {
        iPos = 0;
    }
    else
    {
        iPos = 1;
        vLcdWriteText("Network", 0, 0);
        vLcdWriteText("overview", 1, 0);
    }

    /* Show labels */
    if (sDemoData.sNode.u8AssociatedNodes == 0)
    {
        vLcdWriteText("No nodes associated", 3, 0);
    }
    else
    {
        u8Node = 0;
        while ((u8Node < sDemoData.sNode.u8AssociatedNodes) && (iPos < 4))
        {
            vLcdWriteText((char *)apcNodeNameList[u8Node], au8NodeLcdRow[iPos], au8NodeLcdCol[iPos]);
            u8Node++;
            iPos++;
        }
    }

    /* Hot buttons at bottom of screen */
    vLcdWriteText("Node", 7, 0);
    for (iPos = 0; iPos < DEMO_SENSOR_LIST_LEN; iPos++)
    {
        vLcdWriteText((char *)apcSensorLabel[iPos], 7, au8LabelPos[iPos]);
    }
    vLcdWriteInvertedText((char *)apcSensorLabel[eSensor], 7, au8LabelPos[eSensor]);

    vUpdateNetworkScreen(eSensor);
}

/****************************************************************************
 *
 * NAME: vUpdateNetworkScreen
 *
 * DESCRIPTION:
 * Draws the graphs and values for the Network screen. See the description
 * for vBuildNetworkScreen for an explanation of the positioning of elements
 * on the display.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  eSensor         R   Sensor to display
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vUpdateNetworkScreen(teSensor eSensor)
{
    uint8 u8Node;
    uint8 u8Row;
    uint8 u8Col;
    int iPos;
    bool_t bShowRssi;

    /* If showing four nodes, they appear on screen as follows:
         Node 0    Node 1
         Node 2    Node 3

       If showing only three nodes, they appear as follows:
         Info      Node 0
         Node 1    Node 2
    */
    if (sDemoData.sGui.bShowFourNodes)
    {
        iPos = 0;
    }
    else
    {
        iPos = 1;
    }

    u8Node = 0;
    bShowRssi = sDemoData.sNode.bLocalNode ? FALSE : TRUE;

    while ((u8Node < sDemoData.sNode.u8AssociatedNodes) && (iPos < 4))
    {
        u8Row = au8NodeLcdRow[iPos] + 1;
        u8Col = au8NodeLcdCol[iPos];

        vLcdUpdateElement(&sDemoData.sNode.asNodeData[u8Node],
                          eSensor, u8Row, u8Col, bShowRssi);

        u8Node++;
        iPos++;
        bShowRssi = TRUE;
    }

    vLcdRefreshAll();
}

/****************************************************************************
 *
 * NAME: vLcdUpdateElement
 *
 * DESCRIPTION:
 * Draws the graph and text for a single sensor for a single node. The text
 * includes alarm indications if the sensor value exceeds user specified
 * limits.
 *
 * PARAMETERS:  Name                RW  Usage
 *              psNodeElementData   R   Pointer to data for node
 *              u8Row               R   Character row to display on
 *              u8Col               R   Pixel column to display on
 *              bShowRssi           R   True to show RSSI data
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vLcdUpdateElement(tsNodeData *psNodeData, teSensor eSensor,
                               uint8 u8Row, uint8 u8Col, bool_t bShowRssi)
{
    char acString[10];
    uint8 u8NowValue;
    tsNodeElementData *psNodeElementData = &psNodeData->asNodeElementData[eSensor];

    u8NowValue = psNodeElementData->u8NowValue;

    switch (eSensor)
    {
    case E_SENSOR_TEMP:
        vValToDec(acString, u8NowValue, "[C ");
        break;

    case E_SENSOR_HTS:
        vValToDec(acString, u8NowValue, "% ");
        break;

    case E_SENSOR_ALS:
        /* This is a light sensor so display symbol */
        acString[0] = '&' + u8NowValue;
        acString[1] = '\0';
        break;

    default:
        break;
    }

    vLcdWriteText(acString, u8Row, u8Col);

    /* Print alarm */
    vLcdWriteText("       ", (uint8)(u8Row + 1), u8Col);

    if ((u8NowValue >= psNodeElementData->u8HighAlarm)
        && (psNodeElementData->u8HighAlarm != 0))
    {
        vLcdWriteInvertedText("High", (uint8)(u8Row + 1), u8Col);
    }
    else
    {
        if ((u8NowValue <= psNodeElementData->u8LowAlarm)
            && (psNodeElementData->u8LowAlarm != 255))
        {
            vLcdWriteInvertedText("Low", (uint8)(u8Row + 1), u8Col);
        }
        else
        {
            if (bShowRssi)
            {
                vValToDec(acString, psNodeData->u8Rssi, "");
                vLcdWriteText(acString, (uint8)(u8Row + 1), u8Col);

                vValToDec(acString, psNodeData->u8FramesMissed - 1, "");
                vLcdWriteText(acString, (uint8)(u8Row + 1), u8Col + 20);
            }
        }
    }

    /* Draw graph */
    vDrawGraph(psNodeElementData->au8GraphData, (uint8)(u8Col + 27), u8Row);
}

/****************************************************************************
 *
 * NAME: vBuildNodeScreen
 *
 * DESCRIPTION:
 * Builds the text to appear on a Node screen, then uses the update function
 * to populate it with data.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u8Node          R   Node to display
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vBuildNodeScreen(uint8 u8Node)
{
    vLcdClear();
    vLcdWriteText((char *)apcNodeNameList[u8Node], 0, 0);
    vLcdWriteText("Humidity", 0, 64);
    vLcdWriteText("Temp", 3, 0);
    vLcdWriteText("Light", 3, 64);
    vLcdWriteText("Node", 7, 0);
    vLcdWriteText("Control", 7, 29);
    vLcdWriteText("On", 7, 77);
    vLcdWriteText("Off", 7, 107);

    vUpdateNodeScreen(u8Node);
}

/****************************************************************************
 *
 * NAME: vUpdateNodeScreen
 *
 * DESCRIPTION:
 * Draws the three sensor graphs for a node.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u8Node          R   Node to display
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vUpdateNodeScreen(uint8 u8Node)
{
    tsNodeData *psNodeData;
    char acString[8];

    psNodeData = &sDemoData.sNode.asNodeData[u8Node];

    /* Status */
    if ((sDemoData.sNode.bLocalNode) && (u8Node != 0))
    {
        vValToDec(acString, psNodeData->u8Rssi, "    ");
        vLcdWriteText(acString, 1, 0);
        vValToDec(acString, psNodeData->u8FramesMissed - 1, "    ");
        vLcdWriteText(acString, 1, 20);
    }

    /* Update graphs, alarms and values */
    vLcdUpdateElement(psNodeData, E_SENSOR_TEMP, 4, 0, FALSE);
    vLcdUpdateElement(psNodeData, E_SENSOR_HTS, 1, 64, FALSE);
    vLcdUpdateElement(psNodeData, E_SENSOR_ALS, 4, 64, FALSE);

    //vDisplayDebug();
    vLcdRefreshAll();
}

/****************************************************************************
 *
 * NAME: vBuildNodeControlScreen
 *
 * DESCRIPTION:
 * Builds the text for a Node Control screen, then uses the update function
 * to show the values for each adjustable parameter in turn.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u8Node          R   Node to display
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vBuildNodeControlScreen(uint8 u8Node)
{
    vLcdClear();
    vLcdWriteText((char *)apcNodeNameList[u8Node], 0, 0);
    vLcdWriteText("Select", 7, 0);
    vLcdWriteText("\\", 7, 47);
    vLcdWriteText("]", 7, 74);
    vLcdWriteText("Done", 7, 103);

    /* Update node control screen multiple times to display all the data */
    vUpdateNodeControlScreen(u8Node, 1, FALSE);
    vUpdateNodeControlScreen(u8Node, 2, FALSE);
    vUpdateNodeControlScreen(u8Node, 3, FALSE);
    vUpdateNodeControlScreen(u8Node, 0, TRUE);
}

/****************************************************************************
 *
 * NAME: vUpdateNodeControlScreen
 *
 * DESCRIPTION:
 * Updates a single row of a Node Control screen. The row label is either
 * highlighted or normal text, and the value must be displayed with a symbol
 * after it or, for light levels, purely as a symbol.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u8Node          R   Node to display information for
 *                  u8Selection     R   Currently selected item (0-x)
 *                  boUpdate        R   TRUE if LCD should update afterwards
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vUpdateNodeControlScreen(uint8 u8Node, uint8 u8Selection,
                                      bool_t boUpdate)
{
    static const char *apcRowName[CONTROL_LIST_LEN] = {
        "Temp high alarm", "Temp low alarm", "Light high alarm",
        "Light low alarm"};
    char acString[10];
    tsNodeData *psNodeData = &sDemoData.sNode.asNodeData[u8Node];
    uint8 u8Value;

    /* Write row label highlighted, and previous row label in normal text */
    vWriteRowLabel(u8Selection, (char **)apcRowName, CONTROL_LIST_LEN);

    switch (u8Selection)
    {
    case 0:
        u8Value = psNodeData->asNodeElementData[E_SENSOR_TEMP].u8HighAlarm;
        if (u8Value == 0)
        {
            vLcdWriteText("off   ", 1, 90);
        }
        else
        {
            vValToDec(acString, u8Value, "[C   ");
            vLcdWriteText(acString, 1, 90);
        }
        break;

    case 1:
        u8Value = psNodeData->asNodeElementData[E_SENSOR_TEMP].u8LowAlarm;
        if (u8Value == 255)
        {
            vLcdWriteText("off   ", 2, 90);
        }
        else
        {
            vValToDec(acString, u8Value, "[C   ");
            vLcdWriteText(acString, 2, 90);
        }
        break;

    case 2:
        u8Value = psNodeData->asNodeElementData[E_SENSOR_ALS].u8HighAlarm;
        if (u8Value == 0)
        {
            vLcdWriteText("off", 3, 90);
        }
        else
        {
            acString[0] = '&' + u8Value;
            acString[1] = ' ';
            acString[2] = ' ';
            acString[3] = '\0';
            vLcdWriteText(acString, 3, 90);
        }
        break;

    default:
        u8Value = psNodeData->asNodeElementData[E_SENSOR_ALS].u8LowAlarm;
        if (u8Value == 255)
        {
            vLcdWriteText("off", 4, 90);
        }
        else
        {
            acString[0] = '&' + u8Value;
            acString[1] = ' ';
            acString[2] = ' ';
            acString[3] = '\0';
            vLcdWriteText(acString, 4, 90);
        }
        break;
    }

    if (boUpdate)
    {
        vLcdRefreshAll();
    }
}

/****************************************************************************
 *
 * NAME: vBuildSetupScreen
 *
 * DESCRIPTION:
 * Builds the text for the Setup screen, then uses the update function
 * to show the values for each adjustable parameter in turn.
 *
 * RETURNS:
 * void
 *
 **************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -