Example #1
0
void Protocol::Send(const char *carr, const uint16_t length)
{
    _PutChar(_MagicNumber);
    for (size_t i = 0; i < length; i++)
    {
        _PutChar(carr[i]);
    }
}
Example #2
0
bool Screen::Put16(unsigned int port, unsigned int data) {
	bool clearLine = false;
	switch(port) {
	case 0x04E8:
		return true;
	case 0x04E9:
	{
		char chr = data & 0xFF;
		unsigned char colour = (data & 0xFF00) >> 0x08;

		if(chr == 0x08) { //Backspace
			mCurX = mCurX == 0 ? 0 : mCurX - 1;
		} else if(chr == 0x09) { //Tab
			for(unsigned int i = 0; i < 4; i++) {
				_PutChar(' ');
				_PutColour(0);

				if (mCurX == 0) {
					clearLine = true;
				}
			}
		} else if(chr == 0x0A) { //Line feed
			mCurY = (mCurY + 1) % NUM_ROWS;
			if(mCurY == mFirstRow) {
				mFirstRow = (mFirstRow + 1) % NUM_ROWS;
				clearLine = true;
			}
		} else if(chr == 0x0D) {
			mCurX = 0;
		} else if(chr >= 32 && chr < 127) {
			_PutColour(colour);
			_PutChar(chr);

			if (mCurX == 0) {
				clearLine = true;
			}
		}
		if (clearLine) {
			for(unsigned int i = 0; i < NUM_COLS; i++) {
				mScreen[i + mCurY * NUM_COLS] = ' ';
				mColor[i + mCurY * NUM_COLS] = 0;
			}
		}
		return true;
	}
	case 0x4EA:
		mCurX = data & 0xFF;
		return true;
	case 0x4EB:
		mCurY = data & 0xFF;
		return true;
	}
	return false;
}
Example #3
0
void Protocol::Send(const uint16_t pos)
{
    int size = 1 + sizeof(uint16_t);
    char *buff = new char[size];
    *buff = _MagicNumber;
    *(reinterpret_cast<uint16_t *>(buff + 1)) = pos;
    for (int i = 0; i < size; i++)
    {
        _PutChar(buff[i]);
    }
    delete[] buff;
}
Example #4
0
/*******************************************************************************
* Function Name: `$INSTANCE_NAME`_PrintString
********************************************************************************
* Summary:
*   Print string at the given location.
*
* Parameters:  
*  uint32 xpos: X location at which to start string.
*  uint32 ypos: Upper Y location to place string.
*  char * theString:  The string to print.
*  uint32 fg: The forground fount color.
*  uint32 bg: Background color
*
* Return: 
*  void
*
*******************************************************************************/
void `$INSTANCE_NAME`_PrintString(int32 xpos, int32 ypos, char * theString, uint32 fg, uint32 bg)
{
    uint32 strPos = 0;
    uint32 y, yStop;
    #if(`$INSTANCE_NAME`_MEMORY_TYPE == `$INSTANCE_NAME`_MEMORY_RGB)
       extern uint32  `$INSTANCE_NAME`_ledArray[`$INSTANCE_NAME`_ROWS][`$INSTANCE_NAME`_COLUMNS];
    #else  /* Else use lookup table */
       extern uint8  `$INSTANCE_NAME`_ledArray[`$INSTANCE_NAME`_ROWS][`$INSTANCE_NAME`_COLUMNS];
    #endif
    
    yStop = ypos + `$INSTANCE_NAME`_fontY;
    if(yStop > `$INSTANCE_NAME`_ROWS) yStop = `$INSTANCE_NAME`_ROWS;
    
    while(theString[strPos] != 0)
    {
        if(fg == `$INSTANCE_NAME`_COLORWHEEL_FONT)
        {
            `$INSTANCE_NAME`_PutChar(xpos, ypos, theString[strPos], `$INSTANCE_NAME`_ColorInc(1), bg);
        }
        else
        {
            `$INSTANCE_NAME`_PutChar(xpos, ypos, theString[strPos], fg, bg);
        }
        strPos++;
        xpos += `$INSTANCE_NAME`_fontX;
        if(theString[strPos] != 0)
        {
            for(y = ypos; y < yStop; y++ )
            {
                if((y >= 0) && (y < `$INSTANCE_NAME`_ROWS)&& (xpos >= 0) && (xpos < `$INSTANCE_NAME`_COLUMNS) )
                   `$INSTANCE_NAME`_ledArray[y][xpos] = bg;
            }
        }
        xpos++;
    }
    `$INSTANCE_NAME`_DrawLine(xpos-1, ypos, xpos-1, ypos+`$INSTANCE_NAME`_fontY, bg);
}