import lejos.nxt.*;
import lejos.nxt.addon.*;
import javax.microedition.lcdui.*;

/**
    make the NXT brick a compass?!

    @author Bagnall, course text, p. 325
    @author adapted by Sharon Tuttle
    @version 2015-04-03
*/

public class HandHeldCompass
{
    /**
        make the NXT brick a compass?!

        @param args not used
    */

    public static void main(String[] args) throws Exception
    {
        CompassHTSensor compassSens = 
            new CompassHTSensor(SensorPort.S1);
        Graphics g = new Graphics();

        // continue playing compass until ENTER is pressed

        while (!Button.ENTER.isPressed())
	{
            g.clear();
            int angle = (int) compassSens.getDegrees();
            LCD.drawInt(angle, 0, 0);
            g.fillArc(10, 0, 62, 62, (angle-4), 8);
            LCD.refresh();
            Thread.sleep(200);
        }
    }
}