Beispiel #1
0
        public void ToggleLeds()
        {
            var state = false;

            while (true)
            {
                state = !state;

                Console.WriteLine($"State: {state}");
                display.ClearLine(0);
                display.WriteLine($"State: {state}", 0);

                redLed.State = state;
                display.ClearLine(1);
                display.WriteLine("Red LED is " + (state ? "On" : "Off"), 1);
                Thread.Sleep(200);

                /*
                 * greenLed.State = state;
                 * display.ClearLine(2);
                 * display.WriteLine("Green LED is " + (state ? "On" : "Off"), 2);
                 * Thread.Sleep(200);
                 *
                 * blueLed.State = state;
                 * display.ClearLine(3);
                 * display.WriteLine("Blue LED is " + (state ? "On" : "Off"), 3);
                 * Thread.Sleep(200);*/
            }
        }
Beispiel #2
0
        void SpdtSwitch_Changed(object sender, EventArgs e)
        {
            display.ClearLine(0);
            display.WriteLine("Switch is " + (spdtSwitch.IsOn ? "On" : "Off"), 0);

            display.ClearLine(1);
            display.WriteLine($"Count: {count++}", 1);

            redLed.State   = spdtSwitch.IsOn;
            greenLed.State = !spdtSwitch.IsOn;
        }
Beispiel #3
0
        public void Run()
        {
            DateTime ChristmasDate = new DateTime(_rtc.CurrentDateTime.Year, 12, 25);

            _lcd.WriteLine("Current Date:", 0);
            _lcd.WriteLine(_rtc.CurrentDateTime.Month + "/" + _rtc.CurrentDateTime.Day + "/" + "2018", 1);
            _lcd.WriteLine("Christmas Countdown:", 2);

            while (true)
            {
                var date = ChristmasDate.Subtract(_rtc.CurrentDateTime);
                UpdateCountdown(date);
                Thread.Sleep(1000);
            }
        }
Beispiel #4
0
        public static void Main()
        {
            MCP23008 mcp = new MCP23008();

            ITextDisplay lcd = new Lcd2004(mcp);

            lcd.WriteLine("Wilderness Labs", 0);
            lcd.WriteLine(" Powering", 1);
            lcd.WriteLine("  Connected", 2);
            lcd.WriteLine("   Things", 3);

            //Thread.Sleep(3000);

            //lcd.Clear();

            //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
            //lcd.SaveCustomCharacter(happyFace, 1);
            //lcd.SaveCustomCharacter(sadFace, 2);
            //lcd.SaveCustomCharacter(rocket, 3);
            //lcd.SaveCustomCharacter(heart, 4);

            //lcd.Clear();

            //// 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 + " ");
            //lcd.WriteLine(s.ToString(), 0);

            Thread.Sleep(Timeout.Infinite);
        }