Skip to content

Commit

Permalink
compiles and runs on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
asquared committed Nov 28, 2010
1 parent 79c5e3a commit 5d5066a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/HockeyData_2.cpp
@@ -1,4 +1,5 @@
#include "HockeyData.h"
#include "utility.h"

int invertTime( unsigned char period, int timeleft, int perlen, int otlen ) {
// figure out time until next change of status
Expand Down
2 changes: 1 addition & 1 deletion src/HockeyLogic.cpp
Expand Up @@ -1200,7 +1200,7 @@ void HockeyLogic::logicSync(HockeyData* data, HockeyDraw* hd, Keybuffer* kbuf, H
disp[19] = (data->sync_tr) ? "READ 7-SEG CLOCK" : "READ GREEN LIGHT";
disp[21] = (data->use_tenths) ? "YES" : "NO";
port = data->ssync.get_port();
if (!data->ssync.valid( )) disp[10] = "Currently using port: NONE";
if (!data->ssync.ok( )) disp[10] = "Currently using port: NONE";
else disp[10] = "Currently using port: COM" + int2str(port);
minor = 1;
kbuf->clear();
Expand Down
12 changes: 9 additions & 3 deletions src/Makefile
Expand Up @@ -6,6 +6,7 @@ hockeyboard_OBJECTS = \
GLCairoSurface.o \
GLCairoTextSurface.o \
HockeyData.o \
HockeyData_2.o \
HockeyDraw.o \
HockeyDrop.o \
HockeyLogic.o \
Expand All @@ -16,12 +17,17 @@ hockeyboard_OBJECTS = \
main.o \
Mclock.o \
mouse.o \
serialsync.o \
serialsync_unix.o \
settings.o \
timegettime.o \

hockeyboard_LIBS = -lcairo -lpango -lGL -lGLUT
CXX=gcc
hockeyboard_LIBS = -lGL -lGLU -lglut
hockeyboard_LIBS += `pkg-config --libs freetype2`
hockeyboard_LIBS += `pkg-config --libs cairo`
hockeyboard_LIBS += `pkg-config --libs pango`
hockeyboard_LIBS += `pkg-config --libs pangocairo`

CXX=g++
CFLAGS=-g -O2

CFLAGS += `pkg-config --cflags freetype2`
Expand Down
11 changes: 9 additions & 2 deletions src/main.cpp
Expand Up @@ -207,6 +207,7 @@ int main( int argc, char* argv[] ) {

// load fonts
base = new freetype::font_data;
#ifdef WINDOWS
try {
string fontdir = string(getenv("WINDIR"));
fontdir += "\\Fonts\\";
Expand All @@ -216,7 +217,11 @@ int main( int argc, char* argv[] ) {
catch (std::runtime_error e) {
quit(1);
}

#else
fprintf(stderr, "Initialize base\n");
base->init("DejaVuSansMono.ttf", 12, 16, 255);
#endif
fprintf(stderr, "Initialize state\n");
// generate data object
data = new HockeyData;
logic = new HockeyLogic;
Expand Down Expand Up @@ -247,6 +252,7 @@ int main( int argc, char* argv[] ) {
// new draw code
hd = new HockeyDraw;

fprintf(stderr, "Load settings...\n");
load_settings("settings.ini");

// setup window callbacks
Expand All @@ -258,9 +264,10 @@ int main( int argc, char* argv[] ) {
glutPassiveMotionFunc( mousemove );
glutMouseFunc( mouseclick );


fprintf(stderr, "GLUT main loop...\n");
// enter main loop
glutMainLoop();
fprintf(stderr, "Done!\n");

quit(0);
return 0;
Expand Down
9 changes: 6 additions & 3 deletions src/serialsync_unix.cpp
@@ -1,11 +1,14 @@
#include "serialsync.h"
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>

// counts '1' bits in a nibble (4 bit value)
const unsigned char bitcount[] = { 0, 1, 1, 2, 1, 2, 2, 3,
1, 2, 2, 3, 2, 3, 3, 4 };

SerialSync::SerialSync() {
hSerial = NULL;
portfd = -1;
port = -1;
}

Expand All @@ -31,7 +34,7 @@ bool SerialSync::port_open(int p) {

portfd = open(s, O_RDWR | O_NOCTTY);

if (tcgetattr(fd, &attr) != 0) {
if (tcgetattr(portfd, &attr) != 0) {
perror("tcgetattr");
port = -1;
return false;
Expand All @@ -42,7 +45,7 @@ bool SerialSync::port_open(int p) {
cfsetispeed(&attr, B2400);
cfsetospeed(&attr, B2400);
/* 8N1 default?? */
if (tcsetattr(fd, TCSAFLUSH, &attr) != 0) {
if (tcsetattr(portfd, TCSAFLUSH, &attr) != 0) {
perror("tcsetattr");
port = -1;
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/timegettime.cpp
Expand Up @@ -29,7 +29,7 @@ uint32_t timeGetTime(void) {
}

/* subtract tv_initial from tv */
useconds = tv.seconds - tv_initial.seconds;
useconds = tv.tv_sec - tv_initial.tv_sec;
useconds *= 1000000;
useconds += tv.tv_usec;
useconds -= tv_initial.tv_usec;
Expand Down

0 comments on commit 5d5066a

Please sign in to comment.