Esempio n. 1
0
/* draw a line like Brensenham did... (roughly) */
void fb_rgb332_lineto(uint16_t x2,uint16_t y2){
	uint8_t *p,pixel;	/* framebuffer pointer */
	int delta_regular;	/* framebuffer offset per step */
	int delta_step;		/* " */

	uint16_t x1 = framebuffer->cursor_x; /* start */
	uint16_t y1 = framebuffer->cursor_y;

	int t,tmax;		/* counter for steps */
	int err_inc,err_accu=0;	/* error delta and accumulator for */
				/* Brensenham's algorhithm */

	fb_limit_fb_range(&x1,&y1);
	fb_limit_fb_range(&x2,&y2);
	fb_rgb332_update_damage(x1,y1,x2,y2);

	framebuffer->cursor_x = x2; /* end pixel */
	framebuffer->cursor_y = y2;

	/* pointer to first pixel, pixel value in FB memory */
	p = fb_rgb332->mem + framebuffer->width * y1 + x1;
	pixel = rgb_to_pixel(framebuffer->fg_color);

	if(abs(x2-x1) >= abs(y2-y1)){ /* shallow line */
		/* set pointer deltas for directions */
		delta_regular = 1;		    /* X */
		if(x2 < x1)
			delta_regular = -delta_regular;
		delta_step = framebuffer->width;    /* Y */
		if(y2 < y1)
			delta_step = -delta_step;
		tmax = abs(x2-x1);
		err_inc = abs(y2-y1);
	} else { /* steep line */
		delta_regular = framebuffer->width; /* Y */
		if(y2 < y1)
			delta_regular = -delta_regular;
		delta_step = 1; 		    /* X */
		if(x2 < x1)
			delta_step = -1;
		tmax = abs(y2-y1);
		err_inc = abs(x2-y1);
	}

#if 0
	printf("%s: (%d,%d) -> (%d,%d) step=%d regular=%d err_inc=%d tmax=%d\n",
	       __FUNCTION__,x1,y1,x2,y2,delta_step,delta_regular,err_inc,tmax);
#endif

	for(t=0;t<=tmax;t++){
		*p = pixel;
		err_accu += err_inc;
		if(err_accu >= tmax){
			p += delta_step;
			err_accu -= tmax;
		}
		p += delta_regular;
	}
}
Esempio n. 2
0
lcd_inline void write_data(uint16_t datain)
{
  uint16_t dataout = 0x0100 | fix_rrr(rgb_to_pixel(datain));
  uwire_xfer(SSD1783_DEV_ID,SSD1783_UWIRE_BITLEN,&dataout, NULL);
}
Esempio n. 3
0
static void set_pix(uint8_t *pixel,uint32_t color){
	if(color == FB_COLOR_TRANSP)
		return;
	*pixel = rgb_to_pixel(color);
}