Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Henry

Pages: 1
1
Other Projects / Wii Balance Board Data
« on: July 15, 2011, 03:35:58 AM »
Hi all,
I just bought a brand new Wii Balance Board and want to use it to interface with my PC(xp widcomm).The thing is I can make the connection, but I failed to obtain data from the board. I can only receive 0 from the board! Can someone tell me the reason?

Thanks very very very much!!

2
General Discussion / Wii Balance Board Data
« on: July 15, 2011, 03:33:51 AM »
Hi all,
I just bought a brand new Wii Balance Board and want to use it to interface with my PC(xp widcomm).The thing is I can make the connection, but I failed to obtain data from the board. I can only receive 0 from the board! Can someone tell me the reason?

Thanks very very very much!!

3
General Discussion / interface with the wii balance board
« on: July 01, 2011, 03:30:18 AM »
... , I want to use the WiiRemoteJ library to interface with my  ...
...  board. but after i wrote my java code, it did  ...
... ? ( my OS is windows7 32)



package summer.wiiboard;

/**
 *
 * @author Mat
 */

 ...
... .awt.*;
import javax.swing.*;
import wiiremotej.*;
import wiiremotej.event.*;
 ...
...  java.io.*;
public class BBImpl extends BalanceBoardAdapter
{
 private BalanceBoard  ...
...  console logging options...
 //WiiRemoteJ.setConsoleLoggingAll();
 / ...
... /WiiRemoteJ.setConsoleLoggingOff();
  ...
... .setTitle("Center of gravity graph: Balance Board");
 graphFrame.setSize( ...
... );
 //Find and connect to a Balance Board
BalanceBoard board =  ...
... .");

 while (board == null) {
 try {
  ...
...  to connect.");
board = WiiRemoteJ.findBalanceBoard();

  ...
... (Exception e) {
board = null;
 e. ...
...  System.out.println("Failed to connect board. Trying again.");
 }
  ...
...  }


 System.out.println("Wii Balance Board is connected.");

  ...
...  board.addBalanceBoardListener(new BBImpl( ...
... ));
board.setLEDIlluminated(true);

  ...
...  BalanceBoard boardF = board;
  ...
...  Thread(new Runnable(){public void run(){boardF.disconnect();}}));
 }
  ...
... ();}
 }

 public BBImpl(BalanceBoard board)
 {
 this.board =  ...
... ()
 {
 System.out.println("Board disconnected... Please Wii again.");
  ...
... .out.println("Disconnecting! Please Wii again.");
 System.exit(0);
  ...

4
Wiiboard Projects / using of the WiiRemoteJ library for wii board
« on: June 28, 2011, 06:03:11 AM »
Hi, I want to use the WiiRemoteJ library to interface with my balance board. but after i wrote my java code, it did not seem to work, i get no response. below is my code, can you give me some advice? ( my OS is windows7)



package summer.wiiboard;

/**
 *
 * @author Mat
 */

import java.awt.*;
import javax.swing.*;
import wiiremotej.*;
import wiiremotej.event.*;
import java.io.*;
public class BBImpl extends BalanceBoardAdapter
{
    private BalanceBoard board;
    private static JFrame graphFrame;
    private static JPanel graph;
    private static double massX;
    private static double massY;



    public static void main(String args[])
    {
        java.lang.System.setProperty("bluecove.jsr82.psm_minimum_off", "true");
        java.lang.System.setProperty("bluecove.stack.first", "widcomm");
        //basic console logging options...
        //WiiRemoteJ.setConsoleLoggingAll();
        //WiiRemoteJ.setConsoleLoggingOff();
        try
        {
            graphFrame = new JFrame();
    //        graphFrame.setTitle("Mass Graph");
            graphFrame.setTitle("Center of gravity graph: Balance Board");
            graphFrame.setSize(800, 600);
            graphFrame.setResizable(false);

            graph = new JPanel()
            {
                public void paintComponent(Graphics graphics)
                {
                    graphics.clearRect(0, 0, 800, 600);
                    graphics.fillRect(0, 0, 800, 600);
                    graphics.setColor(Color.WHITE);
                    graphics.drawLine(0, 300, 800, 300);
                    graphics.drawLine(400, 0, 400, 600);

                    graphics.setColor(Color.RED);
                    graphics.fillOval((int)(massX * 800+400-15), (int)(massY * 600+300-15), 30, 30);
                }
            };

            graph.setDoubleBuffered(true);
            graphFrame.add(graph);
            graphFrame.setVisible(false);
            //Find and connect to a Balance Board
            BalanceBoard board = null;
            System.out.println("Please press the red syn button.");
           
            while (board == null) {
               try {
                    System.out.println("Trying to connect.");
                    board = WiiRemoteJ.findBalanceBoard();

               }
                    catch(Exception e) {
                    board = null;
                    e.printStackTrace();
                    System.out.println("Failed to connect board. Trying again.");
                }
               
           }


            System.out.println("Wii Balance Board is connected.");

            board.addBalanceBoardListener(new BBImpl(board));
            board.setLEDIlluminated(true);

            final BalanceBoard boardF = board;
            Runtime.getRuntime().addShutdownHook(new Thread(new Runnable(){public void run(){boardF.disconnect();}}));
        }
        catch(Exception e){e.printStackTrace();}
    }

    public BBImpl(BalanceBoard board)
    {
        this.board = board;
    }

    public void disconnected()
    {
        System.out.println("Board disconnected... Please Wii again.");
        System.exit(0);
    }


    public void massInputReceived(BBMassEvent evt)
    {
       double massTL = evt.getMass(MassConstants.TOP, MassConstants.LEFT);
       double massTR = evt.getMass(MassConstants.TOP, MassConstants.RIGHT);
       double massBL = evt.getMass(MassConstants.BOTTOM, MassConstants.LEFT);
       double massBR = evt.getMass(MassConstants.BOTTOM, MassConstants.RIGHT);

       if (evt.getTotalMass() > 3) { // if mass is too small, don't bother
          double topMass = massTL + massTR;
          double bottomMass = massBL + massBR;
          double leftMass = massTL + massBL;
          double rightMass = massTR + massBR;

          double vertRange = topMass + bottomMass;
          double horizRange = rightMass + leftMass;

          massX = (rightMass-leftMass)/horizRange;
          massY = -(topMass-bottomMass)/vertRange;
       }
       else {
          massX = 0;
          massY = 0;
       }

       graph.repaint();
    }

    public void buttonInputReceived(BBButtonEvent evt) {
       if (evt.wasPressed()) {
          System.out.println("Disconnecting! Please Wii again.");
          System.exit(0);
       }
    }


}

5
Wiiboard Projects / introduce
« on: June 28, 2011, 05:44:13 AM »
Hi,everyone, i'm a student and happy to join this forum.

Pages: 1