Hi alle,
das Prog. liest Messwerte von einem Metex/Voltcraft Digitalmultimeter über die serielle Schnittstelle - com2: ein
und stellt den Messwert als text und grafisch dar.
vielleicht hat ja jemand verwendung dafür.
übrigends das flackern bei der Anzeige ist mit GDI_Plus weg
neon
Spoiler anzeigen
#include <GUIConstants.au3>
#include <GDIPlus.au3>
Dim $hor, $vert,$hor_old, $vert_old
dim $smg, $exit_btn, $window1, $window1_handle,$hGraphic,$hPen,$mess_txt
dim $recieve_data,$recieve_label,$outstr
$outstr="D"
$hor = 0
$vert = 0
$hor_old = 0
$vert_old = 0
$MsComm1 = ObjCreate("MSCOMMLib.MsComm.1")
if not IsObj($MsComm1) then
FileInstall("MSCOMM32.OCX", EnvGet("SystemRoot") & "\System32\MSCOMM32.OCX")
Run(@ComSpec & " /c C:\WINDOWS\SYSTEM32\REGSVR32.EXE C:\WINDOWS\SYSTEM32\MSCOMM32.OCX")
RegWrite("HKEY_CLASSES_ROOT\Licenses\DB4C0D00-400B-101B-A3C9-08002B2F49FB", "", "REG_SZ", "mgkgtgnnmnmninigthkgogggvmkhinjggnvm")
RegWrite("HKEY_CLASSES_ROOT\Licenses\7BC20EDC-4A42-101B-A3C9-08002B2F49FB", "", "REG_SZ", "gifblihbhiiihbciocfbkifbqcfcdiebbiqh")
$MsComm1 = ObjCreate("MSCOMMLib.MsComm.1")
endif
$MsComm1.Settings = "1200,N,7,2"
$MsComm1.Handshaking = 0
;~ $MsComm1.InBufferSize = 20
;~ $MsComm1.InputLen = 14
$MSComm1.DTREnable = True
$MSComm1.RTSEnable = False
$MsComm1.CommPort = 2
$MsComm1.PortOpen = True
$window1 = GUICreate("METEX Communications serial COM2:",600,350)
$window1_handle = WinGetHandle("METEX Communications serial COM2:")
_GDIPlus_Startup ()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($window1_handle)
$hPen = _GDIPlus_PenCreate ( 0xffffff00,1, 2)
$hPenblack = _GDIPlus_PenCreate ( 0xFF000000,1, 2)
$hBrush = _GDIPlus_BrushCreateSolid (0xffff0000)
$hFormat = _GDIPlus_StringFormatCreate ()
$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
$hFont = _GDIPlus_FontCreate ($hFamily, 30, 2)
$tLayout = _GDIPlus_RectFCreate (250, 10, 380, 40)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, $recieve_data, $hFont, $tLayout, $hFormat, $hBrush)
GUISetState()
_GDIPlus_GraphicsClear($hGraphic)
$exit_btn = GUICtrlCreateButton("", 550, 300, 40, 40,$BS_ICON)
GUICtrlSetImage(-1,"shell32.dll",28,1)
GUICtrlSetTip(-1,"Exit Program")
GUISetState()
AdlibEnable("_Read_mm",250)
[/autoit] [autoit][/autoit] [autoit]func _Read_mm()
$recieve_data = ""
$MsComm1.Output = $outstr
$recieve_data = $MsComm1.Input
_GDIPlus_GraphicsFillRect($hGraphic, 250, 10, 380, 40,0)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, $recieve_data, $hFont, $tLayout, $hFormat, $hBrush)
if $hor > 580 Then
$hor = 0
$hor_old =0
$vert_old = 0
_GDIPlus_GraphicsClear ($hGraphic)
GUICtrlSetImage($exit_btn,"shell32.dll",28,1)
GUICtrlSetTip($exit_btn,"Exit Program")
GUISetState()
Else
$hor =$hor + 1
EndIf
$vert = 300 - (Number(StringMid($recieve_data,4))/2)
_GDIPlus_GraphicsDrawLine ($hGraphic, $hor_old,$vert_old, $hor,$vert, $hPen)
$hor_old=$hor
$vert_old=$vert
EndFunc
while 1
$msg=GUIGetMsg()
Select
case $msg = $exit_btn
ExitLoop
EndSelect
WEnd
_GDIPlus_ShutDown ()
$MsComm1.PortOpen = False