Skip to content

Commit

Permalink
Episode 1 Getting Started
Browse files Browse the repository at this point in the history
  • Loading branch information
ultibohub committed May 11, 2016
1 parent 5439794 commit 0864ab8
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.
83 changes: 83 additions & 0 deletions 01-GettingStarted/GettingStarted.lpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<Runnable Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="GettingStarted"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<Units Count="1">
<Unit0>
<Filename Value="GettingStarted.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="GettingStarted"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<TargetProcessor Value="armv7a"/>
<TargetController Value="RPI2B"/>
<TargetCPU Value="arm"/>
<TargetOS Value="ultibo"/>
<Optimizations>
<OptimizationLevel Value="2"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
<UseLineInfoUnit Value="False"/>
</Debugging>
<LinkSmart Value="True"/>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>
79 changes: 79 additions & 0 deletions 01-GettingStarted/GettingStarted.lpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
program GettingStarted;

{$mode objfpc}{$H+}

{ Discovering Ultibo }
{ }
{ Episode 1 - Getting Started }
{ }
{ This is the source code for the application used in the video, this version }
{ is for Raspberry Pi 2 and 3 but you can easily make a version suitable for }
{ Raspberry Pi A/B/A+/B+/Zero by creating a new project and adding the code }
{ below. }
{ }
{ To compile the program select Run, Compile (or Run, Build) from the menu }


uses
RaspberryPi2,
GlobalConfig,
GlobalConst,
GlobalTypes,
Platform,
Threads,
SysUtils,
Classes,
Ultibo,

{The units above are the standard ones included when you create a new project
for Raspberry Pi 2B, we add the Console unit below so we have access to the
console functions in our project}
Console
{ Add additional units here };


{When we create a console window the function will return a handle that can be
passed to other functions to tell them which window to draw or write on. We
create a variable to store the handle so it is available when we need it}
var
Handle:THandle;

begin
{We create a new console window by calling ConsoleWindowCreate, it needs to know
which console device to create the window on so we can ask for the default device
by calling ConsoleDeviceGetDefault.
Many device types in Ultibo support calling the GetDefault function and many also
support SetDefault as well.
The parameter CONSOLE_POSITION_FULL makes our window the full screen, you can find
this and other console positions in the GlobalConst unit.
The final parameter says if our window can be the default window, see below for
more information about what this means}
Handle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);


{To write text on our new window we can call ConsoleWindowWriteLn and pass the
handle from above as well as the text we want to write.
Because we made this the default window we could have used a couple of other ways
to write the text on the window like
ConsoleWriteLn('Hello Ultibo !!');
or
WriteLn('Hello Ultibo !!');
Try them out for yourself to see what happens}
ConsoleWindowWriteLn(Handle,'Hello Ultibo !!');


{ Add your program code here }


{Halt the Main thread just so it never exits}
ThreadHalt(0);
end.

0 comments on commit 0864ab8

Please sign in to comment.