15 unsigned char** fb = (
unsigned char**) calloc(
OLED_WIDTH,
sizeof(
unsigned char*));
17 fb[i] = (
unsigned char*) calloc(
OLED_HEIGHT,
sizeof(
unsigned char));
61 va_start(args, numShapes);
62 for(i=0; i < numShapes; ++i) {
71 for(i=0; i < numShapes; ++i) {
79 for(i=0; i < numShapes; ++i) {
90 printf(
"%sPixel off screen: ", __FUNCTION__);
109 int dx, dy, sx, sy, e2, err;
114 dx = abs(b->
x-a->
x); sx = (a->
x < b->
x) ? 1 : -1;
115 dy = abs(b->
y-a->
y); sy = (a->
y < b->
y) ? 1 : -1;
116 err = (dx>dy ? dx : -dy)/2;
119 if ((a->
x == b->
x) && (a->
y == b->
y)) {
break;}
121 if (e2 >-dx) {err -= dy; a->
x += sx;}
122 if (e2 < dy) {err += dx; a->
y += sy;}
141 for(i = -x; i <= x; ++i) {
154 int xx, yy, xx2, yy2, dx, dy, stop_x, stop_y, error;
159 xx = x_radius * x_radius;
160 yy = y_radius * y_radius;
165 dx = yy * (1 - 2*x_radius);
168 stop_x = yy*2*x_radius;
173 while (stop_x > stop_y) {
179 if (2*error + dx > 0) {
191 dy = xx * (1 - 2*y_radius);
194 stop_y = xx2*y_radius;
196 while (stop_x <= stop_y) {
202 if (2*error + dy > 0) {
218 int xx, yy, xx2, yy2, dx, dy, last_y_filled, stop_x, stop_y, error, i;
219 xx = x_radius * x_radius;
220 yy = y_radius * y_radius;
228 for (i = -x_radius; i <= x_radius; ++i) {
236 dy = xx * (1 - 2*y_radius);
238 stop_y = xx2*y_radius;
242 while (stop_x <= stop_y) {
243 if (y != last_y_filled) {
251 if (2*error + dy > 0) {
272 while(*
string !=
null) {
285 uchar active, col, row, mask;
291 printf(
"%s pen has gone offscreen. Ignoring rest of character...\n", __FUNCTION__);
307 printf(
"(%d,%d):%d\n", p->
x, p->
y, p->
shade);
310 printf(
"%s This function was called in an inappropriate context.\n", __FUNCTION__);
311 printf(
"%s Please consult the documentation.\n", __FUNCTION__);
319 printf(
"(%d,%d):%d", p->
x, p->
y, p->
shade);
321 printf(
"%s This function was called in an inappropriate context.\n", __FUNCTION__);
322 printf(
"%s Please consult the documentation.\n", __FUNCTION__);
330 printf(
"(%d,%d):%d\n", x, y, shade);
332 printf(
"%s This function was called in an inappropriate context.", __FUNCTION__);
333 printf(
"Please consult the documentation.\n");
342 printf(
"(%d,%d):%d", x, y, shade);
344 printf(
"%s This function was called in an inappropriate context.", __FUNCTION__);
345 printf(
"Please consult the documentation.\n");
void fb_erase_string(framebuffer fb, point *top_left_corner, char *string)
Erase string on fb starting at top_left_corner.
void fb_draw_ellipse(framebuffer fb, point *center, ushort x_radius, ushort y_radius, shade_t shade)
Draw an ellipse in fb at center with specified x- and y-radii of color shade.
unsigned short num_points
Representation of a shape.
private void _fb_draw_char(framebuffer fb, point *pen, char c)
For internal use only.
void fb_draw_shape_arr(framebuffer fb, ushort numShapes, shape **shape_arr)
private void _fb_draw_string(framebuffer fb, point *top_left_corner, char *string)
For internal use only.
private void _fb_draw_shape(framebuffer fb, shape *sh, shade_t shade)
For internal use only.
void fb_console_println_coordinate(uchar x, uchar y, shade_t shade)
Print a coordinate (ordered pair) to the console followed by a newline.
void fb_console_print_coordinate(uchar x, uchar y, shade_t shade)
Print a coordinate (ordered pair) to the console.
void fb_draw_shape(framebuffer fb, shape *sh)
Using as a canvas, draw .
void fb_destroy(framebuffer fb)
Destroy a framebuffer object.
private void _fb_fill_four_ellipse_points(framebuffer fb, point *center, ushort x, ushort y)
Fill an ellipse on fb.
point * shape_duplicate_point(point *p)
static const unsigned char font_valvano[129][5]
Font definition: Professor Valvano style.
#define FONT_VALVANO_HEIGHT
#define FONT_VALVANO_WIDTH
framebuffer fb_init()
Create a framebuffer object and return the handle.
void fb_erase_char(framebuffer fb, point *top_left_corner, char c)
Erase char on fb starting at top_left_corner.
void fb_erase_shape(framebuffer fb, shape *sh)
Using as a canvas, draw .
void fb_erase_shape_arr(framebuffer fb, ushort numShapes, shape **shape_arr)
void fb_draw_shapes(framebuffer fb, ushort numShapes,...)
void fb_draw_line_gradient(framebuffer fb, point *point1, point *point2, shade_t shade)
Draw a line segment on from to .
Representation of an ordered pair with a shade.
private void _fb_draw_line(framebuffer fb, point *point1, point *point2, shade_t shade)
The heavy-lifter (pixel-setter) in line-segment-drawing.
void fb_console_println_point(point *p)
Print a point (ordered pair) to the console followed by a newline.
void fb_draw_ellipse_fill(framebuffer fb, point *center, ushort x_radius, ushort y_radius, shade_t shade)
Draw on fb a shaded ellipse described by center, x- and y-radii.
void fb_console_print_point(point *p)
Print a point (ordered pair) to the console.
private void _fb_plot_four_ellipse_points(framebuffer fb, point *center, ushort x, ushort y)
Plot on fb the four symmetric points on an ellipse described by a center and x- and y-offsets...
#define FONT_VALVANO_KERNING
void fb_set_pixel(framebuffer fb, uchar x, uchar y, shade_t shade)
In fb, set pixel (x,y) to .