├── LICENSE ├── PC_Software_Qt └── uDSO │ ├── app.rc │ ├── component │ ├── channelsettingswidget.cpp │ ├── channelsettingswidget.h │ ├── mainwindowmenu.cpp │ ├── mainwindowmenu.h │ ├── oscillographwidget.cpp │ ├── oscillographwidget.h │ ├── sampleratesettingwidget.cpp │ ├── sampleratesettingwidget.h │ ├── statusbarwidget.cpp │ ├── statusbarwidget.h │ ├── systembutton.cpp │ ├── systembutton.h │ ├── titlebarwidget.cpp │ ├── titlebarwidget.h │ ├── triggerwidget.cpp │ └── triggerwidget.h │ ├── global.cpp │ ├── global.h │ ├── lib │ └── libusb.a │ ├── main.cpp │ ├── res │ ├── img.qrc │ └── img │ │ ├── arrow │ │ ├── arrow_down.png │ │ ├── arrow_left.png │ │ ├── arrow_right.png │ │ ├── arrow_up.png │ │ └── down_arrow.png │ │ ├── button │ │ ├── close_hover.png │ │ ├── close_normal.png │ │ ├── close_pressed.png │ │ ├── max_hover.png │ │ ├── max_normal.png │ │ ├── max_pressed.png │ │ ├── menu_hover.png │ │ ├── menu_normal.png │ │ ├── menu_pressed.png │ │ ├── min_hover.png │ │ ├── min_normal.png │ │ ├── min_pressed.png │ │ ├── restore_hover.png │ │ ├── restore_normal.png │ │ └── restore_pressed.png │ │ ├── etc │ │ ├── logo.ico │ │ ├── logo.png │ │ ├── logo_border.png │ │ ├── splashscreen.png │ │ └── start.gif │ │ ├── knob │ │ ├── knob0.png │ │ ├── knob1.png │ │ ├── knob2.png │ │ ├── knob3.png │ │ ├── knob4.png │ │ ├── knob5.png │ │ ├── knob6.png │ │ └── knob7.png │ │ ├── osc │ │ ├── MeasureButtom_1.png │ │ ├── MeasureButtom_2.png │ │ ├── MeasureLeft.png │ │ ├── MeasureRight_1.png │ │ ├── MeasureRight_2.png │ │ ├── MeasureTop.png │ │ ├── TimeBase.png │ │ ├── TimeBase2.png │ │ ├── Trig.png │ │ ├── gnd1.png │ │ ├── gnd2.png │ │ └── gnd3.png │ │ └── usb │ │ ├── connected.png │ │ └── unconnected.png │ ├── uDSO.pro │ ├── ui │ ├── aboutwindow.ui │ ├── connectwindow.ui │ ├── ddswindow.ui │ └── mainwindow.ui │ ├── usb │ ├── lusb0_usb.h │ ├── usb.cpp │ ├── usb.h │ ├── usbthread.cpp │ └── usbthread.h │ └── window │ ├── aboutwindow.cpp │ ├── aboutwindow.h │ ├── connectwindow.cpp │ ├── connectwindow.h │ ├── ddswindow.cpp │ ├── ddswindow.h │ ├── mainwindow.cpp │ └── mainwindow.h ├── README.md └── Screenshot ├── 20160119223711.png ├── 20160119223728.png ├── 20160119223749.png ├── Azure.png ├── demo.png └── 主控电路效果图.png /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/app.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "res/img/etc/logo.ico" -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/channelsettingswidget.cpp: -------------------------------------------------------------------------------- 1 | #include "channelsettingswidget.h" 2 | #include 3 | #include 4 | #include "window/mainwindow.h" 5 | 6 | ChannelSettingsWidget::ChannelSettingsWidget(QWidget *parent, int mark, QString str, QColor color): 7 | QGroupBox(parent) 8 | { 9 | parentWidget = parent; 10 | channelMark = mark; 11 | 12 | this->setFixedSize(160,160); 13 | this->setStyleSheet("QGroupBox { " 14 | "background: rgb(255, 255, 255); " 15 | "border: 1px solid gray; " 16 | "border-color:black; " 17 | "margin-top: 10px; }" 18 | 19 | "QGroupBox::title { " 20 | "color: black; " 21 | "subcontrol-origin: margin; " 22 | "subcontrol-position: top left; " 23 | "left:7px; margin-left: 0px; " 24 | "padding: 0 1 px; }"); 25 | this->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 26 | this->setTitle(str); 27 | 28 | // 29 | knob1 = new QWidget(this); 30 | knob1Count = 0; 31 | knob1->setFixedSize(64, 64); 32 | knob1->setStyleSheet("border-image: url(:/img/knob/knob0.png);"); 33 | knob1->move(95,20); 34 | 35 | knob2 = new QWidget(this); 36 | knob2Count = 0; 37 | knob2->setFixedSize(64, 64); 38 | knob2->setStyleSheet("border-image: url(:/img/knob/knob0.png);"); 39 | knob2->move(95,90); 40 | 41 | // 标签 42 | voltageRangeLabel = new QLabel(this); 43 | voltageRangeLabel->setFrameShape(QFrame::Box); 44 | voltageRangeLabel->setStyleSheet("QLabel { color: blue; border: 1px solid gray; }"); 45 | voltageRangeLabel->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 46 | voltageRangeLabel->setText("2v/Div"); 47 | voltageRangeLabel->setGeometry(10, knob1->y()+5, 80, 25); 48 | voltageRangeLabel->setAlignment(Qt::AlignCenter); 49 | 50 | // 标签 51 | VoltageOffsetLabel = new QLabel(this); 52 | VoltageOffsetLabel->setFrameShape(QFrame::Box); 53 | VoltageOffsetLabel->setStyleSheet("QLabel { color: blue; border: 1px solid gray;}"); 54 | VoltageOffsetLabel->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 55 | VoltageOffsetLabel->setText("+0mv"); 56 | VoltageOffsetLabel->setGeometry(10, knob2->y()+5, 80, 25); 57 | VoltageOffsetLabel->setAlignment(Qt::AlignCenter); 58 | 59 | // 按键 60 | switchButton = new SystemButton(this, "ON"); 61 | switchButton->setFont(QFont("微软雅黑", 9, QFont::Bold, false)); 62 | switchButton->move(10, knob1->y()+35); 63 | switchButton->setFixedSize(35, switchButton->height()); 64 | 65 | // 耦合方式 66 | couplingButton = new SystemButton(this, "AC"); 67 | couplingButton->setFont(QFont("微软雅黑", 8, QFont::Bold, false)); 68 | couplingButton->move(50, knob1->y()+35); 69 | couplingButton->setFixedSize(40, couplingButton->height()); 70 | 71 | // 设置颜色标签 72 | markColorLabel = new QLabel(this); 73 | markColorLabel->setFrameShape(QFrame::Box); 74 | setMarkColor(color); 75 | markColorLabel->setGeometry(10,knob2->y()+35, 25, 25); 76 | 77 | // 颜色标记按键 78 | markColorButton = new SystemButton(this, "COLOR"); 79 | markColorButton->setFont(QFont("微软雅黑", 8, QFont::Bold, false)); 80 | markColorButton->move(40, knob2->y()+35); 81 | markColorButton->setFixedSize(50, markColorButton->height()); 82 | 83 | // 显示DSO信息 84 | updateParameter(); 85 | 86 | // 关联按键的信号和槽 87 | connect(switchButton, SIGNAL(clicked()), this, SLOT(switchButtonHandler()) ); 88 | connect(couplingButton, SIGNAL(clicked()), this, SLOT(couplingButtonHandler()) ); 89 | connect(markColorButton, SIGNAL(clicked()), this, SLOT(markColorButtonHandler()) ); 90 | } 91 | 92 | ChannelSettingsWidget::~ChannelSettingsWidget() 93 | { 94 | 95 | } 96 | 97 | void ChannelSettingsWidget::mousePressEvent(QMouseEvent* event) 98 | { 99 | if (event->x() >= knob1->x() 100 | && event->x() <= knob1->x() + knob1->width() 101 | && event->y() >= knob1->y() 102 | && event->y() <= knob1->y() + knob1->height() 103 | ) 104 | { 105 | DSOControlInfo dso; 106 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 107 | int range; 108 | 109 | if (channelMark == 0) 110 | range = (int)dso.ch1VoltageRange; 111 | else // if(channelMark == 1) 112 | range = (int)dso.ch2VoltageRange; 113 | 114 | if (event->button() == Qt::LeftButton) 115 | { 116 | knob1Count = (knob1Count+1)%8; 117 | range = (range >= (DSO_VOLTAGE_RANGE_NUM-1)) ? (DSO_VOLTAGE_RANGE_NUM-1) : (range+1); 118 | emit voltageRangeChanged(channelMark, 1); 119 | } 120 | else if (event->button() == Qt::RightButton) 121 | { 122 | knob1Count = knob1Count <= 0 ? 7 : knob1Count-1; 123 | range = (range <= 0) ? 0 : (range-1); 124 | emit voltageRangeChanged(channelMark, -1); 125 | } 126 | 127 | voltageRangeLabel->setText(textVoltageRange[range][1]); 128 | if (channelMark == 0) 129 | dso.ch1VoltageRange = range; 130 | else // if(channelMark == 1) 131 | dso.ch2VoltageRange = range; 132 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 133 | 134 | // 更新滚轮状态 135 | updateKnob(knob1); 136 | } 137 | else if(event->x() >= knob2->x() 138 | && event->x() <= knob2->x() + knob2->width() 139 | && event->y() >= knob2->y() 140 | && event->y() <= knob2->y() + knob2->height() 141 | ) 142 | { 143 | DSOControlInfo dso; 144 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 145 | double offset; 146 | 147 | if (channelMark == 0) 148 | offset = dso.ch1Offset; 149 | else // if(channelMark == 1) 150 | offset = dso.ch2Offset; 151 | 152 | if (event->button() == Qt::LeftButton) 153 | { 154 | knob2Count = (knob2Count+1)%8; 155 | offset = (offset >= 2.5) ? 2.5 : (offset+0.1); 156 | emit voltageOffsetChanged(channelMark, 1); 157 | } 158 | else if (event->button() == Qt::RightButton) 159 | { 160 | knob2Count = knob2Count <= 0 ? 7 : knob2Count-1; 161 | offset = (offset <= -2.5) ? -2.5 : (offset-0.1); 162 | emit voltageOffsetChanged(channelMark, -1); 163 | } 164 | 165 | QString str; 166 | if (channelMark == 0) 167 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch1VoltageRange]); 168 | else // if(channelMark == 1) 169 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch2VoltageRange]); 170 | VoltageOffsetLabel->setText(str); 171 | 172 | if (channelMark == 0) 173 | dso.ch1Offset = offset; 174 | else // if(channelMark == 1) 175 | dso.ch2Offset = offset; 176 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 177 | 178 | // 更新滚轮状态 179 | updateKnob(knob2); 180 | 181 | } 182 | } 183 | 184 | void ChannelSettingsWidget::wheelEvent(QWheelEvent* event) 185 | { 186 | if (event->x() >= knob1->x() 187 | && event->x() <= knob1->x() + knob1->width() 188 | && event->y() >= knob1->y() 189 | && event->y() <= knob1->y() + knob1->height() 190 | ) 191 | { 192 | DSOControlInfo dso; 193 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 194 | int range; 195 | 196 | if (channelMark == 0) 197 | range = (int)dso.ch1VoltageRange; 198 | else // if(channelMark == 1) 199 | range = (int)dso.ch2VoltageRange; 200 | 201 | if (event->delta() > 0) 202 | { 203 | knob1Count = (knob1Count+1)%8; 204 | range = (range >= (DSO_VOLTAGE_RANGE_NUM-1)) ? (DSO_VOLTAGE_RANGE_NUM-1) : (range+1); 205 | emit voltageRangeChanged(channelMark, 1); 206 | } 207 | else 208 | { 209 | knob1Count = knob1Count <= 0 ? 7 : knob1Count-1; 210 | range = (range <= 0) ? 0 : (range-1); 211 | emit voltageRangeChanged(channelMark, -1); 212 | } 213 | 214 | voltageRangeLabel->setText(textVoltageRange[range][1]); 215 | if (channelMark == 0) 216 | dso.ch1VoltageRange = range; 217 | else // if(channelMark == 1) 218 | dso.ch2VoltageRange = range; 219 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 220 | 221 | // 更新滚轮状态 222 | updateKnob(knob1); 223 | 224 | } 225 | else if(event->x() >= knob2->x() 226 | && event->x() <= knob2->x() + knob2->width() 227 | && event->y() >= knob2->y() 228 | && event->y() <= knob2->y() + knob2->height() 229 | ) 230 | { 231 | DSOControlInfo dso; 232 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 233 | double offset; 234 | 235 | if (channelMark == 0) 236 | offset = dso.ch1Offset; 237 | else // if(channelMark == 1) 238 | offset = dso.ch2Offset; 239 | 240 | if (event->delta() > 0) 241 | { 242 | knob2Count = (knob2Count+1)%8; 243 | offset = (offset >= 2.5) ? 2.5 : (offset+0.1); 244 | emit voltageOffsetChanged(channelMark, 1); 245 | } 246 | else 247 | { 248 | knob2Count = knob2Count <= 0 ? 7 : knob2Count-1; 249 | offset = (offset <= -2.5) ? -2.5 : (offset-0.1); 250 | emit voltageOffsetChanged(channelMark, -1); 251 | } 252 | 253 | QString str; 254 | if (channelMark == 0) 255 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch1VoltageRange]); 256 | else // if(channelMark == 1) 257 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch2VoltageRange]); 258 | VoltageOffsetLabel->setText(str); 259 | 260 | if (channelMark == 0) 261 | dso.ch1Offset = offset; 262 | else // if(channelMark == 1) 263 | dso.ch2Offset = offset; 264 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 265 | 266 | // 更新滚轮状态 267 | updateKnob(knob2); 268 | } 269 | 270 | } 271 | 272 | void ChannelSettingsWidget::updateKnob(QWidget *widget) 273 | { 274 | QString str; 275 | 276 | if (widget == knob1) 277 | str.sprintf("border-image: url(:/img/knob/knob%d.png);",knob1Count); 278 | else if (widget == knob2) 279 | str.sprintf("border-image: url(:/img/knob/knob%d.png);",knob2Count); 280 | 281 | widget->setStyleSheet(str); 282 | } 283 | 284 | void ChannelSettingsWidget::setMarkColor(QColor color) 285 | { 286 | markColor = color; 287 | 288 | // 设置标签颜色 289 | markColorLabel->setStyleSheet( QString("QLabel { background-color: rgb(%1, %2, %3); border: 1px solid gray;}")\ 290 | .arg(markColor.red()).arg(markColor.green()).arg(markColor.blue()) ); 291 | 292 | // 发射信号通知颜色改变 293 | emit markColoChange(channelMark, markColor); 294 | } 295 | 296 | // 设置面板显示的数据(电压偏移) 297 | void ChannelSettingsWidget::setVoltageOffsetDisplay(QString str) 298 | { 299 | voltageRangeLabel->setText(str); 300 | } 301 | 302 | // 设置面板显示的数据(电压量程) 303 | void ChannelSettingsWidget::setVoltageRangeDisplay(QString str) 304 | { 305 | voltageRangeLabel->setText(str); 306 | } 307 | 308 | QColor ChannelSettingsWidget::getMarkColor() 309 | { 310 | return markColor; 311 | } 312 | 313 | void ChannelSettingsWidget::updateParameter() 314 | { 315 | QString str; 316 | DSOControlInfo dso; 317 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 318 | int coupling, range; 319 | double offset; 320 | 321 | if (channelMark == 0) 322 | { 323 | coupling = (int)dso.ch1Coupling; 324 | range = (int)dso.ch1VoltageRange; 325 | offset = dso.ch1Offset; 326 | } 327 | else // if(channelMark == 1) 328 | { 329 | coupling = (int)dso.ch2Coupling; 330 | range = (int)dso.ch2VoltageRange; 331 | offset = dso.ch2Offset; 332 | } 333 | 334 | if (coupling == DSO_COUPLING_DC) 335 | couplingButton->setText("DC"); 336 | else 337 | couplingButton->setText("AC"); 338 | 339 | voltageRangeLabel->setText(textVoltageRange[range][1]); 340 | 341 | if (channelMark == 0) 342 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch1VoltageRange]); 343 | else // if(channelMark == 1) 344 | str.sprintf("%.1lfV", offset / 2.5 * voltageRangeValue[(int)dso.ch2VoltageRange]); 345 | VoltageOffsetLabel->setText(str); 346 | } 347 | 348 | void ChannelSettingsWidget::switchButtonHandler() 349 | { 350 | static bool state = true; 351 | 352 | state = !state; 353 | 354 | if (state == true) 355 | switchButton->setText("ON"); 356 | else 357 | switchButton->setText("OFF"); 358 | 359 | emit switchStateChanged(channelMark, state); 360 | } 361 | 362 | void ChannelSettingsWidget::couplingButtonHandler() 363 | { 364 | DSOControlInfo dso; 365 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 366 | int coupling; 367 | 368 | if (channelMark == 0) 369 | coupling = (int)dso.ch1Coupling; 370 | else // if (channelMark == 1) 371 | coupling = (int)dso.ch2Coupling; 372 | 373 | switch (coupling) 374 | { 375 | case DSO_COUPLING_DC: 376 | coupling = DSO_COUPLING_AC; 377 | couplingButton->setText("AC"); 378 | break; 379 | case DSO_COUPLING_AC: 380 | coupling = DSO_COUPLING_DC; 381 | couplingButton->setText("DC"); 382 | break; 383 | default: 384 | break; 385 | } 386 | 387 | if (channelMark == 0) 388 | dso.ch1Coupling = coupling; 389 | else // if (channelMark == 1) 390 | dso.ch2Coupling = coupling; 391 | 392 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 393 | 394 | // emit couplingModeChanged(channelMark, status); 395 | } 396 | 397 | // 打开调色板,设置通道颜色 398 | void ChannelSettingsWidget::markColorButtonHandler() 399 | { 400 | // 打开系统调色板 401 | QColorDialog* m_pQColorDialog = new QColorDialog; 402 | 403 | // 获取并设置用户设置的颜色 404 | setMarkColor(m_pQColorDialog->getColor()); 405 | 406 | // 销毁对象 407 | delete m_pQColorDialog; 408 | } 409 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/channelsettingswidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CHANNELSETTINGSWIDGET_H 2 | #define CHANNELSETTINGSWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "systembutton.h" 14 | 15 | class ChannelSettingsWidget : public QGroupBox 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit ChannelSettingsWidget(QWidget *parent = 0, int mark = 0, QString str = "", QColor color = Qt::blue); 20 | ~ChannelSettingsWidget(); 21 | void setMarkColor(QColor color); 22 | void setVoltageOffsetDisplay(QString str); 23 | void setVoltageRangeDisplay(QString str); 24 | QColor getMarkColor(); 25 | 26 | void updateParameter(); 27 | 28 | public slots: 29 | void switchButtonHandler(); 30 | void couplingButtonHandler(); 31 | void markColorButtonHandler(); 32 | 33 | signals: 34 | void switchStateChanged(int, bool); 35 | void voltageOffsetChanged(int, int); 36 | void voltageRangeChanged(int, int); 37 | void couplingModeChanged(int, int); 38 | void markColoChange(int, QColor); 39 | 40 | protected: 41 | 42 | private: 43 | QWidget* parentWidget; 44 | QWidget* knob1; 45 | QWidget* knob2; 46 | QLabel* voltageRangeLabel; 47 | QLabel* VoltageOffsetLabel; 48 | QLabel* markColorLabel; 49 | 50 | SystemButton* switchButton; 51 | SystemButton* markColorButton; 52 | SystemButton* couplingButton; 53 | 54 | int knob1Count; 55 | int knob2Count; 56 | 57 | // 面板控制的参数 58 | int channelMark; 59 | int voltageRange; 60 | int voltageOffset; 61 | int couplingMode; 62 | bool channelEnable; 63 | QColor markColor; 64 | 65 | void mousePressEvent(QMouseEvent* event); 66 | void wheelEvent(QWheelEvent* event); 67 | void updateKnob(QWidget* widget); 68 | }; 69 | 70 | #endif // CHANNELSETTINGSWIDGET_H 71 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/mainwindowmenu.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindowmenu.h" 2 | 3 | MainWindowMenu::MainWindowMenu(QWidget *parent): 4 | QMenu(parent) 5 | { 6 | parentWindow = parent; 7 | 8 | this->setStyleSheet("QMenu{ background-color:white; border: 1px solid #0063B1; }" 9 | "QMenu::item:selected{ background-color: rgb(234, 243, 253); color: black;} "); 10 | 11 | connectAction = new QAction(this); 12 | ddsAction = new QAction(this); 13 | settingsAction = new QAction(this); 14 | aboutAction = new QAction(this); 15 | 16 | connectAction->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 17 | ddsAction->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 18 | settingsAction->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 19 | aboutAction->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 20 | 21 | connectAction->setText(CONNECT_WINDOW_TITLE); 22 | ddsAction->setText(DDS_WINDOW_TITLE); 23 | settingsAction->setText("全局设置"); 24 | aboutAction->setText(ABOUT_WINDOW_TITLE); 25 | 26 | this->addAction(connectAction); 27 | this->addAction(ddsAction); 28 | // this->addAction(settingsAction); 29 | this->addAction(aboutAction); 30 | } 31 | 32 | MainWindowMenu::~MainWindowMenu() 33 | { 34 | 35 | } 36 | 37 | void MainWindowMenu::intConnect() 38 | { 39 | connect(connectAction, SIGNAL(triggered()), parentWindow, SLOT(openConnectWindow()) ); 40 | connect(aboutAction, SIGNAL(triggered()), parentWindow, SLOT(openAboutWindow()) ); 41 | connect(ddsAction, SIGNAL(triggered()), parentWindow, SLOT(openDDSWindow()) ); 42 | } 43 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/mainwindowmenu.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOWMENU_H 2 | #define MAINWINDOWMENU_H 3 | 4 | #include 5 | #include 6 | #include "global.h" 7 | 8 | class MainWindowMenu : public QMenu 9 | { 10 | public: 11 | explicit MainWindowMenu(QWidget *parent = 0); 12 | ~MainWindowMenu(); 13 | void intConnect(); 14 | 15 | private: 16 | QWidget *parentWindow; 17 | QAction *connectAction; 18 | QAction *ddsAction; 19 | QAction *settingsAction; 20 | QAction *aboutAction; 21 | }; 22 | 23 | #endif // MAINWINDOWMENU_H 24 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/oscillographwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "oscillographwidget.h" 2 | #include "window/mainwindow.h" 3 | 4 | OscillographWidget::OscillographWidget(QWidget *parent, int number) : 5 | QWidget(parent) 6 | { 7 | pWidget = parent; 8 | 9 | this->setMinimumSize(1012, 627); 10 | this->setAutoFillBackground(true); 11 | this->setCursor(QCursor(Qt::CrossCursor)); 12 | 13 | // 更新界面标识为假 14 | updateWaveFlag = false; 15 | // 波形数据长度初始化为0 16 | waveDataLength = -1; 17 | // 波形数据指针初始化为空 18 | waveData = NULL; 19 | 20 | // 设置通道数 21 | channelNumber = number; 22 | 23 | // 分配显示缓冲内存 24 | try 25 | { 26 | for (int i=0; irepaint(); 74 | } 75 | 76 | // 77 | void OscillographWidget::dispWaveData(unsigned char* data, int length) 78 | { 79 | if (data != NULL) 80 | { 81 | updateWaveFlag = true; 82 | waveData = data; 83 | waveDataLength = length; 84 | } 85 | 86 | this->repaint(); 87 | } 88 | 89 | // 90 | void OscillographWidget::paintEvent(QPaintEvent *) 91 | { 92 | this->drawFrame(); 93 | this->drawWave(); 94 | this->displayMeasure(); 95 | } 96 | 97 | // 绘制示波器背景 98 | void OscillographWidget::drawFrame() 99 | { 100 | double width, height; 101 | double dx, dy; 102 | 103 | QPainter painter(this); 104 | painter.fillRect(QRect(0,0,this->width(),this->height()),"#101010"); 105 | 106 | width = (double) this->width(); 107 | height = (double) this->height(); 108 | dx = width / 10.0; 109 | dy = height / 8.0; 110 | 111 | painter.setPen(QPen(QColor(0x60,0x60,0x60),1,Qt::DotLine)); 112 | for (double x=dx; xwidth() ; 129 | int dispHeight = this->height(); 130 | 131 | double cnt = 0.0; 132 | double step = (double)dispWidth / (double)waveDataLength; 133 | QPainter painter(this); 134 | 135 | // 压缩显示波形 136 | for (int i=0; iwidth() - 270 - 10; 169 | int startY = 10; 170 | int mWidth = 240; 171 | int mHeight = 140; 172 | 173 | // 绘制方框 174 | painter.setPen(QPen(QColor(0x60,0x60,0x60),1,Qt::SolidLine)); 175 | painter.fillRect(QRect(startX, startY,mWidth,mHeight),QColor(0x60,0x60,0x60,200)); 176 | painter.drawRect(startX,startY,mWidth,mHeight); 177 | 178 | // 179 | painter.setPen(Qt::red); 180 | painter.setFont(QFont("微软雅黑",10,QFont::Bold,false)); 181 | switch(Mode) 182 | { 183 | case 0: 184 | str = "STATUS - RUN"; 185 | break; 186 | case 1: 187 | str = "STATUS - STOP"; 188 | break; 189 | case 2: 190 | str = "STATUS - SINGLE"; 191 | break; 192 | case 3: 193 | str = "STATUS - AUTO"; 194 | break; 195 | case 4: 196 | str = "STATUS - DEFAULT"; 197 | break; 198 | default: 199 | break; 200 | } 201 | painter.drawText(QRect(startX + 5, startY + 5, 180, 20), str); 202 | 203 | // 204 | painter.setPen(Qt::white); 205 | painter.setFont(QFont("微软雅黑",10,QFont::Normal,false)); 206 | // 207 | if (channelDisplayState[0]) 208 | { 209 | str = "CH1"; 210 | painter.drawText(QRect(startX + 5, startY + 5 + 20, 180, 20),str); 211 | painter.drawText(QRect(startX + 5, startY + 5 + 38, 180, 20),str); 212 | painter.drawText(QRect(startX + 5, startY + 5 + 56, 180, 20),str); 213 | 214 | double freq = avgFrequency(DSO_CHANNEL1, ((MainWindow *)pWidget)->usbThread.measureData[0][0]); 215 | if(freq >= 1000000.0) 216 | str.sprintf("频率:%.3lfMHz", freq / 1000000.0); 217 | else if(freq >= 1000.0) 218 | str.sprintf("频率:%.3lfKHz", freq / 1000.0); 219 | else if(freq == 0.0) 220 | str.sprintf("频率:No edge"); 221 | else 222 | str.sprintf("频率:%.3lfHz", freq); 223 | painter.drawText(QRect(startX + 40, startY + 5 + 20, 180, 20),str); 224 | 225 | str.sprintf("峰峰值:%.2lf V", ((MainWindow *)pWidget)->usbThread.measureData[0][1]); 226 | painter.drawText(QRect(startX + 40, startY + 5 + 38, 180, 20),str); 227 | 228 | str.sprintf("有效值:%.2lf V", ((MainWindow *)pWidget)->usbThread.measureData[0][2]); 229 | painter.drawText(QRect(startX + 40, startY + 5 + 56, 180, 20),str); 230 | } 231 | // 232 | if (channelDisplayState[1]) 233 | { 234 | str = "CH2"; 235 | painter.drawText(QRect(startX + 5, startY + 5 + 74, 180, 20),str); 236 | painter.drawText(QRect(startX + 5, startY + 5 + 92, 180, 20),str); 237 | painter.drawText(QRect(startX + 5, startY + 5 + 110, 180, 20),str); 238 | 239 | double freq = avgFrequency(DSO_CHANNEL2, ((MainWindow *)pWidget)->usbThread.measureData[1][0]); 240 | if(freq >= 1000000.0) 241 | str.sprintf("频率:%.3lfMHz", freq / 1000000.0); 242 | else if(freq >= 1000.0) 243 | str.sprintf("频率:%.3lfKHz", freq / 1000.0); 244 | else if(freq == 0.0) 245 | str.sprintf("频率:No edge"); 246 | else 247 | str.sprintf("频率:%.3lfHz", freq); 248 | painter.drawText(QRect(startX + 40, startY + 5 + 74, 180, 20),str); 249 | 250 | str.sprintf("峰峰值:%.2lf V", ((MainWindow *)pWidget)->usbThread.measureData[1][1]); 251 | painter.drawText(QRect(startX + 40, startY + 5 + 92, 180, 20),str); 252 | 253 | str.sprintf("有效值:%.2lf V", ((MainWindow *)pWidget)->usbThread.measureData[1][2]); 254 | painter.drawText(QRect(startX + 40, startY + 5 + 110, 180, 20),str); 255 | } 256 | 257 | // 触发线 258 | double width, height; 259 | double dy; 260 | width = this->width(); 261 | height = this->height(); 262 | dy = height / 8.0; 263 | 264 | DSOControlInfo dso; 265 | ((MainWindow *)pWidget)->usbThread.getDSOParameter(dso); 266 | 267 | double dbTemp; 268 | double voltageRange; 269 | if (dso.trigChannel == DSO_CHANNEL1) 270 | voltageRange = dso.ch1VoltageRange; 271 | else 272 | voltageRange = dso.ch2VoltageRange; 273 | switch ((int)voltageRange) 274 | { 275 | case 0: dbTemp = 80/2.0; break; 276 | case 1: dbTemp = 40/2.0; break; 277 | case 2: dbTemp = 16/2.0; break; 278 | case 3: dbTemp = 8/2.0; break; 279 | case 4: dbTemp = 4/2.0; break; 280 | case 5: dbTemp = 1.6/2.0; break; 281 | case 6: dbTemp = 0.8/2.0; break; 282 | case 7: dbTemp = 0.4/2.0; break; 283 | case 8: dbTemp = 0.16/2.0; break; 284 | case 9: dbTemp = 0.04/2.0; break; 285 | default: break; 286 | } 287 | dbTemp /= height; 288 | dbTemp = (dso.trigLevel - 1.25) / dbTemp; 289 | painter.setPen(QPen(Qt::green,1,Qt::SolidLine)); 290 | painter.drawLine(0, (int)(dy*4 - dbTemp + 0.5), width, (int)(dy*4 - dbTemp + 0.5)); 291 | painter.drawPixmap(0, (int)(dy*4 - dbTemp + 0.5) - 6, QPixmap(":/img/osc/Trig.png")); 292 | 293 | painter.drawPixmap(width - 16, (int)(dy*4+0.5) - 3, QPixmap(":/img/osc/gnd3.png")); 294 | } 295 | 296 | double OscillographWidget::avgFrequency(int channel, double frequency) 297 | { 298 | using namespace std; 299 | 300 | if (channel == DSO_CHANNEL1) 301 | { 302 | if (listFreq1.size() >= 20) 303 | { 304 | listFreq1.pop_front(); 305 | } 306 | listFreq1.push_back(frequency); 307 | 308 | double sum = 0.0; 309 | for (list::iterator it = listFreq1.begin(); it != listFreq1.end() ; it++) 310 | { 311 | sum += *it; 312 | } 313 | return sum / listFreq1.size(); 314 | } 315 | else 316 | { 317 | if (listFreq2.size() >= 20) 318 | { 319 | listFreq2.pop_front(); 320 | } 321 | listFreq2.push_back(frequency); 322 | 323 | double sum = 0.0; 324 | for (list::iterator it = listFreq2.begin(); it != listFreq2.end() ; it++) 325 | { 326 | sum += *it; 327 | } 328 | return sum / listFreq2.size(); 329 | } 330 | } 331 | 332 | // widget的鼠标滚轮事件 333 | void OscillographWidget::wheelEvent(QWheelEvent *event) 334 | { 335 | if (event->delta() > 0) 336 | {} 337 | else 338 | {} 339 | } 340 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/oscillographwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef UDSOOSCILLOGRAPHWIDGET_H 2 | #define UDSOOSCILLOGRAPHWIDGET_H 3 | 4 | #include "global.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | class OscillographWidget : public QWidget 23 | { 24 | Q_OBJECT 25 | public: 26 | explicit OscillographWidget(QWidget *parent = 0, int number = 0); 27 | ~OscillographWidget(); 28 | void setWidgetSize(int height, int width); 29 | void dispWaveData(unsigned char* data, int length); 30 | 31 | public slots: 32 | void setChannelMarkColor(int chn, QColor color); // channelsettings 通过信号槽直接关联 33 | void setChannelDisplay(int chn, bool state); // channelsettings 直接 34 | void updateMode(int status); 35 | 36 | protected: 37 | void wheelEvent(QWheelEvent *event); 38 | 39 | private: 40 | QWidget* pWidget; 41 | 42 | int channelNumber; 43 | bool updateWaveFlag; 44 | unsigned char* waveData; 45 | int waveDataLength; 46 | QPoint* dispBufferArray[4]; 47 | 48 | // 测量参数 49 | long int freqValue; 50 | double vppValue; 51 | double vrmsValue; 52 | 53 | // 示波器状态 54 | int Mode; 55 | 56 | // 最多支持4通道 57 | QColor channelMarkColor[4]; 58 | bool channelDisplayState[4]; 59 | 60 | void paintEvent(QPaintEvent *); 61 | void drawFrame(); 62 | void drawWave(); 63 | void displayMeasure(); 64 | 65 | std::list listFreq1; 66 | std::list listFreq2; 67 | double avgFrequency(int channel, double frequency); 68 | }; 69 | 70 | #endif // UDSOOSCILLOGRAPHWIDGET_H 71 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/sampleratesettingwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "sampleratesettingwidget.h" 2 | #include "window/mainwindow.h" 3 | 4 | SampleRateSettingWidget::SampleRateSettingWidget(QWidget *parent) : 5 | QGroupBox(parent) 6 | { 7 | parentWidget = parent; 8 | 9 | this->setFixedSize(160,95); 10 | this->setStyleSheet("QGroupBox { " 11 | "background: rgb(255, 255, 255); " 12 | "border: 1px solid gray; " 13 | "border-color:black; " 14 | "margin-top: 10px; }" 15 | 16 | "QGroupBox::title { " 17 | "color: black; " 18 | "subcontrol-origin: margin; " 19 | "subcontrol-position: top left; " 20 | "left:7px; margin-left: 0px; " 21 | "padding: 0 1 px; }"); 22 | this->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 23 | this->setTitle("采样速率"); 24 | 25 | // 旋钮 26 | knobWidget = new QWidget(this); 27 | knobCount = 0; 28 | knobWidget->setFixedSize(64, 64); 29 | knobWidget->setStyleSheet("border-image: url(:/img/knob/knob0.png);"); 30 | knobWidget->move(95,20); 31 | 32 | // 标签 33 | sampleRateLabel = new QLabel(this); 34 | sampleRateLabel->setFrameShape(QFrame::Box); 35 | sampleRateLabel->setStyleSheet("QLabel { color: blue; border: 1px solid gray; }"); 36 | sampleRateLabel->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 37 | sampleRateLabel->setText("100M/s"); 38 | sampleRateLabel->setGeometry(10, knobWidget->y()+5, 80, 25); 39 | sampleRateLabel->setAlignment(Qt::AlignCenter); 40 | 41 | // 标签 42 | resolutionLabel = new QLabel(this); 43 | resolutionLabel->setFrameShape(QFrame::Box); 44 | resolutionLabel->setStyleSheet("QLabel { color: blue; border: 1px solid gray;}"); 45 | resolutionLabel->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 46 | resolutionLabel->setText("10us/Div"); 47 | resolutionLabel->setGeometry(10, sampleRateLabel->y()+30, 80, 25); 48 | resolutionLabel->setAlignment(Qt::AlignCenter); 49 | 50 | updateParameter(); 51 | } 52 | 53 | SampleRateSettingWidget::~SampleRateSettingWidget() 54 | { 55 | 56 | } 57 | 58 | void SampleRateSettingWidget::setSampleRateDisplay(QString str) 59 | { 60 | sampleRateLabel->setText(str); 61 | } 62 | 63 | void SampleRateSettingWidget::setResolutionDisplay(QString str) 64 | { 65 | resolutionLabel->setText(str); 66 | } 67 | 68 | void SampleRateSettingWidget::updateParameter() 69 | { 70 | DSOControlInfo dso; 71 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 72 | sampleRateLabel->setText(textSampleRate[(int)dso.sampleRate][0]); 73 | resolutionLabel->setText(textSampleRate[(int)dso.sampleRate][1]); 74 | } 75 | 76 | void SampleRateSettingWidget::mousePressEvent(QMouseEvent *event) 77 | { 78 | if ( event->x() >= knobWidget->x() 79 | && event->x() <= knobWidget->x() + knobWidget->width() 80 | && event->y() >= knobWidget->y() 81 | && event->y() <= knobWidget->y() + knobWidget->height() 82 | ) 83 | { 84 | DSOControlInfo dso; 85 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 86 | int rate = (int)dso.sampleRate; 87 | 88 | if (event->button() == Qt::LeftButton) 89 | { 90 | knobCount = (knobCount+1)%8; 91 | rate = (rate <= 0) ? 0 : (rate-1); 92 | emit sampleRateChanged(1); 93 | } 94 | else if (event->button() == Qt::RightButton) 95 | { 96 | knobCount = knobCount <= 0 ? 7 : knobCount-1; 97 | rate = (rate >= (DSO_SAMPLE_RATE_NUM - 1)) ? (DSO_SAMPLE_RATE_NUM - 1) : (rate+1); 98 | emit sampleRateChanged(-1); 99 | } 100 | 101 | dso.sampleRate = rate; 102 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 103 | sampleRateLabel->setText(textSampleRate[rate][0]); 104 | resolutionLabel->setText(textSampleRate[rate][1]); 105 | 106 | updateKnob(knobWidget); 107 | } 108 | } 109 | 110 | void SampleRateSettingWidget::wheelEvent(QWheelEvent *event) 111 | { 112 | if (event->x() >= knobWidget->x() 113 | && event->x() <= knobWidget->x() + knobWidget->width() 114 | && event->y() >= knobWidget->y() 115 | && event->y() <= knobWidget->y() + knobWidget->height() 116 | ) 117 | { 118 | DSOControlInfo dso; 119 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 120 | int rate = (int)dso.sampleRate; 121 | 122 | if (event->delta() > 0) 123 | { 124 | knobCount = ( knobCount+1 ) % 8; 125 | rate = (rate <= 0) ? 0 : (rate-1); 126 | emit sampleRateChanged(1); 127 | } 128 | else 129 | { 130 | knobCount = knobCount <= 0 ? 7 : knobCount-1; 131 | rate = (rate >= (DSO_SAMPLE_RATE_NUM - 1)) ? (DSO_SAMPLE_RATE_NUM - 1) : (rate+1); 132 | emit sampleRateChanged(-1); 133 | } 134 | 135 | dso.sampleRate = rate; 136 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 137 | sampleRateLabel->setText(textSampleRate[rate][0]); 138 | resolutionLabel->setText(textSampleRate[rate][1]); 139 | 140 | // 更新滚轮状态 141 | updateKnob(knobWidget); 142 | } 143 | } 144 | 145 | void SampleRateSettingWidget::updateKnob(QWidget *widget) 146 | { 147 | QString str; 148 | 149 | if (widget == knobWidget) 150 | str.sprintf("border-image: url(:/img/knob/knob%d.png);",knobCount); 151 | 152 | widget->setStyleSheet(str); 153 | } 154 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/sampleratesettingwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLERATESETTINGWIDGET_H 2 | #define SAMPLERATESETTINGWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class SampleRateSettingWidget : public QGroupBox 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit SampleRateSettingWidget(QWidget *parent = 0); 17 | ~SampleRateSettingWidget(); 18 | void setSampleRateDisplay(QString str); 19 | void setResolutionDisplay(QString str); 20 | 21 | void updateParameter(); 22 | 23 | signals: 24 | void sampleRateChanged(int); 25 | 26 | public slots: 27 | 28 | private: 29 | QWidget* parentWidget; 30 | QWidget* knobWidget; 31 | QLabel* sampleRateLabel; 32 | QLabel* resolutionLabel; 33 | int knobCount; 34 | 35 | void mousePressEvent(QMouseEvent *event); 36 | void wheelEvent(QWheelEvent *event); 37 | void updateKnob(QWidget *widget); 38 | }; 39 | 40 | #endif // SAMPLERATESETTINGWIDGET_H 41 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/statusbarwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "statusbarwidget.h" 2 | #include 3 | #include 4 | #include 5 | 6 | StatusBarWidget::StatusBarWidget( 7 | QWidget *parent, 8 | int height) : 9 | QWidget(parent) 10 | { 11 | parent_widget = parent; 12 | 13 | isShowTime = false; 14 | 15 | // this->setFixedSize(parent_widget->width(), height); 16 | this->setMinimumSize(parent_widget->width(), height); 17 | this->setFixedHeight(height); 18 | 19 | // 设置状态栏背景颜色 20 | QPalette palette = this->palette(); 21 | palette.setColor(QPalette::Window,"#0063B1"); 22 | this->setPalette(palette); 23 | this->setAutoFillBackground(true); 24 | 25 | // 信息显示区 26 | message_label = new QLabel(this); 27 | message_label->setMinimumSize(600, this->height()); 28 | message_label->setStyleSheet("QLabel{color:rgb(255, 255, 255);}"); 29 | message_label->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 30 | 31 | // 时间显示区 32 | time_label = new QLabel(this); 33 | time_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); 34 | time_label->setMinimumSize(150, this->height()); 35 | time_label->setStyleSheet("QLabel{color:rgb(255, 255, 255);}"); 36 | time_label->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 37 | 38 | // 布局 39 | QHBoxLayout *layout =new QHBoxLayout(); 40 | QSpacerItem *hSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); 41 | layout->addWidget(message_label); 42 | layout->addSpacerItem(hSpacer); 43 | layout->addWidget(time_label); 44 | layout->setContentsMargins(5, 0, 5, 0); 45 | this->setLayout(layout); 46 | 47 | // 设置显示时间的定时器 48 | show_time_timer = new QTimer(this); 49 | connect(show_time_timer, SIGNAL(timeout()), this, SLOT(showTime()) ); 50 | } 51 | 52 | StatusBarWidget::~StatusBarWidget() 53 | { 54 | 55 | } 56 | 57 | void StatusBarWidget::isEnabledShowTime(bool flag) 58 | { 59 | if (flag == true && isShowTime != true) 60 | show_time_timer->start(500); 61 | else if (flag == false && isShowTime != false) 62 | show_time_timer->stop(); 63 | else 64 | {} 65 | 66 | isShowTime = flag; 67 | } 68 | 69 | void StatusBarWidget::setWidth(int width) 70 | { 71 | this->setFixedSize(width, this->height()); 72 | // message_label->setGeometry(5, 0, 600, this->height()); 73 | time_label->setGeometry(width-155, 0, 150, this->height()); 74 | } 75 | 76 | void StatusBarWidget::showMessage(QString str) 77 | { 78 | message_label->setText(str); 79 | } 80 | 81 | void StatusBarWidget::showTime() 82 | { 83 | QDateTime time = QDateTime::currentDateTime(); 84 | QString str = time.toString("yyyy.MM.dd hh:mm:ss"); 85 | time_label->setText(str); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/statusbarwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef STATUSBARWIDGET_H 2 | #define STATUSBARWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class StatusBarWidget : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit StatusBarWidget(QWidget *parent = 0,int height = 25); 14 | ~StatusBarWidget(); 15 | void isEnabledShowTime(bool flag); 16 | void setWidth(int width); 17 | void showMessage(QString str); 18 | 19 | signals: 20 | 21 | public slots: 22 | void showTime(); 23 | 24 | private: 25 | QWidget* parent_widget; 26 | bool isShowTime; 27 | QLabel* message_label; 28 | QLabel* time_label; 29 | QTimer* show_time_timer; 30 | }; 31 | 32 | #endif // STATUSBARWIDGET_H 33 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/systembutton.cpp: -------------------------------------------------------------------------------- 1 | #include "systembutton.h" 2 | #include 3 | 4 | SystemButton::SystemButton(QWidget *parent, QString str): 5 | QPushButton(parent) 6 | { 7 | this->setFixedSize(75,25); 8 | this->setFocusPolicy(Qt::NoFocus); 9 | this->setStyleSheet("QPushButton{ " 10 | "color: rgb(0, 0, 0); " 11 | "background-color: rgb(255, 255, 255); " 12 | "border: 1px solid gray; " 13 | "border-radius: 0px; " 14 | "text-align : center;}" 15 | 16 | "QPushButton::hover{ " 17 | "background-color: rgb(229, 241, 251); " 18 | "border: 1px solid rgb(0, 120, 215); }" 19 | 20 | "QPushButton::pressed{ " 21 | "color: white; " 22 | "background-color: rgb(0, 99, 177); " 23 | "border: 1px solid rgb(0, 84, 153);}" 24 | 25 | "QPushButton::disabled{ " 26 | "color: rgb(114, 114, 114); " 27 | "background-color: rgb(220, 220, 220); " 28 | "border: 1px solid gray; }"); 29 | this->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 30 | this->setText(str); 31 | } 32 | 33 | SystemButton::~SystemButton() 34 | { 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/systembutton.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMBUTTON_H 2 | #define SYSTEMBUTTON_H 3 | 4 | #include 5 | #include 6 | 7 | class SystemButton : public QPushButton 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit SystemButton(QWidget *parent = 0, QString str=""); 12 | virtual ~SystemButton(); 13 | }; 14 | 15 | #endif // SYSTEMBUTTON_H 16 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/titlebarwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "titlebarwidget.h" 2 | #include 3 | 4 | TitleBarWidget::TitleBarWidget( 5 | QWidget *parent, 6 | QString str, 7 | int height, 8 | bool is_show_all_button) : 9 | QWidget(parent) 10 | { 11 | parent_widget = parent; 12 | 13 | isShowAllButton = is_show_all_button; 14 | mouse_pressed = false; 15 | window_maximize = false; 16 | 17 | this->setMinimumSize(parent_widget->width(), height); 18 | this->setFixedHeight(height); 19 | 20 | // 设置标题背景颜色 21 | QPalette palette = this->palette(); 22 | palette.setColor(QPalette::Window,"#0063B1"); 23 | this->setPalette(palette); 24 | this->setAutoFillBackground(true); 25 | 26 | // 设置标题栏图标 27 | icon = new QLabel(this); 28 | icon->setMinimumSize(this->height(), this->height()); 29 | // icon->setStyleSheet("QLabel{border-image: url(:/img/etc/logo_border.png); }"); 30 | icon->setStyleSheet("QLabel{border-image: url(:/img/etc/logo_border.png); }"); 31 | // 设置标题文字 32 | title_text = new QLabel(this); 33 | title_text->setMinimumSize(100, this->height()); 34 | title_text->setStyleSheet("QLabel{color:rgb(255, 255, 255);}"); 35 | title_text->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 36 | title_text->setText(tr(" ") + str); 37 | 38 | // 设置按钮 39 | if (isShowAllButton == true) 40 | { 41 | // 创建PushButton 42 | menu_button = new QPushButton(this); 43 | min_button = new QPushButton(this); 44 | max_button = new QPushButton(this); 45 | restore_button = new QPushButton(this); 46 | close_button = new QPushButton(this); 47 | // 设置PushButtond的大小 48 | menu_button->setFixedSize(46,this->height()); 49 | min_button->setFixedSize(46,this->height()); 50 | max_button->setFixedSize(46,this->height()); 51 | restore_button->setFixedSize(46,this->height()); 52 | close_button->setFixedSize(46,this->height()); 53 | // 设置PushButton的样式 54 | menu_button->setStyleSheet("QPushButton{border-image: url(:/img/button/menu_normal.png);}" 55 | "QPushButton:hover{border-image: url(:/img/button/menu_hover.png);}" 56 | "QPushButton:pressed{border-image: url(:/img/button/menu_pressed.png);}"); 57 | min_button->setStyleSheet("QPushButton{border-image: url(:/img/button/min_normal.png);}" 58 | "QPushButton:hover{border-image: url(:/img/button/min_hover.png);}" 59 | "QPushButton:pressed{border-image: url(:/img/button/min_pressed.png);}"); 60 | max_button->setStyleSheet("QPushButton{border-image: url(:/img/button/max_normal.png);}" 61 | "QPushButton:hover{border-image: url(:/img/button/max_hover.png);}" 62 | "QPushButton:pressed{border-image: url(:/img/button/max_pressed.png);}"); 63 | restore_button->setStyleSheet("QPushButton{border-image: url(:/img/button/restore_normal.png);}" 64 | "QPushButton:hover{border-image: url(:/img/button/restore_hover.png);}" 65 | "QPushButton:pressed{border-image: url(:/img/button/restore_pressed.png);}"); 66 | close_button->setStyleSheet("QPushButton{border-image: url(:/img/button/close_normal.png);}" 67 | "QPushButton:hover{border-image: url(:/img/button/close_hover.png);}" 68 | "QPushButton:pressed{border-image: url(:/img/button/close_pressed.png);}"); 69 | // PushButton无焦点 70 | menu_button->setFocusPolicy(Qt::NoFocus); 71 | min_button->setFocusPolicy(Qt::NoFocus); 72 | max_button->setFocusPolicy(Qt::NoFocus); 73 | restore_button->setFocusPolicy(Qt::NoFocus); 74 | close_button->setFocusPolicy(Qt::NoFocus); 75 | // 使最大化按钮不可见 76 | restore_button->setVisible(false); 77 | } 78 | else 79 | { 80 | // 创建PushButton 81 | close_button = new QPushButton(this); 82 | // 设置PushButtond的大小 83 | close_button->setFixedSize(46,this->height()); 84 | // 设置PushButton的样式 85 | close_button->setStyleSheet("QPushButton{border-image: url(:/img/button/close_normal.png);}" 86 | "QPushButton:hover{border-image: url(:/img/button/close_hover.png);}" 87 | "QPushButton:pressed{border-image: url(:/img/button/close_pressed.png);}"); 88 | // PushButton无焦点 89 | close_button->setFocusPolicy(Qt::NoFocus); 90 | } 91 | 92 | // 93 | if (isShowAllButton == true) 94 | { 95 | QHBoxLayout *layout = new QHBoxLayout(); 96 | QSpacerItem *hSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); 97 | layout->addWidget(icon,0); 98 | layout->addWidget(title_text,1); 99 | layout->addSpacerItem(hSpacer); 100 | layout->addWidget(menu_button,2); 101 | layout->addWidget(min_button,3); 102 | layout->addWidget(max_button,4); 103 | layout->addWidget(restore_button,4); 104 | layout->addWidget(close_button,5); 105 | layout->setSpacing(0); 106 | layout->setContentsMargins(5,0,0,0); 107 | this->setLayout(layout); 108 | } 109 | else 110 | { 111 | QHBoxLayout *layout = new QHBoxLayout(); 112 | QSpacerItem *hSpacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); 113 | layout->addWidget(icon,0); 114 | layout->addWidget(title_text,1); 115 | layout->addSpacerItem(hSpacer); 116 | layout->addWidget(close_button,2); 117 | layout->setSpacing(0); 118 | layout->setContentsMargins(5,0,0,0); 119 | this->setLayout(layout); 120 | } 121 | 122 | } 123 | 124 | TitleBarWidget::~TitleBarWidget() 125 | { 126 | 127 | } 128 | 129 | void TitleBarWidget::initConnect() 130 | { 131 | if (isShowAllButton == true) 132 | { 133 | connect(menu_button, SIGNAL(clicked()), parent_widget, SLOT(showMainMenu()) ); 134 | connect(min_button, SIGNAL(clicked()), parent_widget, SLOT(showMinimized()) ); 135 | connect(max_button, SIGNAL(clicked()), this, SLOT(maximizeWindow()) ); 136 | connect(restore_button, SIGNAL(clicked()), this, SLOT(restoreWindow()) ); 137 | connect(close_button, SIGNAL(clicked()), this, SIGNAL(closeWindow()) ); 138 | } 139 | else 140 | { 141 | connect(close_button, SIGNAL(clicked()), this, SIGNAL(closeWindow()) ); 142 | } 143 | } 144 | 145 | void TitleBarWidget::maximizeWindow() 146 | { 147 | if (window_maximize == false) 148 | { 149 | parent_widget->showMaximized(); 150 | max_button->setVisible(false); 151 | restore_button->setVisible(true); 152 | } 153 | window_maximize = true; 154 | } 155 | 156 | void TitleBarWidget::restoreWindow() 157 | { 158 | if (window_maximize == true) 159 | { 160 | parent_widget->showNormal(); 161 | max_button->setVisible(true); 162 | restore_button->setVisible(false); 163 | } 164 | window_maximize = false; 165 | } 166 | 167 | void TitleBarWidget::mousePressEvent(QMouseEvent *event) 168 | { 169 | if(event->button() == Qt::LeftButton) 170 | mouse_pressed = true; 171 | drag_position = event->globalPos() - parent_widget->pos(); 172 | } 173 | 174 | void TitleBarWidget::mouseDoubleClickEvent(QMouseEvent *event) 175 | { 176 | if (isShowAllButton == true) 177 | { 178 | if(event->button() == Qt::LeftButton) 179 | { 180 | if (window_maximize == true) 181 | restoreWindow(); 182 | else 183 | maximizeWindow(); 184 | } 185 | } 186 | } 187 | 188 | void TitleBarWidget::mouseReleaseEvent(QMouseEvent *) 189 | { 190 | mouse_pressed = false; 191 | parent_widget-> setWindowOpacity(1); 192 | 193 | if (isShowAllButton == true) 194 | { 195 | if (parent_widget->y() <= 0) 196 | { 197 | maximizeWindow(); 198 | } 199 | } 200 | } 201 | 202 | void TitleBarWidget::mouseMoveEvent(QMouseEvent *event) 203 | { 204 | if(mouse_pressed == true) 205 | { 206 | if (window_maximize == true && isShowAllButton == true) 207 | { 208 | restoreWindow(); 209 | } 210 | else 211 | { 212 | QPoint movePosition = event->globalPos(); 213 | parent_widget->move(movePosition - drag_position); 214 | parent_widget->setWindowOpacity(0.3); 215 | } 216 | } 217 | } 218 | 219 | 220 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/titlebarwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TITLEBARWIDGET_H 2 | #define TITLEBARWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class TitleBarWidget : public QWidget 13 | { 14 | Q_OBJECT 15 | public: 16 | explicit TitleBarWidget(QWidget *parent = 0, 17 | QString str = "", 18 | int height = 30, 19 | bool is_show_all_button = true); 20 | ~TitleBarWidget(); 21 | void initConnect(); 22 | void setWidth(int width); 23 | 24 | signals: 25 | void closeWindow(); 26 | 27 | public slots: 28 | void maximizeWindow(); 29 | void restoreWindow(); 30 | 31 | protected: 32 | 33 | private: 34 | QWidget *parent_widget; 35 | QLabel *icon; 36 | QLabel *title_text; 37 | QPushButton *menu_button; 38 | QPushButton *min_button; 39 | QPushButton *max_button; 40 | QPushButton *restore_button; 41 | QPushButton *close_button; 42 | bool isShowAllButton; 43 | bool mouse_pressed; 44 | bool window_maximize; 45 | QPoint drag_position; 46 | 47 | void mousePressEvent(QMouseEvent *event); 48 | void mouseDoubleClickEvent(QMouseEvent *event); 49 | void mouseReleaseEvent(QMouseEvent *event); 50 | void mouseMoveEvent(QMouseEvent *event); 51 | }; 52 | 53 | #endif // TITLEBARWIDGET_H 54 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/triggerwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "triggerwidget.h" 2 | #include 3 | #include "window/mainwindow.h" 4 | 5 | TriggerWidget::TriggerWidget(QWidget *parent): 6 | QGroupBox(parent) 7 | { 8 | parentWidget = parent; 9 | 10 | this->setFixedSize(160,125); 11 | this->setStyleSheet("QGroupBox { " 12 | "background: rgb(255, 255, 255); " 13 | "border: 1px solid gray; " 14 | "border-color:black; " 15 | "margin-top: 10px; }" 16 | 17 | "QGroupBox::title { " 18 | "color: black; " 19 | "subcontrol-origin: margin; " 20 | "subcontrol-position: top left; " 21 | "left:7px; margin-left: 0px; " 22 | "padding: 0 1 px; }"); 23 | this->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 24 | this->setTitle("触发"); 25 | 26 | channelLabel = new QLabel(this); 27 | edgeLabel = new QLabel(this); 28 | levelLabel = new QLabel(this); 29 | channelLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 30 | edgeLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 31 | levelLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 32 | channelLabel->setText("通道"); 33 | edgeLabel->setText("边沿"); 34 | levelLabel->setText("触发电平"); 35 | channelLabel->setGeometry(10, 25, 80, 25); 36 | edgeLabel->setGeometry(10, 55, 80, 25); 37 | levelLabel->setGeometry(10, 85, 120, 25); 38 | 39 | // 下拉菜单样式表 40 | QString str("QComboBox{" 41 | "border: 1px solid gray;" 42 | "border-radius: 0px;" 43 | " padding: 1px 2px 1px 2px;}" 44 | "QComboBox::drop-down{" 45 | "subcontrol-origin: padding;" 46 | "subcontrol-position: top right;" 47 | "width: 20px;" 48 | "border-left-width: 1px;" 49 | "border-left-color: darkgray;" 50 | "border-left-style: solid;" 51 | "border-top-right-radius: 5px;" 52 | "border-bottom-right-radius: 5px;}" 53 | "QComboBox::hover{border-color: rgb(0, 170, 255) ;}" 54 | "QComboBox::down-arrow{image: url(:/img/arrow/arrow_down.png);}"); 55 | channelComboBox = new QComboBox(this); 56 | edgeComboBox = new QComboBox(this); 57 | levelComboBox = new QComboBox(this); 58 | channelComboBox->setStyleSheet(str); 59 | edgeComboBox->setStyleSheet(str); 60 | levelComboBox->setStyleSheet(str); 61 | channelComboBox->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 62 | edgeComboBox->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 63 | levelComboBox->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 64 | 65 | // 增加按键选项 66 | channelComboBox->addItem("CH1"); 67 | channelComboBox->addItem("CH2"); 68 | edgeComboBox->addItem("上升沿"); 69 | edgeComboBox->addItem("下降沿"); 70 | for (int i=0; i<=100; i+=10) 71 | { 72 | levelComboBox->addItem(str.sprintf("%.2lfV",2.5 * i/100.0 - 1.25)); 73 | } 74 | // 按键放置 75 | channelComboBox->setGeometry(50, 25, 100, 25); 76 | edgeComboBox->setGeometry( 50, 55, 100, 25); 77 | levelComboBox->setGeometry( 70, 85, 80, 25); 78 | 79 | updateParameter(); 80 | 81 | // 设置信号槽 82 | connect(channelComboBox, SIGNAL(currentTextChanged(const QString &)), this, SLOT(channelComboBoxHandler(const QString & )) ); 83 | connect(edgeComboBox , SIGNAL(currentTextChanged(const QString &)), this, SLOT(edgeComboBoxHandler(const QString &)) ); 84 | connect(levelComboBox , SIGNAL(currentTextChanged(const QString &)), this, SLOT(levelComboBoxHandler(const QString &)) ); 85 | } 86 | 87 | TriggerWidget::~TriggerWidget() 88 | { 89 | 90 | } 91 | 92 | void TriggerWidget::updateParameter() 93 | { 94 | QString str; 95 | 96 | DSOControlInfo dso; 97 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 98 | int channel=(int)dso.trigChannel; 99 | int edge=(int)dso.trigEdge; 100 | double level=dso.trigLevel; 101 | 102 | if (channel == DSO_CHANNEL1) 103 | channelComboBox->setCurrentText("CH1"); 104 | else 105 | channelComboBox->setCurrentText("CH2"); 106 | 107 | if (edge == DSO_TRIG_RAISE) 108 | channelComboBox->setCurrentText("上升沿"); 109 | else 110 | channelComboBox->setCurrentText("下降沿"); 111 | 112 | str.sprintf("%.2lfV",level-1.25); 113 | levelComboBox->setCurrentText(str); 114 | } 115 | 116 | void TriggerWidget::channelComboBoxHandler(const QString & data) 117 | { 118 | DSOControlInfo dso; 119 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 120 | 121 | if(data == "CH1") 122 | dso.trigChannel = DSO_CHANNEL1; 123 | else // if(data == "CH2") 124 | dso.trigChannel = DSO_CHANNEL2; 125 | 126 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 127 | 128 | // emit signal_channelChanged(res); 129 | } 130 | 131 | void TriggerWidget::edgeComboBoxHandler(const QString & data) 132 | { 133 | DSOControlInfo dso; 134 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 135 | 136 | if(data == "上升沿") 137 | dso.trigEdge = DSO_TRIG_RAISE; 138 | else //if (data == "下降沿") 139 | dso.trigEdge = DSO_TRIG_FALL; 140 | 141 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 142 | 143 | // emit signal_edgeChanged(res); 144 | } 145 | 146 | void TriggerWidget::levelComboBoxHandler(const QString & data) 147 | { 148 | DSOControlInfo dso; 149 | ((MainWindow *)parentWidget)->usbThread.getDSOParameter(dso); 150 | 151 | QString str; 152 | for (int i = 0; i < 100; i+=10) 153 | { 154 | str.sprintf("%.2lfV", 2.5 * i / 100.0 - 1.25); 155 | if (data == str) 156 | { 157 | dso.trigLevel = 2.5 * i / 100.0; 158 | break; 159 | } 160 | } 161 | 162 | ((MainWindow *)parentWidget)->usbThread.setDSOParameter(dso); 163 | 164 | // emit signal_levelChanged(res); 165 | } 166 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/component/triggerwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef TRIGGERWIDGET_H 2 | #define TRIGGERWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class TriggerWidget : public QGroupBox 12 | { 13 | Q_OBJECT 14 | public: 15 | TriggerWidget(QWidget *parent = 0); 16 | ~TriggerWidget(); 17 | void updateParameter(); 18 | 19 | signals: 20 | void signal_channelChanged(int data); 21 | void signal_edgeChanged(int data); 22 | void signal_levelChanged(int data); 23 | 24 | public slots: 25 | void channelComboBoxHandler(const QString & data); 26 | void edgeComboBoxHandler(const QString & data); 27 | void levelComboBoxHandler(const QString & data); 28 | 29 | private: 30 | QWidget* parentWidget; 31 | 32 | QLabel* channelLabel; 33 | QLabel* edgeLabel; 34 | QLabel* levelLabel; 35 | 36 | QComboBox* channelComboBox; 37 | QComboBox* edgeComboBox; 38 | QComboBox* levelComboBox; 39 | }; 40 | 41 | #endif // TRIGGERWIDGET_H 42 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/global.cpp: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | 3 | QString g_Platform = "UNKNOWN"; 4 | usb* g_USBDevice = NULL; 5 | 6 | QString g_ApplicationDirPath = ""; 7 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/global.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBAL 2 | #define GLOBAL 3 | 4 | #include 5 | #include "usb/usb.h" 6 | 7 | // 程序版本号 8 | #define UDSO_VERSION "0.0.6" 9 | // 程序更新日期 10 | #define UDSO_UPDATE "2017.01.01" 11 | // 开发者 12 | #define USDO_AUTHOR "Azure" 13 | 14 | // 窗口标题 15 | #define MAIN_WINDOW_TITLE "μDSO" 16 | #define CONNECT_WINDOW_TITLE "设备连接" 17 | #define DDS_WINDOW_TITLE "信号发生器" 18 | #define SETTINGS_WINDOW_TITLE "全局设置" 19 | #define ABOUT_WINDOW_TITLE "关于" 20 | 21 | // 设置是否有启动界面 22 | #define ENABLE_SPLASH_SCREEN true 23 | 24 | // 使能仿真模式 25 | #define ENABLE_SIMULATION_MODE true 26 | 27 | // 标题栏的默认高度 28 | #define DEFAULT_TITLE_BAR_HEIGHT 30 29 | 30 | // 状态栏的默认高度 31 | #define DEFAULT_STATUS_BAR_HEIGHT 25 32 | 33 | // 主窗口的默认大小 34 | #define DEFAULT_MAIN_WINDOW_WIDTH 1200 35 | #define DEFAULT_MAIN_WINDOW_HEIGHT 800 36 | 37 | // “连接设备”窗口的默认大小 38 | #define DEFAULT_CONNECT_WINDOW_WIDTH 320 39 | #define DEFAULT_CONNECT_WINDOW_HEIGHT 280 40 | 41 | // “信号发生器”窗口的默认大小 42 | #define DEFAULT_DDS_WINDOW_WIDTH 320 43 | #define DEFAULT_DDS_WINDOW_HEIGHT 200 44 | 45 | // “全局设置”窗口的默认大小 46 | #define DEFAULT_SETTINGS_WINDOW_WIDTH 640 47 | #define DEFAULT_SETTINGS_WINDOW_HEIGHT 500 48 | 49 | // “关于uDSO”窗口的默认大小 50 | #define DEFAULT_ABOUT_WINDOW_WIDTH 640 51 | #define DEFAULT_ABOUT_WINDOW_HEIGHT 420 52 | 53 | // 采样长度 54 | //#define SAMPLING_LENGTH_MAX 2048/*16384*/ 55 | #define SAMPLING_LENGTH_MAX 600 56 | // 显示缓冲最大长度 57 | #define DISPLAY_BUFFER_MAX_LENGTH 600 58 | 59 | extern QString g_Platform; // 当前平台 60 | extern usb* g_USBDevice; // USB设备 61 | extern QString g_ApplicationDirPath; 62 | 63 | // 控制命令 64 | #define CONTROL_CMD_AD_DATA ((unsigned char) 0) 65 | #define CONTROL_CMD_DSO ((unsigned char) 1) 66 | #define CONTROL_CMD_DDS ((unsigned char) 2) 67 | 68 | // DDS 69 | //////////////////////////////////////////////////////////////////////////////// 70 | // 波形枚举 71 | #define DDS_WAVE_SINE 0 72 | #define DDS_WAVE_SQUA 1 73 | #define DDS_WAVE_TRI 2 74 | #define DDS_WAVE_RAMP 3 75 | #define DDS_WAVE_NAMP 4 76 | #define DDS_WAVE_SINC 5 77 | #define DDS_WAVE_NOISE 6 78 | #define DDS_WAVE_EXPR 7 79 | #define DDS_WAVE_EXPF 8 80 | #define DDS_WAVE_FULL_SIN_P 9 81 | #define DDS_WAVE_FULL_SIN_N 10 82 | #define DDS_WAVE_HALF_SIN_P 11 83 | #define DDS_WAVE_HALF_SIN_N 12 84 | #define DDS_WAVE_GAUSSIAN 13 85 | #define DDS_WAVE_DC 14 86 | #define DDS_WAVE_STA 15 87 | #define DDS_WAVE_ARB 16 88 | // DDS数据信号类型 89 | typedef struct{ 90 | int wave; 91 | double frequency; 92 | double amplitude; 93 | double offset; 94 | double duty; 95 | }DDSControlInfo; 96 | 97 | // DSO 98 | //////////////////////////////////////////////////////////////////////////////// 99 | #define DSO_COUPLING_DC 0 100 | #define DSO_COUPLING_AC 1 101 | #define DSO_TRIG_FALL 0 102 | #define DSO_TRIG_RAISE 1 103 | #define DSO_CHANNEL1 0 104 | #define DSO_CHANNEL2 1 105 | 106 | #define DSO_SAMPLE_RATE_NUM 17 107 | #define DSO_VOLTAGE_RANGE_NUM 11 108 | 109 | const char textSampleRate[DSO_SAMPLE_RATE_NUM][2][20] = 110 | { 111 | {"100M/s", "100ms/div"}, 112 | {"50M/s", "50ms/div"}, 113 | {"25M/s", "20ms/div"}, 114 | {"10M/s", "10ms/div"}, 115 | {"5M/s", "5ms/div"}, 116 | {"2.5M/s", "2ms/div"}, 117 | {"1M/s", "1ms/div"}, 118 | {"500K/s", "500us/div"}, 119 | {"250K/s", "200us/div"}, 120 | {"100K/s", "100us/div"}, 121 | {"50K/s", "50us/div"}, 122 | {"25K/s", "20us/div"}, 123 | {"10K/s", "10us/div"}, 124 | {"5K/s", "5us/div"}, 125 | {"2.5K/s", "2us/div"}, 126 | {"1K/s", "1us/div"}, 127 | {"0.5K/s", "500ns/div"} 128 | }; 129 | const char textVoltageRange[DSO_VOLTAGE_RANGE_NUM][2][20] = 130 | { 131 | {"80V", "10V/div"}, 132 | {"40V", "5V/div"}, 133 | {"16V", "2V/div"}, 134 | {"8V", "1V/div"}, 135 | {"4V", "500mV/div"}, 136 | {"1.6V", "200mV/div"}, 137 | {"0.8V", "100mV/div"}, 138 | {"0.4V", "50mV/div"}, 139 | {"0.16V","20mV/div"}, 140 | {"0.8V", "10mV/div"}, 141 | {"0.04V","5mV/div"} 142 | }; 143 | const double voltageRangeValue[DSO_VOLTAGE_RANGE_NUM] = {80, 40, 16, 8, 4, 1.6, 0.8, 0.4, 0.16, 0.08,0.04}; 144 | 145 | // DSO数据类型 146 | typedef struct 147 | { 148 | double sampleRate; 149 | 150 | double ch1Offset; 151 | double ch1VoltageRange; 152 | double ch1Coupling; 153 | 154 | double ch2Offset; 155 | double ch2VoltageRange; 156 | double ch2Coupling; 157 | 158 | double trigChannel; 159 | double trigEdge; 160 | double trigLevel; 161 | }DSOControlInfo; 162 | 163 | 164 | #endif // GLOBAL 165 | 166 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/lib/libusb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/lib/libusb.a -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/main.cpp: -------------------------------------------------------------------------------- 1 | #include "window/mainwindow.h" 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | // 获取当前平台 6 | #ifdef Q_OS_LINUX 7 | g_Platform = "LINUX"; 8 | #elif defined Q_OS_WIN 9 | g_Platform = "WINDOWS"; 10 | #endif 11 | 12 | // 创建Qt应用 13 | QApplication a(argc, argv); 14 | 15 | g_ApplicationDirPath = a.applicationDirPath(); 16 | 17 | // 启动界面 18 | #if ENABLE_SPLASH_SCREEN 19 | QPixmap pixmap(":/img/etc/splashscreen.png"); 20 | QSplashScreen screen(pixmap); 21 | screen.show(); 22 | QDateTime n=QDateTime::currentDateTime(); 23 | QDateTime now; 24 | do 25 | { 26 | now=QDateTime::currentDateTime(); 27 | a.processEvents(); 28 | } 29 | while (n.secsTo(now) <= 2); //2s 30 | #endif 31 | 32 | // 启动主界面 33 | MainWindow w; 34 | w.show(); 35 | 36 | // 关闭启动画面 37 | #if ENABLE_SPLASH_SCREEN 38 | screen.finish(&w); 39 | #endif 40 | 41 | // 等待应用退出 42 | return a.exec(); 43 | } 44 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/button/close_hover.png 4 | img/button/close_normal.png 5 | img/button/close_pressed.png 6 | img/button/max_hover.png 7 | img/button/max_normal.png 8 | img/button/max_pressed.png 9 | img/button/menu_hover.png 10 | img/button/menu_normal.png 11 | img/button/menu_pressed.png 12 | img/button/min_hover.png 13 | img/button/min_normal.png 14 | img/button/min_pressed.png 15 | img/button/restore_hover.png 16 | img/button/restore_normal.png 17 | img/button/restore_pressed.png 18 | img/knob/knob0.png 19 | img/knob/knob1.png 20 | img/knob/knob2.png 21 | img/knob/knob3.png 22 | img/knob/knob4.png 23 | img/knob/knob5.png 24 | img/knob/knob6.png 25 | img/knob/knob7.png 26 | img/arrow/arrow_down.png 27 | img/arrow/arrow_left.png 28 | img/arrow/arrow_right.png 29 | img/arrow/arrow_up.png 30 | img/etc/logo.png 31 | img/etc/logo_border.png 32 | img/etc/splashscreen.png 33 | img/usb/connected.png 34 | img/usb/unconnected.png 35 | img/osc/gnd1.png 36 | img/osc/gnd2.png 37 | img/osc/MeasureButtom_1.png 38 | img/osc/MeasureButtom_2.png 39 | img/osc/MeasureLeft.png 40 | img/osc/MeasureRight_1.png 41 | img/osc/MeasureRight_2.png 42 | img/osc/MeasureTop.png 43 | img/osc/TimeBase.png 44 | img/osc/TimeBase2.png 45 | img/osc/Trig.png 46 | img/osc/gnd3.png 47 | img/etc/start.gif 48 | 49 | 50 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/arrow/arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/arrow/arrow_down.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/arrow/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/arrow/arrow_left.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/arrow/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/arrow/arrow_right.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/arrow/arrow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/arrow/arrow_up.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/arrow/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/arrow/down_arrow.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/close_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/close_hover.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/close_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/close_normal.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/close_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/close_pressed.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/max_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/max_hover.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/max_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/max_normal.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/max_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/max_pressed.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/menu_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/menu_hover.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/menu_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/menu_normal.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/menu_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/menu_pressed.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/min_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/min_hover.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/min_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/min_normal.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/min_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/min_pressed.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/restore_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/restore_hover.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/restore_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/restore_normal.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/button/restore_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/button/restore_pressed.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/etc/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/etc/logo.ico -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/etc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/etc/logo.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/etc/logo_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/etc/logo_border.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/etc/splashscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/etc/splashscreen.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/etc/start.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/etc/start.gif -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob0.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob1.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob2.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob3.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob4.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob5.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob6.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/knob/knob7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/knob/knob7.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureButtom_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureButtom_1.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureButtom_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureButtom_2.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureLeft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureLeft.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureRight_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureRight_1.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureRight_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureRight_2.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/MeasureTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/MeasureTop.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/TimeBase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/TimeBase.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/TimeBase2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/TimeBase2.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/Trig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/Trig.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/gnd1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/gnd1.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/gnd2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/gnd2.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/osc/gnd3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/osc/gnd3.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/usb/connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/usb/connected.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/res/img/usb/unconnected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/PC_Software_Qt/uDSO/res/img/usb/unconnected.png -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/uDSO.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-01-20T12:24:31 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = uDSO 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which as been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | 26 | SOURCES += main.cpp\ 27 | global.cpp \ 28 | component/channelsettingswidget.cpp \ 29 | component/mainwindowmenu.cpp \ 30 | component/oscillographwidget.cpp \ 31 | component/statusbarwidget.cpp \ 32 | component/systembutton.cpp \ 33 | component/titlebarwidget.cpp \ 34 | window/mainwindow.cpp \ 35 | window/aboutwindow.cpp \ 36 | window/connectwindow.cpp \ 37 | window/ddswindow.cpp \ 38 | usb/usb.cpp \ 39 | usb/usbthread.cpp \ 40 | component/sampleratesettingwidget.cpp \ 41 | component/triggerwidget.cpp 42 | 43 | HEADERS += mainwindow.h \ 44 | global.h \ 45 | component/channelsettingswidget.h \ 46 | component/mainwindowmenu.h \ 47 | component/oscillographwidget.h \ 48 | component/statusbarwidget.h \ 49 | component/systembutton.h \ 50 | component/titlebarwidget.h \ 51 | window/mainwindow.h \ 52 | window/aboutwindow.h \ 53 | window/connectwindow.h \ 54 | window/ddswindow.h \ 55 | usb/usb.h \ 56 | usb/lusb0_usb.h \ 57 | usb/usbthread.h \ 58 | component/sampleratesettingwidget.h \ 59 | component/triggerwidget.h 60 | 61 | FORMS += \ 62 | ui/mainwindow.ui \ 63 | ui/aboutwindow.ui \ 64 | ui/connectwindow.ui \ 65 | ui/ddswindow.ui 66 | 67 | RESOURCES += \ 68 | res/img.qrc 69 | 70 | 71 | LIBS += $${PWD}/lib/libusb.a 72 | 73 | RC_FILE = app.rc 74 | 75 | DISTFILES += 76 | 77 | CONFIG += resources_big 78 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/ui/aboutwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AboutWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/ui/connectwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ConnectWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/ui/ddswindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DDSWindow 6 | 7 | 8 | 9 | 0 10 | 0 11 | 400 12 | 300 13 | 14 | 15 | 16 | Form 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/ui/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/usb/lusb0_usb.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB_H__ 2 | #define __USB_H__ 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | * 'interface' is defined somewhere in the Windows header files. This macro 9 | * is deleted here to avoid conflicts and compile errors. 10 | */ 11 | 12 | #ifdef interface 13 | #undef interface 14 | #endif 15 | 16 | /* 17 | * PATH_MAX from limits.h can't be used on Windows if the dll and 18 | * import libraries are build/used by different compilers 19 | */ 20 | 21 | #define LIBUSB_PATH_MAX 512 22 | 23 | 24 | /* 25 | * USB spec information 26 | * 27 | * This is all stuff grabbed from various USB specs and is pretty much 28 | * not subject to change 29 | */ 30 | 31 | /* 32 | * Device and/or Interface Class codes 33 | */ 34 | #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ 35 | #define USB_CLASS_AUDIO 1 36 | #define USB_CLASS_COMM 2 37 | #define USB_CLASS_HID 3 38 | #define USB_CLASS_PRINTER 7 39 | #define USB_CLASS_MASS_STORAGE 8 40 | #define USB_CLASS_HUB 9 41 | #define USB_CLASS_DATA 10 42 | #define USB_CLASS_VENDOR_SPEC 0xff 43 | 44 | /* 45 | * Descriptor types 46 | */ 47 | #define USB_DT_DEVICE 0x01 48 | #define USB_DT_CONFIG 0x02 49 | #define USB_DT_STRING 0x03 50 | #define USB_DT_INTERFACE 0x04 51 | #define USB_DT_ENDPOINT 0x05 52 | 53 | #define USB_DT_HID 0x21 54 | #define USB_DT_REPORT 0x22 55 | #define USB_DT_PHYSICAL 0x23 56 | #define USB_DT_HUB 0x29 57 | 58 | /* 59 | * Descriptor sizes per descriptor type 60 | */ 61 | #define USB_DT_DEVICE_SIZE 18 62 | #define USB_DT_CONFIG_SIZE 9 63 | #define USB_DT_INTERFACE_SIZE 9 64 | #define USB_DT_ENDPOINT_SIZE 7 65 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ 66 | #define USB_DT_HUB_NONVAR_SIZE 7 67 | 68 | 69 | /* ensure byte-packed structures */ 70 | #include 71 | 72 | 73 | /* All standard descriptors have these 2 fields in common */ 74 | struct usb_descriptor_header 75 | { 76 | unsigned char bLength; 77 | unsigned char bDescriptorType; 78 | }; 79 | 80 | /* String descriptor */ 81 | struct usb_string_descriptor 82 | { 83 | unsigned char bLength; 84 | unsigned char bDescriptorType; 85 | unsigned short wData[1]; 86 | }; 87 | 88 | /* HID descriptor */ 89 | struct usb_hid_descriptor 90 | { 91 | unsigned char bLength; 92 | unsigned char bDescriptorType; 93 | unsigned short bcdHID; 94 | unsigned char bCountryCode; 95 | unsigned char bNumDescriptors; 96 | }; 97 | 98 | /* Endpoint descriptor */ 99 | #define USB_MAXENDPOINTS 32 100 | struct usb_endpoint_descriptor 101 | { 102 | unsigned char bLength; 103 | unsigned char bDescriptorType; 104 | unsigned char bEndpointAddress; 105 | unsigned char bmAttributes; 106 | unsigned short wMaxPacketSize; 107 | unsigned char bInterval; 108 | unsigned char bRefresh; 109 | unsigned char bSynchAddress; 110 | 111 | unsigned char *extra; /* Extra descriptors */ 112 | int extralen; 113 | }; 114 | 115 | #define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ 116 | #define USB_ENDPOINT_DIR_MASK 0x80 117 | 118 | #define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ 119 | #define USB_ENDPOINT_TYPE_CONTROL 0 120 | #define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 121 | #define USB_ENDPOINT_TYPE_BULK 2 122 | #define USB_ENDPOINT_TYPE_INTERRUPT 3 123 | 124 | /* Interface descriptor */ 125 | #define USB_MAXINTERFACES 32 126 | struct usb_interface_descriptor 127 | { 128 | unsigned char bLength; 129 | unsigned char bDescriptorType; 130 | unsigned char bInterfaceNumber; 131 | unsigned char bAlternateSetting; 132 | unsigned char bNumEndpoints; 133 | unsigned char bInterfaceClass; 134 | unsigned char bInterfaceSubClass; 135 | unsigned char bInterfaceProtocol; 136 | unsigned char iInterface; 137 | 138 | struct usb_endpoint_descriptor *endpoint; 139 | 140 | unsigned char *extra; /* Extra descriptors */ 141 | int extralen; 142 | }; 143 | 144 | #define USB_MAXALTSETTING 128 /* Hard limit */ 145 | 146 | struct usb_interface 147 | { 148 | struct usb_interface_descriptor *altsetting; 149 | 150 | int num_altsetting; 151 | }; 152 | 153 | /* Configuration descriptor information.. */ 154 | #define USB_MAXCONFIG 8 155 | struct usb_config_descriptor 156 | { 157 | unsigned char bLength; 158 | unsigned char bDescriptorType; 159 | unsigned short wTotalLength; 160 | unsigned char bNumInterfaces; 161 | unsigned char bConfigurationValue; 162 | unsigned char iConfiguration; 163 | unsigned char bmAttributes; 164 | unsigned char MaxPower; 165 | 166 | struct usb_interface *interface; 167 | 168 | unsigned char *extra; /* Extra descriptors */ 169 | int extralen; 170 | }; 171 | 172 | /* Device descriptor */ 173 | struct usb_device_descriptor 174 | { 175 | unsigned char bLength; 176 | unsigned char bDescriptorType; 177 | unsigned short bcdUSB; 178 | unsigned char bDeviceClass; 179 | unsigned char bDeviceSubClass; 180 | unsigned char bDeviceProtocol; 181 | unsigned char bMaxPacketSize0; 182 | unsigned short idVendor; 183 | unsigned short idProduct; 184 | unsigned short bcdDevice; 185 | unsigned char iManufacturer; 186 | unsigned char iProduct; 187 | unsigned char iSerialNumber; 188 | unsigned char bNumConfigurations; 189 | }; 190 | 191 | struct usb_ctrl_setup 192 | { 193 | unsigned char bRequestType; 194 | unsigned char bRequest; 195 | unsigned short wValue; 196 | unsigned short wIndex; 197 | unsigned short wLength; 198 | }; 199 | 200 | /* 201 | * Standard requests 202 | */ 203 | #define USB_REQ_GET_STATUS 0x00 204 | #define USB_REQ_CLEAR_FEATURE 0x01 205 | /* 0x02 is reserved */ 206 | #define USB_REQ_SET_FEATURE 0x03 207 | /* 0x04 is reserved */ 208 | #define USB_REQ_SET_ADDRESS 0x05 209 | #define USB_REQ_GET_DESCRIPTOR 0x06 210 | #define USB_REQ_SET_DESCRIPTOR 0x07 211 | #define USB_REQ_GET_CONFIGURATION 0x08 212 | #define USB_REQ_SET_CONFIGURATION 0x09 213 | #define USB_REQ_GET_INTERFACE 0x0A 214 | #define USB_REQ_SET_INTERFACE 0x0B 215 | #define USB_REQ_SYNCH_FRAME 0x0C 216 | 217 | #define USB_TYPE_STANDARD (0x00 << 5) 218 | #define USB_TYPE_CLASS (0x01 << 5) 219 | #define USB_TYPE_VENDOR (0x02 << 5) 220 | #define USB_TYPE_RESERVED (0x03 << 5) 221 | 222 | #define USB_RECIP_DEVICE 0x00 223 | #define USB_RECIP_INTERFACE 0x01 224 | #define USB_RECIP_ENDPOINT 0x02 225 | #define USB_RECIP_OTHER 0x03 226 | 227 | /* 228 | * Various libusb API related stuff 229 | */ 230 | 231 | #define USB_ENDPOINT_IN 0x80 232 | #define USB_ENDPOINT_OUT 0x00 233 | 234 | /* Error codes */ 235 | #define USB_ERROR_BEGIN 500000 236 | 237 | /* 238 | * This is supposed to look weird. This file is generated from autoconf 239 | * and I didn't want to make this too complicated. 240 | */ 241 | #define USB_LE16_TO_CPU(x) 242 | 243 | /* 244 | * Device reset types for usb_reset_ex. 245 | * http://msdn.microsoft.com/en-us/library/ff537269%28VS.85%29.aspx 246 | * http://msdn.microsoft.com/en-us/library/ff537243%28v=vs.85%29.aspx 247 | */ 248 | #define USB_RESET_TYPE_RESET_PORT (1 << 0) 249 | #define USB_RESET_TYPE_CYCLE_PORT (1 << 1) 250 | #define USB_RESET_TYPE_FULL_RESET (USB_RESET_TYPE_CYCLE_PORT | USB_RESET_TYPE_RESET_PORT) 251 | 252 | 253 | /* Data types */ 254 | /* struct usb_device; */ 255 | /* struct usb_bus; */ 256 | 257 | struct usb_device 258 | { 259 | struct usb_device *next, *prev; 260 | 261 | char filename[LIBUSB_PATH_MAX]; 262 | 263 | struct usb_bus *bus; 264 | 265 | struct usb_device_descriptor descriptor; 266 | struct usb_config_descriptor *config; 267 | 268 | void *dev; /* Darwin support */ 269 | 270 | unsigned char devnum; 271 | 272 | unsigned char num_children; 273 | struct usb_device **children; 274 | }; 275 | 276 | struct usb_bus 277 | { 278 | struct usb_bus *next, *prev; 279 | 280 | char dirname[LIBUSB_PATH_MAX]; 281 | 282 | struct usb_device *devices; 283 | unsigned long location; 284 | 285 | struct usb_device *root_dev; 286 | }; 287 | 288 | /* Version information, Windows specific */ 289 | struct usb_version 290 | { 291 | struct 292 | { 293 | int major; 294 | int minor; 295 | int micro; 296 | int nano; 297 | } dll; 298 | struct 299 | { 300 | int major; 301 | int minor; 302 | int micro; 303 | int nano; 304 | } driver; 305 | }; 306 | 307 | 308 | struct usb_dev_handle; 309 | typedef struct usb_dev_handle usb_dev_handle; 310 | 311 | /* Variables */ 312 | #ifndef __USB_C__ 313 | #define usb_busses usb_get_busses() 314 | #endif 315 | 316 | 317 | 318 | #include 319 | 320 | 321 | #ifdef __cplusplus 322 | extern "C" 323 | { 324 | #endif 325 | 326 | /* Function prototypes */ 327 | 328 | /* usb.c */ 329 | usb_dev_handle *usb_open(struct usb_device *dev); 330 | int usb_close(usb_dev_handle *dev); 331 | int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, 332 | size_t buflen); 333 | int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, 334 | size_t buflen); 335 | 336 | /* descriptors.c */ 337 | int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, 338 | unsigned char type, unsigned char index, 339 | void *buf, int size); 340 | int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, 341 | unsigned char index, void *buf, int size); 342 | 343 | /* .c */ 344 | int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, 345 | int timeout); 346 | int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, 347 | int timeout); 348 | int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, 349 | int timeout); 350 | int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, 351 | int timeout); 352 | int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, 353 | int value, int index, char *bytes, int size, 354 | int timeout); 355 | int usb_set_configuration(usb_dev_handle *dev, int configuration); 356 | int usb_claim_interface(usb_dev_handle *dev, int interface); 357 | int usb_release_interface(usb_dev_handle *dev, int interface); 358 | int usb_set_altinterface(usb_dev_handle *dev, int alternate); 359 | int usb_resetep(usb_dev_handle *dev, unsigned int ep); 360 | int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); 361 | int usb_reset(usb_dev_handle *dev); 362 | int usb_reset_ex(usb_dev_handle *dev, unsigned int reset_type); 363 | 364 | char *usb_strerror(void); 365 | 366 | void usb_init(void); 367 | void usb_set_debug(int level); 368 | int usb_find_busses(void); 369 | int usb_find_devices(void); 370 | struct usb_device *usb_device(usb_dev_handle *dev); 371 | struct usb_bus *usb_get_busses(void); 372 | 373 | 374 | /* Windows specific functions */ 375 | 376 | #define LIBUSB_HAS_INSTALL_SERVICE_NP 1 377 | int usb_install_service_np(void); 378 | void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance, 379 | LPSTR cmd_line, int cmd_show); 380 | 381 | #define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1 382 | int usb_uninstall_service_np(void); 383 | void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance, 384 | LPSTR cmd_line, int cmd_show); 385 | 386 | #define LIBUSB_HAS_INSTALL_DRIVER_NP 1 387 | int usb_install_driver_np(const char *inf_file); 388 | void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance, 389 | LPSTR cmd_line, int cmd_show); 390 | 391 | #define LIBUSB_HAS_TOUCH_INF_FILE_NP 1 392 | int usb_touch_inf_file_np(const char *inf_file); 393 | void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance, 394 | LPSTR cmd_line, int cmd_show); 395 | 396 | #define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1 397 | int usb_install_needs_restart_np(void); 398 | 399 | #define LIBUSB_HAS_INSTALL_NP 1 400 | int usb_install_npW(HWND hwnd, HINSTANCE instance, LPCWSTR cmd_line, int starg_arg); 401 | int usb_install_npA(HWND hwnd, HINSTANCE instance, LPCSTR cmd_line, int starg_arg); 402 | #define usb_install_np usb_install_npA 403 | void CALLBACK usb_install_np_rundll(HWND wnd, HINSTANCE instance, 404 | LPSTR cmd_line, int cmd_show); 405 | 406 | const struct usb_version *usb_get_version(void); 407 | 408 | int usb_isochronous_setup_async(usb_dev_handle *dev, void **context, 409 | unsigned char ep, int pktsize); 410 | int usb_bulk_setup_async(usb_dev_handle *dev, void **context, 411 | unsigned char ep); 412 | int usb_interrupt_setup_async(usb_dev_handle *dev, void **context, 413 | unsigned char ep); 414 | 415 | int usb_submit_async(void *context, char *bytes, int size); 416 | int usb_reap_async(void *context, int timeout); 417 | int usb_reap_async_nocancel(void *context, int timeout); 418 | int usb_cancel_async(void *context); 419 | int usb_free_async(void **context); 420 | 421 | 422 | #ifdef __cplusplus 423 | } 424 | #endif 425 | 426 | #endif /* __USB_H__ */ 427 | 428 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/usb/usb.cpp: -------------------------------------------------------------------------------- 1 | #include "usb.h" 2 | #include "lusb0_usb.h" 3 | 4 | //-----------------------define------------------// 5 | #define EP_IN 0x81 6 | #define EP_OUT 0x01 7 | 8 | //-----------------------variable----------------// 9 | static unsigned long int counter = 0; 10 | static int search_flag = 0; 11 | static int pain_flag = 1; 12 | static int open_flag = 0; 13 | 14 | //-----------------------function----------------// 15 | usb::usb() 16 | { 17 | deviceVID = 0x0483; 18 | devicePID = 0x5710; 19 | } 20 | 21 | usb::~usb() 22 | { 23 | if(open_flag == 1) 24 | { 25 | usb_close(usb_device); 26 | } 27 | } 28 | 29 | bool usb::connectDevice(void) 30 | { 31 | if (open_flag == 1) 32 | { 33 | return true; 34 | } 35 | else 36 | { 37 | usb_init(); 38 | usb_find_busses(); 39 | usb_find_devices(); 40 | usb_device = open_device(); 41 | if(search_flag == 1) 42 | { 43 | open_flag = 0; 44 | search_flag = 0; 45 | qDebug()<< "Device opened is error"<< endl; 46 | return false; 47 | } 48 | open_flag = 1; 49 | usb_set_configuration(usb_device,1); 50 | usb_claim_interface(usb_device,0); 51 | return true; 52 | } 53 | } 54 | 55 | bool usb::unconnectDevice(void) 56 | { 57 | if (open_flag == 1) 58 | { 59 | usb_close(usb_device); 60 | open_flag = 0; 61 | pain_flag = 1; 62 | return true; 63 | } 64 | else 65 | { 66 | return false; 67 | } 68 | } 69 | 70 | bool usb::getConnectStatus(void) 71 | { 72 | return (bool)open_flag; 73 | } 74 | 75 | usb_dev_handle* usb::open_device(void) 76 | { 77 | struct usb_bus *bus; 78 | 79 | for(bus = usb_get_busses(); bus; bus = bus->next) 80 | { 81 | for(device = bus->devices; device; device = device->next) 82 | { 83 | if(device->descriptor.idVendor == deviceVID && device->descriptor.idProduct == devicePID ) 84 | { 85 | return usb_open(device); 86 | } 87 | 88 | } 89 | } 90 | 91 | search_flag = 1; 92 | 93 | return nullptr; 94 | } 95 | 96 | bool usb::sendData(unsigned char* data, int length) 97 | { 98 | if (open_flag == 0) 99 | return false; 100 | 101 | int res; 102 | 103 | // 发送命令数据 104 | res = usb_bulk_write(usb_device, EP_OUT, (char*)data, length, 2000); 105 | if(res < 0) 106 | { 107 | qDebug("error write: %s",usb_strerror()); 108 | return false; 109 | } 110 | 111 | return true; 112 | } 113 | 114 | bool usb::receiveData(unsigned char* data, int length) 115 | { 116 | if (open_flag == 0) 117 | return false; 118 | 119 | int res; 120 | 121 | // 接收数据 122 | res = usb_bulk_read(usb_device, EP_IN, (char*)data, length, 2000); 123 | if(res != length) 124 | { 125 | qDebug("packet_size error: %d, %d", res, length); 126 | return false; 127 | } 128 | 129 | return true; 130 | } 131 | 132 | void usb::setDeviceVID(int vid) 133 | { 134 | deviceVID = vid; 135 | } 136 | 137 | void usb::setDevicePID(int pid) 138 | { 139 | devicePID = pid; 140 | } 141 | 142 | int usb::getDeviceVID() 143 | { 144 | return deviceVID; 145 | } 146 | 147 | int usb::getDevicePID() 148 | { 149 | return devicePID; 150 | } 151 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/usb/usb.h: -------------------------------------------------------------------------------- 1 | #ifndef USB_H 2 | #define USB_H 3 | 4 | #include 5 | #include 6 | 7 | #include "lusb0_usb.h" 8 | 9 | class usb 10 | { 11 | public: 12 | usb(); 13 | ~usb(); 14 | 15 | bool connectDevice(void); 16 | bool unconnectDevice(void); 17 | bool getConnectStatus(void); 18 | bool sendData(unsigned char* data, int length); 19 | bool receiveData(unsigned char* data, int length); 20 | 21 | void setDeviceVID(int vid); 22 | void setDevicePID(int pid); 23 | int getDeviceVID(); 24 | int getDevicePID(); 25 | 26 | protected: 27 | 28 | private: 29 | usb_dev_handle* open_device(void); 30 | bool isOpenConnected(void); 31 | 32 | int deviceVID; 33 | int devicePID; 34 | usb_dev_handle* usb_device; 35 | struct usb_device* device; 36 | }; 37 | 38 | #endif // USB_H 39 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/usb/usbthread.cpp: -------------------------------------------------------------------------------- 1 | #include "usbthread.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "global.h" 7 | #include "usb/usb.h" 8 | #include 9 | #include 10 | 11 | USBThread::USBThread(QObject* parent): 12 | QThread(parent) 13 | { 14 | writeIndex = 0; 15 | readIndex = -1; 16 | stopped = false; 17 | 18 | // 清零测量参数 19 | for (int i = 0; i < 3; i++) 20 | { 21 | measureData[0][i] = 0.0; 22 | measureData[1][i] = 0.0; 23 | } 24 | 25 | // DDS参数 26 | ddsFlag = true; 27 | ddsControlInfo.wave = DDS_WAVE_SINE; 28 | ddsControlInfo.frequency = 1000.0; 29 | ddsControlInfo.amplitude = 5.0; 30 | ddsControlInfo.offset = 0.0; 31 | ddsControlInfo.duty = 50.0; 32 | // DSO参数 33 | dsoFlag = true; 34 | dsoControlInfo.sampleRate = 8; 35 | dsoControlInfo.ch1Offset = 0.0; 36 | dsoControlInfo.ch1VoltageRange = 2; 37 | dsoControlInfo.ch1Coupling = DSO_COUPLING_DC; 38 | dsoControlInfo.ch2Offset = 0.0; 39 | dsoControlInfo.ch2VoltageRange = 2; 40 | dsoControlInfo.ch2Coupling = DSO_COUPLING_DC; 41 | dsoControlInfo.trigChannel = DSO_CHANNEL1; 42 | dsoControlInfo.trigEdge = DSO_TRIG_RAISE; 43 | dsoControlInfo.trigLevel = 1.25; 44 | } 45 | 46 | void USBThread::setDDSParameter(DDSControlInfo para) 47 | { 48 | ddsMutex.lock(); 49 | ddsFlag = true; 50 | ddsControlInfo = para; 51 | ddsMutex.unlock(); 52 | } 53 | 54 | void USBThread::getDDSParameter(DDSControlInfo & para) 55 | { 56 | para = ddsControlInfo; 57 | } 58 | 59 | void USBThread::setDSOParameter(DSOControlInfo para) 60 | { 61 | dsoMutex.lock(); 62 | dsoFlag = true; 63 | dsoControlInfo = para; 64 | dsoMutex.unlock(); 65 | } 66 | 67 | void USBThread::getDSOParameter(DSOControlInfo & para) 68 | { 69 | para = dsoControlInfo; 70 | } 71 | 72 | // 设置外部读缓冲的数组 73 | void USBThread::setReadIndex(int index) 74 | { 75 | readIndex = index; 76 | } 77 | 78 | void USBThread::run() 79 | { 80 | while (stopped == false) 81 | { 82 | if (ENABLE_SIMULATION_MODE) 83 | { 84 | simulationWaveData(); 85 | msleep(10); 86 | } 87 | else 88 | { 89 | // 检查设备是否连接 90 | if (g_USBDevice->getConnectStatus() == false) 91 | { 92 | qDebug()<< "设备未连接!"; 93 | msleep(500); 94 | continue; 95 | } 96 | 97 | // 控制DDS 98 | controlDDS(); 99 | 100 | // 控制DSO 101 | controlDSO(); 102 | } 103 | } 104 | 105 | stopped = false; 106 | } 107 | 108 | void USBThread::stop() 109 | { 110 | stopped = true; 111 | 112 | // 终止线程 113 | this->terminate(); 114 | } 115 | 116 | void USBThread::controlDDS() 117 | { 118 | if (ddsFlag) 119 | { 120 | double para[5]; 121 | ddsMutex.lock(); 122 | para[0] = ddsControlInfo.wave; 123 | para[1] = ddsControlInfo.frequency; 124 | para[2] = ddsControlInfo.amplitude; 125 | para[3] = ddsControlInfo.offset; 126 | para[4] = ddsControlInfo.duty; 127 | ddsFlag = false; 128 | ddsMutex.unlock(); 129 | 130 | unsigned char cmd[41]; 131 | cmd[0] = CONTROL_CMD_DDS; 132 | for (int i = 0; i < 40; i++) 133 | { 134 | cmd[i+1] = ((unsigned char *)para)[i]; 135 | } 136 | if (g_USBDevice->sendData(cmd, sizeof(cmd)) == false) 137 | { 138 | qDebug()<< "DDS设置向USB设备发送命令失败!"; 139 | return; 140 | } 141 | 142 | unsigned char retData[64]; 143 | memset(retData, 0, sizeof(retData)); 144 | if (g_USBDevice->receiveData(retData, 64) == false ) 145 | { 146 | qDebug("DDS设置异常,回读信号失败"); 147 | return; 148 | } 149 | if (retData[0] != 1) 150 | { 151 | qDebug("DDS设置异常,回读信号错误"); 152 | return; 153 | } 154 | } 155 | } 156 | 157 | void USBThread::controlDSO() 158 | { 159 | if (dsoFlag) 160 | { 161 | double para[10]; 162 | dsoMutex.lock(); 163 | para[0] = dsoControlInfo.sampleRate; 164 | para[1] = dsoControlInfo.ch1Offset; 165 | para[2] = dsoControlInfo.ch1VoltageRange; 166 | para[3] = dsoControlInfo.ch1Coupling; 167 | para[4] = dsoControlInfo.ch2Offset; 168 | para[5] = dsoControlInfo.ch2VoltageRange; 169 | para[6] = dsoControlInfo.ch2Coupling; 170 | para[7] = dsoControlInfo.trigChannel; 171 | para[8] = dsoControlInfo.trigEdge; 172 | para[9] = dsoControlInfo.trigLevel; 173 | dsoFlag = false; 174 | dsoMutex.unlock(); 175 | 176 | unsigned char cmd[81]; 177 | cmd[0] = CONTROL_CMD_DSO; 178 | for (int i = 0; i < 80; i++) 179 | { 180 | cmd[i+1] = ((unsigned char *)para)[i]; 181 | } 182 | if (g_USBDevice->sendData(cmd, sizeof(cmd)) == false) 183 | { 184 | qDebug()<< "DSO设置向USB设备发送命令失败!"; 185 | goto DSO_READ_AD_DATA; 186 | } 187 | 188 | unsigned char retData[64]; 189 | memset(retData, 0, sizeof(retData)); 190 | if (g_USBDevice->receiveData(retData, 64) == false ) 191 | { 192 | qDebug("DSO设置异常,回读信号失败"); 193 | goto DSO_READ_AD_DATA; 194 | } 195 | if (retData[0] != 1) 196 | { 197 | qDebug("DSO设置异常,回读信号错误"); 198 | goto DSO_READ_AD_DATA; 199 | } 200 | } 201 | 202 | DSO_READ_AD_DATA: 203 | // 判断是否可以开始读写数据 204 | if ( writeIndex == readIndex ) 205 | { 206 | qDebug()<< "等待主界面处理完成数据"; 207 | msleep(10); 208 | return; 209 | } 210 | 211 | // 向USB设备发送命令 212 | unsigned char cmd = CONTROL_CMD_AD_DATA; 213 | if (g_USBDevice->sendData(&cmd, 1) == false) 214 | { 215 | qDebug()<< "向USB设备发送命令失败!"; 216 | return; 217 | } 218 | 219 | // 接收USB设备上传的数据 220 | if (g_USBDevice->receiveData(adData[writeIndex][0], SAMPLING_LENGTH_MAX) == false ) 221 | { 222 | qDebug("adData[writeIndex][0] 数据接收异常"); 223 | } 224 | if (g_USBDevice->receiveData(adData[writeIndex][1], SAMPLING_LENGTH_MAX) == false ) 225 | { 226 | qDebug("adData[writeIndex][1] 数据接收异常"); 227 | } 228 | 229 | // 读取测量数据 230 | unsigned char buffer[48]; 231 | if (g_USBDevice->receiveData(buffer, 48) == false ) 232 | { 233 | qDebug("measureData 数据接收异常"); 234 | } 235 | for (int i = 0; i < 3; i++) 236 | { 237 | measureData[0][i] = *((double *)&buffer[i*8]); 238 | measureData[1][i] = *((double *)&buffer[i*8 + 24]); 239 | } 240 | 241 | // 发射接收完成信号 242 | emit signal_ReviceFinish(writeIndex); 243 | 244 | // 更新写的缓冲区 245 | writeIndex = (writeIndex+1)%2; 246 | } 247 | 248 | void USBThread::simulationWaveData() 249 | { 250 | // 判断是否可以开始读写数据 251 | if ( writeIndex == readIndex ) 252 | { 253 | qDebug()<< "等待主界面处理完成数据"; 254 | msleep(10); 255 | return; 256 | } 257 | 258 | // 生成仿真数据 259 | for (int i = 0; i < SAMPLING_LENGTH_MAX; i++) 260 | { 261 | adData[writeIndex][0][i] = (sin((double)i / SAMPLING_LENGTH_MAX * 3 * 3.14 * 2) + 1) / 2.0 * 250 + rand() % 5; 262 | } 263 | for (int i = 0; i < SAMPLING_LENGTH_MAX; i++) 264 | { 265 | adData[writeIndex][1][i] = (sin((double)i / SAMPLING_LENGTH_MAX * 60 * 3.14 * 2) * cos((double)i / SAMPLING_LENGTH_MAX * 2 * 3.14 * 2) + 1) / 2.0 * 250 + rand() % 5; 266 | } 267 | 268 | // 发射接收完成信号 269 | emit signal_ReviceFinish(writeIndex); 270 | 271 | // 更新写的缓冲区 272 | writeIndex = (writeIndex+1)%2; 273 | } 274 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/usb/usbthread.h: -------------------------------------------------------------------------------- 1 | #ifndef USBTHREAD_H 2 | #define USBTHREAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "global.h" 10 | 11 | class USBThread : public QThread 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit USBThread(QObject* parent = 0); 16 | void stop(); 17 | void setReadIndex(int index); 18 | 19 | // 设置DDS 20 | void setDDSParameter(DDSControlInfo para); 21 | void getDDSParameter(DDSControlInfo & para); 22 | // 设置DSO 23 | void setDSOParameter(DSOControlInfo para); 24 | void getDSOParameter(DSOControlInfo & para); 25 | 26 | // 接收数据缓存数组,乒乓数组、2通道、SAMPLING_LENGTH_MAX的长度 27 | unsigned char adData[2][2][SAMPLING_LENGTH_MAX]; 28 | double measureData[2][3]; 29 | 30 | signals: 31 | void signal_ReviceFinish(int); // 数据接收满信号 32 | 33 | protected: 34 | void run(); 35 | 36 | private: 37 | void reviceData(); 38 | 39 | void controlDDS(); 40 | void controlDSO(); 41 | void simulationWaveData(); 42 | 43 | volatile int writeIndex; // 要写入数据的数组 44 | volatile int readIndex; // 读取数据的缓冲区 45 | volatile bool stopped; // 停止线程 46 | 47 | QMutex ddsMutex; 48 | bool ddsFlag; 49 | DDSControlInfo ddsControlInfo; 50 | 51 | QMutex dsoMutex; 52 | bool dsoFlag; 53 | DSOControlInfo dsoControlInfo; 54 | }; 55 | 56 | #endif // USBTHREAD_H 57 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/aboutwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "aboutwindow.h" 2 | #include "ui_aboutwindow.h" 3 | #include 4 | #include 5 | 6 | AboutWindow::AboutWindow(QWidget *parent) : 7 | QWidget(parent), 8 | ui(new Ui::AboutWindow) 9 | { 10 | parentWidget = parent; 11 | 12 | ui->setupUi(this); 13 | 14 | initUI(); 15 | } 16 | 17 | AboutWindow::~AboutWindow() 18 | { 19 | delete ui; 20 | } 21 | 22 | void AboutWindow::closeWindow() 23 | { 24 | this->close(); 25 | this->setAttribute(Qt::WA_DeleteOnClose, true); 26 | } 27 | 28 | void AboutWindow::paintEvent(QPaintEvent *) 29 | { 30 | QPainterPath path; 31 | path.setFillRule(Qt::WindingFill); 32 | path.addRect(0, 0, this->width(), this->height()); 33 | 34 | QPainter painter(this); 35 | painter.fillPath(path, QBrush(Qt::white)); 36 | 37 | path.setFillRule(Qt::WindingFill); 38 | path.addRect(0, 0, this->width()-1, this->height()-1); 39 | 40 | painter.setPen("#0063B1"); 41 | painter.drawPath(path); 42 | } 43 | 44 | void AboutWindow::initUI() 45 | { 46 | QString str; 47 | 48 | this->setMinimumSize(DEFAULT_ABOUT_WINDOW_WIDTH, DEFAULT_ABOUT_WINDOW_HEIGHT); 49 | this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); 50 | // this->setWindowIcon(QIcon(":/img/etc/logo.png")); 51 | this->setWindowIcon(QIcon(":/img/etc/icon.png")); 52 | this->setWindowTitle(tr("关于")); 53 | this->setWindowOpacity(1); //窗体透明度设置 54 | 55 | titleBarWidget = new TitleBarWidget(this, ABOUT_WINDOW_TITLE, 30, false); 56 | titleBarWidget->initConnect(); 57 | connect(titleBarWidget, SIGNAL(closeWindow()), this, SLOT(closeWindow())); 58 | 59 | gifLabel = new QLabel(this); 60 | gifLabel->setFixedSize(this->width(), 300); 61 | gifLabel->move(0, 30); 62 | QMovie *movie=new QMovie(":/img/etc/start.gif"); 63 | gifLabel->setMovie(movie); 64 | movie->start(); 65 | 66 | titleText = new QLabel(this); 67 | titleText->setFixedSize(gifLabel->width(), gifLabel->height()); 68 | titleText->move(0, titleBarWidget->height()); 69 | str.sprintf("

%s %s

",MAIN_WINDOW_TITLE,UDSO_VERSION); 70 | // str += "

The open source, free, cross platform virtual oscilloscope.

"; 71 | titleText->setText(str); 72 | 73 | text = new QLabel(this); 74 | text->setFixedSize(this->width()-20, this->height() - titleBarWidget->height() - gifLabel->height()-30); 75 | text->move(10, titleBarWidget->height() + gifLabel->height()+5); 76 | text->setStyleSheet("QLabel{color:black;}"); 77 | text->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 78 | str.sprintf("作者:%s \n更新日期:%s \nEmail:985424805@qq.com", USDO_AUTHOR, UDSO_UPDATE); 79 | text->setText(str); 80 | 81 | text1 = new QLabel(this); 82 | text1->setFixedSize(this->width()-20, 20); 83 | text1->move(10, titleBarWidget->height() + gifLabel->height() + text->height()); 84 | text1->setStyleSheet("QLabel{color:green;}"); 85 | text1->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 86 | text1->setAlignment(Qt::AlignVCenter); 87 | 88 | subtitleString = " μDSO是自由软件;您可以按照自由软件基金会所发表的 GNU GPL 协议自由发放和/或修改它;采用协议的第 3 版,或者(根据您的选择)任何更高版本。"; 89 | mTimer = new QTimer(this); 90 | connect(mTimer, SIGNAL(timeout()), this, SLOT(updateSubtitle())); 91 | mTimer->start(300); 92 | } 93 | 94 | void AboutWindow::updateSubtitle() 95 | { 96 | static int nPos = 0; 97 | 98 | if (nPos > subtitleString.length()) 99 | { 100 | nPos = 0; 101 | } 102 | text1->setText(subtitleString.mid(nPos)); 103 | nPos++; 104 | } 105 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/aboutwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTWINDOW_H 2 | #define ABOUTWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "global.h" 10 | #include "connectwindow.h" 11 | #include "component/titlebarwidget.h" 12 | #include "component/statusbarwidget.h" 13 | #include "component/systembutton.h" 14 | 15 | namespace Ui { 16 | class AboutWindow; 17 | } 18 | 19 | class AboutWindow : public QWidget 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit AboutWindow(QWidget *parent = 0); 25 | ~AboutWindow(); 26 | 27 | public slots: 28 | void closeWindow(); 29 | void updateSubtitle(); 30 | 31 | private: 32 | void paintEvent(QPaintEvent *); 33 | void initUI(); 34 | void initLayout(); 35 | 36 | private: 37 | QWidget *parentWidget; 38 | Ui::AboutWindow *ui; 39 | TitleBarWidget *titleBarWidget; 40 | QLabel *gifLabel; 41 | QLabel *titleText; 42 | QLabel *text; 43 | QLabel *text1; 44 | QTimer *mTimer; 45 | QString subtitleString; 46 | }; 47 | 48 | #endif // ABOUTWINDOW_H 49 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/connectwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "connectwindow.h" 2 | #include "ui_connectwindow.h" 3 | 4 | ConnectWindow::ConnectWindow(QWidget *parent) : 5 | QWidget(parent), 6 | ui(new Ui::ConnectWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | // 初始化界面 11 | initUI(); 12 | 13 | // 禁用本窗口之外的窗口(包括主窗口) 14 | this->setWindowModality(Qt::ApplicationModal); 15 | } 16 | 17 | ConnectWindow::~ConnectWindow() 18 | { 19 | delete ui; 20 | } 21 | 22 | void ConnectWindow::closeWindow() 23 | { 24 | this->close(); 25 | this->setAttribute(Qt::WA_DeleteOnClose,true); 26 | } 27 | 28 | void ConnectWindow::paintEvent(QPaintEvent *) 29 | { 30 | QPainterPath path; 31 | path.setFillRule(Qt::WindingFill); 32 | path.addRect(0, 0, this->width(), this->height()); 33 | 34 | QPainter painter(this); 35 | painter.fillPath(path, QBrush(Qt::white)); 36 | 37 | path.setFillRule(Qt::WindingFill); 38 | path.addRect(0, 0, this->width()-1, this->height()-1); 39 | 40 | painter.setPen("#0063B1"); 41 | painter.drawPath(path); 42 | } 43 | 44 | void ConnectWindow::initUI() 45 | { 46 | QString str; 47 | 48 | this->setFixedSize(DEFAULT_CONNECT_WINDOW_WIDTH, DEFAULT_CONNECT_WINDOW_HEIGHT); 49 | this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); 50 | // this->setWindowIcon(QIcon(":/img/etc/logo.png")); 51 | this->setWindowIcon(QIcon(":/img/etc/icon.png")); 52 | this->setWindowTitle("μDSO"); 53 | this->setWindowOpacity(1); //窗体透明度设置 54 | 55 | titleBarWidget = new TitleBarWidget(this, CONNECT_WINDOW_TITLE, 30, false); 56 | titleBarWidget->initConnect(); 57 | connect(titleBarWidget, SIGNAL(closeWindow()), this, SLOT(closeWindow()) ); 58 | 59 | // 连接状态图标 60 | imageLabel = new QLabel(this); 61 | imageLabel->setMaximumSize(128, 128); 62 | if (g_USBDevice && g_USBDevice->getConnectStatus() == true) 63 | imageLabel->setStyleSheet("border-image: url(:/img/usb/connected.png);"); 64 | else 65 | imageLabel->setStyleSheet("border-image: url(:/img/usb/unconnected.png);"); 66 | 67 | // 编辑框 68 | pidLineEdit = new QLineEdit(this); 69 | vidLineEdit = new QLineEdit(this); 70 | pidLineEdit->setStyleSheet("QLineEdit { color: black; border: 1px solid gray; }"); 71 | vidLineEdit->setStyleSheet("QLineEdit { color: black; border: 1px solid gray; }"); 72 | pidLineEdit->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 73 | vidLineEdit->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 74 | pidLineEdit->setAlignment(Qt::AlignCenter); 75 | vidLineEdit->setAlignment(Qt::AlignCenter); 76 | pidLineEdit->setText( str.sprintf("0x%04x",g_USBDevice->getDevicePID()) ); 77 | vidLineEdit->setText( str.sprintf("0x%04x",g_USBDevice->getDeviceVID()) ); 78 | 79 | // 设备硬件ID 80 | pidTextLabel = new QLabel(this); 81 | vidTextLabel = new QLabel(this); 82 | pidTextLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 83 | vidTextLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 84 | pidTextLabel->setText("设备硬件ID(PID)"); 85 | vidTextLabel->setText("设备硬件ID(VID)"); 86 | 87 | // 按键初始化 88 | connectDeviceButton = new SystemButton(this, "连接设备"); 89 | unconnectDeviceButton = new SystemButton(this, "断开设备"); 90 | connectDeviceButton->setFixedSize((this->width()- 5*2 - 5)/2, 30); 91 | unconnectDeviceButton->setFixedSize((this->width()- 5*2 - 5)/2, 30); 92 | 93 | // 设置按键状态 94 | if ( g_USBDevice && g_USBDevice->getConnectStatus() == false) 95 | { 96 | connectDeviceButton->setEnabled(true); 97 | unconnectDeviceButton->setDisabled(true); 98 | } 99 | else 100 | { 101 | connectDeviceButton->setDisabled(true); 102 | unconnectDeviceButton->setEnabled(true); 103 | } 104 | 105 | // 106 | connect(connectDeviceButton, SIGNAL(clicked()), this, SLOT(connectDevice()) ); 107 | connect(unconnectDeviceButton, SIGNAL(clicked()), this, SLOT(unconnectDevice()) ); 108 | 109 | initLayout(); 110 | } 111 | 112 | void ConnectWindow::initLayout() 113 | { 114 | QVBoxLayout* mainLayout = new QVBoxLayout(); 115 | 116 | QSpacerItem* vSpacer1 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); 117 | QSpacerItem* vSpacer2 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); 118 | QSpacerItem* hSpacer1 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); 119 | QSpacerItem* hSpacer2 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); 120 | QHBoxLayout* hLayout1 = new QHBoxLayout(); 121 | QHBoxLayout* hLayout2 = new QHBoxLayout(); 122 | QHBoxLayout* hLayout3 = new QHBoxLayout(); 123 | QHBoxLayout* hLayout4 = new QHBoxLayout(); 124 | 125 | hLayout1->addSpacerItem(hSpacer1); 126 | hLayout1->addWidget(imageLabel, 1); 127 | hLayout1->addSpacerItem(hSpacer2); 128 | hLayout1->setSpacing(5); 129 | hLayout1->setContentsMargins(5, 0, 5, 5); 130 | 131 | hLayout2->addWidget(pidTextLabel, 0); 132 | hLayout2->addWidget(pidLineEdit, 1); 133 | hLayout2->setSpacing(5); 134 | hLayout2->setContentsMargins(5, 0, 5, 5); 135 | 136 | hLayout3->addWidget(vidTextLabel, 0); 137 | hLayout3->addWidget(vidLineEdit, 1); 138 | hLayout3->setSpacing(5); 139 | hLayout3->setContentsMargins(5, 0, 5, 5); 140 | 141 | hLayout4->addWidget(connectDeviceButton, 0); 142 | hLayout4->addWidget(unconnectDeviceButton, 1); 143 | hLayout4->setSpacing(0); 144 | hLayout4->setContentsMargins(0, 0, 0, 5); 145 | 146 | mainLayout->addWidget(titleBarWidget,0); 147 | mainLayout->addSpacerItem(vSpacer1); 148 | mainLayout->addLayout(hLayout1,1); 149 | mainLayout->addSpacerItem(vSpacer2); 150 | mainLayout->addLayout(hLayout2,2); 151 | mainLayout->addLayout(hLayout3,3); 152 | mainLayout->addLayout(hLayout4,4); 153 | mainLayout->setSpacing(0); 154 | mainLayout->setContentsMargins(0, 0, 0, 0); 155 | 156 | this->setLayout(mainLayout); 157 | } 158 | 159 | void ConnectWindow::connectDevice() 160 | { 161 | if (ENABLE_SIMULATION_MODE) 162 | return; 163 | 164 | if (g_USBDevice == NULL) 165 | { 166 | qDebug("g_USBDevice 无效指针"); 167 | return; 168 | } 169 | 170 | if(g_USBDevice->connectDevice() == true) 171 | { 172 | emit signal_Connected("已连接到设备!"); 173 | qDebug("已连接到设备!"); 174 | // 设置连接完成标识 175 | imageLabel->setStyleSheet("border-image: url(:/img/usb/connected.png);"); 176 | // 设置按键 177 | connectDeviceButton->setDisabled(true); 178 | unconnectDeviceButton->setEnabled(true); 179 | } 180 | else 181 | { 182 | qDebug("设备连接失败!"); 183 | } 184 | } 185 | 186 | void ConnectWindow::unconnectDevice() 187 | { 188 | if (ENABLE_SIMULATION_MODE) 189 | return; 190 | 191 | if (g_USBDevice == NULL) 192 | { 193 | qDebug("g_USBDevice 无效指针"); 194 | return; 195 | } 196 | 197 | if(g_USBDevice->unconnectDevice() == true) 198 | { 199 | emit signal_Unconnected("设备断开连接!"); 200 | qDebug("断开设备成功!"); 201 | // 设置断开完成标识 202 | imageLabel->setStyleSheet("border-image: url(:/img/usb/unconnected.png);"); 203 | // 设置按键状态 204 | connectDeviceButton->setEnabled(true); 205 | unconnectDeviceButton->setDisabled(true); 206 | } 207 | else 208 | { 209 | qDebug("断开设备失败!"); 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/connectwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef CONNECTWINDOW_H 2 | #define CONNECTWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "global.h" 11 | #include "component/titlebarwidget.h" 12 | #include "component/systembutton.h" 13 | 14 | namespace Ui { 15 | class ConnectWindow; 16 | } 17 | 18 | class ConnectWindow : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit ConnectWindow(QWidget *parent = 0); 24 | ~ConnectWindow(); 25 | 26 | signals: 27 | void signal_Connected(QString); 28 | void signal_Unconnected(QString); 29 | 30 | public slots: 31 | void closeWindow(); 32 | void connectDevice(); 33 | void unconnectDevice(); 34 | 35 | private: 36 | void paintEvent(QPaintEvent *); 37 | void initUI(); 38 | void initLayout(); 39 | 40 | private: 41 | Ui::ConnectWindow* ui; 42 | TitleBarWidget* titleBarWidget; 43 | QLineEdit* pidLineEdit; 44 | QLineEdit* vidLineEdit; 45 | QLabel* pidTextLabel; 46 | QLabel* vidTextLabel; 47 | QLabel* imageLabel; 48 | SystemButton* connectDeviceButton; 49 | SystemButton* unconnectDeviceButton; 50 | }; 51 | 52 | #endif // CONNECTWINDOW_H 53 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/ddswindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ddswindow.h" 2 | #include "ui_ddswindow.h" 3 | 4 | #include "window/mainwindow.h" 5 | 6 | DDSWindow::DDSWindow(QWidget *parent) : 7 | QWidget(0), 8 | ui(new Ui::DDSWindow) 9 | { 10 | parentWidget = parent; 11 | 12 | ui->setupUi(this); 13 | 14 | initUI(); 15 | } 16 | 17 | DDSWindow::~DDSWindow() 18 | { 19 | delete ui; 20 | } 21 | 22 | void DDSWindow::updateParameter() 23 | { 24 | DDSControlInfo dds; 25 | if (parentWidget) 26 | { 27 | ((MainWindow *)parentWidget)->usbThread.getDDSParameter(dds); 28 | 29 | if (dds.wave == DDS_WAVE_SINE) 30 | waveComboBox->setCurrentText("正弦波"); 31 | else if (dds.wave == DDS_WAVE_TRI) 32 | waveComboBox->setCurrentText("三角波"); 33 | else if (dds.wave == DDS_WAVE_SQUA) 34 | waveComboBox->setCurrentText("方波"); 35 | else if (dds.wave == DDS_WAVE_SINC) 36 | waveComboBox->setCurrentText("抽样函数"); 37 | else if (dds.wave == DDS_WAVE_GAUSSIAN) 38 | waveComboBox->setCurrentText("高斯函数"); 39 | else if (dds.wave == DDS_WAVE_DC) 40 | waveComboBox->setCurrentText("直流"); 41 | else //if (dds.wave == DDS_WAVE_NOISE) 42 | waveComboBox->setCurrentText("噪声"); 43 | 44 | QString str; 45 | str.sprintf("%.3lf", dds.frequency); 46 | freqLineEdit->setText(str); 47 | str.sprintf("%.3lf", dds.amplitude); 48 | amplitudeLineEdit->setText(str); 49 | str.sprintf("%.3lf", dds.offset); 50 | offsetLineEdit->setText(str); 51 | } 52 | else 53 | { 54 | freqLineEdit->setText("1000.0"); 55 | amplitudeLineEdit->setText("5.0"); 56 | offsetLineEdit->setText("0.0"); 57 | } 58 | 59 | } 60 | 61 | void DDSWindow::closeWindow() 62 | { 63 | this->close(); 64 | this->setAttribute(Qt::WA_DeleteOnClose,true); 65 | } 66 | 67 | void DDSWindow::setButtonHandler() 68 | { 69 | if (parentWidget) 70 | { 71 | DDSControlInfo dds; 72 | 73 | if(waveComboBox->currentText() == "正弦波") 74 | dds.wave = DDS_WAVE_SINE; 75 | else if(waveComboBox->currentText() == "三角波") 76 | dds.wave = DDS_WAVE_TRI; 77 | else if(waveComboBox->currentText() == "方波") 78 | dds.wave = DDS_WAVE_SQUA; 79 | else if(waveComboBox->currentText() == "抽样函数") 80 | dds.wave = DDS_WAVE_SINC; 81 | else if(waveComboBox->currentText() == "高斯函数") 82 | dds.wave = DDS_WAVE_GAUSSIAN; 83 | else if(waveComboBox->currentText() == "直流") 84 | dds.wave = DDS_WAVE_DC; 85 | else //if(waveComboBox->currentText() == "噪声") 86 | dds.wave = DDS_WAVE_NOISE; 87 | 88 | dds.frequency = freqLineEdit->text().toDouble(); 89 | dds.amplitude = amplitudeLineEdit->text().toDouble(); 90 | dds.offset = offsetLineEdit->text().toDouble(); 91 | dds.duty = 50.0; 92 | 93 | ((MainWindow *)parentWidget)->usbThread.setDDSParameter(dds); 94 | } 95 | } 96 | 97 | void DDSWindow::paintEvent(QPaintEvent *) 98 | { 99 | QPainterPath path; 100 | path.setFillRule(Qt::WindingFill); 101 | path.addRect(0, 0, this->width(), this->height()); 102 | 103 | QPainter painter(this); 104 | painter.fillPath(path, QBrush(Qt::white)); 105 | 106 | path.setFillRule(Qt::WindingFill); 107 | path.addRect(0, 0, this->width()-1, this->height()-1); 108 | 109 | painter.setPen("#0063B1"); 110 | painter.drawPath(path); 111 | } 112 | 113 | void DDSWindow::initUI() 114 | { 115 | this->setFixedSize(DEFAULT_DDS_WINDOW_WIDTH, DEFAULT_DDS_WINDOW_HEIGHT); 116 | this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); 117 | // this->setWindowIcon(QIcon(":/img/etc/logo.png")); 118 | this->setWindowIcon(QIcon(":/img/etc/icon.png")); 119 | this->setWindowTitle("μDSO"); 120 | this->setWindowOpacity(1); //窗体透明度设置 121 | 122 | titleBarWidget = new TitleBarWidget(this, DDS_WINDOW_TITLE, 30, false); 123 | titleBarWidget->initConnect(); 124 | connect(titleBarWidget, SIGNAL(closeWindow()), this, SLOT(closeWindow())); 125 | 126 | waveLabel = new QLabel(this); 127 | freqLabel = new QLabel(this); 128 | amplitudeLabel = new QLabel(this); 129 | offsetLabel = new QLabel(this); 130 | waveLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 131 | freqLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 132 | amplitudeLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 133 | offsetLabel->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 134 | waveLabel->setMinimumWidth(60); 135 | freqLabel->setMinimumWidth(60); 136 | amplitudeLabel->setMinimumWidth(60); 137 | offsetLabel->setMinimumWidth(60); 138 | waveLabel->setText("波形"); 139 | freqLabel->setText("频率(Hz)"); 140 | amplitudeLabel->setText("幅度( V )"); 141 | offsetLabel->setText("偏置( V )"); 142 | 143 | waveComboBox = new QComboBox(this); 144 | waveComboBox->setStyleSheet("QComboBox{" 145 | "border: 1px solid gray;" 146 | "border-radius: 0px;" 147 | " padding: 1px 2px 1px 2px;}" 148 | "QComboBox::drop-down{" 149 | "subcontrol-origin: padding;" 150 | "subcontrol-position: top right;" 151 | "width: 20px;" 152 | "border-left-width: 1px;" 153 | "border-left-color: darkgray;" 154 | "border-left-style: solid;" 155 | "border-top-right-radius: 5px;" 156 | "border-bottom-right-radius: 5px;}" 157 | "QComboBox::hover{border-color: rgb(0, 170, 255) ;}" 158 | "QComboBox::down-arrow{image: url(:/img/arrow/arrow_down.png);}"); 159 | waveComboBox->setFont(QFont("微软雅黑", 10, QFont::Normal, false)); 160 | waveComboBox->addItem("正弦波"); 161 | waveComboBox->addItem("三角波"); 162 | waveComboBox->addItem("方波"); 163 | waveComboBox->addItem("抽样函数"); 164 | waveComboBox->addItem("高斯函数"); 165 | waveComboBox->addItem("直流"); 166 | waveComboBox->addItem("噪声"); 167 | 168 | freqLineEdit = new QLineEdit(this); 169 | amplitudeLineEdit = new QLineEdit(this); 170 | offsetLineEdit = new QLineEdit(this); 171 | freqLineEdit->setStyleSheet("QLineEdit { color: black; border: 1px solid gray; }"); 172 | amplitudeLineEdit->setStyleSheet("QLineEdit { color: black; border: 1px solid gray; }"); 173 | offsetLineEdit->setStyleSheet("QLineEdit { color: black; border: 1px solid gray; }"); 174 | freqLineEdit->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 175 | amplitudeLineEdit->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 176 | offsetLineEdit->setFont(QFont("微软雅黑", 10, QFont::Bold, false)); 177 | freqLineEdit->setAlignment(Qt::AlignCenter); 178 | amplitudeLineEdit->setAlignment(Qt::AlignCenter); 179 | offsetLineEdit->setAlignment(Qt::AlignCenter); 180 | // freqLineEdit->setValidator(new QDoubleValidator(1.0, 5e6, 6, freqLineEdit)); 181 | // amplitudeLineEdit->setValidator(new QDoubleValidator(0.1, 8.0, 6, amplitudeLineEdit)); 182 | // offsetLineEdit->setValidator(new QDoubleValidator(0.1, 8.0, 6, offsetLineEdit)); 183 | 184 | updateParameter(); 185 | 186 | // setButton = new SystemButton(this, "应用设置"); 187 | // enableButton = new SystemButton(this, "打开输出"); 188 | // setButton->setSize((this->width()- 5*2 - 5)/2, 30); 189 | // enableButton->setSize((this->width()- 5*2 - 5)/2, 30); 190 | setButton = new SystemButton(this, "应用设置"); 191 | setButton->setFixedSize(this->width()- 5*2 , 30); 192 | 193 | connect(setButton, SIGNAL(clicked()), this, SLOT(setButtonHandler())); 194 | 195 | initLayout(); 196 | } 197 | 198 | void DDSWindow::initLayout() 199 | { 200 | QVBoxLayout* mainLayout = new QVBoxLayout(); 201 | 202 | QSpacerItem* vSpacer1 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); 203 | QHBoxLayout* hLayout1 = new QHBoxLayout(); 204 | QHBoxLayout* hLayout2 = new QHBoxLayout(); 205 | QHBoxLayout* hLayout3 = new QHBoxLayout(); 206 | QHBoxLayout* hLayout4 = new QHBoxLayout(); 207 | QHBoxLayout* hLayout5 = new QHBoxLayout(); 208 | 209 | hLayout1->addWidget(waveLabel, 0); 210 | hLayout1->addWidget(waveComboBox, 1); 211 | hLayout1->setSpacing(5); 212 | hLayout1->setContentsMargins(5, 5, 5, 5); 213 | 214 | hLayout2->addWidget(freqLabel, 0); 215 | hLayout2->addWidget(freqLineEdit, 1); 216 | hLayout2->setSpacing(5); 217 | hLayout2->setContentsMargins(5, 0, 5, 5); 218 | 219 | hLayout3->addWidget(amplitudeLabel, 0); 220 | hLayout3->addWidget(amplitudeLineEdit, 1); 221 | hLayout3->setSpacing(5); 222 | hLayout3->setContentsMargins(5, 0, 5, 5); 223 | 224 | hLayout4->addWidget(offsetLabel, 0); 225 | hLayout4->addWidget(offsetLineEdit, 1); 226 | hLayout4->setSpacing(5); 227 | hLayout4->setContentsMargins(5, 0, 5, 5); 228 | 229 | // hLayout5->addWidget(enableButton, 0); 230 | // hLayout5->addWidget(setButton , 1); 231 | hLayout5->addWidget(setButton, 0); 232 | hLayout5->setSpacing(5); 233 | hLayout5->setContentsMargins(5, 0, 5, 5); 234 | 235 | mainLayout->addWidget(titleBarWidget,0); 236 | 237 | mainLayout->addLayout(hLayout1, 1); 238 | mainLayout->addLayout(hLayout2, 2); 239 | mainLayout->addLayout(hLayout3, 3); 240 | mainLayout->addLayout(hLayout4, 4); 241 | mainLayout->addSpacerItem(vSpacer1); 242 | mainLayout->addLayout(hLayout5, 5); 243 | mainLayout->setSpacing(0); 244 | mainLayout->setContentsMargins(0, 0, 0, 0); 245 | 246 | this->setLayout(mainLayout); 247 | } 248 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/ddswindow.h: -------------------------------------------------------------------------------- 1 | #ifndef DDSWINDOW_H 2 | #define DDSWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "global.h" 11 | #include "component/titlebarwidget.h" 12 | #include "component/systembutton.h" 13 | 14 | namespace Ui { 15 | class DDSWindow; 16 | } 17 | 18 | class DDSWindow : public QWidget 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit DDSWindow(QWidget *parent = 0); 24 | ~DDSWindow(); 25 | 26 | void updateParameter(); 27 | 28 | public slots: 29 | void closeWindow(); 30 | void setButtonHandler(); 31 | 32 | private: 33 | QWidget *parentWidget; 34 | 35 | Ui::DDSWindow *ui; 36 | TitleBarWidget *titleBarWidget; 37 | 38 | QLabel* waveLabel; 39 | QLabel* freqLabel; 40 | QLabel* amplitudeLabel; 41 | QLabel* offsetLabel; 42 | QComboBox* waveComboBox; 43 | QLineEdit* freqLineEdit; 44 | QLineEdit* amplitudeLineEdit; 45 | QLineEdit* offsetLineEdit; 46 | SystemButton* setButton; 47 | SystemButton* enableButton; 48 | 49 | 50 | void initUI(); 51 | void initLayout(); 52 | void paintEvent(QPaintEvent *); 53 | }; 54 | 55 | #endif // DDSWINDOW_H 56 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | 4 | MainWindow::MainWindow(QWidget *parent) : 5 | QMainWindow(parent), 6 | ui(new Ui::MainWindow) 7 | { 8 | ui->setupUi(this); 9 | 10 | // 初始化窗口指针 11 | aboutWindow = NULL; 12 | connectWindow = NULL; 13 | ddsWindow = NULL; 14 | 15 | // 主界面模式设置为运行模式 16 | Mode = RUN; 17 | 18 | // 实例化USB类 19 | g_USBDevice = new usb(); 20 | // 主界面接收线程发送的信号 21 | connect(&usbThread, 22 | SIGNAL(signal_ReviceFinish(int)), 23 | this, 24 | SLOT(updateDisplay(int)) ); 25 | 26 | // 初始化UI 27 | initUI(); 28 | 29 | // 参数初始化 30 | ch1_VoltageOffset = 0; 31 | ch1_VoltageRange = 0; 32 | ch1_CouplingMode = 0; 33 | ch2_VoltageOffset = 0; 34 | ch2_VoltageRange = 0; 35 | ch2_CouplingMode = 0; 36 | triggerChannel = 0; 37 | triggerEdge = 0; 38 | triggerLevel = 0; 39 | sampleRate = 100000000; 40 | 41 | // 通道设置信号处理 42 | connect(ch1_settings_widget, SIGNAL(voltageOffsetChanged(int, int)), this, SLOT(voltageOffsetChangedHandler(int, int)) ); 43 | connect(ch1_settings_widget, SIGNAL(voltageRangeChanged(int, int)) , this, SLOT(voltageRangeChangedHandler(int, int)) ); 44 | connect(ch1_settings_widget, SIGNAL(couplingModeChanged(int, int)) , this, SLOT(couplingModeChangedHandler(int, int)) ); 45 | connect(ch2_settings_widget, SIGNAL(voltageOffsetChanged(int, int)), this, SLOT(voltageOffsetChangedHandler(int, int)) ); 46 | connect(ch2_settings_widget, SIGNAL(voltageRangeChanged(int, int)) , this, SLOT(voltageRangeChangedHandler(int, int)) ); 47 | connect(ch2_settings_widget, SIGNAL(couplingModeChanged(int, int)) , this, SLOT(couplingModeChangedHandler(int, int)) ); 48 | // 采样率设置信号处理 49 | connect(sampleRateSettingWidget, SIGNAL(sampleRateChanged(int)), this, SLOT(sampleRateChangedHandler(int)) ); 50 | // 触发设置信号处理 51 | connect(triggerWidget, SIGNAL(signal_channelChanged(int)), this, SLOT(triggerChannelChangedHandler(int)) ); 52 | connect(triggerWidget, SIGNAL(signal_edgeChanged(int)) , this, SLOT(triggerEdgeChangedHandler(int)) ); 53 | connect(triggerWidget, SIGNAL(signal_levelChanged(int)) , this, SLOT(triggerLevelChangedHandler(int)) ); 54 | 55 | // 启动线程 56 | usbThread.start(); 57 | } 58 | 59 | MainWindow::~MainWindow() 60 | { 61 | if (g_USBDevice) 62 | { 63 | // 关闭USB 64 | g_USBDevice->unconnectDevice(); 65 | delete g_USBDevice; 66 | g_USBDevice = NULL; 67 | } 68 | 69 | if (aboutWindow) 70 | { 71 | delete aboutWindow; 72 | aboutWindow = NULL; 73 | } 74 | if (connectWindow) 75 | { 76 | delete connectWindow; 77 | connectWindow = NULL; 78 | } 79 | if (ddsWindow) 80 | { 81 | delete ddsWindow; 82 | ddsWindow = NULL; 83 | } 84 | 85 | delete ui; 86 | 87 | usbThread.stop(); 88 | 89 | } 90 | 91 | // 窗口重定义大小 92 | void MainWindow::resizeEvent(QResizeEvent *) 93 | { 94 | } 95 | 96 | // 界面绘制事件 97 | void MainWindow::paintEvent(QPaintEvent *) 98 | { 99 | QPainterPath path; 100 | path.setFillRule(Qt::WindingFill); 101 | path.addRect(0, 0, this->width(), this->height()); 102 | 103 | QPainter painter(this); 104 | painter.fillPath(path, QBrush(Qt::white)); 105 | 106 | path.setFillRule(Qt::WindingFill); 107 | path.addRect(0, 0, this->width()-1, this->height()-1); 108 | 109 | painter.setPen("#0063B1"); 110 | painter.drawPath(path); 111 | } 112 | 113 | // 初始化界面 114 | void MainWindow::initUI() 115 | { 116 | QString titleText = MAIN_WINDOW_TITLE; 117 | if (ENABLE_SIMULATION_MODE) 118 | titleText += tr(" - Simulation Mode"); 119 | 120 | this->setMinimumSize(DEFAULT_MAIN_WINDOW_WIDTH, DEFAULT_MAIN_WINDOW_HEIGHT); 121 | this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint); 122 | // this->setWindowIcon(QIcon(":/img/etc/logo.png")); 123 | this->setWindowIcon(QIcon(":/img/etc/icon.png")); 124 | this->setWindowTitle(titleText); 125 | this->setWindowOpacity(1); //窗体透明度设置 126 | 127 | // 标题栏 128 | title_bar_widget = new TitleBarWidget(this, titleText, DEFAULT_TITLE_BAR_HEIGHT, true); 129 | title_bar_widget->initConnect(); 130 | connect(title_bar_widget, SIGNAL(closeWindow()), this, SLOT(closeApp())); 131 | 132 | // 主界面的下拉菜单 133 | mainMenu = new MainWindowMenu(this); 134 | mainMenu->intConnect(); 135 | 136 | // 状态栏 137 | status_bar_widget = new StatusBarWidget(this, DEFAULT_STATUS_BAR_HEIGHT); 138 | status_bar_widget->showMessage("未连接设备!"); 139 | status_bar_widget->isEnabledShowTime(true); 140 | 141 | // 波形显示区域 142 | oscillograph_widget = new OscillographWidget(this, 2); 143 | oscillograph_widget->setMinimumSize(this->width()-160-5*3, 144 | this->height()-title_bar_widget->height()-status_bar_widget->height() - 5*2); 145 | //连接信号槽函数 146 | connect(this, SIGNAL(signal_ModeChanged(int)), oscillograph_widget, SLOT(updateMode(int))); 147 | emit signal_ModeChanged(Mode); 148 | 149 | // CH1、CH2控制面板 150 | ch1_settings_widget = new ChannelSettingsWidget(this, 0, "CH1", Qt::yellow); 151 | ch2_settings_widget = new ChannelSettingsWidget(this, 1, "CH2", QColor(0x48, 0x76, 0xFF)); 152 | 153 | // 设置颜色关联的槽函数 154 | connect(ch1_settings_widget, 155 | SIGNAL(markColoChange(int, QColor)), 156 | oscillograph_widget, 157 | SLOT(setChannelMarkColor(int, QColor)) 158 | ); 159 | connect(ch2_settings_widget, 160 | SIGNAL(markColoChange(int, QColor)), 161 | oscillograph_widget, 162 | SLOT(setChannelMarkColor(int, QColor)) 163 | ); 164 | // 直接调用槽函数设置波形颜色 165 | oscillograph_widget->setChannelMarkColor(0, Qt::yellow); 166 | oscillograph_widget->setChannelMarkColor(1, QColor(0x48, 0x76, 0xFF)); 167 | 168 | // 采样速率设置 169 | sampleRateSettingWidget = new SampleRateSettingWidget(this); 170 | 171 | // 触发设置 172 | triggerWidget = new TriggerWidget(this); 173 | 174 | // 按键 175 | runButton = new SystemButton(this, "运行/暂停"); 176 | // singleButton = new SystemButton(this, "单次采集"); 177 | // autoButton = new SystemButton(this, "自动设置"); 178 | defalutButton = new SystemButton(this, "默认设置"); 179 | // saveDataDeviceButton = new SystemButton(this, "保存数据"); 180 | screenshotButton = new SystemButton(this, "截图"); 181 | 182 | // 设置按键默认状态 183 | disableButton(); 184 | 185 | // 设置按键事件 186 | connect(runButton, SIGNAL(clicked()), this, SLOT( runButtonHandler()) ); 187 | // connect(singleButton, SIGNAL(clicked()), this, SLOT( singleButtonHandler()) ); 188 | // connect(autoButton, SIGNAL(clicked()), this, SLOT( autoButtonHandler()) ); 189 | connect(defalutButton, SIGNAL(clicked()), this, SLOT( defalutButtonHandler()) ); 190 | // connect(saveDataDeviceButton, SIGNAL(clicked()), this, SLOT( saveDataDeviceButtonHandler()) ); 191 | connect(screenshotButton, SIGNAL(clicked()), this, SLOT( screenshotButtonHandler()) ); 192 | 193 | connect(ch1_settings_widget, SIGNAL(switchStateChanged(int, bool)), oscillograph_widget, SLOT(setChannelDisplay(int, bool))); 194 | connect(ch2_settings_widget, SIGNAL(switchStateChanged(int, bool)), oscillograph_widget, SLOT(setChannelDisplay(int, bool))); 195 | 196 | // 初始化布局 197 | initLayout(); 198 | } 199 | 200 | // 初始化布局 201 | void MainWindow::initLayout() 202 | { 203 | QVBoxLayout *mainLayout = new QVBoxLayout(); 204 | QHBoxLayout *hLayout1 = new QHBoxLayout(); 205 | QVBoxLayout *vLayout1 = new QVBoxLayout(); 206 | QGridLayout *gridLayout = new QGridLayout(); 207 | QSpacerItem *vSpacer1 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); 208 | // QSpacerItem *vSpacer2 = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); 209 | 210 | // gridLayout->addWidget(runButton, 0, 0); 211 | // gridLayout->addWidget(singleButton, 0, 1); 212 | // gridLayout->addWidget(autoButton, 1, 0); 213 | // gridLayout->addWidget(defalutButton, 1, 1); 214 | // gridLayout->addWidget(saveDataDeviceButton, 2, 0); 215 | // gridLayout->addWidget(screenshotButton, 2, 1); 216 | // gridLayout->setSpacing(5); 217 | // gridLayout->setContentsMargins(0, 0, 0, 0); 218 | runButton->setFixedSize(160, 32); 219 | defalutButton->setFixedSize(160, 32); 220 | screenshotButton->setFixedSize(160, 32); 221 | gridLayout->addWidget(runButton, 0, 0); 222 | gridLayout->addWidget(defalutButton, 1, 0); 223 | gridLayout->addWidget(screenshotButton, 2, 0); 224 | gridLayout->setSpacing(2); 225 | gridLayout->setContentsMargins(0, 0, 0, 0); 226 | 227 | vLayout1->addWidget(ch1_settings_widget, 0); 228 | vLayout1->addWidget(ch2_settings_widget, 1); 229 | vLayout1->addWidget(sampleRateSettingWidget, 2); 230 | vLayout1->addWidget(triggerWidget, 3); 231 | vLayout1->addSpacerItem(vSpacer1); 232 | vLayout1->addLayout(gridLayout); 233 | // vLayout1->addSpacerItem(vSpacer2); 234 | vLayout1->setSpacing(0); 235 | vLayout1->setContentsMargins(5, 0, 5, 5); 236 | 237 | hLayout1->addWidget(oscillograph_widget,0); 238 | hLayout1->addLayout(vLayout1,1); 239 | hLayout1->setSpacing(0); 240 | hLayout1->setContentsMargins(0, 0, 0, 0); 241 | 242 | mainLayout->addWidget(title_bar_widget,0); 243 | mainLayout->addLayout(hLayout1,1); 244 | mainLayout->addWidget(status_bar_widget,2); 245 | mainLayout->setSpacing(0); 246 | mainLayout->setContentsMargins(1, 1, 1, 1); 247 | 248 | central_Widget = new QWidget(); 249 | this->setCentralWidget(central_Widget); 250 | central_Widget->setLayout(mainLayout); 251 | } 252 | 253 | // 打开下拉菜单 254 | void MainWindow::showMainMenu() 255 | { 256 | QPoint p = this->rect().topRight(); 257 | 258 | p.setX(p.x() - 180); 259 | p.setY(p.y() + title_bar_widget->height()); 260 | mainMenu->exec(this->mapToGlobal(p)); 261 | } 262 | 263 | // 打开设备连接窗口 264 | void MainWindow::openConnectWindow() 265 | { 266 | if (connectWindow == NULL) 267 | { 268 | connectWindow = new ConnectWindow(); 269 | connectWindow->show(); 270 | } 271 | else if (connectWindow->testAttribute(Qt::WA_DeleteOnClose) == true) 272 | { 273 | delete connectWindow; 274 | connectWindow = new ConnectWindow(); 275 | connectWindow->show(); 276 | } 277 | connect( connectWindow, SIGNAL( signal_Connected(QString) ), this, SLOT( updateStatusBar(QString) ) ); 278 | connect( connectWindow, SIGNAL( signal_Unconnected(QString) ), this, SLOT( updateStatusBar(QString) ) ); 279 | connect( connectWindow, SIGNAL( signal_Connected(QString) ), this, SLOT( enableButton(QString) ) ); 280 | connect( connectWindow, SIGNAL( signal_Unconnected(QString) ), this, SLOT( disableButton(QString) ) ); 281 | } 282 | 283 | // 打开帮助窗口 284 | void MainWindow::openAboutWindow() 285 | { 286 | if (aboutWindow == NULL) 287 | { 288 | aboutWindow = new AboutWindow(0); 289 | aboutWindow->show(); 290 | } 291 | else if (aboutWindow->testAttribute(Qt::WA_DeleteOnClose) == true) 292 | { 293 | delete aboutWindow; 294 | aboutWindow = new AboutWindow(0); 295 | aboutWindow->show(); 296 | } 297 | } 298 | 299 | // 打开信号发生器窗口 300 | void MainWindow::openDDSWindow() 301 | { 302 | if (ddsWindow == NULL) 303 | { 304 | ddsWindow = new DDSWindow(this); 305 | ddsWindow->show(); 306 | } 307 | else if (ddsWindow->testAttribute(Qt::WA_DeleteOnClose) == true) 308 | { 309 | delete ddsWindow; 310 | ddsWindow = new DDSWindow(this); 311 | ddsWindow->show(); 312 | } 313 | } 314 | 315 | // 关闭应用 316 | void MainWindow::closeApp() 317 | { 318 | // 关闭其它窗口 319 | if (aboutWindow && aboutWindow->testAttribute(Qt::WA_DeleteOnClose) == false) 320 | { 321 | aboutWindow->close(); 322 | } 323 | if (connectWindow && connectWindow->testAttribute(Qt::WA_DeleteOnClose) == false) 324 | { 325 | connectWindow->close(); 326 | } 327 | if (ddsWindow && ddsWindow->testAttribute(Qt::WA_DeleteOnClose) == false) 328 | { 329 | ddsWindow->close(); 330 | } 331 | 332 | // 切断设备连接 333 | 334 | // 关闭主窗口 335 | this->close(); 336 | } 337 | 338 | // 更新波形界面 339 | void MainWindow::updateDisplay(int readIndex) 340 | { 341 | if ( Mode == RUN || Mode == SINGLE || Mode == AUTO || Mode == DEFAULT ) 342 | { 343 | usbThread.setReadIndex(readIndex); 344 | oscillograph_widget->dispWaveData((unsigned char*)(usbThread.adData[readIndex]), SAMPLING_LENGTH_MAX); 345 | usbThread.setReadIndex(-1); 346 | } 347 | } 348 | 349 | // 更新消息栏 350 | void MainWindow::updateStatusBar(QString str) 351 | { 352 | status_bar_widget->showMessage(str); 353 | } 354 | 355 | // 失效某些按键 356 | void MainWindow::enableButton() 357 | { 358 | runButton->setEnabled(true) ; 359 | // singleButton->setEnabled(true) ; 360 | // autoButton->setEnabled(true) ; 361 | defalutButton->setEnabled(true) ; 362 | // saveDataDeviceButton->setEnabled(true) ; 363 | } 364 | 365 | // 所有按键有效 366 | void MainWindow::disableButton() 367 | { 368 | runButton->setDisabled(true) ; 369 | // singleButton->setDisabled(true) ; 370 | // autoButton->setDisabled(true) ; 371 | defalutButton->setDisabled(true) ; 372 | // saveDataDeviceButton->setDisabled(true) ; 373 | } 374 | 375 | // 运行状态设置 376 | void MainWindow::runButtonHandler() 377 | { 378 | if (Mode == RUN) 379 | Mode = STOP; 380 | else 381 | Mode = RUN; 382 | 383 | emit signal_ModeChanged(Mode); 384 | } 385 | 386 | // 单次模式触发 387 | void MainWindow::singleButtonHandler() 388 | { 389 | Mode = SINGLE; 390 | emit signal_ModeChanged(Mode); 391 | } 392 | 393 | // 自动设置 394 | void MainWindow::autoButtonHandler() 395 | { 396 | Mode = AUTO; 397 | emit signal_ModeChanged(Mode); 398 | } 399 | 400 | // 默认设置 401 | void MainWindow::defalutButtonHandler() 402 | { 403 | // Mode = DEFAULT; 404 | // emit signal_ModeChanged(Mode); 405 | 406 | // DDS参数 407 | DDSControlInfo dds; 408 | dds.wave = DDS_WAVE_SINE; 409 | dds.frequency = 1000.0; 410 | dds.amplitude = 5.0; 411 | dds.offset = 0.0; 412 | dds.duty = 50.0; 413 | usbThread.setDDSParameter(dds); 414 | // DSO参数 415 | DSOControlInfo dso; 416 | dso.sampleRate = 8; 417 | dso.ch1Offset = 0.0; 418 | dso.ch1VoltageRange = 2; 419 | dso.ch1Coupling = DSO_COUPLING_DC; 420 | dso.ch2Offset = 0.0; 421 | dso.ch2VoltageRange = 2; 422 | dso.ch2Coupling = DSO_COUPLING_DC; 423 | dso.trigChannel = DSO_CHANNEL1; 424 | dso.trigEdge = DSO_TRIG_RAISE; 425 | dso.trigLevel = 1.25; 426 | usbThread.setDSOParameter(dso); 427 | 428 | if (ddsWindow && ddsWindow->testAttribute(Qt::WA_DeleteOnClose) == false) 429 | ddsWindow->updateParameter(); 430 | 431 | ch1_settings_widget->updateParameter(); 432 | ch2_settings_widget->updateParameter(); 433 | sampleRateSettingWidget->updateParameter(); 434 | triggerWidget->updateParameter(); 435 | } 436 | 437 | // 保存数据 438 | void MainWindow::saveDataDeviceButtonHandler() 439 | { 440 | 441 | } 442 | 443 | // 截图按键处理 444 | void MainWindow::screenshotButtonHandler() 445 | { 446 | QPixmap currentScreenPixmap(this->width(),this->height()+20); 447 | QPainter painter(¤tScreenPixmap); 448 | 449 | QString fileName = QFileDialog::getSaveFileName(this, 450 | tr("Save screenshot"), 451 | QDateTime::currentDateTime().toString("yyyyMMddhhmmss"), 452 | tr("Image Files (*.png)")); 453 | 454 | if (!fileName.isNull()) 455 | { 456 | painter.fillRect(QRect(0,0,currentScreenPixmap.width(),currentScreenPixmap.height()),Qt::white); 457 | painter.drawPixmap(0, 20, QWidget::grab(QRect(0,0,this->width(),this->height()) ) ); 458 | painter.setFont(QFont("微软雅黑",10,QFont::Normal,false)); 459 | 460 | painter.setPen(Qt::black); 461 | painter.drawText(QRect(0,0,800,20),(QString)" μDSO " + 462 | (QString)"Version:" + 463 | (QString)UDSO_VERSION + 464 | (QString)" " + 465 | QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss")); 466 | painter.drawText(QRect(currentScreenPixmap.width()-30,0,30,20),"截图"); 467 | 468 | currentScreenPixmap.save(fileName); 469 | qDebug()<< fileName; 470 | 471 | status_bar_widget->showMessage("已保存到: " + fileName); 472 | } 473 | } 474 | 475 | // 电压偏移设置 476 | void MainWindow::voltageOffsetChangedHandler(int chn, int data) 477 | { 478 | switch(chn) 479 | { 480 | case 0: 481 | // TODO 修改偏移,检查参数是否在合适的范围内 482 | // TODO 修改面板显示的内容 483 | // TODO 发送CH1偏移修改信息给USB设备 484 | break; 485 | case 1: 486 | // TODO 修改偏移,检查参数是否在合适的范围内 487 | // TODO 修改面板显示的内容 488 | // TODO 发送CH2偏移修改信息给USB设备 489 | break; 490 | defalut: 491 | break; 492 | } 493 | } 494 | 495 | // 电压量程设置 496 | void MainWindow::voltageRangeChangedHandler(int chn, int data) 497 | { 498 | switch(chn) 499 | { 500 | case 0: 501 | // TODO 修改量程,检查参数是否在合适的范围内 502 | // TODO 修改面板显示的内容 503 | // TODO 发送CH1量程修改信息给USB设备 504 | break; 505 | case 1: 506 | // TODO 修改量程,检查参数是否在合适的范围内 507 | // TODO 修改面板显示的内容 508 | // TODO 发送CH2量程修改信息给USB设备 509 | break; 510 | defalut: 511 | break; 512 | } 513 | } 514 | 515 | // 耦合模式设置 516 | void MainWindow::couplingModeChangedHandler(int chn, int data) 517 | { 518 | switch(chn) 519 | { 520 | case 0: 521 | // TODO 修改耦合,检查参数是否在合适的范围内 522 | // TODO 修改面板显示的内容 523 | // TODO 发送CH1耦合修改信息给USB设备 524 | break; 525 | case 1: 526 | // TODO 修改耦合,检查参数是否在合适的范围内 527 | // TODO 修改面板显示的内容 528 | // TODO 发送CH2耦合修改信息给USB设备 529 | break; 530 | defalut: 531 | break; 532 | } 533 | } 534 | 535 | // 触发通道设置 536 | void MainWindow::triggerChannelChangedHandler(int data) 537 | { 538 | 539 | } 540 | 541 | // 触发边沿 542 | void MainWindow::triggerEdgeChangedHandler(int data) 543 | { 544 | 545 | } 546 | 547 | // 触发水平设置 548 | void MainWindow::triggerLevelChangedHandler(int data) 549 | { 550 | 551 | } 552 | 553 | // 采样率改变 554 | void MainWindow::sampleRateChangedHandler(int data) 555 | { 556 | static int count=16; 557 | 558 | if (data == 1 && count < 16) 559 | { 560 | count+=1; 561 | } 562 | else if (data == -1 && count >0) 563 | { 564 | count-=1; 565 | } 566 | 567 | QString sampleRateString; 568 | QString resolutionString; 569 | switch (count) 570 | { 571 | case 0: 572 | sampleRateString = "500/s"; 573 | resolutionString.sprintf("%.0fms/Div",204.8/(5*10e2)*10e3); 574 | break; 575 | case 1: 576 | sampleRateString = "1K/s"; 577 | resolutionString.sprintf("%.0fms/Div",204.8/(1*10e3)*10e3); 578 | break; 579 | case 2: 580 | sampleRateString = "2.5K/s"; 581 | resolutionString.sprintf("%.0fms/Div",204.8/(2.5*10e3)*10e3); 582 | break; 583 | case 3: 584 | sampleRateString = "5K/s"; 585 | resolutionString.sprintf("%.0fms/Div",204.8/(5*10e3)*10e3); 586 | break; 587 | case 4: 588 | sampleRateString = "10K/s"; 589 | resolutionString.sprintf("%.0fms/Div",204.8/(1*10e4)*10e3); 590 | break; 591 | case 5: 592 | sampleRateString = "25K/s"; 593 | resolutionString.sprintf("%.0fms/Div",204.8/(2.5*10e4)*10e3); 594 | break; 595 | case 6: 596 | sampleRateString = "50K/s"; 597 | resolutionString.sprintf("%.0fms/Div",204.8/(5*10e4)*10e3); 598 | break; 599 | case 7: 600 | sampleRateString = "100K/s"; 601 | resolutionString.sprintf("%.0fms/Div",204.8/(1*10e5)*10e3); 602 | break; 603 | case 8: 604 | sampleRateString = "250K/s"; 605 | resolutionString.sprintf("%.0fus/Div",204.8/(2.5*10e5)*10e6); 606 | break; 607 | case 9: 608 | sampleRateString = "500K/s"; 609 | resolutionString.sprintf("%.0fus/Div",204.8/(5*10e5)*10e6); 610 | break; 611 | case 10: 612 | sampleRateString = "1M/s"; 613 | resolutionString.sprintf("%.0fus/Div",204.8/(1*10e6)*10e6); 614 | break; 615 | case 11: 616 | sampleRateString = "2.5M/s"; 617 | resolutionString.sprintf("%.0fus/Div",204.8/(2.5*10e6)*10e6); 618 | break; 619 | case 12: 620 | sampleRateString = "5M/s"; 621 | resolutionString.sprintf("%.0fus/Div",204.8/(5*10e6)*10e6); 622 | break; 623 | case 13: 624 | sampleRateString = "10M/s"; 625 | resolutionString.sprintf("%.0fus/Div",204.8/(1*10e7)*10e6); 626 | break; 627 | case 14: 628 | sampleRateString = "25M/s"; 629 | resolutionString.sprintf("%.0fus/Div",204.8/(2.5*10e7)*10e6); 630 | break; 631 | case 15: 632 | sampleRateString = "50M/s"; 633 | resolutionString.sprintf("%.0fus/Div",204.8/(5*10e7)*10e6); 634 | break; 635 | case 16: 636 | sampleRateString = "100M/s"; 637 | resolutionString.sprintf("%.0fus/Div",204.8/(1*10e8)*10e6); 638 | break; 639 | default: 640 | break; 641 | } 642 | 643 | sampleRateSettingWidget->setSampleRateDisplay(sampleRateString); 644 | sampleRateSettingWidget->setResolutionDisplay(resolutionString); 645 | } 646 | -------------------------------------------------------------------------------- /PC_Software_Qt/uDSO/window/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | #include "global.h" 19 | #include "window/connectwindow.h" 20 | #include "window/aboutwindow.h" 21 | #include "window/ddswindow.h" 22 | #include "usb/usb.h" 23 | #include "usb/usbthread.h" 24 | #include "component/titlebarwidget.h" 25 | #include "component/statusbarwidget.h" 26 | #include "component/oscillographwidget.h" 27 | #include "component/channelsettingswidget.h" 28 | #include "component/systembutton.h" 29 | #include "component/mainwindowmenu.h" 30 | #include "component/sampleratesettingwidget.h" 31 | #include "component/triggerwidget.h" 32 | 33 | namespace Ui { 34 | class MainWindow; 35 | } 36 | 37 | class MainWindow : public QMainWindow 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit MainWindow(QWidget *parent = 0); 43 | ~MainWindow(); 44 | 45 | // USB通信线程 46 | USBThread usbThread; 47 | 48 | signals: 49 | void signal_ModeChanged(int); 50 | 51 | public slots: 52 | void showMainMenu(); 53 | void openConnectWindow(); 54 | void openAboutWindow(); 55 | void openDDSWindow(); 56 | void closeApp(); 57 | void updateDisplay(int readIndex); 58 | 59 | void updateStatusBar(QString str); 60 | void enableButton(); 61 | void disableButton(); 62 | 63 | void runButtonHandler(); 64 | void singleButtonHandler(); 65 | void autoButtonHandler(); 66 | void defalutButtonHandler(); 67 | void saveDataDeviceButtonHandler(); 68 | void screenshotButtonHandler(); 69 | 70 | // 用于处理控件发送的信号 71 | // 发送给USB设备 72 | void voltageOffsetChangedHandler(int chn, int data); 73 | void voltageRangeChangedHandler(int chn, int data); 74 | void couplingModeChangedHandler(int chn, int data); 75 | // 发送给USB设备和OscillographWidget控件 76 | void triggerChannelChangedHandler(int data); 77 | void triggerEdgeChangedHandler(int data); 78 | void triggerLevelChangedHandler(int data); 79 | // 发送给USB设备 80 | void sampleRateChangedHandler(int data); 81 | 82 | protected: 83 | void resizeEvent(QResizeEvent *); 84 | 85 | private: 86 | Ui::MainWindow *ui; 87 | 88 | // 程序状态控制 89 | enum{ 90 | RUN = 0, 91 | STOP = 1, 92 | SINGLE = 2, 93 | AUTO = 3, 94 | DEFAULT = 4, 95 | }Mode; 96 | 97 | // 子窗口 98 | ConnectWindow* connectWindow; 99 | AboutWindow* aboutWindow; 100 | DDSWindow* ddsWindow; 101 | 102 | QWidget* central_Widget; 103 | 104 | // 自定义组件 105 | TitleBarWidget* title_bar_widget; 106 | StatusBarWidget* status_bar_widget; 107 | MainWindowMenu* mainMenu; 108 | OscillographWidget* oscillograph_widget; 109 | ChannelSettingsWidget* ch1_settings_widget; 110 | ChannelSettingsWidget* ch2_settings_widget; 111 | SampleRateSettingWidget* sampleRateSettingWidget; 112 | TriggerWidget* triggerWidget; 113 | 114 | // 按键 115 | SystemButton* runButton; 116 | SystemButton* singleButton; 117 | SystemButton* autoButton; 118 | SystemButton* defalutButton; 119 | SystemButton* saveDataDeviceButton; 120 | SystemButton* screenshotButton; 121 | 122 | // 供调试使用 123 | int demoTimerId; 124 | int demoDataIndex; 125 | unsigned char demoDatas[2][4096]; 126 | 127 | // 示波器控制参数 128 | int ch1_VoltageOffset; 129 | int ch1_VoltageRange; 130 | int ch1_CouplingMode; 131 | int ch2_VoltageOffset; 132 | int ch2_VoltageRange; 133 | int ch2_CouplingMode; 134 | int triggerChannel; 135 | int triggerEdge; 136 | int triggerLevel; 137 | long sampleRate; 138 | 139 | void paintEvent(QPaintEvent *); 140 | void initUI(); 141 | void initLayout(); 142 | }; 143 | 144 | #endif // MAINWINDOW_H 145 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## uDSO是什么? 2 | 这是一个基于Qt的虚拟示波器软件,通过USB2.0与采样设备进行通信,目前使用STM32F407VET作为采样设备主控芯片,STM32F407VET直接控制高速ADC(AD9280)进行采样,后面计划可能会改用其它芯片(例如ZYNQ等)。当前软件主要支持Windows平台,后面计划会支持移动平台(Android)... 3 | 4 | ![](Screenshot/demo.png) 5 | 6 | ## uDSO有什么功能? 7 | - 示波器 8 | - 逻辑分析仪 9 | - 信号发生器 10 | - ... 11 | 12 | ## uDSO能用来干什么? 13 | - 便携的数字示波器,虚拟示波器 14 | - 替代传统数字示波器 15 | - ... 16 | 17 | ## 关于 uDSO 18 | * 这是一个长期开发和更新的项目,不会有明确的更新时间和终止期限,uDSO 开源、自由、跨平台(Linux/Windows)! 19 | * 公布所有源代码,以及采样设备的原理图和PCB文件(假如这些东西都能被公开的话)... 20 | 21 | #### 软件运行截图 22 | Windows10 系统 23 | ![image 运行截图1](Screenshot/20160119223711.png) 24 | Windows10 系统 25 | ![image 运行截图2](Screenshot/20160119223728.png) 26 | 27 | #### 硬件电路效果图 28 | 主控板电路效果图 29 | ![image 电路效果图](Screenshot/主控电路效果图.png) 30 | 31 | ## TODO 32 | ### 现有问题: 33 | - 还没有完成第一版程序,源代码未上传公开 34 | - 还没有完成第一版电路设计,硬件还未开始调试,PCB未上传公开,硬件是短腿 35 | - 开始时没有明确的目标,本人也比较拖拉,导致整个项目进展非常缓慢 :P 36 | - ... 37 | 38 | ### 待添加功能: 39 | - 赶紧完成第一版程序,将源代码上传公开!!! 40 | - 赶紧完成第一版电路,将PCB上传公开!!! 41 | - ... 42 | 43 | ## License 44 | GNU GENERAL PUBLIC LICENSE Version 3 45 | 46 | ## 关于作者 47 | ![image AzureIcon](Screenshot/Azure.png) 48 | 49 | E-mail: 985424805@qq.com(欢迎联系交流) 50 | -------------------------------------------------------------------------------- /Screenshot/20160119223711.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/20160119223711.png -------------------------------------------------------------------------------- /Screenshot/20160119223728.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/20160119223728.png -------------------------------------------------------------------------------- /Screenshot/20160119223749.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/20160119223749.png -------------------------------------------------------------------------------- /Screenshot/Azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/Azure.png -------------------------------------------------------------------------------- /Screenshot/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/demo.png -------------------------------------------------------------------------------- /Screenshot/主控电路效果图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure2016/uDSO/4e20fb39aa1eca609a18de2b91af8522d00cb27e/Screenshot/主控电路效果图.png --------------------------------------------------------------------------------