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

Function xs_LS013B4DN04

modules/drivers/ls013b4dn04/modLs013b4dn04.c:170–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168#endif
169
170void xs_LS013B4DN04(xsMachine *the)
171{
172 ls013b4dn04 ls;
173
174#if kCommodettoBitmapFormat != kCommodettoBitmapGray256
175 #error gray256 pixels required
176#endif
177
178 ls = c_calloc(1, sizeof(ls013b4dn04Record));
179 if (!ls)
180 xsUnknownError("out of memory");
181
182#if kPocoFrameBuffer
183 ls->pixels = c_malloc(MODDEF_LS013B4DN04_WIDTH * MODDEF_LS013B4DN04_HEIGHT);
184 if (!ls->pixels) {
185 c_free(ls);
186 xsUnknownError("out of memory");
187 }
188#endif
189
190 xsmcSetHostData(xsThis, ls);
191 ls->bytesPerLine = 2 + (MODDEF_LS013B4DN04_WIDTH / 8);
192
193 ls->dispatch = (PixelsOutDispatch)&gPixelsOutDispatch;
194
195#if MODDEF_LS013B4DN04_DITHER
196 ls->flags |= 1;
197 #if MODDEF_LS013B4DN04_UPDATEALL
198 ls->flags |= 2;
199 #endif
200#endif
201
202#if MODDEF_LS013B4DN04_PULSE
203 ls->timer = modTimerAdd(1001, 1000, pulseScreen, &ls, sizeof(ls));
204 if (!ls-> timer)
205 xsUnknownError("out of memory");
206 modTimerUnschedule(ls->timer);
207#endif
208
209 SCREEN_CS_INIT;
210 modSPIConfig(ls->spiConfig, MODDEF_LS013B4DN04_HZ, MODDEF_LS013B4DN04_SPI_PORT,
211 MODDEF_LS013B4DN04_CS_PORT, MODDEF_LS013B4DN04_CS_PIN, ls013b4dn04ChipSelect);
212 modSPIInit(&ls->spiConfig);
213
214#if MODDEF_LS013B4DN04_DISP_PIN
215 ls->first = 1;
216#endif
217
218#if MODDEF_LS013B4DN04_CLEARONSTART
219 ls_clear(ls);
220#endif
221
222 ls->flip = 0;
223}
224
225void xs_LS013B4DN04_close(xsMachine *the)
226{

Callers

nothing calls this directly

Calls 4

ls_clearFunction · 0.85
modTimerAddFunction · 0.50
modTimerUnscheduleFunction · 0.50
modSPIInitFunction · 0.50

Tested by

no test coverage detected