1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4J Tutorial Switch to shutdown RPI

Discussion in 'B4J Tutorials' started by inakigarm, Jun 1, 2017.

  1. inakigarm

    inakigarm Well-Known Member Licensed User

    The RPi hasn't a switch to shutdown the RPI; if you cut off power from the RPi, SD card could be corrupted easely.

    An easy solution is to add a switch to shutdown the RPI connected to a GPIO pin and listening this pin to call shutdown command via B4J.

    Look full article at http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi


    'Non-UI application (console / server application)
    Sub Process_Globals
    Private controller AsGpioController
    Private Pin1 As GpioPinDigitalInput
    End Sub

    Sub AppStart (Args() As String)
    End Sub

    'Shutdown at Pin1 Change
    Sub Pin1_StateChange(State As Boolean)
    Log("Pin1 StateChange event: " & State)
    If Pin1.State=True Then
    Dim shl As Shell
    End If
    End Sub

    jmon and Erel like this.
  2. Cableguy

    Cableguy Expert Licensed User

  3. jmon

    jmon Well-Known Member Licensed User

    Do you know if it would be possible to "suspend" the RPI, then wake it up when pressing again? I couldn't find anything like that anywhere
  4. Cableguy

    Cableguy Expert Licensed User

    No, it either does a shutdown sequence or a reset sequence, according to the python script, but I guess, being it a script, the reset function can perhaps be Modified to accommodate a different function
    jmon likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice