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();
        }
    }
}
Merth says: "Dammit tanner, your C# code sucks".
lol, I can believe that Razz
Awesome!!!
_player1537 wrote:
0x5, I can believe that Razz
More specifically, to be constructive, it would be far far better if your struct was inside your namespace.
^++ (2 posts above Razz)
Can you run code on the watch with this?
I'm pretty sure you can, you just need the right routines in your custom code. Also, for tomorrow, I have to see about either getting a cool graph like the control center, and sending data to Kerm's calc so that I can screw up Merth and Kerm's game of Obliterate (I wanna control the wind!). But I do want to do something with gCn and this Razz
_player1537 wrote:
I'm pretty sure you can, you just need the right routines in your custom code. Also, for tomorrow, I have to see about either getting a cool graph like the control center, and sending data to Kerm's calc so that I can screw up Merth and Kerm's game of Obliterate (I wanna control the wind!). But I do want to do something with gCn and this Razz
What about playing Obliterate on your watch? That would be amazing.
Let's see, I get tilt sensors and 3 buttons, very, very feasible Very Happy
_player1537 wrote:
Let's see, I get tilt sensors and 3 buttons, very, very feasible Very Happy
That's excellent! You can use 4-way tilting to set power and angle, and the buttons for fire, exit, etc.
What kind of CPU does the watch have?
hmm, as I am still just learning C#, the only namespaces I use are the System and System.Windows.Forms so I cannot be of much help... other than that, this code looked pretty good. Hopefully I can be more of a help when I start to learn more...
souvik1997 wrote:
What kind of CPU does the watch have?

It's a TI CC430, which is a MSP430 core with on-package RF transceiver. Specific chip is the CC430F6137, which has 32 kB of Flash and 4 kB of RAM.
Ironically, that's similar specs to an Atmega328p, but with double the RAM.
_player, is there a document of some sort that tells you how to use the library? I cannot seem to find one.... Neutral
I really wish there was :/ I linked to a website where I found the VB code that I copied. Other than that, not sure what else there is. You could use Visual Studio to see what is in the APStatus enum. I'll look at some of it again and see if I can't guess and check what one can do with it.
darn, I have troubles figuring stuff for myself Sad I shall keep on trying too.
TI incompletely documents their products for developers?! SHOCKER!
Kerm, this is a third party library D: (or I think it is)
Not TI Smile I believe it is another person's library.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement