As many of you know, I got the eZ430 Chronos watch by TI for my birthday. After some preliminary help from ParkerR, I was able to get my watch connected to the computer and some software installed. Then I tried out the CCS (the "better" IDE for programming the watch itself) and found that I couldn't send any programs with that, or the other one based on Eclispse. So then I decided to try and interface it with C# (Why not? There were quite a few applications on the wiki written in some .NET variant). The first (and presumably, the best) result I found was something called ez430chronosnet. I loaded it up in VS C# and found some Visual Basic code that connects to the watch and reads all the data. I was able to get that converted to C# and got it working about 30 minutes ago. I tried to get it to be somewhat easy to interface and write your own code with. I got a struct made that holds the RawX, RawY, RawZ, and RawButton values that are received from the GetData() routine. Here is my current code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using eZ430ChronosNet;
public struct RawData
{
public byte RawX, RawY, RawZ, RawButton;
public RawData(uint data)
{
RawX = (byte)(data >> 8);
RawY = (byte)(data >> 16);
RawZ = (byte)(data >> 24);
RawButton = (byte)(data);
}
}
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Chronos ez = new Chronos();
APStatus status;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ConnectButton_Click(object sender, EventArgs e)
{
string p = ez.GetComPortName();
if (ConnectButton.Text == "Disconnect")
{
myTimer.Enabled = false;
ez.CloseComPort();
ConnectButton.Text = "Connect";
}
else if (ez.OpenComPort(p))
{
ez.StartSimpliciTI();
myTimer.Enabled = true;
ConnectButton.Text = "Disconnect";
}
else
{
MessageBox.Show("Something screwed up... Guess whose fault THAT is.");
}
}
private void myTimer_Tick(object sender, EventArgs e)
{
uint data;
ez.GetAPStatus(out status);
ez.GetData(out data);
RawData RawData = new RawData(data);
// Your stuff would go here, interfacing the RawX/Y/Z values.
LabX.Text = "Raw X Value: " + RawData.RawX.ToString();
LabY.Text = "Raw Y Value: " + RawData.RawY.ToString();
LabZ.Text = "Raw Z Value: " + RawData.RawZ.ToString();
LabButton.Text = "Raw Button Value: " + RawData.RawButton.ToString();
LabStatus.Text = status.ToString();
}
}
}