VB Magic

2013/02/06

The Spider is back. This time using VB.net

Filed under: .Net Micro Framework, Fez Spider, Gadgeteer, Glide — Tags: , , , — vbmagic @ 10:55 am

Over the last few days I’ve been gradually re-coding my Gadgeteer game from C# to VB.net now that the .Net Micro Framework 4.2 implementation is ready for the Spider.

That job is now finally over and the game now running as it was under the 4.1 framework.

Here is a little video of it running:

https://vimeo.com/59003253

The code for this project is available on the TinyCLR codeshare page.

I’ll try to work more on it when I get the spare time to do so.

2012/07/31

Argon R1 A new UK developed .NET Gadgeteer Main Board released

Filed under: .Net Micro Framework, Gadgeteer — Tags: , , — vbmagic @ 1:10 pm

Just a quick post about a new Gageteer main board that was developed in the UK by Love Electronics.

Argon R1 Starter Kit

Specifications:

  • Processor: 120Mhz LPC1788 Cortex-M3
  • RAM: 32MB
  • FLASH: 128MB
  • Sockets: 14
  • Size: 92mm x 57mm
  • Weight: 40g

https://www.loveelectronics.co.uk/Blog/24/argon-r1-now-shipping

They also have some modules available:

https://www.loveelectronics.co.uk/categories/97/.net-gadgeteer

2012/06/24

.Net Micro-Framework and VB.net on Fez Spider…A couple of Gotcha’s

Filed under: .NET, C#, Fez Spider, Gadgeteer, VB.NET — Tags: , , , — vbmagic @ 11:50 am

Hi,

I’m at last coding in VB.net with the .net Microframework thanks to the hard work of the people at GHI converting libraries over to use .netmf 4.2

There are a couple of gotcha’s I’ve come across so far converting my Tyrannt game over to VB.

Firstly there is a small problem with the Auto-generated code for resouces which I expect will be fixed by the time the release comes out of Beta.

Inside the code-behind Resources.Designer.vb

Namespace TyranntVB
    Partial Friend Class Resources
        Private Shared manager As System.Resources.ResourceManager
        Friend Shared ReadOnly Property ResourceManager() As System.Resources.ResourceManager
            Get
                If (Resources.manager Is Nothing) Then
                    Resources.manager = New System.Resources.ResourceManager("TyranntVB.Resources", GetType(Resources).Assembly)
                End If
                Return Resources.manager
            End Get
        End Property

You’ll notice there is a Namespace being used. This is what is required in C# but not in Visual Basic. If you remove the Namespace commands

Partial Friend Class Resources
    Private Shared manager As System.Resources.ResourceManager
    Friend Shared ReadOnly Property ResourceManager() As System.Resources.ResourceManager
        Get
            If (Resources.manager Is Nothing) Then
                Resources.manager = New System.Resources.ResourceManager("TyranntVB.Resources", GetType(Resources).Assembly)
            End If
            Return Resources.manager
        End Get
    End Property

Code like this

Resources.GetFont(Resources.FontResources.tyrannt)

Will compile successfully.

Secondly, by default, the project will not know about constants like vbCr and vbLf. I used “\n” quite a bit inside the C# code and when I came to use vbLf the equivalent in VB.net, it caused a compilation error. This is simple to fix. Add the following Imports statement to the top of your code and away you go.

Imports Microsoft.VisualBasic.Constants

I’ll hopefully post again when I have the code ported and running on the Spider.

2012/03/05

New Gadgeteer Main Boards available from GHI

Filed under: .Net Micro Framework, Gadgeteer — Tags: , , , — vbmagic @ 12:22 pm

Hi,

Just wanted to point out some new inexpensive Gadgeteer main boards that have been released by GHI Electronics:

First the FEZ Cerberus kit:
GHI FEZ Cerberus Gadgeteer Basic Kit
http://www.ghielectronics.com/catalog/product/354

And the FEZ Cerb40
GHI Fez Cerb40
http://www.ghielectronics.com/catalog/product/353

Jas

2012/02/20

Fez Spider Talks

Actually got my soldering iron out at the weekend and soldered pins onto the Gadgeteer Extender module.

While rummaging around in my old electronics last week, I came across an old SP03 Text to Speech module:

SP03 Text to Speech module

SP03 Text to Speech module

Info on this device can be found here: SP03 Documentation

So with a breadboard the new soldered Extender module and some connector wires and pull up resistors; it was all connected together and powered on. No magic blue smoke meant that things may actually be working ;-).

Fez Spider with SP03

Fez Spider with SP03

The device uses either serial or I2C communication to communicate which is supported by the FEZ Spider. It took a lot of looking around and a couple of questions on the Tiny CLR forum but I managed to make a class that allowed the communication between the two and managed to make it speak for the first time. Below is that class:

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
 
namespace FEZ_Speak
{
    class SP03
    {
        // initialse the device object
        private I2CDevice _sp03;
 
        // setup constants
        private const byte SP03ADDRESS = 0x62;
        private const int SP03CLOCKRATE = 100;
 
        // setup default speaking paramaters
        private byte _volume = 0x00;
        private byte _speed = 0x03;
        private byte _pitch = 0x05;
 
        // Initialise the hardware
        public SP03()
        {
            I2CDevice.Configuration config = new I2CDevice.Configuration(SP03ADDRESS, SP03CLOCKRATE);
            _sp03 = new I2CDevice(config);
        }
 
        // Speech properties
        public byte Volume
        {
            get { return _volume; }
            set { _volume = value; }
        }
 
        public byte Speed
        {
            get { return _speed; }
            set { _speed = value; }
        }
 
        public byte Pitch
        {
            get { return _pitch; }
            set { _pitch = value; }
        }
 
        // Methods
        // Say something
        public void Say(string speech)
        {
            WaitForSpeechFinish();
            I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[3];
            xActions[0] = I2CDevice.CreateWriteTransaction(GetSettings());
            xActions[1] = I2CDevice.CreateWriteTransaction(ConvertText(speech));
            xActions[2] = I2CDevice.CreateWriteTransaction(SayIt());
            if (_sp03.Execute(xActions, 1000) == 0)
            {
                Debug.Print("Failed to perform I2C transaction");
            }
        }
 
        private byte[] ConvertText(string text)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            byte[] buffer = encoding.GetBytes(text);
            byte[] result = new byte[buffer.Length + 2];
            result[0] = 0;
            result[1] = 0;
            buffer.CopyTo(result, 2);
            return result;
        }
 
        private byte[] GetSettings()
        {
            byte[] speechConfig = new byte[] { 0, 0, _volume, _pitch, _speed };
            return speechConfig;
        }
 
        private byte[] SayIt()
        {
            return new byte[] { 0, 0x40 };
        }
 
        private void WaitForSpeechFinish()
        {
            bool speaking = true;
 
            byte[] request = new byte[1] { 0 };
 
            while (speaking)
            {
                byte[] response = new byte[1];
                I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[2];
                xActions[0] = I2CDevice.CreateWriteTransaction(request);
                xActions[1] = I2CDevice.CreateReadTransaction(response);
                if (response[0] == 0)
                    speaking = false;
            }
        }
    }
}

And here is the code that consumed that class:

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.Touch;
using Microsoft.SPOT.Hardware;
 
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
 
namespace FEZ_Speak
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            SP03 speechUnit = new SP03();
 
            speechUnit.Say("Hello Tiny C L R.");
        }
    }
}

After running this a growly computer voice spoke the words. In case anyone doesn’t believe me, here is the evidence 😉

Jas

2012/02/10

Added a generator tool (Windows) in VB.net for TyranntMicro

Filed under: .NET, Fez Spider, Gadgeteer, Learning, VB.NET, Windows Forms — Tags: , , , — vbmagic @ 7:56 pm

Hi,

Added a new generator tool. So far it can just generate items:

This tool will store the items in “|” delimited text files which can easily be turned into objects using the split(“|”c) or split(‘|’) string function.

An example of the above “Arrows” item is:

1.0|Arrows||A Quiver of arrows. Holds a maximum of 10 arrows|arrowico.gif|arrow.gif|ammo|10|0|False|False|False

I was planning to do this on the Spider but it just makes more sense to do this on a desktop machine.

So Character Generator is almost finished. (Starting items are all that is required)
Item generator done
Next when I get spare time I’ll start working on the Maze Generator in the generator tool and a “Play Game” screen system on the Spider.

2012/02/09

Portable Spider Power

Filed under: Fez Spider, Gadgeteer — Tags: , , , — vbmagic @ 2:21 pm

Hi,

I’ve tried my New Trent iTurbo IMP660 6600mAh External Battery pack on the FEZ Spider and it seems to power it with no problems. I’ve not tested it to see how long it will last but it will re-charge my phone around 4-5 times. If anyone was looking for a way of powering the spider from a portable battery, this seems to work for me.

Battery Powered FEZ Spider

Jas

2012/02/08

Have the starts of a game running on the FEZ Spider

Just a quick post to show what I’ve been doing with the new toy 😉

Of course I started to write the same game as I have going on the Windows Phone and Azure.

The below picture shows the components used in the project:

Board Layout

The source code is available open source from Tyranntmicro on Code Plex

Also a small video of it running is here:

Jas

2012/01/25

Gadgeteer

Filed under: .Net Micro Framework, Gadgeteer — vbmagic @ 1:36 pm

Hi,

It’s been a while since I’ve posted anything. Basically I’ve been busy with other things recently but I intend to get back into more coding with Azure and Windows Phone etc. soon.

On another note I’ve just purchased one of the .Net Gadgeteer FEZ Spider kits.

FEZ Spider Kit

Unfortunately, the current SDK (4.1) does not support VB coding, but I hear that when 4.2 is released it will.

If you are wondering what .Net Gadgeteer is click the link.

It uses the .Net Micro Framework and is extremely easy to code for in Visual Studio. (You can use C# Express too)

I’ll be posting more once the kit has arrived and I have had chance to play with it. I was lucky to get on as it’s sold out due to popular demand in a lot of places.

Jas

Blog at WordPress.com.