From Xojo Documentation
Xojo Dojo is a free and easy way to get started with programming on the Raspberry Pi. With Xojo Dojo you can use the Xojo programming language, along with a few other special commands to make simple Pi programs that can use text, graphics and GPIO.
Visit the open-source Xojo Dojo project on GitLab.
Download Xojo Dojo to your Raspberry Pi and unzip it. Go to the XojoDojo folder and double-click the XojoDojo executable to start it.
If the file is not marked as an executable file, you may have to manually do this by right-clicking on it, and selecting "Properties". Switch to the Permissions tab and in the Access Control section make sure Executable is set to "Anyone". Click OK.
When Xojo Dojo starts it displays an empty window that is the code editor.
You can type some code to get started. For example, this simple code displays text:
Type that code and click Run in the toolbar. Xojo Dojo will switch to the Text tab and you'll see the output "Hello, World!". Xojo Dojo includes several sample projects to show you some of its commands and capabilities. To look at an example project, click Open in the File menu and go to the Scripts folder in the XojoDojo folder. These are the included examples:
- Bounce: A graphics demo that draws a ball that leaves a multi-colored trail as it bounces around the screen. Press the Stop button on the toolbar to stop the demo.
- Boxes: A graphics demo that draws 1000 multi-colored boxes of varying sizes on the screen.
- BubbleSort: An implemention of the Bubble Sort sorting algorithm.
- DiceRoll: Simulates the rolling of two dice a certain number of times and then tells you how often each dice total amount occurred.
- DragonSweep: A graphics demo that draws a fractal "dragon". Based on an IBM PCjr BASIC program from Compute! magazine in March 1986.
- GPIOAlarm: With a piezo speaker wired to your Pi using the GPIO, this program makes it sound like an alarm. View the wiring diagram.
- GPIOButtonLED: With a a button and LED wired to your Pi using the GPIO, this program lights the LED when the button is pressed. View the wiring diagram.
- GPIOLEDBlink: With an LED wired to your Pi using GPIO, this program makes the LED blink. View the wiring diagram.
- GPIOTune: With a piezo speaker wired to your Pi using the GPIO, this program plays a short tune. View the wiring diagram.
- GuessTheNumber: Try to guess a number picked by the program.
- HelloWorld: Simple display of text.
- LongLoop: A long-running loop that outputs text.
- MazePattern: Displays a text output that looks like a maze (but is not a maze). Based on a Commodore 64 BASIC program from 10 PRINT.
- Olympic: Draws the Olympic rings.
- ShowPicture: Prompts you to choose a picture on your drive and displays it.
- Sieve: Calculates the Sieve of Eratosthenes, popular benchmarking program in the 1980s.
- SineWave: Displays a text-based sine wave.
Xojo Dojo Commands
Xojo Dojo uses XojoScript and can thus use all the language commands that are part of Xojo. Xojo Dojo cannot use any of the Xojo frameworks.
Xojo Dojo has its own small set of custom commands it can use, which are described below.
Clears the Graphics output screen.
Clears the Text output screen.
DrawLine(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer)
Draws a line from position x1, y1 to position x2, y2.
DrawOval(x As Integer, y As Integer, w As Integer, h As Integer)
Draws an oval at position x, y and using with w and height h. To draw a circle, make w and h the same.
DrawPicture(x As Integer, y As Integer, picturePath As String)
Draw the picture at the specified path at position x, y.
DrawRect(x As Integer, y As Integer, w As Integer, h As Integer)
Draws a rectangle at position x, y using width w and height h.
DrawString(s As String, x As Integer, y As Integer, w As Integer = 0, condense As Boolean = False)
Draws a string s on the graphics screen at position x, y. Optionally specify a width and whether the string is condensed if it cannot fit.
EndOfLine As String
The end of line character to use with strings.
EndTimer As Double
Stops a timer started with StartTimer, returning the milliseconds of the elapsed time.
FillOval(x As Integer, y As Integer, w As Integer, h As Integer)
Draws a filled oval at position x, y and using with w and height h. To draw a circle, make w and h the same. Change the fill color using the ForeColor command.
FillRect(x As Integer, y As Integer, w As Integer, h As Integer)
Draws a filled rectangle rectangle at position x, y using width w and height h. Change the fill color using the ForeColor command.
ForeColor(Assigns c As Color)
Sets the color to use for drawing and fill commands.
GPIODigitalRead(pin As Integer) as Integer
Read a value from a GPIO pin.
GPIODigitalWrite(pin As Integer, mode As Integer)
Write a value to a GPIO pin.
GPIOPinMode(pin As Integer, mode As Integer)
Set a GPIO pin as either input or output.
Initialize GPIO. WiringPi library must be installed on the Pi.
GPIOSoftToneCreate(pin As Integer) as Integer
Sets up tones for a pin.
GPIOSoftToneWrite(pin As Integer, freq As Integer)
Sends a tone to a pin.
Used with GPIO DigitalRead and DigitalWrite commands to indicate a pin is for input.
Used with GPIO DigitalRead and DigitalWrite commands to indicate a pin is off.
Used with GPIO DigitalRead and DigitalWrite commands to indicate a pin is on.
Used with GPIO DigitalRead and DigitalWrite commands to indicate a pin is for output.
RandomInt(startValue As Integer, endValue As Integer) as Integer
Generates a random integer between startValue and endValue (inclusive).
Switches to the graphics output screen.
Starts a timer.
UserCancelled As Boolean
Returns True when the user has clicked the Stop button on the toolbar. Use it to end your programs that run in a long loop.
Wait(ms As Double = 10)
Pauses your program execution. The default is 10 milliseconds, but you can specify your own value.
Learn More About Xojo and Raspberry Pi
If you want to make full-featured apps for the Raspberry Pi you can try the full version of Xojo. You can also check out our free book: Programming the Raspberry Pi with Xojo and the.