static void Main()
    {
        IPConnection      ipcon = new IPConnection();                // Create IP connection
        BrickletLCD128x64 lcd   = new BrickletLCD128x64(UID, ipcon); // Create device object

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

        // Clear display
        lcd.ClearDisplay();

        // Draw checkerboard pattern
        bool[] pixels = new bool[HEIGHT * WIDTH];

        for (int row = 0; row < HEIGHT; row++)
        {
            for (int column = 0; column < WIDTH; column++)
            {
                pixels[row * WIDTH + column] = (row / 8) % 2 == (column / 8) % 2;
            }
        }
        lcd.WritePixels(0, 0, (byte)(WIDTH - 1), (byte)(HEIGHT - 1), pixels);

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

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

        // Register GUI button pressed callback to function GUIButtonPressedCB
        lcd.GUIButtonPressedCallback += GUIButtonPressedCB;

        // Register GUI slider value callback to function GUISliderValueCB
        lcd.GUISliderValueCallback += GUISliderValueCB;

        // Register GUI tab selected callback to function GUITabSelectedCB
        lcd.GUITabSelectedCallback += GUITabSelectedCB;

        // Clear display
        lcd.ClearDisplay();
        lcd.RemoveAllGUI();

        // Add GUI elements: Button, Slider and Graph with 60 data points
        lcd.SetGUIButton(0, 0, 0, 60, 20, "button");
        lcd.SetGUISlider(0, 0, 30, 60, BrickletLCD128x64.DIRECTION_HORIZONTAL, 50);
        lcd.SetGUIGraphConfiguration(0, BrickletLCD128x64.GRAPH_TYPE_LINE, 62, 0, 60, 52,
                                     "X", "Y");

        // Add a few data points (the remaining points will be 0)
        lcd.SetGUIGraphData(0,
                            new byte[] { 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240 });

        // Add 5 text tabs without and configure it for click and swipe without auto-redraw
        lcd.SetGUITabConfiguration(BrickletLCD128x64.CHANGE_TAB_ON_CLICK_AND_SWIPE,
                                   false);
        lcd.SetGUITabText(0, "Tab A");
        lcd.SetGUITabText(1, "Tab B");
        lcd.SetGUITabText(2, "Tab C");
        lcd.SetGUITabText(3, "Tab D");
        lcd.SetGUITabText(4, "Tab E");

        // Set period for GUI button pressed callback to 0.1s (100ms)
        lcd.SetGUIButtonPressedCallbackConfiguration(100, true);

        // Set period for GUI slider value callback to 0.1s (100ms)
        lcd.SetGUISliderValueCallbackConfiguration(100, true);

        // Set period for GUI tab selected callback to 0.1s (100ms)
        lcd.SetGUITabSelectedCallbackConfiguration(100, true);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
示例#3
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your LCD 128x64 Bricklet

    static void Main()
    {
        IPConnection      ipcon = new IPConnection();                // Create IP connection
        BrickletLCD128x64 lcd   = new BrickletLCD128x64(UID, ipcon); // Create device object

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

        // Clear display
        lcd.ClearDisplay();

        // Write "Hello World" starting from upper left corner of the screen
        lcd.WriteLine(0, 0, "Hello World");

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
示例#4
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your LCD 128x64 Bricklet

    static void Main()
    {
        IPConnection      ipcon = new IPConnection();                // Create IP connection
        BrickletLCD128x64 lcd   = new BrickletLCD128x64(UID, ipcon); // Create device object

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

        // Clear display
        lcd.ClearDisplay();

        // Write "Hello World" with big 24x32 font
        lcd.DrawText(0, 0, BrickletLCD128x64.FONT_24X32, BrickletLCD128x64.COLOR_BLACK,
                     "24x32");

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
示例#5
0
 static void EnumerateCB(IPConnection sender, string UID, string connectedUID, char position,
                         short[] hardwareVersion, short[] firmwareVersion,
                         int deviceIdentifier, short enumerationType)
 {
     if (enumerationType == IPConnection.ENUMERATION_TYPE_CONNECTED ||
         enumerationType == IPConnection.ENUMERATION_TYPE_AVAILABLE)
     {
         if (deviceIdentifier == BrickletLCD128x64.DEVICE_IDENTIFIER)
         {
             try
             {
                 // Initialize newly enumerated LCD128x64 Bricklet
                 brickletLCD = new BrickletLCD128x64(UID, ipcon);
                 brickletLCD.ClearDisplay();
                 brickletLCD.WriteLine(0, 0, "   Weather Station");
                 System.Console.WriteLine("LCD 128x64 initialized");
             }
             catch (TinkerforgeException e)
             {
                 System.Console.WriteLine("LCD 128x64 init failed: " + e.Message);
                 brickletLCD = null;
             }
         }
         else if (deviceIdentifier == BrickletAirQuality.DEVICE_IDENTIFIER)
         {
             try
             {
                 // Initialize newly enumaratedy Air Quality Bricklet and configure callbacks
                 brickletAirQuality = new BrickletAirQuality(UID, ipcon);
                 brickletAirQuality.SetAllValuesCallbackConfiguration(1000, false);
                 brickletAirQuality.AllValuesCallback += AllValuesCB;
                 System.Console.WriteLine("Air Quality initialized");
             }
             catch (TinkerforgeException e)
             {
                 System.Console.WriteLine("Air Quality init failed: " + e.Message);
                 brickletAirQuality = null;
             }
         }
     }
 }
    static void Main()
    {
        IPConnection      ipcon = new IPConnection();                // Create IP connection
        BrickletLCD128x64 lcd   = new BrickletLCD128x64(UID, ipcon); // Create device object

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

        // Clear display
        lcd.ClearDisplay();

        // Draw rotating line
        Bitmap bitmap  = new Bitmap(WIDTH, HEIGHT);
        int    originX = WIDTH / 2;
        int    originY = HEIGHT / 2;
        int    length  = HEIGHT / 2 - 2;
        int    angle   = 0;

        Console.WriteLine("Press enter to exit");

        while (!Console.KeyAvailable)
        {
            double radians = Math.PI * angle / 180.0;
            int    x       = (int)(originX + length * Math.Cos(radians));
            int    y       = (int)(originY + length * Math.Sin(radians));

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.FillRectangle(Brushes.Black, 0, 0, WIDTH, HEIGHT);
                g.DrawLine(Pens.White, originX, originY, x, y);
            }

            DrawBitmap(lcd, bitmap);
            Thread.Sleep(25);

            angle++;
        }

        Console.ReadLine();
        ipcon.Disconnect();
    }