Thursday, December 5, 2019

Embedded

Raster Fonts on Arduino

I was asked a while ago to come up with software to print raster fonts with an arduino. This may seem simple until you realize that you must render each line of pixels individually or you’ll run out of ram. Throw some non-fixed width fonts in there and it’s a real nightmare. Anyways here’s the gist of it: void setup() { Serial.begin(38400); Wire.begin(); //Begin I2C as master pinMode(LEDPIN, OUTPUT); pinMode(BUTTON, INPUT); } void serialPrint(unsigned char ch, unsigned short xPos) { for (int j = 6; j > -1; j–) { Serial.write(pgm_read_byte(&CharTable[ch][j + 2 + 7 * xPos])); } } void …continue reading