Skip to content

Instantly share code, notes, and snippets.

@osvein
Last active August 29, 2015 14:08
Show Gist options
  • Save osvein/63efc2cd74b963aa2d63 to your computer and use it in GitHub Desktop.
Save osvein/63efc2cd74b963aa2d63 to your computer and use it in GitHub Desktop.
Logitech LCD SDK imported from unmanaged dynamic-link library to managed .NET in C#
using System;
using System.Runtime.InteropServices;
public static class LogiLCDImport
{
public static const int MonochromeLCDWidth = 160;
public static const int MonochromeLCDHeight = 43;
public static const int ColorLCDWidth = 320;
public static const int ColorLCDHeight = 240;
[Flags]
public enum LCDType
{
Monochrome = 0x00000001,
Color = 0x00000002
}
[Flags]
public enum LCDButton
{
Monochrome0 = 0x00000001,
Monochrome1 = 0x00000002,
Monochrome2 = 0x00000004,
Monochrome3 = 0x00000008,
ColorLeft = 0x00000100,
ColorRight = 0x00000200,
ColorOK = 0x00000400,
ColorCancel = 0x00000800,
ColorUp = 0x00001000,
ColorDown = 0x00002000,
ColorMenu = 0x00004000
}
#region Generic LCD functions
[DllImport("LogitechLcd.dll")]
public static extern bool LogiLcdInit(string friendlyName, LCDType lcdType);
[DllImport("LogitechLcd.dll")]
bool LogiLcdIsConnected(LCDType lcdType);
[DllImport("LogitechLcd.dll")]
bool LogiLcdIsButtonPressed(LCDButton button);
[DllImport("LogitechLcd.dll")]
void LogiLcdUpdate();
[DllImport("LogitechLcd.dll")]
void LogiLcdShutdown();
#endregion
#region Monochrome LCD functions
[DllImport("LogitechLcd.dll")]
bool LogiLcdMonoSetBackground(byte[] monoBitmap);
[DllImport("LogitechLcd.dll")]
bool LogiLcdMonoSetText(int lineNumber, string text);
#endregion
#region Color LCD functions
[DllImport("LogitechLcd.dll")]
bool LogiLcdColorSetBackground(byte[] colorBitmap);
[DllImport("LogitechLcd.dll")]
bool LogiLcdColorSetTitle(string text, int red = 255, int green = 255, int blue = 255);
[DllImport("LogitechLcd.dll")]
bool LogiLcdColorSetText(int lineNumber, string text, int red = 255, int green = 255, int blue = 255);
#endregion
#region UDK functions, use this only if working with UDK
[DllImport("LogitechLcd.dll")]
int LogiLcdColorSetBackgroundUDK(byte[] partialBitmap, int arraySize);
[DllImport("LogitechLcd.dll")]
int LogiLcdColorResetBackgroundUDK();
[DllImport("LogitechLcd.dll")]
int LogiLcdMonoSetBackgroundUDK(byte[] partialBitmap, int arraySize);
[DllImport("LogitechLcd.dll")]
int LogiLcdMonoResetBackgroundUDK();
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment