changeset 68:59edd5780fef

Changed d-box code to run cleanly when built on board. Updated Makefile to add ne10 include path on board. Some extra docs in Utilities.h
author andrewm
date Fri, 17 Jul 2015 16:57:08 +0100
parents 472e892c6e41
children 272154649c46
files Makefile include/Utilities.h projects/d-box/DboxSensors.h projects/d-box/I2c_TouchKey.h projects/d-box/StatusLED.cpp projects/d-box/how_to_build_dbox.txt projects/d-box/main.cpp projects/tank_wars/game.cpp
diffstat 8 files changed, 102 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri Jul 17 15:28:18 2015 +0100
+++ b/Makefile	Fri Jul 17 16:57:08 2015 +0100
@@ -10,6 +10,9 @@
 STATIC_LIBS := ./libprussdrv.a ./libNE10.a
 LIBS := -lrt -lnative -lxenomai
 
+INCLUDES := -I/usr/include/ne10 -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10
+
+
 ASM_SRCS := $(wildcard source/*.S)
 ASM_OBJS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.o)))
 ASM_DEPS := $(addprefix build/source/,$(notdir $(ASM_SRCS:.S=.d)))
@@ -55,34 +58,34 @@
 DEFAULT_MAIN_CPP_SRCS := ./core/default_main.cpp
 DEFAULT_MAIN_OBJS := ./build/core/default_main.o
 DEFAULT_MAIN_CPP_DEPS := ./build/core/default_main.d
-	
+
 # All = build BeagleRT
 all: BeagleRT
-	
+
 # Rule for BeagleRT core C++ files
 build/core/%.o: ./core/%.cpp
 	@echo 'Building file: $<'
 	@echo 'Invoking: GCC C++ Compiler'
-	g++ -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+	g++ $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
 	@echo 'Finished building: $<'
 	@echo ' '
-	
+
 # Rule for user-supplied C++ files
 build/source/%.o: ./source/%.cpp
 	@echo 'Building file: $<'
 	@echo 'Invoking: GCC C++ Compiler'
-	g++ -I./include -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+	g++ -I./include $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
 	@echo 'Finished building: $<'
 	@echo ' '
-	
+
 # Rule for user-supplied C files
 build/source/%.o: ./source/%.c
 	@echo 'Building file: $<'
 	@echo 'Invoking: GCC C Compiler'
-	gcc -I./include -I/usr/xenomai/include -I/usr/arm-linux-gnueabihf/include/xenomai/include -I/usr/arm-linux-gnueabihf/include/ne10 -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+	gcc -I./include $(INCLUDES) -O2 -Wall -c -fmessage-length=0 -U_FORTIFY_SOURCE -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
 	@echo 'Finished building: $<'
 	@echo ' '
-	
+
 # Rule for user-supplied assembly files
 build/source/%.o: ./source/%.S
 	@echo 'Building file: $<'
@@ -102,7 +105,7 @@
 	@echo 'Finished building target: $@'
 	@echo ' '
 #	$(MAKE) --no-print-directory post-build	
-	
+
 # Rule for building BeagleRT including the default main file (no user-supplied main())
 BeagleRT_with_main: $(CORE_OBJS) $(DEFAULT_MAIN_OBJS) $(ASM_OBJS) $(C_OBJS) $(CPP_OBJS) $(STATIC_LIBS)
 	@echo 'Building target: $@'
--- a/include/Utilities.h	Fri Jul 17 15:28:18 2015 +0100
+++ b/include/Utilities.h	Fri Jul 17 16:57:08 2015 +0100
@@ -32,8 +32,58 @@
 // Likewise, thread launch should be able to be called from setup()
 // Also, make volume change functions callable from render() thread -- as an aux task?
 
+/**
+ * \brief Read an analog input, specifying the frame number (when to read) and the channel.
+ *
+ * This function returns the value of an analog input, at the time indicated by \c frame.
+ * The returned value ranges from 0 to 1, corresponding to a voltage range of 0 to 4.096V.
+ *
+ * \param context The I/O data structure which is passed by BeagleRT to render().
+ * \param frame Which frame (i.e. what time) to read the analog input. Valid values range
+ * from 0 to (context->analogFrames - 1).
+ * \param channel Which analog input to read. Valid values are between 0 and
+ * (context->analogChannels - 1), typically 0 to 7 by default.
+ * \return Value of the analog input, range 0 to 1.
+ */
 float analogReadFrame(BeagleRTContext *context, int frame, int channel);
+
+/**
+ * \brief Write an analog output, specifying the frame number (when to write) and the channel.
+ *
+ * This function sets the value of an analog output, at the time indicated by \c frame. Valid
+ * values are between 0 and 1, corresponding to the range 0 to 5V.
+ *
+ * The value written will persist for all future frames if BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST
+ * is set in context->flags. This is the default behaviour.
+ *
+ * \param context The I/O data structure which is passed by BeagleRT to render().
+ * \param frame Which frame (i.e. what time) to write the analog output. Valid values range
+ * from 0 to (context->analogFrames - 1).
+ * \param channel Which analog output to write. Valid values are between 0 and
+ * (context->analogChannels - 1), typically 0 to 7 by default.
+ * \param value Value to write to the output, range 0 to 1.
+ */
 void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value);
+
+/**
+ * \brief Write an analog output, specifying the frame number (when to write) and the channel.
+ *
+ * This function sets the value of an analog output, at the time indicated by \c frame. Valid
+ * values are between 0 and 1, corresponding to the range 0 to 5V.
+ *
+ * Unlike analogWriteFrame(), the value written will affect \b only the frame specified, with
+ * future values unchanged. This is more efficient than analogWriteFrame() so is better suited
+ * to applications where every frame will be written to a different value. If
+ * BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST is not set within context->flags, then
+ * analogWriteFrameOnce() and analogWriteFrame() are equivalent.
+ *
+ * \param context The I/O data structure which is passed by BeagleRT to render().
+ * \param frame Which frame (i.e. what time) to write the analog output. Valid values range
+ * from 0 to (context->analogFrames - 1).
+ * \param channel Which analog output to write. Valid values are between 0 and
+ * (context->analogChannels - 1), typically 0 to 7 by default.
+ * \param value Value to write to the output, range 0 to 1.
+ */
 void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value);
 
 int digitalReadFrame(BeagleRTContext *context, int frame, int channel);
--- a/projects/d-box/DboxSensors.h	Fri Jul 17 15:28:18 2015 +0100
+++ b/projects/d-box/DboxSensors.h	Fri Jul 17 16:57:08 2015 +0100
@@ -21,7 +21,7 @@
 
 #include "I2c_TouchKey.h"
 #include "AnalogInput.h"
-#include "../../include/GPIOcontrol.h"	// TODO wrap this into a class
+#include <GPIOcontrol.h>	// TODO wrap this into a class
 
 /*---------------------------------------------------------------------------------------------------------------------------------------------------
  * This class retrieves data from all the connected sensors,
--- a/projects/d-box/I2c_TouchKey.h	Fri Jul 17 15:28:18 2015 +0100
+++ b/projects/d-box/I2c_TouchKey.h	Fri Jul 17 16:57:08 2015 +0100
@@ -8,7 +8,7 @@
 #ifndef I2CTK_H_
 #define I2CTK_H_
 
-#include "../../include/I2c.h"
+#include <I2c.h>
 
 // #define NUM_BYTES_OLD 9
 // #define NUM_BYTES_NEW 13
--- a/projects/d-box/StatusLED.cpp	Fri Jul 17 15:28:18 2015 +0100
+++ b/projects/d-box/StatusLED.cpp	Fri Jul 17 16:57:08 2015 +0100
@@ -9,7 +9,7 @@
 
 #include <iostream>
 #include "StatusLED.h"
-#include "../../include/GPIOcontrol.h"
+#include <GPIOcontrol.h>
 
 extern int gShouldStop;
 extern int gVerbose;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/projects/d-box/how_to_build_dbox.txt	Fri Jul 17 16:57:08 2015 +0100
@@ -0,0 +1,35 @@
+The D-Box code can be built on the board using the scripts included with
+BeagleRT. To build the code, do the following from the scripts/ directory:
+
+./setup_board.sh    # Only if BeagleRT is not already copied to the board
+./build_project.sh -n ../projects/d-box  # -n means don't run yet
+
+You will now need to copy the .dbx sound files to the box. These need to
+be in a directory: /root/d-box/sounds
+
+Log into the board via ssh to create the d-box directory, or run:
+
+ssh root@192.168.7.2 "mkdir /root/d-box"
+
+Now copy the .dbx files from a source of your choice to the board. Assuming
+they are in a directory called "sounds":
+
+scp -r sounds root@192.168.7.2:/root/d-box/
+
+Now you can run the D-Box program to make sure it plays. You will need the
+sensors and matrix connected to the box (i.e. a complete hardware D-Box).
+From the scripts/ directory:
+
+./run_project.sh -f -c "-q 24 -r 25 -t 2 -s -p 2 -l 0 -u 0 -i 1 -n f -g 3 -v"
+
+If this plays properly, the D-Box can then be set to run automatically on boot:
+
+./set_startup.sh -l -c "-q 24 -r 25 -t 2 -s -p 2 -l 0 -u 0 -i 1 -n f -g 3 -v"
+
+If at any time you want to stop the D-Box program running, you can run:
+
+./stop_running.sh
+
+To turn off further autoboot, run:
+
+./set_startup.sh -n
--- a/projects/d-box/main.cpp	Fri Jul 17 15:28:18 2015 +0100
+++ b/projects/d-box/main.cpp	Fri Jul 17 16:57:08 2015 +0100
@@ -76,7 +76,7 @@
 char sdPath[256]			= "/dev/mmcblk0p2";			// system path of the SD, partition 2
 char mountPath[256]			= "/root/d-box/usersounds";	// mount point of SD partition 2 [where user files are]
 char gUserDirName[256] 		= "usersounds";				// Directory in which user analysis files can be found [dir of mountPath]
-char gDefaultDirName[256] 	= "sounds";					// Directory in which built in analysis files can be found
+char gDefaultDirName[256] 	= "/root/d-box/sounds";		// Directory in which built in analysis files can be found
 char *gDirName;
 bool gIsLoading 			= false;
 int fileCnt 				= 0;
--- a/projects/tank_wars/game.cpp	Fri Jul 17 15:28:18 2015 +0100
+++ b/projects/tank_wars/game.cpp	Fri Jul 17 16:57:08 2015 +0100
@@ -8,7 +8,7 @@
 #include <cmath>
 #include <cstdlib>
 #include "vector_graphics.h"
-#include "../../include/Utilities.h"
+#include <Utilities.h>
 
 // Virtual screen size
 int screenWidth, screenHeight;