⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temperature.frm

📁 PC端的USB主机源代码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Width           =   1215
   End
   Begin VB.TextBox Temperature 
      Alignment       =   2  'Center
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   4200
      TabIndex        =   8
      Text            =   "22"
      Top             =   2400
      Width           =   1215
   End
   Begin VB.TextBox Temperature 
      Alignment       =   2  'Center
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   4200
      TabIndex        =   7
      Text            =   "20"
      Top             =   1800
      Width           =   1215
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   5
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   4800
      Width           =   495
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   4
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   4200
      Width           =   495
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   3
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   3600
      Width           =   495
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   2
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   3000
      Width           =   495
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   1
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   2400
      Width           =   495
   End
   Begin VB.Label Heading 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Upper"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   14.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   375
      Index           =   1
      Left            =   5520
      TabIndex        =   26
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Label Heading 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Lower"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   14.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   375
      Index           =   0
      Left            =   2880
      TabIndex        =   25
      Top             =   1320
      Width           =   1215
   End
   Begin VB.Shape Alarm 
      FillColor       =   &H000000FF&
      FillStyle       =   0  'Solid
      Height          =   495
      Index           =   0
      Left            =   7200
      Shape           =   3  'Circle
      Top             =   1800
      Width           =   495
   End
   Begin VB.Label Title 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Adding Temperature Limits"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   24
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   1095
      Left            =   0
      TabIndex        =   6
      Top             =   360
      Width           =   8535
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 6"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   5
      Left            =   600
      TabIndex        =   5
      Top             =   4800
      Width           =   1935
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 5"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   4
      Left            =   600
      TabIndex        =   4
      Top             =   4200
      Width           =   1935
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 4"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   3
      Left            =   600
      TabIndex        =   3
      Top             =   3600
      Width           =   1935
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 3"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   2
      Left            =   600
      TabIndex        =   2
      Top             =   3000
      Width           =   1935
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 2"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   1
      Left            =   600
      TabIndex        =   1
      Top             =   2400
      Width           =   1935
   End
   Begin VB.Label Label 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Sensor 1"
      BeginProperty Font 
         Name            =   "Arial Rounded MT Bold"
         Size            =   20.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   615
      Index           =   0
      Left            =   480
      TabIndex        =   0
      Top             =   1800
      Width           =   2175
   End
End
Attribute VB_Name = "DisplayWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' This example operates a little differently than described in Chapter 9 (it's simpler)
' Both examples (Reading Temperatures and Adding Temperature Limits) use the same code,
' only the display is different.
' Every 200msec the Lower and Upper Limits are downloaded to the IO Device which replys
' with the current temperatures and an ALARM byte [Bit 0 = Alarm(0), Bit(1) = Alarm(1), etc]
'
' For ease of display the temperature ranges are restricted 00 to 99 (you can change this)
'
Private Limits As Boolean ' Choose between Example 1 or 2
Private Red, Black As Long

Private Sub Form_Load()
' This module contains both Thermometer examples, set "Limits" = TRUE for example 2
Limits = True
Red = RGB(255, 0, 0): Black = RGB(0, 0, 0) ' Initialize my ALARM colors
If Not Limits Then ' Hide all of the extra display for example 2
    For i% = 0 To 5: LowerLimit(i%).Visible = False: UpperLimit(i%).Visible = False: Alarm(i%).Visible = False: Next i%
    Heading(0).Visible = False: Heading(1).Visible = False
    Title.Caption = "Reading Temperatures"
    End If
End Sub

Private Sub Timer1_Timer()
' Update Limits and check for temperature changes every 200msec
Dim Temperatures(6) As Byte ' Note Temperature(6) is the ALARM indicator
Dim Alarms As Byte: Dim Buffer(11) As Byte
For i% = 0 To 5: Buffer(i%) = Val(LowerLimit(i%).Text): Buffer(6 + i%) = Val(UpperLimit(i%).Text): Next i%
Call WriteUSBdevice(AddressFor(Buffer(0)), 12)  'Update limits
Call ReadUSBdevice(AddressFor(Temperatures(0)), 7) ' Read current temperature
'For i% = 0 To 5: Temperatures(i%) = ((i% + 2) * 10) + i%: Next i%: Temperatures(6) = &H39
Alarms = Temperatures(6)
For i% = 0 To 5 ' Update temperature display and show ALARMs if present
    Temperature(i%).Text = TwoDecimalCharacters$(Temperatures(i%))
    If ((Alarms And 1) = 1) And (Alarm(i%).FillColor = Black) Then Alarm(i%).FillColor = Red
    If ((Alarms And 1) = 0) And (Alarm(i%).FillColor = Red) Then Alarm(i%).FillColor = Black
    Alarms = (Alarms And &HFE) / 2 ' Clear Bit 0 before divide
    Next i%
' NOTE: a real program would do something significant when an ALARM was detected
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -