Option Strict On
Imports WinUsbWrapper
Imports NKH.MindSqualls
Public Class Form1
'déclaration de la brique, des sensors et des variables qui reçoivent les valeurs des sensors
Dim Brick As NxtBrick = New NxtBrick(NxtCommLinkType.Bluetooth, 4) 'port com4
Dim LL As NxtLightSensor = New NxtLightSensor
Dim Lumiere As Byte
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Brick.Disconnect()
Brick.Connect()
Dim hoho As NxtGetFirmwareVersionReply = CType(Brick.CommLink.GetFirmwareVersion, NxtGetFirmwareVersionReply)
Label12.Text = "Nom : " & Brick.Name & " " & "Version Firmware = " & hoho.firmwareVersion.ToString
Brick.CommLink.SetInputMode(NxtSensorPort.Port3, NxtSensorType.COLORNONE, NxtSensorMode.PCTFULLSCALEMODE)
Brick.Sensor3 = LL
Brick.Sensor3.PollInterval = 400
AddHandler LL.OnPolled, AddressOf Light_OnPolled
End Sub
Private Sub Light_OnPolled(ByVal polledItem4 As NxtPollable)
Lumiere = CByte(LL.Intensity)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label8.Text = CStr(Lumiere)
JaugeLight.CreateGraphics.Clear(Color.White)
JaugeLight.CreateGraphics.FillRectangle(Brushes.SlateBlue, 0, 0, CInt(Lumiere) * 2, 30)
Chart1.Series(0).Points.RemoveAt(0)
Chart1.Series(0).Points.Add(Lumiere)
End Sub
Private Sub TimerBattery_Tick(sender As System.Object, e As System.EventArgs) Handles TimerBattery.Tick
Dim nb As Integer = Brick.BatteryLevel
Label4.Text = Decimal.Round(CDec(nb / 1000), 1) & " v"
JaugeBattery.CreateGraphics.Clear(Color.Azure)
JaugeBattery.CreateGraphics.FillRectangle(Brushes.Magenta, 0, 0, CInt(nb / 100) * 3, 30)
End Sub
End Class