Main Site Documentation

Display T43 Errors ("Type 0F (String...")


#1

I have a routine that runs every second; this routine updates the display :

using System;
using System.IO;
using System.Collections;
using System.Threading;
using Microsoft.SPOT.Hardware;

using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Hardware.FEZHydra;

namespace hydra_centrifuge
{
    public partial class Program
    {
        int counter = 0;
        Font ninab = Resources.GetFont(Resources.FontResources.NinaB);
        Bitmap bmap = new Bitmap(480, 272);

        void ProgramStarted()
        {
            Debug.Print("Program Started");
            InterruptPort IntButton = new InterruptPort(Pin.PD9, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
            IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
//            bmap.DrawLine(Microsoft.SPOT.Presentation.Media.Color.White, 2, 10, 10, 10, 100);
//            bmap.DrawEllipse(Microsoft.SPOT.Presentation.Media.Color.White, 50, 40, 20, 20);
            bmap.DrawTextInRect(counter.ToString(), 100, 100, 100, 100, 0, Color.White, ninab);
            bmap.DrawRectangle(Color.White, 5, 50, 50, 200, 200, 5, 5, Color.White, 1, 5, Color.White, 1, 5, 0);
            bmap.Flush();
            GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
            timer.Tick += new GT.Timer.TickEventHandler(timer_tick);
            timer.Start();

        }

        void IntButton_OnInterrupt(uint port, uint state, DateTime time)
        {
            counter = counter + 1;
        }


        void timer_tick(GT.Timer timer)
        {
                Debug.Print(counter.ToString());
                Bitmap bmap2 = new Bitmap(480, 272);
                bmap2.DrawTextInRect(counter.ToString(), 100, 100, 100, 100, 0, Color.White, ninab);
                bmap2.Flush();
        }  // manages timing


    }
}

All is well, but within usually less than 30 seconds, the debug window gives me something like:

[quote]12
12
12
12
12
GC: 1msec 400248 bytes used, 5890884 bytes available
Type 0F (STRING ): 696 bytes
Type 11 (CLASS ): 10728 bytes
Type 12 (VALUETYPE ): 1032 bytes
Type 13 (SZARRAY ): 3420 bytes
Type 03 (U1 ): 252 bytes
Type 04 (CHAR ): 672 bytes
Type 07 (I4 ): 1044 bytes
Type 0F (STRING ): 36 bytes
Type 11 (CLASS ): 1416 bytes
Type 15 (FREEBLOCK ): 5890884 bytes
Type 16 (CACHEDBLOCK ): 120 bytes
Type 17 (ASSEMBLY ): 28212 bytes
Type 18 (WEAKCLASS ): 96 bytes
Type 19 (REFLECTION ): 192 bytes
Type 1B (DELEGATE_HEAD ): 684 bytes
Type 1D (OBJECT_TO_EVENT ): 216 bytes
Type 1E (BINARY_BLOB_HEAD ): 347760 bytes
Type 1F (THREAD ): 1536 bytes
Type 20 (SUBTHREAD ): 144 bytes
Type 21 (STACK_FRAME ): 1668 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 27 (FINALIZER_HEAD ): 120 bytes
Type 31 (IO_PORT ): 144 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 3336 bytes
12
12[/quote]

The interrupt then seems to die; it continues to write new stuff in the debug window, but it continue counting up if I toggle the button. It also does this if I completely comment all parts/mentions of the interrupt out of the program, so I don’t think it has to do with the interrupt. Any ideas how to fix this?


#2

I moved it outside the timer :

   public partial class Program
    {
        int counter = 0;
        Font ninab = Resources.GetFont(Resources.FontResources.NinaB);
        Bitmap bmap2 = new Bitmap(480, 272);

And it isn’t doing that weird thing any more! Now though the screen is never “cleaning itself up”: The pixels overlap so you get something like a “1” overlaid on a “0”, then a “2”, then a “3”, until it’s just a solid block of white pixels. Do you know how to deal with this?


#3

Never mind; I got it! Thanks!

using System;
using System.IO;
using System.Collections;
using System.Threading;
using Microsoft.SPOT.Hardware;

using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Hardware.FEZHydra;

namespace hydra_centrifuge
{
    public partial class Program
    {
        int counter = 0;
        Font ninab = Resources.GetFont(Resources.FontResources.NinaB);
        Bitmap bmap2 = new Bitmap(480, 272);
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            InterruptPort IntButton = new InterruptPort(Pin.PD9, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
            IntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);
//            bmap.DrawLine(Microsoft.SPOT.Presentation.Media.Color.White, 2, 10, 10, 10, 100);
//            bmap.DrawEllipse(Microsoft.SPOT.Presentation.Media.Color.White, 50, 40, 20, 20);
            Bitmap bmap = new Bitmap(480, 272);
            bmap.DrawTextInRect(counter.ToString(), 100, 100, 100, 100, 0, Color.White, ninab);
            bmap.DrawRectangle(Color.White, 5, 50, 50, 200, 200, 5, 5, Color.White, 1, 5, Color.White, 1, 5, 0);
            bmap.Flush();
            GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
            timer.Tick += new GT.Timer.TickEventHandler(timer_tick);
            timer.Start();

        }

        void IntButton_OnInterrupt(uint port, uint state, DateTime time)
        {
            counter = counter + 1;
        }


        void timer_tick(GT.Timer timer)
        {
                Debug.Print(counter.ToString());
                bmap2.Clear();
                bmap2.DrawTextInRect(counter.ToString(), 100, 100, 100, 100, 0, Color.White, ninab);
                bmap2.Flush();
        }  // manages timing


    }
}

#4

please note that the “weird thing” is purely the output of the garbage collector, telling you how much memory you have available.