Пример #1
0
    public Pong(IPConnection ipcon)
    {
        for (int row = 0; row < Config.LED_ROWS; ++row)
        {
            playfield[row] = new byte[Config.LED_COLS];
        }

        // Call a getter to check that the Bricklet is avialable
        ledStrip = new BrickletLEDStrip(Config.UID_LED_STRIP_BRICKLET, ipcon);

        try
        {
            ledStrip.GetFrameDuration();
            System.Console.WriteLine("Found: LED Strip ({0})", Config.UID_LED_STRIP_BRICKLET);
        }
        catch (TinkerforgeException)
        {
            System.Console.WriteLine("Not Found: LED Strip ({0})", Config.UID_LED_STRIP_BRICKLET);
            return;
        }

        keyPress = new KeyPress(ipcon);
        speaker  = new PongSpeaker(ipcon);
        okay     = true;

        ledStrip.SetFrameDuration(40);
        ledStrip.FrameRendered += FrameRenderedCB;

        InitGame();
    }
Пример #2
0
    static void Main()
    {
        IPConnection     ipcon = new IPConnection();               // Create IP connection
        BrickletLEDStrip ls    = new BrickletLEDStrip(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT);                                 // Connect to brickd
        // Don't use device before ipcon is connected

        // Set frame duration to 50ms (20 frames per second)
        ls.SetFrameDuration(50);

        // Register frame rendered callback to function FrameRenderedCB
        ls.FrameRenderedCallback += FrameRenderedCB;

        // Set initial rgb values to get started
        ls.SetRGBValues(0, NUM_LEDS, r, g, b);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
    static void Main()
    {
        IPConnection ipcon = new IPConnection(); // Create IP connection
        BrickletLEDStrip ls = new BrickletLEDStrip(UID, ipcon); // Create device object

        ipcon.Connect(HOST, PORT); // Connect to brickd
        // Don't use device before ipcon is connected

        // Set frame duration to 50ms (20 frames per second)
        ls.SetFrameDuration(50);

        // Register frame rendered callback to function FrameRenderedCB
        ls.FrameRendered += FrameRenderedCB;

        // Set initial rgb values to get started
        ls.SetRGBValues(0, NUM_LEDS, r, g, b);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }