Raspberry Pi Tips

From Xojo Documentation

Desktop Apps

Playing Sound

The Raspberry Pi can at least play WAV and mp3 sound files. By default sound output is sent out the HDMI port. There is also a headphone port that can be used for sound output. To switch between the sound outputs, you can use this command:

sudo amixer cset numid=3 <n>

where n is 0=auto, 1=headphones, 2=HDMI. In your code you can run this command from a Shell. This code switches to the headphone port:

#If TargetARM Then
' Switch to headphone port
Var sh As New Shell
sh.Execute("amixer cset numid=3 1")

Web Apps

The standard Raspberry Pi web browser identifies itself as Epiphany. In Xojo web apps you can check for this using the WebSession.Browser property and WebSession.BrowserType enumeration:

If Session.Browser = WebSession.BrowserType.Epiphany Then
// This is the Raspberry Pi browser
End If

Newer versions of Raspbian also have Chromium which identifies as WebSession.BrowserType.Chrome.

General Tips

If you have the default installation of Raspbian (with the desktop), you'll be able to connect your Pi to any display (including a TV) using HDMI. Plug in a USB keyboard and mouse and you can use it as a real computer.

Updating Raspbian OS

To update Raspbian, you can run these two commands from Terminal:

sudo apt-get update
sudo apt-get dist-upgrade

Transferring Files to Raspberry Pi

By default, there is an SFTP server installed on the Pi but you'll have to enable it using the Pi Configuration screen to enable SSH. Once enabled, you can connect to it using any SFTP client. You'll need to know the IP address of the Raspberry Pi on your network and the username and password that you created when you initially installed Raspbian (by default, it's 'pi' and 'raspberry' respectively).

Connecting to Raspberry Pi via Shell

You can also use ssh without any Pi configuration. Start ssh with a command such as this:

ssh pi@

and then enter your password ('raspberry' by default). You'll now be connected to the Pi in a terminal window. Here you can easily run Xojo console apps that you've transferred using SFTP.

Note: Windows doesn't have ssh already available. You'll want to install PuTTY or on newer versions of Windows 10 enable its SSH Client.

Connecting to Raspberry Pi via VNC

Raspberry Pi Configuration Window

VNC (aka Remote Desktop) allows you to view the desktop of the Pi and interact with it using your mouse. This is useful for testing Xojo desktop apps, but it can also be helpful to more easily access configuration screens or use the Pi in some other fashion.

The Pi has a VNC server built-in but you may need to enable it. Go to the Pi Configuration (Pi menu->Preferences->Raspberry Pi Configuration) where you should see a radio button to enable VNC.

You can connect to the Pi using any VNC client. Here are some suggestions:

  • RealVNC
  • Mac Screen Sharing
    • Finder, Go ↠ Connect to Server, vnc:// (substitute your own IP address and port)
  • Tight VNC