Added clock code and X64 binaries.
Signed-off-by: Natalia Portillo <claunia@claunia.com>
This commit is contained in:
104
Aclock.c
104
Aclock.c
@@ -11,6 +11,62 @@
|
|||||||
#include <Library/UefiApplicationEntryPoint.h>
|
#include <Library/UefiApplicationEntryPoint.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef M_PI
|
||||||
|
#define M_PI 3.14159265358979323846
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FontWH_Ratio 2
|
||||||
|
|
||||||
|
// Global variables
|
||||||
|
SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
|
||||||
|
EFI_SYSTEM_TABLE *eST;
|
||||||
|
|
||||||
|
void draw_circle(int hand_max, int sYcen, int sXcen){
|
||||||
|
int x,y,r;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
for(r=0;r<60;r++){
|
||||||
|
x=cos(r*M_PI/180*6)*hand_max*FontWH_Ratio+sXcen;
|
||||||
|
y=sin(r*M_PI/180*6)*hand_max+sYcen;
|
||||||
|
switch (r) {
|
||||||
|
case 0:
|
||||||
|
case 5:
|
||||||
|
case 10:
|
||||||
|
case 15:
|
||||||
|
case 20:
|
||||||
|
case 25:
|
||||||
|
case 30:
|
||||||
|
case 35:
|
||||||
|
case 40:
|
||||||
|
case 45:
|
||||||
|
case 50:
|
||||||
|
case 55:
|
||||||
|
c='o';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c='.';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ConOut->SetCursorPosition(ConOut, x, y);
|
||||||
|
Print(L"%c", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_hand(int minute, int hlenght, char c, int sXcen, int sYcen){
|
||||||
|
int x,y,n;
|
||||||
|
float r=(minute-15)*(M_PI/180)*6;
|
||||||
|
|
||||||
|
for(n=1; n<hlenght; n++){
|
||||||
|
x=cos(r)*n*FontWH_Ratio+sXcen;
|
||||||
|
y=sin(r)*n+sYcen;
|
||||||
|
ConOut->SetCursorPosition(ConOut, x, y);
|
||||||
|
Print(L"%c", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
as the real entry point for the application.
|
as the real entry point for the application.
|
||||||
|
|
||||||
@@ -28,7 +84,51 @@ UefiMain (
|
|||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Print(L"Hello World \n");
|
ConOut = SystemTable->ConOut;
|
||||||
return EFI_SUCCESS;
|
eST = SystemTable;
|
||||||
|
EFI_TIME ltime;
|
||||||
|
|
||||||
|
/*char INFO[]="Copyright (c) 1994-2016 Antoni Sawicki <as@tenoware.com>\n"
|
||||||
|
"Copyright (c) 2016 Natalia Portillo <claunia@claunia.com>\n"
|
||||||
|
"Version 1.0 (efi); Canary Islands, May 2016\n";*/
|
||||||
|
int sXmax, sYmax, smax, hand_max, sXcen, sYcen;
|
||||||
|
|
||||||
|
sXmax=sYmax=hand_max=sXcen=sYcen=0;
|
||||||
|
ConOut->ClearScreen(ConOut);
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
eST->RuntimeServices->GetTime(<ime, NULL);
|
||||||
|
|
||||||
|
UINTN Columns, Rows;
|
||||||
|
ConOut->QueryMode(ConOut, ConOut->Mode->Mode, &Columns, &Rows);
|
||||||
|
sYmax = (int)Rows;
|
||||||
|
sXmax = (int)Columns;
|
||||||
|
|
||||||
|
if(sXmax/FontWH_Ratio<=sYmax)
|
||||||
|
smax=sXmax/FontWH_Ratio;
|
||||||
|
else
|
||||||
|
smax=sYmax;
|
||||||
|
|
||||||
|
hand_max = (smax/2)-1;
|
||||||
|
|
||||||
|
sXcen = sXmax/2;
|
||||||
|
sYcen = sYmax/2;
|
||||||
|
|
||||||
|
ConOut->ClearScreen(ConOut);
|
||||||
|
draw_circle(hand_max, sYcen, sXcen);
|
||||||
|
|
||||||
|
draw_hand((ltime.Hour*5)+(ltime.Minute/10), 2*hand_max/3, 'h', sXcen, sYcen);
|
||||||
|
draw_hand(ltime.Minute, hand_max-2, 'm', sXcen, sYcen);
|
||||||
|
draw_hand(ltime.Second, hand_max-1, '.', sXcen, sYcen);
|
||||||
|
|
||||||
|
ConOut->SetCursorPosition(ConOut, sXcen-5, sYcen-(3*hand_max/5));
|
||||||
|
Print(L".:ACLOCK:.");
|
||||||
|
ConOut->SetCursorPosition(ConOut, sXcen-5, sYcen+(3*hand_max/5));
|
||||||
|
Print(L"[%02d:%02d:%02d]", ltime.Hour, ltime.Minute, ltime.Second);
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
Aclock.inf
10
Aclock.inf
@@ -26,11 +26,15 @@
|
|||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
[LibraryClasses]
|
[LibraryClasses]
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
UefiBootServicesTableLib
|
||||||
UefiApplicationEntryPoint
|
UefiApplicationEntryPoint
|
||||||
UefiLib
|
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
|
|||||||
BIN
binaries/aclock-efi-x64.efi
Normal file
BIN
binaries/aclock-efi-x64.efi
Normal file
Binary file not shown.
BIN
binaries/aclock-efi-x64.iso
Normal file
BIN
binaries/aclock-efi-x64.iso
Normal file
Binary file not shown.
Reference in New Issue
Block a user