Main Site Documentation

What am i missing?


#1

Hi, i just plugged my FEZCerberus, connected a UC_battery_4xAA and one display_n18.

Then i have the following code:


public partial class Program
{
    GT.Timer timer = new GT.Timer(1000);
    Window instance;
    TextBlock textBlock;
    // This method is run when the mainboard is powered up or reset.   
    void ProgramStarted()
    {
        Debug.Print("Program Started");
        timer.Tick += timer_Tick;
        timer.Start();
        instance = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.DebugWindow));
        textBlock = (TextBlock)instance.GetChildByName("TextBlock");
        textBlock.Text = ".";
        Glide.MainWindow = instance;
        Glide.FitToScreen = true;
        instance.Invalidate();
    }
    int count;
    void timer_Tick(GT.Timer timer)
    {
        count++;
        //display_N18.SetBacklight(count % 2 == 1);
        Mainboard.SetDebugLED(count % 2 == 0);
        textBlock.Text += ".";
        instance.Invalidate();
    }
}

DebugWindow.xml contains the following:

<?xml version="1.0" encoding="utf-8"?>

The debug led is blinking so i know the code is running but my screen is on but its empty…

What am i doing wrong?
(i didn’t do the LCD Configuration in the FEZ Config, i have no idea what values to input).


#2

Are there any error messages in the output/console window?

If you insert the display in the Gadgeteer designer, it will be initialized for you.

BTW, the first time you run the program, the display will be initialized and you will have to reboot for the display to be active.


#3

I didn’t understand how to debug my device but now i do, well first a got a error when Glide was trying to load Gif images (FEZCerberus only seems to support bmp), i resolved that by removing all gif images and the references to them.

Then i got “Failed allocation for 3419 blocks, 41028 bytes” and i guess thats a indicator that FEZCerberus doesn’t have enough ram to run glide??


#4

I didn’t think you could use Glide and the display libraries directly with the Cerberus because of limited resources. There isn’t enough memory for full bitmap manipualtion on that board. See the notes in the dev guide (https://www.ghielectronics.com/docs/59/display-n18-module).

You might take a look at some of the projects in Code Share that use the N18 with the Cerberus. They show simple code for display. Here is one: https://www.ghielectronics.com/community/codeshare/entry/863


#5

@ Petoj -

That was my thought when I asked for error messages. The Cerberus has 112KB of available memory, and a 160x128 screen requires 82K of memory. I don’t know how buffering is done with the N18 module and Glide. They both may have buffers which could cause a memory shortage.


#6

After a little debugging i noticed that this message was printed when glide tried to allocate the bitmap object!

How sad i have written a more or less complete project where im using Glide and now i can’t use it atleas not with Cerberus!
Well well its my own fault thanks for your quick responses!


#7

Yes, be sure to take a look at the Developers Guide when considering a module. It often lists restrictions or considerations when using different main boards. Especially pat attention when using Cobra II, Cerberus, Medusa, and Lynx.


#8

Well i managed to get rid of the memory shortage error but i had to remove a lot of code from Glide and add a Debug.GC(true); before it allocated the Bitmap…

But the screen is still empty.

:wall:


#9

Petoj, perhaps you can look at a simple text output to prove that your display is connected correctly and working.

Here’s a thread that Taylorza showed some great and simple code that is very optimised to the low memory on Cerb situation.

https://www.ghielectronics.com/community/forum/topic?id=14026&page=1


#10

Good idea, i tested the code Blue Hair Bob linked to and it worked so the display is functional. my first idea was that i broke some thing in Glide when removing all the code but if i use the same library with the emulator it still works :(…


#11

I guess ill have to rewrite the gui some other way, but one question is there any way to figure out what is taking up all the memory?


#12

yes, it’s graphics.

Sorry, don’t want to sound flippant, but the challenge is in the size of the graphics bitmap/s. Glide, while better than WPF, is still not “light”; perhaps the Skewworks libraries are something you could look at although Thom has announced he isn’t maintaining them at the moment, so they are what they are… http://www.skewworks.com/picomax/ seems the right target for you?