byte array (Struct)

    • Offizieller Beitrag

    Hallo

    Ich hab mich mal wieder an den G15 kram rangesetzt und versuche jetzt mit der eigentlichen SDK auf das LCD der G15 zuzugreifen.
    Klappt auch super, bis auf das anzeigen eines Bitmaps.
    Hier mal aus der Dokumentation der SDK:

    Spoiler anzeigen
    Zitat
    Code
    typedef struct {
     DWORD Format; 
    } lgLcdBitmapHeader;
    
    
    typedef struct {
     lgLcdBitmapHeader hdr;
     BYTE pixels[LGLCD_BMP_WIDTH*LGLCD_BMP_HEIGHT];
     } lgLcdBitmap160x43x1;

    Format
    Specifies the format of the structure following the header. Currently, only LGLCD_BMP_FORMAT_160x43x1 is supported.
    pixels
    Contains the display bitmap with 160x43 pixels. Every byte represents one pixel, with >=128 being “on” and <128 being “off”.

    Also müsste die Struct so aussehen:

    [autoit]

    $vStructBitmapHeader = DllStructCreate("dword;")
    DllStructSetData($vStructBitmapHeader,1,$LGLCD_BMP_FORMAT_160x43x1)
    $vStructBitmap160x43x1 = DllStructCreate("ptr;byte["&160*43&"]")

    [/autoit][autoit][/autoit][autoit]

    DllStructSetData($vStructBitmap160x43x1,1,DllStructGetPtr($vStructBitmapHeader))
    For $X = 0 To 159
    For $Y = 0 To 42
    DllStructSetData($vStructBitmap160x43x1,2, _Iif(Mod($X+$Y,2) = 0,255,0),(($Y * 160) + $X) + 1)
    Next
    Next

    [/autoit]


    Dll gibt immer "Daten mit diesem Typ werden nicht unterstützt." (bzw 1630) zurück.
    Dll wird so aufgerufen:

    [autoit]

    DllCall($hWrap,"int","lgLcdUpdateBitmap","int",$iDevice,"ptr",DllStructGetPtr($vStructBitmap160x43x1),"dword", BitOR(0x80000000,128)*-1)

    [/autoit]

    Hat jemand eine Idee?

    Mfg Spider

    Edit: Hier nochmal die Doku von dem Aufruf der Funktion:

    Spoiler anzeigen
  • Moin Spider,

    ich bin im Moment ohne AutoIt zu Fuß, aber ändere deine vStructBitmap160x... wie folgt ab:

    [autoit]


    $tag_lgLcdBitmapHeader = 'dword Format;'
    $tag_lgLcdBitmap160x43x1 = $tag_lgLcdBitmapHeader & 'byte pixels['& $LGLCD_BMP_WIDTH*$LGLCD_BMP_HEIGHT&'];'

    [/autoit][autoit][/autoit][autoit]

    $st_lgLcdBitmap160x43x1 = DllStructCreate ($tag_lgLcdBitmap160x43x1)

    [/autoit]
    Code
    typedef struct {
     DWORD Format; 
    } lgLcdBitmapHeader;
    
    
    typedef struct {
     lgLcdBitmapHeader hdr; // Dieses Strukturmitglied besteht aus dem Datentyp lgLcdBitmapHeader, kein Zeiger auf diesen.
     BYTE pixels[LGLCD_BMP_WIDTH*LGLCD_BMP_HEIGHT];
     } lgLcdBitmap160x43x1;


    EDIT
    Noch was gefunden, wenn ich mich nicht irre ...

    Spoiler anzeigen
    [autoit]

    $tag_lgLcdBitmapHeader = 'dword Format;'
    $tag_lgLcdBitmap160x43x1 = $tag_lgLcdBitmapHeader & 'byte pixels['& $LGLCD_BMP_WIDTH*$LGLCD_BMP_HEIGHT&'];'

    [/autoit] [autoit][/autoit] [autoit]

    $st_lgLcdBitmap160x43x1 = DllStructCreate ($tag_lgLcdBitmap160x43x1)

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData ($vStructBitmap160x43x1, 'Format', $LGLCD_BMP_FORMAT_160x43x1)

    [/autoit] [autoit][/autoit] [autoit]

    For $Y = 0 To 42
    For $X = 1 To 160
    DllStructSetData ($vStructBitmap160x43x1, 'pixels', _
    _Iif(Mod($X+$Y,2) = 0,255,0), ($Y * 160) + $X)
    Next
    Next

    [/autoit]

    Gruß
    Greenhorn


    2 Mal editiert, zuletzt von Greenhorn (25. Dezember 2008 um 22:09)