Hi, I’m going to buy Cobra II mainboard with 16x2 display and 3x4 keyboarb using extender module.
Now I’m writing some code for testing purpose without testing over Cobra II
I try use MS Simulator, but doesn’t work with display code. I suppose because the hardware is not properly simulated.
Is there a simutaor for test my cose without connect USB mainboard ?
Now I’ve startered a Gadgeteer project adding Cobra II connected to display and extender module.
I’ve some code to try but i’ve some trouble…
Thank you in advance.
Mycode likes this:
using System;
using System.IO;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Messaging;
using Microsoft.SPOT.Net;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using GHIElectronics.Gadgeteer;
using GHIElectronics;
using GHI.Premium.IO;
using GHI.Premium.Native;
using GHI.Premium.System;
using GHI.Premium.USBClient;
using GHI.Premium.USBHost;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using System.Threading;
using Microsoft.SPOT.Hardware;
namespace GadgeteerDisplay
{
public partial class Program
{
byte[] ba = new byte[1024];
DateTime start_time;
TimeSpan ts;
Keypad3x4 MyKeypad;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
/*******************************************************************************************
Modules added in the Program.gadgeteer designer view are used by typing
their name followed by a period, e.g. button. or camera.
Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
button.ButtonPressed +=<tab><tab>
If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
timer.Tick +=<tab><tab>
timer.Start();
*******************************************************************************************/
Debug.Print("Program Started");
// DISPLAY
this.display_HD44780.Clear();
this.display_HD44780.PrintString("Hello World");
display_HD44780.SetBacklight(true);
// http://www.tinyclr.com/codeshare/entry/482
// KEYPAD
// Use the keypad on socket 4 of the current mainboard
MyKeypad = new Keypad3x4(Mainboard, 4);
// Enables keys scan
MyKeypad.Enable();
// Deals with key pressed/released
MyKeypad.KeyPressed += MyKeypad_KeyPressed;
MyKeypad.KeyReleased += MyKeypad_KeyReleased;
// LED AND PORTS
// http://msdn.microsoft.com/en-us/library/hh421133.aspx
OutputPort LED;
LED = new OutputPort(Cpu.Pin.GPIO_Pin0, false);
LED.Write(true);
InputPort IP = new InputPort(Cpu.Pin.GPIO_Pin2, true, Port.ResistorMode.Disabled);
bool readed = IP.Read();
}
void MyKeypad_KeyPressed(object sender, Keypad3x4.KeyPressedEventArgs e)
{
Mainboard.SetDebugLED(true);
Debug.Print("Key " + e.KeyValue + "('" + e.KeyChar + "') pressed");
}
void MyKeypad_KeyReleased(object sender, Keypad3x4.KeyReleasedEventArgs e)
{
Mainboard.SetDebugLED(false);
Debug.Print("Key " + e.KeyValue + "('" + e.KeyChar + "') released");
}
public void writeSD()
{
// ...
// SD Card is inserted
// Create a new storage device
PersistentStorage sdPS = new PersistentStorage("SD");
// Mount the file system
sdPS.MountFileSystem();
int i;
for (i = 0; i < 1024; i++)
{
ba[i] = (byte)(i % 255);
}
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
FileStream FileHandle = new FileStream(rootDirectory + @ "\hello.txt", FileMode.Create);
for (i = 0; i < 1024; i++)
{
FileHandle.Write(ba, 0, 1024);
}
FileHandle.Close();
sdPS.UnmountFileSystem();
}
my problem is initializing
this.display_HD44780
// Initialize GTM.Modules and event handlers here.
display_HD44780 = new GTM.GHIElectronics.Display_HD44780(1);