Skip to content

Commit

Permalink
Add a test to run a beam-ray looping around the dome
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeeley committed Aug 25, 2011
1 parent 217c38c commit 29cd350
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 0 deletions.
76 changes: 76 additions & 0 deletions test/beam-rays/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#############################################################################
#
# Makefile for building the Hello World sample program
#
#############################################################################

ifeq ($(DEBUG),y)
CFLAGS += -O -g -Wall # -O is need to expand inlines
else
CFLAGS += -O2 -Wall
endif

TARGET = beam-rays

PWD := $(shell pwd)
SOLARIUM_ROOT = $(PWD)/../..
SOLARIUM_LIB = $(SOLARIUM_ROOT)/lib

GUMSTIX_BUILDROOT = $(SOLARIUM_ROOT)/../gumstix/gumstix-buildroot
BUILD_ARM = $(wildcard $(GUMSTIX_BUILDROOT)/build_arm*)
CROSS_COMPILE = $(patsubst %gcc, %, $(wildcard $(BUILD_ARM)/staging_dir/bin/arm-linux-uclibc*-gcc))

ifeq ($(strip $(CROSS_COMPILE)),)
$(error Unable to detect Cross Compiler)
endif

TARGET_ARCH=-Os -march=armv5te -mtune=xscale -Wa,-mcpu=xscale
CC = $(CROSS_COMPILE)gcc

#
# If you need additional serch paths for include files, then use the -I flag
# and add them to the CPPFLAGS variable
#

CPPFLAGS += -I $(SOLARIUM_LIB)

#
# If you need addional search paths for library files, then use the -L flag
# and add them to LDFLAGS.
#

LDFLAGS += -static -s

#
# If you need additional libraries, then use -lxxx to search for libxxx.a
#

LDLIBS += -lm

.PHONY: all

all: depend $(TARGET)

#
# You can change the $(TARGET).c if that's not your main file and you can
# add additional .o files to the end of the line
#

SRCS = $(TARGET).c $(SOLARIUM_LIB)/i2c/device.c $(SOLARIUM_LIB)/i2c/i2c-api.c $(SOLARIUM_LIB)/i2c/DumpMem.c $(SOLARIUM_LIB)/i2c/Log.c $(SOLARIUM_LIB)/solarium-types.c $(SOLARIUM_LIB)/solarium-draw.c
OBJS = $(SRCS:.c=.o)

$(TARGET) : $(OBJS)

clean:
rm -rf $(OBJS) core .depend $(TARGET)

depend .depend dep:
$(CC) $(CFLAGS) $(CPPFLAGS) -M $(SRCS) > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif

upload:
scp $(TARGET) 192.168.1.141:/home/garth/bin

75 changes: 75 additions & 0 deletions test/beam-rays/beam-rays.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <stdio.h>
#include <unistd.h>
#include "solarium-types.h"
#include "solarium-draw.h"

#define ENABLE_BEAM_STEP_DELAY 0
#define BEAM_STEP_DELAY 1000000

#define COLOR_STEP 5

void set_beam_colors (int i)
{
int j;
beam_t *beam = get_beam(i);

*(beam->red) = 255;
*(beam->green) = 255;
*(beam->blue) = 255;

*(beam->dirty) = 1;

for (j = 0; j < NUM_BEAMS; ++j) {
beam = get_beam(j);
if (j == i) {
continue;
}
if (*(beam->red) || *(beam->green) || *(beam->blue)) {
if (*(beam->red) < COLOR_STEP) {
*(beam->red) = 0;
}
else {
*(beam->red) -= COLOR_STEP;
}
if (*(beam->green) < COLOR_STEP) {
*(beam->green) = 0;
}
else {
*(beam->green) -= COLOR_STEP;
}
if (*(beam->blue) < COLOR_STEP) {
*(beam->blue) = 0;
}
else {
*(beam->blue) -= COLOR_STEP;
}

*(beam->dirty) = 1;
}
}
}

int main (void)
{
int i;

setup();

while (1) {
for (i = 0; i < NUM_BEAMS; ++i) {
set_beam_colors(i);

draw();

printf ("Drew beam %d\n", i);

#if ENABLE_BEAM_STEP_DELAY
usleep(BEAM_STEP_DELAY);
#endif
}
}

return 0;
}


0 comments on commit 29cd350

Please sign in to comment.