Driver - FEZ Touch Driver Ver 2.3

[title]FEZ Touch Driver Ver 2.3[/title]
http://code.tinyclr.com/project/363/fez-touch-driver-ver-23/
[line]
This is an updated driver for the FEZ Touch LCD touch display.

This driver adds support for custom fixed and proportional fonts, landscape and portrait modes, and display mode for controlling the LCD backlight (On, Dim, or Off).

Updated to Ver 2.3, which includes a PortraitInverted Orientation added by Steh from the TinyCLR forum.

I’ve developed a FEZ Touch Font Generator application for creating your own fonts (also uploaded to TinyCLR Code).

I use FEZ Driver on Panda 2 and I need to output Cyrillic symbols. But when I generate font for Cyrillic by Font Generator and use it, the program throws exception in line:

ushort charWidth = (ushort)(this.charDescriptors[descriptorIndex] & bitMask);

of Font class in FEZTouchDriver.cs.

After debugging I figure out that descriptorIndex for any Cyrillic symbol is more than 1000, however charDescriptors has only 350 elements.
But I still can’t fix the problem with that.

Andriy
Which font are you using? I would like to install that font on my computer and do some tests.

For example, this one:


//
// Copyright 2011, JASDev International
// This file was generated automatically by FEZ Touch Font Generator.
// Go to http://www.jasdev.com for more information.
//

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;

namespace FEZTouch.Fonts
{
    public class FontUkr : FEZ_Components.FEZTouch.Font
    {
        // CONSTRUCTOR
        public FontUkr()
        {
            // set properties
            this.avgWidth = 0;
            this.maxWidth = 8;
            this.height = 16;
            this.startChar = ' ';
            this.endChar = 'ї';

            // attach string pointers to const strings
            this.charDescriptors = constFontUkrDescriptors;
            this.charBitmaps = constFontUkrBitmaps;
        }

        // character descriptor array
        public const string constFontUkrDescriptors =
            //  [width][height][offset][length]   [character]
                "\u8008\u8010\u8000\u8001" +    // [ ]
                "\u8008\u8010\u8001\u8007" +    // [!]
                "\u8008\u8010\u8008\u8005" +    // ["]
                "\u8008\u8010\u800D\u8007" +    // [#]
                "\u8008\u8010\u8014\u8007" +    // [$]
                "\u8008\u8010\u801B\u8007" +    // [%]
                "\u8008\u8010\u8022\u8007" +    // [&]
                "\u8008\u8010\u8029\u8004" +    // [']
                "\u8008\u8010\u802D\u8008" +    // [(]
                "\u8008\u8010\u8035\u8008" +    // [)]
                "\u8008\u8010\u803D\u8005" +    // [*]
                "\u8008\u8010\u8042\u8007" +    // [+]
                "\u8008\u8010\u8049\u8008" +    // [,]
                "\u8008\u8010\u8051\u8005" +    // [-]
                "\u8008\u8010\u8056\u8007" +    // [.]
                "\u8008\u8010\u805D\u8007" +    // [/]
                "\u8008\u8010\u8064\u8007" +    // [0]
                "\u8008\u8010\u806B\u8007" +    // [1]
                "\u8008\u8010\u8072\u8007" +    // [2]
                "\u8008\u8010\u8079\u8007" +    // [3]
                "\u8008\u8010\u8080\u8007" +    // [4]
                "\u8008\u8010\u8087\u8007" +    // [5]
                "\u8008\u8010\u808E\u8007" +    // [6]
                "\u8008\u8010\u8095\u8007" +    // [7]
                "\u8008\u8010\u809C\u8007" +    // [8]
                "\u8008\u8010\u80A3\u8007" +    // [9]
                "\u8008\u8010\u80AA\u8007" +    // [:]
                "\u8008\u8010\u80B1\u8007" +    // [;]
                "\u8008\u8010\u80B8\u8007" +    // [<]
                "\u8008\u8010\u80BF\u8005" +    // [=]
                "\u8008\u8010\u80C4\u8006" +    // [>]
                "\u8008\u8010\u80CA\u8007" +    // [?]
                "\u8008\u8010\u80D1\u8007" +    // [@ ]
                "\u8008\u8010\u80D8\u8008" +    // [[]
                "\u8008\u8010\u80E0\u8007" +    // [\]
                "\u8008\u8010\u80E7\u8008" +    // []]
                "\u8008\u8010\u80EF\u8004" +    // [^]
                "\u8008\u8010\u80F3\u8009" +    // [_]
                "\u8008\u8010\u80FC\u8003" +    // [`]
                "\u8008\u8010\u80FF\u8007" +    // [{]
                "\u8008\u8010\u8106\u8008" +    // [|]
                "\u8008\u8010\u810E\u8007" +    // [}]
                "\u8008\u8010\u8115\u8005" +    // [~]
                "\u8008\u8010\u811A\u8007" +    // [Є]
                "\u8008\u8010\u8121\u8007" +    // [І]
                "\u8008\u8010\u8128\u8007" +    // [Ї]
                "\u8008\u8010\u812F\u8007" +    // [А]
                "\u8008\u8010\u8136\u8007" +    // [Б]
                "\u8008\u8010\u813D\u8007" +    // [В]
                "\u8008\u8010\u8144\u8007" +    // [Г]
                "\u8008\u8010\u814B\u8008" +    // [Д]
                "\u8008\u8010\u8153\u8007" +    // [Е]
                "\u8008\u8010\u815A\u8007" +    // [Ж]
                "\u8008\u8010\u8161\u8007" +    // [З]
                "\u8008\u8010\u8168\u8007" +    // [И]
                "\u8008\u8010\u816F\u8007" +    // [Й]
                "\u8008\u8010\u8176\u8007" +    // [К]
                "\u8008\u8010\u817D\u8007" +    // [Л]
                "\u8008\u8010\u8184\u8007" +    // [М]
                "\u8008\u8010\u818B\u8007" +    // [Н]
                "\u8008\u8010\u8192\u8007" +    // [О]
                "\u8008\u8010\u8199\u8007" +    // [П]
                "\u8008\u8010\u81A0\u8007" +    // [Р]
                "\u8008\u8010\u81A7\u8007" +    // [С]
                "\u8008\u8010\u81AE\u8007" +    // [Т]
                "\u8008\u8010\u81B5\u8007" +    // [У]
                "\u8008\u8010\u81BC\u8007" +    // [Ф]
                "\u8008\u8010\u81C3\u8007" +    // [Х]
                "\u8008\u8010\u81CA\u8008" +    // [Ц]
                "\u8008\u8010\u81D2\u8007" +    // [Ч]
                "\u8008\u8010\u81D9\u8007" +    // [Ш]
                "\u8008\u8010\u81E0\u8008" +    // [Щ]
                "\u8008\u8010\u81E8\u8007" +    // [Ь]
                "\u8008\u8010\u81EF\u8007" +    // [Ю]
                "\u8008\u8010\u81F6\u8007" +    // [Я]
                "\u8008\u8010\u81FD\u8007" +    // [а]
                "\u8008\u8010\u8204\u8007" +    // [б]
                "\u8008\u8010\u820B\u8007" +    // [в]
                "\u8008\u8010\u8212\u8007" +    // [г]
                "\u8008\u8010\u8219\u8007" +    // [д]
                "\u8008\u8010\u8220\u8007" +    // [е]
                "\u8008\u8010\u8227\u8007" +    // [ж]
                "\u8008\u8010\u822E\u8007" +    // [з]
                "\u8008\u8010\u8235\u8007" +    // [и]
                "\u8008\u8010\u823C\u8007" +    // [й]
                "\u8008\u8010\u8243\u8007" +    // [к]
                "\u8008\u8010\u824A\u8007" +    // [л]
                "\u8008\u8010\u8251\u8007" +    // [м]
                "\u8008\u8010\u8258\u8007" +    // [н]
                "\u8008\u8010\u825F\u8007" +    // [о]
                "\u8008\u8010\u8266\u8007" +    // [п]
                "\u8008\u8010\u826D\u8008" +    // [р]
                "\u8008\u8010\u8275\u8007" +    // [с]
                "\u8008\u8010\u827C\u8007" +    // [т]
                "\u8008\u8010\u8283\u8008" +    // [у]
                "\u8008\u8010\u828B\u8008" +    // [ф]
                "\u8008\u8010\u8293\u8007" +    // [х]
                "\u8008\u8010\u829A\u8007" +    // [ц]
                "\u8008\u8010\u82A1\u8007" +    // [ч]
                "\u8008\u8010\u82A8\u8007" +    // [ш]
                "\u8008\u8010\u82AF\u8007" +    // [щ]
                "\u8008\u8010\u82B6\u8007" +    // [ь]
                "\u8008\u8010\u82BD\u8007" +    // [ю]
                "\u8008\u8010\u82C4\u8007" +    // [я]
                "\u8008\u8010\u82CB\u8007" +    // [є]
                "\u8008\u8010\u82D2\u8007" +    // [і]
                "\u8008\u8010\u82D9\u8007";     // [ї]

        // character bitmap array
        public const string constFontUkrBitmaps =
            "\u8000" +
            "\u8000\u8000\uC040\u8080\u8101\u8000\u8004" +
            "\u8000\u8000\uB1B0\uA123\u8002" +
            "\u8000\u9000\u9121\uA3F1\uE242\uC48F\u8484" +
            "\u8000\uA000\u90E0\uC021\uC201\u8384\u8404" +
            "\u8000\u8000\uA810\u8020\u80E3\u8502\u8004" +
            "\u8000\u8000\uC000\uC043\uC180\u848A\u801E" +
            "\u8000\u8000\uA020\uC040" +
            "\u8000\u8000\u8080\u8081\u8101\u8202\u8804\u8010" +
            "\u8000\u8000\u9010\uC040\u8080\u8101\u8102\u8002" +
            "\u8000\u8000\uF040\uC083\u8282" +
            "\u8000\u8000\uC000\u8080\u8FE1\u8202\u8004" +
            "\u8000\u8000\u8000\u8000\u8000\u8300\u8302\u8002" +
            "\u8000\u8000\u8000\u8000\u87E0" +
            "\u8000\u8000\u8000\u8000\u8000\u8300\u8006" +
            "\u8000\uC000\uC080\uC080\uC080\uC080\u8080" +
            "\u8000\u8000\u88F0\u9212\uA424\u8848\u800F" +
            "\u8000\u8000\uF040\u8080\u8101\u8202\u801F" +
            "\u8000\u8000\u8870\u8101\uC081\uC440\u800F" +
            "\u8000\u8000\u8870\uC101\u8201\u8444\u8007" +
            "\u8000\u8000\uA0C0\uA121\u87E2\u8404\u801C" +
            "\u8000\u8000\u91F0\uE020\u8403\u8848\u800F" +
            "\u8000\u8000\uA1C0\uE020\uC443\u8888\u800E" +
            "\u8000\u8000\u89F8\u8202\u8202\u8202\u8004" +
            "\u8000\u8000\u88F0\uE212\uA423\u8848\u800F" +
            "\u8000\u8000\u88F0\u9212\u87C4\uC408\u8007" +
            "\u8000\u8000\u8000\uC0C0\u8001\u8300\u8006" +
            "\u8000\u8000\u8000\uC0C0\u8001\u8300\u8103" +
            "\u8000\u8000\u8000\uC182\u8060\u8601\u8010" +
            "\u8000\u8000\u8000\u83F0\u87E0" +
            "\u8000\u8000\u8800\u8060\u8601\uC182" +
            "\u8000\u8000\u90E0\u8202\u8204\u8002\u8006" +
            "\u8000\uB800\u8888\uD191\uA2A2\uC046\u8708" +
            "\u8000\u8000\uA0E0\uC040\u8080\u8101\u8202\u801C" +
            "\u8000\u8400\u9008\uC020\u8080\u8201\u8404" +
            "\u8000\u8000\uA038\uC040\u8080\u8101\u8202\u8007" +
            "\u8000\u9000\uD020\u8110" +
            "\u8000\u8000\u8000\u8000\u8000\u8000\u8000\u8000\u80FF" +
            "\u8000\u8000\uC020" +
            "\u8000\u8000\uA040\uC040\u8040\u8101\u8402" +
            "\u8000\u8000\uA020\uC040\u8080\u8101\u8202\u8004" +
            "\u8000\u8000\uA010\uC040\u8100\u8101\u8102" +
            "\u8000\u8000\u8000\uE000\u8324" +
            "\u8000\u8000\u8970\uF213\uA021\u8840\u800F" +
            "\u8000\u8000\uC1F0\u8080\u8101\u8202\u801F" +
            "\u8000\u8090\uC1F0\u8080\u8101\u8202\u801F" +
            "\u8000\u8000\uC060\uC140\u8282\uC887\u803B" +
            "\u8000\u8000\u91F8\uE022\uC443\uC888\u800F" +
            "\u8000\u8000\u90F8\uE222\uC443\uC888\u800F" +
            "\u8000\u8000\u91F8\uA222\uC040\uC080\u8003" +
            "\u8000\u8000\uA3F0\uC242\u8484\uC889\uA0BF\u8041" +
            "\u8000\u8000\u91F8\uE0A2\uC141\uC880\u801F" +
            "\u8000\u8000\uAB2C\uE151\uA2C1\uE945\u8032" +
            "\u8000\u8000\uB0D0\u8222\u8403\u8808\u800F" +
            "\u8000\u8000\u8B1C\u9293\uA4A5\uE8C9\u8038" +
            "\uA400\u8030\u8B1C\u9293\uA4A5\uE8C9\u8038" +
            "\u8000\u8000\u9338\uE0A5\uC140\uC884\u8033" +
            "\u8000\u8000\uA3F0\uC242\u8484\uC949\u8039" +
            "\u8000\u8000\uB3B8\uA363\uC545\uC888\u803B" +
            "\u8000\u8000\u93B8\uE222\uC447\uC888\u803B" +
            "\u8000\u8000\u90E0\u9412\uA828\u8890\u800E" +
            "\u8000\u8000\u93F8\uA222\uC444\uC888\u803B" +
            "\u8000\u8000\u90F8\uA222\uC3C4\uC080\u8003" +
            "\u8000\u8000\u91E0\u9012\uA020\u8880\u800E" +
            "\u8000\u8000\uCBF8\u8084\u8101\u8202\u800E" +
            "\u8000\u8000\u93B8\uC142\u8102\uC142\u8003" +
            "\u8000\u8000\uC0E0\u93E0\uC929\u820F\u800E" +
            "\u8000\u8000\u93B8\u8142\u8101\uC885\u803B" +
            "\u8000\u8000\u93B8\uA222\uC444\uC888\uA03F\u8040" +
            "\u8000\u8000\u93B8\uA222\u8644\u880B\u8038" +
            "\u8000\u8000\uCAEC\u9494\uA929\uF252\u803F" +
            "\u8000\u8000\uCAEC\u9494\uA929\uF252\uA03F\u8040" +
            "\u8000\u8000\u9038\uE020\uC443\uC888\u800F" +
            "\u8000\u8000\uC99C\uF494\uA929\uF252\u8019" +
            "\u8000\u8000\u93E0\uA222\uC784\uC888\u8038" +
            "\u8000\u8000\u8000\u91E0\uA7C4\u8C48\u8037" +
            "\u8000\uC000\u88F0\uB1D0\uA424\u8848\u800F" +
            "\u8000\u8000\u8000\uA3F0\uC7C4\uD090\u801F" +
            "\u8000\u8000\u8000\uA3F0\uC444\uC088\u8003" +
            "\u8000\u8000\u8000\uA3F0\uC242\uE484\u905F" +
            "\u8000\u8000\u8000\u91E0\uA7E4\u8040\u801F" +
            "\u8000\u8000\u8000\uAED8\uC18B\uEA46\u8036" +
            "\u8000\u8000\u8000\u83F0\u83C4\uC808\u800F" +
            "\u8000\u8000\u8000\uA670\uC546\uC98A\u8039" +
            "\u8000\u9000\u80C1\uA670\uC546\uC98A\u8039" +
            "\u8000\u8000\u8000\uA370\uC1C5\uC884\u8033" +
            "\u8000\u8000\u8000\uC7E0\u8484\uC949\u8039" +
            "\u8000\u8000\u8000\uB738\uA5A6\uE84B\u8039" +
            "\u8000\u8000\u8000\uA770\uC7C4\uC888\u803B" +
            "\u8000\u8000\u8000\u91E0\uA424\u8848\u800F" +
            "\u8000\u8000\u8000\uA7F0\uC444\uC888\u803B" +
            "\u8000\u8000\u8000\uE1B0\uC444\u8888\u810F\u8007" +
            "\u8000\u8000\u8000\u92E0\uA026\u8840\u800F" +
            "\u8000\u8000\u8000\u97F0\u8929\u8202\u800E" +
            "\u8000\u8000\u8000\u9738\uC244\u8304\u8282\u8003" +
            "\u8000\u8000\uC060\u93E0\uA929\u9252\u841F\u801C" +
            "\u8000\u8000\u8000\uA330\u8182\uC483\u8019" +
            "\u8000\u8000\u8000\uA770\uC444\uC888\uA03F" +
            "\u8000\u8000\u8000\u9738\uE624\u880B\u8038" +
            "\u8000\u8000\u8000\u95D8\uA929\uF252\u803F" +
            "\u8000\u8000\u8000\u95D8\uA929\uF252\uA03F" +
            "\u8000\u8000\u8000\uA070\uC3C0\uC888\u800F" +
            "\u8000\u8000\u8000\uD3B8\uA8E8\uF151\u801D" +
            "\u8000\u8000\u8000\uA7C0\u8444\uC88F\u8039" +
            "\u8000\u8000\u8000\u93E0\uA1E4\u8840\u800F" +
            "\u8000\u8000\u8040\u80E0\u8101\u8202\u801F" +
            "\u8000\u8000\u8090\u80E0\u8101\u8202\u801F";
    }
}

The descriptorIndex is calculated as follows:


protected const int constSizeOfCharDescriptor = 4;
int descriptorIndex = (newChar - this.startChar) * constSizeOfCharDescriptor;

This calculation assumes that your set of characters is contiguous, with no missing characters.
In other words your font contains all characters from startChar to endChar.

Jasdev, you want to say that the program throws exception when I use symbol, which is missing in my font?
If yes, than I must say that I tried to use combined set of characters including all Ukrainian and English letters. But it still throws exception.

No, what I’m saying is that the index calculation assumes your font includes all values between startChar and endChar.

If you have a font with only three characters, and they aren’t contiguous, it will fail:

font contains these chars: 0x00, 0x02, 0x04

char startChar = 0x00;
char endChar = 0x04;

If you run this test. It will fail because the index is invalid:

char newChar = 0x04;
descriptorIndex = (newChar - startChar) * constSizeOfCharDescriptor;
descriptorIndex = 16
this.charDescriptors[descriptorIndex]

Now I understand. Thank you!

It works, but only if I put into font lowercase letters without numbers.
When I add uppercase letters to font the program output wrong letters.

@ Andriy

Very good!
Do you have any photos or videos of your display.
It would be cool to see the Cyrillic symbols.

Hello!
Here is photos with Cyrillic.

Another one:

Very cool 8) Thanks!

Очень хорошо! ;D

Thanks!

@ Andriy

Where are you from? I mean what city in Ukrain?

I’m from Ternopil.

@ jasdev
I managed to output Cyrillic letters, but I need to use numbers and other symbols too.
I can’t make font with all needed chars.

Could you fix your Font Generator or FEZ Driver for using combined symbols in one font?

@ Andriy
Yes, I can have a look tonight when I get home from work.
The solution will be to add another array that maps character values to descriptorIndex values.

After my comment about fixing Driver I started to fix it too. And you know, it works! ;D
I did the same, added another array with set of chars to calculate index.