FEZ Touch and larger font

Cool :slight_smile: I downloaded the latest version, It now crashes on the Skewworks.Spiral.Graphics.Initialize methode with the following error:
An unhandled exception of type ‘System.InvalidOperationException’ occurred in GHIElectronics.NETMF.Hardware.dll

The iTead module does not use a ReadPin and a Backlight pin so I used Cpu.Pin.GPIO_NONE is that correct?

Spiral tries to actually instance the pin so I’m thinking that will probably fail.

Did you had any chanse to try the iTead display? I really would like to use it, but I have know idea how to proceed :slight_smile:

Great I just used 2 unused pins! And now it runs great! Now all I need to figure out is how to get touch working! Can I use that too?

Touch is available in Spiral, so as long as the pinouts are compatible it should work for you. You might want to try calling the calibrate method.

Nope unfortunatly it is not, the FEZ Touch uses SPI, the iTeadStudio one does not, would it be possible for you to make the touch initialize methode so that I can use alternate pinout (without using SPI)? That would be great, because without touch it is a bit hard to use :slight_smile:

Ah, gotcha it’ll take some time but I can get it hooked up. How’s the rendering speed?

I will post a movie of it a bit later, the speed is not blazing fast, but acceptable :slight_smile:

Here is a little test clip its a Panda with the iTead Display:

:clap: That’s a lot faster than I thought it would be, nicely done!

Ok, so I would also like to use some big fonts to display for example temperature on the display, cannyou please post a short tutorial on how to make a font, because even with the sample picture I can’t get it to work :-[

The easy way is to simply use images…

  1. Look at how we display images
  2. make an array of 30 or more images. Make the size of each image the size you need for your font
  3. draw the characters and symbols you need, one on each image.
  4. test it out
  5. share it back with community :slight_smile:

… this method uses a LOT of memory so you may want to put all images as resources (or SD card) then you can only pull in what you need.

That’s more or less what Spiral’s Font Creator does but the images it makes a 1bit encoded to save on size. Maybe I should offer up the Font Creator for the community…

Hi,

Another simple way to have bigger text without changing the font, is to zoom it by displaying each pixel twice. Of course, it looks a bit blocky and takes much more time to display, but no memory is wasted.

Here’s sample code that needs to be replaced within FEZ_Components_FEZTouch.cs in the driver. It’s pretty basic, but should work fine.


        // Will only work with zoom = 1 or zoom = 2. 
        // Otherwise, the code would need to be changed much more by either
        // 1) Increasing buffer size
        // 2) Draw parts of letters within each buffer
        public void DrawString(string str, int x, int y, Color foreColor, Color backColor, int zoom=1)
        {
            if (x < 0 || y < 0 || (x + str.Length * FONT_WIDTH * zoom) > ScreenWidth || (y + FONT_HEIGHT * zoom) > ScreenHeight)
                throw new ArgumentException();

            int index = 0;
            int length;

            // Max characters per buffer
            int max_chars = BUFFERING_SIZE / (FONT_WIDTH * FONT_HEIGHT * 2 * zoom * zoom + 4);

            // first four bytes are color in the buffer
            buffer[0] = (byte)((int)foreColor >> 8);
            buffer[1] = (byte)(foreColor);

            buffer[2] = (byte)((int)backColor >> 8);
            buffer[3] = (byte)(backColor);

            while (index < str.Length)
            {
                length = (str.Length - index) > max_chars ? max_chars : (str.Length - index);
                DrawString_Internal(x, y, str.Substring(index, length), zoom);
                index += length;
                x += length * FONT_WIDTH * zoom;
            }
        }

        private void DrawString_Internal(int x, int y, string val, int zoom)
        {
            lcdCS.Write(false);

            byte ch;

            // get the foreground and background color bytes before any loops 
            byte bc0 = buffer[2];
            byte bc1 = buffer[3];
            byte fc0 = buffer[0];
            byte fc1 = buffer[1];

            // first four bytes are used for color
            int bufferIndex = 4;

            SetDrawingWindow(x, y, FONT_WIDTH * val.Length * zoom, FONT_HEIGHT * zoom);

            for (int j = 0; j < (12*zoom); j++)
            {
                for (int currentChar = 0; currentChar < val.Length; currentChar++)
                {
                    ch = font[((val[currentChar] - 32) * 12) + (int)(j/zoom)];

                    // use defined masks
                    for (int i = 0; i < 8; i++)
                    {
                        if ((ch & (1<<(8-i))) != 0)
                        {
                            for (int k = 0; k < zoom; k++)
                            {
                                buffer[bufferIndex + 2 * zoom * i + 2 * k] = fc0;
                                buffer[bufferIndex + 2 * zoom * i + 2 * k + 1] = fc1;
                            }
                        }
                        else
                        {
                            for (int k = 0; k < zoom; k++)
                            {
                                buffer[bufferIndex + 2 * zoom * i + 2 * k] = bc0;
                                buffer[bufferIndex + 2 * zoom * i + 2 * k + 1] = bc1;
                            }                            
                        }
                    }

                    bufferIndex += (16 * zoom);
                }
            }

            SetRegister(REGISTER_WRITE_GRAM);
            pp.Write(buffer, 4, bufferIndex - 4);

            lcdCS.Write(true);
        }

Yeah there’s also RLE it all just depends on whats needed. I can always make it separate classes so it is only included when needed like I did w the full screen render and input dialogs.