コード例 #1
0
        public void DrawBitmap(int x, int y, VerticalByteBitmap bitmap)
        {
            var rectangle = new VerticalByteRectangle(x, y, bitmap.Width, bitmap.Height);

            this.SendColPagePreamble(rectangle);

            var buffer = bitmap.ShiftLsbToMsb(rectangle.YOffsetStart);

            //for( int index = 0; index < buffer.GetLength( 0 ); index++ ) {
            //	this.SendCommands( buffer[ index ] );
            //}
        }
コード例 #2
0
ファイル: MeadowApp.cs プロジェクト: SupraBitKid/Chicago
        public void ConfigurePorts()
        {
            Console.WriteLine("Creating Outputs...");
            this.redPwm = Device.CreatePwmPort(Device.Pins.OnboardLedRed, pwmFrequency, 0f);
            this.bluPwm = Device.CreatePwmPort(Device.Pins.OnboardLedBlue, pwmFrequency, 0f);
            this.grePwm = Device.CreatePwmPort(Device.Pins.OnboardLedGreen, pwmFrequency, 0f);

            var busForDisplay = Device.CreateI2cBus( ) as I2cBus;

            busForDisplay.Frequency = i2cFrequency;

            Console.WriteLine("I2C bus frequency: {0}", busForDisplay.Frequency);

            this.display = new Ssd1306(busForDisplay, 0x3C, Ssd1306.DisplayType.OLED128x32);
            this.display.SendUGdash2832HSWEG02Startup();
            this.display.InvertDisplay = true;
            this.display.Clear(true);

            this.chicagoFont = new ShikaakwaProportionalFont();
            this.cornerFont  = new CornerProportionalFont();

            var yPosition = 3;

            this.line1     = this.chicagoFont.GetBitmapFromString("Programmed in C#").ShiftLsbToMsb(yPosition);
            this.line1Page = 0;
            yPosition     += this.chicagoFont.Spacing;
            var shiftLineTwo = yPosition % 8;

            this.line2     = this.chicagoFont.GetBitmapFromString("by SupraBitKid").ShiftLsbToMsb(shiftLineTwo);
            this.line2Page = ( byte )(yPosition / 8);

            this.topLeftCorner     = this.cornerFont.GetCharacter('a');
            this.topRightCorner    = this.cornerFont.GetCharacter('b');
            this.bottomLeftCorner  = this.cornerFont.GetCharacter('c');
            this.bottomRightCorner = this.cornerFont.GetCharacter('d');

            this.redColorText   = this.chicagoFont.GetBitmapFromString("red").ShiftLsbToMsb(shiftLineTwo);
            this.greenColorText = this.chicagoFont.GetBitmapFromString("green").ShiftLsbToMsb(shiftLineTwo);
            this.blueColorText  = this.chicagoFont.GetBitmapFromString("blue").ShiftLsbToMsb(shiftLineTwo);

            this.display.Clear(false);
            this.display.DrawBitmap(0, 0, this.topLeftCorner, Ssd1306Extensions.BitmapOp.Or);
            this.display.DrawBitmap(( byte )(this.display.Width - this.topRightCorner.Width), 0, this.topRightCorner, Ssd1306Extensions.BitmapOp.Or);
            this.display.DrawBitmap(0, ( byte )(this.display.GetPageCount() - 1), this.bottomLeftCorner, Ssd1306Extensions.BitmapOp.Or);
            this.display.DrawBitmap(( byte )(this.display.Width - this.bottomRightCorner.Width),
                                    ( byte )(this.display.GetPageCount() - 1), this.bottomRightCorner, Ssd1306Extensions.BitmapOp.Or);
            this.display.DrawBitmap(6, this.line1Page, this.line1, Ssd1306Extensions.BitmapOp.Or);
            this.display.DrawBitmap(6, this.line2Page, this.line2, Ssd1306Extensions.BitmapOp.Or);
            this.display.Show();
        }
コード例 #3
0
        public VerticalByteBitmap GetBitmapFromString(string text)
        {
            var totalWidth = this.GetWidth(text);
            var result     = new VerticalByteBitmap(totalWidth, this.Height);

            var characters        = this.GetAvailableCharacters(text);
            var characterBitmaps  = this.GetCharactersFromString(characters);
            var characterKernings = this.GetKerningsFromString(characters);
            var runningX          = 0;

            for (int index = 0; index < characterBitmaps.Length; index++)
            {
                result.DrawBitmap(runningX, 0, characterBitmaps[index]);
                runningX += characterBitmaps[index].Width + characterKernings[index];
            }

            return(result);
        }
コード例 #4
0
        public static void DrawBitmap(this Ssd1306 display, byte startColumn, byte startPage, VerticalByteBitmap bitmap, BitmapOp bitmapOp)
        {
            var buffer = GetBuffer(display);

            var width = Math.Min(display.Width, startColumn + bitmap.Width);

            var pageHeight = display.Height / 8;

            var pageWidth = display.Width;

            for (int yPage = 0; yPage < bitmap.Rectangle.YByteHeight; yPage++)
            {
                var singlePage = bitmap.Buffer[yPage];

                if (yPage + startPage < pageHeight)
                {
                    for (int xIndex = 0; xIndex < bitmap.Width; xIndex++)
                    {
                        var offset = xIndex + startColumn + ((yPage + startPage) * pageWidth);

                        if (offset < buffer.Length)
                        {
                            switch (bitmapOp)
                            {
                            case BitmapOp.And:
                                buffer[offset] &= singlePage[xIndex];
                                break;

                            case BitmapOp.Or:
                                buffer[offset] |= singlePage[xIndex];
                                break;

                            case BitmapOp.Replace:
                                buffer[offset] = singlePage[xIndex];
                                break;

                            case BitmapOp.Xor:
                                buffer[offset] ^= singlePage[xIndex];
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
ファイル: MeadowApp.cs プロジェクト: SupraBitKid/Chicago
 public void XorDisplayColorText(VerticalByteBitmap colorNameText)
 {
     this.display.DrawBitmap(( byte )(this.display.Width - colorNameText.Width - 1), this.line2Page, colorNameText, Ssd1306Extensions.BitmapOp.Xor);
     this.display.Show();
 }