Lejos EV3原生图书馆bluecove_arm不可用WR

时间:2016-11-01 03:03:48

标签: java lejos-nxj

我正在考虑使用Lejos 0.9.1-beta在Ev3上使用Wii遥控器的简单示例。我正在使用WiiRemoteJ和Bluecove 2.1.1-SNAPSHOT,该示例适用于我的Mac,但我的EV3上有下一个错误:

  

Native Library bluecove_arm不可用WR

我在下一个link找到了解决方案,但我不知道如何在EV3中编译和创建一个新的jar。

你能帮我吗?

这是我的代码

package test;

import wiiremotej.*;
import wiiremotej.event.*;

import com.intel.bluetooth.BlueCoveConfigProperties;

import lejos.hardware.lcd.LCD;


public class Wii extends WiiRemoteAdapter {

    private WiiRemote remote;

    private static boolean accelerometerSource = true; 

    private static int y = 0;
    private static int lastY = 0;


    public static void main(String args[]) {
        System.setProperty(BlueCoveConfigProperties.PROPERTY_JSR_82_PSM_MINIMUM_OFF, "true");
        WiiRemoteJ.setConsoleLoggingOff();

        try {
            LCD.drawString("Buscando WR", 0, 2);
            WiiRemote remote = null;

            while (remote == null) {
                try {
                    remote = WiiRemoteJ.findRemote();
                    LCD.drawString("WR encontrado", 0, 2);
                } 
                catch (Exception e) {
                    remote = null;
                    LCD.drawString("ERROR", 0, 2);
                }
            }

            remote.addWiiRemoteListener(new Wii(remote));
            remote.setAccelerometerEnabled(true);
            remote.setSpeakerEnabled(false);
            remote.setIRSensorEnabled(false, WRIREvent.BASIC);
            remote.setLEDIlluminated(0, false);

            remote.getButtonMaps().add(new ButtonMap(WRButtonEvent.HOME, ButtonMap.NUNCHUK, WRNunchukExtensionEvent.C,
                    new int[] { java.awt.event.KeyEvent.VK_CONTROL }, java.awt.event.InputEvent.BUTTON1_MASK, 0, -1));

            final WiiRemote remoteF = remote;
            Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                public void run() {
                    remoteF.disconnect();
                }
            }));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Wii(WiiRemote remote) {
        this.remote = remote;
    }

    public void accelerationInputReceived(WRAccelerationEvent evt) {
        //Doblar derecha y izquierda
        if(accelerometerSource){
            lastY = y;
            //300 es el centro
            y = (int)(evt.getYAcceleration()/5*300)+300;
            if( y < lastY - 2){
                LCD.drawString("Izquierda", 3, 2);
            }
            else if( y > lastY + 2){
                LCD.drawString("Derecha", 3, 2);
            }
        }
    }

    public void buttonInputReceived(WRButtonEvent evt) {
        if (evt.isPressed(WRButtonEvent.ONE)){
            LCD.drawString("Avanzar", 5, 2);
        }
        if (evt.isPressed(WRButtonEvent.TWO)){
            LCD.drawString("Retroceder", 5, 2);
        }           
    }

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

    public void statusReported(WRStatusEvent evt) {
    }

    public void IRInputReceived(WRIREvent evt) {
    }

    public void extensionConnected(WiiRemoteExtension extension) {
        System.out.println("Extension connected!");
        try {
            remote.setExtensionEnabled(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void extensionPartiallyInserted() {
        System.out.println("Extension partially inserted. Push it in more next time!");
    }

    public void extensionUnknown() {
        System.out.println("Extension unknown. Did you try to plug in a toaster or something?");
    }

    public void extensionDisconnected(WiiRemoteExtension extension) {
        System.out.println("Extension disconnected. Why'd you unplug it, eh?");
    }   

}

0 个答案:

没有答案