Esempio n. 1
0
        /// <summary>
        /// Relies on persistence of vision to display the 8*8 bitmap in memory, one line at a time, one column at a time
        /// Each line is scanned top-bottom and right to left.
        /// The function should be called 30 times per second to avoid flickering.
        /// </summary>
        protected static void DoDisplay(LedMatrix matrix)
        {
            while (true)
            {
                var row = 0;

                foreach (var bitmap in matrix.MatrixBitmap)
                {
                    matrix.OnRow(row, bitmap, true);

                    byte mask = 1;
                    var  col  = 0;

                    while (mask != 0x80 /* 10000000 */)
                    {
                        var state = bitmap & mask;
                        if (matrix.OnCol(col, bitmap, 1 == state))
                        {
                            break;
                        }

                        // Next column
                        mask <<= 1;
                        col++;
                    }

                    // Turn off the current row in the LED matrix before moving on to the next one
                    matrix.OnRow(row, bitmap, false);
                    row++;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Relies on persistence of vision to display the 8*8 bitmap in memory, one line at a time, one column at a time
        /// Each line is scanned top-bottom and right to left.
        /// The function should be called 30 times per second to avoid flickering.
        /// </summary>
        protected static void DoDisplay(LedMatrix matrix)
        {
            while (true) {
                var row = 0;

                foreach (var bitmap in matrix.MatrixBitmap) {
                    matrix.OnRow(row, bitmap, true);

                    byte mask = 1;
                    var col = 0;

                    while (mask != 0x80 /* 10000000 */) {
                        var state = bitmap & mask;
                        if (matrix.OnCol(col, bitmap, 1 == state)) break;

                        // Next column
                        mask <<= 1;
                        col++;
                    }

                    // Turn off the current row in the LED matrix before moving on to the next one
                    matrix.OnRow(row, bitmap, false);
                    row++;
                }
            }
        }