コード例 #1
0
        public void sendImageArray(byte[] sourceImageArray)
        {
            if (_serialPort.IsOpen)
            {
                PACKET packet = new PACKET();

                //  Set Column Address
                //  Column_Address(0x1C, 0x5B);
                packet.CD         = 1;
                packet.command    = 0x15;
                packet.dataLength = 2;
                packet.data[0]    = 0x1C;
                packet.data[1]    = 0x5B;
                Transmit(packet);
                Thread.Sleep(1);

                //  Set Row Address
                //  Row_Address(0x00, 0x3F);
                packet.CD         = 1;
                packet.command    = 0x75;
                packet.dataLength = 2;
                packet.data[0]    = 0x00;
                packet.data[1]    = 0x3F;
                Transmit(packet);
                Thread.Sleep(1);

                //  Write_Command(0x5c);
                packet.CD         = 1;
                packet.command    = 0x5C;
                packet.dataLength = 0;
                Transmit(packet);
                Thread.Sleep(1);

                int arrayProgress  = 0;
                int bytesRemaining = sourceImageArray.Length;
                for (int i = 0; i < sourceImageArray.Length; i++)
                {
                    packet.data[arrayProgress++] = sourceImageArray[i];

                    if (arrayProgress == 251)
                    {
                        packet.CD         = 0;
                        packet.dataLength = (byte)arrayProgress;
                        frmMain.Transmit(packet);
                        arrayProgress   = 0;
                        bytesRemaining -= 251;
                    }
                }
                if (bytesRemaining > 0)
                {
                    packet.CD         = 0;
                    packet.dataLength = (byte)bytesRemaining;
                    frmMain.Transmit(packet);
                }
            }
        }
コード例 #2
0
        private void btnInvert_Click(object sender, EventArgs e)
        {
            PACKET packet = new PACKET();

            //Display_Mode(0xA7);                //Set Display Inverted Mode
            packet.CD         = 1;
            packet.command    = 0xA7;
            packet.dataLength = 0;
            Transmit(packet);
        }
コード例 #3
0
        private void btnNormal_Click(object sender, EventArgs e)
        {
            PACKET packet = new PACKET();

            //Display_Mode(0xA6);                //Set Display Normal Mode
            packet.CD         = 1;
            packet.command    = 0xA6;
            packet.dataLength = 0;
            Transmit(packet);
        }
コード例 #4
0
        static public void Transmit(PACKET packet)
        {
            //Send out signals
            _serialPort.Write(BitConverter.GetBytes(0x55), 0, 1);
            _serialPort.Write(BitConverter.GetBytes(0xAA), 0, 1);

            // Send the C/D bit
            _serialPort.Write(BitConverter.GetBytes(packet.CD), 0, 1);

            // Send the Command -OR- a zero
            if (packet.CD == 1)
            {
                _serialPort.Write(BitConverter.GetBytes(packet.command), 0, 1);
            }

            // Send the dataLength
            _serialPort.Write(BitConverter.GetBytes(packet.dataLength), 0, 1);

            // Send the data
            for (int i = 0; i < packet.dataLength; i++)
            {
                _serialPort.Write(BitConverter.GetBytes(packet.data[i]), 0, 1);
            }
        }
コード例 #5
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (_serialPort.IsOpen)
            {
                groupBox2.Enabled = false;
                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter           = "24-Bit Bitmap file (*.bmp)|*.bmp|All files (*.*)|*.*";
                openFileDialog1.FilterIndex      = 2;
                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    PACKET packet = new PACKET();
                    try
                    {
                        //  Set Column Address
                        //  Column_Address(0x1C, 0x5B);
                        packet.CD         = 1;
                        packet.command    = 0x15;
                        packet.dataLength = 2;
                        packet.data[0]    = 0x1C;
                        packet.data[1]    = 0x5B;
                        Transmit(packet);

                        //  Set Row Address
                        //  Row_Address(0x00, 0x3F);
                        packet.CD         = 1;
                        packet.command    = 0x75;
                        packet.dataLength = 2;
                        packet.data[0]    = 0x00;
                        packet.data[1]    = 0x3F;
                        Transmit(packet);

                        //  Write_Command(0x5c);
                        packet.CD         = 1;
                        packet.command    = 0x5C;
                        packet.dataLength = 0;
                        Transmit(packet);

                        System.Drawing.Bitmap image    = (Bitmap)Bitmap.FromFile(openFileDialog1.FileName);
                        _bmpImage             imgArray = new _bmpImage();
                        imgArray.sourceImage = image;

                        // Start sending bytes
                        imgArray.sendImageArray(8);

                        //TODO
                        //if the arrayProgress < 255
                        // Wrap it up and send it
                        //TODO
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error: Could not open Bitmap: " + ex.Message);
                    }
                }
                groupBox2.Enabled = true;
            }
        }
コード例 #6
0
        private void cmdInit_Click(object sender, EventArgs e)
        {
            PACKET serial = new PACKET();

            //Send the following Commands
            // Copied from CFA Bring Up

            //Write_Command(0xFD);
            //Write_Data(0x12);
            serial.CD      = 1;
            serial.command = 0xFD;
            serial.data[0] = 0x12;
            Transmit(serial);

            //Write_Command(0xAE);
            serial.command = 0xAE;
            Transmit(serial);

            //Write_Command(0x15);
            //Write_Data(0x1c);
            //Write_Data(0x5b);
            serial.command    = 0x15;
            serial.dataLength = 2;
            serial.data[0]    = 0x1C;
            serial.data[1]    = 0x5B;
            Transmit(serial);

            //Write_Command(0x75);
            //Write_Data(0x00);
            //Write_Data(0x3f);
            serial.command    = 0x75;
            serial.dataLength = 2;
            serial.data[0]    = 0x00;
            serial.data[1]    = 0x3F;
            Transmit(serial);

            //Write_Command(0xB3);
            //Write_Data(0x91);
            serial.command    = 0xB3;
            serial.dataLength = 1;
            serial.data[0]    = 0x91;
            Transmit(serial);

            //Write_Command(0xCA);
            //Write_Data(0x3F);
            serial.command    = 0xCA;
            serial.dataLength = 1;
            serial.data[0]    = 0x3F;
            Transmit(serial);

            //Write_Command(0xA2);
            //Write_Data(0x00);
            serial.command    = 0xA2;
            serial.dataLength = 1;
            serial.data[0]    = 0x00;
            Transmit(serial);

            //Write_Command(0xA1);
            //Write_Data(0x00);
            serial.command    = 0xA1;
            serial.dataLength = 1;
            serial.data[0]    = 0x00;
            Transmit(serial);

            //Write_Command(0xA0);
            //Write_Data(0x14);
            //Write_Data(0x11);
            serial.command    = 0xA0;
            serial.dataLength = 2;
            serial.data[0]    = 0x14;
            serial.data[1]    = 0x11;
            Transmit(serial);

            //Write_Command(0xB5);
            //Write_Data(0x00);
            serial.command    = 0xB5;
            serial.dataLength = 1;
            serial.data[0]    = 0x00;
            Transmit(serial);

            //Write_Command(0xAB);
            //Write_Data(0x01);
            serial.command    = 0xAB;
            serial.dataLength = 1;
            serial.data[0]    = 0x01;
            Transmit(serial);

            //Write_Command(0xB4);
            //Write_Data(0xA0);
            //Write_Data(0xFD);
            serial.command    = 0xB4;
            serial.dataLength = 2;
            serial.data[0]    = 0xA0;
            serial.data[1]    = 0xFD;
            Transmit(serial);

            //Write_Command(0xC1);
            //Write_Data(0x9F);
            serial.command    = 0xC1;
            serial.dataLength = 1;
            serial.data[0]    = 0x9F;
            Transmit(serial);

            //Write_Command(0xC7);
            //Write_Data(0x0F);
            serial.command    = 0xC7;
            serial.dataLength = 1;
            serial.data[0]    = 0x0F;
            Transmit(serial);

            //Write_Command(0xb8);
            //Write_Data(0x0c);
            //Write_Data(0x18);
            //Write_Data(0x24);
            //Write_Data(0x30);
            //Write_Data(0x3c);
            //Write_Data(0x48);
            //Write_Data(0x54);
            //Write_Data(0x60);
            //Write_Data(0x6c);
            //Write_Data(0x78);
            //Write_Data(0x84);
            //Write_Data(0x90);
            //Write_Data(0x9c);
            //Write_Data(0xa8);
            //Write_Data(0xb4);
            serial.command    = 0xB8;
            serial.dataLength = 15;
            serial.data[0]    = 0x0C;
            serial.data[1]    = 0x18;
            serial.data[2]    = 0x24;
            serial.data[3]    = 0x30;
            serial.data[4]    = 0x3C;
            serial.data[5]    = 0x48;
            serial.data[6]    = 0x54;
            serial.data[7]    = 0x60;
            serial.data[8]    = 0x6C;
            serial.data[9]    = 0x78;
            serial.data[10]   = 0x84;
            serial.data[11]   = 0x90;
            serial.data[12]   = 0x9C;
            serial.data[13]   = 0xA8;
            serial.data[14]   = 0xB4;
            Transmit(serial);

            //Write_Command(0x00);
            serial.command = 0x00;
            Transmit(serial);

            //Write_Command(0xB1);
            //Write_Data(0xE2);
            serial.command    = 0xB1;
            serial.dataLength = 1;
            serial.data[0]    = 0xE2;
            Transmit(serial);

            //Write_Command(0xD1);
            //Write_Data(0x82);
            //Write_Data(0x20);
            serial.command    = 0xD1;
            serial.dataLength = 2;
            serial.data[0]    = 0x82;
            serial.data[0]    = 0x20;
            Transmit(serial);

            //Write_Command(0xBB);
            //Write_Data(0x1F);
            serial.command    = 0xBB;
            serial.dataLength = 1;
            serial.data[0]    = 0x1F;
            Transmit(serial);

            //Write_Command(0xB6);
            //Write_Data(0x08);
            serial.command    = 0xB6;
            serial.dataLength = 1;
            serial.data[0]    = 0x08;
            Transmit(serial);

            //Write_Command(0xBE);
            //Write_Data(0x07);
            serial.command    = 0xBE;
            serial.dataLength = 1;
            serial.data[0]    = 0x07;
            Transmit(serial);

            //Write_Command(0xA6);
            serial.command    = 0xA6;
            serial.dataLength = 0;
            Transmit(serial);

            //Write_Command(0xA9);
            serial.command    = 0xA9;
            serial.dataLength = 0;
            Transmit(serial);

            //Write_Command(0x5C);
            serial.command    = 0x5C;
            serial.dataLength = 0;
            Transmit(serial);

            //Write_Command(0xAF);
            serial.command    = 0xAF;
            serial.dataLength = 0;
            Transmit(serial);
        }
コード例 #7
0
ファイル: _bmpImage.cs プロジェクト: jeidon/fuzzyspoon
        //Public Properties
        //        public BITMAPFILEHEADER bfh;
        //        public BITMAPINFOHEADER bih;

        public int sendImageArray(int bpp)
        {
            PACKET packet         = new PACKET();
            int    arrayProgress  = 0;
            int    arraySize      = sourceImage.Height * sourceImage.Width;
            int    bytesRemaining = arraySize;

            for (int y = 0; y < sourceImage.Height; y++)
            {
                for (int x = 0; x < sourceImage.Width; x++)
                {
                    byte newValue = 0;
                    //byte msb, lsb;
                    System.Drawing.Color pixel = sourceImage.GetPixel(x, y);

                    //if (bpp == 32)
                    //{
                    //    32Bit Easy... done
                    //    fprintf(fDest, "0x%02x, ", alpha);
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtRed);
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtGreen);
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtBlue);
                    //}
                    //else if (bpp == 24)
                    //{
                    //    24Bit
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtRed);
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtGreen);
                    //    fprintf(fDest, "0x%02x, ", pixel.rgbtBlue);
                    //}
                    //else if (bpp == 18)
                    //{
                    //    18Bit
                    //    downConvert18(&pixel, &newPixel);
                    //    fprintf(fDest, "0x%02x, ", newPixel.rgbtRed);
                    //    fprintf(fDest, "0x%02x, ", newPixel.rgbtGreen);
                    //    fprintf(fDest, "0x%02x, ", newPixel.rgbtBlue);
                    //}
                    //else if (bpp == 16)
                    //{
                    //    16Bit
                    //    downConvert16(&pixel, &msb, &lsb);
                    //    fprintf(fDest, "0x%02x, ", msb);
                    //    fprintf(fDest, "0x%02x, ", lsb);
                    //}
                    //else
                    if (bpp == 8)
                    {
                        //8 bit
                        downConvert8(pixel, newValue);
                        packet.data[arrayProgress++] = newValue;
                    }

                    if (arrayProgress == 256)
                    {
                        packet.CD         = 0;
                        packet.dataLength = 255;
                        frmMain.Transmit(packet);
                        arrayProgress   = 0;
                        bytesRemaining -= 255;
                    }
                }
            }
            if (bytesRemaining > 0)
            {
                packet.CD         = 0;
                packet.dataLength = Convert.ToByte(bytesRemaining);
                frmMain.Transmit(packet);
            }
            return(0);
        }