コード例 #1
0
ファイル: LcdValueUnitDisplay.cs プロジェクト: destroyar/iot
        /// <summary>
        /// Initializes the display for use as a big-number display.
        /// Configures the display with some graphic blocks for the display of big numbers.
        /// </summary>
        /// <param name="romName">Name of the character Rom, required to properly print culture-specific characters in the small text display</param>
        /// <param name="factory">Encoding factory or null</param>
        public void InitForRom(string romName, LcdCharacterEncodingFactory?factory = null)
        {
            if (factory == null)
            {
                factory = new LcdCharacterEncodingFactory();
            }

            lock (_lock)
            {
                // Create the default encoding for the current ROM and culture, but leave the custom characters away.
                var encoding = factory.Create(_culture, romName, ' ', 0);
                Dictionary <byte, byte[]> specialGraphicsRequired = new Dictionary <byte, byte[]>();
                CreateSpecialChars(specialGraphicsRequired);
                for (byte i = 0; i < specialGraphicsRequired.Count; i++)
                {
                    _lcd.CreateCustomCharacter(i, specialGraphicsRequired[i]);
                }

                _currentSeparationChar = ' '; // To make sure the next function doesn't just skip the initialization
                LoadSeparationChar(_currentSeparationChar);
                _encoding = encoding;
                _lcd.BlinkingCursorVisible  = false;
                _lcd.UnderlineCursorVisible = false;
                _lcd.BacklightOn            = true;
                _lcd.DisplayOn = true;
                _lcd.Clear();
                ReadCharacterMap();
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a custom character for standard displays with 8-pixel-per-row characters. See <see cref="ICharacterLcd.CreateCustomCharacter"/> for details.
        /// </summary>
        /// <param name="self">Instance of ICharacterLcd. This method can be called as extension method on this instance</param>
        /// <param name="location">Index of the character to create in the hardware character table</param>
        /// <param name="b0">First row data (standard displays only use the lower 5 bits of each row)</param>
        /// <param name="b1">Second row data</param>
        /// <param name="b2">Third row data</param>
        /// <param name="b3">Fourth row data</param>
        /// <param name="b4">Fifth row data</param>
        /// <param name="b5">Sixth row data</param>
        /// <param name="b6">Seventh row data</param>
        /// <param name="b7">Eight row data</param>
        public static void CreateCustomCharacter(this ICharacterLcd self, byte location, byte b0, byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7)
        {
            byte[] array = { b0, b1, b2, b3, b4, b5, b6, b7 };
            ReadOnlySpan <byte> bytes = new ReadOnlySpan <byte>(array);

            self.CreateCustomCharacter(location, bytes);
        }
コード例 #3
0
ファイル: LcdConsole.cs プロジェクト: microestc/dotnet-iot
        /// <summary>
        /// Loads the specified character encoding. This loads any custom characters from the encoding to the display.
        /// </summary>
        /// <param name="encoding">The encoding to load.</param>
        /// <returns>True if the character encoding was successfully loaded, false if there are not enough custom slots for all the required custom characters.
        /// This may also return false if the encoding factory returned incomplete results, such as a missing custom character for a special diacritic.</returns>
        public bool LoadEncoding(LcdCharacterEncoding encoding)
        {
            bool allCharactersLoaded = encoding.AllCharactersSupported;

            lock (_lock)
            {
                int numberOfCharctersToLoad = Math.Min(encoding.ExtraCharacters.Count, _lcd.NumberOfCustomCharactersSupported);
                if (numberOfCharctersToLoad < encoding.ExtraCharacters.Count)
                {
                    // We can't completelly load that encoding, because there are not enough custom slots.
                    allCharactersLoaded = false;
                }

                for (byte i = 0; i < numberOfCharctersToLoad; i++)
                {
                    byte[] pixelMap = encoding.ExtraCharacters[i];
                    _lcd.CreateCustomCharacter(i, pixelMap);
                }

                _characterEncoding = encoding;
            }

            return(allCharactersLoaded);
        }