Пример #1
0
void xs_gpio_init(xsMachine* the)
{
    FskErr err;
    FskGPIO gpio;
    SInt32 pin = 0;
	GPIOdirection dir;
    char *pinName = NULL;

    xsVars(1);

    if ((gpio = xsGetHostData(xsThis)))
        xsThrowDiagnosticIfFskErr(kFskErrOperationFailed, "Digital pin %d already initialized.", (int)gpio->pinNum);

    dir = stringToDirection(the, xsToString(xsGet(xsThis, xsID("_direction"))), gpio);

    xsVar(0) = xsGet(xsThis, xsID("_pin"));
    if (xsStringType == xsTypeOf(xsVar(0)))
        pinName = xsToString(xsVar(0));
    else
        pin = xsToInteger(xsVar(0));

    err = FskGPIONew(&gpio, pin, pinName, dir);
    xsThrowDiagnosticIfFskErr(err, "Digital pin %d initialization failed with error %s.", pin, FskInstrumentationGetErrorString(err));

    xsSetHostData(xsThis, gpio);
}
Пример #2
0
void xs_gpio_set_direction(xsMachine* the)
{
    FskGPIO gpio = xsGetHostData(xsThis);
    FskErr err;
    GPIOdirection dir = stringToDirection(the, xsToString(xsArg(0)), gpio);

    err = FskGPIOPlatformSetDirection(gpio, dir);
    xsThrowIfFskErr(err);
}
Пример #3
0
bool Function::loadXMLDirection(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunctionDirection)
    {
        qWarning() << Q_FUNC_INFO << "Direction node not found";
        return false;
    }

    setDirection(stringToDirection(root.text()));

    return true;
}
Пример #4
0
bool Function::loadXMLDirection(QXmlStreamReader &root)
{
    if (root.name() != KXMLQLCFunctionDirection)
    {
        qWarning() << Q_FUNC_INFO << "Direction node not found";
        return false;
    }

    QString str = root.readElementText();
    if (str.isEmpty())
        return false;

    setDirection(stringToDirection(str));

    return true;
}
Пример #5
0
bool KDFrameProfileSection::readFrameProfileSectionNode( const QDomElement& element,
        KDFrameProfileSection* section )
{
    bool ok = true;
    Direction tempDirection = DirPlain;
    Curvature tempCurvature = CvtPlain;
    int tempWidth;
    QPen tempPen;
    QDomNode node = element.firstChild();
    while( !node.isNull() ) {
        QDomElement element = node.toElement();
        if( !element.isNull() ) { // was really an element
            QString tagName = element.tagName();
            if( tagName == "Direction" ) {
                QString value;
                ok = ok & KDXML::readStringNode( element, value );
                tempDirection = stringToDirection( value );
            } else if( tagName == "Curvature" ) {
                QString value;
                ok = ok & KDXML::readStringNode( element, value );
                tempCurvature = stringToCurvature( value );
            } else if( tagName == "Width" ) {
                ok = ok & KDXML::readIntNode( element, tempWidth );
            } else if( tagName == "Style" || tagName == "Pen" ) {
                ok = ok & KDXML::readPenNode( element, tempPen );
            } else {
                qDebug( "Unknown tag in frame" );
            }
        }
        node = node.nextSibling();
    }

    if( ok ) {
        section->_direction = tempDirection;
        section->_curvature = tempCurvature;
        section->_width = tempWidth;
        section->_pen = tempPen;
    }

    return ok;
}