public static NuimoLedMatrix AddHours(this NuimoLedMatrix matrix, int hours)
        {
            if (hours == 0)
            {
                return(matrix);
            }
            if (hours > 3)
            {
                throw new ArgumentException("hours > 3 not supported");
            }

            NuimoLedMatrix matrixToAdd;

            switch (hours)
            {
            case 1:
                matrixToAdd = OneHour;
                break;

            case 2:
                matrixToAdd = TwoHour;
                break;

            case 3:
                matrixToAdd = ThreeHour;
                break;

            default:
                return(null);
            }

            return(matrix.AddLedMatrix(matrixToAdd, 0, 7));
        }
        public static NuimoLedMatrix AddSeconds(this NuimoLedMatrix matrix, int seconds)
        {
            var textToAdd     = ":" + seconds;
            var matrixForText = textToAdd.ToSmallLedMatrix();

            matrix = matrix.AddLedMatrix(matrixForText);
            return(matrix);
        }
        public static NuimoLedMatrix AddMinutes(this NuimoLedMatrix matrix, int minutes)
        {
            var textToAdd     = minutes + ":";
            var matrixForText = textToAdd.ToSmallLedMatrix();

            matrix = matrix.AddLedMatrix(matrixForText);
            return(matrix);
        }
        private static NuimoLedMatrix ToNuimoLedMatrix(this bool[] leds)
        {
            var ledCharArray = leds
                               .Take(Math.Min(leds.Length, 81))
                               .Select(ledOn => ledOn ? '*' : ' ')
                               .ToArray();
            var ledString = new string(ledCharArray);
            var matrix    = new NuimoLedMatrix(ledString);

            return(matrix);
        }
        public static NuimoLedMatrix AddLedMatrix(this NuimoLedMatrix matrix, NuimoLedMatrix matrixToAdd,
                                                  int shiftRight = 0, int shiftDown = 0)
        {
            var ledsToAdd = matrixToAdd.Leds
                            .ShiftRight(shiftRight)
                            .ShiftDown(shiftDown);

            var leds           = matrix.Leds.Zip(ledsToAdd, (led1, led2) => led1 || led2).ToArray();
            var matrixToReturn = leds.ToNuimoLedMatrix();

            return(matrixToReturn);
        }
Example #6
0
        public static NuimoLedMatrix ToSmallLedMatrix(this string text)
        {
            var matrix = new NuimoLedMatrix("");

            var offset = 0;

            foreach (var character in text)
            {
                matrix  = matrix.AddLedMatrix(character.ToLedMatrix(true), offset);
                offset += 3;
            }
            return(matrix);
        }
Example #7
0
        private void ShowTime(INuimoController controller)
        {
            var timeDisplay = new NuimoLedMatrix("");

            if (TimeLeft >= TimeSpan.FromHours(1))
            {
                timeDisplay = timeDisplay.AddHours(TimeLeft.Hours);
            }

            if (TimeLeft >= TimeSpan.FromMinutes(1))
            {
                timeDisplay = timeDisplay.AddMinutes(TimeLeft.Minutes);
            }
            else
            {
                timeDisplay = timeDisplay.AddSeconds(TimeLeft.Seconds);
            }

            controller?.DisplayLedMatrixAsync(timeDisplay, 2, NuimoLedMatrixWriteOptions.WithoutWriteResponse);
            Debug.WriteLine(TimeLeft);
        }
Example #8
0
 public static string ToLedString(this NuimoLedMatrix matrix)
 {
     return(new string(matrix.Leds.Select(led => led ? '*' : ' ').ToArray()));
 }