Base Device to setup (Pass to all blocks) (For use with Freetronics OLED128 128x128 pixel OLED display)
ftoled-display-device
@/ftoled-display-device
Base Device to setup (Pass to all blocks) (For use with Freetronics OLED128 128x128 pixel OLED display)
pin_csport
CS Pin Number
pin_dcport
DC Pin Number
pin_resetport
Reset Pin Number
DEV@/ftoled-display-device
To use the node in your project you should have the bradzilla84/ftoled 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/freetronics/FTOLED"
// Include C++ library:
{{#global}}
#include <SPI.h>
#include <FTOLED.h>
{{/global}}
// Adafruit_PN532 class wants to know ports in the moment of instantiation
// but we don't know them at this moment.
// Therefore, we reserve memory to store an instance of the class,
// and create the instance later:
struct State {
uint8_t mem[sizeof(OLED)];
};
// Define our custom type as a pointer on the class instance.
using Type = OLED*;
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
// It should be evaluated only once on the first (setup) transaction
if (!isSettingUp())
return;
auto state = getState(ctx);
auto pin_cs = getValue<input_pin_cs>(ctx);
auto pin_dc = getValue<input_pin_dc>(ctx);
auto pin_reset = getValue<input_pin_reset>(ctx);
// Create a new object in the memory area reserved previously.
// Instead of the `reset` port, specify `NOT_A_PORT`, since it is not needed
Type Display = new (state->mem) OLED(pin_cs, pin_dc, pin_reset);
Display->begin();
emitValue<output_DEV>(ctx, Display);
}