main
lincaigui 7 months ago
parent 944a0b29d2
commit 5373920978

@ -1,12 +1,14 @@
# gesture
#### 介绍
FPGA手势识别项目
FPGA 4399手势黄金矿工
#### 件架构
#### 件架构
FPGA+Paj7620u2
通信i2c
#### 软件架构
go按键模拟
4399黄金矿工游戏
#### 使用说明

@ -4,7 +4,8 @@ module ges_recognize(
output wire scl ,
inout wire sda ,
output wire [3: 0] led
output wire [3: 0] led ,
output wire tx
);
wire [2: 0] step ;
wire [5: 0] cfg_num ;
@ -13,6 +14,11 @@ wire cfg_start ;
wire i2c_clk ;
wire i2c_start ;
wire [7: 0] po_data ;
wire tx_vld ;
reg send_flag ;
wire rx_vld ;
assign rx_vld = po_data != 8'h00;
paj7620_cfg paj7620_cfg_inst(
.i2c_clk (i2c_clk ),
.sys_rst_n (sys_rst_n ),
@ -37,6 +43,16 @@ i2c_ctrl i2c_ctrl_inst(
.sda (sda ),
.po_data (po_data )
);
uart_tx uart_tx_inst(
.sys_clk (sys_clk),
.sys_rst_n (sys_rst_n),
.tx_din (po_data),//
.rx_vld (rx_vld),//
.tx_vld (tx_vld),
.tx_dout (tx)//
);
led_ctrl led_ctrl_inst(
.sys_clk (sys_clk ),

@ -0,0 +1,64 @@
module ges_recognize(
input wire sys_clk ,
input wire sys_rst_n ,
output wire scl ,
inout wire sda ,
output wire [3: 0] led ,
output wire tx
);
wire [2: 0] step ;
wire [5: 0] cfg_num ;
wire [15: 0] cfg_data ;
wire cfg_start ;
wire i2c_clk ;
wire i2c_start ;
wire [7: 0] po_data ;
wire tx_vld ;
reg send_flag ;
wire rx_vld ;
assign rx_vld == po_data != 8'h00;
paj7620_cfg paj7620_cfg_inst(
.i2c_clk (i2c_clk ),
.sys_rst_n (sys_rst_n ),
.cfg_start (cfg_start ),
.step (step ),
.cfg_num (cfg_num ),
.cfg_data (cfg_data ),
.i2c_start (i2c_start )
);
i2c_ctrl i2c_ctrl_inst(
.sys_clk (sys_clk ),
.sys_rst_n (sys_rst_n ),
.i2c_start (i2c_start ),
.cfg_num (cfg_num ),
.cfg_data (cfg_data ),
.cfg_start (cfg_start ),
.step (step ),
.i2c_clk (i2c_clk ),
.scl (scl ),
.sda (sda ),
.po_data (po_data )
);
uart_tx uart_tx_inst(
.sys_clk (sys_clk),
.sys_rst_n (sys_rst_n),
.tx_din (po_data),//
.rx_vld (rx_vld),//
.tx_vld (tx_vld),
.tx_dout (tx)//
);
led_ctrl led_ctrl_inst(
.sys_clk (sys_clk ),
.sys_rst_n (sys_rst_n ),
.po_data (po_data ),
.led (led )
);
endmodule

@ -748,7 +748,7 @@ always @(posedge i2c_clk or negedge sys_rst_n)begin
po_data <= recv_data;
end
else begin
po_data <= po_data;
po_data <= 8'h0;
end
end
endmodule

@ -0,0 +1,16 @@
`define SYS_FRQ 50_000_000
`define BAUD_115200
//9600192003840057600115200
`ifdef BAUD_9600
`define MAX 9600
`elsif BAUD_19200
`define MAX 19200
`elsif BAUD_38400
`define MAX 38400
`elsif BAUD_57600
`define MAX 57600
`elsif BAUD_115200
`define MAX 115200
`else
`define MAX 115200
`endif

@ -0,0 +1,108 @@
`include "param.v"
module uart_rx(
input wire sys_clk ,
input wire sys_rst_n ,
input wire rx_din ,//
input wire rcv_start ,
output wire [7: 0] rx_dout ,//
output wire rx_vld //
);
parameter BAUD = `SYS_FRQ / `MAX;//1bit
reg din_reg0;//
reg din_reg1;//沿
wire nedge;//沿
reg rx_flag;//
//bit
reg [3: 0] cnt_bit ;
wire add_cnt_bit;
wire end_cnt_bit;
//
reg [12: 0] cnt_bps ;
wire add_cnt_bps ;
wire end_cnt_bps ;
//
reg [7: 0] data_reg;
always @(posedge sys_clk or negedge sys_rst_n) begin
if(!sys_rst_n)begin
din_reg0 <= 1'b1;
din_reg1 <= 1'b1;
end
else begin
din_reg0 <= rx_din;
din_reg1 <= din_reg0;
end
end
assign nedge = ~din_reg0 && din_reg1;//沿
//rx_flag
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
rx_flag <= 1'b0;
end
else if(nedge && rcv_start)begin//沿
rx_flag <= 1'b1;
end
else if(end_cnt_bit)begin//
rx_flag <= 1'b0;
end
else begin
rx_flag <= rx_flag;//
end
end
//cnt_bps
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_bps <= 13'd0;
end
else if(add_cnt_bps)begin
if(end_cnt_bps)begin
cnt_bps <= 13'd0;
end
else begin
cnt_bps <= cnt_bps + 1'd1;
end
end
else begin
cnt_bps <= cnt_bps;
end
end
assign add_cnt_bps = rx_flag;
assign end_cnt_bps = add_cnt_bps && cnt_bps == BAUD - 1'd1;
//cnt_bit
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_bit <= 4'd0;
end
else if(add_cnt_bit)begin
if(end_cnt_bit)begin
cnt_bit <= 4'd0;
end
else begin
cnt_bit <= cnt_bit + 1'd1;
end
end
else begin
cnt_bit <= cnt_bit;
end
end
assign add_cnt_bit = end_cnt_bps;//
assign end_cnt_bit = add_cnt_bit && cnt_bit == 4'd8;//0-8
//data_reg
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
data_reg <= 8'hx;
end
else if((cnt_bit >= 4'd1 && cnt_bit <= 4'd8) && (cnt_bps == BAUD >> 1))begin
data_reg[cnt_bit - 1'd1] = din_reg0;//
end
else begin
data_reg <= data_reg;
end
end
assign rx_dout = data_reg;//
assign rx_vld = end_cnt_bit;//
endmodule

@ -0,0 +1,85 @@
module uart_top(
input wire sys_clk ,
input wire sys_rst_n ,
input wire rx ,
output wire tx ,
output wire led_ready
);
wire [7: 0] data_byte ;
wire [7: 0] data_out ;
wire ready ;
wire comm_finish ;
wire tx_vld ;
wire rx_vld ;
reg rcv_start ;
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
rcv_start <= 1'b1;
end
else if(ready)begin
rcv_start <= 1'b0;
end
else if(comm_finish)begin
rcv_start <= 1'b1;
end
else begin
rcv_start <= rcv_start;
end
end
uart_rx uart_rx_inst(
.sys_clk (sys_clk) ,
.sys_rst_n (sys_rst_n) ,
.rx_din (rx) ,//
.rcv_start (rcv_start) ,
.rx_dout (data_byte) ,//
.rx_vld (rx_vld) //
);
uart_tx uart_tx_inst(
.sys_clk (sys_clk) ,
.sys_rst_n (sys_rst_n) ,
.tx_din (data_out) ,//
.rx_vld (rx_vld) ,//
.tx_vld (tx_vld) ,
.tx_dout (tx)//
);
device_ready device_ready_inst(
.sys_clk (sys_clk) ,
.sys_rst_n (sys_rst_n) ,
.data_in (data_byte) ,
.rx_vld (rx_vld) ,
.ready (ready)
);
command_send command_send_inst(
.sys_clk (sys_clk) ,
.sys_rst_n (sys_rst_n) ,
.tx_vld (tx_vld) ,
.comm_finish (comm_finish),
.data_out (data_out)
);
led_driver led_driver_inst(
.sys_clk (sys_clk),
.sys_rst_n (sys_rst_n),
.rx_data (data_byte),
.led_ready (led_ready)
);
endmodule

@ -0,0 +1,104 @@
`include "param.v"
module uart_tx(
input wire sys_clk ,
input wire sys_rst_n ,
input wire [7: 0] tx_din ,//
input wire rx_vld ,//
output wire tx_vld ,
output reg tx_dout //
);
parameter BAUD = `SYS_FRQ / `MAX;//
reg [8: 0] data_reg;//
reg tx_flag ;//
//
reg [12: 0] cnt_bps;
wire add_cnt_bps;
wire end_cnt_bps;
//
reg [3: 0] cnt_bit;
wire add_cnt_bit;
wire end_cnt_bit;
//
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
data_reg <= 9'hx;
end
else if(rx_vld)begin
data_reg <= {tx_din, 1'b0};//
end
else begin
data_reg <= data_reg;
end
end
//tx_flag
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
tx_flag <= 1'b0;
end
else if(rx_vld)begin
tx_flag <= 1'b1;
end
else if(end_cnt_bit)begin
tx_flag <= 1'b0;
end
else begin
tx_flag <= tx_flag;
end
end
//cnt_bps
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_bps <= 13'd0;
end
else if(add_cnt_bps)begin
if(end_cnt_bps)begin
cnt_bps <= 13'd0;
end
else begin
cnt_bps <= cnt_bps + 1'd1;
end
end
else begin
cnt_bps <= cnt_bps;
end
end
assign add_cnt_bps = tx_flag;
assign end_cnt_bps = add_cnt_bps && cnt_bps == BAUD - 1'd1;
//cnt_bit
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
cnt_bit <= 4'd0;
end
else if(add_cnt_bit)begin
if(end_cnt_bit)begin
cnt_bit <= 4'd0;
end
else begin
cnt_bit <= cnt_bit + 1'd1;
end
end
else begin
cnt_bit <= cnt_bit;
end
end
assign add_cnt_bit = end_cnt_bps;//
assign end_cnt_bit = add_cnt_bit && cnt_bit == 4'd8;
//tx_dout
always @(posedge sys_clk or negedge sys_rst_n)begin
if(!sys_rst_n)begin
tx_dout <= 1'b1;
end
else if(tx_flag)begin
tx_dout <= data_reg[cnt_bit];//
end
else begin
tx_dout <= 1'b1;
end
end
assign tx_vld = end_cnt_bit;
endmodule

@ -0,0 +1,33 @@
module software
go 1.22.2
require (
github.com/StackExchange/wmi v1.2.1
github.com/go-vgo/robotgo v0.110.1
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
)
require (
github.com/gen2brain/shm v0.0.0-20230802011745-f2460f5984f7 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/jezek/xgb v1.1.0 // indirect
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237 // indirect
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/otiai10/gosseract v2.2.1+incompatible // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 // indirect
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 // indirect
github.com/shirou/gopsutil/v3 v3.23.8 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/vcaesar/gops v0.30.2 // indirect
github.com/vcaesar/imgo v0.40.0 // indirect
github.com/vcaesar/keycode v0.10.1 // indirect
github.com/vcaesar/tt v0.20.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/image v0.12.0 // indirect
golang.org/x/sys v0.12.0 // indirect
)

@ -0,0 +1,116 @@
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gen2brain/shm v0.0.0-20230802011745-f2460f5984f7 h1:VLEKvjGJYAMCXw0/32r9io61tEXnMWDRxMk+peyRVFc=
github.com/gen2brain/shm v0.0.0-20230802011745-f2460f5984f7/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-vgo/robotgo v0.110.1 h1:2etpOzsBBt9KJOxDBFBVYzE4/U7gRrsnB9dxuujRMTw=
github.com/go-vgo/robotgo v0.110.1/go.mod h1:DdJUdi6mEU8ttHMbow6hKD1TjgsfgJC/H+4dusok8Uw=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/jezek/xgb v1.1.0 h1:wnpxJzP1+rkbGclEkmwpVFQWpuE2PUGNUzP8SbfFobk=
github.com/jezek/xgb v1.1.0/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237 h1:YOp8St+CM/AQ9Vp4XYm4272E77MptJDHkwypQHIRl9Q=
github.com/kbinani/screenshot v0.0.0-20230812210009-b87d31814237/go.mod h1:e7qQlOY68wOz4b82D7n+DdaptZAi+SHW0+yKiWZzEYE=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a h1:N9zuLhTvBSRt0gWSiJswwQ2HqDmtX/ZCDJURnKUt1Ik=
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I=
github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE=
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b h1:0LFwY6Q3gMACTjAbMZBjXAqTOzOwFaj2Ld6cjeQ7Rig=
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 h1:2lhSR8N3T6I30q096DT7/5AKEIcf1vvnnWAmS0wfnNY=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 h1:2uX8QRLkkxn2EpAQ6I3KhA79BkdRZfvugJUzJadiJwk=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/shirou/gopsutil/v3 v3.23.8 h1:xnATPiybo6GgdRoC4YoGnxXZFRc3dqQTGi73oLvvBrE=
github.com/shirou/gopsutil/v3 v3.23.8/go.mod h1:7hmCaBn+2ZwaZOr6jmPBZDfawwMGuo1id3C6aM8EDqQ=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
github.com/vcaesar/gops v0.30.2 h1:fANyUGCjLkfcYmJRVnXv+QZhT8cL2e0GWpRFZe58p/4=
github.com/vcaesar/gops v0.30.2/go.mod h1:2NSA2Q9M1irGnGD9tWdo0Z+MwKjUj4Q4EgUDukN/Vsk=
github.com/vcaesar/imgo v0.40.0 h1:okI1eonRAfGLzjqgTIBkUwhm4j/rH19qGno4eFOBQsc=
github.com/vcaesar/imgo v0.40.0/go.mod h1:E5uI53XkEfbI20VvcIZ/19G2hHidPfH9h4NtQooEY+8=
github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw=
github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
github.com/vcaesar/tt v0.20.0 h1:9t2Ycb9RNHcP0WgQgIaRKJBB+FrRdejuaL6uWIHuoBA=
github.com/vcaesar/tt v0.20.0/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.12.0 h1:w13vZbU4o5rKOFFR8y7M+c4A5jXDC0uXTdHYRP8X2DQ=
golang.org/x/image v0.12.0/go.mod h1:Lu90jvHG7GfemOIcldsh9A2hS01ocl6oNO7ype5mEnk=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

@ -0,0 +1,67 @@
package main
import (
"fmt"
"log"
"time"
"github.com/StackExchange/wmi"
"github.com/go-vgo/robotgo"
"github.com/tarm/serial"
)
type Win32_PnPEntity struct {
Name string
}
func check() string {
var devices []Win32_PnPEntity
query := `SELECT Name FROM Win32_PnPEntity WHERE Name LIKE '%(COM%'`
err := wmi.Query(query, &devices)
if err != nil {
panic(fmt.Sprintf("Failed to query WMI: %v", err))
}
return devices[0].Name[40:44]
}
func main() {
// 串口配置
com := check()
config := &serial.Config{
Name: com, // 替换为实际的串口设备路径例如在Windows上可能是"COM1"
Baud: 115200, // 波特率,根据实际需求设置
}
// 打开串口
port, err := serial.OpenPort(config)
if err != nil {
log.Fatal(err)
}
defer port.Close()
buffer := make([]byte, 128) // 缓冲区大小根据你的数据包大小调整
for {
n, err := port.Read(buffer)
if err != nil {
log.Printf("读取错误: %v\n", err)
continue
}
if n > 0 {
log.Printf("读取到 %d 字节数据: %d\n", n, buffer[:n])
// 这里可以添加处理数据的逻辑
if buffer[0] == 0x02 {
robotgo.Click("left")
}
} else {
// 当没有读取到数据时,可以根据需要处理或简单跳过
// log.Println("没有新数据")
}
// 可以根据需要添加适当的延迟避免无数据时CPU占用过高
time.Sleep(10 * time.Millisecond)
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,60 @@
{
"RT_GROUP_ICON": {
"APP": {
"0000": [
"home-logo.png"
]
}
},
"RT_MANIFEST": {
"#1": {
"0409": {
"identity": {
"name": "",
"version": ""
},
"description": "",
"minimum-os": "win7",
"execution-level": "as invoker",
"ui-access": false,
"auto-elevate": false,
"dpi-awareness": "system",
"disable-theming": false,
"disable-window-filtering": false,
"high-resolution-scrolling-aware": false,
"ultra-high-resolution-scrolling-aware": false,
"long-path-aware": false,
"printer-driver-isolation": false,
"gdi-scaling": false,
"segment-heap": false,
"use-common-controls-v6": false
}
}
},
"RT_VERSION": {
"#1": {
"0000": {
"fixed": {
"file_version": "0.0.0.0",
"product_version": "0.0.0.0"
},
"info": {
"0409": {
"Comments": "",
"CompanyName": "",
"FileDescription": "",
"FileVersion": "",
"InternalName": "",
"LegalCopyright": "",
"LegalTrademarks": "",
"OriginalFilename": "",
"PrivateBuild": "",
"ProductName": "",
"ProductVersion": "",
"SpecialBuild": ""
}
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.
Loading…
Cancel
Save