public static void sendLcdArray(Bitmap bitmap, MetaWatchService.WatchBuffers bufferType) { var send = new byte[1152]; var i = 0; for (var y = 0; y < 96; y++, i++) { var p = new byte[8]; for (var x = 0; x < 96; x += 8) { for (int j = 0; j < 8; j++) { if (bitmap.GetPixel(y, x) == System.Drawing.Color.White) { p[j] = 0; } else { p[j] = 1; } } } send[i] = (byte)(p[7] << 7 | p[6] << 6 | p[5] << 5 | p[4] << 4 | p[3] << 3 | p[2] << 2 | p[1] << 1 | p[0]); } sendLcdBuffer(send, bufferType); }
public static void sendLcdBitmap(Bitmap bitmap, MetaWatchService.WatchBuffers bufferType) { // var pixelArray = new byte[96*96]; // bitmap.pi // bitmap.getPixels(pixelArray, 0, 96, 0, 0, 96, 96); // sendLcdArray(bitmap, bufferType); }
static void sendLcdBuffer(byte[] buffer, MetaWatchService.WatchBuffers bufferType) { if (MetaWatchService.connectionState != MetaWatchService.ConnectionState.CONNECTED) { return; } int i = 0; if (bufferType == MetaWatchService.WatchBuffers.IDLE) { i = 30; } for (; i < 96; i += 2) { byte[] bytes = new byte[30]; bytes[0] = BtMessage.Start; bytes[1] = (byte)(bytes.Length + 2); // packet length bytes[2] = (byte)BtMessage.Message.WriteBuffer; bytes[3] = (byte)bufferType; bytes[4] = (byte)i; // row A for (int j = 0; j < 12; j++) { bytes[j + 5] = buffer[i * 12 + j]; } bytes[4 + 13] = (byte)(i + 1); // row B for (int j = 0; j < 12; j++) { bytes[j + 5 + 13] = buffer[i * 12 + j + 12]; } sendQueue.Add(bytes); } processSendQueue(); }