Ejemplo n.º 1
0
/*******************************************************************************
* Function Name: DrawPixel
********************************************************************************
*
* Summary:
*  This function writes to the (x,y) coordinate of the 'matrix' buffer in RAM
*
* Parameters:  
*   uint8 x: 		betn 0 and 31
*	uint8 y: 		betn 0 and 15
*	RGB c:			5-bit color to be written to the pixel 
* 	color *matrix: 	pointer to the matrix buffer
*
* Return:
*   None
*
*******************************************************************************/
void DrawPixel(uint8 x, uint8 y, RGB c, color *matrix)
{
	/* pre-calculate some values to index the matrix 
	 * Note that the translation has been done here to
	 * leave the ISR clean
	 */
	uint8 i = 0, index;
	
	/* index indexes the elements of 'matrix' 
	 * 'matrix' consists of 64 'color' structs, 4 elements per row
	 * The formula for index thus is index = y*4 + x/8
	 */
	uint8 scratch1 = y*4;
	
	/* The x-coordinate is broken up into 2 parts:
	* 1. Which of the 4 FIFO bytes need to be written (scratch2)
	* 2. Which bit of that byte needs to be written (bit_pos)
	*/
	uint8 scratch2 = (uint8)(x/8);
	uint8 bit_pos = (uint8)x%8;
	
	index = scratch1 + scratch2;
	
	ClearPixel(x, y, matrix);
	
	for(i = 0; i < 5 ; i++)
	{
		matrix[index].r[i] |= (uint8)((uint8)((c.r & (0x01 << i)) && 1)<<(bit_pos));
		matrix[index].g[i] |= (uint8)((uint8)((c.g & (0x01 << i)) && 1)<<(bit_pos));
		matrix[index].b[i] |= (uint8)((uint8)((c.b & (0x01 << i)) && 1)<<(bit_pos));
	}
}
Ejemplo n.º 2
0
unsigned char drawChar(unsigned char c, unsigned int pos, unsigned char invert)
{
    unsigned char i, j, tempColumn;
    unsigned int columnIndex;

    columnIndex = (unsigned int)(c*5);

    //character out of bounds
    if(columnIndex > (sizeof(font)-1)) return 1;

    for(j=0; j<5;j++)
    {
        tempColumn = font[columnIndex+j];
        
        if(invert)
        {
            tempColumn = ~tempColumn;
        }
        
        //go through each column of character, left to right
        for(i=0; i<7; i++)
        {
            //go through each row of characer, top to bottom
            if((tempColumn & 0x01) > 0)
            {
                SetPixel((pos+j), i);
            }
            else
            {
                ClearPixel((pos+j), i);
            }

            tempColumn >>= 1;
        }
    }

    return 0;
}
Ejemplo n.º 3
0
TargetPixel::~TargetPixel()
{
    ClearPixel();
}
Ejemplo n.º 4
0
void
ClearImage(const Graphics& g)
{
	ClearPixel(g.GetBufferPtr(), GetAreaOf(g.GetSize()));
}