MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_DotStar

Function xs_DotStar

modules/drivers/dotstar/modDotstar.c:96–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void xs_DotStar(xsMachine *the)
97{
98 int format;
99 spiDisplay sd;
100 int csPin;
101
102 xsmcVars(1);
103 if (xsmcHas(xsArg(0), xsID_pixelFormat)) {
104 xsmcGet(xsVar(0), xsArg(0), xsID_pixelFormat);
105 format = xsmcToInteger(xsVar(0));
106 }
107 else
108 format = kCommodettoBitmapFormat;
109
110 if (kCommodettoBitmapRGB565LE != format)
111 xsUnknownError("bad format");
112
113 sd = c_calloc(1, sizeof(spiDisplayRecord));
114 if (!sd)
115 xsUnknownError("no memory");
116
117 xsmcSetHostData(xsThis, sd);
118
119 modSPIConfig(sd->spiConfig, MODDEF_DOTSTAR_HZ, MODDEF_DOTSTAR_SPI_PORT,
120 NULL, -1, dotstarChipSelect);
121 modSPIInit(&sd->spiConfig);
122
123 xsmcGet(xsVar(0), xsArg(0), xsID_width);
124 sd->width = (uint16_t)xsmcToInteger(xsVar(0));
125 xsmcGet(xsVar(0), xsArg(0), xsID_height);
126 sd->height = (uint16_t)xsmcToInteger(xsVar(0));
127
128 sd->format = (uint8_t)format;
129
130 sd->dispatch = (PixelsOutDispatch)&gPixelsOutDispatch_16LE;
131
132 setBrightness(sd, MODDEF_DOTSTAR_BRIGHTNESS);
133}
134
135void xs_DotStar_begin(xsMachine *the)
136{

Callers

nothing calls this directly

Calls 2

setBrightnessFunction · 0.85
modSPIInitFunction · 0.50

Tested by

no test coverage detected