示例#1
0
void Max7219::setToCharacter(byte character, boolean inverse) const
{
	word charOffset = getCharOffset(character);
	for(byte i = 0; i < 8; ++i) {
		byte val = pgm_read_byte_near(parallax_font + charOffset++);
		maxSingle(i + 1, inverse ? ~val : val);
	}
} // setChar
示例#2
0
void Max7219::doScrollUp()
{
	byte i = 0;
	for(; i < 7; ++i) {
		scrollChar[i] = scrollChar[i + 1];
		maxSingle(i + 1, scrollChar[i]);
	}
	word charOffset = getCharOffset(pgm_read_byte_near(m_scrollText + m_scrollIndex)) + m_currScrollPixRowCol;
	byte row = pgm_read_byte_near(parallax_font + charOffset);
	scrollChar[i] = m_inverseScroll ? ~row : row;
	maxSingle(i + 1, scrollChar[i]);

	scrollNextPixRowCol();
} // doScrollUp
示例#3
0
void HT1632Class::drawText(const char text [], int x, int y, const byte font [], int font_end [], uint8_t font_height, uint8_t gutter_space) {
	int curr_x = x;
	char i = 0;
	char currchar;
	
	// Check if string is within y-bounds
	if(y + font_height < 0 || y >= COM_SIZE)
	return;
	
	while(true){  
		if(text[i] == '\0')
			return;
		
		currchar = text[i] - 32;
		if(currchar >= 65 && currchar <= 90) // If character is lower-case, automatically make it upper-case
			currchar -= 32; // Make this character uppercase.

		if(currchar < 0 || currchar >= 64) { // If out of bounds, skip
			++i;
			continue; // Skip this character.
		}

		// Check to see if character is not too far right.
		if(curr_x >= OUT_SIZE)
			break; // Stop rendering - all other characters are no longer within the screen 
		
		// Check to see if character is not too far left.
		int chr_width = getCharWidth(font_end, font_height, currchar);
		if(curr_x + chr_width + gutter_space >= 0){
			drawImage(font, chr_width, font_height, curr_x, y,  getCharOffset(font_end, currchar));
			
			// Draw the gutter space
			for(char j = 0; j < gutter_space; ++j)
			drawImage(font, 1, font_height, curr_x + chr_width + j, y, 0);
		}
		
		curr_x += chr_width + gutter_space;
		++i;
	}
}
示例#4
0
uint8_t lcdBufPutc(char c, const EmxFont_t* aFont, uint8_t x, uint8_t y, uint8_t aColor)
{   
    // BEWARE: 'aFont' must point to PROGMEM
    /* 
       NOTE: aColor reads 0b01234567  where bit
       .                    0         if on, says: only read width in pixels and return
       .                     1        if on, says: inverse the pixels
       .                      23      are still unused
       .                        4567  define the color. ST7565 only knows color '1' or '0'
     */


    uint8_t startCh             = pgm_read_byte(&aFont->startCh);       // code of first character in font

    if (c < startCh || c > pgm_read_byte(&aFont->endCh))
        return 0;

    uint8_t idx                = (c-startCh);
    uint8_t width              = getCharWidth(aFont, idx);
    uint8_t extraWidth;
    uint8_t att = getAttribs(aFont);
    if (att & FT_EXTRAWS)
        extraWidth = 1;
    else
        extraWidth = 0;
    
    if (aColor & LA_CHARWIDTHONLY)
        return width + extraWidth;
    
    uint8_t  bytesToRead         = getCharBytes(aFont, idx);
    uint16_t offset              = getCharOffset(aFont, idx);
    uint16_t curPix              = getCharFirstPix(aFont, idx);
    const uint8_t* fontPtr       = (uint8_t*) pgm_read_word(&aFont->firstChar);
    fontPtr                     +=  offset;

    uint8_t reverse = aColor & LA_REVERSE;
    aColor ^= LA_REVERSE;

    if (reverse)
    {
        lcdBufFillRect(x, y, width, FONTHEIGHT((*aFont)), aColor);
        aColor = !aColor;
    }

    while(bytesToRead)
    {
        uint8_t data = pgm_read_byte(fontPtr);
        // if (reverse)
        //     data = ~data;
        for (uint8_t bit=0x80; bit; bit >>= 1)
        {
            if (data & bit)
            {
                uint8_t px = x + (curPix%width);
                uint8_t py = y + (curPix/width);
                lcdBufSetPixel(px, py, aColor & 0x0F);
            }
            ++curPix;
        }
        --bytesToRead;
        ++fontPtr;                    // now pointing to next data byte
    } // while bytesToRead
    // enable lcd-update timer

    return width + extraWidth;
} // lcdBufPutc(char c, const EmxFont_t* aFont, uint8_t x, uint8_t y)