NanoComputer Sample Applications
From NanoComputerWiki
This page contains some sample applications for the Flying Electron NanoComputer
Contents |
Hello World Sample
NanoComputer Application: HelloWorld.ihx
Prints "Hello World" in White on a Blue Background
Source Code:
// --------------------------------------------------
// Includes
// --------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include "NanoComputer.h"
// --------------------------------------------------
// Main
// --------------------------------------------------
void main() {
// Print Hello World! in WHITE on a BLUE background
LCD_ClearDisplay(BLUE);
LCD_SetColor(WHITE);
LCD_Printf(10, 10, "Hello World!");
}
Lines Sample
NanoComputer Application: Lines.ihx
Draw a bunch of colored lines on the screen
Source Code:
// --------------------------------------------------
// Includes
// --------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include "NanoComputer.h"
// --------------------------------------------------
// Main
// --------------------------------------------------
void main() {
// Set the LCD to be horizontal
BIOS_SetPropVal(LCD_PROP_MODE, LCD_MODE_ROTATE_90_DEGREES);
// Clear the Display
LCD_ClearDisplay(BLACK);
// Print the Caption
LCD_SetColor(GREEN);
LCD_Printf(10, 5, "Lines Sample");
// Draw the Test Lines
// X Long, X+, Y+
LCD_SetColor(WHITE);
LCD_Line(75, 75, 125, 100);
// X Long, X+, Y-
LCD_SetColor(RED);
LCD_Line(75, 75, 125, 50);
// X Long, X-, Y+
LCD_SetColor(BLUE);
LCD_Line(75, 75, 25, 100);
// X Long, X-, Y-
LCD_SetColor(GREEN);
LCD_Line(75, 75, 25, 50);
// Y Long, X+, Y+
LCD_SetColor(WHITE);
LCD_Line(175, 75, 200, 125);
// Y Long, X+, Y-
LCD_SetColor(RED);
LCD_Line(175, 75, 200, 25);
// Y Long, X-, Y+
LCD_SetColor(BLUE);
LCD_Line(175, 75, 150, 125);
// Y Long, X-, Y-
LCD_SetColor(GREEN);
LCD_Line(175, 75, 150, 25);
}
Show Picture Sample
NanoComputer Application: ShowPicture.ihx
Note: First download Pirate.pic and save to your C:\ drive, then upload the file to the NanoComputer using the following command:
NC_CMD --upload Pirate.pic
Note: The source code below uses arguments passed into the NanoComputer Application. To have the ShowPicture application show the Pirate.pic picture the application should be invoked as follow:
NC_CMD --run ShowPicture Pirate.pic
Source Code:
// --------------------------------------------------
// Includes
// --------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "NanoComputer.h"
#include "PICTURE.h"
// --------------------------------------------------
// Main
// --------------------------------------------------
void main() {
// Variables
COLOR colorBuf[0x800];
char filename[NCFS_FILENAME_BUFFERSIZE];
PICTURE_Info pictureInfo;
char retVal;
// Init
BIOS_SetPropVal(LCD_PROP_MODE, LCD_MODE_ROTATE_0_DEGREES);
LCD_ClearDisplay(BLACK);
LCD_SetColor(GREEN);
// Copy the args to the filename
strcpy(filename, APP_ARGS);
// Get the Picture Info
retVal = PICTURE_GetInfo(filename, &pictureInfo);
if (retVal == E_NCFS_FILE_NOT_FOUND) {
LCD_Printf(10, 10, "\"%s\" not found!", filename);
return;
}
if (retVal != E_OK) {
LCD_Printf(10, 10, "Error %X", retVal);
return;
}
// Draw the Picture
PICTURE_DrawEx(&pictureInfo, 0, 0, colorBuf, 0x800 );
}
Navigation
- Click on any of the links below to navigate to a new page



