Esempio n. 1
0
        private void Initialize()
        {
            lcd = new Lcd(new GpioLcdTransferProvider(lcd_RS, lcd_EN, lcd_D4, lcd_D5, lcd_D6, lcd_D7));
            lcd.Begin(16, 2);
            DisplayLine("Shot Bru (V1)");
            DisplayLine("Initializing...", 1);

            model = new ShotModel();
            modeController = new ModeController(new Mode[]
                {
                    new HomeMode(model),
                    new LightMode(model),
                });

            keyPad = new KeyPad(keyPad_Input);
            keyPad.KeyPressed += new KeyPressedEventHandler(keyPad_KeyPressed);

            sensor1 = new Sensor(model, sensor1_Input, sensor1_Power);
            sensor1.Triggered += new TriggerEventHandler(sensor1_Triggered);

            camera1 = new Camera(camera1_Shutter);

            // setup the display timer to fire every 250mS,
            displayTimer = new Timer(new TimerCallback(displayTimer_Fired), model, 250, 250);

            // wait for 1 second, gives sensors a chance to start up
            Thread.Sleep(1000);
            //sensor1.Start();
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor for parallel LCD connection
 /// </summary>
 /// <param name="rs"></param>
 /// <param name="rw"></param>
 /// <param name="enable"></param>
 /// <param name="d4"></param>
 /// <param name="d5"></param>
 /// <param name="d6"></param>
 /// <param name="d7"></param>
 /// <param name="rows"></param>
 /// <param name="cols"></param>
 public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, 
     Cpu.Pin d7, byte rows, byte cols)
 {
     GpioLcdTransferProvider lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7);
     lcd = new Lcd(lcdProvider);
     lcd_begin(rows, cols);
 }
Esempio n. 3
0
        public static void Main()
        {
            // Option 1: Use I2C provider.
            // Default configuration coresponds to Adafruit's LCD backpack

            // initialize i2c bus (only one instance is allowed)
            var bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(bus);

            /*
            // Option 2: Adafruit's LCD backup can also work in SIP mode.
            // this setup enabled this pinout.
            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10,
                Shifter74Hc595LcdTransferProvider.BitOrder.MSBFirst,
                new Shifter74Hc595LcdTransferProvider.ShifterSetup
                {
                    RS = ShifterPin.GP0,
                    RW = ShifterPin.None,
                    Enable = ShifterPin.GP1,
                    D4 = ShifterPin.GP5,
                    D5 = ShifterPin.GP4,
                    D6 = ShifterPin.GP3,
                    D7 = ShifterPin.GP2,
                    BL = ShifterPin.GP6
                });
            */

            // create the LCD interface
            var lcd = new Lcd(lcdProvider);

            // set up the LCD's number of columns and rows:
            lcd.Begin(16, 2);

            // Print a message to the LCD.
            lcd.Write("hello, world!");

            Stopwatch sw = Stopwatch.StartNew();

            while (true)
            {
                sw.Start();

                // set the cursor to column 0, line 1
                lcd.SetCursorPosition(0, 1);

                // print the number of seconds since reset:
                lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString());

                Debug.Print(sw.ElapsedMilliseconds.ToString());
                sw.Reset();

                Thread.Sleep(100);

            //    lcd.Backlight = !lcd.Backlight;
            }
        }
Esempio n. 4
0
        public LcdScreen(int columns, int rows, Lcd lcd)
        {
            this.lcd = lcd;
            this.columns = columns;
            this.rows = rows;
            this.pageQueue = new Queue();

            this.lcd.Begin((byte)columns, (byte)rows);
        }
Esempio n. 5
0
 public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, 
     Cpu.Pin d7, byte rows, byte cols)
 {
     lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7);
     lcd = new Lcd(lcdProvider);
     SetScreenSize(rows, cols);
     lcd.Write("hello, world!");
     strBlankRow = new string(' ', cols);
 }
Esempio n. 6
0
        /// <summary>
        /// Constructor for SPI LCD connection (Adafruit I2C LCD backpack)
        /// </summary>
        public clsLCD_MLC(byte rows, byte cols)
        {
            // initialize i2c bus (only one instance is allowed)
            I2CBus bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            MCP23008LcdTransferProvider lcdProvider = new MCP23008LcdTransferProvider(bus);
            lcd = new Lcd(lcdProvider);
            lcd_begin(rows, cols);
        }
Esempio n. 7
0
        public Program()
        {
            var lcdProvider = new GpioLcdTransferProvider(Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D10, Pins.GPIO_PIN_D11, Pins.GPIO_PIN_D12);
            this.lcd = new Lcd(lcdProvider);
            this.lcdScreen = new LcdScreen(20, 4, this.lcd);
            this.lyncCache = new LyncCache();

            this.lcdScreenRefreshReset = new AutoResetEvent(false);

            var lcdScreenAutoRefreshThread = new Thread(this.RunLcdScreenAutoRefresh) { Priority = ThreadPriority.BelowNormal };
            lcdScreenAutoRefreshThread.Start();
        }
Esempio n. 8
0
        public static void Main()
        {
            DateTime dt = Ds1307.GetDateTime();
            Utility.SetLocalTime(dt);

            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1,
                                                          Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9,
                                                          Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10,
                                                          Stm32F4Discovery.Pins.PD8);

            var lcd = new Lcd(lcdProvider);
            lcd.Begin(Columns, 2);

            var userButton = new InterruptPort(Stm32F4Discovery.ButtonPins.User,
                                               false, Port.ResistorMode.PullDown,
                                               Port.InterruptMode.InterruptEdgeLow);

            DateTime showUptimeMode = DateTime.MinValue;
            userButton.OnInterrupt += (d1, d2, t) => showUptimeMode = DateTime.Now.AddSeconds(ShowUptimeInterval);
            
            for (;;)
            {
                var now = DateTime.Now;

                string line1, line2;

                if(showUptimeMode > now)
                {
                    TimeSpan uptime = GetUptime();
                    string uptimeStr = uptime.ToString();
                    int endIndex = uptimeStr.LastIndexOf('.');
                    if(endIndex > Columns)
                        endIndex = Columns;

                    line1 = "Uptime:   ";
                    line2 = uptimeStr.Substring(0, endIndex);
                }
                else
                {
                    line1 = now.ToString("yyyy-MM-dd");
                    line2 = now.ToString("HH:mm:ss        ");
                }

                lcd.SetCursorPosition(0, 0);
                lcd.Write(line1);
                lcd.SetCursorPosition(0, 1);
                lcd.Write(line2);

                Thread.Sleep(100);
            }
        }
        public LcdDisplay()
        {
            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8);

            _lcd = new Lcd(lcdProvider);

            _lcd.Begin(Columns, Rows);
            _lcd.Write("Wait...");

            //http://www.quinapalus.com/hd44780udg.html
            _lcd.CreateChar(0, new byte[] {0x8, 0x14, 0x8, 0x3, 0x4, 0x4, 0x3, 0x0});
            _lcd.Backlight = false;
        }
Esempio n. 10
0
 private static void initializeLCD(I2CBus bus)
 {
     // Use I2C provider
     // Default configuration coresponds to Adafruit's LCD backpack
     // Initialize provider (multiple devices can be attached to same bus)
     var lcdProvider = new MCP23008LcdTransferProvider(_bus);
     // Create the LCD interface
     LCD = new Lcd(lcdProvider);
     // Set the LCD Color property = Led.  This is for cleaner code only.
     //LCD.Color = Led;
     // Set up the LCD's number of columns and rows:
     LCD.Begin(20, 4);
     // Clear the LCD
     LCD.Clear();
 }
Esempio n. 11
0
        public static void Main()
        {
            // initialise the LCD display
            var ledPort = new OutputPort(Pins.ONBOARD_LED, false);
            var backlightPort = new OutputPort(Pins.GPIO_PIN_D3, false);
            var lcdProvider = new MicroLiquidCrystal.GpioLcdTransferProvider(
                Pins.GPIO_PIN_D8,  // RS
                Pins.GPIO_PIN_D9,  // ENABLE
                Pins.GPIO_PIN_D4,  // D4
                Pins.GPIO_PIN_D5,  // D5
                Pins.GPIO_PIN_D6,  // D6
                Pins.GPIO_PIN_D7); // D7
            var lcd = new Lcd(lcdProvider);
            lcd.Begin(16, 2);

            lcd.Clear();
            lcd.SetCursorPosition(2, 0);

            backlightPort.Write(true);

            lcd.Write("Ready ... ");

            const int interval = 10;
            const int reset = 1000;
            int duration = 0;
            while (true)
            {
                // set the cursor to column 0, line 1
                lcd.SetCursorPosition(0, 1);

                // print the number of seconds since reset:
                var time = Utility.GetMachineTime();
                lcd.Write(time.ToString());

                ledPort.Write(duration > reset/2);

                Thread.Sleep(interval);
                duration += interval;
                if (duration >= reset)
                    duration = 0;
            }
        }
Esempio n. 12
0
        public static void Main()
        {
            // create shift register provider
            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10,
                Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst);

            // construct the LCD object
            _lcd = new Lcd(lcdProvider);

            // set up the LCD's number of columns and rows:
            _lcd.Begin(16, 2);

            _modeSwitch = new InterruptPort(Pins.ONBOARD_SW1, false, ResistorModes.Disabled, Port.InterruptMode.InterruptEdgeLow);
            _modeSwitch.OnInterrupt += OnModeSwitchInterrupt;

            // run test
            ChangeMode();

            Thread.Sleep(Timeout.Infinite);
        }
Esempio n. 13
0
        public static void Main()
        {
            var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2,
                                                          Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11,
                                                          Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8);

            var lcd = new Lcd(lcdProvider);
            lcd.Begin(16, 2); //columns, rows

            //znaki specjalne
            //http://www.quinapalus.com/hd44780udg.html
            var customCharacters = new[]
                                       {
                                           new byte[] {0x00, 0x0a, 0x15, 0x11, 0x11, 0x0a, 0x04, 0x00}, //serce
                                           new byte[] {0x04, 0x02, 0x01, 0x1f, 0x01, 0x02, 0x04, 0x00} //strzalka
                                       };

            //ladowanie znakow specjalnych
            for (int i = 0; i < customCharacters.Length; i++)
                lcd.CreateChar(i, customCharacters[i]);

            lcd.Clear();
            lcd.Write("* Hello World! *");
            Thread.Sleep(3000);

//            lcd.Clear();
//            lcd.Encoding = Encoding.UTF8;
//            lcd.Write("ĄąĆćĘꣳŃńÓ󌜯ż");
//            Thread.Sleep(3000);

            lcd.Clear();
            lcd.WriteByte(0); //pierwszy znak specjalny
            Thread.Sleep(2000);
            lcd.WriteByte(1); //drugi znak specjalny
            Thread.Sleep(3000);

            //nastepna linia
            lcd.SetCursorPosition(0, 1);
            lcd.Write("#     Bye...   #");
        }
Esempio n. 14
0
        public static void Main()
        {
            // initialize i2c bus (only one instance is allowed)
            _bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(_bus);

            // create the LCD interface
            _lcd = new Lcd(lcdProvider);

            // set up the LCD's number of columns and rows:
            _lcd.Begin(16, 2);

            // Print a message to the LCD.
            _lcd.Write("Netduino clock");

            // initialize RTC clock
            _clock = new DS1307RealTimeClock(_bus);

            // TODO: Do this only once to set your clock
            // clock.SetClock(new DateTime(2010,11,25,8,17,32));

            _clock.SetLocalTimeFromRTC();
            Debug.Print("The RTC time is: " + DateTime.Now);

            // set timer to update display
            _lcdTimer = new Timer(UpdateDisplay, null, 500, 500);

            // update time now and then every 15 minutes
            _ntpTimer = new Timer(UpdateTime, null, TimeSpan.Zero, new TimeSpan(0, ClockUpdateMinutes, 0));

            // subscribe to network change events
            NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged;

            // end of main
            Thread.Sleep(Timeout.Infinite);
        }
Esempio n. 15
0
        public LCD()
        {
            //Switched to shift register solution on 5/31/2011
            //var lcdProvider = new GpioLcdTransferProvider(
            //    Pins.GPIO_PIN_D12,  // RS
            //    Pins.GPIO_NONE,     // RW
            //    Pins.GPIO_PIN_D11,  // enable
            //    Pins.GPIO_PIN_D9,   // d0
            //    Pins.GPIO_PIN_D8,   // d1
            //    Pins.GPIO_PIN_D7,   // d2
            //    Pins.GPIO_PIN_D6,   // d3
            //    Pins.GPIO_PIN_D5,   // d4
            //    Pins.GPIO_PIN_D4,   // d5
            //    Pins.GPIO_PIN_D3,   // d6
            //    Pins.GPIO_PIN_D2);  // d7

            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_D10);

            // create the LCD interface
            lcd = new Lcd(lcdProvider);

            // set up the number of columns and rows:
            lcd.Begin(16, 2);
        }
Esempio n. 16
0
        private const string RowPadding = "                    "; // 20 chars

        #endregion Fields

        #region Methods

        /// <summary>
        /// 20x4 LCDs wrap rows in order 0-&gt;2-&gt;1-&gt;3 due to its memory configuration. This compensates by modifiying the string to write.
        /// </summary>
        /// <param name="lcd">
        /// The lcd module.
        /// </param>
        /// <param name="text">
        /// The text to write to the LCD.
        /// </param>
        public static void Write20X4(Lcd lcd, string text)
        {
            lcd.Clear();
            lcd.Home();

            var memoryMappedText = text.Substring(0, Math.Min(text.Length, 20));
            if (text.Length > 40)
            {
                memoryMappedText += PadRight(text.Substring(40, Math.Min(text.Length - 40, 20)));
                memoryMappedText += PadRight(text.Substring(20, Math.Min(text.Length - 20, 20)));

                if (text.Length > 60)
                {
                    memoryMappedText += text.Substring(60, Math.Min(text.Length - 60, 20));
                }
            }
            else if (text.Length > 20)
            {
                memoryMappedText += RowPadding;
                memoryMappedText += PadRight(text.Substring(20, Math.Min(text.Length - 20, 20)));
            }

            lcd.Write(memoryMappedText);
        }
Esempio n. 17
0
        public static void Main()
        {
            // create the transfer provider
            /*
            // Option 1: Use direct GPIO provider
            // Initialize the library with the numbers of the interface pins
            // Use wiring shown here http://arduino.cc/en/uploads/Tutorial/lcd_schem.png
            var lcdProvider = new GPIO_LCD_TransferProvider(Pins.GPIO_PIN_D12, Pins.GPIO_PIN_D11, //Pins.GPIO_PIN_D10,
                //Pins.GPIO_PIN_D9, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D6,
                Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D2);
            */

            // Option 2: Use shift register provider
            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10,
                Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst);

            // create the LCD interface
            var lcd = new Lcd(lcdProvider);

            // set up the LCD's number of columns and rows:
            lcd.Begin(16, 2);

            // Print a message to the LCD.
            lcd.Write("hello, world!");

            while (true)
            {
                // set the cursor to column 0, line 1
                lcd.SetCursorPosition(0, 1);

                // print the number of seconds since reset:
                lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString());

                Thread.Sleep(100);
            }
        }
Esempio n. 18
0
        // Hold a static reference in case the GC kicks in and disposes it automatically, note that we only support one in this example!
        public static void Main()
        {
            // Subscribe to RemovableMedia events

              // Create a new storage device
              //ps = new PersistentStorage("SD");
              //ps.MountFileSystem();

              // Sleep forever

              /// Inicjalizacja ponów LED
              Program.ledPortOrange = new OutputPort(ledOrange, false);
              Program.ledPortGreen = new OutputPort(ledGreen, false);
              Program.ledPortBlue = new OutputPort(ledBlue, false);
              Program.ledPortRed = new OutputPort(ledRed, false);

              //anak a dc dziala jak talala
              //AnalogInput BatteryVoltage = new AnalogInput((Cpu.AnalogChannel)Cpu.AnalogChannel.ANALOG_0);

             //// (; ; )
             // {
             //  double voltage = BatteryVoltage.Read();

             //  var milliVolts = (voltage * (double)3300) / (double)0xFFF;
             //  var milliVolts = voltage * 130;
             // }

              string startLog = null;

              Thread.Sleep(1000);

              var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1,
                                              Stm32F4Discovery.Pins.PD2,
                                              Stm32F4Discovery.Pins.PD9,
                                              Stm32F4Discovery.Pins.PD11,
                                              Stm32F4Discovery.Pins.PD10,
                                              Stm32F4Discovery.Pins.PD8);

              var lcd = new Lcd(lcdProvider);
              lcd.Begin(16, 2);

              //lcd.SetCursorPosition(0, 0);
              //lcd.Write("GO!");
              //Thread.Sleep(2000);

              bool sdCardIsInserted = false;

              VolumeInfo[] volumes;

              string[] availFs = VolumeInfo.GetFileSystems();
              if (availFs.Length == 0)
              {
            //lcd.SetCursorPosition(0, 0);
            Debug.Print("No FS found");
            return;
              }

              foreach (string fs in availFs)
              {
            // lcd.SetCursorPosition(0, 0);
            Debug.Print("Av FS: " + fs);
            startLog += (fs + "\n");
            //Thread.Sleep(1000);
              }

              do
              {
            //VolumeInfo.GetVolumes()[0].Refresh();

            volumes = VolumeInfo.GetVolumes();      // List of installed volumes

            foreach (VolumeInfo volume in volumes)  // Refreach all volumes - for hot swap SD inserting
            {
              volume.Refresh();
            }

            volumes = VolumeInfo.GetVolumes();      // List of installed volumes

            if (volumes.Length == 0)
            {
              //lcd.SetCursorPosition(0, 0);
              Debug.Print("No volumes found");
              blinkAllLed();
            }
            else
            {
              int totalSize = 0;
              foreach (VolumeInfo volume in volumes)
              {
            totalSize += (int)volume.TotalSize;
              }

              if (totalSize > 0)
              {
            sdCardIsInserted = true;
              }
              else
              {
            blinkAllLed();
              }
            }

              } while (!sdCardIsInserted);

              foreach (VolumeInfo volume in volumes)
              {
            //lcd.SetCursorPosition(0, 0);
            Debug.Print("Volume: " + volume.Name);
            startLog += (volume.Name + "\n");
            Thread.Sleep(1000);
              }

              // Losowa nazwa pliku
              string ext = Program.RandomString(5);

              /*
              string[] directories = Directory.GetDirectories(@"\SD");
              lcd.Write("directory count: " + directories.Length.ToString());
              startLog += ("directory count: " + directories.Length.ToString() + "\n");

              for (int i = 0; i < directories.Length; i++)
              {
            lcd.Write("directory: " + directories[i]);
            startLog += ("directory count: " + directories[i] + "\n");
              }
              */
              string[] files = Directory.GetFiles(@"\SD");
              startLog += ("file count: " + files.Length.ToString() + "\n");

              for (int i = 0; i < files.Length; i++)
              {
            startLog += ("filename: " + files[i] + "\n");
            //ledPortGreen.Write(true);
            //Thread.Sleep(500);
            //ledPortGreen.Write(false);
            //Thread.Sleep(500);
            Debug.Print("filename: " + files[i]);
              }

              string rtDir = VolumeInfo.GetVolumes()[0].RootDirectory;
              string path = rtDir + @"\" + (files.Length + 1) + "" + "dane" + ext + ".ns";
              /*
              FileStream fs0 = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
              byte[] buffer = UTF8Encoding.UTF8.GetBytes("Start Systemu\n" + path.ToString() + "\n" + startLog.ToString() + "\n");

              if (fs0.CanRead) {
            blinkLed(ledGreen); blinkLed(ledGreen);
              } else {
            blinkLed(ledGreen);
              }

              if (fs0.CanSeek) {
            blinkLed(ledBlue); blinkLed(ledBlue);
              } else {
            blinkLed(ledBlue);
              }

              if (fs0.CanWrite) {
            blinkLed(ledRed); blinkLed(ledRed);
              } else {
            blinkLed(ledRed);
              }

              fs0.Write(buffer, 0, buffer.Length);
              fs0.Close();
              Thread.Sleep(2000);
              */
              //startLog = null; // Odśnieżanie

              for (; ; )
              {

            string tx = Program.RandomString(5);

            lcd.SetCursorPosition(0, 0);
            lcd.Write((files.Length+1) + "_ZAPIS " + tx);

            FileStream fs1;

            if (File.Exists(path)) {
              fs1 = new FileStream(path, FileMode.Append);
              Debug.Print("Exist: " + path);
              blinkLed(ledGreen); blinkLed(ledGreen);

            } else {
              fs1 = new FileStream(path, FileMode.Create);
              Debug.Print("Not Exist: " + path);
              blinkLed(ledGreen);
            }

            byte[] bff = UTF8Encoding.UTF8.GetBytes(tx + "\n");
            /*
            if (fs1.CanRead)
            {
              blinkLed(ledGreen); blinkLed(ledGreen);
            }
            else
            {
              blinkLed(ledGreen);
            }

            if (fs1.CanSeek)
            {
              blinkLed(ledBlue); blinkLed(ledBlue);
            }
            else
            {
              blinkLed(ledBlue);
            }

            if (fs1.CanWrite)
            {
              blinkLed(ledRed); blinkLed(ledRed);
            }
            else
            {
              blinkLed(ledRed);
            }
            */
            if (startLog.Length > 0)
            {
              byte[] stbff = UTF8Encoding.UTF8.GetBytes(startLog + "\n");
              fs1.Write(stbff, 0, stbff.Length);
              startLog = "";
              stbff = null;
              blinkLed(ledRed);
            }

            fs1.Write(bff, 0, bff.Length);
            fs1.Close();

            //FileStream fs2 = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 512);
            // sr = new StreamReader(fs2);
            //string b = sr.ReadToEnd();
            //fs2.Close();
            //Thread.Sleep(50);

            //FileStream fs3 = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.None);
            //[] buffer2 = UTF8Encoding.UTF8.GetBytes("dwa" + "\n");
            //fs3.Write(buffer2, 0, buffer.Length);
            //fs3.Close();

             Thread.Sleep(500);
              }
        }
Esempio n. 19
0
 private static void UpdateMessage(string message, Lcd display)
 {
     display.SetCursorPosition(0, 1);
     foreach (var c in message)
     {
         if (c == ' ')
         {
             display.MoveCursor(true);
             continue;
         }
         display.WriteByte((byte)c);
     }
 }
Esempio n. 20
0
        private static void ShowMessage(string message, Lcd display)
        {
            display.Clear();
            var lines = message.Split(';');
            display.SetCursorPosition(0, 0);
            display.Write(lines[0]);

            if (lines.Length != 2) return;

            display.SetCursorPosition(0, 1);
            display.Write(lines[1]);
        }
Esempio n. 21
0
        private static Lcd ConfigureLiquidCrystalDisplay()
        {
            var transferProvider = new GpioLcdTransferProvider(
                    (Cpu.Pin)FEZ_Pin.Digital.Di21,
                    (Cpu.Pin)FEZ_Pin.Digital.Di23,
                    (Cpu.Pin)FEZ_Pin.Digital.Di47,
                    (Cpu.Pin)FEZ_Pin.Digital.Di46,
                    (Cpu.Pin)FEZ_Pin.Digital.Di49,
                    (Cpu.Pin)FEZ_Pin.Digital.Di48
                    );

            var display = new Lcd(transferProvider);
            display.Begin(16, 2);
            display.BlinkCursor = false;
            display.ShowCursor = false;

            return display;
        }
Esempio n. 22
0
        private static void InitializeLCDDisplay()
        {
            lcdProvider = new GpioLcdTransferProvider(Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7);
            lcd = new Lcd(lcdProvider);
            lcd.Begin(16, 2);
            lcdInitialized = true;

            WriteLCD("PHB Detector", "...now loading");
            Thread.Sleep(5000);//show loading dialog for at least 5 sec..
        }
Esempio n. 23
0
        // Demo from http://bansky.net/blog/2008/10/interfacing-lcd-with-3-wires-from-net-micro-framework
        public static void Main()
        {
            // create the transfer provider
            var lcdProvider = new Shifter74Hc595LcdTransferProvider(SPI_Devices.SPI1, Pins.GPIO_PIN_D10,
                Shifter74Hc595LcdTransferProvider.BitOrder.LSBFirst);

            // create the LCD interface
            var lcd = new Lcd(lcdProvider);

            // set up the LCD's number of columns and rows:
            lcd.Begin(16, 2);

            // Creating custom characters (Smiley face and gimp)
            byte[] buffer = new byte[] {    0x07, 0x08, 0x10, 0x10, 0x13, 0x13, 0x10, 0x10,
                                            0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04,
                                            0x1C, 0x02, 0x01, 0x01, 0x19, 0x19, 0x01, 0x01,
                                            0x10, 0x10, 0x12, 0x11, 0x10, 0x10, 0x08, 0x07,
                                            0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1F,
                                            0x01, 0x01, 0x09, 0x11, 0x01, 0x01, 0x02, 0x1C,

                                            0x15, 0x15, 0x0E, 0x04, 0x04, 0x0A, 0x11, 0x11,
                                            0x04, 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x11, 0x11
                                       };

            // Load custom characters to display CGRAM
            for (int i = 0; i < 8; i++)
            {
                lcd.CreateChar(i, buffer, i * 8);
            }

            // Turn displat on, turn back light on, hide small cursor, show big blinking cursor
            lcd.BlinkCursor = true;

            lcd.Clear();
            lcd.Write("Start me up!");
            Thread.Sleep(3000);

            lcd.Clear();
            lcd.BlinkCursor = false;

            // Print the special characters with the face
            lcd.Write(new byte[] { 0x00, 0x01, 0x02 }, 0, 3);
            lcd.Write(" .NET Micro");

            // Move to second line
            lcd.SetCursorPosition(0, 1);

            // Print the special characters with the face
            lcd.Write(new byte[] { 0x03, 0x04, 0x05 }, 0, 3);
            lcd.Write("  Framework");
            Thread.Sleep(2000);

            // Blink with back light
            for (int i = 0; i < 4; i++)
            {
                lcd.Backlight = (i % 2) != 0;
                Thread.Sleep(400);
            }

            lcd.Clear();
            const string message = "* Hello World! *";
            // Let gimp write the message
            for (int i = 0; i < message.Length; i++)
            {
                lcd.SetCursorPosition(i, 1);
                lcd.WriteByte((byte)(((i % 2) == 0) ? 0x06 : 0x07));

                lcd.SetCursorPosition(i, 0);
                lcd.Write(message[i].ToString());

                Thread.Sleep(200);

                lcd.SetCursorPosition(i, 1);
                lcd.Write(" ");
            }
            Thread.Sleep(1500);

            lcd.Clear();
            lcd.SetCursorPosition(16, 0);

            lcd.Write("http://bansky.net/blog");

            // Scroll the page url
            while (true)
            {
                lcd.ScrollDisplayLeft();
                Thread.Sleep(400);
            }
        }
Esempio n. 24
0
 public static void DisplaySetup(GpioLcdTransferProvider lcdProvider)
 {
     _lcd = new Lcd(lcdProvider);
 }