-
Aug 10th, 2019, 06:11 AM
#1
Thread Starter
New Member
How to make 7 Segment led display GUI?
Hi there to everyone I know my way around visual studio and would like to know , how do you create in vb.net
7 Segment led display controls?
And just out of curiosity
Once I learn how to create these displays I would
Like to be able to communicate through serial port to actual device further down the road!!
I’m trying to find out and learn how it is really done and especially
In VB.NET cause that is my favourite and some what easier language for me to learn and I love it .
So I hope there’s someone nice enough to share that knowledge on how it is created in vb be it picture boxes or actual hard coded for faster process and smooth flow....
-
Aug 10th, 2019, 09:32 AM
#2
Re: How to make 7 Segment led display GUI?
Have you searched the forum. I think I have seen this before.
-
Aug 10th, 2019, 11:43 AM
#3
Re: How to make 7 Segment led display GUI?
Its not clear exactly what you want. Just to draw the numbers? Here is start on it that I came up with.
See where it draws the string of numbers at the cords specified (also scale ratio) in the paint event?
Code:
Imports System.Drawing.Drawing2D
Public Class Form3
Private Sub Form3_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
Dim ScaleRatio As Single = CSng(Me.ClientSize.Width / 50)
With e.Graphics
.ScaleTransform(ScaleRatio, ScaleRatio)
'draw grid
Using pg As New Pen(Color.DimGray, 0.01)
Dim gMax As Integer = CInt(10 * ScaleRatio)
For x As Integer = 0 To gMax
.DrawLine(pg, x, 0, x, gMax)
.DrawLine(pg, 0, x, gMax, x)
Next
End Using
DrawNumber(e.Graphics, "0123.4", 2, 1)
DrawNumber(e.Graphics, "56789", 2, 14)
End With
End Sub
Private Sub DrawNumber(g As Graphics, theNumber As String, x1 As Single, y1 As Single)
With g
Dim transState As GraphicsState = g.Save()
.TranslateTransform(x1, y1)
For i As Integer = 0 To theNumber.Length - 1
DrawDigit(g, theNumber.Substring(i, 1))
.TranslateTransform(9, 0)
Next
g.Restore(transState)
End With
End Sub
Private Sub DrawDigit(g As Graphics, theDigitA As String)
With g
Using p As New Pen(Color.LimeGreen, 1.6)
p.StartCap = Drawing2D.LineCap.Triangle
p.EndCap = Drawing2D.LineCap.Triangle
If theDigitA = "." Then
'decimal point
.TranslateTransform(-9, 0)
.DrawLine(p, New PointF(8, 11), New PointF(8, 11.1))
Else
'verts left top
If "045689".Contains(theDigitA) Then .DrawLine(p, New PointF(1, 2), New PointF(1, 5))
'vert left bottom
If "0268 ".Contains(theDigitA) Then .DrawLine(p, New PointF(1, 7), New PointF(1, 10))
'verts right top
If "01234789".Contains(theDigitA) Then .DrawLine(p, New PointF(6, 2), New PointF(6, 5))
'verts right bottom
If "013456789".Contains(theDigitA) Then .DrawLine(p, New PointF(6, 7), New PointF(6, 10))
'horz top
If "02356789".Contains(theDigitA) Then .DrawLine(p, New PointF(2, 1), New PointF(5, 1))
'horz mid
If "2345689".Contains(theDigitA) Then .DrawLine(p, New PointF(2, 6), New PointF(5, 6))
'horz botttom
If "023568".Contains(theDigitA) Then .DrawLine(p, New PointF(2, 11), New PointF(5, 11))
End If
End Using
End With
End Sub
Private Sub Form3_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Invalidate()
End Sub
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DoubleBuffered = True
BackColor = Color.Black
End Sub
End Class
Last edited by tommytwotrain; Aug 10th, 2019 at 12:27 PM.
Reason: optimized
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|