Exemplo n.º 1
0
        /// <summary>
        /// Set color palette
        /// </summary>
        /// <param name="cp">color palette</param>
        /// <returns>void</returns>
        public async Task SetColorAsync(ePaperColorPalette cp)
        {
            byte[] parameters = new byte[2] {
                (byte)cp.ForegroundColor, (byte)cp.BackgroundColor
            };
            string result = await SendCommand(ePaperCommand.SetColor, parameters);

            if (result != "OK")
            {
                ThrowException(result);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get color palette
        /// </summary>
        /// <returns>color palette</returns>
        public async Task <ePaperColorPalette> GetColorAsync()
        {
            string result = await SendCommand(ePaperCommand.GetColor);

            ePaperColorPalette pcp = new ePaperColorPalette();
            ePaperColor        fColor;
            ePaperColor        bColor;

            if (!Enum.TryParse <ePaperColor>(result.Substring(0, 1), out fColor))
            {
                ThrowException(result);
            }
            if (!Enum.TryParse <ePaperColor>(result.Substring(1, 1), out bColor))
            {
                ThrowException(result);
            }
            pcp.ForegroundColor = fColor;
            pcp.BackgroundColor = bColor;

            return(pcp);
        }