Example #1
0
        public void ProcessPacket(SerialPacket packet, ShiftRegisterDriver.Session shiftRegisterSession)
        {
            this.user = packet.Data.Substring(2, packet.Data.Length - 2);

            switch (packet.Data[0])
            {
                case StatusCode.Away:
                    this.status = "away";

                    // first and third bit enabled
                    shiftRegisterSession.Write(5);
                    break;
                case StatusCode.Busy:
                    this.status = "busy";

                    // first and fourth bit enabled
                    shiftRegisterSession.Write(9);
                    break;
                case StatusCode.Free:
                    this.status = "free";

                    // first and second bit enabled
                    shiftRegisterSession.Write(3);
                    break;
            }
        }
Example #2
0
        private void ProcessPacket(SerialPacket packet, ShiftRegisterDriver shiftRegisterDriver)
        {
            switch (packet.DataType)
            {
                case PacketDataType.Lync:
                    using (var shiftRegisterSession = shiftRegisterDriver.AcquireSessionLock())
                    {
                        this.lyncCache.ProcessPacket(packet, shiftRegisterSession);
                    }

                    this.lyncCache.QueueDisplayStatus(this.lcdScreen);
                    break;
                default:
                    var page = this.lcdScreen.CreatePage();
                    page.Write(0, packet.Data);
                    this.lcdScreen.PushPage(page);
                    break;
            }
        }
Example #3
0
        private void RunCore()
        {
            using (var shiftRegisterDriver = new ShiftRegisterDriver(Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D3, false, 4))
            using (var serialPort = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One))
            using (var packetReader = new SerialPacketReader(serialPort))
            {
                // turn on the lcd backlight
                using (var shiftRegisterSession = shiftRegisterDriver.AcquireSessionLock())
                {
                    shiftRegisterSession.Write(1);
                }

                var window = this.lcdScreen.CreatePage();
                window.MinimumWaitTime = 1000;
                window.Write(0, "EventPipe v1.0");
                this.lcdScreen.PushPage(window);
                this.lcdScreenRefreshReset.Set();

                while (true)
                {
                    // just in case the serial port closes, try again?
                    if (!serialPort.IsOpen)
                    {
                        serialPort.Open();
                    }

                    var packet = packetReader.Read();
                    this.ProcessPacket(packet, shiftRegisterDriver);
                }
            }
        }
 public Session(ShiftRegisterDriver shiftRegisterDriver)
 {
     this.shiftRegisterDriver = shiftRegisterDriver;
 }