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