Exemple #1
0
        // Testing MAX7219 to control 10 led bar
        // It is partially working as I can control MAX7219 SegA (8 led) or SegB (2 led)
        // But because only 10 led are wired instead of the 64, this affect the multiplexing
        // and in the end we cannot have the 10 led on at the same time
        static void test1(NusbioMatrix matrix)
        {
            //matrix.Clear(0, refresh: true);
            //for (var r = 0; r < 8; r++)
            //    for (var c = 0; c < 8; c++)
            //        matrix.SetLed(0, r, c, true, true); // WriteDisplay for every pixel
            //Thread.Sleep(500);

            matrix.Clear(0, refresh: true);
            matrix.SetPixel(0, (byte)(32));
            matrix.SetPixel(1, (byte)(32));
            matrix.WriteDisplay();

            matrix.Clear(0, refresh: true);
            for (var p = 0; p < 8; p++)
            {
                matrix.SetPixel(p, (byte)(64));
                matrix.WriteDisplay();
            }
            matrix.WriteDisplay();

            matrix.SetPixel(0, (byte)(64 + 32));
            matrix.SetPixel(1, (byte)(64 + 32));
            matrix.WriteDisplay();


            matrix.Clear(0, refresh: true);
            for (var p = 0; p < 8; p++)
            {
                matrix.SetPixel(p, (byte)(255));
                matrix.WriteDisplay();
            }
            matrix.WriteDisplay();

            matrix.Clear(0, refresh: true);
            for (var b = 0; b < 8; b++)
            {
                for (var p = 0; p < 8; p++)
                {
                    matrix.SetPixel(p, (byte)(1 << b));
                    matrix.WriteDisplay();
                }
            }
            Thread.Sleep(500);
            matrix.Clear(0, refresh: false);
            matrix.WriteDisplay();

            matrix.Clear(0, refresh: true);
            for (var r = 0; r < 8; r++)
            {
                for (var c = 0; c < 8; c++)
                {
                    matrix.SetLed(0, r, c, true, false); // WriteDisplay for every pixel
                }
            }
            Thread.Sleep(500);
            matrix.WriteDisplay(0);

            var m = new MAX7219MapTo10LedBarMap(matrix);
            m.Clear(true);
            for (var i = 0; i < m.Count; i++)
            {
                m.SetState(i, true, true);
            }
            m.WriteDisplay();
        }