TouchC8 tests

Hello,
I forgot a test and a module yesterday evening :

The test : I’ve change the diagram, now TouchC8 is defined as “connected to socket 5”. Now, each details explained in previous post are the same, but on the other socket.
Yesterday my abstract was precipitate. Now I can say it :
[ul]on incoherent socket : function ok, but no debug available.
on coherent socket : function ok when debug is active.[/ul]

I also have a Midas LCD display, controlled by I2C. And I’ve tested it successfully on socket 5 or 6, but it was the only module connected to the board, without anything in diagramm.
I’ve just made a test : In the diagramm, if I add a touchC8 on one of the socket 5 or 6, without connected it (on the bench) nor code write by myself, display doesn’t work anymore. But I’m not surprised.

Thank you,
Arnaud.

hi Arnaud,

can I suggest you start a separate, new project, make sure you target 4.3 framework, and then only add the TouchC8 module in the designer. From there, add the code @ Sprigo supplied, and try that out? It would be good to remove any aspects from your project that may be influencing this

From a Gadgeteer socket perspective, the I2C port lines are duplicated on both socket 5 and socket 6, so that means for the “simple” I2C comms between the Hydra and the C8 module, either socket will work. Where it becomes more important to have the socket in the designer and the socket in real life match is when you use features that use the two other pins, the interrupt pin and the reset pin. When I checked the module’s code, if you mismatch the sockets then there probably isn’t any significant difference in the case where you power on the entire device together, and there certainly won’t be any errors noticed by the code, those portions of the code that use the reset pin will just happily toggle the pin it is intending to (that doesn’t actually reset the C8’s chip) and no interrupt will be seen by the Hydra (since the pin the signal will be supplied to is not set up to receive interrupts). So there really is no value in testing anything besides having the designer and the physical hardware set up correctly. Pick a socket and stick with it.

One other addition I might suggest you add to the code @ Sprigo supplied is a simple timer that flashes the mainboard debug LED every 250ms or so (I would suggest you don’t do that any more often than that in your test, and maybe even start at 500 or 1000). That way you can see the app is still running as expected.

I’d also ask can you please run Fez Config and check firmware versions, and paste the results back here? Upgrade if there’s a mismatch reported too!

So in summary:
Create a new app;
Check you’re targeting 4.3;
Set your hardware and designer up consistently;
Add @ Sprigo’s code (plus timer);
Deploy app and watch debug messages and mainboard’s LED flash;
Show us the output from the debug messages as you touch the C8.

Hello Brett & Sprigo.

I understand…

I’ve recheck FEZ Config, everything seems ok for me :
[b] Loader (TinyBooter) version information:
4.3.7.7 on this computer.
4.3.7.7 on this device.

The Loader (TinyBooter) is up to date. <<<

Firmware (TinyCLR) version information:
4.3.7.10 on this computer.
4.3.7.10 on this device.

The Firmware (TinyCLR) is up to date. <<<
Please wait for the device to reboot… Done.[/b]

Here is the full code :

//using System;
//using System.Collections;
using System.Threading;
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;

namespace TestC8T_2
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            Mainboard.SetDebugLED(true);
            Thread.Sleep(200); // leave it on for 1 second
            Mainboard.SetDebugLED(false);

            touchC8.ButtonPressed += touchC8_ButtonPressed;
            touchC8.ButtonReleased += touchC8_ButtonReleased;
            touchC8.ProximityEnter += touchC8_ProximityEnter;
            touchC8.ProximityExit += touchC8_ProximityExit;
            touchC8.WheelPositionChanged += touchC8_WheelPositionChanged;
            touchC8.WheelPressed += touchC8_WheelPressed;
            touchC8.WheelReleased += touchC8_WheelReleased;

            GT.Timer timer = new GT.Timer(250); // Create a timer
            timer.Tick += timer_Tick; // Run the method timer_tick when the timer ticks
            timer.Start(); // Start the timer

        }


        bool state = false;
        void timer_Tick(GT.Timer timer)
        {
            state = !state; // Invert the state (to blink the LED)
            Mainboard.SetDebugLED(state); // Set the LED to state
        }

        void touchC8_WheelReleased(TouchC8 sender, TouchC8.WheelTouchedEventArgs e)
        {
            Debug.Print("Wheel Released Event : State = " + e.State.ToString());
        }

        void touchC8_WheelPressed(TouchC8 sender, TouchC8.WheelTouchedEventArgs e)
        {
            Debug.Print("Wheel Pressed Event : State = " + e.State.ToString());
        }

        void touchC8_WheelPositionChanged(TouchC8 sender, TouchC8.WheelPositionChangedEventArgs e)
        {
            Debug.Print("Wheel Position Changed Event : Position = " + e.Position.ToString() + " Direction = " + e.Direction.ToString());
        }

        void touchC8_ProximityExit(TouchC8 sender, TouchC8.PromixityDetectedEventArgs e)
        {
            Debug.Print("Proximity Exit Event : " + e.State.ToString());
        }

        void touchC8_ProximityEnter(TouchC8 sender, TouchC8.PromixityDetectedEventArgs e)
        {
            Debug.Print("Proximity Enter Event : " + e.State.ToString());
        }

        void touchC8_ButtonReleased(TouchC8 sender, TouchC8.ButtonTouchedEventArgs e)
        {
            Debug.Print("Button Released : " + e.Button.ToString());
        }

        void touchC8_ButtonPressed(TouchC8 sender, TouchC8.ButtonTouchedEventArgs e)
        {
            Debug.Print("Button Pressed : " + e.Button.ToString());
        }
    }
}

Here is the debug result. I precise that all debug messages seem consistent with TouchC8 manipulations.

Le thread ‘’ (0x2) s’est arrêté avec le code 0 (0x0).
Using mainboard GHI Electronics FEZ Hydra version 1.2
Program Started
Le thread ‘’ (0x3) s’est arrêté avec le code 0 (0x0).
Proximity Enter Event : True
Proximity Exit Event : False
Proximity Enter Event : True
Proximity Exit Event : False
Proximity Enter Event : True
Wheel Position Changed Event : Position = 45 Direction = 1
Wheel Pressed Event : State = True
Wheel Released Event : State = False
Proximity Exit Event : False
Proximity Enter Event : True
Button Pressed : 8
Button Released : 8
Proximity Exit Event : False
Proximity Enter Event : True
Button Pressed : 4
Button Released : 4
Button Pressed : 2
Button Released : 2
Proximity Exit Event : False
Proximity Enter Event : True
Button Pressed : 8
Button Released : 8
Button Pressed : 4
Button Released : 4
Button Pressed : 2
Button Released : 2
Button Pressed : 2
Button Released : 2
Button Pressed : 4
Button Released : 4
Proximity Exit Event : False
Proximity Enter Event : True
Button Pressed : 4
Button Pressed : 2
Button Released : 2
Button Released : 4
Proximity Exit Event : False
Proximity Enter Event : True
Proximity Exit Event : False
Proximity Enter Event : True
Wheel Position Changed Event : Position = 180 Direction = 1
Wheel Pressed Event : State = True
Wheel Released Event : State = False
Wheel Position Changed Event : Position = 270 Direction = 1
Wheel Pressed Event : State = True
Wheel Position Changed Event : Position = 279 Direction = 0
Wheel Position Changed Event : Position = 283.5 Direction = 0
Wheel Position Changed Event : Position = 270 Direction = 1
Wheel Released Event : State = False
Wheel Pressed Event : State = True
Wheel Position Changed Event : Position = 279 Direction = 0
Wheel Position Changed Event : Position = 292.5 Direction = 0
Wheel Position Changed Event : Position = 301.5 Direction = 0
Wheel Position Changed Event : Position = 310.5 Direction = 0
Wheel Position Changed Event : Position = 315 Direction = 0
Wheel Position Changed Event : Position = 324 Direction = 0
Wheel Position Changed Event : Position = 337.5 Direction = 0
Wheel Position Changed Event : Position = 351 Direction = 0
Wheel Position Changed Event : Position = 0 Direction = 0
Wheel Position Changed Event : Position = 9 Direction = 0
Wheel Position Changed Event : Position = 18 Direction = 0
Wheel Position Changed Event : Position = 27 Direction = 0
Wheel Position Changed Event : Position = 36 Direction = 0
Wheel Position Changed Event : Position = 40.5 Direction = 0
Wheel Position Changed Event : Position = 54 Direction = 0
Wheel Position Changed Event : Position = 63 Direction = 0
Wheel Position Changed Event : Position = 72 Direction = 0
Wheel Position Changed Event : Position = 81 Direction = 0
Wheel Position Changed Event : Position = 90 Direction = 0
Wheel Position Changed Event : Position = 99 Direction = 0
Wheel Position Changed Event : Position = 108 Direction = 0
Wheel Position Changed Event : Position = 117 Direction = 0
Wheel Position Changed Event : Position = 126 Direction = 0
Wheel Position Changed Event : Position = 135 Direction = 0
Wheel Position Changed Event : Position = 144 Direction = 0
Wheel Position Changed Event : Position = 153 Direction = 0
Wheel Position Changed Event : Position = 157.5 Direction = 0
Wheel Position Changed Event : Position = 166.5 Direction = 0
Wheel Position Changed Event : Position = 180 Direction = 0
Wheel Position Changed Event : Position = 184.5 Direction = 0
Wheel Position Changed Event : Position = 193.5 Direction = 0
Wheel Position Changed Event : Position = 198 Direction = 0
Wheel Position Changed Event : Position = 207 Direction = 0
Wheel Position Changed Event : Position = 216 Direction = 0
Wheel Position Changed Event : Position = 225 Direction = 0
Wheel Position Changed Event : Position = 229.5 Direction = 0
Wheel Position Changed Event : Position = 238.5 Direction = 0
Wheel Position Changed Event : Position = 243 Direction = 0
Wheel Position Changed Event : Position = 247.5 Direction = 0
Wheel Position Changed Event : Position = 252 Direction = 0
Wheel Position Changed Event : Position = 261 Direction = 0
Wheel Position Changed Event : Position = 270 Direction = 0
Wheel Position Changed Event : Position = 279 Direction = 0
Wheel Position Changed Event : Position = 288 Direction = 0
Wheel Position Changed Event : Position = 292.5 Direction = 0
Wheel Position Changed Event : Position = 297 Direction = 0
Wheel Position Changed Event : Position = 315 Direction = 0
Wheel Position Changed Event : Position = 319.5 Direction = 0
Wheel Position Changed Event : Position = 333 Direction = 0
Wheel Position Changed Event : Position = 337.5 Direction = 0
Wheel Position Changed Event : Position = 351 Direction = 0
Wheel Position Changed Event : Position = 0 Direction = 0
Wheel Position Changed Event : Position = 13.5 Direction = 0
Wheel Position Changed Event : Position = 18 Direction = 0
Wheel Position Changed Event : Position = 45 Direction = 0
Wheel Position Changed Event : Position = 45 Direction = 1
Wheel Released Event : State = False
Proximity Exit Event : False
Proximity Enter Event : True
Proximity Exit Event : False
Proximity Enter Event : True
Proximity Exit Event : False
Proximity Enter Event : True
Wheel Position Changed Event : Position = 135 Direction = 1
Wheel Pressed Event : State = True
Wheel Position Changed Event : Position = 121.5 Direction = 1
Wheel Position Changed Event : Position = 108 Direction = 1
Wheel Position Changed Event : Position = 94.5 Direction = 1
Wheel Position Changed Event : Position = 90 Direction = 1
Wheel Position Changed Event : Position = 76.5 Direction = 1
Wheel Position Changed Event : Position = 63 Direction = 1
Wheel Position Changed Event : Position = 54 Direction = 1
Wheel Position Changed Event : Position = 49.5 Direction = 1
Wheel Position Changed Event : Position = 45 Direction = 1
Wheel Position Changed Event : Position = 36 Direction = 1
Wheel Position Changed Event : Position = 27 Direction = 1
Wheel Position Changed Event : Position = 22.5 Direction = 1
Wheel Position Changed Event : Position = 18 Direction = 1
Wheel Position Changed Event : Position = 13.5 Direction = 1
Wheel Position Changed Event : Position = 9 Direction = 1
Wheel Position Changed Event : Position = 4.5 Direction = 1
Wheel Position Changed Event : Position = 0 Direction = 1
Wheel Position Changed Event : Position = 355.5 Direction = 1
Wheel Position Changed Event : Position = 346.5 Direction = 1
Wheel Position Changed Event : Position = 342 Direction = 1
Wheel Position Changed Event : Position = 337.5 Direction = 1
Wheel Position Changed Event : Position = 333 Direction = 1
Wheel Position Changed Event : Position = 328.5 Direction = 1
Wheel Position Changed Event : Position = 319.5 Direction = 1
Wheel Position Changed Event : Position = 301.5 Direction = 1
Wheel Position Changed Event : Position = 292.5 Direction = 1
Wheel Position Changed Event : Position = 288 Direction = 1
Wheel Position Changed Event : Position = 283.5 Direction = 1
Wheel Position Changed Event : Position = 279 Direction = 1
Wheel Position Changed Event : Position = 274.5 Direction = 1
Wheel Position Changed Event : Position = 261 Direction = 1
Wheel Position Changed Event : Position = 252 Direction = 1
Wheel Position Changed Event : Position = 247.5 Direction = 1
Wheel Position Changed Event : Position = 243 Direction = 1
Wheel Position Changed Event : Position = 238.5 Direction = 1
Wheel Position Changed Event : Position = 234 Direction = 1
Wheel Position Changed Event : Position = 225 Direction = 1
Wheel Position Changed Event : Position = 216 Direction = 1
Wheel Position Changed Event : Position = 207 Direction = 1
Wheel Position Changed Event : Position = 202.5 Direction = 1
Wheel Position Changed Event : Position = 198 Direction = 1
Wheel Position Changed Event : Position = 193.5 Direction = 1
Wheel Position Changed Event : Position = 184.5 Direction = 1
Wheel Position Changed Event : Position = 180 Direction = 1
Wheel Position Changed Event : Position = 175.5 Direction = 1
Wheel Position Changed Event : Position = 166.5 Direction = 1
Wheel Position Changed Event : Position = 162 Direction = 1
Wheel Position Changed Event : Position = 153 Direction = 1
Wheel Position Changed Event : Position = 148.5 Direction = 1
Wheel Position Changed Event : Position = 139.5 Direction = 1
Wheel Position Changed Event : Position = 135 Direction = 1
Wheel Position Changed Event : Position = 126 Direction = 1
Wheel Position Changed Event : Position = 117 Direction = 1
Wheel Position Changed Event : Position = 103.5 Direction = 1
Wheel Position Changed Event : Position = 99 Direction = 1
Wheel Position Changed Event : Position = 90 Direction = 1
Wheel Position Changed Event : Position = 81 Direction = 1
Wheel Position Changed Event : Position = 72 Direction = 1
Wheel Position Changed Event : Position = 63 Direction = 1
Wheel Position Changed Event : Position = 54 Direction = 1
Wheel Position Changed Event : Position = 45 Direction = 1
Wheel Released Event : State = False
Proximity Exit Event : False
Le programme ‘[2] Micro Framework application: Managé’ s’est arrêté avec le code 0 (0x0).

Concerning Le thread ‘’ (0x3) s’est arrêté avec le code 0 (0x0). and 2 others message :
May be the translation would be something like that :
[em]The thread ‘’ (0x3) has stopped with code 0 (0x0).[/em]

I’ve allways saw this type of message when debug. And you ?
In other programm I made, If it runs several minutes, this message sometime appears and the first value increase.

And last : My diagramm and Bench are consistent : Touch C8 connnected on socket 6.

Conclusion would be that hardware is ok ?
Thanks.
Arnaud.

It works so good…

And I discover a new way to code : touchC8.WheelPressed += touchC8_WheelPressed;

Maybe my first code generates problem (C type) ? Each 50 ms, checking function like touchC8.IsWheelPressed() seems basic to me, but in C#, NETMF…?
Thak you all.

Arnaud.

that just says that a thread (in this case one Gadgeteer creates for you that you don’t need to worry about) has finished successfully (return code 0). You can totally ignore it.

As for all the other debug output, it all looks great. It’s working fine.

1 Like

Glad to hear it’s all working.

Basically you set things up, register your event handlers and then sit back and wait for an event to happen. No need to keep checking.

;D

1 Like

Thanks all 3.
I learn, it seem I have solution using handlers… I’ll proceed with.
(even if I still don’t understand what’s happen in my code… )

Arnaud.