示例#1
0
 static void Main(string[] args)
 {
     TreehopperManager manager = new TreehopperManager();
     Console.Write("Waiting for board to be attached...");
     manager.BoardAdded += manager_BoardAdded;
     Thread.Sleep(-1); // wait forever for board to be attached.
 }
示例#2
0
 static void manager_BoardAdded(TreehopperManager sender, TreehopperUSB board)
 {
     if (PreBoardAdded != null)
     {
         PreBoardAdded(sender, board);
     }
 }
示例#3
0
        // This is called when a board is plugged into the computer.
        static void TreehopperUSB_BoardAdded(TreehopperManager sender, TreehopperUSB board)
        {
            Board = board;
            Console.WriteLine("Board found:");
            Console.WriteLine(board.Description);
            Board.Open();
            Board.Pin8.MakeDigitalOutput();
            Board.Pin8.DigitalValue = false;

            Board.Pin2.Pwm.IsEnabled = true;
            //while(true)
            //{
            //    Board.Pin2.ToggleOutput();
            //    Thread.Sleep(1000);
            //}
            //timer.Start();
            while(true)
            {
                for (int i = 100; i > 0; i--)
                {
                    Board.Pin2.Pwm.DutyCycle = i / 100.0;
                    Thread.Sleep(10);
                }
                for (int i = 0; i < 100; i++)
                {
                    Board.Pin2.Pwm.DutyCycle = i / 100.0;
                    Thread.Sleep(10);
                }
            }
        }
示例#4
0
 // This is called when a board is plugged into the computer.
 static void TreehopperUSB_BoardAdded(TreehopperManager sender, TreehopperUSB board)
 {
     Board = board;
     Console.WriteLine("Board found:");
     Console.WriteLine(board.Description);
     Board.Open();
     timer.Start();
 }
示例#5
0
 private static void InitTreehopperManager()
 {
     if (manager == null)
     {
         manager               = new TreehopperManager();
         manager.BoardAdded   += manager_BoardAdded;
         manager.BoardRemoved += manager_BoardRemoved;
     }
 }
        public FirmwareManagerForm()
        {
            InitializeComponent();
            devNotifier = DeviceNotifier.OpenDeviceNotifier();
            // devNotifier.OnDeviceNotify += devNotifier_OnDeviceNotify;

            TreehopperManager manager = new TreehopperManager();
            manager.BoardAdded += manager_BoardAdded;
            manager.BoardRemoved += manager_BoardRemoved;
        }
示例#7
0
        static void manager_BoardAdded(TreehopperManager sender, TreehopperUSB board)
        {
            Console.WriteLine("Board found.");
            board.Open();

            /// One of the most powerful features of Treehopper's API is that input pins -- analog or digital -- have event-driven
            /// interfaces that allow them to update your application without requiring polling. This particular event only fires
            /// when the 10-bit ADC's value differs from the previous value.
            //board.Pin7.AnalogIn.VoltageChanged += AnalogIn_Changed;

            //board.Pin7.AnalogIn.IsEnabled = true;
            Ltc2305 ltc = new Treehopper.Libraries.Ltc2305(0x8, board.I2C);
            Ltc2305 ltc2 = new Treehopper.Libraries.Ltc2305(0x19, board.I2C);
            while(true)
            {
              //  byte[] retVal = board.I2C.SendReceive(0x80, new byte[] { }, 1);
                //Debug.WriteLine("Device 1, channel 0: " + ltc.Read(Ltc2305Channels.Channel0));
                //Debug.WriteLine("Device 1, channel 1: " + ltc.Read(Ltc2305Channels.Channel1));
                Debug.WriteLine("Device 2, channel 0: " + ltc2.Read(Ltc2305Channels.Channel0));
                Debug.WriteLine("Device 2, channel 1: " + ltc2.Read(Ltc2305Channels.Channel1));
                Thread.Sleep(100);
            }
        }
示例#8
0
 static void TreehopperUSB_BoardRemoved(TreehopperManager sender, TreehopperUSB board)
 {
     Board.Close();
     timer.Stop();
 }
 public MainWindow()
 {
     InitializeComponent();
     TreehopperManager manager = new TreehopperManager();
     manager.BoardAdded += manager_BoardAdded;
 }