Aktuelle Zeit: 18.10.2017 23:51

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: VFD Display über USB ansteuern
BeitragVerfasst: 17.04.2014 19:48 
Offline
Benutzeravatar

Registriert: 23.07.2011 02:08
Hallo

Ich habe hier ein VFD Display, und zwar dieses hübsche Teil
http://www.eisgold.de/Futaba-MDM166A-US ... _2732.html
Bild

Die Ansteuerung mit LCD Hype funktioniert (auch wenn dieses Scriptformat noch ein wenig Einarbeitung braucht).
Allerdings würde ich das Display gerne direkt mit PB ansteuern.

Es liegt eine DLL bei, welche wohl als Plugin für LCD Hype dient. Leider keine Dokumentation.
PureDLLHelper zeigt mir folgende Funktionen an, welche sich von den übrigen Plugins die LCD Hype schon mitbringt unterscheiden.

Code:
PrototypeC SendSymbol()
PrototypeC SendBitmap()
PrototypeC SendText()
PrototypeC SendCommand()
PrototypeC SendCustomChar()
PrototypeC CleanUp()
PrototypeC Init()
PrototypeC SetProperty()
PrototypeC GetProperty()


zB. Alphacool USB Display DLL
Code:
Prototype  LCD_ConfigDialog()
Prototype  LCD_SendToController(a)
Prototype  LCD_SendToMemory(a)
Prototype  LCD_SendToGfxMemory(a, b, c, d, e, f)
Prototype  LCD_SetOutputAddress(a, b)
Prototype  LCD_SetCGRAMChar(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q)
Prototype  LCD_GetCGRAMChar(a)
Prototype  LCD_Init()
Prototype  LCD_CleanUp()
Prototype  LCD_IsReadyToReceive()
Prototype  LCD_SetIOPropertys(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
Prototype  LCD_Customize(a, b, c, d, e)
Prototype  DLL_GetInfo(a)
Prototype  ___CPPdebugHook()



Es liegt aber auch ein PDF bei, welches das Protokoll beschreibt. Und ein kleines Programm, dass die Uhrzeit, Lautstärke und evtl. laufende Musik auf dem Display anzeigen kann. Es scheint ohne dll auszukommen.

Laut Protokollbeschreibung erwartet das Display Datenblöcke von max. 64 bytes, wovon das erste byte die Länge des nachfolgenden Blocks angibt, welcher die Befehle enthält.

Aber wie sende ich die Befehle an das Display?

Das Display wird angeblich als HID erkannt und benötigt keine weiteren Treiber.

_________________
Signatur und so


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 17.04.2014 20:38 
Offline
Benutzeravatar

Registriert: 08.03.2013 14:27
Wohnort: ERB
Ich selber habe da keine Erfahrung mit. Aber als ich Linux und lcdproc gelesen habe war klar, das es auch einen Sourcecode gibt, in dem es stehen muss.

Schau mal in den LCDProc-Source. Vielleicht hilft dir das weiter. Docbook's liegen auch dabei ;)

http://lcdproc.omnipotent.net/download.php3

Dev-Doc's: http://lcdproc.sourceforge.net/docs/lcd ... 5-dev.html

_________________
PBExpress
Lightweight PureBasic FastCGI Framework

Github: https://github.com/reVerBxTc/PBExpress
Wiki: https://github.com/reVerBxTc/PBExpress/wiki


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 16.07.2017 23:29 
Offline
Benutzeravatar

Registriert: 03.01.2016 14:55
Hey Zusammen,

ich hab hier auch so ein Display. Hab es zwar mit Python zum laufen gebracht wo bei ich von Python noch weniger Ahnung hab als von PB :).
Aber jetzt würde ich das gern mit PB machen.
Da zu hab ich mir ein HID Module besorgt mit dem ich auch die Infos auslesen kann aber es werden keine Daten an das Display gesendet.

Und so sieht der erste klägliche Versuch aus:
Code:
EnableExplicit

Global ln = 64
Global Display
Global *buffer


DeclareModule HID

;-DeclareModule

Structure HID_CAPS
  Usage.w
  UsagePage.w
  InputReportByteLength.w
  OutputReportByteLength.w
  FeatureReportByteLength.w
  Reserved.w[17]
  NumberLinkCollectionNodes.w
  NumberInputButtonCaps.w
  NumberInputValueCaps.w
  NumberInputDataIndices.w
  NumberOutputButtonCaps.w
  NumberOutputValueCaps.w
  NumberOutputDataIndices.w
  NumberFeatureButtonCaps.w
  NumberFeatureValueCaps.w
  NumberFeatureDataIndices.w
EndStructure

Structure HID_Sub_DeviceInfo
  VendorID.u
  ProductID.u
  VersionNumber.u
  NumInputBuffers.u
  InputReportByteLength.u
  OutputReportByteLength.u
  FeatureReportByteLength.u
  Manufacturer.s
  Product.s
  SerialNumber.s
EndStructure

Structure HID_DeviceInfo
  CountDevice.w              ; Число обнаруженных HID устройств
  DeviceInfo.HID_Sub_DeviceInfo[258]
EndStructure


Structure HID_Attributes
  VID.u
  PID.u
  VersionNumber.u
EndStructure

Declare HID_Init()
Declare HID_End()
Declare OpenDevice(PID.u, VID.u, VersionNumber.w=-1, Index.u=0)
Declare CloseDevice(hDevice)
Declare TestDevice(PID.u, VID.u, VersionNumber.w=-1, Index.u=0)
Declare DeviceInfo(*Info.HID_DeviceInfo)
Declare ReadDevice(hDevice, *Buffer, Len)
Declare WriteDevice(hDevice, *Buffer, Len)
Declare GetFeature(hDevice, *Buffer, Len)
Declare SetFeature(hDevice, *Buffer, Len)
Declare GetInputReport(hDevice, *Buffer, Len)
Declare SetOutputReport(hDevice, *Buffer, Len)
Declare GetCaps(hDevice, *Capabilities.HID_CAPS)
 ; Узнаём по хендлу устройства, его PID, VID и номер версии.
Declare GetAttributes(hDevice, *DeviceInfo.HID_Attributes)
Declare GetNumInputBuffers(hDevice)
Declare.s GetManufacturerString(hDevice)
Declare.s GetProductString(hDevice)
Declare.s GetSerialNumberString(hDevice)
Declare.s GetIndexedString(hDevice, Index)

EndDeclareModule

Module HID


Structure HIDD_ATTRIBUTES
  Size.l
  VendorID.u
  ProductID.u
  VersionNumber.w
EndStructure

Structure PSP_DEVICE_INTERFACE_DETAIL_DATA
  cbSize.l
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
    DevicePath.l
  CompilerElse
    DevicePath.c
  CompilerEndIf
EndStructure

CompilerIf Defined(SP_DEVICE_INTERFACE_DATA, #PB_Structure)=0
  Structure SP_DEVICE_INTERFACE_DATA
    cbSize.l
    InterfaceClassGuid.GUID
    Flags.l
    Reserved.l
  EndStructure
CompilerEndIf

EnableExplicit

Prototype pGetHidGuid(*HidGuid.GUID)
Prototype pGetAttributes(*HidDeviceObject, *Attributes.HIDD_ATTRIBUTES)
Prototype pGetPreparsedData(*HidDeviceObject, *PreparsedData)
Prototype pGetCaps(*PreparsedData, *Capabilities.HID_CAPS)
Prototype pFreePreparsedData(PreparsedData)
Prototype pGetNumInputBuffers(HidHandle, *NumInputBuffers)
Prototype pGetManufacturerString(HidHandle, *Buffer, Len)
Prototype pGetProductString(HidHandle, *Buffer, Len)
Prototype pGetSerialNumberString(HidHandle, *Buffer, Len)
Prototype pGetIndexedString(HidHandle, Index, *Buffer, Len)
Prototype pGetFeature(HidHandle, *Buffer, Len)
Prototype pSetFeature(HidHandle, *Buffer, Len)
Prototype pGetInputReport(HidHandle, *Buffer, Len)
Prototype pSetOutputReport(HidHandle, *Buffer, Len)
Prototype pSetupDiEnumDeviceInterfaces(*DeviceInfoSet, DeviceInfoData, *InterfaceClassGuid.GUID, MemberIndex, *DeviceInterfaceData.SP_DEVICE_INTERFACE_DATA)
Prototype pSetupDiGetDeviceInterfaceDetail(*DeviceInfoSet, *DeviceInterfaceData.SP_DEVICE_INTERFACE_DATA, DeviceInterfaceDetailData, DeviceInterfaceDetailDataSize, *RequiredSize, *DeviceInfoData)

Define hid_Lib, Setupapi_Lib, OS_Version

Procedure HID_Init()
  Shared hid_Lib, Setupapi_Lib, OS_Version
 
  OS_Version = OSVersion()
 
  hid_Lib=LoadLibrary_("hid.dll")
  Setupapi_Lib=LoadLibrary_("setupapi.dll")
 
  Global fGetHidGuid.pGetHidGuid=GetProcAddress_(hid_Lib, ?GetHidGuid)
  Global fGetAttributes.pGetAttributes=GetProcAddress_(hid_Lib, ?GetAttributes)
  Global fGetPreparsedData.pGetPreparsedData=GetProcAddress_(hid_Lib, ?GetPreparsedData)
  Global fFreePreparsedData.pFreePreparsedData=GetProcAddress_(hid_Lib, ?FreePreparsedData)
  Global fGetCaps.pGetCaps=GetProcAddress_(hid_Lib, ?GetCaps)
  Global fGetInputReport.pGetInputReport=GetProcAddress_(hid_Lib, ?GetInputReport)
  Global fSetOutputReport.pSetOutputReport=GetProcAddress_(hid_Lib, ?SetOutputReport)
  Global fGetFeature.pGetFeature=GetProcAddress_(hid_Lib, ?GetFeature)
  Global fSetFeature.pSetFeature=GetProcAddress_(hid_Lib, ?SetFeature)
  Global fGetNumInputBuffers.pGetNumInputBuffers=GetProcAddress_(hid_Lib, ?GetNumInputBuffers)
  Global fGetManufacturerString.pGetManufacturerString=GetProcAddress_(hid_Lib, ?GetManufacturerString)
  Global fGetProductString.pGetProductString=GetProcAddress_(hid_Lib, ?GetProductString)
  Global fGetSerialNumberString.pGetSerialNumberString=GetProcAddress_(hid_Lib, ?GetSerialNumberString)
  Global fGetIndexedString.pGetIndexedString=GetProcAddress_(hid_Lib, ?GetIndexedString)
  Global fSetupDiEnumDeviceInterfaces.pSetupDiEnumDeviceInterfaces=GetProcAddress_(Setupapi_Lib, ?SetupDiEnumDeviceInterfaces)
  Global fSetupDiGetDeviceInterfaceDetail.pSetupDiGetDeviceInterfaceDetail=GetProcAddress_(Setupapi_Lib, ?Setup_InterfaceDetail)
 
  DataSection
   
    GetHidGuid:
    ! db "HidD_GetHidGuid", 0, 0
   
    GetAttributes:
    ! db "HidD_GetAttributes", 0, 0
   
    GetPreparsedData:
    ! db "HidD_GetPreparsedData", 0, 0
   
    FreePreparsedData:
    ! db "HidD_FreePreparsedData", 0, 0
   
    GetCaps:
    ! db "HidP_GetCaps", 0, 0
   
    GetInputReport:
    ! db "HidD_GetInputReport", 0, 0
   
    SetOutputReport:
    ! db "HidD_SetOutputReport", 0, 0
   
    GetFeature:
    ! db "HidD_GetFeature", 0, 0
   
    SetFeature:
    ! db "HidD_SetFeature", 0, 0
   
    GetNumInputBuffers:
    ! db "HidD_GetNumInputBuffers", 0, 0
   
    GetManufacturerString:
    ! db "HidD_GetManufacturerString", 0, 0
   
    GetProductString:
    ! db "HidD_GetProductString", 0, 0
   
    GetSerialNumberString:
    ! db "HidD_GetSerialNumberString", 0, 0
   
    GetIndexedString:
    ! db "HidD_GetIndexedString", 0, 0
   
    SetupDiEnumDeviceInterfaces:
    ! db "SetupDiEnumDeviceInterfaces", 0, 0
   
    Setup_InterfaceDetail:
    CompilerIf #PB_Compiler_Unicode=0
      ! db "SetupDiGetDeviceInterfaceDetailA", 0, 0
    CompilerElse
      ! db "SetupDiGetDeviceInterfaceDetailW", 0, 0
    CompilerEndIf
   
  EndDataSection
 
EndProcedure

Procedure HID_End()
  Shared hid_Lib, Setupapi_Lib
  If hid_Lib
    FreeLibrary_(hid_Lib)
  EndIf
  If Setupapi_Lib
    FreeLibrary_(Setupapi_Lib)
  EndIf
EndProcedure

Procedure FunctInfo(hDevice, *Info.HID_DeviceInfo)
  Protected Attributes.HIDD_ATTRIBUTES, i
  Protected HIDP_CAPS.HID_CAPS
   
  Attributes\Size = SizeOf(HIDD_ATTRIBUTES)
 
  If fGetAttributes(hDevice, @Attributes)
   
    i = *Info\CountDevice
    *Info\CountDevice+1
   
    *Info\DeviceInfo[i]\VendorID        = Attributes\VendorID
    *Info\DeviceInfo[i]\ProductID       = Attributes\ProductID
    *Info\DeviceInfo[i]\VersionNumber   = Attributes\VersionNumber
   
    *Info\DeviceInfo[i]\Manufacturer    = GetManufacturerString(hDevice)
    *Info\DeviceInfo[i]\Product         = GetProductString(hDevice)
    *Info\DeviceInfo[i]\SerialNumber    = GetSerialNumberString(hDevice)
    *Info\DeviceInfo[i]\NumInputBuffers = GetNumInputBuffers(hDevice)
    GetCaps(hDevice, @HIDP_CAPS)
    *Info\DeviceInfo[i]\InputReportByteLength   = HIDP_CAPS\InputReportByteLength
    *Info\DeviceInfo[i]\OutputReportByteLength  = HIDP_CAPS\OutputReportByteLength
    *Info\DeviceInfo[i]\FeatureReportByteLength = HIDP_CAPS\FeatureReportByteLength
   
  EndIf
 
EndProcedure

Procedure Open_HID_Device(PID.u, VID.u, VersionNumber.w=-1, Index.u=0, *Funct=0, *Info.HID_DeviceInfo=0)
  Protected HidGuid.Guid
  Protected devInfoData.SP_DEVICE_INTERFACE_DATA
  Protected Attributes.HIDD_ATTRIBUTES, Security.SECURITY_ATTRIBUTES
  Protected *detailData.PSP_DEVICE_INTERFACE_DETAIL_DATA
  Protected Length.l, CurrentIndex.w, hDevInfo
  Protected i, Result, DevicePath.s
  Protected Required, hDevice
 
  If fGetHidGuid=0 Or fSetupDiEnumDeviceInterfaces=0 Or
     fSetupDiGetDeviceInterfaceDetail=0 Or fGetAttributes=0
    ProcedureReturn 0
  EndIf
 
  devInfoData\cbSize = SizeOf(SP_DEVICE_INTERFACE_DATA)
 
  Security\nLength=SizeOf(SECURITY_ATTRIBUTES)
  Security\bInheritHandle=1
  Security\lpSecurityDescriptor = 0
 
  fGetHidGuid(@HidGuid)
 
  hDevInfo=SetupDiGetClassDevs_(@HidGuid,0,0, #DIGCF_PRESENT|#DIGCF_DEVICEINTERFACE)
  If hDevInfo=0
    ProcedureReturn 0
  EndIf
 
 
  For i=0 To 255
   
    Result=fSetupDiEnumDeviceInterfaces(hDevInfo, 0, @HidGuid, i, @devInfoData)
    If Result
      Result = fSetupDiGetDeviceInterfaceDetail(hDevInfo, @devInfoData, 0, 0,@Length, 0)
      *detailData=AllocateMemory(Length)
      *detailData\cbSize=SizeOf(PSP_DEVICE_INTERFACE_DETAIL_DATA)
      Result = fSetupDiGetDeviceInterfaceDetail(hDevInfo, @devInfoData, *detailData, Length+1, @Required, 0)
     
      DevicePath.s=PeekS(@*detailData\DevicePath)
      FreeMemory(*detailData)
     
      hDevice=CreateFile_(@DevicePath, #GENERIC_READ|#GENERIC_WRITE,
                          #FILE_SHARE_READ|#FILE_SHARE_WRITE, @Security, #OPEN_EXISTING, 0, 0)
     
      If hDevice<>#INVALID_HANDLE_VALUE
       
        If *Funct And *Info
         
          CallFunctionFast(*Funct, hDevice, *Info)
          CloseHandle_(hDevice)
         
        Else
         
          Attributes\Size = SizeOf(HIDD_ATTRIBUTES)
          Result = fGetAttributes(hDevice, @Attributes)
         
          If Attributes\ProductID=PID And Attributes\VendorID=VID And
             (Attributes\VersionNumber=VersionNumber Or VersionNumber=-1 )
            If CurrentIndex=Index
              SetupDiDestroyDeviceInfoList_(hDevInfo)
              ProcedureReturn hDevice
            Else
              CurrentIndex+1
              CloseHandle_(hDevice)
            EndIf
          Else
            CloseHandle_(hDevice)
          EndIf
         
        EndIf
       
      EndIf
    Else
      Break
    EndIf
  Next i
 
  SetupDiDestroyDeviceInfoList_(hDevInfo)
  ProcedureReturn 0
EndProcedure

Procedure OpenDevice(PID.u, VID.u, VersionNumber.w=-1, Index.u=0)
  ProcedureReturn Open_HID_Device(PID, VID, VersionNumber, Index, 0, 0)
EndProcedure

Procedure CloseDevice(hDevice)
  If hDevice
    ProcedureReturn CloseHandle_(hDevice)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure TestDevice(PID.u, VID.u, VersionNumber.w=-1, Index.u=0)
  Protected hHid.i, Result
 
  hHid=OpenDevice(PID, VID, VersionNumber, Index)
  If hHid
    CloseDevice(hHid)
    Result=#True
  Else
    Result=#False
  EndIf
 
  ProcedureReturn Result
EndProcedure

Procedure DeviceInfo(*Info.HID_DeviceInfo)
  If *Info
    ClearStructure(*Info, HID_DeviceInfo)
    Open_HID_Device(0, 0, 0, 0, @FunctInfo(), *Info)
    ProcedureReturn Bool(*Info\CountDevice>0)
  EndIf
EndProcedure

Procedure ReadDevice(hDevice, *Buffer, Len)
  Protected Written.l=0
 
  If hDevice=0 Or *Buffer=0 Or Len<=0
    ProcedureReturn 0
  EndIf
 
  ReadFile_(hDevice, *Buffer, Len, @Written, 0)
  ProcedureReturn Written
EndProcedure

Procedure WriteDevice(hDevice, *Buffer, Len)
  Protected Written.l=0
 
  If hDevice=0 Or *Buffer=0 Or Len<=0
    ProcedureReturn 0
  EndIf

  WriteFile_(hDevice, *Buffer, Len, @Written,  #Null)
  ProcedureReturn Written
EndProcedure

Procedure GetFeature(hDevice, *Buffer, Len)
  If hDevice And *Buffer And Len>0 And fGetFeature
    ProcedureReturn fGetFeature(hDevice, *Buffer, Len)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure SetFeature(hDevice, *Buffer, Len)
  If hDevice And *Buffer And Len>0 And fSetFeature
    ProcedureReturn fSetFeature(hDevice, *Buffer, Len)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure GetInputReport(hDevice, *Buffer, Len)
  Shared OS_Version
  If hDevice And *buffer And Len>0 And
     OS_Version>=#PB_OS_Windows_XP And fGetInputReport
    ProcedureReturn fGetInputReport(hDevice, *Buffer, Len)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure SetOutputReport(hDevice, *Buffer, Len)
  Shared OS_Version
  If hDevice And *buffer And Len>0 And fSetOutputReport
    ProcedureReturn fSetOutputReport(hDevice, *Buffer, Len)
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure GetCaps(hDevice, *Capabilities.HID_CAPS)
  Protected result=0, PreparsedData
  If hDevice And fGetPreparsedData And
     fGetCaps And fFreePreparsedData
   
    If fGetPreparsedData(hDevice, @PreparsedData)
      fGetCaps(PreparsedData, *Capabilities)
      fFreePreparsedData(PreparsedData)
      result=1
    EndIf 
   
  EndIf
  ProcedureReturn result
EndProcedure

Procedure GetAttributes(hDevice, *DeviceInfo.HID_Attributes)
  Protected Info.HIDD_ATTRIBUTES, Result=#False
 
  If hDevice And *DeviceInfo And fGetAttributes
    Info\Size = SizeOf(HIDD_ATTRIBUTES)
    If fGetAttributes(hDevice, @Info)
      CopyMemory(@Info+OffsetOf(HIDD_ATTRIBUTES\VendorID), *DeviceInfo, SizeOf(HID_Attributes))
      Result=#True
    EndIf
  EndIf
 
  ProcedureReturn Result
EndProcedure

Procedure GetNumInputBuffers(hDevice)
  Protected NumInputBuffers=0
  If hDevice And fGetNumInputBuffers
    fGetNumInputBuffers(hDevice, @NumInputBuffers)
  EndIf
  ProcedureReturn NumInputBuffers
EndProcedure

Procedure.s GetManufacturerString(hDevice)
  Protected Result.s="", *mem
  If hDevice And fGetManufacturerString
    *mem=AllocateMemory(256)
    If *mem
      If fGetManufacturerString(hDevice, *mem, 252)
        Result=PeekS(*mem,-1,#PB_Unicode)
      EndIf
      FreeMemory(*mem)
    EndIf
  EndIf
  ProcedureReturn Result
EndProcedure

Procedure.s GetProductString(hDevice)
  Protected Result.s="", *mem
  If hDevice And fGetProductString
    *mem=AllocateMemory(256)
    If *mem
      If fGetProductString(hDevice, *mem, 252)
        Result=PeekS(*mem,-1,#PB_Unicode)
      EndIf
      FreeMemory(*mem)
    EndIf
  EndIf
  ProcedureReturn Result
EndProcedure

Procedure.s GetSerialNumberString(hDevice)
  Protected Result.s="", *mem
  If hDevice And fGetSerialNumberString
    *mem=AllocateMemory(256)
    If *mem
      If fGetSerialNumberString(hDevice, *mem, 252)
        Result=PeekS(*mem,-1,#PB_Unicode)
      EndIf
      FreeMemory(*mem)
    EndIf
  EndIf
  ProcedureReturn Result
EndProcedure

Procedure.s GetIndexedString(hDevice, Index)
  Protected Result.s="", *mem
  If hDevice And fGetIndexedString
    *mem=AllocateMemory(256)
    If *mem
      If fGetIndexedString(hDevice, Index, *mem, 252)
        Result=PeekS(*mem,-1,#PB_Unicode)
      EndIf
      FreeMemory(*mem)
    EndIf
  EndIf
  ProcedureReturn Result
EndProcedure

EndModule

Procedure SetTime()
 
  Protected Minute, Hour, *buffer
 
  Minute = Val(FormatDate("%ii",Date()))
  Hour = Val(FormatDate("%hh",Date()))
 
  Minute = Minute + Int(Minute / 10)*6
  Hour = Hour + Int(Hour / 10)*6
 
  *buffer = AllocateMemory(ln)
  PokeB(*buffer, $04)
  PokeB(*buffer+1, $1b)
  PokeB(*buffer+2, $00)
  PokeB(*buffer+3, Minute)
  PokeB(*buffer+4, Hour)
  ProcedureReturn *buffer
 
EndProcedure

Procedure ShowBigClock()
 
  Protected *buffer

  *buffer = AllocateMemory(ln)
  PokeB(*buffer, $03)
  PokeB(*buffer+1, $1b)
  PokeB(*buffer+2, $02)
  PokeB(*buffer+3, $01)
 
  ProcedureReturn *buffer
 
EndProcedure

Procedure SetSymbol(sym = $01, state = $01)
 
  Protected *buffer

  *buffer = AllocateMemory(ln)
  PokeB(*buffer, $04)
  PokeB(*buffer+1, $1b)
  PokeB(*buffer+2, $30)
  PokeB(*buffer+3, sym)
  PokeB(*buffer+4, state)
 
  ProcedureReturn *buffer
 
EndProcedure

Procedure RestDisplay()
 
  Protected *buffer

  *buffer = AllocateMemory(ln)
  PokeB(*buffer, $02)
  PokeB(*buffer+1, $1b)
  PokeB(*buffer+2, $50)
 
  ProcedureReturn *buffer
 
EndProcedure


HID::HID_Init()

Display = HID::OpenDevice($6A11, $19C2)
Debug HID::GetManufacturerString(Display)
Debug HID::GetProductString(Display)

*buffer = SetTime()

ShowMemoryViewer(*buffer, ln)
Debug HID::WriteDevice(Display, *buffer, ln)

HID::CloseDevice(Display)
HID::HID_End()

; IDE Options = PureBasic 5.60 (Windows - x86)
; CursorPosition = 529
; FirstLine = 9
; Folding = AAAAE-
; EnableXP
; EnableUnicode


Ist das was ich da mit dem HID Module zusammen geschustert hab überhaupt das richtig?
Oder bin ich komplett auf dem Holzweg?
Mit dem USB Analyzer sehe ich auch das überhaupt keine Daten gesendet werden. Bis auf die Infos die vom Display kommen.

Und in Python 2.7 sie das ganze so aus:
Code:
from pywinusb import hid
import time

def Clear():
  buffer=[0x00]*65
  buffer[0]=0x0
  buffer[1]=0x02
  buffer[2]=0x1b
  buffer[3]=0x50
  return (buffer)

def SetTime(hh, mm):
  buffer=[0x00]*65
  buffer[0]=0x0
  buffer[1]=0x04
  buffer[2]=0x1b
  buffer[3]=0x00
  buffer[4]=int(mm, 16)
  buffer[5]=int(hh, 16)
  return (buffer)
   
def SetClock(size):
  if size:
    dispsize = 0x02
  else:
    dispsize = 0x01
   
  buffer=[0x00]*65
  buffer[0]=0x0
  buffer[1]=0x03
  buffer[2]=0x1b
  buffer[3]=dispsize
  buffer[4]=0x01
  return (buffer)

def ShowBigClock():
 
  t = time.struct_time(time.gmtime())
  mm = t.tm_min
  hh = t.tm_hour + 2
 
  out_report.set_raw_data(Clear())
  out_report.send()
  out_report.set_raw_data(SetTime(str(hh), str(mm)))
  out_report.send()
  out_report.set_raw_data(SetClock(1))
  out_report.send()

def Symbol(sym, state):

  buffer=[0x00]*65
  buffer[0]=0x0
  buffer[1]=0x04
  buffer[2]=0x1b
  buffer[3]=0x30
  buffer[4]=int(sym, 16)
  buffer[5]=state
  out_report.set_raw_data(buffer)
  out_report.send()
 
if __name__ == "__main__":

  filter = hid.HidDeviceFilter(vendor_id = 0x19C2, product_id = 0x6A11)
  devices = filter.get_devices()

  if devices:
    device = devices[0]   
    device.open()
    out_report = device.find_output_reports()[0]
    ShowBigClock()

    end = 0
    timeout = 0.05

    while end < 20:
      Symbol("03", 1)
      Symbol("04", 0)
      time.sleep(timeout)
      Symbol("04", 1)
      Symbol("03", 0)
      time.sleep(timeout)
      end=end+1
     
  else:
    print ("Display not Found.")


Würde mich freuen wenn mir jemand weiterhelfen könnt.

Danke und Gruss NoDiss


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 13.08.2017 18:17 
Offline
Benutzeravatar

Registriert: 03.01.2016 14:55
Falls es noch jemand gebrauchen kann.

Und danke an Robinson dessen Code ich hier etwas missbraucht habe ;)
http://www.purebasic.fr/german/viewtopic.php?f=17&t=4128

Code:
EnableExplicit

Structure _MyHidGuid
  Data1.l
  Data2.w
  Data3.w
  Data4.w
  Data5.b[6]
EndStructure

Structure MyGuid
  Data1.l
  Data2.w
  Data3.w
  Data4.w
  Data5.b[6]
EndStructure

Structure _MySpDevInterfaceData
  cbSize.l
  InterfaceClassGuid.MyGuid
  Flags.l
  Reserved.l
EndStructure

Structure _MySpDevinfoData
  cbSize.l
  HidGuid.MyGuid
  DevInst.l
  Reserved.l   
EndStructure

Structure _MySpDevInterfaceDetailData
  cbSize.l
  DevicePath.b[128]
EndStructure

Structure _HIDP_PREPARSED_DATA
  Value.l
EndStructure

Structure _HIDP_CAPS
  Usage.w
  UsagePage.w
  InputReportByteLength.w
  OutputReportByteLength.w
  FeatureReportByteLength.w
  Reserved.w[17]
  NumberLinkCollectionNodes.w
  NumberInputButtonCaps.w
  NumberInputValueCaps.w
  NumberInputDataIndices.w
  NumberOutputButtonCaps.w
  NumberOutputValueCaps.w
  NumberOutputDataIndices.w
  NumberFeatureButtonCaps.w
  NumberFeatureValueCaps.w
  NumberFeatureDataIndices.w
EndStructure

Global *HidD_GetHidGuid_z,
       *HidD_GetPreparsedData_z,
       *HidD_FreePreparsedData_z,
       *HidP_GetCaps_z

Global *SetupDiEnumDeviceInfo_z,
       *SetupDiDestroyDeviceInfoList_z,
       *SetupDiEnumDeviceInterfaces_z,
       *SetupDiGetDeviceRegistryPropertyA_z,
       *SetupDiGetDeviceInterfaceDetailA_z

Global hid_dll,
       setupapi_dll

;---hid.dll

hid_dll = OpenLibrary(#PB_Any,"hid.dll")
If hid_dll
  *HidD_GetHidGuid_z = GetFunction (hid_dll,"HidD_GetHidGuid")
  *HidD_GetPreparsedData_z = GetFunction (hid_dll,"HidD_GetPreparsedData")
  *HidD_FreePreparsedData_z = GetFunction (hid_dll,"HidD_FreePreparsedData")
  *HidP_GetCaps_z = GetFunction (hid_dll,"HidP_GetCaps")                 
  If Not *HidD_GetHidGuid_z And *HidD_GetPreparsedData_z And *HidD_FreePreparsedData_z And *HidP_GetCaps_z
    CloseLibrary(hid_dll)
    MessageRequester("Error","Eine oder mehrere Funktionen der hid.dll nicht verfügbar.",#PB_MessageRequester_Ok)
    End
  EndIf   
Else
  MessageRequester("Error","Konnte hid.dll nicht öffnen.",#PB_MessageRequester_Ok)
  End
EndIf

;---setupapi.dll

setupapi_dll = OpenLibrary(#PB_Any,"setupapi.dll")
If setupapi_dll   
  *SetupDiEnumDeviceInfo_z = GetFunction (setupapi_dll,"SetupDiEnumDeviceInfo")
  *SetupDiDestroyDeviceInfoList_z = GetFunction (setupapi_dll,"SetupDiDestroyDeviceInfoList")
  *SetupDiEnumDeviceInterfaces_z = GetFunction (setupapi_dll,"SetupDiEnumDeviceInterfaces")
  *SetupDiGetDeviceInterfaceDetailA_z = GetFunction (setupapi_dll,"SetupDiGetDeviceInterfaceDetailA")
  *SetupDiGetDeviceRegistryPropertyA_z = GetFunction (setupapi_dll,"SetupDiGetDeviceRegistryPropertyA")
  If Not *SetupDiEnumDeviceInfo_z And *SetupDiDestroyDeviceInfoList_z And *SetupDiEnumDeviceInterfaces_z And *SetupDiGetDeviceInterfaceDetailA_z And  *SetupDiGetDeviceRegistryPropertyA_z
    CloseLibrary(setupapi_dll)
    MessageRequester("Error","Eine oder mehrere Funktionen der setupapi.dll nicht verfügbar.",#PB_MessageRequester_Ok)
    End
  EndIf   
Else
  MessageRequester("Error","Konnte setupapi.dll nicht öffnen.",#PB_MessageRequester_Ok)
  End
EndIf

Procedure GetHidHandle(VID.s, PID.s)
 
  Protected MyHidGuid._MyHidGuid,
            MySpDevinfoData._MySpDevinfoData,
            MySpDevInterfaceData._MySpDevInterfaceData,
            MySpDevInterfaceDetailData._MySpDevInterfaceDetailData,
            HIDP_PREPARSED_DATA._HIDP_PREPARSED_DATA
 
  Protected MemberIndex.l,
            hDevInfoSet.l,
            DetailDataSize.l,
            RequiredSize.l,
            hPropertyBuffer.l,
            PathString.s,
            StartPosition.l,
            check.l,
            HidHandle.l,
            Error.l,
            VID_PID.s
 
  Protected *Path
 
 
  VID_PID = "vid_" + VID + "&pid_" + PID
 
  CallFunctionFast(*HidD_GetHidGuid_z,@MyHidGuid)
  hDevInfoSet = SetupDiGetClassDevs_(@MyHidGuid,0,0,#DIGCF_DEVICEINTERFACE|#DIGCF_PRESENT)           
  MySpDevinfoData\cbSize = SizeOf(MySpDevinfoData)
  MySpDevInterfaceData\cbSize = SizeOf(MySpDevInterfaceData)
  MySpDevInterfaceDetailData\cbSize = $5
 
  MemberIndex = 0
 
  Repeat
   
    check = CallFunctionFast(*SetupDiEnumDeviceInterfaces_z,hDevInfoSet,0,@MyHidGuid,MemberIndex,@MySpDevInterfaceData)     
    If check < 1
      Error = GetLastError_()       
      If Error = #ERROR_NO_MORE_ITEMS
        HidHandle = 0
        Break
      EndIf
    EndIf
   
    DetailDataSize = 0
    RequiredSize = 0
    CallFunctionFast(*SetupDiGetDeviceInterfaceDetailA_z,hDevInfoSet,@MySpDevInterfaceData,0,DetailDataSize,@RequiredSize,0)
   
    DetailDataSize = RequiredSize   
    CallFunctionFast(*SetupDiGetDeviceInterfaceDetailA_z,hDevInfoSet,@MySpDevInterfaceData,@MySpDevInterfaceDetailData,DetailDataSize,@RequiredSize,@MySpDevinfoData)     
   
    PathString = PeekS(@MySpDevInterfaceDetailData\DevicePath, -1, #PB_Ascii) 
    If FindString(PathString,VID_PID,1)
      HidHandle = CreateFile_(PathString,#GENERIC_READ|#GENERIC_WRITE,#FILE_SHARE_READ|#FILE_SHARE_WRITE,0,#OPEN_EXISTING,0,0)
      Break
    EndIf
   
    MemberIndex + 1
   
  ForEver
 
  CallFunctionFast(*HidD_FreePreparsedData_z,@HIDP_PREPARSED_DATA)
  SetupDiDestroyDeviceInfoList_(hDevInfoSet)
 
  ProcedureReturn HidHandle
 
EndProcedure

Procedure WriteDevice(Hid_h, *Buffer)
 
  Protected Written.l=0

  WriteFile_(Hid_h, *Buffer, 65, @Written, #Null)
  ProcedureReturn Written
 
EndProcedure


;-------------------------------------------


Global Futaba_main, HID, event
Global HID.i = GetHidHandle("19c2", "6a11")

#Test_Image = 0


LoadFont(1, "Segoe Print", 10)

Procedure OpenFutaba_main(x = 0, y = 0, width = 384, height = 64)
  Futaba_main = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  ImageGadget(#Test_Image, 0, 0, 348, 64, 0)
EndProcedure

Procedure Futaba_main_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

Procedure ImageToDisplay(imgID)
 
  Protected *img, *buffer, x.i, n.i, y.i, bitstring1.s, bitstring2.s, s.i, f.i
  Dim ImgTMP.i(5000)
  Dim row1(200)
  Dim row2(200)
 
  If imgID = 0
    LoadImage(imgID, "Test.bmp") ;24bit BMP
  EndIf
 
  ResizeImage(imgID, 96,16)
 
  *img = EncodeImage(imgID, #PB_ImagePlugin_BMP)

  For x = 54 To MemorySize(*img) - 1 Step 3
    s = (PeekA(*img+x) + PeekA(*img+x+1) + PeekA(*img+x+2)) / 3
    ImgTMP(n) = s
    n = n + 1
  Next
 
  For x=0 To 95
    bitstring1 = ""
    For y=7 To 0 Step -1
      s = 96*y+x
      If ImgTMP(s) < 128
        bitstring1 = bitstring1 + "0"
      Else
        bitstring1 = bitstring1 + "1"
      EndIf
    Next
    row1(x) = Val("%" + bitstring1)
    bitstring2 = ""
    For y=15 To 8 Step -1
      s = 96*y+x
      If ImgTMP(s) < 128
        bitstring2 = bitstring2 + "0"
      Else
        bitstring2 = bitstring2 + "1"
      EndIf
    Next
    row2(x) = Val("%" + bitstring2)
  Next
 
  *buffer = AllocateMemory(65)
  f=0
  For x=0 To 3
    FillMemory(*buffer, 65)
    PokeB(*buffer, $00)
    PokeB(*buffer+1, $36)
    PokeB(*buffer+2, $1b)
    PokeB(*buffer+3, $60)
    PokeB(*buffer+4, x*48)
    PokeB(*buffer+5, $1b)
    PokeB(*buffer+6, $70)
    PokeB(*buffer+7, $30)
   
    For y=8 To 54 Step 2
      PokeB(*buffer+y, row2(f))
      PokeB(*buffer+y+1, row1(f))
      f=f+1
    Next
    Delay(5)
    WriteDevice(HID, *buffer)
  Next
 
 
  ResizeImage(imgID, 96*4, 16*4, #PB_Image_Raw)
  SetGadgetState(#Test_Image, ImageID(imgID))
 
EndProcedure

Procedure DisplayText(x, y, line1.s, line2.s, Font_ID)
 
  If CreateImage(2, 96, 16, 24) And StartDrawing(ImageOutput(2))
    DrawingFont(Font_ID)
    DrawText(x, y, line1, RGB(255, 255, 255))
    DrawText(x, y+8, line2, RGB(255, 255, 255))
    StopDrawing()
  EndIf
  ImageToDisplay(2)
 
EndProcedure

Procedure DisplayTime()
 
  Protected Time.s, TimeSave.s
 
  Time = FormatDate("%hh:%ii:%ss", Date())
  If Not TimeSave = Time
    TimeSave = Time
    DisplayText(15,-4, Time, "", FontID(1))
  EndIf
 
EndProcedure

Procedure RestDisplay()
 
  Protected *buffer

  *buffer = AllocateMemory(65)
  PokeB(*buffer, $00)
  PokeB(*buffer+1, $02)
  PokeB(*buffer+2, $1b)
  PokeB(*buffer+3, $50)
 
  ProcedureReturn *buffer
 
EndProcedure

OpenFutaba_main()
SetWindowTitle(Futaba_main, "Display Test")
AddWindowTimer(Futaba_main, 10, 100)
WriteDevice(HID, RestDisplay())

Repeat
  event = WaitWindowEvent(2)
  If Event = #PB_Event_Timer And EventTimer() = 10
    DisplayTime()
  EndIf
Until Futaba_main_Events(event) = #False

WriteDevice(HID, RestDisplay())
CloseLibrary(hid_dll)
CloseLibrary(setupapi_dll)

; IDE Options = PureBasic 5.60 (Windows - x86)
; Folding = w-
; EnableXP


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 13.08.2017 22:55 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Hab mal den Python Code tlw. übersetzt...
Code:

Structure LED_STRUCT
  StructureUnion
    dwLead.l
    dbBuffer.a[64]
  EndStructureUnion
EndStructure

Global LedPanel.LED_STRUCT

Procedure.i LedClear()
  ClearStructure(@LedPanel,LED_STRUCT)
  LedPanel\dwLead = $501B0200
  ProcedureReturn @LedPanel
EndProcedure

Procedure.i LedSetTime()
  Protected CDate.i = Date()
  ClearStructure(@LedPanel,LED_STRUCT)
  LedPanel\dwLead = $1B0400
  LedPanel\dbBuffer[4] = Minute(CDate)
  LedPanel\dbBuffer[5] = Hour(CDate)
  ProcedureReturn @LedPanel
EndProcedure

Procedure.i LedSymbol(Input.s,State.b)
  ClearStructure(@LedPanel,LED_STRUCT)
  LedPanel\dwLead = $301B0400
  LedPanel\dbBuffer[4] = Asc(Input)
  LedPanel\dbBuffer[5] = State
  ProcedureReturn @LedPanel
EndProcedure



Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 14.08.2017 20:27 
Offline
Benutzeravatar

Registriert: 03.01.2016 14:55
Das is ja Nice :allright:

Das Display möchte die Zeit in Hex hab. Warum auch immer :?

also so:
Code:
Procedure.i LedSetTime()
  Protected CDate.i = Date()
  ClearStructure(@LedPanel,LED_STRUCT)
  LedPanel\dwLead = $011B0400
  LedPanel\dbBuffer[4] = Val("$" + Str(Minute(CDate)))
  LedPanel\dbBuffer[5] = Val("$" + Str(Hour(CDate)))
  ProcedureReturn @LedPanel
EndProcedure


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 14.08.2017 22:20 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
nodiss hat geschrieben:
...Das Display möchte die Zeit in Hex hab. Warum auch immer :?
...


:shock: :lol:

Muss mir wohl auch mal so ein Display zulegen.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: VFD Display über USB ansteuern
BeitragVerfasst: 03.09.2017 11:40 
Offline

Registriert: 29.08.2004 13:18
Vermutlich, weil es für das Display einfacher umzurechnen ist. So ist jede Ziffer in genau 4Bit codiert.

_________________
CodeArchiv Rebirth: Deutsches Forum Github Hilfe ist immer gern gesehen!


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye