Inheritance: MonoBehaviour
示例#1
0
        /// <summary>
        /// Initializes the display by setting the specified columns and lines.
        /// </summary>
        private void Initialize(int rows)
        {
            // While the chip supports 5x10 pixel characters for one line displays they
            // don't seem to be generally available. Supporting 5x10 would require extra
            // support for CreateCustomCharacter
            if (GetTwoLineMode(rows))
            {
                _displayFunction |= DisplayFunction.TwoLine;
            }

            _displayControl |= DisplayControl.DisplayOn;
            _displayMode    |= DisplayEntryMode.Increment;

            ReadOnlySpan <byte> commands = stackalloc byte[]
            {
                // Function must be set first to ensure that we always have the basic
                // instruction set selected. (See PCF2119x datasheet Function_set note
                // for one documented example of where this is necessary.)
                (byte)_displayFunction,
                (byte)_displayControl,
                (byte)_displayMode,
                ClearDisplayCommand
            };

            SendCommands(commands);
        }
示例#2
0
        protected override DisplayControl ADLConfig(ADLConfig config, ADLElement element)
        {
            if (element.Name != "composite")
            {
                return(null);
            }

            CompositeDisplay result = new CompositeDisplay
            {
                X      = element["object"]["x"],
                Y      = element["object"]["y"],
                Width  = element["object"]["width"],
                Height = element["object"]["height"],
            };

            foreach (var i in element["children"])
            {
                DisplayControl ctrl = DisplayControl.CreateControl(config, i);
                if (ctrl != null)
                {
                    result.Controls.Add(ctrl);
                }
            }

            return(result);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);


            //Initialize handlers those using MOVERIO API
            _displayControl = new DisplayControl(ApplicationContext);

            var button2DMode      = FindViewById <Button>(Resource.Id.button2DMode);
            var button3DMode      = FindViewById <Button>(Resource.Id.button3DMode);
            var buttonMute3sec    = FindViewById <Button>(Resource.Id.buttonMute3Sec);
            var checkBoxShowToast = FindViewById <CheckBox>(Resource.Id.checkBoxShowToast);
            var seekBarIntensity  = FindViewById <SeekBar>(Resource.Id.seekBarIntensity);


            button2DMode.Click += (_, __) => _displayControl.SetMode(DisplayControl.DisplayMode2d, checkBoxShowToast.Checked);
            button3DMode.Click += (_, __) => _displayControl.SetMode(DisplayControl.DisplayMode3d, checkBoxShowToast.Checked);

            buttonMute3sec.Click += (_, __) => Task.Run(async() =>
            {
                _displayControl.SetMute(true);
                await Task.Delay(3000);
                _displayControl.SetMute(false);
            });

            seekBarIntensity.ProgressChanged += (_, e) => _displayControl.SetBacklight(e.Progress);
        }
示例#4
0
        public void Open_Parentheses_With_Operation()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act (5+5)*(5+5)*exp(1)
            display.Update(NewValue: "(");
            display.Update(NewValue: "5");
            display.Update(NewValue: "+", IsNewTerm: true);
            display.Update(NewValue: "5");
            display.Update(NewValue: ")");
            display.Update(NewValue: "*");
            display.Update(NewValue: "(");
            display.Update(NewValue: "5");
            display.Update(NewValue: "+", IsNewTerm: true);
            display.Update(NewValue: "5");
            display.Update(NewValue: ")");
            display.Update(NewValue: "*");
            display.Update(NewValue: "", Operation: "exp");
            display.Update(NewValue: "1");
            display.Update(NewValue: ")");
            display.Evaluate();
            // Assert
            string actual   = display.Text;
            string expected = "271.828182845905";

            Assert.AreEqual(expected, actual, "Failed Open_Parentheses_With_Operation");
        }
        /// <summary>
        /// Exibe o display
        /// </summary>
        /// <param name="mensagem"></param>
        /// <param name="padrao"></param>
        public void BindDisplay(string mensagem, bool padrao)
        {
            Log.PrintThread("Fluxos_DisplayCallback");

            ThreadInvoker.Instance.RunByUiThread(() =>
            {
                if (_emCaptura)
                {
                    CapturaDigitadaControl capturaDigitadaControl = cttPrincipal.Content as CapturaDigitadaControl;
                    if (capturaDigitadaControl != null)
                    {
                        capturaDigitadaControl.Display(mensagem, !_emCaptura);
                    }
                    return;
                }

                DisplayControl displayControl = new DisplayControl();
                cttPrincipal.Content          = displayControl;
                displayControl.Bind(mensagem, true, !padrao);
                if (_forceClose)
                {
                    CancelCaptura(true);
                    return;
                }
                Show();
            });
        }
示例#6
0
        /// <summary>
        /// Initializes the display by setting the specified columns and lines.
        /// </summary>
        private void Initialize(int rows)
        {
            // Setup 4-bit mode
            // See Figure 24, on page 46

            // Wait for startup
            WaitForNotBusy(15000);

            // While the chip supports 5x10 pixel characters for one line displays they
            // don't seem to be generally available. Supporting 5x10 would require extra
            // support for CreateCustomCharacter

            // if (SetTwoLineMode(rows))
            //     _displayFunction |= DisplayFunction.TwoLine;

            _displayControl |= DisplayControl.DisplayOn;
            _displayMode    |= DisplayEntryMode.Increment;
            ReadOnlySpan <byte> commands = stackalloc byte[]
            {
                // Function must be set first to ensure that we always have the basic
                // instruction set selected. (See PCF2119x datasheet Function_set note
                // for one documented example of where this is necessary.)
                // @@ ReturnHomeCommand,    // 0x02
                // (byte)_displayFunction,  // 0x28
                (byte)_displayControl,      // 0x0c
                ClearDisplayCommand,        // 0x01
                (byte)_displayMode,         // 0x06
                (byte)0x80,                 // 0x80 - Sets address
                // (byte)0x0E,                 // 0x0E <-- not valid?
            };

            SendCommands(commands);
        }
示例#7
0
        public GrayMatchToolForm()
        {
            InitializeComponent();
            displayForm      = new DisplayControl();
            displayForm.Size = panel1.Size;
            panel1.Controls.Add(displayForm);
            displayForm.Show();
            #region Initialize Comboxs
            foreach (var item in Enum.GetValues(typeof(ROI)))
            {
                ROIShapeComb.Items.Add(item);
                FindRegionShapeComb.Items.Add(item);
            }
            #endregion

            #region Initialize ShapeMatchTools
            Infos = new List <GrayMatchToolInfo>();
            Tools = new Dictionary <string, GrayMatchTool>();
            #endregion

            #region Register Events
            this.displayForm.CircleROIEvent     += DisplayForm_CircleROIEvent;
            this.displayForm.Rectangle1ROIEvent += DisplayForm_Rectangle1ROIEvent;
            this.displayForm.Rectangle2ROIEvent += DisplayForm_Rectangle2ROIEvent;
            this.displayForm.EllipseROIEvent    += DisplayForm_EllipseROIEvent;
            #endregion
        }
示例#8
0
        /// <summary>
        /// Initializes the screen
        /// </summary>
        /// <param name="memoryBitMapAllocation">The memory allocation.</param>
        public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
        {
            if (_isInitialized)
            {
                return;
            }

            MemoryAllocationBitmap = memoryBitMapAllocation;
            BackLightPin           = 32;
            Controller             = new();
            Controller.OpenPin(BackLightPin, PinMode.Output);
            Enabled = true;

            var displaySpiConfig = new SpiConfiguration(
                1,
                ChipSelect,
                DataCommand,
                Reset,
                BackLightPin);

            var screenConfig = new ScreenConfiguration(
                0,
                0,
                320,
                240);

            _ = DisplayControl.Initialize(
                displaySpiConfig,
                screenConfig,
                (uint)MemoryAllocationBitmap);

            _isInitialized = true;
        }
示例#9
0
        void proccesFrame(Bitmap image, Action <IKeeper <Blob, double, double, AForge.Point>, IEnumerable <Blob> > action)
        {
            Bitmap rawImage       = image;
            Bitmap processedImage = processImage(rawImage);

            IEnumerable <Tuple <string, Blob> > blobsWithTags = blobCounter.CountItems(processedImage);

            blobKeepers.ForEach(blobKeeper => action(blobKeeper, from blobWithTag in blobsWithTags
                                                     where blobKeeper.Tag == blobWithTag.Item1
                                                     select blobWithTag.Item2));

            DisplayControl.crossThreadOperation(() =>
            {
                switch ((string)DisplayControl.SelectedItem)
                {
                case "Raw image":
                    highlightBlobs(rawImage);
                    break;

                case "Processed":
                    highlightBlobs(processedImage);
                    break;

                case "None":
                default:
                    break;
                }
            });

            videoGroupBox.crossThreadOperation(() => videoGroupBox.Text = $"Video - {pictureGiver.Tag}: {progressMessage}");
        }
示例#10
0
        protected override DisplayControl UIConfig(UIElement config, UIElement element)
        {
            if (element["@class"] != "caFrame")
            {
                return(null);
            }

            CompositeDisplay result = new CompositeDisplay
            {
                X      = element["property?name=geometry"]["rect"]["x"],
                Y      = element["property?name=geometry"]["rect"]["y"],
                Width  = element["property?name=geometry"]["rect"]["width"],
                Height = element["property?name=geometry"]["rect"]["height"],
            };

            foreach (UIElement i in element.AllChilds("widget"))
            {
                var ctrl = DisplayControl.CreateControl(config, i);
                if (ctrl != null)
                {
                    result.Controls.Add(ctrl);
                }
            }

            return(result);
        }
        /// <summary>
        /// Initializes the screen
        /// </summary>
        /// <param name="memoryBitMapAllocation">The memory allocation.</param>
        public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
        {
            if (_isInitialized)
            {
                return;
            }

            // We're allocating anough memory for the full screen as this is a SPRAM board
            MemoryAllocationBitmap = memoryBitMapAllocation;
            BackLightPin           = -1;
            _power = M5Stack.M5Core2.Power;
            // Enable the screen
            Enabled = true;
            // Reset
            _power.Gpio4Value = PinValue.Low;
            Thread.Sleep(100);
            _power.Gpio4Value = PinValue.High;
            Thread.Sleep(100);
            // Create the screen
            DisplayControl.Initialize(new SpiConfiguration(2, ChipSelect, DataCommand, Reset, BackLightPin), new ScreenConfiguration(0, 0, 320, 240), (uint)MemoryAllocationBitmap);

            // For M5Core2, values from 2.5 to 3V are working fine
            // 3.0V for the screen
            LuminosityPercentage = 100;
            _power.EnableDCDC3(true);
            _isInitialized = true;
        }
示例#12
0
 public BlobTool(IToolInfo info, HImage image, DisplayControl window)
 {
     this.ToolName = info.ToolName;
     this.Info     = info;
     this.Window   = window;
     this.Image    = image;
 }
        /// <summary>
        /// Initializes the screen
        /// </summary>
        /// <param name="memoryBitMapAllocation">The memory allocation.</param>
        public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
        {
            if (_isInitialized)
            {
                return;
            }

            // We're allocating enough memory for the full screen because these targets have PSRAM
            MemoryAllocationBitmap = memoryBitMapAllocation;
            // backligth is not controlled by the screen driver
            BackLightPin = -1;

#if M5CORE2
            _power = M5Stack.M5Core2.Power;
#elif TOUGH
            _power = M5Stack.Tough.Power;
#endif

            // Reset screen
            _power.Gpio4Value = PinValue.Low;
            Thread.Sleep(100);
            _power.Gpio4Value = PinValue.High;
            Thread.Sleep(100);

#if TOUGH
            // Reset touch controller
            _power.Gpio1Value = PinValue.Low;
            Thread.Sleep(100);
            _power.Gpio1Value = PinValue.High;
            Thread.Sleep(100);
#endif

            // Create the screen
            var displaySpiConfig = new SpiConfiguration(
                1,
                ChipSelect,
                DataCommand,
                Reset,
                BackLightPin);

            var screenConfig = new ScreenConfiguration(
                0,
                0,
                320,
                240);

            _ = DisplayControl.Initialize(
                displaySpiConfig,
                screenConfig,
                (uint)MemoryAllocationBitmap);

            // set initial value for brightness
            BrightnessPercentage = DefaultScreenBrightness;

            // enable back-light
            Enabled = true;

            _isInitialized = true;
        }
示例#14
0
        public static void Main()
        {
            DisplayControl     dc           = new DisplayControl();
            int                height       = dc.ShorterSide;
            int                width        = dc.LongerSide;
            int                delayBetween = 1100;
            DisplayOrientation orientation  = (DisplayOrientation)dc.Orientation;

            Bitmap fullScreenBitmap = new Bitmap(width, height);    // Use this bitmap as our buffered output to the screen.

            fullScreenBitmap.Clear();

            Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12);

            while (true)
            {
                RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                ColourGradient colourGradient = new ColourGradient(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                Colours ColourExample = new Colours(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                PagedText pt = new PagedText(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                BouncingBalls bb = new BouncingBalls(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                TileImage ti = new TileImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                FontExamples fe = new FontExamples(fullScreenBitmap);
                Thread.Sleep(delayBetween);

                RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                MatrixRain mr = new MatrixRain(fullScreenBitmap);
                Thread.Sleep(Timeout.Infinite);
            }
        }
示例#15
0
        public static void Main()
        {
            Debug.WriteLine("Hello from nanoFramework!");
            InitiM5Stick();
            // For M5Stick, values from 8 to 12 are working fine
            power.LDO2OutputVoltage = ElectricPotential.FromVolts(8);

            int backLightPin = -1; // Not managed thru ESP32 but thru AXP192
            int chipSelect   = 5;
            int dataCommand  = 23;
            int reset        = 18;

            Configuration.SetPinFunction(4, DeviceFunction.SPI1_MISO); // 4 is unused but necessary
            Configuration.SetPinFunction(15, DeviceFunction.SPI1_MOSI);
            Configuration.SetPinFunction(13, DeviceFunction.SPI1_CLOCK);
            DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(26, 1, 80, 160), 10 * 1024);
            Debug.WriteLine($"DisplayControl.MaximumBufferSize:{DisplayControl.MaximumBufferSize}");

            ushort[] toSend = new ushort[100];
            var      blue   = ColorUtility.To16Bpp(Color.Blue);
            var      red    = ColorUtility.To16Bpp(Color.Red);
            var      green  = ColorUtility.To16Bpp(Color.Green);
            var      white  = ColorUtility.To16Bpp(Color.White);

            for (int i = 0; i < toSend.Length; i++)
            {
                toSend[i] = blue;
            }

            DisplayControl.Write(0, 0, 10, 10, toSend);

            for (int i = 0; i < toSend.Length; i++)
            {
                toSend[i] = red;
            }

            DisplayControl.Write(69, 0, 10, 10, toSend);

            for (int i = 0; i < toSend.Length; i++)
            {
                toSend[i] = green;
            }

            DisplayControl.Write(0, 149, 10, 10, toSend);

            for (int i = 0; i < toSend.Length; i++)
            {
                toSend[i] = white;
            }

            DisplayControl.Write(69, 149, 10, 10, toSend);

            Thread.Sleep(Timeout.Infinite);

            // Browse our samples repository: https://github.com/nanoframework/samples
            // Check our documentation online: https://docs.nanoframework.net/
            // Join our lively Discord community: https://discord.gg/gCyBu8T
        }
 private void LoadSettings()
 {
   this.DisplayControl = XMLUTILS.LoadDisplayControlSettings();
   this.SetDisplayVideo();
   this.SetDisplayAction();
   this.SetDisplayActionTime();
   this.SetDisplayIdle();
   this.SetIdleDelay();
 }
 private void LoadSettings()
 {
     this.DisplayControl = XMLUTILS.LoadDisplayControlSettings();
     this.SetDisplayVideo();
     this.SetDisplayAction();
     this.SetDisplayActionTime();
     this.SetDisplayIdle();
     this.SetIdleDelay();
 }
示例#18
0
 public LineToolForm()
 {
     InitializeComponent();
     displayForm      = new DisplayControl();
     displayForm.Size = panel2.Size;
     panel1.Controls.Add(displayForm);
     displayForm.Show();
     displayForm.Rectangle2ROIEvent += DisplayForm_Rectangle2ROIEvent;
 }
 private void HOnMouseClick(object sender, MouseEventArgs mouseEventArgs)
 {
     if (Control.ModifierKeys == Keys.Control)   //ctrl键按下,添加一个TrackGenerator
     {
         PolarCoordinate coordinate =
             coordinateSystem.PointToCoordinate(Tools.PointToPoint2F(mouseEventArgs.Location));
         TargetManagerAddTrackGeneratorCommand generator = new TargetManagerAddTrackGeneratorCommand(coordinate);
         generator.Execute();
     }
     DisplayControl.Focus();
 }
示例#20
0
        public BlobToolForm()
        {
            InitializeComponent();

            #region Init DisplayControl
            displayForm      = new DisplayControl();
            displayForm.Size = panel2.Size;
            panel1.Controls.Add(displayForm);
            displayForm.Show();
            displayForm.Rectangle2ROIEvent += DisplayForm_Rectangle2ROIEvent;
            #endregion
        }
        public RGBLCDShield(MCP23017 mcp23017, byte cols = 16, byte rows = 2, byte dotsize = 0)
        {
            this.mcp23017        = mcp23017;
            this.displayFunction = 0x0;

            // initialize the MCP23017 for this board
            mcp23017.PinMode(8, MCP23017.Direction.Output);
            mcp23017.PinMode(6, MCP23017.Direction.Output);
            mcp23017.PinMode(7, MCP23017.Direction.Output);

            //SetBacklight(BacklightColor.White);

            mcp23017.PinMode(rsPin, MCP23017.Direction.Output);
            mcp23017.PinMode(rwPin, MCP23017.Direction.Output);
            mcp23017.PinMode(enablePin, MCP23017.Direction.Output);

            for (int i = 0; i < dataPins.Length; i++)
            {
                mcp23017.PinMode(dataPins[i], MCP23017.Direction.Output);
            }

            for (int i = 0; i < buttonPins.Length; i++)
            {
                mcp23017.PinMode(buttonPins[i], MCP23017.Direction.Input);
                mcp23017.PullUp(buttonPins[i], 0x01);
            }

            Thread.Sleep(50);
            mcp23017.DigitalWrite(rsPin, 0x00);
            mcp23017.DigitalWrite(enablePin, 0x00);
            mcp23017.DigitalWrite(rwPin, 0x00);

            // put the LCD screen into 4 bit mode
            Write4Bits(0x03);
            Thread.Sleep(5);

            Write4Bits(0x03);
            Thread.Sleep(1);

            Write4Bits(0x03);
            Write4Bits(0x02);

            this.displayFunction = DisplayFunction.LCD_2LINE | DisplayFunction.LCD_4BITMODE | DisplayFunction.LCD_5x8DOTS;
            command((byte)((byte)Commands.LCD_FUNCTIONSET | (byte)this.displayFunction));

            this.displayControl = DisplayControl.LCD_DISPLAYON | DisplayControl.LCD_CURSOROFF | DisplayControl.LCD_BLINKOFF;
            Display();

            Clear();

            this.displayMode = DisplayMode.LCD_ENTRYLEFT | DisplayMode.LCD_ENTRYSHIFTDECREMENT;
            command((byte)((byte)Commands.LCD_ENTRYMODESET | (byte)this.displayMode));
        }
示例#22
0
        /// <summary>
        /// The executable entry point.
        /// </summary>
        public static void Main()
        {
            // Create the object that handles the buttons presses on GPIO pins.
            GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);

#if ESP32   // This is an example mapping, work them out for your needs!
            int backLightPin = 32;
            int chipSelect   = 14;
            int dataCommand  = 27;
            int reset        = 33;
            // Add the nanoFramework.Hardware.Esp32 to the solution
            Configuration.SetPinFunction(19, DeviceFunction.SPI1_MISO);
            Configuration.SetPinFunction(23, DeviceFunction.SPI1_MOSI);
            Configuration.SetPinFunction(18, DeviceFunction.SPI1_CLOCK);
            // Adjust as well the size of your screen and the position of the screen on the driver
            DisplayControl.Initialize(new SpiConfiguration(1, chipSelect, dataCommand, reset, backLightPin), new ScreenConfiguration(0, 0, 320, 240));
            // Depending on you ESP32, you may also have to use either PWM either GPIO to set the backlight pin mode on
            // GpioController.OpenPin(backLightPin, PinMode.Output);
            // GpioController.Write(backLightPin, PinValue.High);
            // Assign GPIO / Key functions to GPIOButtonInputProvider
            // Esp32
            inputProvider.AddButton(12, Button.VK_LEFT, true);
            inputProvider.AddButton(13, Button.VK_RIGHT, true);
            inputProvider.AddButton(34, Button.VK_UP, true);
            inputProvider.AddButton(35, Button.VK_SELECT, true);
            inputProvider.AddButton(36, Button.VK_DOWN, true);
#elif STM32F769I_DISCO // This is an example (working) button map, work the actual pins out for your need!
            //WARNING: Invalid pin mappings will never be returned, and may need you to reflash the device!
            inputProvider.AddButton(PinNumber('J', 0), Button.VK_LEFT, true);
            inputProvider.AddButton(PinNumber('J', 1), Button.VK_RIGHT, true);
            inputProvider.AddButton(PinNumber('J', 3), Button.VK_UP, true);
            inputProvider.AddButton(PinNumber('J', 4), Button.VK_DOWN, true);
            inputProvider.AddButton(PinNumber('A', 6), Button.VK_SELECT, true);

            DisplayControl.Initialize(new SpiConfiguration(), new ScreenConfiguration());
#else
            throw new System.Exception("Unknown button and/or display mapping!");
#endif

            // Create application object
            MySimpleWPFApplication myApplication = new MySimpleWPFApplication();

            // Add main window to application
            mainWindow = new MainMenuWindow(myApplication);

            // Load the fonts resources used by demo.
            NinaBFont = Resource.GetFont(Resource.FontResources.NinaB);
            SmallFont = Resource.GetFont(Resource.FontResources.small);

            // Start the application running.
            myApplication.Run(mainWindow);
        }
示例#23
0
        public void Single_Number()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.Update(NewValue: "1");
            // Assert
            string actual   = display.Text;
            string expected = "1";

            Assert.AreEqual(expected, actual, "Failed Single Number");
        }
示例#24
0
        public void MR_No_MS()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.RecallMemory();
            // Assert
            string actual   = display.Text;
            string expected = "";

            Assert.AreEqual(expected, actual, "Failed MR_No_MS");
        }
示例#25
0
        public void MC()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.ClearMemory();
            // Assert
            string actual   = display.StoredValue;
            string expected = "";

            Assert.AreEqual(expected, actual, "Failed MC");
        }
示例#26
0
        /// <summary>
        /// Initializes the screen
        /// </summary>
        /// <param name="memoryBitMapAllocation">The memory allocation.</param>
        public Screen(int memoryBitMapAllocation = DefaultMemoryAllocationBitmap)
        {
            if (_isInitialized)
            {
                return;
            }

            MemoryAllocationBitmap = memoryBitMapAllocation;
            // Not used in Stick versions, AXP is doing this
            BackLightPin = -1;

#if M5STICKC
            _power = M5StickC.Power;
#else
            _power = M5StickCPlus.Power;
#endif

            var displaySpiConfig = new SpiConfiguration(
                1,
                ChipSelect,
                DataCommand,
                Reset,
                BackLightPin);

#if M5STICKC
            var screenConfig = new ScreenConfiguration(
                26,
                1,
                80,
                160);
#else
            var screenConfig = new ScreenConfiguration(
                52,
                40,
                135,
                240);
#endif

            _ = DisplayControl.Initialize(
                displaySpiConfig,
                screenConfig,
                (uint)MemoryAllocationBitmap);

            // Enable the screen
            Enabled = true;

            // For M5Stick, values from 2.6 to 3V are working fine
            LuminosityPercentage = 100;
            _power.EnableLDO3(true);
            _isInitialized = true;
        }
示例#27
0
文件: Program.cs 项目: valoni/Samples
        public static void Main()
        {
            DisplayControl dc           = new DisplayControl();
            int            height       = dc.ShorterSide;
            int            width        = dc.LongerSide;
            int            bpp          = dc.BitsPerPixel;
            int            delayBetween = 3000;

            Bitmap fullScreenBitmap = new Bitmap(width, height);                            // Use this bitmap as our output to the screen.

            fullScreenBitmap.Clear();
            fullScreenBitmap.Flush();
            DisplayOrientation orientation = (DisplayOrientation)dc.Orientation;
            Font DisplayFont = Resource.GetFont(Resource.FontResources.SegoeUIRegular12);

            while (true)
            {
                SetPixels sp = new SetPixels(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                FontExamples fe = new FontExamples(fullScreenBitmap);
                Thread.Sleep(delayBetween);

                StretchImage si = new StretchImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RandomDrawLine rdlt = new RandomDrawLine(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                TileImage ti = new TileImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RandomEllipses re = new RandomEllipses(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RandomRectangles rr = new RandomRectangles(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                SliceScaling9 ss = new SliceScaling9(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RotateImage ri = new RotateImage(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                RandomClipping rc = new RandomClipping(fullScreenBitmap, DisplayFont);
                Thread.Sleep(delayBetween);

                MatrixRain mr = new MatrixRain(fullScreenBitmap, DisplayFont);
                Thread.Sleep(Timeout.Infinite);
            }
        }
示例#28
0
        public void Mod_Non_Divisor()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act log(e)
            display.Text = "16%5";
            display.Evaluate();
            // Assert
            string actual   = display.Text;
            string expected = "1";

            Assert.AreEqual(expected, actual, "Failed Mod_Non_Divisor");
        }
示例#29
0
        public void Backspace_No_Values()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.Backspace();
            display.Backspace();
            // Assert
            string actual   = display.Text;
            string expected = "";

            Assert.AreEqual(expected, actual, "Failed Backspace_No_Values");
        }
示例#30
0
        public void MS()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.Text = "1";
            display.StoreValue(display.Text);
            // Assert
            string actual   = display.StoredValue;
            string expected = "1";

            Assert.AreEqual(expected, actual, "Failed MR");
        }
示例#31
0
        public void MMinus()
        {
            // Arrange
            DisplayControl display = new DisplayControl();

            // Act
            display.Update(NewValue: "1");
            display.StoreNegativeValue(display.Text);
            // Assert
            string actual   = display.StoredValue;
            string expected = "-1";

            Assert.AreEqual(expected, actual, "Failed MMinus");
        }
 public void Display()
 {
     this.displayControl |= DisplayControl.LCD_DISPLAYON;
     command((byte)((byte)Commands.LCD_DISPLAYCONTROL | (byte)this.displayControl));
 }
 public void NoDisplay()
 {
     this.displayControl &= ~DisplayControl.LCD_DISPLAYON;
     command((byte)((int)Commands.LCD_DISPLAYCONTROL | (int)this.displayControl));
 }
        public RGBLCDShield(MCP23017 mcp23017, byte cols = 16, byte rows = 2, byte dotsize = 0)
        {
            this.mcp23017 = mcp23017;
            this.displayFunction = 0x0;

            // initialize the MCP23017 for this board
            mcp23017.PinMode(8, MCP23017.Direction.Output);
            mcp23017.PinMode(6, MCP23017.Direction.Output);
            mcp23017.PinMode(7, MCP23017.Direction.Output);

            //SetBacklight(BacklightColor.White);

            mcp23017.PinMode(rsPin, MCP23017.Direction.Output);
            mcp23017.PinMode(rwPin, MCP23017.Direction.Output);
            mcp23017.PinMode(enablePin, MCP23017.Direction.Output);

            for (int i = 0; i < dataPins.Length; i++) mcp23017.PinMode(dataPins[i], MCP23017.Direction.Output);

            for (int i = 0; i < buttonPins.Length; i++)
            {
                mcp23017.PinMode(buttonPins[i], MCP23017.Direction.Input);
                mcp23017.PullUp(buttonPins[i], 0x01);
            }

            Thread.Sleep(50);
            mcp23017.DigitalWrite(rsPin, 0x00);
            mcp23017.DigitalWrite(enablePin, 0x00);
            mcp23017.DigitalWrite(rwPin, 0x00);

            // put the LCD screen into 4 bit mode
            Write4Bits(0x03);
            Thread.Sleep(5);

            Write4Bits(0x03);
            Thread.Sleep(1);

            Write4Bits(0x03);
            Write4Bits(0x02);

            this.displayFunction = DisplayFunction.LCD_2LINE | DisplayFunction.LCD_4BITMODE | DisplayFunction.LCD_5x8DOTS;
            command((byte)((byte)Commands.LCD_FUNCTIONSET | (byte)this.displayFunction));

            this.displayControl = DisplayControl.LCD_DISPLAYON | DisplayControl.LCD_CURSOROFF | DisplayControl.LCD_BLINKOFF;
            Display();

            Clear();

            this.displayMode = DisplayMode.LCD_ENTRYLEFT | DisplayMode.LCD_ENTRYSHIFTDECREMENT;
            command((byte)((byte)Commands.LCD_ENTRYMODESET | (byte)this.displayMode));
        }