// Port from https://github.com/adafruit/Adafruit_Python_SSD1306/blob/8819e2d203df49f2843059d981b7347d9881c82b/Adafruit_SSD1306/SSD1306.py#L184 internal static void DisplayImage(this Ssd1306 s, Image <Gray16> image) { Int16 width = 128; Int16 pages = 4; List <byte> buffer = new List <byte>(); for (int page = 0; page < pages; page++) { for (int x = 0; x < width; x++) { int bits = 0; for (byte bit = 0; bit < 8; bit++) { bits = bits << 1; bits |= image[x, page * 8 + 7 - bit].PackedValue > 0 ? 1 : 0; } buffer.Add((byte)bits); } } int chunk_size = 16; for (int i = 0; i < buffer.Count; i += chunk_size) { s.SendData(buffer.Skip(i).Take(chunk_size).ToArray()); } }
private static void SendMessageLine(Ssd1306 device, string message) { int bytesSend = 0; foreach (char character in message) { byte[] chars = BasicFont.GetCharacterBytes(character); device.SendData(chars); bytesSend += chars.Length; } int bytesDiff = Math.Abs(bytesSend - 64); byte[] bytesComplete = new byte[bytesDiff]; device.SendData(bytesComplete); }
private static void SendMessage(Ssd1306 device, string message) { foreach (char character in message) { device.SendData(BasicFont.GetCharacterBytes(character)); } }
private static void SendMessage(Ssd1306 device, string message) { device.SendCommand(new Ssd1306Cmnds.SetColumnAddress()); device.SendCommand(new Ssd1306Cmnds.SetPageAddress(Ssd1306Cmnds.PageAddress.Page0, Ssd1306Cmnds.PageAddress.Page3)); foreach (char character in message) { device.SendData(BasicFont.GetCharacterBytes(character)); } }
private static void SendMessage(Ssd1306 ssd1306, string message) { ssd1306.SendCommand(new SetColumnAddress()); ssd1306.SendCommand(new SetPageAddress(PageAddress.Page0, PageAddress.Page3)); foreach (char character in message) { ssd1306.SendData(BasicFont.GetCharacterBytes(character)); } }
private static void ClearScreen(Ssd1306 device) { device.SendCommand(new Ssd1306Cmnds.SetColumnAddress()); device.SendCommand(new Ssd1306Cmnds.SetPageAddress(Ssd1306Cmnds.PageAddress.Page0, Ssd1306Cmnds.PageAddress.Page3)); for (int cnt = 0; cnt < 32; cnt++) { byte[] data = new byte[16]; device.SendData(data); } }
private static void ClearScreen(Ssd1306 ssd1306) { ssd1306.SendCommand(new SetColumnAddress()); ssd1306.SendCommand(new SetPageAddress(PageAddress.Page0, PageAddress.Page3)); for (int cnt = 0; cnt < 32; cnt++) { byte[] data = new byte[16]; ssd1306.SendData(data); } }
private static void ClearScreen(Ssd1306 device) { // OLED 64x32 // for each page for (int i = 0; i < 4; i++) { device.SendData(new byte[64]); // for each column /*for (int j = 0; j < 64; j++) { * device.SendData(new byte[] {0x00}); * }*/ } }