Esempio n. 1
0
        private static void Program_EEPROM_AT28C16(Nusbio nusbio)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "EEPROM AT28C16 Programming");
            ConsoleEx.WriteMenu(-1, 5, "Q)uit");

            MadeInTheUSB.EEPROM.EEPROM_AT28C16 e = new MadeInTheUSB.EEPROM.EEPROM_AT28C16(
                nusbio, new List <NusbioGpio>()
            {
                NusbioGpio.Gpio0, NusbioGpio.Gpio1, NusbioGpio.Gpio2, NusbioGpio.Gpio3, NusbioGpio.Gpio4
            },
                writeEnable: NusbioGpio.Gpio7,
                outputEnable: NusbioGpio.Gpio6
                );

            var maxAddr = 16;

            e.EnableOutput(false);
            for (var a = 0; a < maxAddr; a += 1)
            {
                var val = 0;
                Console.WriteLine("Addr:{0} - {1}, set value:{2}", a, BitUtil.BitRpr(a), val);
                //e.Write(a, (byte)val); // Value is not controllable yet
            }
            e.EnableOutput(true);

            while (true)
            {
                for (var a = 0; a < maxAddr; a++)
                {
                    var val = (a % 2) == 0 ? 128 + 32 + 8 + 2 : 0;
                    Console.WriteLine("Address:{0:00}:{1}, Value:{2}:{3}",
                                      a, BitUtil.BitRpr(a), val, BitUtil.BitRpr(val));
                    e.Read(a);
                    Thread.Sleep(500);
                    if (Console.KeyAvailable)
                    {
                        break;
                    }
                }
                if (Console.KeyAvailable)
                {
                    if (Console.ReadKey().Key == ConsoleKey.Q)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        private static void ProgramFor0To15Counter(Nusbio nusbio, MadeInTheUSB.EEPROM.EEPROM_AT28C16 e, bool demoGpio3to7Too = false)
        {
            var maxAddr = 16;

            Console.Clear();
            ConsoleEx.TitleBar(0, GetAssemblyProduct() + "Program for 0..15 counter", ConsoleColor.Yellow, ConsoleColor.DarkBlue);

            if (ConsoleEx.Question(3, "Program Y)es N)o", new List <char>()
            {
                'Y', 'N'
            }) == 'Y')
            {
                Console.WriteLine("Programming...");
                var val = 0;
                e.EnableOutput(false);
                for (var a = 0; a < maxAddr; a += 1)
                {
                    val = a;
                    Console.WriteLine("Addr:{0:00} - {1}, set value:{2}", a, BitUtil.BitRpr(a), val);
                    if (a <= 9)
                    {
                        // For digit 0..9 the bit 16 is high. Bit 16 will be use to drive
                        // The second 7-SegmentDisplay just to display a 1
                        // When bit 16 is high the second 7-SegmentDisplay will display nothing ActiveLow/Common Annode
                        val += 16;
                    }
                    else
                    {
                        val -= 10; // First digit become 10-10:0, 11-10:1, 12-10:2, ...
                        // Bit 16 will is low and turn on The second 7-SegmentDisplay just to display a 1
                    }
                    e.Write(a, val);
                    Thread.Sleep(500);
                }
            }

            e.EnableOutput(true);
            for (var a = 0; a < maxAddr; a++)
            {
                Console.WriteLine("Address:{0:00}:{1}", a, BitUtil.BitRpr(a));
                e.Read(a);
                Thread.Sleep(500);
                if (Console.KeyAvailable)
                {
                    break;
                }
            }
        }