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();
    }
    // Callback function for touch gesture callback
    static void TouchGestureCB(BrickletLCD128x64 sender, byte gesture, long duration,
                               int pressureMax, int xStart, int xEnd, int yStart,
                               int yEnd, long age)
    {
        if (gesture == BrickletLCD128x64.GESTURE_LEFT_TO_RIGHT)
        {
            Console.WriteLine("Gesture: Left To Right");
        }
        else if (gesture == BrickletLCD128x64.GESTURE_RIGHT_TO_LEFT)
        {
            Console.WriteLine("Gesture: Right To Left");
        }
        else if (gesture == BrickletLCD128x64.GESTURE_TOP_TO_BOTTOM)
        {
            Console.WriteLine("Gesture: Top To Bottom");
        }
        else if (gesture == BrickletLCD128x64.GESTURE_BOTTOM_TO_TOP)
        {
            Console.WriteLine("Gesture: Bottom To Top");
        }

        Console.WriteLine("Duration: " + duration);
        Console.WriteLine("Pressure Max: " + pressureMax);
        Console.WriteLine("X Start: " + xStart);
        Console.WriteLine("X End: " + xEnd);
        Console.WriteLine("Y Start: " + yStart);
        Console.WriteLine("Y End: " + yEnd);
        Console.WriteLine("Age: " + age);
        Console.WriteLine("");
    }
    private static string UID  = "XYZ";    // Change XYZ to the UID of your LCD 128x64 Bricklet

    // Callback function for touch position callback
    static void TouchPositionCB(BrickletLCD128x64 sender, int pressure, int x, int y,
                                long age)
    {
        Console.WriteLine("Pressure: " + pressure);
        Console.WriteLine("X: " + x);
        Console.WriteLine("Y: " + y);
        Console.WriteLine("Age: " + age);
        Console.WriteLine("");
    }
Ejemplo n.º 4
0
    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();
    }
    private static void DrawBitmap(BrickletLCD128x64 lcd, Bitmap bitmap)
    {
        bool[] pixels = new bool[HEIGHT * WIDTH];

        for (int row = 0; row < HEIGHT; row++)
        {
            for (int column = 0; column < WIDTH; column++)
            {
                pixels[row * WIDTH + column] = bitmap.GetPixel(column, row).GetBrightness() > 0;
            }
        }

        lcd.WritePixels(0, 0, (byte)(WIDTH - 1), (byte)(HEIGHT - 1), pixels);
    }
Ejemplo n.º 6
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();
    }
Ejemplo n.º 7
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();
    }
Ejemplo n.º 8
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();
    }
Ejemplo n.º 10
0
    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 touch position callback to function TouchPositionCB
        lcd.TouchPositionCallback += TouchPositionCB;

        // Register touch gesture callback to function TouchGestureCB
        lcd.TouchGestureCallback += TouchGestureCB;

        // Set period for touch position callback to 0.1s (100ms)
        lcd.SetTouchPositionCallbackConfiguration(100, true);

        // Set period for touch gesture callback to 0.1s (100ms)
        lcd.SetTouchGestureCallbackConfiguration(100, true);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Ejemplo n.º 11
0
 // Callback function for GUI tab selected callback
 static void GUITabSelectedCB(BrickletLCD128x64 sender, short index)
 {
     Console.WriteLine("Index: " + index);
 }
Ejemplo n.º 12
0
 // Callback function for GUI slider value callback
 static void GUISliderValueCB(BrickletLCD128x64 sender, byte index, byte value)
 {
     Console.WriteLine("Index: " + index);
     Console.WriteLine("Value: " + value);
     Console.WriteLine("");
 }
Ejemplo n.º 13
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your LCD 128x64 Bricklet

    // Callback function for GUI button pressed callback
    static void GUIButtonPressedCB(BrickletLCD128x64 sender, byte index, bool pressed)
    {
        Console.WriteLine("Index: " + index);
        Console.WriteLine("Pressed: " + pressed);
        Console.WriteLine("");
    }