Skip to content

Hyperdisplay Compatibility #32

@iangrahamchristensen

Description

@iangrahamchristensen

I've attempted to add your 8x16 font size to the hyperdisplay library, but I would appreciate some help. I began by adding the microview 8x16font.h bitmap from your repository. I copied the getCharInfo() method in hyperdisplay.cpp, and I'm attempting to rework the algorithm for the 8x16font.h, however, I'm running into some issues. When I try writing out the bitmap on graphing paper I end up with gibberish, and when running the code the size is still 5x7 unless I swap indi and indj at line 973 --> if(values[indj] & (0x01 << indi)).

		void hyperdisplay::getCharInfo(uint8_t character, char_info_t * character_info) 
		{
			character_info->data = NULL;	// Use the window's current color

			// Link the default cordinate arrays
			character_info->xLoc = hyperdisplayAlternativeXloc;
			character_info->yLoc = hyperdisplayAlternativeYloc;

			// Set the maximum x and y dimensions
			character_info->xDim = 8;
			character_info->yDim = 17;

			// Figure out if the character should cause a newline
			if (character == '\r' || character == '\n')
			{
				character_info->causesNewline = true;
			}
			else
			{
				character_info->causesNewline = false;
			} 

			// Figure out if you need to actually show the chracter
			if((character >= ' ') && (character <= '~'))
			{
				character_info->show = true;
			}
			else
			{
				character_info->show = false;
				return;								// No point in continuing;
			}

			// This will store the hex values that represent each column of pixels
			int values[17];

			// The first value skips the first row of definitions
			// The second value is the character width
			// The third value is the ASCII start character
			int offset = 6 + 8 * (character - 32);

			// Counter for how many pixels need to be printed
			character_info->numPixels = 0;
			
			// The index value of the next X and Y locations
			int n = 0;
			
			// Read the 8 different hex values being saved in the array
			for(int indi = 0; indi < 16; indi++)
			{

				// Sets each value in the array to a hex value from the fontmap, 
				// which in binary should be a set of bits that are on or off
				// representing the pixels that are either black or white, etc.
				// (the sum of the offset and indi are the index of the byte being read)
				values[indi] = pgm_read_byte(font8x16 + offset + indi);

				// Now go through each row of the character's pixels and confirm whether to print a pixel or not
				for(int indj = 0; indj < 8; indj++)
				{
					// Not sure what this does or why it works, but I switched the
					// indi and indj values and the TFT displays the correct size
					// (obviously the the 0x01 is shifted to the left by indj, and 
					//  then the column value is ANDed together to see if the outcome
					//  is true...not sure what that means though without understanding
					//  the fontmap better)
					if(values[indi] & (0x01 << indj))
					{
						// A pixel is being added so we need to increase the numPixels counter
						character_info->numPixels++;

						// Add the x and y locations of the new pixel to the character_info struct
						*(character_info->xLoc + n) = (hd_font_extent_t)indi;
						*(character_info->yLoc + n) = (hd_font_extent_t)indj;

						// Increment the index value because we just filled the current index with pixel data
						n++;
					}
				}
			}
		}

Here is the link to the file I'm using: https://github.com/iangchristensen/SparkFun_HyperDisplay_Library/blob/master/SparkFun_HyperDisplay_Library/src/hyperdisplay.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions