├── .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 |