Administrator
|
Thomas Baumann create a VB library for Digole serial module, here is the how toPosted at:2015-06-19 19:15:49 Edited at:2015-06-19 19:16:53
|
Thanks for the code contribution from Thomas Baumann
Usage example:
Dim display As Digole display = New Digole("COM12") display.SetBaudrate(115200) display.ClearScreen()
display.SetFont(10) display.SetTrueColor(Drawing.Color.Gray) display.SetTextPosAbs(4, 95) display.Print("Out: 50,001 Hz, 50 %") display.SetTextPosAbs(4, 105) display.Print("Tolerance: 0.01 %")
display.Dispose() Also I created routines which converts image files into the 256/64k/262k raw format the display needs.
Friend Sub ConvertImageTo256RAW(ByVal InImage As String, ByVal OutImage As String)
Const Mask As Byte = &HE0
' RRRGGGBB
Using inBmp As New Drawing.Bitmap(InImage) Using outBmp As New IO.FileStream(OutImage, IO.FileMode.Create, IO.FileAccess.Write)
For y As Integer = 0 To inBmp.Height - 1 For x As Integer = 0 To inBmp.Width - 1
Dim c As Drawing.Color = inBmp.GetPixel(x, y)
outBmp.WriteByte( _ (c.R And Mask) Or _ ((c.G And Mask) >> 3) Or _ (c.B >> 6) _ )
Next Next
outBmp.Close()
End Using End Using
End Sub Friend Sub ConvertImageTo64kRAW(ByVal InImage As String, ByVal OutImage As String)
Const MaskRB As Byte = &HF8 Const MaskGh As Byte = &HE0 Const MaskGl As Byte = &H1C
' RRRRRGGG GGGBBBBB
Using inBmp As New Drawing.Bitmap(InImage) Using outBmp As New IO.FileStream(OutImage, IO.FileMode.Create, IO.FileAccess.Write)
For y As Integer = 0 To inBmp.Height - 1 For x As Integer = 0 To inBmp.Width - 1
Dim c As Drawing.Color = inBmp.GetPixel(x, y)
outBmp.WriteByte( _ (c.R And MaskRB) Or _ ((c.G And MaskGh) >> 5) _ ) outBmp.WriteByte( _ ((c.G And MaskGl) << 5) Or _ ((c.B And MaskRB) >> 3) _ )
Next Next
outBmp.Close()
End Using End Using
End Sub Friend Sub ConvertImageTo262kRAW(ByVal InImage As String, ByVal OutImage As String)
' 00RRRRRR 00GGGGGG 00BBBBBB
Using inBmp As New Drawing.Bitmap(InImage) Using outBmp As New IO.FileStream(OutImage, IO.FileMode.Create, IO.FileAccess.Write)
For y As Integer = 0 To inBmp.Height - 1 For x As Integer = 0 To inBmp.Width - 1
Dim c As Drawing.Color = inBmp.GetPixel(x, y)
outBmp.WriteByte(c.R >> 2) outBmp.WriteByte(c.G >> 2) outBmp.WriteByte(c.B >> 2)
Next Next
outBmp.Close()
End Using End Using
End Sub
|