Ejemplo n.º 1
0
uint8_t MD_PZone::findChar(uint8_t code, uint8_t size, uint8_t *cBuf)
// Find a character either in user defined list or from foint table
{
	charDef	*pcd = _userChars;
	uint8_t	len;

	PRINTX("\nfindUserChar 0x", code);
	while (pcd != NULL)
	{
		PRINTX(" ", pcd->code);
		if (pcd->code == code)	// found it
		{
			PRINTS(" found character");
			len = min(size, pcd->data[0]);
			memcpy(cBuf, &pcd->data[1], len);
			return(len);
		}
		pcd = pcd->next;
	}

	PRINTS(" no user char");
	_MX->setFont(_fontDef);		// change to the font for this zone
	len = _MX->getChar(code, size, cBuf);

	return(len);
}
Ejemplo n.º 2
0
void renameSymbol() {
    int i,k;

    // rename local variable 'i'
    for(i=0; i<10; i++) printf(" %d", i);
    printf("\n");

    // rename the 'renameSymbol' function
    if (0) renameSymbol();

#define PRINTJ() printf("j == %d\n", j)

    // works inside macros, rename for example 'j'
    j = 33; PRINTJ();


    // you can rename any kind of symbol, a macro parameter for example
#define PRINT(renameMe) printf("%d\n", renameMe)

    // renaming 'k' to 'x' will cause name collision
    k = 0;
    {
        int x; x = k; printf("x==%d\n", x);
    }

#define PRINTX() printf("x == %d\n", x);
    // problem can  occur also if a symbol inside  a macro is refering
    // to  various different variables.  Rename  for example following
    // 'x' variable
    {
        int x = 0; 
        PRINTX(); 
    }

}
Ejemplo n.º 3
0
bool MD_PZone::addChar(uint8_t code, uint8_t *data)
// Add a user defined character to the replacement list
{
	charDef	*pcd;

	if (code == 0)
	return(false);

	PRINTX("\naddChar 0x", code);

	// first see if we have the code in our list
	pcd = _userChars;
	while (pcd != NULL)
	{
		if (pcd->code == code)
		{
			pcd->data = data;
			PRINTS(" found existing in list");
			return(true);
		}
		pcd = pcd->next;
	}

	// Now see if we have an empty slot in our list
	pcd = _userChars;
	while (pcd != NULL)
	{
		if (pcd->code == 0)
		{
			pcd->code = code;
			pcd->data = data;
			PRINTS(" found empty slot");
			return(true);
		}
		pcd = pcd->next;
	}

	// default is to add a new node to the front of the list
	if ((pcd = new charDef) != NULL)
	{
		pcd->code = code;
		pcd->data = data;
		pcd->next = _userChars;
		_userChars = pcd;
		PRINTS(" added new node");
	}
	else
	{
		PRINTS(" failed allocating new node");
	}

	return(pcd != NULL);
}
Ejemplo n.º 4
0
uint8_t MD_PZone::makeChar(char c)
// Load a character bitmap and add in trailing char spacing blanks
{
	uint8_t	len;

	PRINTX("\nmakeChar 0x", c);

	// look for the character
	len = findChar((uint8_t)c, ARRAY_SIZE(_cBuf), _cBuf);

	// Add in the inter char spacing
	for (uint8_t i = 0; i<_charSpacing; i++)
	{
		if (len < ARRAY_SIZE(_cBuf))
		_cBuf[len++] = 0;
	}

	PRINT(", len=", len);

	return(len);
}
Ejemplo n.º 5
0
int main() {
    int x = 1;
    renameSymbol();
    PRINTX();
}