Code:
gameboycam :
IncludeFile "game-pebi-inc.pb"
#BufferIn = 1024*16
#BufferOut = 1024*16
Global HCom.l
Global Chaine.s
Declare bild()
Procedure pebi()
los.s = "los"+Chr(13)
ComSendByte(HCom,@los,Len(los))
Buffer.b = 0
StartDrawing( WindowOutput() )
Delay(200)
For y=20 To 127+20
For x=200 To 127+200
ComReadByte(HCom,@Buffer,1)
Plot(x,y,RGB(buffer,buffer,buffer))
Next x
Next y
StopDrawing()
EndProcedure
Chaine="COM1:19200,N,8,1"
Open_Window_0()
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_EventGadget
If GadgetID = #Button_0
If HCom <> 0
MessageRequester("Message","Comport ist offen !",#MB_ICONEXCLAMATION)
Else
HCom = ComOpen(Chaine,0 ,#BufferIn,#BufferOut)
EndIf
ElseIf GadgetID = #Button_1
If HCom <> 0
If ComClose(HCom)
HCom = 0
EndIf
EndIf
ElseIf GadgetID = #Button_2
If HCom <> 0
pebi()
Else
MessageRequester("Message","Comport nicht geöffnet !",#MB_ICONEXCLAMATION)
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
If HCom <> 0
If ComClose(HCom)
HCom = 0
EndIf
EndIf
CloseWindow(0)
End
;
videocapture:
IncludeFile "inc.pb"
#WM_CAP_START = #WM_USER
#WM_CAP_SET_CALLBACK_ERROR = #WM_CAP_START + 2
#WM_CAP_SET_CALLBACK_STATUS = #WM_CAP_START + 3
#WM_CAP_SET_CALLBACK_YIELD = #WM_CAP_START + 4
#WM_CAP_SET_CALLBACK_FRAME = #WM_CAP_START + 5
#WM_CAP_SET_CALLBACK_VIDEOSTREAM = #WM_CAP_START + 6
#WM_CAP_SET_CALLBACK_WAVESTREAM = #WM_CAP_START + 7
#WM_CAP_DRIVER_CONNECT = #WM_CAP_START + 10
#WM_CAP_DRIVER_DISCONNECT = #WM_CAP_START + 11
#WM_CAP_DRIVER_GET_CAPS = #WM_CAP_START + 14
#WM_CAP_DLG_VIDEOFORMAT = #WM_CAP_START + 41
#WM_CAP_DLG_VIDEOSOURCE = #WM_CAP_START + 42
#WM_CAP_DLG_VIDEODISPLAY = #WM_CAP_START + 43
#WM_CAP_SET_PREVIEW = #WM_CAP_START + 50
#WM_CAP_SET_PREVIEWRATE = #WM_CAP_START + 52
#WM_CAP_GET_STATUS = #WM_CAP_START + 54
#WM_CAP_FILE_SAVEDIB = #WM_CAP_START + 25
#WM_CAP_SET_SCALE = #WM_CAP_START + 53
#WM_CAP_SET_CALLBACK_CAPCONTROL = #WM_CAP_START + 85
#WM_CAP_EDIT_COPY = #WM_CAP_START + 30
#WM_CAP_GRAB_FRAME = #WM_CAP_START+60
Open_Window_0()
OpenLibrary(0, "AVICAP32.DLL")
hRobby = CallFunction(0, "capCreateCaptureWindowA", "Test", #WS_VISIBLE + #WS_CHILD, 120, 30, 300, 300, hWnd, 0)
SendMessage_(hRobby, #WM_CAP_DRIVER_CONNECT, 0 , 0)
SendMessage_(hRobby, #WM_CAP_SET_SCALE , 1 , 0)
SendMessage_(hRobby, #WM_CAP_SET_PREVIEWRATE, 50, 0)
SendMessage_(hRobby, #WM_CAP_SET_PREVIEW, 1 , 0)
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_EventGadget
If GadgetID = #Button_0
If Link <> 0
StartDrawing( WindowOutput() )
DrawImage(Link, 440,30,300, 300)
StopDrawing()
EndIf
EndIf
EndIf
SendMessage_(hRobby, #WM_CAP_GRAB_FRAME, 0 , 0)
SendMessage_(hRobby, #WM_CAP_EDIT_COPY, 0 , 0)
Link = GetClipboardData(#PB_ClipboardImage)
Delay(1)
Until Event = #PB_Event_CloseWindow ; End of the event loop
SendMessage_(hRobby, #WM_CAP_SET_PREVIEW, 0, 0)
SendMessage_(hRobby, #WM_CAP_DRIVER_DISCONNECT, "Test", 0)
CloseWindow(0)
CloseLibrary(0)
End
;
cmucamdaten:
; PureBasic Visual Designer v3.92 build 1460
IncludeFile "cmu-pebi-inc.pb"
#BufferIn = 1024*32
#BufferOut = 1024*32
Global HCom.l
Global Chaine.s
Global Buffer.b
Global Buffer1.b
Global Buffer2.b
Global x.w
Global y.w
Global zaehler.l
Global durch.w
Dim cmudaten.b(40000)
Procedure pebi()
ComOpen(Chaine,0 ,#BufferIn,#BufferOut)
los.s = "sf"+Chr(13)
ComSendByte(HCom,@los,Len(los))
Delay(500)
zaehler=-1
Repeat
zaehler=zaehler+1
ComReadByte(HCom,@Buffer,1)
cmudaten(zaehler)=Buffer
Until Buffer=3
StartDrawing( WindowOutput() )
durch=0
zaehler=3
x=120
y=10
Repeat
durch=durch+1
For z=0 To 86
zaehler=zaehler+1
Buffer=cmudaten(zaehler)
zaehler=zaehler+1
Buffer1=cmudaten(zaehler)
zaehler=zaehler+1
Buffer2=cmudaten(zaehler)
Plot(x,y,RGB(Buffer,Buffer1,Buffer2))
x=x+1
Plot(x,y,RGB(Buffer,Buffer1,Buffer2))
x=x+1
Next z
zaehler=zaehler+1
x=120
y=y+1
Until durch= 144
ComClose(HCom)
StopDrawing()
EndProcedure
Chaine="COM1:19200,N,8,1"
Open_Window_0()
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_EventGadget
If GadgetID = #Button_0
If HCom <> 0
MessageRequester("Message","Comport ist offen !",#MB_ICONEXCLAMATION)
Else
HCom = ComOpen(Chaine,0 ,#BufferIn,#BufferOut)
EndIf
ElseIf GadgetID = #Button_1
If HCom <> 0
If ComClose(HCom)
HCom = 0
EndIf
EndIf
ElseIf GadgetID = #Button_2
If HCom <> 0
pebi()
Else
MessageRequester("Message","Comport nicht geöffnet !",#MB_ICONEXCLAMATION)
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
If HCom <> 0
If ComClose(HCom)
HCom = 0
EndIf
EndIf
CloseWindow(0)
End
;
robbysteuerung über RS232 :
; PureBasic Visual Designer v3.92 build 1460
IncludeFile "robo-inc.pb"
#BufferIn = 1024
#BufferOut = 1024
Global HCom.l
Global Chaine.s
Chaine="COM1:19200,N,8,1"
Open_Window_0()
HCom = ComOpen(Chaine,0 ,#BufferIn,#BufferOut)
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
; ButtonGadget(#Button_0, 170, 150, 60, 20, "rea")
; ButtonGadget(#Button_2, 40, 120, 60, 20, "lii")
; ButtonGadget(#Button_4, 40, 150, 60, 20, "lia")
; ButtonGadget(#Button_6, 150, 50, 60, 20, "reo")
; ButtonGadget(#Button_7, 80, 50, 60, 20, "lio")
; ButtonGadget(#Button_8, 170, 120, 60, 20, "rei")
; ButtonGadget(#Button_9, 150, 80, 60, 20, "reu")
; ButtonGadget(#Button_11, 80, 80, 60, 20, "liu")
If Event = #PB_EventGadget
If GadgetID = #Button_0
los.s ="130"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_2
los.s = "141"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_4
los.s = "138"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_6
los.s = "129"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_7
los.s = "137"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_8
los.s = "133"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_9
los.s = "132"+Chr(13)
ComSendByte(HCom,@los,Len(los))
ElseIf GadgetID = #Button_11
los.s = "140"+Chr(13)
ComSendByte(HCom,@los,Len(los))
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
If HCom <> 0
If ComClose(HCom)
HCom = 0
EndIf
EndIf
End
;
Lesezeichen