Display.cs
author sl
Mon, 07 Jul 2014 22:29:26 +0200
changeset 4 0825370a7947
parent 3 71b55cfd8c05
child 6 70b26a1ae93b
permissions -rw-r--r--
Display is now updated as labels are scrolling.
sl@3
     1
using System;
sl@3
     2
using System.Collections.Generic;
sl@3
     3
using System.Linq;
sl@3
     4
using System.Text;
sl@3
     5
using System.Threading.Tasks;
sl@3
     6
//
sl@3
     7
using System.Runtime.InteropServices;
sl@3
     8
using System.Text;
sl@3
     9
sl@3
    10
namespace SharpDisplayManager
sl@3
    11
{
sl@3
    12
    class Display
sl@3
    13
    {
sl@3
    14
sl@3
    15
        //Constructor
sl@3
    16
        public Display()
sl@3
    17
        {
sl@3
    18
            iDevice = IntPtr.Zero;
sl@3
    19
        }
sl@3
    20
sl@3
    21
        //
sl@3
    22
        public bool Open()
sl@3
    23
        {
sl@3
    24
            if (iDevice == IntPtr.Zero)
sl@3
    25
            {
sl@3
    26
                iDevice = MiniDisplayOpen();                
sl@3
    27
            }
sl@3
    28
            return iDevice != IntPtr.Zero;
sl@3
    29
        }
sl@3
    30
sl@3
    31
        public void Close()
sl@3
    32
        {
sl@3
    33
            MiniDisplayClose(iDevice);
sl@3
    34
            iDevice = IntPtr.Zero;
sl@3
    35
        }
sl@3
    36
sl@3
    37
        public bool IsOpen()
sl@3
    38
        {
sl@3
    39
            return iDevice != IntPtr.Zero;
sl@3
    40
        }
sl@3
    41
sl@3
    42
        public void Clear()
sl@3
    43
        {
sl@3
    44
            MiniDisplayClear(iDevice);
sl@3
    45
        }
sl@3
    46
sl@3
    47
        public void Fill()
sl@3
    48
        {
sl@3
    49
            MiniDisplayFill(iDevice);
sl@3
    50
        }
sl@3
    51
sl@3
    52
        public void SwapBuffers()
sl@3
    53
        {
sl@3
    54
            MiniDisplaySwapBuffers(iDevice);
sl@3
    55
        }
sl@3
    56
sl@3
    57
        public int MaxBrightness()
sl@3
    58
        {
sl@3
    59
            return MiniDisplayMaxBrightness(iDevice);
sl@3
    60
        }
sl@3
    61
sl@3
    62
        public int MinBrightness()
sl@3
    63
        {
sl@3
    64
            return MiniDisplayMinBrightness(iDevice);
sl@3
    65
        }
sl@3
    66
sl@3
    67
        public void SetBrightness(int aBrightness)
sl@3
    68
        {
sl@3
    69
            if (!IsOpen()) return;
sl@3
    70
sl@3
    71
            MiniDisplaySetBrightness(iDevice, aBrightness);
sl@3
    72
        }
sl@3
    73
sl@4
    74
        public int WidthInPixels()
sl@4
    75
        {
sl@4
    76
            return MiniDisplayWidthInPixels(iDevice);
sl@4
    77
        }
sl@4
    78
sl@4
    79
        public int HeightInPixels()
sl@4
    80
        {
sl@4
    81
            return MiniDisplayHeightInPixels(iDevice);
sl@4
    82
        }
sl@4
    83
sl@4
    84
        public void SetPixel(int aX, int aY, int aValue)
sl@4
    85
        {
sl@4
    86
            MiniDisplaySetPixel(iDevice,aX,aY,aValue);
sl@4
    87
        }
sl@4
    88
sl@4
    89
sl@4
    90
sl@3
    91
        //Our display device handle
sl@3
    92
        IntPtr iDevice;
sl@3
    93
sl@3
    94
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
    95
        public static extern IntPtr MiniDisplayOpen();
sl@3
    96
sl@3
    97
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
    98
        public static extern void MiniDisplayClose(IntPtr aDevice);
sl@3
    99
sl@3
   100
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   101
        public static extern void MiniDisplayClear(IntPtr aDevice);
sl@3
   102
sl@3
   103
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   104
        public static extern void MiniDisplayFill(IntPtr aDevice);
sl@3
   105
sl@3
   106
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   107
        public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
sl@3
   108
sl@3
   109
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   110
        public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
sl@3
   111
sl@3
   112
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   113
        public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
sl@3
   114
sl@3
   115
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@3
   116
        public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
sl@3
   117
sl@4
   118
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@4
   119
        public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
sl@4
   120
sl@4
   121
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@4
   122
        public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
sl@4
   123
sl@4
   124
        [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
sl@4
   125
        public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
sl@4
   126
sl@3
   127
sl@3
   128
    }
sl@3
   129
}