public void DrawFrame(GraphicsBuffer.DrawCallback callback) { if (graphics == null) { graphics = new GraphicsBuffer(Width, Height, true); } byte[] pixelData = graphics.Draw(callback, GraphicsFormat.RGB565); Draw(pixelData, Width, 0, 0); }
public void ShowFrame(GraphicsBuffer.DrawCallback callback) { if (!isInitialized) { InitSensor(); isInitialized = true; } byte[] pixelData = graphics.Draw(callback, GraphicsFormat.BlackAndWhiteDithered); byte[] tile = new byte[Width + 7]; for (int page = 0; page < Height / 8; page++) { tile[0] = 0x80; tile[1] = (byte)(SetPageAddress + page); tile[2] = 0x80; tile[3] = (byte)(SetColumnAddressLow | (DisplayOffset & 0x0f)); tile[4] = 0x80; tile[5] = (byte)(SetColumnAddressHigh | ((DisplayOffset >> 4) & 0x0f)); tile[6] = 0x40; int index = page * 8 * Width; for (int i = 0; i < Width; i++) { byte b = 0; byte bit = 1; int p = index + i; for (int j = 0; j < 8; j++) { if (pixelData[p] != 0) { b |= bit; } bit <<= 1; p += Width; } tile[i + 7] = b; } device.SubmitOnI2CPort(i2cPort, tile, DisplayAddress); } /* * // Just for the fun of it: read back some of the data * byte[] cmd = new byte[] { * 0x80, SetPageAddress + 4, * 0x80, (byte)(SetColumnAddressLow | (DisplayOffset & 0x0f)), * 0x80, (byte)(SetColumnAddressHigh | ((DisplayOffset >> 4) & 0x0f)), * 0x40 * }; * byte[] pageData = device.SendAndRequestOnI2CPort(i2cPort, cmd, DisplayAddress, Width); */ }