Exemple #1
0
    static void Main()
    {
        IPConnection      ipcon = new IPConnection();                // Create IP connection
        BrickletOLED64x48 oled  = new BrickletOLED64x48(UID, ipcon); // Create device object

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

        // Clear display
        oled.ClearDisplay();

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

        for (int row = 0; row < HEIGHT; row++)
        {
            pixels[row] = new bool[WIDTH];

            for (int column = 0; column < WIDTH; column++)
            {
                pixels[row][column] = (row / 8) % 2 == (column / 8) % 2;
            }
        }

        DrawMatrix(oled, pixels);

        Console.WriteLine("Press enter to exit");
        Console.ReadLine();
        ipcon.Disconnect();
    }
Exemple #2
0
    private static string UID  = "XYZ";    // Change XYZ to the UID of your OLED 64x48 Bricklet

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

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

        // Clear display
        oled.ClearDisplay();

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

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

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

        // Clear display
        oled.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(oled, bitmap);
            Thread.Sleep(25);

            angle++;
        }

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