static void InitDisplay()
        {
            // Display Get Ready ////////////////////////////////////
            var spi  = SpiController.FromName(FEZBit.SpiBus.Display);
            var gpio = GpioController.GetDefault();

            st7735 = new ST7735Controller(
                spi.GetDevice(ST7735Controller.GetConnectionSettings
                                  (SpiChipSelectType.Gpio, GpioController.GetDefault().OpenPin(FEZBit.GpioPin.DisplayCs))), //CS pin.
                gpio.OpenPin(FEZBit.GpioPin.DisplayRs),                                                                     //RS pin.
                gpio.OpenPin(FEZBit.GpioPin.DisplayReset)                                                                   //RESET pin.
                );

            var backlight = gpio.OpenPin(FEZBit.GpioPin.Backlight);

            backlight.SetDriveMode(GpioPinDriveMode.Output);
            backlight.Write(GpioPinValue.High);

            st7735.SetDataAccessControl(true, true, false, false); //Rotate the screen.
            st7735.SetDrawWindow(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
            st7735.Enable();
            // Create flush event
            Graphics.OnFlushEvent += Graphics_OnFlushEvent;;

            // Create bitmap buffer
            screen = Graphics.FromImage(new Bitmap(SCREEN_WIDTH, SCREEN_HEIGHT));

            font12 = Resource.GetFont(Resource.FontResources.droid_reg12);
            screen.Clear();
            screen.DrawRectangle(new Pen(new SolidBrush(Color.White)), 10, 10, SCREEN_WIDTH - 20, SCREEN_HEIGHT - 20);
            screen.DrawString("FEZ Bit", font12, new SolidBrush(Color.Red), 55, 30);
            screen.DrawString("SITCore", font12, new SolidBrush(Color.Green), 50, 50);
            screen.DrawString("GHI Electronics", font12, new SolidBrush(Color.Blue), 25, 70);
            screen.Flush();
        }
Beispiel #2
0
        public static void InitializeDisplay()
        {
            var spi  = SpiController.FromName(SC20100.SpiBus.Spi4);
            var gpio = GpioController.GetDefault();

            DisplayController = new ST7735Controller(
                spi.GetDevice(ST7735Controller.GetConnectionSettings(SpiChipSelectType.Gpio, gpio.OpenPin(SC20100.GpioPin.PD10))), // ChipSelect
                gpio.OpenPin(SC20100.GpioPin.PC4),                                                                                 // Pin RS
                gpio.OpenPin(SC20100.GpioPin.PE15)                                                                                 // Pin RESET

                );

            var bl = gpio.OpenPin(SC20100.GpioPin.PA15); // back light

            bl.Write(GpioPinValue.High);
            bl.SetDriveMode(GpioPinDriveMode.Output);

            DisplayController.SetDataAccessControl(true, true, false, false); //Rotate the screen.
            DisplayController.SetDrawWindow(0, 0, Width, Height);
            DisplayController.Enable();


            // Create flush event
            Graphics.OnFlushEvent += Graphics_OnFlushEvent;
        }
Beispiel #3
0
        public static void Main()
        {
            var spi    = SpiController.FromName(G80.SpiBus.Spi2);
            var gpio   = GpioController.GetDefault();
            var st7735 = new ST7735Controller(spi.GetDevice(ST7735Controller.GetConnectionSettings(SpiChipSelectType.Gpio, G80.GpioPin.PD10)), gpio.OpenPin(G80.GpioPin.PE10), gpio.OpenPin(G80.GpioPin.PE12));

            st7735.SetDataAccessControl(true, true, false, false);
            st7735.Enable();

            var disp = DisplayController.FromProvider(st7735);

            disp.SetConfiguration(new SpiDisplayControllerSettings {
                Width = 160, Height = 128
            });

            var bl = gpio.OpenPin(G80.GpioPin.PC7);

            bl.Write(GpioPinValue.High);
            bl.SetDriveMode(GpioPinDriveMode.Output);

            var hdc    = GraphicsManager.RegisterDrawTarget(new DrawTarget(disp));
            var screen = Graphics.FromHdc(hdc);

            var rnd   = new Random();
            var x     = rnd.Next(160);
            var y     = rnd.Next(128);
            var vx    = rnd.Next(20) - 10;
            var vy    = rnd.Next(20) - 10;
            var color = new Pen(Color.Green);
            var teal  = new SolidBrush(Color.Teal);

            // This is a special built-in font for simple SPI displays
            var font = new Font("GHIMono8x5", 8);

            while (true)
            {
                x += vx;
                y += vy;

                if (x >= 160 || x < 0)
                {
                    vx *= -1;
                }
                if (y >= 128 || y < 0)
                {
                    vy *= -1;
                }

                screen.Clear(Color.Black);
                screen.DrawString("Hello World!", font, teal, 40, 10);
                screen.DrawEllipse(color, x, y, 10, 10);
                screen.Flush();
                Thread.Sleep(10);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Constructor of TftDisplayShield
        /// </summary>
        /// <param name="i2CBus">Id of I2C bus</param>
        /// <param name="spiBus">Id of Spi bus</param>
        /// <param name="pinChipSelect">Id of ChipSelect pin (D10)</param>
        /// <param name="pinDataCommand">Id of control pin (D8)</param>
        /// <param name="bgrPanel">if true display is BGR panel, else it is RGB panel</param>
        public TftDisplayShield(string i2CBus, string spiBus, GpioPin pinChipSelect, GpioPin pinDataCommand, bool bgrPanel = false) : base(i2CBus, Address)
        {
            _bgrPanel = bgrPanel;
            PinMode(ResetPin, GpioPinDriveMode.Output);
            PinModeBulk(Button.All, GpioPinDriveMode.InputPullUp);
            SetBackLight(BackLightOff);
            ResetTft();
            var spi = SpiController.FromName(spiBus);
            var spiConnectionString = ST7735Controller.GetConnectionSettings(SpiChipSelectType.Gpio, pinChipSelect);

            _st7735Controller = new ST7735Controller(spi.GetDevice(spiConnectionString), pinDataCommand);
            _st7735Controller.Enable();
            Graphics.OnFlushEvent += Graphics_OnFlushEvent;
            _oldState              = ReadButtons() ^ Button.All;
        }
Beispiel #5
0
        public static void Main()
        {
            // Get the display ready
            var spi    = SpiController.FromName(G80.SpiBus.Spi2);
            var gpio   = GpioController.GetDefault();
            var st7735 = new ST7735Controller(spi.GetDevice(ST7735Controller.GetConnectionSettings(SpiChipSelectType.Gpio, G80.GpioPin.PD10)), gpio.OpenPin(G80.GpioPin.PE10), gpio.OpenPin(G80.GpioPin.PE12));

            st7735.SetDataAccessControl(true, true, false, false);
            st7735.Enable();
            var disp = DisplayController.FromProvider(st7735);

            disp.SetConfiguration(new SpiDisplayControllerSettings {
                Width = 160, Height = 128
            });
            var bl = gpio.OpenPin(G80.GpioPin.PC7);

            bl.Write(GpioPinValue.High);
            bl.SetDriveMode(GpioPinDriveMode.Output);
            var hdc = GraphicsManager.RegisterDrawTarget(new DrawTarget(disp));

            screen = Graphics.FromHdc(hdc);
            screen.Clear(Color.Black);

            var btn1 = gpio.OpenPin(G80.GpioPin.PE0);

            btn1.SetDriveMode(GpioPinDriveMode.InputPullUp);
            btn1.ValueChanged += Btn1_ValueChanged;

            // Serial port
            serial = UartController.FromName(G80.UartPort.Usart1);
            serial.SetActiveSettings(9600, 8, UartParity.None, UartStopBitCount.One, UartHandshake.None);
            serial.Enable();
            serial.DataReceived += Serial_DataReceived;

            Thread.Sleep(Timeout.Infinite);
        }