Learn How to Write Applications for the NanoComputer in One Really Long Day - Chapter 5

From NanoComputerWiki

Revision as of 01:37, 3 November 2008 by FlyingElectron (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Chapter 5 -- Writing Your First Application (Part 2)

Introduction

In this chapter, we will finish our first NanoComputer application which was started in the previous Chapter 4 by adding code to make the application print "Hello World!" on the LCD screen of the NanoComputer.


Open the Source Code File for Editing

  • Start the Windows XP Command Prompt if it is not already open.
If you have trouble starting the Windows XP Command Prompt, please refer back to "Chapter 3 - Starting the Windows XP Command Prompt".
  • Change the current directory inside the Windows XP Command Prompt to C:\MyHelloWorld
If you have trouble changing the current directory inside the Windows XP Command Prompt, please refer back to the section titled "Change the Current Directory to C:\MyHelloWorld" in Chapter 4.
  • Open the MyHelloWorld.c source code file using the notepad text editor.
If you have trouble opening the MyHelloWorld.c source code file using the notepad text editor, please refer back to the section titled "Viewing the Source Code File" in Chapter 4.


Edit the Source Code File to Print "Hello World!"

  • At this point, the source code show be displayed inside the Notepad application and should look similar to the screenshot below.
Image:MyHelloWorld Notepad SourceCode2.png


  • Add the following code below the existing LCD_ClearDisplay(BLUE); line in the source code file
// Set the Drawing Color to be WHITE
    LCD_SetColor(WHITE);
// Print Hello World at coordinates 10, 10 on the LCD screen
    LCD_Printf(10, 10, "Hello World!");
After adding the code, the contents of the Notepad application should look like the screenshot below.
Image:MyHelloWorld Notepad SourceCode3.png


  • Open the file dropdown menu of the Notepad application by clicking on the File menu item of the Notepad application.
Image:MyHelloWorld Notepad FileMenu.png


  • Save the file by clicking on the Save submenu option in the Notepad application
Image:MyHelloWorld Notepad FileMenuSave.png


  • After you have saved the source code file, close the Notepad application by clicking on the big red X in the upper right hand corner of the Notepad application.
Image:MyHelloWorld Notepad Close2.png


Test Your New Application

  • Compile the MyHelloWorld application using the "make" command
If you have trouble compiling the MyHelloWorld application, please refer back to the section titled "Compiling the MyHelloWorld Application" in Chapter 4.
  • Install the MyHelloWorld application using the "NC_CMD --install output\MyHelloWorld" command
If you have trouble installing the MyHelloWorld application, please refer back to the section titled "Installing the MyHelloWorld Application" in Chapter 4.
  • Run the MyHelloWorld application using the "NC_CMD --run MyHelloWorld" command
If you have trouble installing the MyHelloWorld application, please refer back to the section titled "Running the MyHelloWorld Application" in Chapter 4.
After running the MyHelloWorld application, the LCD screen of the NanoComputer should have a blue background color with "Hello World!" printed in white on the LCD screen.
Image:MyHelloWorld NanoComputer 3.png


Conclusion

  • Congratulations, you have now learned how to create your first NanoComputer application! You can make this application do more my adding more code and using more function calls from the BIOS. See the BIOS reference for more information on what functions are available.
  • If you need more help with the C language, we recommend you pick up a learning C book at your local book store or look for C tutorials on the internet.


Navigation

Click on any of the links below to navigate to a new page