Exemplo n.º 1
0
        public void Display()
        {
            Command(OLEDConstants.SSD1306_COLUMNADDR);
            Command(0x00);                       // Column start address (0 = reset)
            Command(Convert.ToByte(_width - 1)); // Column end address (127 = reset)

            Command(OLEDConstants.SSD1306_PAGEADDR);
            Command(0x00); // Page start address (0 = reset)
            Command(Convert.ToByte(_pages - 1));


            for (int i = 0; i < (_width * _height / 8); i++)
            {
                // send a bunch of data in one xmission

                var sendBuffer = new List <byte>();
                sendBuffer.Add(0x40);

                for (int x = 0; x < 16; x++)
                {
                    sendBuffer.Add(_buffer[i]);
                    i++;
                }
                i--;
                _writer.Write(sendBuffer.ToArray());
            }
        }
Exemplo n.º 2
0
        private void WriteStackTrace(IEnumerable <StackFrame> trace)
        {
            if (trace == null)
            {
                _writer.WriteLine("(Stacktrace is null)");
                return;
            }

            bool missingInfo = false;

            foreach (var frame in trace)
            {
                LogFormatUtility.GetSignatureElements(
                    frame.GetMethod(), out string methodName, out string arguments);

                string fileName        = frame.GetFileName();
                bool   missingFilename = string.IsNullOrWhiteSpace(fileName);
                missingInfo |= missingFilename;

                int  lineNumber        = frame.GetFileLineNumber();
                bool missingLineNumber = lineNumber == 0;
                missingInfo |= missingLineNumber;

                _writer.Write($"at ");

                if (!missingLineNumber)
                {
                    _writer.Write($"line {lineNumber} of ");
                }

                _writer.Write($"{methodName}{arguments}");

                if (!missingFilename)
                {
                    _writer.Write($"in {frame.GetFileName()}");
                }

                _writer.WriteLine();
            }

            if (missingInfo)
            {
                _writer.WriteLine($"(Some info is missing. This is expected if release-mode code is involved)");
            }
        }
Exemplo n.º 3
0
        public static void WritePrefix(ISimpleWriter writer, LogEvent entry, ref string _lastDate)
        {
            string dateText = entry.Timestamp.ToLocalTime().ToShortDateString();

            if (dateText != _lastDate)
            {
                writer.WriteLine($"[{dateText}]");
                _lastDate = dateText;
            }

            string timeText = entry.Timestamp.ToLocalTime().ToShortTimeString();

            string type = Enum.GetName(typeof(LogLevel), entry.Level);

            writer.Write($"[{timeText}][{type}] ");
        }