ref: b545233a9b54502f276f70a167f2b7f71c54161f
dir: /main.c/
#include <u.h> #include <libc.h> #include <draw.h> #include <memdraw.h> #include "bitart.h" #define NPIXELS 4032 #define H 32 #define W 126 #define NDRAWFUNCS 7 #define NITERFUNCS 4 int h, w; char *path; long ms; void usage(void) { sysfatal("usage: %s [ -f subfont ] text", argv0); } void main(int argc, char **argv) { Memimage *img; // 126 x 32 oled ⇒ 4032 pixels int iteri, drawi; h = 32; w = 126; ms = 100; // « change to ≤10 to get a kernel fault path = "/mnt/reform/kbdoled"; drawfunc *drawtab[NDRAWFUNCS] = { ob0, ob1,//general kenobi! *growls* « "hello there" ob2, ob3, ob4, ob5, drand, }; iterfunc *itertab[NITERFUNCS] = { topdown, bottomup, leftright, rightleft, }; ARGBEGIN{ default: usage(); }ARGEND; if (memimageinit()) sysfatal("memimageinit failed: %r"); // FOR EVER for(;;){ iteri = ntruerand(NITERFUNCS); drawi = ntruerand(NDRAWFUNCS); // blank the screen img = allocmemimage(Rect(0, 0, w, h), GREY1); if (!img) sysfatal("cannot allocate memimage: %r"); // white on black; bg is black memfillcolor(img, DBlack); /* call the independent drawing routine of choice */ itertab[iteri](drawtab[drawi], img); freememimage(img); } }