The Software Development Kit (SDK) is a set of tools to write your own Ndless-compatible programs.

Prerequisites

You must have basic knowledge of the C language.

The Ndless SDK

Get the Ndless Software Development Kit. Choose the highest version.
Get the MSYS and YAGARTO components. Choose the highest version.

On Windows

  • Unzip the SDK archive. Make sure that no parent directory contains a space in its name.
  • If you were previously using the command-line based SDK and had to change your PATH environment variable, remove the /bin directories of the previous SDK and of your YAGARTO installation from the PATH, as the latest SDK uses its own.
  • Copy the mingw-get/ and yagarto/ folders from the MSYS-YAGARTO package into the SDK folder.
  • Set up the TI-Nspire emulator integrated to the SDK. Follow the instructions in emu_resources/_ReadMe.txt.
  • You may also want to set up Windows to associate .c and .h files to the NdlessEditor.exe.

You’re ready. Everything is provided by the SDK from the compiler to the editor, no additional setup is required.

On Linux

The SDK provides the compiler scripts, headers and libraries, but you must set up yourself the GCC toolchain and use your  emulator and editor. Follow this tutorial.

The Ndless Editor

The Ndless Editor is a SciTE-based text editor with special configuration and extensions to ease native development in C.

Open NdlessEditor.exe in the SDK root directory.

Ndless-related commands are available from the Tools menu. The message pane will appear at the bottom of the screen when running commands, and will display the output of these commands.

Your first native program

We’ll start with a classic ‘Hello, world!’ displayed with the nspireio library provided with the SDK. We’ll go through the various steps of creating the project, writing the code, building and testing the program with the emulator.

Use Tools > New Ndless project to generate a C source file template:

Save it to a new directory for your project. We’ll save it as hello.c in a new directory  helloworld/.

Coding

Here is our new program body:

Let’s extend it to say Hello to the World with the nspireio2 library.

  • First we include nspireio2’s definitions:
#include <os.h>
#include <nspireio2.h>
  • We define an nspireio console, switch to grayscale mode (nspireio can’t display color text at the moment) and clear the screen:
	nio_console csl;
	lcd_ingray();
	clrscr();
  • We set up the nspireio console:
	// 53 columns, 29 rows. 0px offset for x/y.
	// Background color 0 (black), foreground color 15 (white)
	nio_InitConsole(&csl, 53, 29, 0, 0, 0, 15);
	nio_DrawConsole(&csl);
  • Then say hello, and wait for a key to be pressed:
	nio_printf(&csl, "hello world!");
	wait_key_pressed();
  • Finally the nspireio console is freed and the program exited:
	nio_CleanUp(&csl);
	return 0;

Here’s the whole program:

#include <os.h>
#include <nspireio2.h>

int main(void) {
	nio_console csl;
	lcd_ingray();
	clrscr();
	// 53 columns, 29 rows. 0px offset for x/y.
	// Background color 0 (black), foreground color 15 (white)
	nio_InitConsole(&csl, 53, 29, 0, 0, 0, 15);
	nio_DrawConsole(&csl);
	nio_printf(&csl, "hello world!");
	wait_key_pressed();
	nio_CleanUp(&csl);
	return 0;
}

For more information on the instructions used here, read nspireio’s documentation and libndls’s documentation (libndls is the TI-Nspire specific library provided with the Ndless SDK).

Buiding

Use the Tools > Build command (or press the F7 key) to build the program. A name for the program must be given the first time it is built. Type ‘helloworld’ in the at the bottom of the editor, and press enter. This will be the name of the generated .tns.

A Makefile is created in the program’s directory. If you want to change the name of the program later, you’ll be able to edit the Makefile and change the EXE variable.

The build commands result are displayed in the message pane. If you get an error, double check the source code of the program.

Emulating

Testing the first versions of your program with the emulator may be faster than transferring them after each build to a real TI-Nspire. Let’s run the TI-Nspire emulator with the Tools > TI-Nspire emulator command. Wait for a few seconds until the OS is fully loaded.

If you have any issue here, make sure you have followed every step described in emu_resources/_ReadMe.txt of the Ndless SDK.

We can now send the helloworld.tns file we have just built. In the Ndless Editor where hello.c is open, use the command Tools > Transfer the program. The program will be automatically sent to the ‘ndless’ directory of the TI-Nspire OS.

Finally let make it say hello to the world: open the ‘ndless’ directory in the emulator and open helloworld.tns. If a popup is displayed telling you that ‘This document format is not supported’, Ndless was not installed correctly. Follow again the instructions in emu_resources/_ReadMe.txt.

helloworld.tns is stored in the ‘hello/’ directory of the computer we have created at the beginning of the tutorial. What about trying it on your own TI-Nspire?

Going further

You can explore the program samples in the ‘_samples/’ directory of the SDK.

Also make sure to have a look at the libdndls’s documentation for TI-Nspire specific functions, and the syscalls page for the supported standard functions. You will then be interested by advanced usage of the Ndless SDK.

To try to port SDL-based programs and games, use hoffa’s nSDL library. The library itself is already provided with the Ndless SDK, you just have to include <SDL/SDL.h> at the beginning of the program. See _samples/helloworld-sdl/ in the Ndless SDK directory for a sample program.

Advanced editing

The Ndless Editor’s Tools menu provides the following additional commands:

  • Compile: compile the currently open .c file, but not the whole program. This command can be used to quickly check the file for syntax errors.
  • Clean Build: rebuild the whole program. Building with the Build command is incremental. A Clean Build can sometimes solve building issues.
  • Clean: clean any file generated by the build.
  • Ndless SDK console: open a MSYS (Unix-like) console in the current program directory. This can be useful if you have customized the program’s Makefile and want to run specific Make targets.

Since the Ndless Editor is SciTE-based, you may want to fiddle with SciTE’s configuration options to customize it for a better TI-Nspire development experience. Overriding the default Ndless SDK configuration with the file SciTEUser.properties is the recommended way to go.