G15 LCD ansteuern

  • VB.NET

Es gibt 8 Antworten in diesem Thema. Der letzte Beitrag () ist von Fynnl.

    G15 LCD ansteuern

    Hey Leute,
    kennt jemand die Tastatur G15 von Logitech?
    Naja, ich besitze eine und ich wollte mal fragen ob jemand einen VB code kennt womit man das LCD Bildschirm der Tastatur einsteuert und Grafiken und Text und sowas ausgeben kann. :huh:

    Andy1253 schrieb:

    Aus den ganzen Links werde ich nicht schlau. :huh:
    Hälfte funzt nicht und die andere Hälfte ist entweder beschädigt oder die Codes gehen nicht :|


    Ich hoffe es wird mir niemand übel nehmen, dass ich dieses alte Thema wieder aus den tiefen des Forum befreit habe. Aber es trifft einfach genau meine Anliegen :rolleyes:

    Meine Frage ist, wie ich Text auf dem Display anzeigen lassen kann. Mein bisheriger Code schafft dies leider nicht :(
    Spoiler anzeigen

    VB.NET-Quellcode

    1. 'LCD
    2. Dim Text As String = "Test"
    3. Dim FontColor As Color = Color.White
    4. Dim BackColor As Color = Color.Black
    5. Dim FontName As String = "Times New Roman"
    6. Dim FontSize As Integer = 12
    7. Dim Height As Integer = 43
    8. Dim Width As Integer = 160
    9. Dim FileName As String = "LCD"
    10. Dim objBitmap As New Bitmap(Width, Height)
    11. Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
    12. Dim objColor As Color
    13. Dim objFont As New Font(FontName, FontSize)
    14. 'Following PointF object defines where the text will be displayed in the
    15. 'specified area of the image
    16. Dim objPoint As New PointF(5.0F, 5.0F)
    17. Dim objBrushForeColor As New SolidBrush(FontColor)
    18. Dim objBrushBackColor As New SolidBrush(BackColor)
    19. Dim pic_array(6880) As Byte
    20. Public Sub Draw()
    21. objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, Height)
    22. objGraphics.DrawString(Text, objFont, objBrushForeColor, objPoint)
    23. Pic.Image = objBitmap
    24. pic_array = ConvertBitmapToByte(objBitmap)
    25. For i As Integer = 0 To 6879 '255 = Pixel an, 0 = aus, alles was dazwischen liegt wird zum Testen mal angeschaltet
    26. If pic_array(i) < 254 And pic_array(i) <> 0 Then
    27. pic_array(i) = 255
    28. End If
    29. Next
    30. End Sub
    31. ''' <summary>
    32. ''' Konvertiert Bitmap in Byte-Array
    33. ''' </summery>
    34. ''' <param name="text"></param>
    35. Private Function ConvertBitmapToByte(ByVal bild As Bitmap) As Byte()
    36. Dim membit As New IO.MemoryStream
    37. bild.Save(membit, Imaging.ImageFormat.Bmp)
    38. Return membit.ToArray
    39. End Function


    Leider bin ich nicht in der Lage den Fehler zu finden. Entweder liegt er beim konvertieren des Bitmaps zum Byte-Array oder in der Graphics Abteilung. Gibt es irgendwo ein VB.Net Beispiel mit dem man Text auf das Display schreiben kann? Ich habe bisher nur das hier in Vb6 (oder was auch immer das sein mag) gefunden:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. VERSION 5.00
    2. Begin VB.Form frmTest
    3. Caption = "LCD Demo"
    4. ClientHeight = 1380
    5. ClientLeft = 60
    6. ClientTop = 345
    7. ClientWidth = 2505
    8. LinkTopic = "Form1"
    9. ScaleHeight = 92
    10. ScaleMode = 3 'Pixel
    11. ScaleWidth = 167
    12. StartUpPosition = 2 'CenterScreen
    13. Begin VB.CommandButton Command2
    14. Caption = "Fast Demo"
    15. Height = 555
    16. Left = 1320
    17. TabIndex = 2
    18. Top = 780
    19. Width = 1155
    20. End
    21. Begin VB.CommandButton Command1
    22. Caption = "Slow Demo"
    23. Height = 555
    24. Left = 60
    25. TabIndex = 1
    26. Top = 780
    27. Width = 1215
    28. End
    29. Begin VB.PictureBox LCD
    30. AutoRedraw = -1 'True
    31. BackColor = &H00000000&
    32. BorderStyle = 0 'None
    33. FillColor = &H00FFFFFF&
    34. BeginProperty Font
    35. Name = "Small Fonts"
    36. Size = 6
    37. Charset = 0
    38. Weight = 400
    39. Underline = 0 'False
    40. Italic = 0 'False
    41. Strikethrough = 0 'False
    42. EndProperty
    43. ForeColor = &H00FFFFFF&
    44. Height = 645
    45. Left = 60
    46. ScaleHeight = 43
    47. ScaleMode = 3 'Pixel
    48. ScaleWidth = 160
    49. TabIndex = 0
    50. Top = 60
    51. Width = 2400
    52. End
    53. End
    54. Attribute VB_Name = "frmTest"
    55. Attribute VB_GlobalNameSpace = False
    56. Attribute VB_Creatable = False
    57. Attribute VB_PredeclaredId = True
    58. Attribute VB_Exposed = False
    59. Private Sub Command1_Click()
    60. ' Create an array of 6880 bytes
    61. Dim byteArrayDemo(0 To 6879) As Byte
    62. ' Turn on every second pixel, to create a checkerboard pattern.
    63. ' Set the value to 255 to make it ON, or 0 to make it OFF.
    64. ' Loop through the entire screen.
    65. For X = 0 To 159
    66. For Y = 0 To 42
    67. byteArrayDemo((Y * 160) + X) = IIf((X + Y) Mod 2 = 0, 255, 0)
    68. Next
    69. Next
    70. lcdControl.showPixels byteArrayDemo, 0
    71. End Sub
    72. Private Sub Command2_Click()
    73. ' Clear the picturebox and then write some text onto it.
    74. LCD.Cls
    75. LCD.Print "This is a fast demo."
    76. LCD.Print "The current time is " & Time
    77. ' Update the LCD.
    78. updatePreview
    79. End Sub
    80. Private Sub Form_Load()
    81. ' Create a new instance of the AvLCD component
    82. Set lcdControl = New AvLCD
    83. ' Initialize the LCD.
    84. lcdControl.initLCD "AvLCD Demo File"
    85. ' Set a callback to our ButtonPress Handler.
    86. lcdControl.setCallback AddressOf LCDbuttonPress
    87. End Sub
    88. Private Sub Form_Unload(Cancel As Integer)
    89. ' When unloading, close the LCD interface.
    90. lcdControl.closeLCD
    91. End Sub


    In diesem Beispiel wird einfach "auf die Picturebox geschrieben". Mit VB.Net ist das meines Wissens nach nicht mehr möglich. Deswegen muss ich ja auf die Graphics Klassen ausweichen.

    Also wenn mir wirklich jemand helfen könnte wäre ich dem wirklich sehr dankbar!

    Fynnl
    g15-applets.de/extendedg15wrap…tc-g15-wrapper-t5254.html

    VB.NET-Quellcode

    1. ' Wrapper instanzieren
    2. Dim LCD as New extendedg15wrapper("AppName", False) 'Autostart aus
    3. Dim LCDButtons As New g15ButtonEvents
    4. 'Bitmap erstellen
    5. Dim b As New Bitmap(160, 43) 'Hier dann mit GDI zeichnen
    6. 'Bitmap an LCD senden
    7. LCD.SetBitmap(b)
    8. 'Für die Buttons zb.
    9. AddHandler LCDButtons.Button1Down, New g15ButtonEvents.Buttons(Address Of TuWasBeiButton1)