max548x

hussainfawzi/max548x-10bit-pot/max548x

No description
max548x
@/max548x
CSport
Chip Select pin
WIPERnumber
Set the wiper position Range 0 - 1023
TO NV_Mpulse
Store the wiper position to the non-volatile register.
FROM NV_Mpulse
Update the wiper position from the non-volatile register.
UPDATEpulse
Feed a pulse signal to update the wipe positon based on the value applied to WIPER pin.
max548x
CS
WIPER
TO NV_M
FROM NV_M
UPDATE
DONE
DONEpulse
Spits a pulse when done.
To use the node in your project you should have the hussainfawzi/max548x-10bit-pot library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD require "https://github.com/hussainfawzi/MAX548X"

{{#global}}
#include "MAX548X.h"
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    Number CS = getValue<input_CS>(ctx);
    MAX548X MAX5482(CS);

    if (isInputDirty<input_FROM_NV_M>(ctx)){MAX5482.fromNV(); emitValue<output_DONE>(ctx, 1);}
    if (isInputDirty<input_TO_NV_M>(ctx)){MAX5482.toNV(); emitValue<output_DONE>(ctx, 1);}
    if (!isInputDirty<input_UPDATE>(ctx))
        return;

    Number buff = getValue<input_WIPER>(ctx);
    MAX5482.setPOT(buff);
    emitValue<output_DONE>(ctx, 1);
};