示例#1
0
        public LedMatrix(LedMatrixOptions options = null, string[] arguments = null)
        {
            options = options ?? new LedMatrixOptions();
            var opt = new NativeLedMatrixOptions(options);

            try
            {
                var nativeArguments = arguments.ConvertToNativeArguments(options);

                _matrix = RpiRgbLedMatrix.led_matrix_create_from_options_const_argv(ref opt, nativeArguments.Length, nativeArguments);
            }
            finally
            {
                if (options.HardwareMapping != null)
                {
                    opt.Free(ref opt.hardware_mapping);
                }
                if (options.LedRgbSequence != null)
                {
                    opt.Free(ref opt.led_rgb_sequence);
                }
                if (options.PixelMapperConfig != null)
                {
                    opt.Free(ref opt.pixel_mapper_config);
                }
                if (options.PanelType != null)
                {
                    opt.Free(ref opt.panel_type);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of a <see cref="BdfFont" />.
        /// </summary>
        /// <param name="bdfFontFile">A path to a bdf font file.</param>
        public BdfFont(string bdfFontFile)
        {
            if (String.IsNullOrEmpty(bdfFontFile))
            {
                throw new ArgumentNullException(nameof(bdfFontFile));
            }

            if (!File.Exists(bdfFontFile))
            {
                // try local folder as an alternative
                var alternateFontPath = Path.Combine(
                    Path.GetDirectoryName(GetType().Assembly.Location),
                    Path.GetFileName(bdfFontFile)
                    );

                if (!File.Exists(alternateFontPath))
                {
                    throw new ArgumentException($"The provided file '{bdfFontFile}' needs to exist.");
                }

                bdfFontFile = alternateFontPath;
            }

            _font = RpiRgbLedMatrix.load_font(bdfFontFile);
        }
示例#3
0
        internal Canvas(IntPtr canvas)
        {
            if (canvas == null || canvas == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(canvas));
            }

            _canvas = canvas;
            RpiRgbLedMatrix.led_canvas_get_size(_canvas, out int width, out int height);

            Width  = width;
            Height = height;
        }
示例#4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                }

                RpiRgbLedMatrix.led_matrix_delete(_matrix);
                _matrix = IntPtr.Zero;

                disposedValue = true;
            }
        }
示例#5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                }

                RpiRgbLedMatrix.delete_font(_font);
                _font = IntPtr.Zero;

                disposedValue = true;
            }
        }
示例#6
0
 public void DrawLine(int x0, int y0, int x1, int y1, Color color)
 {
     RpiRgbLedMatrix.draw_line(_canvas, x0, y0, x1, y1, color.Red, color.Green, color.Blue);
 }
示例#7
0
 public void DrawCircle(int x, int y, int radius, Color color)
 {
     RpiRgbLedMatrix.draw_circle(_canvas, x, y, radius, color.Red, color.Green, color.Blue);
 }
示例#8
0
 public void Clear()
 {
     RpiRgbLedMatrix.led_canvas_clear(_canvas);
 }
示例#9
0
 public void Fill(Color color)
 {
     RpiRgbLedMatrix.led_canvas_fill(_canvas, color.Red, color.Green, color.Blue);
 }
示例#10
0
 public void SetImage(int xOffset, int yOffset, byte[] imageBuffer, int bufferSizeBytes, int imageWidth, int imageHeight, bool isBgr)
 {
     RpiRgbLedMatrix.set_image(_canvas, xOffset, yOffset, imageBuffer, bufferSizeBytes, imageWidth, imageHeight, isBgr);
 }
示例#11
0
 public void SetPixel(int x, int y, Color color)
 {
     RpiRgbLedMatrix.led_canvas_set_pixel(_canvas, x, y, color.Red, color.Green, color.Blue);
 }
示例#12
0
 public Canvas SwapOnVsync(Canvas canvas)
 {
     canvas._canvas = RpiRgbLedMatrix.led_matrix_swap_on_vsync(_matrix, canvas._canvas);
     return(canvas);
 }
示例#13
0
        public Canvas GetCanvas()
        {
            var canvas = RpiRgbLedMatrix.led_matrix_get_canvas(_matrix);

            return(new Canvas(canvas));
        }
示例#14
0
        public Canvas CreateOffscreenCanvas()
        {
            var canvas = RpiRgbLedMatrix.led_matrix_create_offscreen_canvas(_matrix);

            return(new Canvas(canvas));
        }
示例#15
0
 internal int DrawText(IntPtr canvas, int x, int y, Color color, string text, int spacing = 0, bool vertical = false)
 {
     return((vertical)
                         ? RpiRgbLedMatrix.vertical_draw_text(canvas, _font, x, y, color.Red, color.Green, color.Blue, text, spacing)
                         : RpiRgbLedMatrix.draw_text(canvas, _font, x, y, color.Red, color.Green, color.Blue, text, spacing));
 }