Esempio n. 1
0
        public static void Main()
        {
            var oled    = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64);
            var display = new GraphicsLibrary(oled);

            display.Clear(true);
            display.DrawLine(0, 30, 80, 60, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawCircle(63, 31, 20, true, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawRectangle(20, 20, 60, 40);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawRectangle(30, 10, 50, 40, true, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.CurrentFont = new Font8x8();
            display.DrawText(4, 10, "NETDUINO 3 WiFi");
            display.Show();
            Thread.Sleep(Timeout.Infinite);
        }
Esempio n. 2
0
        public DisplayController()
        {
            var display = new SSD1306(0x3C, 400, SSD1306.DisplayType.OLED128x32);

            graphicsLibrary = new GraphicsLibrary(display);
            graphicsLibrary.Clear(true);
        }
Esempio n. 3
0
 private static void DisplayLinesOnDisplay(SSD1306 device)
 {
     for (int y = 0; y < 64; y++)
     {
         for (int x = 0; x < 128; x++)
         {
             var shouldDisplay = x % 2 == 0 ? true : false;
             device.DrawPixel(x, y, shouldDisplay);
         }
     }
 }
Esempio n. 4
0
        void CreateI2CDisplay()
        {
            Console.WriteLine("Create Display with I2C...");

            display = new SSD1306
                      (
                i2cBus: Device.CreateI2cBus(),
                address: 60,
                displayType: SSD1306.DisplayType.OLED128x32
                      );
        }
        void CreateI2CDisplay()
        {
            Console.WriteLine("Create SpiBus");
            var spiBus = Device.CreateSpiBus();

            Console.WriteLine("Create Display");

            var i2CBus = Device.CreateI2cBus();

            display = new SSD1306(i2CBus, Device.Pins.D08, Device.Pins.D07, 60, 400, SSD1306.DisplayType.OLED128x32);
        }
Esempio n. 6
0
        public static void Main()
        {
            var device = new SSD1306();

            DisplayLinesOnDisplay(device);

            DrawText(device, 0, 0, 2, "HO");
            DrawText(device, 0, 10, 2, "HLO");
            DrawText(device, 0, 20, 2, "HELLO");

            device.Show();
        }
        void CreateSpiDisplay()
        {
            Console.WriteLine("Create SpiBus");
            var spiBus = Device.CreateSpiBus();

            Console.WriteLine("Create Display");

            display = new SSD1306(device: Device, spiBus: spiBus,
                                  chipSelectPin: Device.Pins.D02,
                                  dcPin: Device.Pins.D01,
                                  resetPin: Device.Pins.D00,
                                  SSD1306.DisplayType.OLED128x64);
        }
Esempio n. 8
0
        void CreateSpiDisplay()
        {
            Console.WriteLine("Create Display with SPI...");

            display = new SSD1306
                      (
                device: Device,
                spiBus: Device.CreateSpiBus(),
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                displayType: SSD1306.DisplayType.OLED128x64
                      );
        }
Esempio n. 9
0
        /// <summary>
        /// 保存切片结果
        /// </summary>
        /// <param name="slices">切片结果集</param>
        /// <param name="size">3维图原始大小</param>
        static void SaveSlices(Dictionary <ArrayDefine, List <SlicedPlane> > slices, ModelSize size)
        {
            Console.WriteLine("请选择切片保存模式");
            Console.WriteLine("1.图片\t2.机器语言\t3.图片与机器语言");
            var saveType = Console.ReadLine();
            var prefix   = 0;

            foreach (var key in slices.Keys)
            {
                Console.WriteLine("正在保存第" + (prefix + 1) + "组切片...");
                Console.WriteLine("请输入图片尺寸");
                Console.WriteLine("长:");
                int width = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("宽:");
                int height = Convert.ToInt32(Console.ReadLine());

                var filename = AppDomain.CurrentDomain.BaseDirectory + prefix + "_frame.h";
                System.IO.File.Delete(filename);

                var code       = "";
                var frameTable = new List <string>();

                var images = SliceImage.ToImage(slices[key], size, width, height, 0, 0);
                for (int i = 0; i < images.Count; i++)
                {
                    var bmp = images[i];
                    if (saveType == "1" || saveType == "3")
                    {
                        bmp.Save(AppDomain.CurrentDomain.BaseDirectory + "/" + prefix + "_" + i + ".bmp", ImageFormat.Bmp);
                    }


                    if (saveType == "2" || saveType == "3")
                    {
                        IImageMould im = new SSD1306();
                        code += "static unsigned char _" + prefix + "_frame_" + i + "[] = { " + im.GetMould(bmp) + " }; \n";
                        frameTable.Add("_" + prefix + "_frame_" + i);
                    }
                }
                if (saveType == "2" || saveType == "3")
                {
                    code += "unsigned char* _" + prefix + "_frames_table[] = { " + string.Join(",", frameTable.ToArray()) + " };";
                    System.IO.File.AppendAllText(filename, code);
                }
                Console.WriteLine("第" + (prefix + 1) + "组切片保存完成");
                prefix++;
            }
            Console.WriteLine("所有切片保存完成。");
        }
Esempio n. 10
0
        protected void InitializePeripherals()
        {
            display  = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x32);
            graphics = new GraphicsLibrary(display);

            rowPorts[0] = new InputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullDown);
            rowPorts[1] = new InputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D1, true, Port.ResistorMode.PullDown);
            rowPorts[2] = new InputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D2, true, Port.ResistorMode.PullDown);
            rowPorts[3] = new InputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D3, true, Port.ResistorMode.PullDown);

            columnPorts[0] = new OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D4, false);
            columnPorts[1] = new OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D5, false);
            columnPorts[2] = new OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D6, false);
            columnPorts[3] = new OutputPort(SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_D7, false);

            currentColumn = 0;
        }
Esempio n. 11
0
        private void InitializePeripherals()
        {
            leds[0] = new Led(N.Pins.GPIO_PIN_D4);
            leds[1] = new Led(N.Pins.GPIO_PIN_D5);
            leds[2] = new Led(N.Pins.GPIO_PIN_D6);
            leds[3] = new Led(N.Pins.GPIO_PIN_D7);

            buttons[0] = new PushButton(N.Pins.GPIO_PIN_D10, Netduino.Foundation.CircuitTerminationType.High);
            buttons[1] = new PushButton(N.Pins.GPIO_PIN_D11, Netduino.Foundation.CircuitTerminationType.High);
            buttons[2] = new PushButton(N.Pins.GPIO_PIN_D12, Netduino.Foundation.CircuitTerminationType.High);
            buttons[3] = new PushButton(N.Pins.GPIO_PIN_D13, Netduino.Foundation.CircuitTerminationType.High);

            speaker  = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);
            spdt     = new SpdtSwitch(N.Pins.GPIO_PIN_D2);
            graphics = new GraphicsLibrary(display = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64));
            display.IgnoreOutOfBoundsPixels = true;

            SetAllLEDs(false);
        }
Esempio n. 12
0
        public static void Main()
        {
            // I2C constructor
            // var oled = new SSD1306(Cpu.Pin.GPIO_Pin9, Cpu.Pin.GPIO_Pin10, Cpu.Pin.GPIO_Pin7, SPI.SPI_module.SPI1, 4000, SSD1306.DisplayType.OLED128x32);

            // SPI constructor
            var oled = new SSD1306(chipSelectPin: Pins.GPIO_PIN_D9,
                                   dcPin: Pins.GPIO_PIN_D10,
                                   resetPin: Pins.GPIO_PIN_D7,
                                   spiModule: SPI.SPI_module.SPI1,
                                   speedKHz: 400000,
                                   displayType: SSD1306.DisplayType.OLED128x32);

            oled.IgnoreOutOfBoundsPixels = true;

            var display = new GraphicsLibrary(oled);

            display.Clear(true);
            display.DrawLine(0, 0, 60, 28, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawCircle(63, 31, 20, true, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawRectangle(20, 20, 60, 40);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.DrawRectangle(30, 10, 50, 40, true, true);
            display.Show();
            Thread.Sleep(1000);

            display.Clear(true);
            display.CurrentFont = new Font8x8();
            display.DrawText(4, 10, "NETDUINO 3 WiFi");
            display.Show();
            Thread.Sleep(Timeout.Infinite);
        }
Esempio n. 13
0
        /// <summary>
        ///     Draw a text message on the display using the current font.
        /// </summary>
        /// <param name="x">Abscissa of the location of the text.</param>
        /// <param name="y">Ordinate of the location of the text.</param>
        /// <param name="spacing">Number of pixels between characters.</param>
        /// <param name="text">Text to display.</param>
        /// <param name="wrap">Wrap the text at the end of the display?</param>
        public static void DrawText(SSD1306 device, int x, int y, int spacing, string text, bool wrap = false)
        {
            // var font = new Font8x8();

            var fontHeight = 8;

            byte[] bitMap = new byte[text.Length * fontHeight];

            for (int index = 0; index < text.Length; index++)
            {
                byte[] characterMap = new byte[] { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00 };

                for (int characterSegment = 0; characterSegment < fontHeight; characterSegment++)
                {
                    bitMap[index + (characterSegment * text.Length)] = characterMap[characterSegment];
                }
            }
            device.DrawBitmap(x, y, text.Length, fontHeight, bitMap, Netduino.Foundation.Displays.DisplayBase.BitmapMode.And);
        }
Esempio n. 14
0
        private void InitializePeripherals()
        {
            resetButton          = new PushButton(N.Pins.ONBOARD_BTN, Netduino.Foundation.CircuitTerminationType.Floating);
            resetButton.Clicked += OnResetButton;

            tree = new InputPort(N.Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp);

            speaker  = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3);
            greenLed = new PwmLed(N.PWMChannels.PWM_PIN_D5, 2.0f);
            redLed   = new PwmLed(N.PWMChannels.PWM_PIN_D6, 2.0f);

            var ssd1306 = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64);

            display             = new GraphicsLibrary(ssd1306);
            display.CurrentFont = new Font8x12();

            display.Clear(true);

            PlayBuzzer();
        }
Esempio n. 15
0
        public static void Main()
        {
            Configuration.SetPinFunction(21, DeviceFunction.I2C1_DATA);
            Configuration.SetPinFunction(22, DeviceFunction.I2C1_CLOCK);

            oled = new SSD1306("I2C1", 128, 64, 0x3C);
            oled.Init();

            Console.WriteLine("---------------------");
            Console.WriteLine("Start SSD1306 Display");
            Console.WriteLine("---------------------");
            oled.Display();
            Thread.Sleep(500);

            oled.Clear();
            Thread.Sleep(500);

            while (true)
            {
                SSD1306Demo();
            }
        }
Esempio n. 16
0
        static void InitDisplays()
        {
            tftDisplay = new ILI9163(chipSelectPin: Pins.GPIO_PIN_D4,
                                     dcPin: Pins.GPIO_PIN_D7,
                                     resetPin: Pins.GPIO_PIN_D6,
                                     width: 128,
                                     height: 160,
                                     spiModule: SPI.SPI_module.SPI1,
                                     speedKHz: 25000);

            oledDisplay = new SSD1306(0x3C, 400, SSD1306.DisplayType.OLED128x32);

            font4x8  = new Font4x8();
            font8x12 = new Font8x12();

            tftGraphics = new GraphicsLibrary(tftDisplay)
            {
                CurrentFont = font4x8
            };
            oledGraphics = new GraphicsLibrary(oledDisplay)
            {
                CurrentFont = font8x12
            };
        }