Micro-Project Report ON " ": Design Digital Clock
Micro-Project Report ON " ": Design Digital Clock
Micro-Project Report ON " ": Design Digital Clock
Micro-Project Report
ON
“DESIGN DIGITAL
CLOCK”
By
1)Kadam Priti [2014660140]
2) Shaikh Suhana [2014660141]
3) Tarate Gayatri [2114660126]
4) Pacharne Gayatri [2114660128]
Guided By
Prof. Chaure Suraj
1
Shree Samarth Academy’s
Shree Samarth Polytechnic
Department of Computer Engineering.
CERTIFICATE
This is to certify that the project work entitled
“DESIGN DIGITAL
CLOCK’’
Is
Submitted by
1)Kadam Priti [2014660140]
5) Shaikh Suhana [2014660141]
6) Tarate Gayatri [2114660126]
7) Pacharne Gayatri [2114660128]
2
Micro-Project Proposal
“DESIGN DIDITAL
CLOCK”
3
3.0 Action plan:
4
Format for Micro-Project Report
“DESIGN DIDITAL
CLOCK”
Brief Description:
In this era of computing, computer graphics has become one of the most
powerful and interesting fact of computing. It all started with display of data
on hardcopy and CRT screen. Now computer graphics is about creation,
retrieval, manipulation of models and images.Graphics today is used in many
different areas. Graphics provides one of the most natural means of
communicating within a computer, since our highly developed 2D and 3D
pattern-recognition abilities allow us to perceive and process pictorial data
rapidly and effectively. Interactive computer graphics is the most important
means of producing pictures since the invention of photography and
television. It has the added advantage that, with the computer, we can make
pictures not only of concrete real world objects but also of abstract, synthetic
objects, such as mathematical surfaces and of data that have no inherent
geometry, such as survey results.
OpenGL CONCEPT
INTERFACE
OpenGL is an application program interface (API) offering various functions
to implement primitives, models and images. This offers functions to create
and manipulate render lighting, coloring, viewing the models. OpenGL offers
different coordinate system and frames. OpenGL offers translation, rotation
and scaling of objects. Functions in the main GL library have names that
begins with gl and are stored in a library usually referred to as GL. The
second is the OpenGL Utility Library(GLU). The library uses only GL
functions but contains code for creating common objects and simplifying
viewing. All functions in GLU can be created from the core GL library but
application programmers prefer not to write the code repeatedly. The GLU
library is available in all OpenGL implementations; functions in the GLU
library begin with the letter glu. Rather than using a different library for each
system we use a readily available library called OpenGL Utility
5
Toolkit(GLUT),which provides the minimum functionality that should be
expected in any modern windowing system.
OVERVIEW
• OpenGL(Open Graphics Library) is the interface between a graphics
program and graphics hardware. It is streamlined. In other words, it provides
low-level functionality. For example, all objects are built from points, lines
and convex polygons. Higher level objects like cubes are implemented as six
four-sided polygons.
• OpenGL supports features like 3-dimensions, lighting, anti-aliasing,
shadows, textures, depth effects, etc.
• It is system-independent. It does not assume anything about hardware or
operating system and is only concerned with efficiently rendering
mathematically described scenes. As a result, it does not provide any
windowing capabilities.
• It is a state machine. At any moment during the execution of a program
there is a current model transformation.
• It is a rendering pipeline. The rendering pipeline consists of the following
steps: Defines objects mathematically. Arranges objects in space relative to
a viewpoint. Calculates the color of the objects.
6
OPENGL ARCHITECTURE:
Pipeline Architectures
7
SYSTEM DESIGN
Program Structure :
clockLayout
I’ve used this function to print the clock layout i.e. clock dial and
the markings on the clock. If we observe clearly, the clock has
hours marking each separated by 30 degrees and each hour is
divided into 5 markings each making an angle of 6 degrees. So,
iterating the markings for every 30 degrees gives hours and
iterating markings with 6 degrees give minutes markings on the
clock. The clock would look like this after executing this function.
Image Theory
secHand
It is clear from the name that this gonna do something with the
seconds hand. This function is going to get the present second
from the system clock and incline the line according to a particular
angle. Eg: if the present seconds is 5 then the angle of the
seconds hand with respect to the vertical must be 30 degrees, i.e.
5*6=30.
minHand
This function fulfills the task of moving the minutes hand based
on the system clock. The minutes hand must be inclined 6
degrees for every minute passing. Eg: if the elapsed minutes
are 30 then the minutes hand angle must be making 180
degrees with the vertical.
hrHand
8
Working of Analog Clock
Clocks use oscillators to keep the gears in motion. These oscillators have
changed from flowing water to pendulums to quartz crystals, but they all seek to
achieve the same purpose: perpetual motion. The oscillating mechanisms are
powered by a variety of sources, but the two most prevalent power sources are direct
electrical currents or batteries. The electricity or battery power fuels the controller
mechanism, which supplies crucial support to the oscillator. The controller, in turn,
fuels the wheel chain of the analog clock. The wheel chain is responsible for
notching and turning the indicator hands of the clock. So, with each second that
passes, the wheel chain synchronizes the minutes and hours accordingly. It is a
relatively simple process, culminating in the familiar big hand and little hand
indicating the hour and minute. All analog clocks uses gears in intricate fashion to
enhance efficiency but the basic mechanism remains same (even for vertical
designs).
Program Graphics
Most of the objects in the program, such as buttons, grids or cells, are drawn using
OpenGL primitives.
Most of the control buttons used through the program were made as textures in an
image editor and exported as .raw files. The class “Textures” (in Textures.h &
Textures.cpp) handles the loading of these images intomemory and drawing them
on the screen using OpenGL’s texture related function.
Text is drawn after the backbuffer is flushed to the front buffer, by hijacking the
window handle wia Win32 and writing text onto the window via the
Win32ThrowText() function defined in Util.h
9
IMPLEMENTATION SOURCE CODE
#include
<gl/glut.h>
#include <gl/gl.h>
#include <math.h>
#include <time.h>
#include
<sys/timeb.h>
30.0f,
minStart
= 0.9f, minEnd
= 1.0f,
= 1.0f;
float angleHour
= 0,
angleMin= 0,
angleSec = 0;
10
clockR*rStart*s); glVertex2f(
clockR*rEnd*c, clockR*rEnd*s);
}
void
RenderScene(void){
int i;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.0f,
0.0f);
glLineWidth(2.0f);
glEnable(GL_LINE_SMOOTH
);
glEnable(GL_POINT_SMOOT
H);
glEnable(GL_POLYGON_SMO
OTH);
glBegin(GL_LINES);
for(i=0; i<60;
i++){
if(i%5){ // normal
minute if(i%5 == 1)
glColor3f(1.0f, 1.0f, 1.0f);
newLine(minStart, minEnd, i*angle1min);
}else{
glColor3f(1.0f, 0.0f, 0.0f);
newLine(stepStart, stepEnd,
i*angle1min);
}
}
glEnd();
glLineWidth(3.0f
);
11
glBegin(GL_LINES
);
newLine(0.0f, 0.5f, -
angleHour+M_PI/2); newLine(0.0f,
0.8f, -angleMin+M_PI/2);
glEnd();
glLineWidth(1.0f);
glColor3f(0.0f, 0.0f,
1.0f);
glBegin(GL_LINES);
newLine(0.0f, 0.8f, -
angleSec+M_PI/2); glEnd();
glutSwapBuffers();
}
void SetupRC(void){
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
///////////////////////////////////////////////////////////
// Called by GLUT library when the window has chanaged
size void ChangeSize(GLsizei w, GLsizei h){
GLfloat aspectRatio;
// Prevent a divide by
zero if(h == 0)
h = 1;
12
far) aspectRatio = (GLfloat)w / (GLfloat)h;
if (w <= h)
glOrtho (-clockVol, clockVol, -clockVol / aspectRatio,
clockVol / aspectRatio, 1.0, -1.0);
else
glOrtho (-clockVol * aspectRatio, clockVol *
aspectRatio, - clockVol, clockVol, 1.0, -1.0);
glMatrixMode(GL_MODE
LVIEW);
glLoadIdentity();
}
void TimerFunction(int
value){ struct timeb
tb;
time_t
tim=time(0);
struct tm* t;
t=localtime(&
tim);
ftime(&tb);
angleSec = (float)(t->tm_sec+
(float)tb.millitm/1000.0f)/30.0f * M_PI;
angleMin = (float)(t->tm_min)/30.0f * M_PI +
angleSec/60.0f; angleHour = (float)(t->tm_hour > 12 ? t-
>tm_hour-12 : t-
>tm_hour)/6.0f * M_PI+
angleMin/12.0f;
glutPostRedisplay();
glutTimerFunc(33,TimerFunction, 1);
}
///////////////////////////////////////////////////////////
// Main program entry point
int main(int argc, char* argv[]){
glutInit(&argc, argv);
13
glutInitDisplayMode(GLUT_DOUBLE |
GLUT_RGBA); glutCreateWindow("glClock
by bobo");
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glutTimerFunc(33, TimerFunction, 1);
SetupRC();
glutMainLoop()
return 0;
}
14
OUTPUT OF THE PROGRAM
15
16
CONCLUSIONS
Attempts to represent time in a digital format have been around for ages, with the
first patented design of the ‘Plato’ digital clock of 1903 being introduced at the St.
Louis World Fair in 1904. But analogue soldiers on regardless.Digital displays have
enjoyed periods of popularity but people always seem to move back eventually to
analogue dials in the long term.Personally, I place the eternal popularity to be based
on the instant recognisability of the position of the hands. with the briefest of glances
it is possible to observe the time and a number of other aspects that digits alone do
not instantly convey, I always seemed to have to analyse them to get the picture - a
dial is of course exactly that - the picture.
17
Teacher Evaluation Sheet
Name of Student………………………………………………………………………………………
Enrollment No………………………………………………...….………...….………...….………...
Name of Program…………………………………………………….….....….………...….………...
Semester……………………………………………………………….…....….………...….………..
Course Title…………………………………………………………….…...….………...….………..
Code………………………………………………………………………...….………...….………...
Title of the Micro-Project……………………………………………………………………………...
Course Outcomes Achieved
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
………………………………………………………………………………………………………………
18
Note:
Every course teacher is expected to assign marks for group evolution in first 3 columns & individual
evaluation in 4th columns for each group of students as per rubrics
*****************
19