├── .gitattributes
├── .github
└── workflows
│ ├── CDC_client.yml
│ └── CDC_firmware.yml
├── .gitignore
├── LICENSE
├── ProjectCDC
├── Bootloader
│ ├── CH552.h
│ ├── Main.c
│ ├── UsbDescriptor.h
│ └── bootloader.uvproj
├── Client
│ ├── UsbScreen.sln
│ ├── UsbScreen
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── Convert.cs
│ │ ├── FodyWeavers.xml
│ │ ├── FodyWeavers.xsd
│ │ ├── Interface
│ │ │ └── IScreen.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── Models
│ │ │ ├── Plugin.cs
│ │ │ ├── SerialScreen.cs
│ │ │ └── Setting.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── Themes
│ │ │ └── TitleBarStyle.xaml
│ │ ├── UsbScreen.csproj
│ │ └── packages.config
│ └── plugins
│ │ ├── Aida64Info
│ │ ├── Aida64Info.sln
│ │ └── Aida64Info
│ │ │ ├── Aida64Info.csproj
│ │ │ ├── Class.cs
│ │ │ ├── IScreen.cs
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Clock
│ │ ├── Clock.sln
│ │ └── Clock
│ │ │ ├── Class.cs
│ │ │ ├── Clock.csproj
│ │ │ ├── IScreen.cs
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── ClockAnalog0
│ │ ├── ClockAnalog0.sln
│ │ └── ClockAnalog0
│ │ │ ├── Class.cs
│ │ │ ├── ClockAnalog0.csproj
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── ClockAnalogDigital0
│ │ ├── ClockAnalogDigital0.sln
│ │ └── ClockAnalogDigital0
│ │ │ ├── Class.cs
│ │ │ ├── ClockAnalogDigital0.csproj
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── ClockMechanical0
│ │ ├── ClockMechanical0.sln
│ │ └── ClockMechanical0
│ │ │ ├── Class.cs
│ │ │ ├── ClockMechanical0.csproj
│ │ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── ClockTheme
│ │ ├── ClockTheme.sln
│ │ └── ClockTheme
│ │ ├── Class.cs
│ │ ├── ClockTheme.csproj
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ └── Resources
│ │ └── ReadMe.md
├── Firmware
│ ├── CH552.h
│ ├── Freqsys.c
│ ├── Freqsys.h
│ ├── LCD.c
│ ├── LCD.h
│ ├── Main.c
│ ├── SPI.c
│ ├── SPI.h
│ ├── UsbDescriptor.h
│ ├── UsbManager.c
│ ├── UsbManager.h
│ └── UsbScreen.uvproj
├── MasterTool
│ ├── UsbScreen.sln
│ └── UsbScreen
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ │ ├── ScreenCapture.cs
│ │ ├── Themes
│ │ └── TitleBarStyle.xaml
│ │ ├── UsbScreen.csproj
│ │ └── app.config
├── cli-test
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── src
│ │ └── main.rs
│ └── static
│ │ └── sarasa-mono-sc-nerd-regular.ttf
└── rust-cli
│ ├── cli-test.exe
│ └── static
│ └── sarasa-mono-sc-nerd-regular.ttf
├── ProjectHID
├── Bootloader
│ ├── CH552.h
│ ├── CH558.h
│ ├── CH559.h
│ ├── Main.c
│ ├── UsbReports.h
│ └── bootloader.uvproj
├── Firmware
│ ├── CH552.h
│ ├── Main.c
│ ├── SPI.h
│ ├── TypeDefines.h
│ ├── UsbManager.h
│ ├── UsbReports.h
│ └── UsbScreen.uvproj
└── MasterTool
│ ├── UsbScreen.sln
│ └── UsbScreen
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── HidApi
│ ├── HidAPI.cs
│ └── WinAPI.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ ├── ScreenCapture.cs
│ ├── Themes
│ └── TitleBarStyle.xaml
│ └── UsbScreen.csproj
├── README.md
├── hardware
├── datasheets
│ ├── 1.54-SPI-Screen
│ │ ├── 01-1.54IPS显示屏C51_SPI例程
│ │ │ ├── LCD
│ │ │ │ ├── lcd.c
│ │ │ │ ├── lcd.h
│ │ │ │ ├── lcd_init.c
│ │ │ │ └── lcd_init.h
│ │ │ └── main.c
│ │ ├── 1.54-SPI原理图.pdf
│ │ ├── ST7789VW芯片手册.pdf
│ │ └── ZJY154T-PG04.pdf
│ ├── C108958_CH551G_2020-08-19.pdf
│ └── C83932_SC662K-3.3V_2016-10-24.pdf
├── kicad-project
│ ├── .gitignore
│ ├── USB-Screen-cache.lib
│ ├── USB-Screen-rescue.dcm
│ ├── USB-Screen-rescue.lib
│ ├── USB-Screen.kicad_pcb
│ ├── USB-Screen.pretty
│ │ ├── SOP-16_4.55x10.3mm_P1.27mm.kicad_mod
│ │ ├── SW_4mm_4mm.kicad_mod
│ │ ├── ZJY154T-PG04.kicad_mod
│ │ └── packages3d
│ │ │ ├── SW_Push_1P1T_NO_4x4mm_H2.0mm.wrl
│ │ │ ├── USB_C_Receptacle_Palconn_UTC16-G.step
│ │ │ └── USB_Micro-B_Molex-105017-0001.step
│ ├── USB-Screen.pro
│ ├── USB-Screen.sch
│ ├── USB-Screen2.kicad_pcb
│ ├── USB-Screen2.pro
│ ├── USB_Screen_Library.dcm
│ ├── USB_Screen_Library.lib
│ ├── fp-lib-table
│ └── sym-lib-table
├── shell
│ ├── .gitignore
│ ├── cap.scad
│ └── usb_screen.scad
└── software_for_test
│ ├── CH552.H
│ ├── CompatibilityHID.C
│ ├── Debug.C
│ ├── Debug.H
│ ├── SPI.C
│ ├── SPI.H
│ ├── USB-Screen
│ ├── USB-Screen.sln
│ └── USB-Screen
│ │ ├── App.config
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── Dev
│ │ ├── Hid.cs
│ │ └── Screen.cs
│ │ ├── FodyWeavers.xml
│ │ ├── FodyWeavers.xsd
│ │ ├── MainWindow.xaml
│ │ ├── MainWindow.xaml.cs
│ │ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ │ ├── USB-Screen.csproj
│ │ └── packages.config
│ └── UsbScreen.uvproj
├── rust-cli.7z
└── rust-cli
├── cli-test.exe
└── static
└── sarasa-mono-sc-nerd-regular.ttf
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pdf filter=lfs diff=lfs merge=lfs -text
2 | *.wrl filter=lfs diff=lfs merge=lfs -text
--------------------------------------------------------------------------------
/.github/workflows/CDC_client.yml:
--------------------------------------------------------------------------------
1 | name: Build ProjectCDC
2 |
3 | on:
4 | push:
5 | paths:
6 | - 'ProjectCDC/MasterTool/**'
7 | pull_request:
8 | paths:
9 | - 'ProjectCDC/MasterTool/**'
10 |
11 | jobs:
12 | build:
13 | runs-on: windows-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v2
17 | - name: Add msbuild to PATH
18 | uses: microsoft/setup-msbuild@v1.0.2
19 | - name: Build
20 | run: msbuild ProjectCDC/MasterTool/UsbScreen.sln /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
21 | - name: Upload Artifact
22 | uses: actions/upload-artifact@v1.0.0
23 | with:
24 | name: MasterToolCDC
25 | path: ProjectCDC/MasterTool/UsbScreen/bin/Release
26 |
--------------------------------------------------------------------------------
/.github/workflows/CDC_firmware.yml:
--------------------------------------------------------------------------------
1 | name: Build firmware
2 |
3 | on:
4 | push:
5 | paths:
6 | - 'ProjectCDC/Firmware/**'
7 | pull_request:
8 | paths:
9 | - 'ProjectCDC/Firmware/**'
10 |
11 | jobs:
12 | build:
13 | runs-on: windows-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v2
17 | - name: Build
18 | run: |
19 | cd ProjectCDC/firmware
20 | Invoke-WebRequest -uri https://github.com/chenxuuu/USB-Screen/releases/download/0.0.0/c51.zip -OutFile c51.zip
21 | Expand-Archive -Path c51.zip -DestinationPath ./
22 | BIN\C51.exe Freqsys.c "OPTIMIZE (9)"
23 | BIN\C51.exe LCD.c "OPTIMIZE (9)"
24 | BIN\C51.exe Main.c "OPTIMIZE (9)"
25 | BIN\C51.exe SPI.c "OPTIMIZE (9)"
26 | BIN\C51.exe UsbManager.c "OPTIMIZE (9)"
27 | BIN\LX51.exe Freqsys.OBJ,LCD.OBJ,Main.OBJ,SPI.OBJ,UsbManager.OBJ TO screen
28 | BIN\OHx51.exe screen
29 | mkdir build
30 | mv screen.hex build
31 | shell: powershell
32 | - name: Upload Artifact
33 | uses: actions/upload-artifact@v1.0.0
34 | with:
35 | name: Firmware
36 | path: ProjectCDC/Firmware/build
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Bootloader/CH552.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/Bootloader/CH552.h
--------------------------------------------------------------------------------
/ProjectCDC/Bootloader/UsbDescriptor.h:
--------------------------------------------------------------------------------
1 | #ifndef __USBDESCRIPTOR_H__
2 | #define __USBDESCRIPTOR_H__
3 |
4 | // 供应商和产品信息
5 | #define VendorId 0x1A86 // 供应商标识(VID)
6 | #define ProductId 0x5722 // 产品标识(PID)
7 | #define ReleaseNo 0x0100 // 发行版本(*.*.*.*)
8 | #define LSB(x) (x & 0xFF)
9 | #define MSB(x) ((x & 0xFF00) >> 8)
10 | #define VIDL LSB(VendorId) // Vendor Id Low Byte (LSB)
11 | #define VIDH MSB(VendorId) // Vendor Id High Byte (MSB)
12 | #define PIDL LSB(ProductId) // Product Id Low Byte (LSB)
13 | #define PIDH MSB(ProductId) // Product Id High Byte (MSB)
14 | #define REVL LSB(ReleaseNo) // Release Number Low Byte (LSB)
15 | #define REVH MSB(ReleaseNo) // Release Number High Byte (MSB)
16 |
17 | #define EP0SIZE 0x40 // 端点0数据包大小(只有8,16,32,64有效)
18 | #define EP1SIZE 0x08 // 端点1数据包大小
19 | #define EP2SIZE 0x40 // 端点2数据包大小
20 | #define EP3SIZE 0x40 // 端点3数据包大小
21 | #define EP4SIZE 0x40 // 端点4数据包大小
22 |
23 | // 设备描述符
24 | extern UINT8C DevReport[] = {
25 | 0x12, // 描述符长度,以字节为单位,固定为0x12
26 | 0x01, // 设备描述符类型,固定为0x01
27 | 0x00,0x02, // USB协议版本,低位在前; 如USB2.0=0x0200,USB1.1=0x0110等。
28 | 0x02, // 设备类(0x00表示设备独立分属不同的设备类;0x01-0xFE表示标准HID设备,0x02表示CDC,0x03表示HID;0xFF表示供应商自定义设备)
29 | 0x00, // 设备子类
30 | 0x00, // 设备协议(由USB分配).如果使用USB-IF组织定义的协议,就需要设置这里的值,否则直接设置为0。如果厂商自己定义的可以设置为FFH.
31 | EP0SIZE, // 端点0数据包大小(只有8,16,32,64有效)
32 | VIDL,VIDH, // Vendor ID; 供应商ID; 简称VID
33 | PIDL,PIDH, // Product ID; 产品ID; 简称PID
34 | REVL,REVH, // Device Release Version; 设备版本号; 简称Rev
35 | 0x01, // 厂商描述符字符串索引.若没有可为0
36 | 0x02, // 产品描述符字符串索引.若没有可为0
37 | 0x03, // 设备序列号字符串索引.若没有可为0
38 | 0x01 // USB设备支持的配置数.指配置描述符的个数
39 | };
40 | // 配置描述符
41 | extern UINT8C CfgReport[] =
42 | {
43 | // 配置描述符:配置描述符定义了设备的配置信息,一个设备可以有多个配置描述符
44 | 0x09, // 配置描述符长度.固定为0x09.
45 | 0x02, // 配置描述符类型.固定为0x02.
46 | 0x43, 0x00, // 配置描述符总长度(数据低位在前: 0x0043);
47 | 0x02, // 配置所支持的“接口数目”.也表示该配置下接口描述符数量.
48 | 0x01, // 这个配置的索引值
49 | 0x00, // 用于描述该配置字符串描述符的索引.
50 | 0x80, // 供电模式选择.Bit7:总线供电,Bit6:自供电,Bit5:远程唤醒,Bit4-0保留.
51 | 0xFA, // 总线供电的USB设备的最大消耗电流.以2mA为单位.(这里是2mA*0xFA=500mA)
52 |
53 | // 接口0描述符:接口描述符说明了接口所提供的配置,由配置描述符“接口数目”决定其数量
54 | 0x09, // 接口描述符长度.固定为0x09.
55 | 0x04, // 接口描述符类型.固定为0x04.
56 | 0x00, // 接口编号. 编号规则从0x00开始
57 | 0x00, // 备用编号. 用于为上一个字段选择可供替换的位置.
58 | 0x01, // 此接口使用的“端点数目”.不包括端点0.
59 | 0x02, // 主类型代码(由USB分配)
60 | 0x02, // 子类型代码(由USB分配)
61 | 0x01, // 协议代码(由USB分配)
62 | 0x00, // 字符串描述符的索引
63 | // 标头功能描述符 Header Functional Descriptor
64 | 0x05, // 描述符长度.固定为0x05.
65 | 0x24, // 主类型: CS_interface
66 | 0x00, // 子类型: 标题功能描述
67 | 0x10,0x01, // CDC协议版本: 规范发布号0x0110
68 | // 管理功能描述符 Call Management Functional Descriptor
69 | 0x05, // 描述符长度.固定为0x05.
70 | 0x24, // 主类型: CS_interface
71 | 0x01, // 子类型: 呼叫管理功能描述
72 | 0x00, // bm功能:D0+D1
73 | 0x00, // 数据接口:0 没有数据接口
74 | // ACM功能描述符
75 | 0x04, // 描述符长度.固定为0x04.
76 | 0x24, // 主类型: CS_interface
77 | 0x02, // 子类型: 抽象控件管理描述符
78 | 0x02, // 功能: (支持Set_Line_Coding、Set_Control_Line_State、Get_Line_Coding、Serial_State)
79 | // 联合功能描述符
80 | 0x05, // 描述符长度.固定为0x05.
81 | 0x24, // 主类型: CS_interface
82 | 0x06, // 子类型:
83 | 0x00, // 主接口: 编号为0的通讯类接口
84 | 0x01, // 从接口: 编号为1的数据类接口
85 | // 端点1描述符
86 | 0x07, // 描述符长度.固定为0x07.
87 | 0x05, // 描述符类型.固定为0x05.
88 | 0x81, // 端点地址(这里为上传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
89 | 0x03, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
90 | EP1SIZE, // 端点最大通信包长度(数据低位在前: 0x0008,单位Byte);
91 | 0x00,
92 | 0x01, // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
93 |
94 | // 接口1描述符
95 | 0x09, // 描述符长度.固定为0x09.
96 | 0x04, // 描述符类型.固定为0x04.
97 | 0x01, // 接口编号. 编号规则从0x00开始
98 | 0x00, // 备用编号. 用于为上一个字段选择可供替换的位置.
99 | 0x02, // 此接口使用的“端点数目”.
100 | 0x0A, // 主类型代码(这里表示CDC)
101 | 0x00, // 子类型代码
102 | 0x00, // 协议代码
103 | 0x00, // 字符串描述符的索引
104 | // 端点描述符
105 | 0x07, // 描述符长度.固定为0x07.
106 | 0x05, // 描述符类型.固定为0x05.
107 | 0x82, // 端点地址(这里为上传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
108 | 0x02, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
109 | EP2SIZE, // 端点最大通信包长度(数据低位在前: 0x0040,单位Byte);
110 | 0x00,
111 | 0x00, // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
112 | // 端点描述符
113 | 0x07, // 描述符长度.固定为0x07.
114 | 0x05, // 描述符类型.固定为0x05.
115 | 0x02, // 端点地址(这里为下传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
116 | 0x02, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
117 | EP2SIZE, // 端点最大通信包长度(数据低位在前: 0x0040,单位Byte);
118 | 0x00,
119 | 0x00 // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
120 | };
121 |
122 | /*以下内容为字符串描述符,用于描述设备接口的用途*/
123 | // 语言类型 (0x0409: U.S. English)
124 | UINT8C StrLangID[] = { 0x04, 0x03, 0x09, 0x04 };
125 | // 制造商 (注:因KeilC的UINT16是大端数据,所以要用联合体把UINT16字符转化成小端数据)
126 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[7]; } StrVendor = {
127 | sizeof(StrVendor),0x03,
128 | {'A','n','t','e','c','e','r'}};
129 | // 产品型号
130 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[12]; } StrProduct = {
131 | sizeof(StrProduct),0x03,
132 | {'U','s','b','S','c','r','e','e','n','I','S','P'}};
133 | // 产品序列号
134 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[20]; } StrSerial = {
135 | sizeof(StrSerial),0x03,
136 | {'S','T','1','E','6','D','I','P','S','F','0','F','0','S','P','I','3','I','S','P'}};
137 | // 将所有字符串描述符纳入一个指针数组
138 | PUINT8C StrReports[]={
139 | (PUINT8C)&StrLangID,
140 | (PUINT8C)&StrVendor,
141 | (PUINT8C)&StrProduct,
142 | (PUINT8C)&StrSerial
143 | };
144 |
145 | // CDC初始配置参数
146 | UINT8C LineCoding[7] = {
147 | 0x00,0x48,0x00,0x00, // 波特率: 19200 (数据低位在前0x4800)
148 | 0x00, // 停止位: 1 (可选 {1,1.5,2})
149 | 0x00, // 校验位: 无 (可选 {无,奇,偶,标志,空格})
150 | 0x08 // 数据位: 8 (可选 {0x04,0x05,0x06,0x07,0x08})
151 | };
152 | #define SET_LINE_CODING 0X20 // 主机写CDC配置命令
153 | #define GET_LINE_CODING 0X21 // 主机读CDC配置命令
154 | #define SET_LINE_STATE 0X22 // 主机写CDC状态
155 |
156 |
157 | #endif
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsbScreen", "UsbScreen\UsbScreen.csproj", "{0675F590-7E52-4213-95C8-F14D32E8A821}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0675F590-7E52-4213-95C8-F14D32E8A821}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {0675F590-7E52-4213-95C8-F14D32E8A821}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {0675F590-7E52-4213-95C8-F14D32E8A821}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {0675F590-7E52-4213-95C8-F14D32E8A821}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {A2272F17-16FB-43DD-A240-B44B34E59C71}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace UsbScreen
10 | {
11 | ///
12 | /// App.xaml 的交互逻辑
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Convert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Data;
8 |
9 | namespace UsbScreen
10 | {
11 | class Convert
12 | {
13 | }
14 |
15 | ///
16 | /// 打开串口
17 | ///
18 | [ValueConversion(typeof(bool), typeof(string))]
19 | public class ConnectOrDisconnect : IValueConverter
20 | {
21 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | if ((bool) value)
24 | return "断开";
25 | else
26 | return "连接";
27 | }
28 |
29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
30 | {
31 | throw new NotImplementedException();
32 | }
33 | }
34 |
35 | ///
36 | /// 启用插件
37 | ///
38 | [ValueConversion(typeof(bool), typeof(string))]
39 | public class EnableOrDisable : IValueConverter
40 | {
41 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
42 | {
43 | if ((bool)value)
44 | return "停用";
45 | else
46 | return "启用";
47 | }
48 |
49 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
50 | {
51 | throw new NotImplementedException();
52 | }
53 | }
54 |
55 | ///
56 | /// 反向bool
57 | ///
58 | [ValueConversion(typeof(bool), typeof(bool))]
59 | public class boolNot : IValueConverter
60 | {
61 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
62 | {
63 | return !(bool)value;
64 | }
65 |
66 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
67 | {
68 | return !(bool)value;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Interface/IScreen.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 |
3 | namespace UsbScreen.Interface
4 | {
5 | interface IScreen
6 | {
7 | ///
8 | /// 使用指定的宽高初始化插件
9 | ///
10 | /// 画布宽度
11 | /// 画布高度
12 | void InitializeComponent(int width, int height);
13 |
14 | ///
15 | /// 获取插件数据
16 | ///
17 | /// 图片,开始位置(x,y),下次刷新等待时间
18 | (Bitmap pic,int x,int y,long next) GetData();
19 |
20 | ///
21 | /// 停用插件
22 | ///
23 | ///
24 | void Dispose();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Models/Plugin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Reflection;
8 | using System.Timers;
9 |
10 | namespace UsbScreen.Models
11 | {
12 | class IPlugin
13 | {
14 | ///
15 | /// 插件路径
16 | ///
17 | public string Dir { get; set; } = null;
18 | ///
19 | /// 插件名称(文件名)
20 | ///
21 | public string Name{ get{ return Dir.Split('\\').Last(); } }
22 | ///
23 | /// 对象引用到插件
24 | ///
25 | public object Plugin { get; set; } = null;
26 |
27 | public Type PluginType { get; set; }
28 | ///
29 | /// 初始化插件
30 | ///
31 | public bool Init()
32 | {
33 | PluginType.GetMethod("InitializeComponent").Invoke(Plugin, new object[] { 240, 240 });
34 | return true;
35 | }
36 | ///
37 | /// 获取插件数据
38 | ///
39 | public ValueTuple GetData()
40 | {
41 | return (ValueTuple)PluginType.GetMethod("GetData").Invoke(Plugin, null);
42 | }
43 | ///
44 | /// 释放插件资源
45 | ///
46 | public void Dispose()
47 | {
48 | PluginType.GetMethod("Dispose").Invoke(Plugin, null);
49 | }
50 |
51 | }
52 |
53 | [PropertyChanged.AddINotifyPropertyChangedInterface]
54 | class Plugin
55 | {
56 | ///
57 | /// 待操作的屏幕对象
58 | ///
59 | public SerialScreen screen { get; set; }
60 | ///
61 | /// 是否已启用了某插件?
62 | ///
63 | public bool IsEnable { get; set; } = false;
64 | ///
65 | /// 保存已加载的插件
66 | ///
67 | private List IPlugins = new List();
68 | ///
69 | /// 保存当前已启用插件的索引
70 | ///
71 | private int PIndex { get; set; } = -1;
72 | ///
73 | /// 插件访问定时器
74 | ///
75 | private readonly Timer PluginTimer = new Timer();
76 |
77 | public Plugin()
78 | {
79 | PluginTimer.AutoReset = false;
80 | PluginTimer.Elapsed += delegate
81 | {
82 | PluginTimer.Stop();
83 | if (!IsEnable) return;
84 | try
85 | {
86 | (Bitmap pic, int x, int y, long next) = IPlugins[PIndex].GetData();
87 | screen?.Show(pic, x, y);
88 | PluginTimer.Interval = next;
89 | PluginTimer.Start(); // 准备获取下一帧数据
90 | }
91 | catch (Exception e)
92 | {
93 | ErrorLogger(e.ToString());
94 | Debug.Print(e.Message);
95 | }
96 |
97 | };
98 | }
99 |
100 | public static string[] GetPluginList()
101 | {
102 | return Directory.GetFiles("plugin", "*.dll");
103 | }
104 |
105 | public static void ErrorLogger(string err)
106 | {
107 | File.AppendAllText("error_log.txt", $"{DateTime.Now:[yyyy-MM-dd HH:mm:ss:ffff]}\r\n{err}\r\n\r\n");
108 | }
109 |
110 | public bool EnablePlugin(string path)
111 | {
112 | path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
113 | // 判断插件是否已加载
114 | if (IPlugins.Count > 0)
115 | {
116 | PIndex = IPlugins.FindIndex(p => p.Dir == path);
117 | if (PIndex > -1)
118 | {
119 | PluginTimer.Interval = 1;
120 | PluginTimer.Start();
121 | IsEnable = true;
122 | return true;
123 | }
124 | }
125 | // 插件在加载前被删除了
126 | if (!File.Exists(path)) return false;
127 | // 加载新插件
128 | Assembly ass = Assembly.Load(File.ReadAllBytes(path));
129 | foreach (Type t in ass.GetExportedTypes())
130 | {
131 | if(t.GetInterface("IScreen") != null)
132 | {
133 | IPlugin newPlugin = new IPlugin
134 | {
135 | Plugin = ass.CreateInstance(t.FullName),
136 | PluginType = t,
137 | Dir = path
138 | };
139 | PIndex = IPlugins.Count;
140 | IPlugins.Add(newPlugin);
141 | }
142 | }
143 |
144 | if (PIndex > -1)
145 | {
146 | try
147 | {
148 | IPlugins[PIndex].Init();
149 | PluginTimer.Interval = 1;
150 | PluginTimer.Start();
151 | IsEnable = true;
152 | Debug.Print($"[插件加载成功] {IPlugins[PIndex].Name} Is Enabled");
153 | return true;
154 | }
155 | catch (Exception e)
156 | {
157 | IPlugins.RemoveAt(PIndex);
158 | Debug.Print($"[插件加载失败] {IPlugins[PIndex].Name} Is Enable Failed");
159 | ErrorLogger(e.ToString());
160 | Debug.Print(e.Message);
161 | }
162 |
163 | }
164 | PIndex = -1;
165 | return false;
166 | }
167 |
168 | public void Disable()
169 | {
170 | IPlugins[PIndex].Dispose(); // 伪卸载插件(其实还是在内存里面,只是为了能够加载更新的DLL文件)
171 | IPlugins.RemoveAt(PIndex);
172 | IsEnable = false;
173 | PIndex = -1;
174 | PluginTimer.Stop();
175 | }
176 | }
177 | }
178 |
179 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Models/Setting.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace UsbScreen.Models
10 | {
11 | [PropertyChanged.AddINotifyPropertyChangedInterface]
12 | class Setting
13 | {
14 | ///
15 | /// 保存配置
16 | ///
17 | private void Save()
18 | {
19 | File.WriteAllText("settings.json", JsonConvert.SerializeObject(this));
20 | }
21 |
22 | private string _lastPort = "";
23 | ///
24 | /// 上次使用的串口
25 | ///
26 | public string LastPort
27 | {
28 | get => _lastPort;
29 | set
30 | {
31 | _lastPort = value;
32 | Save();
33 | }
34 | }
35 |
36 | private string _lastPlugin = "";
37 | ///
38 | /// 上次使用的插件
39 | ///
40 | public string LastPlugin
41 | {
42 | get => _lastPlugin;
43 | set
44 | {
45 | _lastPlugin = value;
46 | Save();
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("UsbScreen")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("HP Inc.")]
14 | [assembly: AssemblyProduct("UsbScreen")]
15 | [assembly: AssemblyCopyright("Copyright © HP Inc. 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52 | //通过使用 "*",如下所示:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UsbScreen.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UsbScreen.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UsbScreen.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/UsbScreen/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Aida64Info/Aida64Info.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.3.32804.467
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aida64Info", "Aida64Info\Aida64Info.csproj", "{3B2328FE-973E-4751-B5A9-0BCA6C03360E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {417C0C86-1029-4E67-B554-55F31017CD06}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Aida64Info/Aida64Info/Aida64Info.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 8.0
6 | enable
7 | enable
8 | Debug
9 | AnyCPU
10 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}
11 | Library
12 | Properties
13 | Aida64Info
14 | Aida64Info
15 | v4.7.2
16 | 512
17 | true
18 |
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | set WORKDIR=$(SolutionDir)
56 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
57 | set PluginEXE=$(TargetFileName)
58 | set ClientDIR=UsbScreen\bin\Debug\plugin\
59 | cd %25WORKDIR%25
60 | cd ../../
61 | if exist UsbScreen\ (
62 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
63 | )
64 |
65 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Aida64Info/Aida64Info/Class.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/Client/plugins/Aida64Info/Aida64Info/Class.cs
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Aida64Info/Aida64Info/IScreen.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 |
3 | namespace Aida64Info
4 | {
5 | interface IScreen
6 | {
7 | ///
8 | /// 使用指定的宽高初始化插件
9 | ///
10 | /// 画布宽度
11 | /// 画布高度
12 | void InitializeComponent(int width, int height);
13 |
14 | ///
15 | /// 获取插件数据
16 | ///
17 | /// 图片,开始位置(x,y),下次刷新等待时间
18 | (Bitmap pic, int x, int y, long next) GetData();
19 |
20 | ///
21 | /// 停用插件
22 | ///
23 | ///
24 | void Dispose();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Aida64Info/Aida64Info/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Aida64Info")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Aida64Info")]
13 | [assembly: AssemblyCopyright("Copyright © Antecer 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("3b2328fe-973e-4751-b5a9-0bca6c03360e")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Clock/Clock.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clock", "Clock\Clock.csproj", "{3B2328FE-973E-4751-B5A9-0BCA6C03360E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {417C0C86-1029-4E67-B554-55F31017CD06}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Clock/Clock/Class.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/Client/plugins/Clock/Clock/Class.cs
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Clock/Clock/Clock.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {3B2328FE-973E-4751-B5A9-0BCA6C03360E}
8 | Library
9 | Properties
10 | Clock
11 | Clock
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | set WORKDIR=$(SolutionDir)
53 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
54 | set PluginEXE=$(TargetFileName)
55 | set ClientDIR=UsbScreen\bin\Debug\plugin\
56 | cd %25WORKDIR%25
57 | cd ../../
58 | if exist UsbScreen\ (
59 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
60 | )
61 |
62 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Clock/Clock/IScreen.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 |
3 | namespace Clock
4 | {
5 | interface IScreen
6 | {
7 | ///
8 | /// 使用指定的宽高初始化插件
9 | ///
10 | /// 画布宽度
11 | /// 画布高度
12 | void InitializeComponent(int width, int height);
13 |
14 | ///
15 | /// 获取插件数据
16 | ///
17 | /// 图片,开始位置(x,y),下次刷新等待时间
18 | (Bitmap pic, int x, int y, long next) GetData();
19 |
20 | ///
21 | /// 停用插件
22 | ///
23 | ///
24 | void Dispose();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/Clock/Clock/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("Clock")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HP Inc.")]
12 | [assembly: AssemblyProduct("Clock")]
13 | [assembly: AssemblyCopyright("Copyright © HP Inc. 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("3b2328fe-973e-4751-b5a9-0bca6c03360e")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalog0/ClockAnalog0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30615.102
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockAnalog0", "ClockAnalog0\ClockAnalog0.csproj", "{4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {CD20E777-643C-439E-98C0-DC8633DB7509}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalog0/ClockAnalog0/ClockAnalog0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {4B73B52D-1A1A-453A-A583-CE4C7CA40CFA}
8 | Library
9 | Properties
10 | ClockAnalog0
11 | ClockAnalog0
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | set WORKDIR=$(SolutionDir)
51 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
52 | set PluginEXE=$(TargetFileName)
53 | set ClientDIR=UsbScreen\bin\Debug\plugin\
54 | cd %25WORKDIR%25
55 | cd ../../
56 | if exist UsbScreen\ (
57 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
58 | )
59 |
60 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalog0/ClockAnalog0/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ClockAnalog0")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ClockAnalog0")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("4b73b52d-1a1a-453a-a583-ce4c7ca40cfa")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalogDigital0/ClockAnalogDigital0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30615.102
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockAnalogDigital0", "ClockAnalogDigital0\ClockAnalogDigital0.csproj", "{42323271-2BD9-4B75-81DD-E4D005384F6F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {42323271-2BD9-4B75-81DD-E4D005384F6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {42323271-2BD9-4B75-81DD-E4D005384F6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {42323271-2BD9-4B75-81DD-E4D005384F6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {42323271-2BD9-4B75-81DD-E4D005384F6F}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {2D4A8BE0-A061-4765-A982-B510F637B0E5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalogDigital0/ClockAnalogDigital0/ClockAnalogDigital0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {42323271-2BD9-4B75-81DD-E4D005384F6F}
8 | Library
9 | Properties
10 | ClockAnalogDigital0
11 | ClockAnalogDigital0
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | set WORKDIR=$(SolutionDir)
51 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
52 | set PluginEXE=$(TargetFileName)
53 | set ClientDIR=UsbScreen\bin\Debug\plugin\
54 | cd %25WORKDIR%25
55 | cd ../../
56 | if exist UsbScreen\ (
57 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
58 | )
59 |
60 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockAnalogDigital0/ClockAnalogDigital0/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ClockAnalogDigital0")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ClockAnalogDigital0")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("42323271-2bd9-4b75-81dd-e4d005384f6f")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockMechanical0/ClockMechanical0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30615.102
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockMechanical0", "ClockMechanical0\ClockMechanical0.csproj", "{E58FD023-8128-4D33-B91D-39CB518B9E6B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {E58FD023-8128-4D33-B91D-39CB518B9E6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {E58FD023-8128-4D33-B91D-39CB518B9E6B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {E58FD023-8128-4D33-B91D-39CB518B9E6B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {E58FD023-8128-4D33-B91D-39CB518B9E6B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {EB1CB306-DB30-4CCA-8706-3574DDBF6F14}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockMechanical0/ClockMechanical0/ClockMechanical0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E58FD023-8128-4D33-B91D-39CB518B9E6B}
8 | Library
9 | Properties
10 | ClockMechanical0
11 | ClockMechanical0
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | set WORKDIR=$(SolutionDir)
51 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
52 | set PluginEXE=$(TargetFileName)
53 | set ClientDIR=UsbScreen\bin\Debug\plugin\
54 | cd %25WORKDIR%25
55 | cd ../../
56 | if exist UsbScreen\ (
57 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
58 | )
59 |
60 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockMechanical0/ClockMechanical0/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ClockMechanical0")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ClockMechanical0")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("e58fd023-8128-4d33-b91d-39cb518b9e6b")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockTheme/ClockTheme.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30615.102
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockTheme", "ClockTheme\ClockTheme.csproj", "{B4751C58-F16F-4851-B56E-D6CA66BAED27}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B4751C58-F16F-4851-B56E-D6CA66BAED27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B4751C58-F16F-4851-B56E-D6CA66BAED27}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B4751C58-F16F-4851-B56E-D6CA66BAED27}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B4751C58-F16F-4851-B56E-D6CA66BAED27}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {80262164-5DF7-48EA-9482-732018552EBB}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockTheme/ClockTheme/ClockTheme.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B4751C58-F16F-4851-B56E-D6CA66BAED27}
8 | Library
9 | Properties
10 | ClockTheme
11 | ClockTheme
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | set WORKDIR=$(SolutionDir)
54 | set PluginDIR=plugins\$(ProjectName)\$(TargetName)\$(OutDir)
55 | set PluginEXE=$(TargetFileName)
56 | set ClientDIR=UsbScreen\bin\Debug\plugin\
57 | cd %25WORKDIR%25
58 | cd ../../
59 | if exist UsbScreen\ (
60 | copy %25PluginDIR%25%25PluginEXE%25 %25ClientDIR%25
61 | )
62 |
63 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockTheme/ClockTheme/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ClockTheme")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ClockTheme")]
13 | [assembly: AssemblyCopyright("Copyright © 2020")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("b4751c58-f16f-4851-b56e-d6ca66baed27")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ProjectCDC/Client/plugins/ClockTheme/ClockTheme/Resources/ReadMe.md:
--------------------------------------------------------------------------------
1 | Version_1.0
2 |
3 | StackingOrder(堆叠顺序) must use png:
4 | Background.png
5 | Backdrop.png
6 | Dial.png
7 | Pointer_Hour.png
8 | Pointer_Minute.png
9 | Pointer_Second.png
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/CH552.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/Firmware/CH552.h
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/Freqsys.c:
--------------------------------------------------------------------------------
1 | /********************************** (C) COPYRIGHT ******************************
2 | * File Name : Freqsys
3 | * Author : Antecer
4 | * Version : V1.0
5 | * Date : 2020年10月09日
6 | * Description : 单片机频率系统定义
7 | *******************************************************************************/
8 | #include "CH552.h"
9 | #include "Freqsys.h"
10 |
11 | /*******************************************************************************
12 | * Function Name : SetFsys
13 | * Description : 设置系统时钟频率
14 | * Info : 内核时钟12MHz
15 | : PLL倍频=96MHz
16 | : USB时钟分频器=48MHz (USB模块FullSpeed模式需要48MHz频率)
17 | : 系统时钟分频器=24MHz
18 | *******************************************************************************/
19 | void setFsys(void)
20 | {
21 | SAFE_MOD = 0x55; //解锁安全模式
22 | SAFE_MOD = 0xAA;
23 | CLOCK_CFG = 0x86; //系统时钟分频器4分频=24MHz
24 | }
25 | /*******************************************************************************
26 | * Function Name : mDelayus(UNIT16 n)
27 | * Description : us延时函数
28 | * Input : UNIT16 n
29 | *******************************************************************************/
30 | void mDelayuS(UINT16 n)
31 | {
32 | while (n)
33 | {
34 | ++SAFE_MOD;
35 | --n;
36 | }
37 | }
38 | /*******************************************************************************
39 | * Function Name : mDelayms(UNIT16 n)
40 | * Description : ms延时函数
41 | * Input : UNIT16 n
42 | *******************************************************************************/
43 | void mDelaymS(UINT16 n)
44 | {
45 | while (n)
46 | {
47 | mDelayuS(1000);
48 | --n;
49 | }
50 | }
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/Freqsys.h:
--------------------------------------------------------------------------------
1 | #ifndef __FREQSYS_H__
2 | #define __FREQSYS_H__
3 |
4 | extern void setFsys(void);
5 | extern void mDelayuS(UINT16 n);
6 | extern void mDelaymS(UINT16 n);
7 |
8 | #endif
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/LCD.h:
--------------------------------------------------------------------------------
1 | #ifndef __LCD_H__
2 | #define __LCD_H__
3 |
4 | sbit LCD_RES = P3 ^ 2; // LCD复位
5 | sbit LCD_BLK = P3 ^ 4; // LCD背光控制开关
6 |
7 | extern LCD_BUFF;
8 |
9 | extern void LCD_Init(void);
10 | extern void LCD_SET(PUINT8X addr);
11 | #endif
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/Main.c:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include "CH552.h"
4 | #include "Freqsys.h"
5 |
6 | #include "LCD.h"
7 | #include "UsbManager.h"
8 |
9 | sbit K1 = P3^0;
10 | sbit K2 = P1^1;
11 | sbit K3 = P3^3;
12 |
13 | /*******************************************************************************
14 | * Function Name : IOport_Init
15 | * Description : IO口默认状态配置位
16 | * Input : None
17 | * Return : None
18 | *******************************************************************************/
19 | void IOport_Init(void)
20 | {
21 | LCD_BLK = 0;
22 | while(USB_DEV_AD==0);
23 | LCD_BLK = 1;
24 | P3 = 0xFF;
25 | P1 = 0xFF;
26 | }
27 |
28 | /*******************************************************************************
29 | * Function Name : PWM_Init
30 | * Description : PWM初始化(PWM2输出引脚为P3.4)
31 | * Input : None
32 | * Return : None
33 | *******************************************************************************/
34 | void PWM_Init()
35 | {
36 | PWM_CK_SE = 0x01; // PWM时钟分频设置
37 | PWM_DATA2 = 0x7F; // PWM2占空比设置(占空比=PWM_DATA2/256)
38 | PWM_CTRL = bPWM2_OUT_EN; // PWM2输出使能
39 | }
40 |
41 | /*******************************************************************************
42 | * Function Name : main
43 | * Description : 主函数
44 | * Input : None
45 | * Return : None
46 | *******************************************************************************/
47 | void main(void)
48 | {
49 | setFsys(); // 初始化系统时钟
50 | PWM_Init(); // 初始化PWM功能
51 | USB_DeviceInit(); // 初始化USB功能
52 | EA = 1; // 使能单片机全局中断
53 | IOport_Init(); // 初始化IO口状态
54 | LCD_Init(); // 初始化LCD屏幕
55 | while(1)
56 | {
57 | if(DMA_STATUS & 0x01)
58 | {
59 | ROM_DATA_H = DMA_STATUS&0x10;
60 | LCD_SET(Ep3Buffer);
61 | DMA_STATUS &= (~0x11);
62 | if((UDEV_CTRL&bUD_GP_BIT) == 0)
63 | {
64 | UEP3_CTRL = UEP3_CTRL & ~MASK_UEP_R_RES | UEP_R_RES_ACK;
65 | }
66 | }
67 | else if(DMA_STATUS & 0x02)
68 | {
69 | ROM_DATA_H = DMA_STATUS&0x20;
70 | LCD_SET(Ep4Buffer);
71 | DMA_STATUS &= (~0x22);
72 | if((UDEV_CTRL&bUD_GP_BIT) != 0)
73 | {
74 | UEP3_CTRL = UEP3_CTRL & ~MASK_UEP_R_RES | UEP_R_RES_ACK;
75 | }
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/SPI.c:
--------------------------------------------------------------------------------
1 | /********************************** (C) COPYRIGHT ******************************
2 | * File Name : SPI
3 | * Author : Antecer
4 | * Version : V1.0
5 | * Date : 2020年10月09日
6 | * Description : SPI读写函数
7 | *******************************************************************************/
8 | #include "CH552.h"
9 | #include "SPI.h"
10 |
11 | /*******************************************************************************
12 | * Function Name : SPI_Send_DAT(UINT8 dat)
13 | * Description : 软件SPI写数据
14 | * Input : UINT8 dat
15 | *******************************************************************************/
16 | void SPI_Send_DAT(UINT8 dat)
17 | {
18 | static UINT8 i;
19 | for (i = 0x80; i; i >>= 1)
20 | {
21 | SPI_SDA = dat & i;
22 | SPI_SCL = 0;
23 | SPI_SCL = 1;
24 | }
25 | }
26 | /*******************************************************************************
27 | * Function Name : SPI_Send_CMD(UINT8 cmd)
28 | * Description : 软件SPI写命令
29 | * Input : UINT8 cmd
30 | *******************************************************************************/
31 | void SPI_Send_CMD(UINT8 cmd)
32 | {
33 | SPI_DC = 0; // 写命令
34 | SPI_Send_DAT(cmd);
35 | SPI_DC = 1; // 写数据
36 | }
37 | /*******************************************************************************
38 | * Function Name : SPI_Init(void)
39 | * Description : 初始化SPI总线
40 | * Input : None
41 | * Return : None
42 | *******************************************************************************/
43 | //void SPI_Init(void)
44 | //{
45 | // P1_DIR_PU = 0x1F; // 第7,6,5位禁用上拉(注意需要外接3.3V弱上拉10K电阻)
46 | // SPI0_CK_SE = 0x02; // 分频系数2,SPI频率=Fsys/2
47 | // SPI0_SETUP = 0x00; // 主机模式,关中断,高位在前(默认)
48 | //}
49 | /*******************************************************************************
50 | * Function Name : SPI_Mode(UINT8 mod)
51 | * Description : 硬件SPI模式配置(0x60模式0;0x68模式1;0x02关闭硬件SPI)
52 | * Input : UINT8 mod
53 | * Return : None
54 | *******************************************************************************/
55 | //void SPI_Mode(UINT8 mod)
56 | //{
57 | // SPI0_CTRL = mod;
58 | //}
59 | /*******************************************************************************
60 | * Function Name : SPI_SendDAT(UINT8 dat)
61 | * Description : 硬件SPI写数据(主机模式)
62 | * Input : UINT8 dat
63 | * Return : None
64 | *******************************************************************************/
65 | //void SPI_SendDAT(UINT8 dat)
66 | //{
67 | // SPI0_DATA = dat;
68 | // while (S0_FREE == 0); //等待传输完成
69 | //}
70 | /*******************************************************************************
71 | * Function Name : SPI_SendCMD(UINT8 cmd)
72 | * Description : 硬件SPI写命令(主机模式)
73 | * Input : UINT8 cmd
74 | * Return : None
75 | *******************************************************************************/
76 | //void SPI_SendCMD(UINT8 cmd)
77 | //{
78 | // SPI_DC = 0; // 写命令
79 | // SPI_SendDAT(cmd);
80 | // SPI_DC = 1; // 写数据
81 | //}
82 |
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/SPI.h:
--------------------------------------------------------------------------------
1 | #ifndef __SPI_H__
2 | #define __SPI_H__
3 |
4 | sbit SPI_DC = P3^1; // 数据&命令(低电平写命令,高电平写数据)
5 | sbit SPI_CS = P1^4; // 片选;低电平有效
6 | sbit SPI_SCL = P1^7; // SPI时钟
7 | sbit SPI_SDA = P1^5; // SPI数据(MOSI)
8 |
9 | // 初始化SPI总线<注意需要对总线进行外部消除干扰处理>
10 | #ifndef SPI_INIT
11 | #define SPI_INIT(); {SPI0_CK_SE=0x02;}
12 | #endif
13 |
14 | // 硬件SPI模式配置(0x60模式0;0x68模式1;0x02关闭硬件SPI)
15 | #ifndef SPI_MODE
16 | #define SPI_MODE(x); SPI0_CTRL=(x);
17 | #endif
18 |
19 | // 硬件SPI写1Byte数据
20 | #ifndef SPI_DAT
21 | #define SPI_DAT(x); {while(S0_FREE==0);SPI_DC=1;SPI0_DATA=(x);}
22 | #endif
23 |
24 | // 硬件SPI写1Byte命令
25 | #ifndef SPI_CMD
26 | #define SPI_CMD(x); {while(S0_FREE==0);SPI_DC=0;SPI0_DATA=(x);}
27 | #endif
28 |
29 | // 软件SPI写1Byte数据
30 | extern void SPI_Send_DAT(UINT8 dat);
31 | // 软件SPI写1Byte命令
32 | extern void SPI_Send_CMD(UINT8 cmd);
33 |
34 | #endif
35 |
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/UsbDescriptor.h:
--------------------------------------------------------------------------------
1 | #ifndef __USBDESCRIPTOR_H__
2 | #define __USBDESCRIPTOR_H__
3 |
4 | // 供应商和产品信息
5 | #define VendorId 0x1A86 // 供应商标识(VID)
6 | #define ProductId 0x5722 // 产品标识(PID)
7 | #define ReleaseNo 0x0100 // 发行版本(*.*.*.*)
8 | #define LSB(x) (x & 0xFF)
9 | #define MSB(x) ((x & 0xFF00) >> 8)
10 | #define VIDL LSB(VendorId) // Vendor Id Low Byte (LSB)
11 | #define VIDH MSB(VendorId) // Vendor Id High Byte (MSB)
12 | #define PIDL LSB(ProductId) // Product Id Low Byte (LSB)
13 | #define PIDH MSB(ProductId) // Product Id High Byte (MSB)
14 | #define REVL LSB(ReleaseNo) // Release Number Low Byte (LSB)
15 | #define REVH MSB(ReleaseNo) // Release Number High Byte (MSB)
16 |
17 | #define EP0SIZE 0x40 // 端点0数据包大小(只有8,16,32,64有效)
18 | #define EP1SIZE 0x08 // 端点1数据包大小
19 | #define EP2SIZE 0x40 // 端点2数据包大小
20 | #define EP3SIZE 0x40 // 端点3数据包大小
21 | #define EP4SIZE 0x40 // 端点4数据包大小
22 |
23 | // 设备描述符
24 | extern UINT8C DevReport[] = {
25 | 0x12, // 描述符长度,以字节为单位,固定为0x12
26 | 0x01, // 设备描述符类型,固定为0x01
27 | 0x00,0x02, // USB协议版本,低位在前; 如USB2.0=0x0200,USB1.1=0x0110等。
28 | 0x02, // 设备类(0x00表示设备独立分属不同的设备类;0x01-0xFE表示标准HID设备,0x02表示CDC,0x03表示HID;0xFF表示供应商自定义设备)
29 | 0x00, // 设备子类
30 | 0x00, // 设备协议(由USB分配).如果使用USB-IF组织定义的协议,就需要设置这里的值,否则直接设置为0。如果厂商自己定义的可以设置为FFH.
31 | EP0SIZE, // 端点0数据包大小(只有8,16,32,64有效)
32 | VIDL,VIDH, // Vendor ID; 供应商ID; 简称VID
33 | PIDL,PIDH, // Product ID; 产品ID; 简称PID
34 | REVL,REVH, // Device Release Version; 设备版本号; 简称Rev
35 | 0x01, // 厂商描述符字符串索引.若没有可为0
36 | 0x02, // 产品描述符字符串索引.若没有可为0
37 | 0x03, // 设备序列号字符串索引.若没有可为0
38 | 0x01 // USB设备支持的配置数.指配置描述符的个数
39 | };
40 | // 配置描述符
41 | extern UINT8C CfgReport[] =
42 | {
43 | // 配置描述符:配置描述符定义了设备的配置信息,一个设备可以有多个配置描述符
44 | 0x09, // 配置描述符长度.固定为0x09.
45 | 0x02, // 配置描述符类型.固定为0x02.
46 | 0x43, 0x00, // 配置描述符总长度(数据低位在前: 0x0043);
47 | 0x02, // 配置所支持的“接口数目”.也表示该配置下接口描述符数量.
48 | 0x01, // 这个配置的索引值
49 | 0x00, // 用于描述该配置字符串描述符的索引.
50 | 0xA0, // 供电模式选择.Bit7:总线供电,Bit6:自供电,Bit5:远程唤醒,Bit4-0保留.
51 | 0xFA, // 总线供电的USB设备的最大消耗电流.以2mA为单位.(这里是2mA*0xFA=500mA)
52 |
53 | // 接口0描述符:接口描述符说明了接口所提供的配置,由配置描述符“接口数目”决定其数量
54 | 0x09, // 接口描述符长度.固定为0x09.
55 | 0x04, // 接口描述符类型.固定为0x04.
56 | 0x00, // 接口编号. 编号规则从0x00开始
57 | 0x00, // 备用编号. 用于为上一个字段选择可供替换的位置.
58 | 0x01, // 此接口使用的“端点数目”.不包括端点0.
59 | 0x02, // 主类型代码(由USB分配)
60 | 0x02, // 子类型代码(由USB分配)
61 | 0x01, // 协议代码(由USB分配)
62 | 0x00, // 字符串描述符的索引
63 | // 标头功能描述符 Header Functional Descriptor
64 | 0x05, // 描述符长度.固定为0x05.
65 | 0x24, // 主类型: CS_interface
66 | 0x00, // 子类型: 标题功能描述
67 | 0x10,0x01, // CDC协议版本: 规范发布号0x0110
68 | // 管理功能描述符 Call Management Functional Descriptor
69 | 0x05, // 描述符长度.固定为0x05.
70 | 0x24, // 主类型: CS_interface
71 | 0x01, // 子类型: 呼叫管理功能描述
72 | 0x00, // bm功能:D0+D1
73 | 0x00, // 数据接口:0 没有数据接口
74 | // ACM功能描述符
75 | 0x04, // 描述符长度.固定为0x04.
76 | 0x24, // 主类型: CS_interface
77 | 0x02, // 子类型: 抽象控件管理描述符
78 | 0x02, // 功能: (支持Set_Line_Coding、Set_Control_Line_State、Get_Line_Coding、Serial_State)
79 | // 联合功能描述符
80 | 0x05, // 描述符长度.固定为0x05.
81 | 0x24, // 主类型: CS_interface
82 | 0x06, // 子类型:
83 | 0x00, // 主接口: 编号为0的通讯类接口
84 | 0x01, // 从接口: 编号为1的数据类接口
85 | // 端点1描述符
86 | 0x07, // 描述符长度.固定为0x07.
87 | 0x05, // 描述符类型.固定为0x05.
88 | 0x81, // 端点地址(这里为上传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
89 | 0x03, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
90 | EP1SIZE, // 端点最大通信包长度(数据低位在前: 0x0008,单位Byte);
91 | 0x00,
92 | 0xFF, // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
93 |
94 | // 接口1描述符
95 | 0x09, // 描述符长度.固定为0x09.
96 | 0x04, // 描述符类型.固定为0x04.
97 | 0x01, // 接口编号. 编号规则从0x00开始
98 | 0x00, // 备用编号. 用于为上一个字段选择可供替换的位置.
99 | 0x02, // 此接口使用的“端点数目”.
100 | 0x0A, // 主类型代码(这里表示CDC)
101 | 0x00, // 子类型代码
102 | 0x00, // 协议代码
103 | 0x00, // 字符串描述符的索引
104 | // 端点描述符
105 | 0x07, // 描述符长度.固定为0x07.
106 | 0x05, // 描述符类型.固定为0x05.
107 | 0x82, // 端点地址(这里为上传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
108 | 0x02, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
109 | EP2SIZE, // 端点最大通信包长度(数据低位在前: 0x0040,单位Byte);
110 | 0x00,
111 | 0x00, // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
112 | // 端点描述符
113 | 0x07, // 描述符长度.固定为0x07.
114 | 0x05, // 描述符类型.固定为0x05.
115 | 0x03, // 端点地址(这里为下传端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
116 | 0x02, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
117 | EP3SIZE, // 端点最大通信包长度(数据低位在前: 0x0040,单位Byte);
118 | 0x00,
119 | 0x00 // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms)
120 | };
121 |
122 | /*以下内容为字符串描述符,用于描述设备接口的用途*/
123 | // 语言类型 (0x0409: U.S. English)
124 | UINT8C StrLangID[] = { 0x04, 0x03, 0x09, 0x04 };
125 | // 制造商 (注:因KeilC的UINT16是大端数据,所以要用联合体把UINT16字符转化成小端数据)
126 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[7]; } StrVendor = {
127 | sizeof(StrVendor),0x03,
128 | {'A','n','t','e','c','e','r'}};
129 | // 产品型号
130 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[9]; } StrProduct = {
131 | sizeof(StrProduct),0x03,
132 | {'U','s','b','S','c','r','e','e','n'}};
133 | // 产品序列号
134 | code struct { UINT8 bLength; UINT8 bDscType; union{UINT8 b;UINT16 w;} string[17]; } StrSerial = {
135 | sizeof(StrSerial),0x03,
136 | {'S','T','1','E','6','D','I','P','S','F','0','F','0','S','P','I','3'}};
137 | // 将所有字符串描述符纳入一个指针数组
138 | PUINT8C StrReports[]={
139 | (PUINT8C)&StrLangID,
140 | (PUINT8C)&StrVendor,
141 | (PUINT8C)&StrProduct,
142 | (PUINT8C)&StrSerial
143 | };
144 |
145 | // CDC初始配置参数
146 | UINT8C LineCoding[7] = {
147 | 0x00,0x00,0x00,0x06, // 波特率: 12M (数据低位在前0x06000000)
148 | 0x00, // 停止位: 1 (可选 {1,1.5,2})
149 | 0x00, // 校验位: 无 (可选 {无,奇,偶,标志,空格})
150 | 0x08 // 数据位: 8 (可选 {0x04,0x05,0x06,0x07,0x08})
151 | };
152 | #define SET_LINE_CODING 0X20 // 主机写CDC配置命令
153 | #define GET_LINE_CODING 0X21 // 主机读CDC配置命令
154 | #define SET_LINE_STATE 0X22 // 主机写CDC状态
155 |
156 |
157 | #endif
--------------------------------------------------------------------------------
/ProjectCDC/Firmware/UsbManager.h:
--------------------------------------------------------------------------------
1 | #ifndef __USBMANAGER_H__
2 | #define __USBMANAGER_H__
3 |
4 | #ifndef ROM_CMD_PROG
5 | #define ROM_CMD_PROG 0x9A // 定义Flash写入命令
6 | #endif
7 |
8 | #define ROM_STATUS_RECODE ROM_STATUS^0x40 // 重定义Flash操作结果返回码(551系列最高位默认为0,558系列最高位默认为1)
9 | #define IAP_CODE_ADDR (0x2800-1024*2) // IAP程序起始地址,该地址至少比实际的IAP地址小4byte且最好为1KB对齐
10 | #define ChipIdData0 (*(PUINT8C)(0x3FFC)) // ChipID最低字节
11 | #define ChipIdData1 (*(PUINT8C)(0x3FFD)) // ChipID次低字节
12 | #define ChipIdData2 (*(PUINT8C)(0x3FFE)) // ChipID次高字节
13 | #define ChipIdData3 (*(PUINT8C)(0x3FFF)) // ChipID 高字节
14 | #define ChipIdData4 (*(PUINT8C)(0x3FFB)) // ChipID保留
15 | #define ChipIdData5 (*(PUINT8C)(0x3FFA)) // ChipID最高字节
16 |
17 | // USB数据缓冲区结构体{EP0[0x40],EP1[0x40],EP2[0x40],EP3[0x80]}
18 | typedef struct _UsbBuffer{
19 | UINT8 EP0[0x40]; // 端点0 OUT&IN 64byte收发共用缓冲区
20 | UINT8 EP1[0x40]; // 端点1 IN 64byte发送缓冲区
21 | UINT8 EP2[0x40]; // 端点2 IN 64byte发送缓冲区
22 | UINT8 EP3[0x40]; // 端点3 OUT 64byte*2接收缓冲区(双缓冲接收)
23 | UINT8 EP4[0x40]; //
24 | } UsbBuffer;
25 |
26 | extern xdata UsbBuffer Buffer;
27 | #define Ep0Buffer Buffer.EP0
28 | #define Ep1Buffer Buffer.EP1
29 | #define Ep2Buffer Buffer.EP2
30 | #define Ep3Buffer Buffer.EP3
31 | #define Ep4Buffer Buffer.EP4
32 |
33 | #define UsbSetupBuf ((PUSB_SETUP_REQ)Ep0Buffer) // 定义Setup包结构体
34 | #define USBbReqType (UsbSetupBuf->bRequestType)
35 | #define USBbRequest (UsbSetupBuf->bRequest)
36 | #define USBwValueL (UsbSetupBuf->wValueL)
37 | #define USBwValueH (UsbSetupBuf->wValueH)
38 | #define USBwIndexL (UsbSetupBuf->wIndexL)
39 | #define USBwIndexH (UsbSetupBuf->wIndexH)
40 | #define USBwLengthL (UsbSetupBuf->wLengthL)
41 | #define USBwLengthH (UsbSetupBuf->wLengthH)
42 |
43 | extern UINT8 DMA_STATUS;
44 | extern void USB_DeviceInit(void);
45 | extern void HID_DeviceInterrupt(void);
46 |
47 | #endif
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30524.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsbScreen", "UsbScreen\UsbScreen.csproj", "{089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {3712068A-6BAD-4DD0-A5CE-2D7D8A98FE96}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace UsbScreen
9 | {
10 | ///
11 | /// App.xaml 的交互逻辑
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("UsbScreen")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("UsbScreen")]
15 | [assembly: AssemblyCopyright("Copyright © 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52 | //通过使用 "*",如下所示:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UsbScreen.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UsbScreen.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性,对
51 | /// 使用此强类型资源类的所有资源查找执行重写。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UsbScreen.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/ScreenCapture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Drawing;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 | using System.Windows.Interop;
7 | using System.Windows.Media.Imaging;
8 |
9 | namespace UsbScreen
10 | {
11 | ///
12 | /// 获取屏幕坐标颜色(需引用程序集:System.Drawing)
13 | ///
14 | public partial class ScreenCapture
15 | {
16 | ///
17 | /// 捕获屏幕区域
18 | ///
19 | /// 输出Bitmap
20 | /// 区域范围
21 | public static void GetScreenCapture(out Bitmap bmp, Rectangle rect)
22 | {
23 | bmp = new Bitmap(rect.Width, rect.Height);
24 | using (Graphics g = Graphics.FromImage(bmp))
25 | {
26 | g.CopyFromScreen(rect.X, rect.Y, 0, 0, bmp.Size);
27 | g.DrawImage(bmp, 0, 0, rect, GraphicsUnit.Pixel);
28 | }
29 | }
30 | ///
31 | /// 获取屏幕截图
32 | ///
33 | ///
34 | public static void ScreenSnapshot(out BitmapSource Snapshot)
35 | {
36 | GetScreenCapture(out Bitmap bmp, new Rectangle()
37 | {
38 | X = 0,
39 | Y = 0,
40 | Width = (int)SystemParameters.PrimaryScreenWidth,
41 | Height = (int)SystemParameters.PrimaryScreenHeight
42 | });
43 |
44 | IntPtr hBitmap = bmp.GetHbitmap();
45 | Snapshot = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
46 | DeleteObject(hBitmap);
47 | }
48 |
49 | ///
50 | /// 释放资源
51 | ///
52 | ///
53 | ///
54 | [DllImport("gdi32.dll")]
55 | public static extern bool DeleteObject(IntPtr hObject);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/UsbScreen.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}
8 | WinExe
9 | UsbScreen
10 | UsbScreen
11 | v4.8
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 |
19 | x86
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | 9.0
28 | true
29 | false
30 |
31 |
32 | x86
33 | pdbonly
34 | true
35 | bin\Release\
36 | TRACE
37 | prompt
38 | 4
39 | 9.0
40 | false
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | 4.0
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | MSBuild:Compile
62 | Designer
63 |
64 |
65 |
66 | MSBuild:Compile
67 | Designer
68 |
69 |
70 | App.xaml
71 | Code
72 |
73 |
74 | MainWindow.xaml
75 | Code
76 |
77 |
78 | MSBuild:Compile
79 | Designer
80 |
81 |
82 |
83 |
84 | Code
85 |
86 |
87 | True
88 | True
89 | Resources.resx
90 |
91 |
92 | True
93 | Settings.settings
94 | True
95 |
96 |
97 | ResXFileCodeGenerator
98 | Resources.Designer.cs
99 |
100 |
101 |
102 | SettingsSingleFileGenerator
103 | Settings.Designer.cs
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/ProjectCDC/MasterTool/UsbScreen/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ProjectCDC/cli-test/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cli-test"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 |
8 | [dependencies]
9 | serialport = "4"
10 | image = "0.23"
11 | imageproc ="0.22"
12 | rusttype = "0.9"
13 | lazy_static = "1.4"
14 | chrono = "0.4"
15 |
--------------------------------------------------------------------------------
/ProjectCDC/cli-test/src/main.rs:
--------------------------------------------------------------------------------
1 | use std::{io::Read, sync::Mutex, thread, time::Duration};
2 | use chrono::Timelike;
3 | use image::{RgbImage, ImageBuffer, Rgb, Rgba};
4 | use imageproc::drawing;
5 | use lazy_static::lazy_static;
6 | use rusttype::{Font, Scale};
7 | use serialport::SerialPort;
8 |
9 |
10 | //屏幕长宽
11 | const WIDTH:u32 = 240;
12 | const HEIGHT:u32 = 240;
13 |
14 | //获取资源文件路径
15 | pub fn get_path() -> String{
16 | let path = std::env::args().nth(2).unwrap_or(String::from("static/"));
17 | if path.ends_with('/') || path.ends_with('\\') {
18 | path
19 | } else {
20 | path + "/"
21 | }
22 | }
23 | //加载字体文件
24 | fn load_font(path: String) -> Font<'static>{
25 | let mut file = std::fs::File::open(&path).expect(&path);
26 | let mut data = Vec::new();
27 | file.read_to_end(&mut data).unwrap();
28 | Font::try_from_vec(data).unwrap()
29 | }
30 | //静态加载字体
31 | lazy_static! {
32 | static ref FONT_SARASA: Font<'static> = load_font(get_path() + "sarasa-mono-sc-nerd-regular.ttf");
33 | static ref IMAGE_CACHE: Mutex> = Mutex::new(Vec::with_capacity((240*240*2) as usize));
34 | }
35 |
36 | //生成最终的图片序列
37 | fn send_bytes(img: &RgbImage, port: &mut Box){
38 | let mut data = IMAGE_CACHE.lock().unwrap();
39 | data.clear();
40 | for y in 0..240 {
41 | for x in 0..240 {
42 | let color = img.get_pixel(x, y);
43 | let r = color[0] as u16;
44 | let g = color[1] as u16;
45 | let b = color[2] as u16;
46 | let color = (r-r%8)/8*2048 + (g-g%4)/4*32 + (b-b%8)/8;
47 | data.push((color / 256) as u8);
48 | data.push((color % 256) as u8);
49 | }
50 | }
51 | let mut temp : Vec = vec![];
52 | //第一包
53 | temp.push(5);
54 | temp.push(0);
55 | temp.push(239);
56 | temp.push(0);
57 | temp.push(239);
58 | port.write_all(&temp[..]).unwrap();
59 |
60 | //剩下的数据包
61 | let mut sent:usize = 0;
62 |
63 | while sent < data.len() {
64 | if data.len() - sent >= 64 {
65 | port.write_all(&data[sent..(sent+64)]).unwrap();
66 | sent += 64;
67 | } else {
68 | let len = data.len() - sent;
69 | let len = if len > 62 { 62 } else { len };
70 | sent += len;
71 | data[sent-1] = len as u8;
72 | port.write_all(&data[(sent-1)..(sent+len)]).unwrap();
73 | }
74 | }
75 | }
76 |
77 |
78 | fn main() {
79 | for p in serialport::available_ports().unwrap() {
80 | println!("{}",p.port_name);
81 | }
82 | println!("enter a port to connect:");
83 | let mut com = String::new();
84 | std::io::stdin().read_line(&mut com).unwrap();
85 | let com = com.trim_end();
86 | println!("opening {}",com);
87 | let mut com = serialport::new(com, 92160000)
88 | .timeout(std::time::Duration::from_millis(1))
89 | .open().unwrap();
90 |
91 | let mut img: RgbImage = ImageBuffer::new(WIDTH, HEIGHT);
92 | drawing::draw_filled_rect_mut(&mut img,imageproc::rect::Rect::at(0, 0).of_size(WIDTH, HEIGHT),Rgb([100u8,100u8,100u8]));
93 | let mut img2: RgbImage = ImageBuffer::new(WIDTH, HEIGHT);
94 | drawing::draw_filled_rect_mut(&mut img2,imageproc::rect::Rect::at(0, 0).of_size(WIDTH, HEIGHT),Rgb([0u8,0u8,0u8]));
95 |
96 | let mut last = true;
97 | loop {
98 | // let now = chrono::Local::now();
99 | // let bgcolor = if last {Rgb([0u8,0u8,0u8])} else {Rgb([100u8,100u8,100u8])};
100 | // let txtcolor = if last {Rgb([255u8,255u8,255u8])} else {Rgb([255u8,255u8,255u8])};
101 | last = !last;
102 | // drawing::draw_filled_rect_mut(&mut img,imageproc::rect::Rect::at(0, 0).of_size(WIDTH, HEIGHT),bgcolor);
103 | // let now = format!("{:02}:{:02}:{:02}",now.hour(),now.minute(),now.second());
104 | // println!("{}",now);
105 | // drawing::draw_text_mut(&mut img, txtcolor, 0,90, Scale {x: 70.0,y: 70.0 }, &FONT_SARASA,&now);
106 | if last {send_bytes(&img,&mut com);} else {send_bytes(&img2,&mut com);}
107 | println!("{}",last);
108 | //thread::sleep(Duration::from_millis(500));
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/ProjectCDC/cli-test/static/sarasa-mono-sc-nerd-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/cli-test/static/sarasa-mono-sc-nerd-regular.ttf
--------------------------------------------------------------------------------
/ProjectCDC/rust-cli/cli-test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/rust-cli/cli-test.exe
--------------------------------------------------------------------------------
/ProjectCDC/rust-cli/static/sarasa-mono-sc-nerd-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectCDC/rust-cli/static/sarasa-mono-sc-nerd-regular.ttf
--------------------------------------------------------------------------------
/ProjectHID/Bootloader/CH552.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectHID/Bootloader/CH552.h
--------------------------------------------------------------------------------
/ProjectHID/Bootloader/CH559.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectHID/Bootloader/CH559.h
--------------------------------------------------------------------------------
/ProjectHID/Bootloader/UsbReports.h:
--------------------------------------------------------------------------------
1 | #ifndef UINT8C
2 | #define UINT8C const unsigned char code
3 | #endif
4 |
5 | /*HID设备报告描述符*/
6 | #ifndef UsbReports_H
7 | #define UsbReports_H
8 |
9 | // 供应商和产品信息
10 | #define VendorId 0x2333 // 供应商标识(VID)
11 | #define ProductId 0xC551 // 产品标识(PID)
12 | #define ReleaseNo 0x1005 // 发行版本
13 | #define LSB(x) (x & 0xFF)
14 | #define MSB(x) ((x & 0xFF00) >> 8)
15 | #define VIDL LSB(VendorId) // Vendor Id Low Byte (LSB)
16 | #define VIDH MSB(VendorId) // Vendor Id High Byte (MSB)
17 | #define PIDL LSB(ProductId) // Product Id Low Byte (LSB)
18 | #define PIDH MSB(ProductId) // Product Id High Byte (MSB)
19 | #define REVL LSB(ReleaseNo) // Release Number Low Byte (LSB)
20 | #define REVH MSB(ReleaseNo) // Release Number High Byte (MSB)
21 |
22 | // HID类报表描述符
23 | UINT8C HidReport[] = {
24 | 0x06, 0x00, 0xFF, // USAGE_PAGE (Vendor Defined Page 1)
25 | 0x09, 0x01, // USAGE (Vendor Usage 1)
26 | 0xA1, 0x01, // COLLECTION (Application)
27 | 0x09, 0x02, // Usage ID - vendor defined
28 | 0x15, 0x00, // Logical Minimum (0)
29 | 0x25, 0xFF, // Logical Maximum (255)
30 | 0x75, 0x08, // Report Size (8 bits)
31 | 0x95, 0x40, // Report Count(64)
32 | 0x81, 0x06, // Input (Data, Variable, Absolute)
33 | 0x09, 0x02, // Usage ID - vendor defined
34 | 0x15, 0x00, // Logical Minimum (0)
35 | 0x25, 0xFF, // Logical Maximum (255)
36 | 0x75, 0x08, // Report Size (8 bits)
37 | 0x95, 0x40, // Report Count(64)
38 | 0x91, 0x06, // Output (Data, Variable, Absolute)
39 | 0xc0 // END_COLLECTION
40 | };
41 |
42 | // 配置描述符
43 | UINT8C CfgReport[] =
44 | {
45 | // 配置描述符:配置描述符定义了设备的配置信息,一个设备可以有多个配置描述符
46 | 0x09, // 配置描述符长度.固定为0x09.
47 | 0x02, // 配置描述符类型.固定为0x02.
48 | 0x29, // 配置描述符总长度(低8位);指此配置返回的配置描述符,接口描述符以及端点描述符的全部大小.
49 | 0x00, // 配置描述符总长度(高8位)
50 | 0x01, // 配置所支持的“接口数目”.也表示该配置下接口描述符数量.
51 | 0x01, // 这个配置的索引值
52 | 0x04, // 用于描述该配置字符串描述符的索引.
53 | 0xA0, // 供电模式选择.Bit7:总线供电,Bit6:自供电,Bit5:远程唤醒,Bit4-0保留.
54 | 0xC8, // 总线供电的USB设备的最大消耗电流.以2mA为单位.(这里是2mA*0xC8=400mA)
55 |
56 | // 接口描述符:接口描述符说明了接口所提供的配置,由配置描述符“接口数目”决定其数量
57 | 0x09, // 接口描述符长度.固定为0x09.
58 | 0x04, // 接口描述符类型.固定为0x04.
59 | 0x00, // 接口编号. 编号规则从0x00开始
60 | 0x00, // 备用编号. 用于为上一个字段选择可供替换的位置.
61 | 0x02, // 此接口使用的“端点数目”.不包括端点0.
62 | 0x03, // 类型代码(由USB分配)
63 | 0x00, // 子类型代码(由USB分配)
64 | 0x00, // 协议代码(由USB分配)
65 | 0x03, // 字符串描述符的索引
66 | // HID类描述符
67 | 0x09, // HID描述符长度.固定为0x09.
68 | 0x21, // HID描述符类型.固定为0x21.
69 | 0x10, // USB规格发布号LSB低位; 表示了本设备能适用于哪种协议,
70 | 0x01, // USB规格发布号MSB高位; 如USB2.0=0x0200,USB1.1=0x0110等。
71 | 0x00, // 国家代码(0x00不支持)
72 | 0x01, // 下级描述符数量,通常至少需要一个报告描述符。
73 | 0x22, // 下级描述符类型,例如报告描述符。
74 | sizeof(HidReport), // Report Size LSB 下级描述符长度 (HIDReport[]长度)
75 | 0x00, // Report Size LSB
76 | // 端点描述符:USB设备中的每个端点都有自己的端点描述符,由接口描述符“端点数目”决定其数量
77 | 0x07, // 端点描述符大小.固定为0x07.
78 | 0x05, // 端点描述符类型.固定为0x05.
79 | 0x84, // 端点地址(这里为输入端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
80 | 0x03, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
81 | 0x40, // Max Packet Size LSB 端点最大通信包长度(单位byte)
82 | 0x00, // Max Packet Size MSB
83 | 0x01, // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms).
84 | // 端点描述符:USB设备中的每个端点都有自己的端点描述符,由接口描述符“端点数目”决定其数量
85 | 0x07, // 端点描述符大小.固定为0x07.
86 | 0x05, // 端点描述符类型.固定为0x05.
87 | 0x04, // 端点地址(这里为输出端点).Bit7<1输入:0输出>,Bit6-4保留,Bit3-0端点号.
88 | 0x03, // 端点属性.Bit7-2保留,Bit1-0<0控制:1同步:2批量:3中断>.
89 | 0x40, // Max Packet Size LSB 端点最大通信包长度(单位byte)
90 | 0x00, // Max Packet Size MSB
91 | 0x01 // 端点的报告周期.批量传送和控制传输的端点忽略为0;同步传输的端点必须为1;中断传输的端点为1-255(单位ms).
92 | };
93 |
94 | // 设备描述符
95 | UINT8C DevReport[] =
96 | {
97 | 0x12, // 描述符长度,以字节为单位,固定为0x12
98 | 0x01, // 设备描述符类型,固定为0x01
99 | 0x10, // USB规格发布号LSB低位; 表示了本设备能适用于哪种协议,
100 | 0x01, // USB规格发布号MSB高位; 如USB2.0=0x0200,USB1.1=0x0110等。
101 | 0x00, // 类型代码(由USB指定)。当它的值是0时,表示所有接口在配置描述符里,并且所有接口是独立的。当它的值是1到FEH时,表示不同的接口关联的。当它的值是FFH时,它是厂商自己定义的.
102 | 0x00, // 子类型代码(由USB分配).如果类型代码值是0,一定要设置为0.其它情况就跟据USB-IF组织定义的编码.
103 | 0x00, // 协议代码(由USB分配).如果使用USB-IF组织定义的协议,就需要设置这里的值,否则直接设置为0。如果厂商自己定义的可以设置为FFH.
104 | 0x08, // 端点0数据包大小(只有8,16,32,64有效)
105 | VIDL, // Vendor ID LSB; 供应商ID
106 | VIDH, // Vendor ID MSB; 俗称VID
107 | PIDL, // Product ID LSB; 产品ID
108 | PIDH, // Product ID MSB; 俗称PID
109 | REVL, // Device release number LSB; 设备版本号
110 | REVH, // Device release number MSB
111 | 0x01, // 厂商描述符字符串索引.索引到对应的字符串描述符. 为0则表示没有.
112 | 0x02, // 产品描述符字符串索引.同上.
113 | 0x00, // 设备序列号字符串索引.同上.
114 | 0x01 // 可能的配置数.指配置字符串的个数
115 | };
116 |
117 | // 语言类型
118 | const struct { UINT8 bLength; UINT8 bDscType; UINT16 string[1]; } code HidStrLangID = { sizeof(HidStrLangID),0x03,
119 | {0x0409} }; // LangID = 0x0409: U.S. English
120 | // 厂家信息
121 | const struct { UINT8 bLength; UINT8 bDscType; UINT16 string[7]; } code HidStrVendor = { sizeof(HidStrVendor),0x03,
122 | {'A','n','t','e','c','e','r'} };
123 | // 产品型号
124 | const struct { UINT8 bLength; UINT8 bDscType; UINT16 string[9]; } code HidStrSerial = { sizeof(HidStrSerial),0x03,
125 | {'U', 's', 'b', 'S', 'c', 'r', 'e', 'e', 'n'}};
126 | // 产品名称
127 | const struct { UINT8 bLength; UINT8 bDscType; UINT16 string[8]; } code HidStrProduct = { sizeof(HidStrProduct),0x03,
128 | {'C', 'H', '5', '5', '1', 'I', 'A', 'P'}};
129 | // 将所有字符串描述符纳入一个指针数组
130 | PUINT8C StringReports[]=
131 | {
132 | (PUINT8C)(&HidStrLangID),
133 | (PUINT8C)(&HidStrVendor),
134 | (PUINT8C)(&HidStrSerial),
135 | (PUINT8C)(&HidStrProduct)
136 | };
137 | #endif /* UsbReports_H */
--------------------------------------------------------------------------------
/ProjectHID/Firmware/CH552.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/ProjectHID/Firmware/CH552.h
--------------------------------------------------------------------------------
/ProjectHID/Firmware/Main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "CH552.h"
4 | #include "TypeDefines.h"
5 | #include "UsbReports.h"
6 | #include "SPI.h"
7 | #include "UsbManager.h"
8 |
9 | sbit Bg_Led1 = P3^0;
10 | sbit Bg_Led2 = P3^3;
11 | sbit Bg_Led3 = P1^1;
12 |
13 | /*******************************************************************************
14 | * Function Name : SetFsys
15 | * Description : 设置系统时钟频率
16 | * Info : 内核时钟12MHz
17 | : PLL倍频=96MHz
18 | : USB时钟分频器=96MHz/48MHz (USB模块工作需要48MHz频率)
19 | : 系统时钟分频器=96MHz/24MHz
20 | *******************************************************************************/
21 | void SetFsys()
22 | {
23 | SAFE_MOD = 0x55; //解锁安全模式
24 | SAFE_MOD = 0xAA;
25 | CLOCK_CFG = 0x86; //系统时钟分频器4分频=24MHz
26 | }
27 | /*******************************************************************************
28 | * Function Name : IOport_Init
29 | * Description : IO口默认状态配置位
30 | * Input : None
31 | * Return : None
32 | *******************************************************************************/
33 | void IOport_Init(void)
34 | {
35 | LCD_BLK = 0;
36 | while(USB_DEV_AD==0);
37 | LCD_BLK = 1;
38 | P3 = 0xFF;
39 | P1 = 0xFF;
40 | P1_DIR_PU = 0x1F; // 第7,6,5位禁用上拉(注意需要外接3.3V弱上拉10K电阻)
41 | }
42 |
43 | /*******************************************************************************
44 | * Function Name : main
45 | * Description : 主函数
46 | * Input : None
47 | * Return : None
48 | *******************************************************************************/
49 | void main(void)
50 | {
51 | SetFsys(); // 初始化系统时钟
52 | USB_DeviceInit(); // 初始化USB功能
53 | EA = True; // 使能单片机全局中断
54 | IOport_Init(); // 初始化IO口状态
55 | LCD_Init();
56 | while(true)
57 | {
58 | LCD_BLK = IsUsbShut; // 电脑关机后熄灭屏幕背光
59 | }
60 | }
--------------------------------------------------------------------------------
/ProjectHID/Firmware/TypeDefines.h:
--------------------------------------------------------------------------------
1 | #ifndef TypeDefines_H
2 | #define TypeDefines_H
3 |
4 | #ifndef TRUE
5 | #define TRUE 1
6 | #define FALSE 0
7 | #endif
8 | #ifndef True
9 | #define True 1
10 | #define False 0
11 | #endif
12 | #ifndef true
13 | #define true 1
14 | #define false 0
15 | #endif
16 |
17 | #ifndef NULL
18 | #define NULL 0
19 | #endif
20 | #ifndef Null
21 | #define Null 0
22 | #endif
23 | #ifndef null
24 | #define null 0
25 | #endif
26 |
27 | #ifndef Bool
28 | typedef bit Bool;
29 | #endif
30 | #ifndef bool
31 | typedef bit bool;
32 | #endif
33 |
34 | #ifndef UINT8
35 | #define UINT8 unsigned char
36 | #endif
37 | #ifndef UINT8X
38 | #define UINT8X unsigned char xdata
39 | #endif
40 |
41 | #ifndef U8I
42 | #define U8I unsigned char idata
43 | #endif
44 | #ifndef U16I
45 | #define U16I unsigned short idata
46 | #endif
47 |
48 |
49 | #endif /* TypeDefines_H */
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30524.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsbScreen", "UsbScreen\UsbScreen.csproj", "{089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {3712068A-6BAD-4DD0-A5CE-2D7D8A98FE96}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Windows;
7 |
8 | namespace UsbScreen
9 | {
10 | ///
11 | /// App.xaml 的交互逻辑
12 | ///
13 | public partial class App : Application
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/HidApi/HidAPI.cs:
--------------------------------------------------------------------------------
1 | /*注意:HIDAPI只能在“平台目标:x86”模式下工作,否则无法获取到USB设备*/
2 | using Microsoft.Win32.SafeHandles;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.IO;
7 | using System.Runtime.InteropServices;
8 |
9 | namespace HidApi
10 | {
11 | public class HidAPI
12 | {
13 | private const int MaxHidDevices = 256; // HID最大设备数量
14 | ///
15 | /// 结构体包含有关HIDClass设备的供应商信息
16 | /// Size 属性长度(sizeof(HidAttributes))
17 | /// VID 供应商代码(VendorID)
18 | /// PID 产品代码(ProductID)
19 | /// VER 产品版本号(VersionNumber)
20 | ///
21 | public struct HidAttributes
22 | {
23 | public int Size;
24 | public ushort VID;
25 | public ushort PID;
26 | public ushort VER;
27 | }
28 |
29 | ///
30 | /// USB设备信息结构体
31 | /// UsagePage
32 | /// Usage
33 | /// InputLength USB上传数据包长度(含ReportID)。
34 | /// OutputLength USB下传数据包长度(含ReportID)。
35 | /// Reserved 保留供内部系统使用。
36 | /// NumberLinkCollectionNodes
37 | /// NumberInputButtonCaps
38 | /// NumberInputValueCaps
39 | /// NumberInputDataIndices
40 | /// NumberOutputButtonCaps
41 | /// NumberOutputValueCaps
42 | /// NumberOutputDataIndices
43 | /// NumberFeatureButtonCaps
44 | /// NumberFeatureValueCaps
45 | /// NumberFeatureDataIndices
46 | ///
47 | public struct HIDP_CAPS
48 | {
49 | public ushort UsagePage;
50 | public ushort Usage;
51 | public ushort InputLength;
52 | public ushort OutputLength;
53 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)]
54 | public ushort[] Reserved;
55 | public ushort NumberLinkCollectionNodes;
56 | public ushort NumberInputButtonCaps;
57 | public ushort NumberInputValueCaps;
58 | public ushort NumberInputDataIndices;
59 | public ushort NumberOutputButtonCaps;
60 | public ushort NumberOutputValueCaps;
61 | public ushort NumberOutputDataIndices;
62 | public ushort NumberFeatureButtonCaps;
63 | public ushort NumberFeatureValueCaps;
64 | public ushort NumberFeatureDataIndices;
65 | }
66 |
67 | ///
68 | /// 获取HID的全局GUID
69 | ///
70 | /// 指向调用者分配的Guid容器
71 | [DllImport("hid.dll")]
72 | public static extern void HidD_GetHidGuid(out Guid HidGuid);
73 |
74 | ///
75 | /// 返回HID设备的属性集合
76 | ///
77 | /// 设备句柄,即CreateFile的返回值
78 | /// 返回指定设备的属性集合
79 | /// 成功返回True,失败返回False
80 | [DllImport("hid.dll")]
81 | public static extern bool HidD_GetAttributes(IntPtr hidDeviceObject, out HidAttributes attributes);
82 |
83 | ///
84 | /// 返回HID顶级集合的预处理数据。
85 | ///
86 | /// 设备句柄,即CreateFile的返回值
87 | /// 指向包含_HIDP_PREPARSED_DATA结构中的集合预处理数据的例程分配缓冲区的地址。
88 | /// 成功返回True,失败返回False
89 | [DllImport("hid.dll")]
90 | public static extern bool HidD_GetPreparsedData(IntPtr HidDeviceObject, out IntPtr PreparsedData);
91 |
92 | ///
93 | /// 释放资源
94 | ///
95 | ///
96 | ///
97 | [DllImport("hid.dll")]
98 | public static extern bool HidD_FreePreparsedData(IntPtr PreparsedData);
99 |
100 | ///
101 | /// 设置HID接收缓冲区大小
102 | ///
103 | /// 设备句柄,即CreateFile的返回值
104 | /// 缓冲区大小参数(65*N)
105 | ///
106 | [DllImport("hid.dll")]
107 | public static extern bool HidD_SetNumInputBuffers(IntPtr HidDeviceObject, int NumberBuffers);
108 |
109 | [DllImport("hid.dll")]
110 | public static extern uint HidP_GetCaps(IntPtr PreparsedData, out HIDP_CAPS Capabilities);
111 |
112 | ///
113 | /// 获取已连接电脑的HID设备列表
114 | ///
115 | /// 返回HID设备集合字符串List
116 | public static List GetHidDeviceList()
117 | {
118 | List deviceList = new List();
119 | HidD_GetHidGuid(out Guid HIDGuid); // 获取HID设备的全局GUID,用于筛选所有已连接设备中的HID设备。
120 | IntPtr HIDInfoSet = WinAPI.SetupDiGetClassDevs(ref HIDGuid, 0, IntPtr.Zero, WinAPI.DIGCF.DIGCF_PRESENT | WinAPI.DIGCF.DIGCF_DEVICEINTERFACE); //获取包含所有HID接口信息集合的句柄
121 | if (HIDInfoSet != IntPtr.Zero)
122 | {
123 | WinAPI.SP_DEVICE_INTERFACE_DATA interfaceInfo = new WinAPI.SP_DEVICE_INTERFACE_DATA();
124 | interfaceInfo.cbSize = Marshal.SizeOf(interfaceInfo);
125 | for (uint index = 0; index < MaxHidDevices; index++)
126 | {
127 | if (!WinAPI.SetupDiEnumDeviceInterfaces(HIDInfoSet, IntPtr.Zero, ref HIDGuid, index, ref interfaceInfo)) continue;
128 | int buffsize = 0;
129 | // 第一次读取接口详细信息(取得信息缓冲区的大小)
130 | WinAPI.SetupDiGetDeviceInterfaceDetail(HIDInfoSet, ref interfaceInfo, IntPtr.Zero, buffsize, ref buffsize, null);
131 | IntPtr pDetail = Marshal.AllocHGlobal(buffsize);
132 | WinAPI.SP_DEVICE_INTERFACE_DETAIL_DATA detail = new WinAPI.SP_DEVICE_INTERFACE_DETAIL_DATA()
133 | {
134 | cbSize = Marshal.SizeOf(typeof(WinAPI.SP_DEVICE_INTERFACE_DETAIL_DATA))
135 | };
136 | Marshal.StructureToPtr(detail, pDetail, false);
137 | // 第二次读取接口详细信息
138 | if (WinAPI.SetupDiGetDeviceInterfaceDetail(HIDInfoSet, ref interfaceInfo, pDetail, buffsize, ref buffsize, null))
139 | {
140 | deviceList.Add(Marshal.PtrToStringAuto((IntPtr)((int)pDetail + 4))); //通常数据为小写字符串
141 | }
142 | Marshal.FreeHGlobal(pDetail);
143 | }
144 | }
145 | WinAPI.SetupDiDestroyDeviceInfoList(HIDInfoSet);
146 | return deviceList;
147 | }
148 | }
149 | }
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("UsbScreen")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("UsbScreen")]
15 | [assembly: AssemblyCopyright("Copyright © 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52 | //通过使用 "*",如下所示:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace UsbScreen.Properties
13 | {
14 | ///
15 | /// 强类型资源类,用于查找本地化字符串等。
16 | ///
17 | // 此类是由 StronglyTypedResourceBuilder
18 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
19 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
20 | // (以 /str 作为命令选项),或重新生成 VS 项目。
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources
25 | {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources()
33 | {
34 | }
35 |
36 | ///
37 | /// 返回此类使用的缓存 ResourceManager 实例。
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager
41 | {
42 | get
43 | {
44 | if ((resourceMan == null))
45 | {
46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UsbScreen.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// 重写当前线程的 CurrentUICulture 属性,对
55 | /// 使用此强类型资源类的所有资源查找执行重写。
56 | ///
57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58 | internal static global::System.Globalization.CultureInfo Culture
59 | {
60 | get
61 | {
62 | return resourceCulture;
63 | }
64 | set
65 | {
66 | resourceCulture = value;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace UsbScreen.Properties
13 | {
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
17 | {
18 |
19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
20 |
21 | public static Settings Default
22 | {
23 | get
24 | {
25 | return defaultInstance;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/ScreenCapture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 | using System.Windows.Interop;
6 | using System.Windows.Media.Imaging;
7 |
8 | namespace UsbScreen
9 | {
10 | ///
11 | /// 获取屏幕坐标颜色(需引用程序集:System.Drawing)
12 | ///
13 | public partial class ScreenCapture
14 | {
15 | ///
16 | /// 获取屏幕截图
17 | ///
18 | ///
19 | public static BitmapSource ScreenSnapshot()
20 | {
21 | BitmapSource shotBmp;
22 | using (var bmp = new Bitmap((int)SystemParameters.PrimaryScreenWidth, (int)SystemParameters.PrimaryScreenHeight))
23 | {
24 | using (var g = Graphics.FromImage(bmp))
25 | {
26 | g.CopyFromScreen(0, 0, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
27 | IntPtr hBitmap = bmp.GetHbitmap();
28 | try
29 | {
30 | shotBmp = Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
31 | }
32 | finally
33 | {
34 | DeleteObject(hBitmap);
35 | }
36 | }
37 | }
38 | return shotBmp;
39 | }
40 |
41 | ///
42 | /// 释放资源
43 | ///
44 | ///
45 | ///
46 | [DllImport("gdi32.dll")]
47 | public static extern bool DeleteObject(IntPtr hObject);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/ProjectHID/MasterTool/UsbScreen/UsbScreen.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {089C0F1F-CDF1-4588-9E3A-0EB8C0EFD903}
8 | WinExe
9 | UsbScreen
10 | UsbScreen
11 | v4.0
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 | x86
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | 9.0
27 | true
28 |
29 |
30 | x86
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 | 9.0
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | 4.0
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | MSBuild:Compile
58 | Designer
59 |
60 |
61 |
62 | MSBuild:Compile
63 | Designer
64 |
65 |
66 | App.xaml
67 | Code
68 |
69 |
70 |
71 |
72 | MainWindow.xaml
73 | Code
74 |
75 |
76 | MSBuild:Compile
77 | Designer
78 |
79 |
80 |
81 |
82 | Code
83 |
84 |
85 | True
86 | True
87 | Resources.resx
88 |
89 |
90 | True
91 | Settings.settings
92 | True
93 |
94 |
95 | ResXFileCodeGenerator
96 | Resources.Designer.cs
97 |
98 |
99 | SettingsSingleFileGenerator
100 | Settings.Designer.cs
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # USB-Screen
2 |
3 | 
4 | 
5 |
6 | 低成本PC资源监控小屏幕。如果感兴趣,点个星星呗。
7 |
8 | PC monitor screen, only cost $5.
9 |
10 | > only Chinese readme now.
11 |
12 |
13 |
14 | ## 硬件
15 |
16 | - 主控:CH551
17 | - 屏幕:1.4寸IPS彩屏
18 | - 接口:microUSB、typec、排针
19 | - 外壳:3d打印
20 |
21 | ## 使用的开发软件/框架
22 |
23 | - 硬件设计:KICAD
24 | - 嵌入式软件:标准C51 (Keil/SDCC)
25 | - 外壳:OpenSCAD
26 | - PC客户端:WPF (.net framework 4.0)
27 | - 可根据通讯协议自行开发客户端
28 |
29 | ## 通讯协议
30 |
31 | 目前通过`USB CDC`进行通讯。
32 |
33 | 设备插入后,会被识别为串口设备,设备实例路径为`USB\VID_1A86&PID_5722\ST1E6DIPSF0F0SPI3`
34 |
35 | 数据包分为两种:
36 |
37 | ### 包长度小于64字节
38 |
39 | 这种类型的数据包,将作为`刷新区域设置`+`像素信息`使用,刷新区域的范围为**0~239**,格式如下:
40 |
41 | ```txt
42 | 1byte 1byte 1byte 1byte 1byte
43 | +-------------+-------------+-----------+--------------+------------+
44 | | data length | width start | width end | height start | height end |
45 | +-------------+-------------+-----------+--------------+------------+
46 | ↓
47 | |<--length-------------------------------......-->|
48 | 1byte 1byte
49 | +-------------------+------------------+------
50 | | rgb565 high 8 bit | rgb565 low 8 bit |......
51 | +-------------------+------------------+------
52 | ```
53 |
54 | 像素数据顺序为从左至右从上至下刷新,每个像素点的颜色为2字节,遵循`rgb565`色彩格式,如下
55 |
56 | ```txt
57 | 1byte 1byte
58 | +-----------+-----------+
59 | | rrrr rggg | gggb bbbb |
60 | +-----------+-----------+
61 | ```
62 |
63 | #### `data length`的使用特例
64 |
65 | 因为`data length`包最长也只能为`59`,所以进行了额外定义:
66 |
67 | 1. `data length`的值为`0xC0`为亮度调节命令,后接1byte亮度参数,用于调节屏幕背光亮度
68 | ```txt
69 | 1byte 1byte
70 | +-----------+------------+
71 | | 1100 0000 | brightness |
72 | +-----------+------------+
73 | ```
74 |
75 | 2. `data length`的最高位`0x80`如果为1,则表示当前模式为黑白模式,此模式下1字节代表8个像素点,设备会将所有数据按黑白模式进行处理
76 |
77 | 3. `data length`的倒数第二高位`0x40`如果为1,则表示后面的数据全部为像素数据,同时`data length`剩下字节表示后面跟随数据的长度,注意总包长度必须小于64字节
78 |
79 | ```txt
80 | 1byte
81 | +---------------+
82 | | 0x40 & length |
83 | +---------------+
84 | ↓
85 | |<-------length-----------------------......-->|
86 | 1byte 1byte
87 | +-------------------+------------------+------
88 | | rgb565 high 8 bit | rgb565 low 8 bit |......
89 | +-------------------+------------------+------
90 | ```
91 |
92 | ### 包长度等于64字节
93 |
94 | 64字节数据将全部作为像素数据发送至屏幕
95 |
96 | ```txt
97 | 1byte 1byte 1byte 1byte
98 | +-------------------+------------------+-------------------+------------------+---
99 | | rgb565 high 8 bit | rgb565 low 8 bit | rgb565 high 8 bit | rgb565 low 8 bit |...
100 | +-------------------+------------------+-------------------+------------------+---
101 | ```
102 |
103 | ## 功能
104 |
105 | PC控制端正在制作中
106 |
107 | 欢迎[提建议](https://github.com/chenxuuu/USB-Screen/issues)或直接参与开发。
108 |
109 |
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd.c
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd.h
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd_init.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd_init.c
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd_init.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/LCD/lcd_init.h
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/main.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/datasheets/1.54-SPI-Screen/01-1.54IPS显示屏C51_SPI例程/main.c
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/1.54-SPI原理图.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a1be8013473f32a84f0634e7711ef72fde38fb741a99f2578c63d846024e86e8
3 | size 76164
4 |
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/ST7789VW芯片手册.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:1f9e956057e3909c0714bdab9e682205e03cf52adefd5b4a01093fa3167d398b
3 | size 3135599
4 |
--------------------------------------------------------------------------------
/hardware/datasheets/1.54-SPI-Screen/ZJY154T-PG04.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a7f147d191c88033e68f2154d0ea94f2b543627a59cd8667af7bcf86f28356f0
3 | size 422942
4 |
--------------------------------------------------------------------------------
/hardware/datasheets/C108958_CH551G_2020-08-19.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:62f3004bfb81b9ec25da3735ae3e705f2bd958e26b41d89f492c0d5defd7d087
3 | size 614327
4 |
--------------------------------------------------------------------------------
/hardware/datasheets/C83932_SC662K-3.3V_2016-10-24.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c3b9bdd5fb3c25a3031d8d04ed07abad7fa25c8a966ce1f9ae894b2acbe9461c
3 | size 983677
4 |
--------------------------------------------------------------------------------
/hardware/kicad-project/.gitignore:
--------------------------------------------------------------------------------
1 | # For PCBs designed using KiCad: http://www.kicad-pcb.org/
2 | # Format documentation: http://kicad-pcb.org/help/file-formats/
3 |
4 | # Temporary files
5 | *.000
6 | *.bak
7 | *.bck
8 | *.kicad_pcb-bak
9 | *.kicad_sch-bak
10 | *.kicad_prl
11 | *.sch-bak
12 | *~
13 | _autosave-*
14 | *.tmp
15 | *-save.pro
16 | *-save.kicad_pcb
17 | fp-info-cache
18 |
19 | # Netlist files (exported from Eeschema)
20 | *.net
21 |
22 | # Autorouter files (exported from Pcbnew)
23 | *.dsn
24 | *.ses
25 |
26 | # Exported BOM files
27 | *.xml
28 | *.csv
29 |
30 | # Geber files
31 | [Gg]erber/
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen-rescue.dcm:
--------------------------------------------------------------------------------
1 | EESchema-DOCLIB Version 2.0
2 | #
3 | #End Doc Library
4 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen-rescue.lib:
--------------------------------------------------------------------------------
1 | EESchema-LIBRARY Version 2.4
2 | #encoding utf-8
3 | #
4 | # 2SC4213-Transistor_BJT
5 | #
6 | DEF 2SC4213-Transistor_BJT Q 0 0 Y N 1 F N
7 | F0 "Q" 200 75 50 H V L CNN
8 | F1 "2SC4213-Transistor_BJT" 200 0 50 H V L CNN
9 | F2 "Package_TO_SOT_SMD:SOT-323_SC-70" 200 -75 50 H I L CIN
10 | F3 "" 0 0 50 H I L CNN
11 | $FPLIST
12 | SOT?323*
13 | $ENDFPLIST
14 | DRAW
15 | C 50 0 111 0 1 10 N
16 | P 2 0 1 0 25 25 100 100 N
17 | P 3 0 1 0 25 -25 100 -100 100 -100 N
18 | P 3 0 1 20 25 75 25 -75 25 -75 N
19 | P 5 0 1 0 50 -70 70 -50 90 -90 50 -70 50 -70 F
20 | X B 1 -200 0 225 R 50 50 1 1 I
21 | X E 2 100 -200 100 U 50 50 1 1 P
22 | X C 3 100 200 100 D 50 50 1 1 P
23 | ENDDRAW
24 | ENDDEF
25 | #
26 | # USB_B_Micro-Connector
27 | #
28 | DEF USB_B_Micro-Connector J 0 40 Y Y 1 F N
29 | F0 "J" -200 450 50 H V L CNN
30 | F1 "USB_B_Micro-Connector" -200 350 50 H V L CNN
31 | F2 "" 150 -50 50 H I C CNN
32 | F3 "" 150 -50 50 H I C CNN
33 | $FPLIST
34 | USB*
35 | $ENDFPLIST
36 | DRAW
37 | C -150 85 25 0 1 10 F
38 | C -25 135 15 0 1 10 F
39 | S -200 -300 200 300 0 1 10 f
40 | S -5 -300 5 -270 0 1 0 N
41 | S 10 50 -20 20 0 1 10 F
42 | S 200 -205 170 -195 0 1 0 N
43 | S 200 -105 170 -95 0 1 0 N
44 | S 200 -5 170 5 0 1 0 N
45 | S 200 195 170 205 0 1 0 N
46 | P 2 0 1 10 -75 85 25 85 N
47 | P 4 0 1 10 -125 85 -100 85 -50 135 -25 135 N
48 | P 4 0 1 10 -100 85 -75 85 -50 35 0 35 N
49 | P 4 0 1 10 25 110 25 60 75 85 25 110 F
50 | P 5 0 1 0 -170 220 -70 220 -80 190 -160 190 -170 220 F
51 | P 9 0 1 0 -185 230 -185 220 -175 190 -175 180 -65 180 -65 190 -55 220 -55 230 -185 230 N
52 | X VBUS 1 300 200 100 L 50 50 1 1 w
53 | X D- 2 300 -100 100 L 50 50 1 1 P
54 | X D+ 3 300 0 100 L 50 50 1 1 P
55 | X ID 4 300 -200 100 L 50 50 1 1 P
56 | X GND 5 0 -400 100 U 50 50 1 1 w
57 | X Shield 6 -100 -400 100 U 50 50 1 1 P
58 | ENDDRAW
59 | ENDDEF
60 | #
61 | # USB_C_Receptacle_USB2.0-Connector
62 | #
63 | DEF USB_C_Receptacle_USB2.0-Connector J 0 40 Y Y 1 F N
64 | F0 "J" -400 750 50 H V L CNN
65 | F1 "USB_C_Receptacle_USB2.0-Connector" 750 750 50 H V R CNN
66 | F2 "" 150 0 50 H I C CNN
67 | F3 "" 150 0 50 H I C CNN
68 | $FPLIST
69 | USB*C*Receptacle*
70 | $ENDFPLIST
71 | DRAW
72 | A -275 -150 75 -1799 -1 0 1 20 N -350 -150 -200 -150
73 | A -275 -150 25 -1799 -1 0 1 10 N -300 -150 -250 -150
74 | A -275 -150 25 -1799 -1 0 1 10 F -300 -150 -250 -150
75 | A -275 150 25 1 1799 0 1 10 F -250 150 -300 150
76 | A -275 150 25 1 1799 0 1 10 N -250 150 -300 150
77 | A -275 150 75 1 1799 0 1 20 N -200 150 -350 150
78 | C -100 45 25 0 1 10 F
79 | C 0 -230 50 0 1 0 F
80 | S -10 -700 10 -660 0 0 0 N
81 | S 400 -590 360 -610 0 0 0 N
82 | S 400 -490 360 -510 0 0 0 N
83 | S 400 -190 360 -210 0 0 0 N
84 | S 400 -90 360 -110 0 0 0 N
85 | S 400 10 360 -10 0 0 0 N
86 | S 400 110 360 90 0 0 0 N
87 | S 400 310 360 290 0 0 0 N
88 | S 400 410 360 390 0 0 0 N
89 | S 400 610 360 590 0 0 0 N
90 | S -400 700 400 -700 0 1 10 f
91 | S -300 -150 -250 150 0 1 10 F
92 | S 75 70 125 120 0 1 10 F
93 | P 2 0 1 20 -350 -150 -350 150 N
94 | P 2 0 1 20 -200 150 -200 -150 N
95 | P 2 0 1 20 0 -230 0 170 N
96 | P 3 0 1 20 0 -130 -100 -30 -100 20 N
97 | P 3 0 1 20 0 -80 100 20 100 70 N
98 | P 4 0 1 10 -50 170 0 270 50 170 -50 170 F
99 | X GND A1 0 -900 200 U 50 50 1 1 W
100 | X GND A12 0 -900 200 U 50 50 1 1 P N
101 | X VBUS A4 600 600 200 L 50 50 1 1 W
102 | X CC1 A5 600 400 200 L 50 50 1 1 B
103 | X D+ A6 600 -100 200 L 50 50 1 1 B
104 | X D- A7 600 100 200 L 50 50 1 1 B
105 | X SBU1 A8 600 -500 200 L 50 50 1 1 B
106 | X VBUS A9 600 600 200 L 50 50 1 1 P N
107 | X GND B1 0 -900 200 U 50 50 1 1 P N
108 | X GND B12 0 -900 200 U 50 50 1 1 P N
109 | X VBUS B4 600 600 200 L 50 50 1 1 P N
110 | X CC2 B5 600 300 200 L 50 50 1 1 B
111 | X D+ B6 600 -200 200 L 50 50 1 1 B
112 | X D- B7 600 0 200 L 50 50 1 1 B
113 | X SBU2 B8 600 -600 200 L 50 50 1 1 B
114 | X VBUS B9 600 600 200 L 50 50 1 1 P N
115 | X SHIELD S1 -300 -900 200 U 50 50 1 1 P
116 | ENDDRAW
117 | ENDDEF
118 | #
119 | #End Library
120 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen.pretty/SOP-16_4.55x10.3mm_P1.27mm.kicad_mod:
--------------------------------------------------------------------------------
1 | (module SOP-16_4.55x10.3mm_P1.27mm (layer F.Cu) (tedit 5F6026CA)
2 | (descr "SOP, 16 Pin (https://toshiba.semicon-storage.com/info/docget.jsp?did=12855&prodName=TLP290-4), generated with kicad-footprint-generator ipc_gullwing_generator.py")
3 | (tags "SOP SO")
4 | (attr smd)
5 | (fp_text reference REF** (at 0 -6.1) (layer F.SilkS)
6 | (effects (font (size 1 1) (thickness 0.15)))
7 | )
8 | (fp_text value SOP-16_4.55x10.3mm_P1.27mm (at 0 6.1) (layer F.Fab)
9 | (effects (font (size 1 1) (thickness 0.15)))
10 | )
11 | (fp_circle (center -3.81 -5.334) (end -3.556 -5.08) (layer F.SilkS) (width 0.12))
12 | (fp_line (start -1.275 -5.15) (end 2.032 -5.15) (layer F.Fab) (width 0.1))
13 | (fp_line (start 2.032 -5.15) (end 2.032 5.15) (layer F.Fab) (width 0.1))
14 | (fp_line (start 2.032 5.15) (end -2.275 5.15) (layer F.Fab) (width 0.1))
15 | (fp_line (start -2.275 5.15) (end -2.275 -4.15) (layer F.Fab) (width 0.1))
16 | (fp_line (start -2.275 -4.15) (end -1.275 -5.15) (layer F.Fab) (width 0.1))
17 | (fp_line (start -4.3 -5.4) (end -4.3 5.4) (layer F.CrtYd) (width 0.05))
18 | (fp_line (start -4.3 5.4) (end 4.064 5.4) (layer F.CrtYd) (width 0.05))
19 | (fp_line (start 4.046 5.4) (end 4.046 -5.4) (layer F.CrtYd) (width 0.05))
20 | (fp_line (start 4.046 -5.4) (end -4.318 -5.4) (layer F.CrtYd) (width 0.05))
21 | (fp_text user %R (at 0 0) (layer F.Fab)
22 | (effects (font (size 1 1) (thickness 0.15)))
23 | )
24 | (pad 16 smd roundrect (at 2.996 -4.445) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
25 | (pad 15 smd roundrect (at 2.996 -3.175) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
26 | (pad 14 smd roundrect (at 2.996 -1.905) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
27 | (pad 13 smd roundrect (at 2.996 -0.635) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
28 | (pad 12 smd roundrect (at 2.996 0.635) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
29 | (pad 11 smd roundrect (at 2.996 1.905) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
30 | (pad 10 smd roundrect (at 2.996 3.175) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
31 | (pad 9 smd roundrect (at 2.996 4.445) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
32 | (pad 8 smd roundrect (at -3.25 4.445) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
33 | (pad 7 smd roundrect (at -3.25 3.175) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
34 | (pad 6 smd roundrect (at -3.25 1.905) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
35 | (pad 5 smd roundrect (at -3.25 0.635) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
36 | (pad 4 smd roundrect (at -3.25 -0.635) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
37 | (pad 3 smd roundrect (at -3.25 -1.905) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
38 | (pad 2 smd roundrect (at -3.25 -3.175) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
39 | (pad 1 smd roundrect (at -3.25 -4.445) (size 1.6 0.6) (layers F.Cu F.Paste F.Mask) (roundrect_rratio 0.25))
40 | (model ${KISYS3DMOD}/Package_SO.3dshapes/SOP-16_4.4x10.4mm_P1.27mm.wrl
41 | (offset (xyz -0.25 0 0))
42 | (scale (xyz 1 1 1))
43 | (rotate (xyz 0 0 0))
44 | )
45 | )
46 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen.pretty/SW_4mm_4mm.kicad_mod:
--------------------------------------------------------------------------------
1 | (module SW_4mm_4mm (layer F.Cu) (tedit 5F86C3EE)
2 | (fp_text reference REF** (at 0 0.5) (layer F.SilkS)
3 | (effects (font (size 1 1) (thickness 0.15)))
4 | )
5 | (fp_text value SW_4mm_4mm (at 0 -0.5) (layer F.Fab)
6 | (effects (font (size 1 1) (thickness 0.15)))
7 | )
8 | (fp_line (start -2.54 2.54) (end -2.54 2.659) (layer F.SilkS) (width 0.254))
9 | (fp_line (start 1.01 -1.891) (end 1.01 -1.891) (layer F.SilkS) (width 0.254))
10 | (fp_line (start -0.99 -1.891) (end 1.01 -1.891) (layer F.SilkS) (width 0.254))
11 | (fp_circle (center 0.01 0.109) (end 0.717 0.109) (layer F.SilkS) (width 0.254))
12 | (fp_line (start 2.56 2.54) (end 2.56 2.659) (layer F.SilkS) (width 0.254))
13 | (fp_line (start -1.99 -0.891) (end -1.99 -0.891) (layer F.SilkS) (width 0.254))
14 | (fp_line (start 1.01 2.109) (end -0.99 2.109) (layer F.SilkS) (width 0.254))
15 | (fp_line (start -1.99 -0.891) (end -0.99 -1.891) (layer F.SilkS) (width 0.254))
16 | (fp_line (start 2.56 -1.16) (end 2.56 1.378) (layer F.SilkS) (width 0.254))
17 | (fp_line (start 2.56 -2.441) (end 2.56 -2.322) (layer F.SilkS) (width 0.254))
18 | (fp_line (start 2.01 1.109) (end 1.01 2.109) (layer F.SilkS) (width 0.254))
19 | (fp_line (start 2.01 -0.891) (end 2.01 1.109) (layer F.SilkS) (width 0.254))
20 | (fp_line (start -2.54 -1.16) (end -2.54 1.378) (layer F.SilkS) (width 0.254))
21 | (fp_line (start -2.54 -2.441) (end -2.54 -2.322) (layer F.SilkS) (width 0.254))
22 | (fp_line (start 2.56 2.659) (end -2.54 2.659) (layer F.SilkS) (width 0.254))
23 | (fp_line (start -2.54 -2.441) (end 2.56 -2.441) (layer F.SilkS) (width 0.254))
24 | (fp_circle (center 0.01 0.109) (end 1.21 0.109) (layer F.SilkS) (width 0.254))
25 | (fp_line (start -1.99 1.109) (end -1.99 -0.891) (layer F.SilkS) (width 0.254))
26 | (fp_line (start -0.99 2.109) (end -1.99 1.109) (layer F.SilkS) (width 0.254))
27 | (fp_line (start 1.01 -1.891) (end 2.01 -0.891) (layer F.SilkS) (width 0.254))
28 | (fp_text user gge7 (at 0.01 0.109) (layer Cmts.User)
29 | (effects (font (size 1 1) (thickness 0.15)))
30 | )
31 | (pad 4 smd rect (at 3.01 1.959) (size 1.3 0.7) (layers F.Cu F.Paste F.Mask))
32 | (pad 3 smd rect (at -2.99 1.959) (size 1.3 0.7) (layers F.Cu F.Paste F.Mask))
33 | (pad 2 smd rect (at 3.01 -1.741) (size 1.3 0.7) (layers F.Cu F.Paste F.Mask))
34 | (pad 1 smd rect (at -2.99 -1.741) (size 1.3 0.7) (layers F.Cu F.Paste F.Mask))
35 | )
36 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen.pretty/ZJY154T-PG04.kicad_mod:
--------------------------------------------------------------------------------
1 | (module ZJY154T-PG04 (layer F.Cu) (tedit 5F8696B1)
2 | (attr smd)
3 | (fp_text reference REF** (at 0.06 -0.68) (layer F.SilkS)
4 | (effects (font (size 1 1) (thickness 0.15)))
5 | )
6 | (fp_text value ZJY154T-PG04 (at 0.06 0.47) (layer F.Fab)
7 | (effects (font (size 1 1) (thickness 0.15)))
8 | )
9 | (fp_line (start -15.75 16.8) (end 15.77 16.8) (layer F.SilkS) (width 0.12))
10 | (fp_line (start 15.77 16.8) (end 15.77 -16.92) (layer F.SilkS) (width 0.12))
11 | (fp_line (start 15.77 -16.92) (end -15.75 -16.92) (layer F.SilkS) (width 0.12))
12 | (fp_line (start -15.75 -16.92) (end -15.75 16.8) (layer F.SilkS) (width 0.12))
13 | (fp_line (start -3.81 3.81) (end -5.08 3.81) (layer F.SilkS) (width 0.12))
14 | (fp_line (start -5.08 3.81) (end -5.08 12.7) (layer F.SilkS) (width 0.12))
15 | (fp_line (start -5.08 12.7) (end -15.75 16.8) (layer F.SilkS) (width 0.12))
16 | (fp_line (start -3.81 3.81) (end 5.08 3.81) (layer F.SilkS) (width 0.12))
17 | (fp_line (start 5.08 3.81) (end 5.08 12.7) (layer F.SilkS) (width 0.12))
18 | (fp_line (start 5.08 12.7) (end 15.77 16.8) (layer F.SilkS) (width 0.12))
19 | (pad 12 smd rect (at -3.84 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
20 | (pad 11 smd rect (at -3.14 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
21 | (pad 10 smd rect (at -2.44 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
22 | (pad 9 smd rect (at -1.74 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
23 | (pad 8 smd rect (at -1.04 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
24 | (pad 7 smd rect (at -0.34 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
25 | (pad 6 smd rect (at 0.36 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
26 | (pad 5 smd rect (at 1.06 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
27 | (pad 4 smd rect (at 1.76 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
28 | (pad 3 smd rect (at 2.46 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
29 | (pad 2 smd rect (at 3.16 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
30 | (pad 1 smd rect (at 3.86 6.59 180) (size 0.35 3) (layers F.Cu F.Paste F.Mask))
31 | )
32 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen.pretty/packages3d/SW_Push_1P1T_NO_4x4mm_H2.0mm.wrl:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:312131121aaca7e2aac0a2a2049ab3868dd840d8f58a72a01043d8f77ada79f5
3 | size 62958
4 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen.pro:
--------------------------------------------------------------------------------
1 | update=2020/9/15 17:04:08
2 | version=1
3 | last_client=kicad
4 | [general]
5 | version=1
6 | RootSch=
7 | BoardNm=
8 | [cvpcb]
9 | version=1
10 | NetIExt=net
11 | [eeschema]
12 | version=1
13 | LibDir=
14 | [eeschema/libraries]
15 | [pcbnew]
16 | version=1
17 | PageLayoutDescrFile=
18 | LastNetListRead=
19 | CopperLayerCount=2
20 | BoardThickness=1.6
21 | AllowMicroVias=0
22 | AllowBlindVias=0
23 | RequireCourtyardDefinitions=0
24 | ProhibitOverlappingCourtyards=1
25 | MinTrackWidth=0.2
26 | MinViaDiameter=0.4
27 | MinViaDrill=0.3
28 | MinMicroViaDiameter=0.2
29 | MinMicroViaDrill=0.09999999999999999
30 | MinHoleToHole=0.25
31 | TrackWidth1=0.25
32 | ViaDiameter1=0.8
33 | ViaDrill1=0.4
34 | dPairWidth1=0.2
35 | dPairGap1=0.25
36 | dPairViaGap1=0.25
37 | SilkLineWidth=0.12
38 | SilkTextSizeV=1
39 | SilkTextSizeH=1
40 | SilkTextSizeThickness=0.15
41 | SilkTextItalic=0
42 | SilkTextUpright=1
43 | CopperLineWidth=0.2
44 | CopperTextSizeV=1.5
45 | CopperTextSizeH=1.5
46 | CopperTextThickness=0.3
47 | CopperTextItalic=0
48 | CopperTextUpright=1
49 | EdgeCutLineWidth=0.05
50 | CourtyardLineWidth=0.05
51 | OthersLineWidth=0.15
52 | OthersTextSizeV=1
53 | OthersTextSizeH=1
54 | OthersTextSizeThickness=0.15
55 | OthersTextItalic=0
56 | OthersTextUpright=1
57 | SolderMaskClearance=0.05
58 | SolderMaskMinWidth=0
59 | SolderPasteClearance=0
60 | SolderPasteRatio=-0
61 | [pcbnew/Layer.F.Cu]
62 | Name=F.Cu
63 | Type=0
64 | Enabled=1
65 | [pcbnew/Layer.In1.Cu]
66 | Name=In1.Cu
67 | Type=0
68 | Enabled=0
69 | [pcbnew/Layer.In2.Cu]
70 | Name=In2.Cu
71 | Type=0
72 | Enabled=0
73 | [pcbnew/Layer.In3.Cu]
74 | Name=In3.Cu
75 | Type=0
76 | Enabled=0
77 | [pcbnew/Layer.In4.Cu]
78 | Name=In4.Cu
79 | Type=0
80 | Enabled=0
81 | [pcbnew/Layer.In5.Cu]
82 | Name=In5.Cu
83 | Type=0
84 | Enabled=0
85 | [pcbnew/Layer.In6.Cu]
86 | Name=In6.Cu
87 | Type=0
88 | Enabled=0
89 | [pcbnew/Layer.In7.Cu]
90 | Name=In7.Cu
91 | Type=0
92 | Enabled=0
93 | [pcbnew/Layer.In8.Cu]
94 | Name=In8.Cu
95 | Type=0
96 | Enabled=0
97 | [pcbnew/Layer.In9.Cu]
98 | Name=In9.Cu
99 | Type=0
100 | Enabled=0
101 | [pcbnew/Layer.In10.Cu]
102 | Name=In10.Cu
103 | Type=0
104 | Enabled=0
105 | [pcbnew/Layer.In11.Cu]
106 | Name=In11.Cu
107 | Type=0
108 | Enabled=0
109 | [pcbnew/Layer.In12.Cu]
110 | Name=In12.Cu
111 | Type=0
112 | Enabled=0
113 | [pcbnew/Layer.In13.Cu]
114 | Name=In13.Cu
115 | Type=0
116 | Enabled=0
117 | [pcbnew/Layer.In14.Cu]
118 | Name=In14.Cu
119 | Type=0
120 | Enabled=0
121 | [pcbnew/Layer.In15.Cu]
122 | Name=In15.Cu
123 | Type=0
124 | Enabled=0
125 | [pcbnew/Layer.In16.Cu]
126 | Name=In16.Cu
127 | Type=0
128 | Enabled=0
129 | [pcbnew/Layer.In17.Cu]
130 | Name=In17.Cu
131 | Type=0
132 | Enabled=0
133 | [pcbnew/Layer.In18.Cu]
134 | Name=In18.Cu
135 | Type=0
136 | Enabled=0
137 | [pcbnew/Layer.In19.Cu]
138 | Name=In19.Cu
139 | Type=0
140 | Enabled=0
141 | [pcbnew/Layer.In20.Cu]
142 | Name=In20.Cu
143 | Type=0
144 | Enabled=0
145 | [pcbnew/Layer.In21.Cu]
146 | Name=In21.Cu
147 | Type=0
148 | Enabled=0
149 | [pcbnew/Layer.In22.Cu]
150 | Name=In22.Cu
151 | Type=0
152 | Enabled=0
153 | [pcbnew/Layer.In23.Cu]
154 | Name=In23.Cu
155 | Type=0
156 | Enabled=0
157 | [pcbnew/Layer.In24.Cu]
158 | Name=In24.Cu
159 | Type=0
160 | Enabled=0
161 | [pcbnew/Layer.In25.Cu]
162 | Name=In25.Cu
163 | Type=0
164 | Enabled=0
165 | [pcbnew/Layer.In26.Cu]
166 | Name=In26.Cu
167 | Type=0
168 | Enabled=0
169 | [pcbnew/Layer.In27.Cu]
170 | Name=In27.Cu
171 | Type=0
172 | Enabled=0
173 | [pcbnew/Layer.In28.Cu]
174 | Name=In28.Cu
175 | Type=0
176 | Enabled=0
177 | [pcbnew/Layer.In29.Cu]
178 | Name=In29.Cu
179 | Type=0
180 | Enabled=0
181 | [pcbnew/Layer.In30.Cu]
182 | Name=In30.Cu
183 | Type=0
184 | Enabled=0
185 | [pcbnew/Layer.B.Cu]
186 | Name=B.Cu
187 | Type=0
188 | Enabled=1
189 | [pcbnew/Layer.B.Adhes]
190 | Enabled=1
191 | [pcbnew/Layer.F.Adhes]
192 | Enabled=1
193 | [pcbnew/Layer.B.Paste]
194 | Enabled=1
195 | [pcbnew/Layer.F.Paste]
196 | Enabled=1
197 | [pcbnew/Layer.B.SilkS]
198 | Enabled=1
199 | [pcbnew/Layer.F.SilkS]
200 | Enabled=1
201 | [pcbnew/Layer.B.Mask]
202 | Enabled=1
203 | [pcbnew/Layer.F.Mask]
204 | Enabled=1
205 | [pcbnew/Layer.Dwgs.User]
206 | Enabled=1
207 | [pcbnew/Layer.Cmts.User]
208 | Enabled=1
209 | [pcbnew/Layer.Eco1.User]
210 | Enabled=1
211 | [pcbnew/Layer.Eco2.User]
212 | Enabled=1
213 | [pcbnew/Layer.Edge.Cuts]
214 | Enabled=1
215 | [pcbnew/Layer.Margin]
216 | Enabled=1
217 | [pcbnew/Layer.B.CrtYd]
218 | Enabled=1
219 | [pcbnew/Layer.F.CrtYd]
220 | Enabled=1
221 | [pcbnew/Layer.B.Fab]
222 | Enabled=1
223 | [pcbnew/Layer.F.Fab]
224 | Enabled=1
225 | [pcbnew/Layer.Rescue]
226 | Enabled=0
227 | [pcbnew/Netclasses]
228 | [pcbnew/Netclasses/Default]
229 | Name=Default
230 | Clearance=0.2
231 | TrackWidth=0.25
232 | ViaDiameter=0.8
233 | ViaDrill=0.4
234 | uViaDiameter=0.3
235 | uViaDrill=0.1
236 | dPairWidth=0.2
237 | dPairGap=0.25
238 | dPairViaGap=0.25
239 | [pcbnew/Netclasses/1]
240 | Name=power
241 | Clearance=0.2
242 | TrackWidth=0.45
243 | ViaDiameter=0.8
244 | ViaDrill=0.4
245 | uViaDiameter=0.3
246 | uViaDrill=0.1
247 | dPairWidth=0.2
248 | dPairGap=0.25
249 | dPairViaGap=0.25
250 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB-Screen2.pro:
--------------------------------------------------------------------------------
1 | update=2020/10/15, 星期四 20:18:29
2 | version=1
3 | last_client=pcbnew
4 | [general]
5 | version=1
6 | RootSch=
7 | BoardNm=
8 | [cvpcb]
9 | version=1
10 | NetIExt=net
11 | [eeschema]
12 | version=1
13 | LibDir=
14 | [eeschema/libraries]
15 | [pcbnew]
16 | version=1
17 | PageLayoutDescrFile=
18 | LastNetListRead=
19 | CopperLayerCount=2
20 | BoardThickness=1.6
21 | AllowMicroVias=0
22 | AllowBlindVias=0
23 | RequireCourtyardDefinitions=0
24 | ProhibitOverlappingCourtyards=1
25 | MinTrackWidth=0.2
26 | MinViaDiameter=0.4
27 | MinViaDrill=0.3
28 | MinMicroViaDiameter=0.2
29 | MinMicroViaDrill=0.09999999999999999
30 | MinHoleToHole=0.25
31 | TrackWidth1=0.3
32 | TrackWidth2=0.3
33 | ViaDiameter1=0.6
34 | ViaDrill1=0.3
35 | ViaDiameter2=0.6
36 | ViaDrill2=0.3
37 | dPairWidth1=0.2
38 | dPairGap1=0.25
39 | dPairViaGap1=0.25
40 | SilkLineWidth=0.12
41 | SilkTextSizeV=1
42 | SilkTextSizeH=1
43 | SilkTextSizeThickness=0.15
44 | SilkTextItalic=0
45 | SilkTextUpright=1
46 | CopperLineWidth=0.2
47 | CopperTextSizeV=1.5
48 | CopperTextSizeH=1.5
49 | CopperTextThickness=0.3
50 | CopperTextItalic=0
51 | CopperTextUpright=1
52 | EdgeCutLineWidth=0.05
53 | CourtyardLineWidth=0.05
54 | OthersLineWidth=0.15
55 | OthersTextSizeV=1
56 | OthersTextSizeH=1
57 | OthersTextSizeThickness=0.15
58 | OthersTextItalic=0
59 | OthersTextUpright=1
60 | SolderMaskClearance=0.05
61 | SolderMaskMinWidth=0
62 | SolderPasteClearance=0
63 | SolderPasteRatio=-0
64 | [pcbnew/Layer.F.Cu]
65 | Name=F.Cu
66 | Type=0
67 | Enabled=1
68 | [pcbnew/Layer.In1.Cu]
69 | Name=In1.Cu
70 | Type=0
71 | Enabled=0
72 | [pcbnew/Layer.In2.Cu]
73 | Name=In2.Cu
74 | Type=0
75 | Enabled=0
76 | [pcbnew/Layer.In3.Cu]
77 | Name=In3.Cu
78 | Type=0
79 | Enabled=0
80 | [pcbnew/Layer.In4.Cu]
81 | Name=In4.Cu
82 | Type=0
83 | Enabled=0
84 | [pcbnew/Layer.In5.Cu]
85 | Name=In5.Cu
86 | Type=0
87 | Enabled=0
88 | [pcbnew/Layer.In6.Cu]
89 | Name=In6.Cu
90 | Type=0
91 | Enabled=0
92 | [pcbnew/Layer.In7.Cu]
93 | Name=In7.Cu
94 | Type=0
95 | Enabled=0
96 | [pcbnew/Layer.In8.Cu]
97 | Name=In8.Cu
98 | Type=0
99 | Enabled=0
100 | [pcbnew/Layer.In9.Cu]
101 | Name=In9.Cu
102 | Type=0
103 | Enabled=0
104 | [pcbnew/Layer.In10.Cu]
105 | Name=In10.Cu
106 | Type=0
107 | Enabled=0
108 | [pcbnew/Layer.In11.Cu]
109 | Name=In11.Cu
110 | Type=0
111 | Enabled=0
112 | [pcbnew/Layer.In12.Cu]
113 | Name=In12.Cu
114 | Type=0
115 | Enabled=0
116 | [pcbnew/Layer.In13.Cu]
117 | Name=In13.Cu
118 | Type=0
119 | Enabled=0
120 | [pcbnew/Layer.In14.Cu]
121 | Name=In14.Cu
122 | Type=0
123 | Enabled=0
124 | [pcbnew/Layer.In15.Cu]
125 | Name=In15.Cu
126 | Type=0
127 | Enabled=0
128 | [pcbnew/Layer.In16.Cu]
129 | Name=In16.Cu
130 | Type=0
131 | Enabled=0
132 | [pcbnew/Layer.In17.Cu]
133 | Name=In17.Cu
134 | Type=0
135 | Enabled=0
136 | [pcbnew/Layer.In18.Cu]
137 | Name=In18.Cu
138 | Type=0
139 | Enabled=0
140 | [pcbnew/Layer.In19.Cu]
141 | Name=In19.Cu
142 | Type=0
143 | Enabled=0
144 | [pcbnew/Layer.In20.Cu]
145 | Name=In20.Cu
146 | Type=0
147 | Enabled=0
148 | [pcbnew/Layer.In21.Cu]
149 | Name=In21.Cu
150 | Type=0
151 | Enabled=0
152 | [pcbnew/Layer.In22.Cu]
153 | Name=In22.Cu
154 | Type=0
155 | Enabled=0
156 | [pcbnew/Layer.In23.Cu]
157 | Name=In23.Cu
158 | Type=0
159 | Enabled=0
160 | [pcbnew/Layer.In24.Cu]
161 | Name=In24.Cu
162 | Type=0
163 | Enabled=0
164 | [pcbnew/Layer.In25.Cu]
165 | Name=In25.Cu
166 | Type=0
167 | Enabled=0
168 | [pcbnew/Layer.In26.Cu]
169 | Name=In26.Cu
170 | Type=0
171 | Enabled=0
172 | [pcbnew/Layer.In27.Cu]
173 | Name=In27.Cu
174 | Type=0
175 | Enabled=0
176 | [pcbnew/Layer.In28.Cu]
177 | Name=In28.Cu
178 | Type=0
179 | Enabled=0
180 | [pcbnew/Layer.In29.Cu]
181 | Name=In29.Cu
182 | Type=0
183 | Enabled=0
184 | [pcbnew/Layer.In30.Cu]
185 | Name=In30.Cu
186 | Type=0
187 | Enabled=0
188 | [pcbnew/Layer.B.Cu]
189 | Name=B.Cu
190 | Type=0
191 | Enabled=1
192 | [pcbnew/Layer.B.Adhes]
193 | Enabled=1
194 | [pcbnew/Layer.F.Adhes]
195 | Enabled=1
196 | [pcbnew/Layer.B.Paste]
197 | Enabled=1
198 | [pcbnew/Layer.F.Paste]
199 | Enabled=1
200 | [pcbnew/Layer.B.SilkS]
201 | Enabled=1
202 | [pcbnew/Layer.F.SilkS]
203 | Enabled=1
204 | [pcbnew/Layer.B.Mask]
205 | Enabled=1
206 | [pcbnew/Layer.F.Mask]
207 | Enabled=1
208 | [pcbnew/Layer.Dwgs.User]
209 | Enabled=1
210 | [pcbnew/Layer.Cmts.User]
211 | Enabled=1
212 | [pcbnew/Layer.Eco1.User]
213 | Enabled=1
214 | [pcbnew/Layer.Eco2.User]
215 | Enabled=1
216 | [pcbnew/Layer.Edge.Cuts]
217 | Enabled=1
218 | [pcbnew/Layer.Margin]
219 | Enabled=1
220 | [pcbnew/Layer.B.CrtYd]
221 | Enabled=1
222 | [pcbnew/Layer.F.CrtYd]
223 | Enabled=1
224 | [pcbnew/Layer.B.Fab]
225 | Enabled=1
226 | [pcbnew/Layer.F.Fab]
227 | Enabled=1
228 | [pcbnew/Layer.Rescue]
229 | Enabled=0
230 | [pcbnew/Netclasses]
231 | [pcbnew/Netclasses/Default]
232 | Name=Default
233 | Clearance=0.2
234 | TrackWidth=0.3
235 | ViaDiameter=0.6
236 | ViaDrill=0.3
237 | uViaDiameter=0.3
238 | uViaDrill=0.1
239 | dPairWidth=0.2
240 | dPairGap=0.25
241 | dPairViaGap=0.25
242 | [pcbnew/Netclasses/1]
243 | Name=power
244 | Clearance=0.2
245 | TrackWidth=0.4
246 | ViaDiameter=0.8
247 | ViaDrill=0.4
248 | uViaDiameter=0.3
249 | uViaDrill=0.1
250 | dPairWidth=0.2
251 | dPairGap=0.25
252 | dPairViaGap=0.25
253 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB_Screen_Library.dcm:
--------------------------------------------------------------------------------
1 | EESchema-DOCLIB Version 2.0
2 | #
3 | #End Doc Library
4 |
--------------------------------------------------------------------------------
/hardware/kicad-project/USB_Screen_Library.lib:
--------------------------------------------------------------------------------
1 | EESchema-LIBRARY Version 2.4
2 | #encoding utf-8
3 | #
4 | # CH551
5 | #
6 | DEF CH551 U 0 20 Y Y 1 F N
7 | F0 "U" 0 400 50 H V C CNN
8 | F1 "CH551" 0 -550 50 H V C CNN
9 | F2 "USB-Screen:SOP-16_4.55x10.3mm_P1.27mm" 0 -750 50 H I C CNN
10 | F3 "" 0 -750 50 H I C CNN
11 | DRAW
12 | S -450 350 450 -500 0 1 0 f
13 | X P3.2 1 -550 250 100 R 50 50 1 1 P
14 | X P3.3 10 550 -350 100 L 50 50 1 1 P
15 | X P3.4 11 550 -250 100 L 50 50 1 1 P
16 | X P3.6/UDP 12 550 -150 100 L 50 50 1 1 B
17 | X P3.7/UDM 13 550 -50 100 L 50 50 1 1 B
18 | X GND/VSS 14 550 50 100 L 50 50 1 1 W
19 | X VCC/VDD 15 550 150 100 L 50 50 1 1 W
20 | X V33 16 550 250 100 L 50 50 1 1 B
21 | X P1.4/SCS 2 -550 150 100 R 50 50 1 1 P
22 | X P1.5/MOSI 3 -550 50 100 R 50 50 1 1 P
23 | X P1.6/MISO 4 -550 -50 100 R 50 50 1 1 P
24 | X P1.7/SCK 5 -550 -150 100 R 50 50 1 1 P
25 | X RST 6 -550 -250 100 R 50 50 1 1 P
26 | X P3.1/TXD 7 -550 -350 100 R 50 50 1 1 P
27 | X P3.0/RXD 8 -550 -450 100 R 50 50 1 1 P
28 | X P1.1 9 550 -450 100 L 50 50 1 1 P
29 | ENDDRAW
30 | ENDDEF
31 | #
32 | # SC662
33 | #
34 | DEF SC662 U 0 40 Y Y 1 F N
35 | F0 "U" 0 200 50 H V C CNN
36 | F1 "SC662" 150 -200 50 H V C CNN
37 | F2 "Package_TO_SOT_SMD:SOT-23" 0 150 50 H I C CNN
38 | F3 "" 0 150 50 H I C CNN
39 | DRAW
40 | S -250 -150 250 150 0 1 0 f
41 | X GND 1 0 -250 100 U 50 50 1 1 W
42 | X VOUT 2 350 50 100 L 50 50 1 1 w
43 | X VDD 3 -350 50 100 R 50 50 1 1 W
44 | ENDDRAW
45 | ENDDEF
46 | #
47 | # SW_4*4mm
48 | #
49 | DEF SW_4*4mm K 0 40 Y Y 1 F N
50 | F0 "K" 0 0 50 H V C CNN
51 | F1 "SW_4*4mm" 0 0 50 H V C CNN
52 | F2 "USB-Screen:SW_4mm_4mm" 0 0 50 H I C CNN
53 | F3 "" 0 0 50 H I C CNN
54 | DRAW
55 | C 0 150 9 0 1 0 N
56 | C 0 200 9 0 1 0 N
57 | P 2 0 1 0 0 100 0 150 N
58 | P 2 0 1 0 0 200 36 155 N
59 | P 2 0 1 0 0 250 0 200 N
60 | X ~ 1 -100 250 100 R 50 50 1 1 I
61 | X ~ 2 100 250 100 L 50 50 1 1 I
62 | X ~ 3 -100 100 100 R 50 50 1 1 I
63 | X ~ 4 100 100 100 L 50 50 1 1 I
64 | ENDDRAW
65 | ENDDEF
66 | #
67 | # ZJY154T-PG04
68 | #
69 | DEF ZJY154T-PG04 U 0 40 Y Y 1 F N
70 | F0 "U" -100 650 50 H V C CNN
71 | F1 "ZJY154T-PG04" -100 650 50 H V C CNN
72 | F2 "USB-Screen:ZJY154T-PG04" -100 650 50 H I C CNN
73 | F3 "" -100 650 50 H I C CNN
74 | DRAW
75 | S -150 -650 200 600 0 1 0 f
76 | X GND 1 -250 500 100 R 50 50 1 1 W
77 | X SDA 10 -250 -400 100 R 50 50 1 1 I
78 | X RESET 11 -250 -500 100 R 50 50 1 1 I
79 | X GND 12 -250 -600 100 R 50 50 1 1 W
80 | X LEDK 2 -250 400 100 R 50 50 1 1 I
81 | X LEDA 3 -250 300 100 R 50 50 1 1 I
82 | X VDD 4 -250 200 100 R 50 50 1 1 W
83 | X GND 5 -250 100 100 R 50 50 1 1 W
84 | X GND 6 -250 0 100 R 50 50 1 1 W
85 | X D/C 7 -250 -100 100 R 50 50 1 1 I
86 | X CS 8 -250 -200 100 R 50 50 1 1 I
87 | X SCL 9 -250 -300 100 R 50 50 1 1 I
88 | ENDDRAW
89 | ENDDEF
90 | #
91 | #End Library
92 |
--------------------------------------------------------------------------------
/hardware/kicad-project/fp-lib-table:
--------------------------------------------------------------------------------
1 | (fp_lib_table
2 | (lib (name USB-Screen)(type KiCad)(uri ${KIPRJMOD}/USB-Screen.pretty)(options "")(descr ""))
3 | )
4 |
--------------------------------------------------------------------------------
/hardware/kicad-project/sym-lib-table:
--------------------------------------------------------------------------------
1 | (sym_lib_table
2 | (lib (name USB_Screen_Library)(type Legacy)(uri ${KIPRJMOD}/USB_Screen_Library.lib)(options "")(descr ""))
3 | (lib (name USB-Screen-rescue)(type Legacy)(uri ${KIPRJMOD}/USB-Screen-rescue.lib)(options "")(descr ""))
4 | )
5 |
--------------------------------------------------------------------------------
/hardware/shell/.gitignore:
--------------------------------------------------------------------------------
1 | *.stl
2 | *.gcode
--------------------------------------------------------------------------------
/hardware/shell/cap.scad:
--------------------------------------------------------------------------------
1 | //长宽高
2 | ma=32.3;//横着
3 | mb=34.3;//竖着
4 | mc=4.2;//厚度
5 |
6 | l1=1.6;//屏幕顶部
7 | l2=2;//两边
8 | l3=4.8;//屏幕底部
9 |
10 | ll=3;//默认槽宽
11 |
12 |
13 | difference()
14 | {
15 | union()
16 | {
17 | translate([0,-2,mb/2+1])
18 | cube([ma-0.4,mc+4-0.2,2.8],true);
19 | difference()//两边的脚
20 | {
21 | translate([0,-5,mb/2-7])
22 | cube([ma+2,2,15],true);
23 | translate([0,-5,mb/2-7])
24 | cube([ma-3,2.1,18],true);
25 | }
26 | }
27 | union()
28 | {
29 | include;
30 | translate([6,-2.5,5])
31 | cube([12,5,mb],true);//usb口
32 | }
33 | }
--------------------------------------------------------------------------------
/hardware/shell/usb_screen.scad:
--------------------------------------------------------------------------------
1 | //长宽高
2 | ma=32.3;//横着
3 | mb=34.3;//竖着
4 | mc=4.2;//厚度
5 |
6 | l1=1.6;//屏幕顶部
7 | l2=2;//两边
8 | l3=4.8;//屏幕底部
9 |
10 | ll=3;//默认槽宽
11 |
12 |
13 | difference()
14 | {
15 | cube([ma+4,mc+4,mb+5],true);
16 | union()
17 | {
18 | cube([ma,mc,mb],true);//中间的空间
19 | translate([0,0,-1.5])//屏幕排线
20 | cube([ma-10,mc,mb],true);
21 |
22 | translate([0,3,0])//前面扣洞
23 | cube([ma-l2*2,mc,mb-l3*2],true);
24 | translate([0,3,mb/4+0.5])//前面再扣洞
25 | cube([ma-l2*2,mc,mb/2-l2*2],true);
26 | translate([0,-3,0])//背面扣洞
27 | cube([ma-ll,mc,mb-ll],true);
28 |
29 | translate([0,0,5])//上面扣洞
30 | cube([ma,mc,mb],true);
31 | translate([0,-3,10])//去掉一个梁
32 | cube([ma-ll,mc,mb-ll],true);
33 |
34 | translate([0,-3,mb/2+1])//做个槽放盖子
35 | cube([ma,mc,3.5],true);
36 | }
37 | }
38 | translate([0,-7.5,0])//背面
39 | cube([ma+4,2,mb+5],true);
40 |
41 | difference()
42 | {
43 | translate([0,-5,0])//背面
44 | cube([ma+4,3,mb+5],true);
45 | translate([0,-5,0])//背面
46 | union()
47 | {
48 | translate([0,0,5])//上面扣洞
49 | cube([ma,mc,mb+10],true);
50 | translate([0,0,3])//卡扣
51 | cube([ma+5,4,4],true);
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/hardware/software_for_test/CH552.H:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/CH552.H
--------------------------------------------------------------------------------
/hardware/software_for_test/CompatibilityHID.C:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/CompatibilityHID.C
--------------------------------------------------------------------------------
/hardware/software_for_test/Debug.C:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/Debug.C
--------------------------------------------------------------------------------
/hardware/software_for_test/Debug.H:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/Debug.H
--------------------------------------------------------------------------------
/hardware/software_for_test/SPI.C:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/SPI.C
--------------------------------------------------------------------------------
/hardware/software_for_test/SPI.H:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/hardware/software_for_test/SPI.H
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "USB-Screen", "USB-Screen\USB-Screen.csproj", "{71B93789-4E5C-4CD4-B551-B7F67A502C13}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {71B93789-4E5C-4CD4-B551-B7F67A502C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {71B93789-4E5C-4CD4-B551-B7F67A502C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {71B93789-4E5C-4CD4-B551-B7F67A502C13}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {71B93789-4E5C-4CD4-B551-B7F67A502C13}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {12DBFE4F-6C6F-4857-B3C1-FEC0A6C178BE}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace USB_Screen
10 | {
11 | ///
12 | /// App.xaml 的交互逻辑
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Dev/Hid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using HidLibrary;
8 |
9 | namespace USB_Screen.Dev
10 | {
11 | [PropertyChanged.AddINotifyPropertyChangedInterface]
12 | class Hid
13 | {
14 | ///
15 | /// 发送进度
16 | ///
17 | public int Progress { get; set; } = 0;
18 |
19 | ///
20 | /// 是否存在设备,目前仅支持单设备
21 | ///
22 | /// 是否存在
23 | public static bool HasDevice() => HidDevices.Enumerate(0x2333, 0x2434).ToArray().Length > 0;
24 |
25 | ///
26 | /// 发送多字节数据
27 | ///
28 | /// 数据
29 | /// 是否成功
30 | public bool SendBytes(byte[] data)
31 | {
32 | Progress = 0;//进度清零
33 |
34 |
35 | HidDevice[] HidDeviceList;
36 | HidDevice HidDevice;
37 |
38 | // Enumerate the devices with the Vendor Id
39 | HidDeviceList = HidDevices.Enumerate(0x2333, 0x2434).ToArray();
40 | if (HidDeviceList.Length <= 0)
41 | return false;
42 |
43 | HidDevice = HidDeviceList[0];
44 | List d = new List(data);
45 | while (d.Count > 64)
46 | {
47 | var temp = d.GetRange(0, 64);
48 | d.RemoveRange(0,64);
49 | if (!Send(temp.ToArray(), HidDevice))
50 | return false;
51 | Progress = 100 - (int)(100 * (double)d.Count / data.Length);//更新进度
52 | }
53 |
54 | if (d.Count > 0)
55 | {
56 | var temp = d.GetRange(0, d.Count);
57 | for (int i= d.Count; i<64;i++)
58 | temp.Add(0);
59 | if (!Send(temp.ToArray(), HidDevice))
60 | return false;
61 | Progress = 100 - (int)(100 * (double)d.Count / data.Length);//更新进度
62 | }
63 |
64 | Progress = 100;//更新进度
65 | return true;
66 | }
67 |
68 |
69 | ///
70 | /// 发一包数据
71 | ///
72 | /// 数据
73 | /// 是否成功
74 | private static bool Send(byte [] data, HidDevice HidDevice)
75 | {
76 | var temp = new byte[data.Length + 1];
77 | temp[0] = 0;
78 | for (int i = 1; i < data.Length + 1; i++)
79 | temp[i] = data[i-1];
80 | try
81 | {
82 | HidDevice.Write(temp);
83 | return true;
84 | }
85 | catch(Exception e)
86 | {
87 | Debug.WriteLine($"hid send error\r\n{e}");
88 | return false;
89 | }
90 | }
91 |
92 | public static string ByteToHexString(byte[] bytes)
93 | {
94 | string str = string.Empty;
95 | if (bytes != null)
96 | {
97 | for (int i = 0; i < bytes.Length; i++)
98 | {
99 | str += bytes[i].ToString("X2");
100 | }
101 | }
102 | return str;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Dev/Screen.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Runtime.Remoting.Messaging;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace USB_Screen.Dev
10 | {
11 | class Screen
12 | {
13 | ///
14 | /// 向list插入数据
15 | ///
16 | /// 数据list
17 | /// 数据,注意会被销毁
18 | /// 是否为命令
19 | public static void AddData(List list, List data, bool command = false)
20 | {
21 | while (data.Count > 0)
22 | {
23 | var len = 63 - list.Count % 64;
24 | if(len == 0)
25 | list.Add(0);
26 | else
27 | {
28 | if (len > data.Count)
29 | len = data.Count;
30 | list.Add((byte)((command ? 0x00 : 0x80) + len));
31 | list.AddRange(data.GetRange(0,len));
32 | data.RemoveRange(0,len);
33 | }
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Drawing;
5 | using System.Drawing.Drawing2D;
6 | using System.Drawing.Imaging;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Navigation;
18 | using System.Windows.Shapes;
19 | using USB_Screen.Dev;
20 |
21 | namespace USB_Screen
22 | {
23 | ///
24 | /// MainWindow.xaml 的交互逻辑
25 | ///
26 | public partial class MainWindow : Window
27 | {
28 | Dev.Hid hid = new Dev.Hid();
29 |
30 | public MainWindow()
31 | {
32 | InitializeComponent();
33 | // 当窗口后台运行时半透明显示
34 | this.Deactivated += delegate { this.Opacity = 0.8; };
35 | // 当窗口前台运行时取消半透明
36 | this.Activated += delegate { this.Opacity = 1; };
37 | // 注册窗口移动事件
38 | TitleBar.MouseMove += (object sender, MouseEventArgs e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
39 | // 注册窗口关闭按钮
40 | AppExit.Click += delegate { this.Close(); };
41 |
42 |
43 |
44 | TestButton.Click += Button_Click;
45 |
46 |
47 | progressBar.DataContext = hid;
48 | }
49 |
50 | object sendLock = new object();
51 | private void Button_Click(object sender, RoutedEventArgs e)
52 | {
53 | lock(sendLock)
54 | {
55 | Task.Run(() =>
56 | {
57 | byte x = 240;
58 | byte y = 240;
59 |
60 | List data = new List();
61 |
62 | Screen.AddData(data, new List() { 0x2a }, true);
63 | Screen.AddData(data, new List() { 0, 0 });
64 | Screen.AddData(data, new List() { 0, (byte)(x - 1) });
65 | Screen.AddData(data, new List() { 0x2b }, true);
66 | Screen.AddData(data, new List() { 0, 0 });
67 | Screen.AddData(data, new List() { 0, (byte)(y - 1) });
68 | Screen.AddData(data, new List() { 0x2c }, true);
69 |
70 | List sd = new List();
71 | using (Bitmap img = new Bitmap(@"1.png"))
72 | {
73 | for (int i = 0; i < x; i++)
74 | for (int j = 0; j < y; j++)
75 | {
76 | var color = img.GetPixel(y - i - 1, j);
77 | //rrrr rggg gggb bbbb
78 | var rgb565 = color.R / 8 * 2048 + color.G / 4 * 32 + color.B / 8;
79 | sd.Add((byte)(rgb565 / 256));
80 | sd.Add((byte)(rgb565 % 256));
81 | }
82 | }
83 |
84 | //MessageBox.Show(sd.Count.ToString());
85 | Screen.AddData(data, sd);
86 |
87 | var r = hid.SendBytes(data.ToArray());
88 | });
89 | }
90 |
91 | }
92 |
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("USB-Screen")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("HP Inc.")]
14 | [assembly: AssemblyProduct("USB-Screen")]
15 | [assembly: AssemblyCopyright("Copyright © HP Inc. 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
52 | //通过使用 "*",如下所示:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace USB_Screen.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("USB_Screen.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性,对
51 | /// 使用此强类型资源类的所有资源查找执行重写。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace USB_Screen.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/hardware/software_for_test/USB-Screen/USB-Screen/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rust-cli.7z:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/rust-cli.7z
--------------------------------------------------------------------------------
/rust-cli/cli-test.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/rust-cli/cli-test.exe
--------------------------------------------------------------------------------
/rust-cli/static/sarasa-mono-sc-nerd-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenxuuu/USB-Screen/41554c191029859dba53e2c75ce117e452603cfb/rust-cli/static/sarasa-mono-sc-nerd-regular.ttf
--------------------------------------------------------------------------------