예제 #1
0
파일: Program.cs 프로젝트: valoni/NETMF44
        public static void Main()
        {
            try
            {
                _lcd = new SerialLCD(Hardware.SocketTwo, SerialLCD.Baud.BaudRate9600, SerialLCD.DisplaySize.Size4X20);
                _lcd.ClearScreen();
                _lcd.SetBacklight(true);
            }

            catch (PinInUseException ex)
            {
                Debug.Print("Some pins are in use while creating instances : " + ex.Message + " Stack Trace " + ex.StackTrace);
            }

            DisplayMBNLogo(5000);

            _lcd.Print("Hello MikroBus.Net", 0, 0);
            _lcd.Print("VBat ", 2, 0);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.OneBar, 2, 5);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.TwoBars, 2, 6);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.ThreeBars, 2, 7);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.FourBars, 2, 8);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.FiveBars, 2, 9);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.SixBars, 2, 10);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.SevenBars, 2, 11);
            _lcd.Print("Temperature 25.0°C", 3, 0);
            _lcd.PutC((byte)SerialLCD.CustomCharacters.DegreesSymbol, 3, 16);

            Thread.Sleep(Timeout.Infinite);
        }
예제 #2
0
        public static void Main()
        {
            SerialLCD _display = new SerialLCD();

            // define our character maps.
            // see http://maxpromer.github.io/LCD-Character-Creator/ for
            // a GUI character maker
            byte[] happyFace = { 0x0, 0x0, 0xa, 0x0, 0x11, 0xe, 0x0, 0x0 };
            byte[] sadFace   = { 0x0, 0x0, 0xa, 0x0, 0xe, 0x11, 0x0, 0x0 };
            byte[] rocket    = { 0x4, 0xa, 0xa, 0xa, 0x11, 0x15, 0xa, 0x0 };
            byte[] heart     = { 0x0, 0xa, 0x1f, 0x1f, 0xe, 0x4, 0x0, 0x0 };

            // save the custom characters
            _display.SaveCustomCharacter(happyFace, 1);
            _display.SaveCustomCharacter(sadFace, 2);
            _display.SaveCustomCharacter(rocket, 3);
            _display.SaveCustomCharacter(heart, 4);

            _display.Clear();
            _display.SetBrightness();

            // create our string, using the addresses of the characters
            // casted to char.
            StringBuilder s = new StringBuilder();

            s.Append("1:" + (char)1 + " ");
            s.Append("2:" + (char)2 + " ");
            s.Append("3:" + (char)3 + " ");
            s.Append("4:" + (char)4 + " ");
            _display.WriteLine(s.ToString(), 0);

            Thread.Sleep(Timeout.Infinite);
        }
예제 #3
0
        public static void Main()
        {
            var display = new SerialLCD();

            //
            //  Clear the display ready for the test.
            //
            display.Clear();
            display.SetCursorStyle(SerialLCD.CursorStyle.BlinkingBoxOff);
            display.SetCursorStyle(SerialLCD.CursorStyle.UnderlineOff);
            //
            //  Display some text on the bottom row of a 16x2 LCD.
            //
            display.SetCursorPosition(2, 1);
            display.DisplayText("Hello, world");
            Thread.Sleep(1000);
            //
            //  Now scroll the text off of the display to the left.
            //
            for (int index = 0; index < 16; index++)
            {
                display.ScrollDisplay(SerialLCD.Direction.Left);
                Thread.Sleep(500);
            }
            //
            //  Put some text on the top line of the display (note that the
            //  text is still off to the left of the display).
            //
            display.SetCursorPosition(0, 0);
            display.DisplayText("Scrolling Right");
            Thread.Sleep(500);
            //
            //  Now scroll the text back on to the display from the left to
            //  the right of the display.
            //
            for (int index = 0; index < 16; index++)
            {
                display.ScrollDisplay(SerialLCD.Direction.Right);
                Thread.Sleep(500);
            }
            //
            //  Now put a cursor on the display and move it around.
            //
            display.SetCursorStyle(SerialLCD.CursorStyle.BlinkingBoxOn);
            for (int index = 0; index < 10; index++)
            {
                display.MoveCursor(SerialLCD.Direction.Left);
                Thread.Sleep(200);
            }
            Thread.Sleep(1000);
            display.SetCursorStyle(SerialLCD.CursorStyle.BlinkingBoxOff);
            //
            //  Done.
            //
            Thread.Sleep(Timeout.Infinite);
        }
예제 #4
0
        public TachometerApp()
        {
            this._motor = new HBridgeMotor(N.PWMChannels.PWM_PIN_D3,
                                           N.PWMChannels.PWM_PIN_D5, N.Pins.GPIO_PIN_D4, 50);
            this._tach = new LinearHallEffectTachometer(N.Pins.GPIO_PIN_D2);
            this._lcd  = new SerialLCD(new TextDisplayConfig()
            {
                Width = 16, Height = 2
            });

            this._tach.RPMsChanged += RPMsChanged;
        }
예제 #5
0
        public TachometerApp()
        {
            Debug.Print("Here2");
            this._motor = new H.PWM(N.PWMChannels.PWM_PIN_D3, 100, 0, false);
            this._tach  = new LinearHallEffectTachometer(N.Pins.GPIO_PIN_D2);
            this._lcd   = new SerialLCD(new TextDisplayConfig()
            {
                Width = 16, Height = 2
            });

            this._tach.RPMsChanged += RPMsChanged;
        }
예제 #6
0
        public static void Main()
        {
            var display = new SerialLCD();

            //
            //  Clear the display ready for the test.
            //
            display.Clear();
            display.SetCursorStyle(SerialLCD.CursorStyle.BlinkingBoxOff);
            display.SetCursorStyle(SerialLCD.CursorStyle.UnderlineOff);
            //
            //  Display some text on the bottom row of a 16x2 LCD.
            //
            display.SetCursorPosition(1, 1);
            display.Write("Hello, world");
            Thread.Sleep(1000);
        }
예제 #7
0
        // counts from 1-100 and displays it in a scrolling manner on a display
        public static void Main()
        {
            SerialLCD _lcd = new SerialLCD(new TextDisplayConfig {
                Height = 4, Width = 20
            });

            _lcd.SetBrightness();

            while (true)
            {
                // count to 100
                for (int i = 1; i <= (100 - _lcd.DisplayConfig.Height + 1); i++)
                {
                    // write to all lines
                    for (byte l = 0; l < _lcd.DisplayConfig.Height; l++)
                    {
                        _lcd.WriteLine((i + l).ToString(), l);
                    }
                    Thread.Sleep(250);
                }
            }
        }
예제 #8
0
        public static void Main()
        {
            SerialLCD _display = new SerialLCD();

            // set to 100% brightness in case it got stuck in a strange state
            _display.SetBrightness(1);

            _display.WriteLine("Hello, line 2.", 1);

            while (true)
            {
                float bValue = 0f;
                // loop through 0 - 100% brightness
                for (int i = 0; i <= 100; i++)
                {
                    bValue = (float)i / (float)100;
                    _display.WriteLine("Brightness: " + i.ToString() + "%", 0);
                    Debug.Print("Brightness: " + i.ToString() + "%");
                    _display.SetBrightness(bValue);
                }
            }
        }