Introduction to native development

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.

35 thoughts on “Introduction to native development

  1. SciTE is available for Linux, so could the Lua scripts be modified for Linux? Autokey (a python program on Linux) could be used instead of Autoit for sending files to nspire_emu, and nspire_emu works well in Wine.

  2. So, novice question here… I noticed that you refer to the programming language as c everywhere, but you still use the gcc compiler. Is the programming environment only for c, or is c++ supported as well?

  3. excuse me, but i cannot understand the step about using polydump to obtain TI-Nspire CX boot1 and boot2 images in the emu_resources/read_me.txt. can you please explain to me how do i do so? many thanks!

      1. it was mainly the part “using polydump to obtain TI-Nspire CX boot1 and boot2 images”. it should say “install ndless on your TI nspire CX and run polydump on it” instead of the generic word “use”. I would also find it to be a good idea if someone(maybe you?) would mkae the boot1 and boot2 images directly available for download, thus making your SDK easier to use and allowing those without an nspire yet want to develop using your SDK+ the emulator to be able to do so. Besides this, a great program and SDK, though. Keep on your good work! Much thanks for your program :)

      2. no problem! i very much appreciate awesome work like yours, especially when its constantly updated!

  4. For whatever reason, NdlessEditor won’t do anything when I click on “TI-Nspire Emulator”, even though I have dumped boot1, boot2, and the 3.1 .tco file inside emu_resources, regardless of whether I am running it as an admin or not. Should I name the .tco file something specific? Win7 Ultimate under VMWare Fusion.

    1. You should have in emu_resources:
      – boot1.img.tns
      – boot2.img.tns
      – [any_name].tco
      No error message appears at the bottom of the editor?
      Does at least a DOS console pops up and closes?
      To make sure the editors’s Lua extensions work well, can you check that “Tools > Ndless SDK console” opens the SDK console?
      Also did you make sure that the editor is installed in a directory without space or any special character in its path?

  5. Is there no way to use the nspire_emu included with the SDK if I don’t have a CX? I only have a normal Nspire.

      1. Please use the new r869 of the SDK with Touchpad and Clickpad support for the emulator and tell me if everything is OK for you.

  6. hi, I’ve followed the setup as described. But everytime i start the editor it says “Can’t load spawner-ex”. The dll is in place ( \ndless-​v3.​1-​beta-​r914-​sdk\spawner-ex\ ). Do know how to fix this problem ? I’m using win7.
    Thanks

    1. Silversircel, apparently the root folder name was corrupted in r914, I suspect this could be the cause. I’ve fixed it, can you please re-download it and test if it is now ok for you?

      1. hi, i`ve tested the new sdk. But it shows the same: “Can’t load spawner-ex”. couldn’t that be a problem based on the win7 64 bit architecture?

  7. Hey I’m a middle schooler and obviously I wanna pimp my calc :P. Is there any way to change the color of the homepage? or have a opening message when you turn it on? If any of you know how to write please do if you can.

    Thanks so much!

  8. The link to the nspireio documentation is broken, when I click the link it shows this error.

    Error

    TracError: The Trac Environment needs to be upgraded.

    Run “trac-admin /data/nspforge/trac/nspireio upgrade”

  9. I got the same problem like “Stolen_Goods”, it wont do anything if I open the TI-Nspire emulator. The SDK console works, but if I click on the emulator, nothing happens (not even a DOS-console). I also tried to fix it by moving the folder to C://, but the problem still occurs.

      1. Wow, I didnt really expect that someone would reply and fix it, but that is just what you did! it works now, thank you so much

  10. I had issues when using the polydump. It gave me boot1.tns but no other files. After running the polydump once it will not longer work without reinstalling the OS. I upgraded to 3.9 and then downgraded to 3.6 and tried again with the same result. I am trying to get this set up to use npdf on my TI-nspire cx cas s-04140. At this point with little coding experience I am stumped. I am a Civil Engineer and I just like playing with my toys and thought this would be a useful addition for me. Any suggestion?

Leave a comment