'-------------------------------------------------------------------------------
Option Explicit

'-------------------------------------------------------------------------------
Public Sub Main()

' This program continually blinks the red and green LEDs on a BX-24 system.
' The date and time are also output to the serial port.

    Do
        Call BlinkLEDs
        Call DisplayDateTime
        Call Delay(0.3)
    Loop

End Sub
'-------------------------------------------------------------------------------
Private Sub BlinkLEDs()

    Const GreenLED As Byte = 26
    Const RedLED As Byte = 25

    Const LEDon As Byte = 0
    Const LEDoff As Byte = 1

    ' Red pulse.
    Call PutPin(RedLED, LEDon)
    Call Delay(0.07)
    Call PutPin(RedLED, LEDoff)

    Call Delay(0.07)

    ' Green pulse.
    Call PutPin(GreenLED, LEDon)
    Call Delay(0.07)
    Call PutPin(GreenLED, LEDoff)

    Call Delay(0.07)

End Sub
'-------------------------------------------------------------------------------
Private Sub DisplayDateTime()

    Dim Year As Integer
    Dim Month As Byte
    Dim Day As Byte
    Dim Hour As Byte
    Dim Minute As Byte
    Dim Second As Single
    Dim iSecond As Integer

    Call GetTimestamp(Year, Month, Day, Hour, Minute, Second)

    Debug.Print CStr(Year); "/";

    Call PutTwoDigit(Month)
    Debug.Print "/";

    Call PutTwoDigit(Day)
    Debug.Print " ";

    Call PutTwoDigit(Hour)
    Debug.Print ":";

    Call PutTwoDigit(Minute)
    Debug.Print ":";

    Call PutTwoDigit(FixB(Second))

    Debug.Print  ' Append <CR><LF>

End Sub
'-------------------------------------------------------------------------------
Private Sub PutTwoDigit( _
    ByVal Value As Byte)

' Outputs a 2-digit number with a leading 0.

    If (Value < 10) Then
        Debug.Print "0";
    End If

    Debug.Print CStr(Value);

End Sub
'-------------------------------------------------------------------------------
