PRE2015 4 Groep5 Code: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
Line 703: Line 703:
===Robot===
===Robot===
===Shared===
===Shared===
'''CommandBook.ino'''
int countCommand(CommandBook *book)
{
int c = 0;
while (book[c].command != NULL && c < BOOKSIZE)
c++;
return c;
}
bool addCommand(CommandBook *book, char command, int value)
{
int c = countCommand(book);
if (c >= BOOKSIZE) {
return false;
}
book[c].command = command;
book[c].value = value;
return true;
}
#ifndef BASESTATION
void runCommand(CommandBook *book)
{
int c = countCommand(book);
for (int i = 0; i < c; i++)
{
switch (book[i].command)
{
case 't':
{
r_MovePlant(book[i].value);
break;
}
case 'c':
{
r_Cut();
break;
}
case 'g':
{
r_Grab();
break;
}
case 'r':
{
r_MovePlant(0);
break;
}
case 'W':
{
shaftStepper.enableOutputs();
shaftStepper.moveTo(900);
shaftStepper.runToPosition();
shaftStepper.disableOutputs();
break;
}
case 'S':
{
shaftStepper.enableOutputs();
shaftStepper.moveTo(0);
shaftStepper.runToPosition();
//shaftStepper.disableOutputs(); //Keeping the shaft on it's place ONE TIME ONLY FOR DEMO (MABYE 2-3, but check temperature)
break;
}
case 'D':
{
armStepper.enableOutputs();
armStepper.moveTo(750);
armStepper.runToPosition();
armStepper.disableOutputs();
break;
}
case 'A':
{
armStepper.enableOutputs();
armStepper.moveTo(0);
armStepper.runToPosition();
armStepper.disableOutputs();
break;
}
case 'u':
{
armTurnPos(book[i].value);
break;
}
case 'i':
{
grabberTurnPos(book[i].value );
break;
}
case 'd':
{
delay(book[i].value);
break;
}
case 'm':
{
kopStepper.move(book[i].value);
break;
}
default: // "undef"
break;
book[i].command = NULL;
book[i].value = NULL;
}
Serial.print('-');
Serial.print(book[i].command);
Serial.print('\t');
Serial.print(book[i].value);
Serial.println("\tDone");
}
Serial.println("All commands done.");
}
#endif // BASESTATION
void printCommand(CommandBook *book)
{
int c = countCommand(book);
Serial.println(F("Commandos in book:"));
for (int i = 0; i < c; i++)
{
Serial.print('-');
Serial.print(book[i].command);
Serial.print('\t');
Serial.println(book[i].value);
}
Serial.println(F("-END OF COMMANDS"));
}
bool deleteCommand(CommandBook *book)
{
int c = countCommand(book);
if (c == 0) {
return false;
}
book[c - 1].command = NULL;
book[c - 1].value = NULL;
return true;
}
bool sendCommand(CommandBook *book) {
int c = countCommand(book);
uint8_t* buf = new uint8_t[BOOKSIZE * 3 + 1];
buf[0] = c;
for (int n = 0; n < c; n += 1) {
buf[(n * 3) + 1] = (uint8_t) book[n].command;
buf[(n * 3) + 2] = (uint8_t) (book[n].value >> 8);
buf[(n * 3) + 3] = (uint8_t)(book[n].value & 0xFF);
}
Serial.println(F("Sending message..."));
bool result = nrf24SendMessage(buf, c * 3 + 1);
delete buf;
return result;
}
'''nrf24communication.ino'''
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_NRF24 driver;
// RH_NRF24 driver(8, 7);  // For RFM73 on Anarduino Mini
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver);
bool isServer;
uint8_t _nrf24_buf[32];
uint8_t _nrf24_blen = 0;
bool nrf24Initialize(bool server) {
Serial.print(F(" -Initiating radio:\t"));
if (manager.init()) {
Serial.println(F("OK"));
Serial.print(F(" -Setting radio channel:\t"));
if (!driver.setChannel(1)) {
return false;
Serial.println(F("setChannel failed"));
}
else {
Serial.println(F("Channel 1"));
}
Serial.print(F(" -Setting radio settings:\t"));
if (!driver.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm)) {
Serial.println(F("setRF failed"));
return false;
}
else {
Serial.println(F("2Mbps, 0dBm"));
}
}
else {
Serial.println(F("FAILED!!!"));
return false;
}
if (server) {
manager.setThisAddress(SERVER_ADDRESS);
}
else {
manager.setThisAddress(CLIENT_ADDRESS);
}
isServer = server;
return true;
}
bool compareBuffers(uint8_t *buf1, uint8_t *buf2, uint8_t len) {
for (uint8_t n = 0; n < len; n += 1) {
if (buf1[n] != buf2[n]) {
return false;
}
}
return true;
}
void nrf24DebugPrint(char* str) {
if (true) {
Serial.println(str);
}
}
bool nrf24ReceiveMessage(uint8_t* str, uint8_t* len) {
uint8_t from;
if (!manager.waitAvailableTimeout(3000)) {
return false;
}
if (!manager.recvfromAck(str, len, &from)) {
debugln(F("Couldn't receive message"));
return false;
}
uint8_t* _nrf24_buf = (uint8_t *) "OK";
if (manager.sendtoWait(_nrf24_buf, 3, from)) {
return true;
}
debugln(F("Did not receive acknowledgement on 'OK'"));
return false;
}
bool nrf24SendMessage(uint8_t* str, uint8_t len) {
uint8_t address = SERVER_ADDRESS;
if (isServer) {
address = CLIENT_ADDRESS;
}
if (!manager.sendtoWait(str, len, address)) {
debugln(F("No acknowledgement received"));
return false;
}
if (!manager.waitAvailableTimeout(1000)) {
return false;
}
uint8_t from;
if (manager.recvfromAck(_nrf24_buf, &_nrf24_blen, &from)) {
return true;
}
debugln(F("Could not receive 'OK'"));
return false;
}
bool radioSleep()
{
driver.setModeIdle();
if (driver.sleep())
{
return true;
}
else
return false;
}


'''Solution.sln'''
'''Solution.sln'''

Revision as of 17:02, 16 June 2016

Repository: https://github.com/JochemKuijpers/UseWaterpret

Library

https://github.com/JochemKuijpers/UseWaterpret/tree/master/Library

Libraries used:

  • Arduino_Menu
  • DallasTemperatureControl
  • OneWire
  • RadioHead-1.59
  • ServoTimer2

Solution

BaseStation

BaseStation.ino

/*
 Name:		BaseStation.ino
 Created:	5/19/2016 4:07:46 PM
 Author:	Use Waterpret
*/

#include <SPI.h>

#define ENABLE_DEBUG
#define BOOKSIZE 10
#define BASESTATION

#ifdef ENABLE_DEBUG
// disable Serial output
#define debugln(a) (Serial.println(a))
#define debug(a) (Serial.print(a))
#else
#define debugln(a)
#define debug(a)
#endif

struct CommandBook
{
	char command;
	int value;
}tempCommand;

//menu
#include <MenuSystem.h>
#include "CustomNumericMenuItem.h"

// forward declarations
const String format_float(const float value);
const String format_int(const float value);
const String format_color(const float value);
const String format_type(const float value);
const String format_value(const float value);
void display_menu(Menu* p_menu);
void on_status_selected(MenuItem* p_menu_item);
void on_back_item_selected(MenuItem* p_menu_item);
void on_help_selected(MenuItem* p_menu_item);
void on_about_selected(MenuItem* p_menu_item);
void on_add_selected(MenuItem* p_menu_item);
void on_del_selected(MenuItem* p_menu_item);
void on_demo_selected(MenuItem* p_menu_item);
void on_send_selected(MenuItem* p_menu_item);
bool addCommand(CommandBook *book, char command, int value);
int countCommand(CommandBook *book);
void runCommand(CommandBook *book);
void printCommand(CommandBook *book);
bool deleteCommand(CommandBook *book);
bool sendCommand(CommandBook *book);
CommandBook commandos[BOOKSIZE] = {};				// array with commands for the Arduino

// Menu variables
MenuSystem ms;
Menu mm("Main Menu", &display_menu);
	Menu muCommand("Command Builder..", &display_menu);
		NumericMenuItem muCommand_type("Command type", 0, 0, 11, 1, format_type);
		NumericMenuItem muCommand_value("Value", 0, -15, 15, 1, format_value);
		MenuItem muCommand_add("Add command to CommandBook", &on_add_selected);
		MenuItem muCommand_delete("Delete command from CommandBook", &on_del_selected);
		MenuItem muCommand_demo("Set demo sequence", &on_demo_selected);
		MenuItem muCommand_send("Send CommandBook to Robot", &on_send_selected);
	MenuItem muRobot_status("Status", &on_status_selected);
	BackMenuItem mu_back("Back..", &on_back_item_selected, &ms);
	MenuItem mm_help("Help", &on_help_selected);
	MenuItem mm_about("About", &on_about_selected);

void setup()
{
	Serial.begin(9600);
	nrf24Initialize(true);
	delay(3000);

	mm.add_menu(&muCommand);
		muCommand.add_item(&muCommand_type);
		muCommand.add_item(&muCommand_value);
		muCommand.add_item(&muCommand_add);
		muCommand.add_item(&muCommand_delete);
		muCommand.add_item(&muCommand_demo);
		muCommand.add_item(&muCommand_send);
		muCommand.add_item(&mu_back);
	mm.add_item(&muRobot_status);
	mm.add_item(&mm_help);
	mm.add_item(&mm_about);
	ms.set_root_menu(&mm);

	display_help();
	ms.display();
}

void loop() {
	serial_handler();




}

BaseStation.vcxproj

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Label="ProjectConfigurations">
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Debug|x64">
      <Configuration>Debug</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|x64">
      <Configuration>Release</Configuration>
      <Platform>x64</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <PropertyGroup Label="Globals">
    <ProjectGuid>{194F20BC-E954-42EA-99FE-BA4D6577DDA3}</ProjectGuid>
    <RootNamespace>BaseStation</RootNamespace>
    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v140</PlatformToolset>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v140</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>true</UseDebugLibraries>
    <PlatformToolset>v140</PlatformToolset>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
    <ConfigurationType>Application</ConfigurationType>
    <UseDebugLibraries>false</UseDebugLibraries>
    <PlatformToolset>v140</PlatformToolset>
    <WholeProgramOptimization>true</WholeProgramOptimization>
    <CharacterSet>MultiByte</CharacterSet>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ImportGroup Label="ExtensionSettings">
  </ImportGroup>
  <ImportGroup Label="Shared">
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <IncludePath>$(SolutionDir)Shared;$(IncludePath)</IncludePath>
  </PropertyGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard;C:\Users\s133140\Source\Repos\UseWaterpret\Solution\BaseStation;C:\Users\s133140\Documents\Arduino\libraries\Arduino_Menu;C:\Users\s133140\Documents\Arduino\libraries\Arduino_Menu\utility;C:\Users\s133140\Documents\Arduino\libraries\RadioHead;C:\Users\s133140\Documents\Arduino\libraries\RadioHead\utility;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\utility;C:\Program Files (x86)\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\nctamhse.x5i\Micro Platforms\default\debuggers;C:\Users\s133140\Documents\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\tools\avr/avr/include/;C:\Program Files (x86)\Arduino\hardware\tools\avr//avr/include/avr/;C:\Program Files (x86)\Arduino\hardware\tools\avr/lib\gcc\avr\4.8.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <ForcedIncludeFiles>C:\Users\s133140\Source\Repos\UseWaterpret\Solution\BaseStation\__vm\.BaseStation.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
      <PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=10609;ARDUINO_AVR_DUEMILANOVE;ARDUINO_ARCH_AVR;__cplusplus=201103L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard;C:\Users\Jochem\Documents\Projects\UseWaterpret\Solution\BaseStation;C:\Users\Jochem\Documents\Arduino\libraries\Arduino_Menu;C:\Users\Jochem\Documents\Arduino\libraries\Arduino_Menu\utility;C:\Users\Jochem\Documents\Arduino\libraries\RadioHead;C:\Users\Jochem\Documents\Arduino\libraries\RadioHead\utility;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\utility;C:\Program Files (x86)\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zhfqazlz.lqo\Micro Platforms\default\debuggers;C:\Users\Jochem\Documents\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\tools\avr/avr/include/;C:\Program Files (x86)\Arduino\hardware\tools\avr//avr/include/avr/;C:\Program Files (x86)\Arduino\hardware\tools\avr/lib\gcc\avr\4.8.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <ForcedIncludeFiles>C:\Users\Jochem\Documents\Projects\UseWaterpret\Solution\BaseStation\__vm\.BaseStation.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
      <PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=10609;ARDUINO_AVR_UNO;ARDUINO_ARCH_AVR;__cplusplus=201103L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>MaxSpeed</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
    </ClCompile>
    <Link>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <Optimization>Disabled</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <SDLCheck>true</SDLCheck>
      <AdditionalIncludeDirectories>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard;C:\Users\Jochem\Documents\Projects\UseWaterpret\Solution\BaseStation;C:\Users\Jochem\Documents\Arduino\libraries\Arduino_Menu;C:\Users\Jochem\Documents\Arduino\libraries\Arduino_Menu\utility;C:\Users\Jochem\Documents\Arduino\libraries\RadioHead;C:\Users\Jochem\Documents\Arduino\libraries\RadioHead\utility;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src\utility;C:\Program Files (x86)\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\zhfqazlz.lqo\Micro Platforms\default\debuggers;C:\Users\Jochem\Documents\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\tools\avr/avr/include/;C:\Program Files (x86)\Arduino\hardware\tools\avr//avr/include/avr/;C:\Program Files (x86)\Arduino\hardware\tools\avr/lib\gcc\avr\4.8.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
      <ForcedIncludeFiles>C:\Users\Jochem\Documents\Projects\UseWaterpret\Solution\BaseStation\__vm\.BaseStation.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
      <WholeProgramOptimization>false</WholeProgramOptimization>
      <PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;F_CPU=16000000L;ARDUINO=10609;ARDUINO_AVR_UNO;ARDUINO_ARCH_AVR;__cplusplus=201103L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup>
    <None Include="..\Shared\CommandBook.ino" />
    <None Include="..\Shared\nrf24communication.ino" />
    <None Include="BaseStation.ino">
      <FileType>CppCode</FileType>
    </None>
    <None Include="menu.ino" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="CustomNumericMenuItem.h" />
    <ClInclude Include="__vm\.BaseStation.vsarduino.h" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
  <ProjectExtensions>
    <VisualStudio>
      <UserProperties arduino.upload.maximum_size="30720" arduino.upload.speed="57600" visualmicro.package.name="arduino" arduino.board.property_bag="name=Arduino Duemilanove or Diecimila w/ ATmega328&#xD;
upload.tool=avrdude&#xD;
upload.protocol=arduino&#xD;
bootloader.tool=avrdude&#xD;
bootloader.low_fuses=0xFF&#xD;
bootloader.unlock_bits=0x3F&#xD;
bootloader.lock_bits=0x0F&#xD;
build.f_cpu=16000000L&#xD;
build.board=AVR_DUEMILANOVE&#xD;
build.core=arduino&#xD;
build.variant=standard&#xD;
menu.cpu.atmega328=ATmega328&#xD;
menu.cpu.atmega328.upload.maximum_size=30720&#xD;
menu.cpu.atmega328.upload.maximum_data_size=2048&#xD;
menu.cpu.atmega328.upload.speed=57600&#xD;
menu.cpu.atmega328.bootloader.high_fuses=0xDA&#xD;
menu.cpu.atmega328.bootloader.extended_fuses=0x05&#xD;
menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex&#xD;
menu.cpu.atmega328.build.mcu=atmega328p&#xD;
menu.cpu.atmega168=ATmega168&#xD;
menu.cpu.atmega168.upload.maximum_size=14336&#xD;
menu.cpu.atmega168.upload.maximum_data_size=1024&#xD;
menu.cpu.atmega168.upload.speed=19200&#xD;
menu.cpu.atmega168.bootloader.high_fuses=0xdd&#xD;
menu.cpu.atmega168.bootloader.extended_fuses=0x00&#xD;
menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex&#xD;
menu.cpu.atmega168.build.mcu=atmega168&#xD;
runtime.ide.path=C:\Program Files (x86)\Arduino&#xD;
build.system.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr\system&#xD;
runtime.ide.version=10609&#xD;
target_package=arduino&#xD;
target_platform=avr&#xD;
runtime.hardware.path=C:\Program Files (x86)\Arduino\hardware\arduino&#xD;
originalid=diecimila&#xD;
intellisense.tools.path={runtime.tools.avr-gcc.path}/&#xD;
intellisense.include.paths={intellisense.tools.path}avr/include/;{intellisense.tools.path}/avr/include/avr/;{intellisense.tools.path}lib\gcc\avr\4.8.1\include&#xD;
tools.atprogram.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram&#xD;
tools.atprogram.cmd.setwinpath=true&#xD;
tools.atprogram.program.params.verbose=-v&#xD;
tools.atprogram.program.params.quiet=-q&#xD;
tools.atprogram.program.pattern="{cmd.path}" -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"&#xD;
tools.atprogram.program.xpattern="{cmd.path}" {AVRSTUDIO_BACKEND_CONNECTION} -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"&#xD;
tools.atprogram.erase.params.verbose=-v&#xD;
tools.atprogram.erase.params.quiet=-q&#xD;
tools.atprogram.bootloader.params.verbose=-v&#xD;
tools.atprogram.bootloader.params.quiet=-q&#xD;
tools.atprogram.bootloader.pattern="{cmd.path}" -d {build.mcu} {bootloader.verbose}  program -c -f "{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}"&#xD;
version=1.6.11&#xD;
compiler.warning_flags=-w&#xD;
compiler.warning_flags.none=-w&#xD;
compiler.warning_flags.default=&#xD;
compiler.warning_flags.more=-Wall&#xD;
compiler.warning_flags.all=-Wall -Wextra&#xD;
compiler.path={runtime.tools.avr-gcc.path}/bin/&#xD;
compiler.c.cmd=avr-gcc&#xD;
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD&#xD;
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections&#xD;
compiler.c.elf.cmd=avr-gcc&#xD;
compiler.S.flags=-c -g -x assembler-with-cpp&#xD;
compiler.cpp.cmd=avr-g++&#xD;
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD&#xD;
compiler.ar.cmd=avr-ar&#xD;
compiler.ar.flags=rcs&#xD;
compiler.objcopy.cmd=avr-objcopy&#xD;
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0&#xD;
compiler.elf2hex.flags=-O ihex -R .eeprom&#xD;
compiler.elf2hex.cmd=avr-objcopy&#xD;
compiler.ldflags=&#xD;
compiler.size.cmd=avr-size&#xD;
build.extra_flags=&#xD;
compiler.c.extra_flags=&#xD;
compiler.c.elf.extra_flags=&#xD;
compiler.S.extra_flags=&#xD;
compiler.cpp.extra_flags=&#xD;
compiler.ar.extra_flags=&#xD;
compiler.objcopy.eep.extra_flags=&#xD;
compiler.elf2hex.extra_flags=&#xD;
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"&#xD;
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"&#xD;
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"&#xD;
archive_file_path={build.path}/{archive_file}&#xD;
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"&#xD;
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm&#xD;
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"&#xD;
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"&#xD;
recipe.output.tmp_file={build.project_name}.hex&#xD;
recipe.output.save_file={build.project_name}.{build.variant}.hex&#xD;
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"&#xD;
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*&#xD;
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*&#xD;
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*&#xD;
preproc.includes.flags=-w -x c++ -M -MG -MP&#xD;
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"&#xD;
preproc.macros.flags=-w -x c++ -E -CC&#xD;
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"&#xD;
tools.avrdude.path={runtime.tools.avrdude.path}&#xD;
tools.avrdude.cmd.path={path}/bin/avrdude&#xD;
tools.avrdude.config.path={path}/etc/avrdude.conf&#xD;
tools.avrdude.upload.params.verbose=-v&#xD;
tools.avrdude.upload.params.quiet=-q -q&#xD;
tools.avrdude.upload.params.noverify=-V&#xD;
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} {upload.verify} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"&#xD;
tools.avrdude.program.params.verbose=-v&#xD;
tools.avrdude.program.params.quiet=-q -q&#xD;
tools.avrdude.program.params.noverify=-V&#xD;
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} {program.verify} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"&#xD;
tools.avrdude.erase.params.verbose=-v&#xD;
tools.avrdude.erase.params.quiet=-q -q&#xD;
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m&#xD;
tools.avrdude.bootloader.params.verbose=-v&#xD;
tools.avrdude.bootloader.params.quiet=-q -q&#xD;
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m&#xD;
tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu}&#xD;
build.usb_manufacturer="Unknown"&#xD;
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'&#xD;
vm.platform.root.path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\nctamhse.x5i\Micro Platforms\arduino16x&#xD;
avrisp.name=AVR ISP&#xD;
avrisp.communication=serial&#xD;
avrisp.protocol=stk500v1&#xD;
avrisp.program.protocol=stk500v1&#xD;
avrisp.program.tool=avrdude&#xD;
avrisp.program.extra_params=-P{serial.port}&#xD;
avrispmkii.name=AVRISP mkII&#xD;
avrispmkii.communication=usb&#xD;
avrispmkii.protocol=stk500v2&#xD;
avrispmkii.program.protocol=stk500v2&#xD;
avrispmkii.program.tool=avrdude&#xD;
avrispmkii.program.extra_params=-Pusb&#xD;
usbtinyisp.name=USBtinyISP&#xD;
usbtinyisp.protocol=usbtiny&#xD;
usbtinyisp.program.tool=avrdude&#xD;
usbtinyisp.program.extra_params=&#xD;
arduinoisp.name=ArduinoISP&#xD;
arduinoisp.protocol=arduinoisp&#xD;
arduinoisp.program.tool=avrdude&#xD;
arduinoisp.program.extra_params=&#xD;
usbasp.name=USBasp&#xD;
usbasp.communication=usb&#xD;
usbasp.protocol=usbasp&#xD;
usbasp.program.protocol=usbasp&#xD;
usbasp.program.tool=avrdude&#xD;
usbasp.program.extra_params=-Pusb&#xD;
parallel.name=Parallel Programmer&#xD;
parallel.protocol=dapa&#xD;
parallel.force=true&#xD;
parallel.program.tool=avrdude&#xD;
parallel.program.extra_params=-F&#xD;
arduinoasisp.name=Arduino as ISP&#xD;
arduinoasisp.communication=serial&#xD;
arduinoasisp.protocol=stk500v1&#xD;
arduinoasisp.speed=19200&#xD;
arduinoasisp.program.protocol=stk500v1&#xD;
arduinoasisp.program.speed=19200&#xD;
arduinoasisp.program.tool=avrdude&#xD;
arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}&#xD;
usbGemma.name=Arduino Gemma&#xD;
usbGemma.protocol=arduinogemma&#xD;
usbGemma.program.tool=avrdude&#xD;
usbGemma.program.extra_params=&#xD;
usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf&#xD;
stk500.name=Atmel STK500 development board&#xD;
stk500.communication=serial&#xD;
stk500.protocol=stk500&#xD;
stk500.program.protocol=stk500&#xD;
stk500.program.tool=avrdude&#xD;
stk500.program.extra_params=-P{serial.port}&#xD;
buspirate.name=BusPirate as ISP&#xD;
buspirate.communication=serial&#xD;
buspirate.protocol=buspirate&#xD;
buspirate.program.protocol=buspirate&#xD;
buspirate.program.tool=avrdude&#xD;
buspirate.program.extra_params=-P{serial.port}&#xD;
runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr&#xD;
runtime.tools.avrdude-6.0.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr&#xD;
runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr&#xD;
runtime.tools.avr-gcc-4.8.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr&#xD;
upload.maximum_size=30720&#xD;
upload.maximum_data_size=2048&#xD;
upload.speed=57600&#xD;
bootloader.high_fuses=0xDA&#xD;
bootloader.extended_fuses=0x05&#xD;
bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex&#xD;
build.mcu=atmega328p&#xD;
runtime.vm.boardinfo.id=diecimila_atmega328&#xD;
runtime.vm.boardinfo.name=diecimila_atmega328&#xD;
runtime.vm.boardinfo.desc=Arduino Duemilanove or Diecimila w/ ATmega328&#xD;
runtime.vm.boardinfo.src_location=C:\Program Files (x86)\Arduino\hardware\arduino\avr&#xD;
ide.hint=For use with Arduino.cc 1.6.2+ ide&#xD;
ide.location.key=Arduino16x&#xD;
ide.location.ide.winreg=Arduino 1.6.x Application&#xD;
ide.location.sketchbook.winreg=Arduino 1.6.x Sketchbook&#xD;
ide.location.sketchbook.preferences=sketchbook.path&#xD;
ide.default.revision_name=1.6.9&#xD;
ide.default.version=10609&#xD;
ide.default.package=arduino&#xD;
ide.default.platform=avr&#xD;
ide.multiplatform=true&#xD;
ide.includes=arduino.h&#xD;
ide.exe_name=arduino&#xD;
ide.platformswithoutpackage=false&#xD;
ide.includes.fallback=wprogram.h&#xD;
ide.extension=ino&#xD;
ide.extension.fallback=pde&#xD;
ide.versionGTEQ=160&#xD;
ide.exe=arduino.exe&#xD;
ide.hosts=atmel&#xD;
ide.url=http://arduino.cc/en/Main/Software�%0Aide.help.reference.path=reference\arduino.cc\en\Reference�%0Aide.help.reference.path2=reference\www.arduino.cc\en\Reference�%0Aide.help.reference.serial=reference\www.arduino.cc\en\Serial�%0Avm.debug=true�%0Asoftware=ARDUINO�%0Assh.user.name=root�%0Assh.user.default.password=arduino�%0Assh.host.wwwfiles.path=/www/sd�%0Abuild.working_directory={runtime.ide.path}�%0Aide.location.preferences.portable={runtime.ide.path}\portable�%0Aide.location.preferences=%VM_APPDATA_LOCAL%\arduino15\preferences.txt�%0Aide.location.preferences_fallback=%VM_APPDATA_ROAMING%\arduino15\preferences.txt�%0Aide.location.contributions=%VM_APPDATA_LOCAL%\arduino15�%0Aide.location.contributions_fallback=%VM_APPDATA_ROAMING%\arduino15�%0Aide.contributions.boards.allow=true�%0Aide.contributions.boards.ignore_unless_rewrite_found=true�%0Aide.contributions.libraries.allow=true�%0Aide.contributions.boards.support.urls.wiki=https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls�%0Aide.create_platforms_from_boardsTXT.teensy=build.core�%0Aide.appid=arduino16x�%0Alocation.sketchbook=C:\Users\s133140\Documents\Arduino�%0Avm.core.include=arduino.h�%0Avm.boardsource.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr&#xD;
runtime.platform.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr&#xD;
vm.platformname.name=avr&#xD;
build.arch=AVR&#xD;
build.architecture=avr&#xD;
vmresolved.compiler.path=C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\&#xD;
vmresolved.tools.path=C:\Program Files (x86)\Arduino\hardware\tools\avr&#xD;
" visualmicro.application.name="arduino16x" arduino.build.mcu="atmega328p" arduino.upload.protocol="arduino" arduino.build.f_cpu="16000000L" arduino.board.desc="Arduino Duemilanove or Diecimila w/ ATmega328" arduino.board.name="diecimila_atmega328" arduino.upload.port="COM4" visualmicro.platform.name="avr" arduino.build.core="arduino" />
    </VisualStudio>
  </ProjectExtensions>
</Project>

BaseStation.vcxproj.filters

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Filter Include="Source Files">
      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
    </Filter>
    <Filter Include="Header Files">
      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
    </Filter>
    <Filter Include="Resource Files">
      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <None Include="BaseStation.ino" />
    <None Include="..\Shared\nrf24communication.ino" />
    <None Include="menu.ino" />
    <None Include="..\Shared\CommandBook.ino" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="CustomNumericMenuItem.h">
      <Filter>Header Files</Filter>
    </ClInclude>
    <ClInclude Include="__vm\.BaseStation.vsarduino.h">
      <Filter>Header Files</Filter>
    </ClInclude>
  </ItemGroup>
</Project>

CustomNumericMenuItem.h

/*
 * An example of a custom NumericMenuItem.
 * It tries to display some ASCII graphics in edit mode.
 * This can be useful if you want to give the end user an overview of the value limits.
 * 
 * Copyright (c) 2016 arduino-menusystem
 * Licensed under the MIT license (see LICENSE)
 */

#ifndef _CUSTOMNUMERICMENUITEM_H
#define _CUSTOMNUMERICMENUITEM_H

#include <MenuSystem.h>

class CustomNumericMenuItem : public NumericMenuItem
{
public:
    /**
     * @param width the width of the edit mode 'ASCII graphics', must be > 1
     * @param name The name of the menu item.
     * @param value Default value.
     * @param minValue The minimum value.
     * @param maxValue The maximum value.
     * @param increment How much the value should be incremented by.
     * @param valueFormatter The custom formatter. If NULL the String float
     *                       formatter will be used.
     */
    CustomNumericMenuItem(uint8_t width, const char* name, float value,
                          float minValue, float maxValue, float increment=1.0,
                          ValueFormatter_t value_formatter=NULL)
    : NumericMenuItem(name, value, minValue, maxValue, increment,
                      value_formatter),
      _width(width)
    {
    }

    virtual String& get_composite_name(String& buffer) const
    {
        if (is_editing_value())
        {
            // Only display the ASCII graphics in edit mode.

            // make room for a ' ' at the end and the terminating 0
            char graphics[_width + 2];
            // fill the string with '-'
            for (int i = 0; i <_width; i++)
                graphics[i] = '-';
            // insert a '|' at the relative _value position
            graphics[int((_width - 1) * (_value - _minValue) / (_maxValue - _minValue))] = '|';
            graphics[_width] = ' ';
            graphics[_width+1] = 0;
            buffer = graphics;

            if (_value_formatter != NULL)
                buffer += _value_formatter(_value);
            else
                buffer += _value;
            return buffer;
        }
        else
        {
            // Non edit mode: Let parent class handle this
            return NumericMenuItem::get_composite_name(buffer);
        }
    }

private:
    const uint8_t _width;
};

#endif // _CUSTOMNUMERICMENUITEM_H

menu.ino

/*
* serial_nav.ino - Example code using the menu system library
*
* This example shows the menu system being controlled over the serial port.
*
* Copyright (c) 2015, 2016 arduino-menusystem
* Licensed under the MIT license (see LICENSE)
*/

// Menu callback function

// writes the (int) value of a float into a char buffer.
const String format_int(const float value)
{
	return String((int)value);
}

// writes the value of a float into a char buffer.
const String format_float(const float value)
{
	return String(value);
}

const String format_type(const float value)
{
	String buffer;

	switch ((int)value)
	{
	case 0:
		buffer += "Go to plant";
		tempCommand.command = 't';
		break;
	case 1:
		buffer += "Grab/cut plant";
		tempCommand.command = 'g';
		break;
	case 2:
		buffer += "Clean plant";
		tempCommand.command = 'c';
		break;
	case 3:
		buffer += "Return home";
		tempCommand.command = 'r';
		break;
	case 4:
		buffer += "Move shaft up";
		tempCommand.command = 'W';
		break;
	case 5:
		buffer += "Move shaft down";
		tempCommand.command = 'S';
		break;
	case 6:
		buffer += "Extend arm";
		tempCommand.command = 'D';
		break;
	case 7:
		buffer += "Retract arm";
		tempCommand.command = 'A';
		break;
	case 8:
		buffer += "Move grabber";
		tempCommand.command = 'i';
		break;
	case 9:
		buffer += "Move arm";
		tempCommand.command = 'u';
		break;
	case 10:
		buffer += "Delay";
		tempCommand.command = 'd';
		break;
	case 11:
		buffer += "Move";
		tempCommand.command = 'm';
		break;
	default:
		buffer += "undef";
		break;
	}

	return buffer;
}

const String format_value(const float value)
{
	tempCommand.value = (int)value;

	switch (tempCommand.command) {
	case 't':
		return "plant " + String(tempCommand.value);
	case 'g':
	case 'c':
	case 'r':
	case 'W':
	case 'A':
	case 'S':
	case 'D':
		return "N/A";
	case 'm':
		return String(tempCommand.value * 100) + " steps";
	case 'u':
		return String(tempCommand.value * 10) + " degrees";
	case 'i':
		return String(tempCommand.value * 10) + " degrees";
	case 'd':
		return String(tempCommand.value * 500) + " ms";
	default:
		return "undef";
	}
}

void on_add_selected(MenuItem* p_menu_item)
{
	if (!addCommand(commandos, tempCommand.command, tempCommand.value)) {
		Serial.println();
		Serial.println(F("ERROR:"));
		Serial.println(F("Command book full!"));
		delay(1000);
	}
}

void on_del_selected(MenuItem* p_menu_item)
{
	if (!deleteCommand(commandos)) {
		Serial.println();
		Serial.println(F("ERROR:"));
		Serial.println(F("No commands to delete!"));
		delay(1000);
	}
}

void on_send_selected(MenuItem* p_menu_item)
{
	if (!sendCommand(commandos)) {
		Serial.println(F("ERROR:"));
		Serial.println(F("Could not send commands"));
	}

	delay(1000);
}

void on_demo_selected(MenuItem* p_menu_item) {
	int c = countCommand(commandos);
	for (int n = 0; n < c; n += 1) {
		deleteCommand(commandos);
	}
	addCommand(commandos, 't', 1);
	addCommand(commandos, 'd', 3000);
	addCommand(commandos, 'W', 0);
	addCommand(commandos, 'S', 0);
	addCommand(commandos, 'd', 3000);
	addCommand(commandos, 'D', 0);
	addCommand(commandos, 'A', 0);
	addCommand(commandos, 'd', 3000);
	addCommand(commandos, 'c', 0);
}

void on_help_selected(MenuItem* p_menu_item)
{
	display_help();
	delay(3000);
}

void on_about_selected(MenuItem* p_menu_item)
{
	Serial.println(F("This is the Base Station interface"));
	Serial.println(F("which controls the seaweed harvesting"));
	Serial.println(F("robot."));
	Serial.println();
	Serial.println(F("Refer to the USE Social Robots"));
	Serial.println(F("2015/2016 Q4 - group 5 wiki for"));
	Serial.println(F("more information."));
	delay(5000);
}


void on_status_selected(MenuItem* p_menu_item)
{
	Serial.println(F("Returning status of the robot:"));
	Serial.println(F("------------------------------"));
	Serial.print(F("Temperature: "));
	Serial.println(F("80"));
	Serial.print(F("Max speed (RPM): "));
	Serial.println(F("300"));
	Serial.print(F("Acceleration: "));
	Serial.println(F("80"));
	Serial.print(F("Motor1 "));
	Serial.println(F("running"));
	Serial.print(F("Motor2: "));
	Serial.println(F("not running"));
	Serial.print(F("Motor3: "));
	Serial.println(F("not running"));
	Serial.print(F("ServoArm (degrees):"));
	Serial.println(F("167"));
	Serial.print(F("MotorGrab: "));
	Serial.println(F("086"));
	delay(3000);
}

void on_back_item_selected(MenuItem* p_menu_item)
{
	//
}

void display_menu(Menu* p_menu)
{
	Serial.write(27);       // ESC command
	Serial.print("[2J");    // clear screen command
	Serial.write(27);
	Serial.print("[H");     // cursor to home command
	Serial.print(F("--[ "));
	Serial.print(p_menu->get_name());
	Serial.println(F(" ]--"));

	String buffer;
	MenuComponent const* cp_menu_sel = p_menu->get_current_component();
	for (int i = 0; i < p_menu->get_num_menu_components(); ++i)
	{
		MenuComponent const* cp_m_comp = p_menu->get_menu_component(i);
		if (cp_menu_sel == cp_m_comp)
			Serial.print("> ");
		else
			Serial.print("  ");
		Serial.print(cp_m_comp->get_composite_name(buffer));

		Serial.println("");
	}

	if (p_menu == &muCommand) {
		Serial.println();
		printCommand(commandos);
	}
}


void display_help() {
	Serial.println(F("***************"));
	Serial.println(F("w,^:      go to previus item (up)"));
	Serial.println(F("s,v:      go to next item (down)"));
	Serial.println(F("a,esc:    go back (right)"));
	Serial.println(F("d,enter:  select \"selected\" item"));
	Serial.println(F("h,?:      print this help"));
	Serial.println(F("***************"));
}

void serial_handler()
{
	char inChar, inChar2;

	if ((inChar = Serial.read()) > 0)
	{
		switch (inChar)
		{
		case 27: // control characters
			delay(25);
			if ((inChar2 = Serial.read()) > 0) {
				switch (inChar2) {
				case 91: // escaped control characters
					delay(25);
					switch (Serial.read()) {
					case 65: // up
					case 90: // shift+tab
					case 68: // left
						ms.prev();
						ms.display();
						break;
					case 66: // down
					case 67: // right
						ms.next();
						ms.display();
						break;
					}
					break;
				case 49: // function keys, just display help.
					ms.display();
					display_help();
					break;
				}
			}
			else { // escape
				ms.back();
				ms.display();
			}
			break;

		case 'w': // w
			// Previous item
			ms.prev();
			ms.display();
			break;
		case 's': // s
		case 9: // tab
			// Next item
			ms.next();
			ms.display();
			break;
		case 127: // backspace
		case 'a': // a
		case 3: // Ctrl+C
			// Back presed
			ms.back();
			ms.display();
			break;
		case 0x0D: // enter
		case ' ': // space
		case 'd': // d
			// Select presed
			ms.select();
			ms.display();
			break;
		case '?': // ?
		case 0x0F: // F1
		case 'h': // h
			// Display help
			ms.display();
			display_help();
			break;
		default:
			break;
		}
	}
}

Robot

Shared

CommandBook.ino

int countCommand(CommandBook *book)
{
	int c = 0;
	while (book[c].command != NULL && c < BOOKSIZE)
		c++;
	return c;
}

bool addCommand(CommandBook *book, char command, int value)
{
	int c = countCommand(book);
	if (c >= BOOKSIZE) {
		return false;
	}
	book[c].command = command;
	book[c].value = value;
	return true;
}

#ifndef BASESTATION
void runCommand(CommandBook *book)
{
	int c = countCommand(book);
	for (int i = 0; i < c; i++)
	{
		switch (book[i].command)
		{
		case 't':
		{
			r_MovePlant(book[i].value);
			break;
		}
		case 'c':
		{
			r_Cut();
			break;
		}
		case 'g':
		{
			r_Grab();
			break;
		}
		case 'r':
		{
			r_MovePlant(0);
			break;
		}
		case 'W':
		{
			shaftStepper.enableOutputs();
			shaftStepper.moveTo(900);
			shaftStepper.runToPosition();
			shaftStepper.disableOutputs();
			break;
		}
		case 'S':
		{
			shaftStepper.enableOutputs();
			shaftStepper.moveTo(0);
			shaftStepper.runToPosition();
			//shaftStepper.disableOutputs(); //Keeping the shaft on it's place ONE TIME ONLY FOR DEMO (MABYE 2-3, but check temperature)
			break;
		}
		case 'D':
		{
			armStepper.enableOutputs();
			armStepper.moveTo(750);
			armStepper.runToPosition();
			armStepper.disableOutputs();
			break;
		}
		case 'A':
		{
			armStepper.enableOutputs();
			armStepper.moveTo(0);
			armStepper.runToPosition();
			armStepper.disableOutputs();
			break;
		}
		case 'u':
		{
			armTurnPos(book[i].value);
			break;
		}
		case 'i':
		{
			grabberTurnPos(book[i].value );
			break;
		}
		case 'd':
		{
			delay(book[i].value);
			break;
		}
		case 'm':
		{
			kopStepper.move(book[i].value);
			break;
		}
		default:		// "undef"
			break;
		book[i].command = NULL;
		book[i].value = NULL;

		}
		Serial.print('-');
		Serial.print(book[i].command);
		Serial.print('\t');
		Serial.print(book[i].value);
		Serial.println("\tDone");
	}
	Serial.println("All commands done.");
}
#endif // BASESTATION

void printCommand(CommandBook *book)
{
	int c = countCommand(book);
	Serial.println(F("Commandos in book:"));
	for (int i = 0; i < c; i++)
	{
		Serial.print('-');
		Serial.print(book[i].command);
		Serial.print('\t');
		Serial.println(book[i].value);
	}
	Serial.println(F("-END OF COMMANDS"));
}

bool deleteCommand(CommandBook *book)
{
	int c = countCommand(book);
	if (c == 0) {
		return false;
	}
	book[c - 1].command = NULL;
	book[c - 1].value = NULL;
	return true;
}

bool sendCommand(CommandBook *book) {
	int c = countCommand(book);
	uint8_t* buf = new uint8_t[BOOKSIZE * 3 + 1];
	buf[0] = c;
	for (int n = 0; n < c; n += 1) {
		buf[(n * 3) + 1] = (uint8_t) book[n].command;
		buf[(n * 3) + 2] = (uint8_t) (book[n].value >> 8);
		buf[(n * 3) + 3] = (uint8_t)(book[n].value & 0xFF);
	}

	Serial.println(F("Sending message..."));
	bool result = nrf24SendMessage(buf, c * 3 + 1);
	delete buf;
	return result;
}

nrf24communication.ino

#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_NRF24 driver;
// RH_NRF24 driver(8, 7);   // For RFM73 on Anarduino Mini

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver);

bool isServer;
uint8_t _nrf24_buf[32];
uint8_t _nrf24_blen = 0;

bool nrf24Initialize(bool server) {
	Serial.print(F(" -Initiating radio:\t"));
	if (manager.init()) {
		Serial.println(F("OK"));
		Serial.print(F(" -Setting radio channel:\t"));
		if (!driver.setChannel(1)) {
			return false;
			Serial.println(F("setChannel failed"));
		}
		else {
			Serial.println(F("Channel 1"));
		}
		Serial.print(F(" -Setting radio settings:\t"));
		if (!driver.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm)) {
			Serial.println(F("setRF failed"));
			return false;
		}
		else {
			Serial.println(F("2Mbps, 0dBm"));
		}
	}
	else {
		Serial.println(F("FAILED!!!"));
		return false;
	}

	if (server) {
		manager.setThisAddress(SERVER_ADDRESS);
	}
	else {
		manager.setThisAddress(CLIENT_ADDRESS);
	}
	isServer = server;

	return true;
}

bool compareBuffers(uint8_t *buf1, uint8_t *buf2, uint8_t len) {
	for (uint8_t n = 0; n < len; n += 1) {
		if (buf1[n] != buf2[n]) {
			return false;
		}
	}
	return true;
}

void nrf24DebugPrint(char* str) {
	if (true) {
		Serial.println(str);
	}
}

bool nrf24ReceiveMessage(uint8_t* str, uint8_t* len) {
	uint8_t from;
	if (!manager.waitAvailableTimeout(3000)) {
		return false;
	}

	if (!manager.recvfromAck(str, len, &from)) {
		debugln(F("Couldn't receive message"));
		return false;
	}
	uint8_t* _nrf24_buf = (uint8_t *) "OK";
	if (manager.sendtoWait(_nrf24_buf, 3, from)) {
		return true;
	}
	debugln(F("Did not receive acknowledgement on 'OK'"));
	return false;

}

bool nrf24SendMessage(uint8_t* str, uint8_t len) {
	uint8_t address = SERVER_ADDRESS;
	if (isServer) {
		address = CLIENT_ADDRESS;
	}

	if (!manager.sendtoWait(str, len, address)) {
		debugln(F("No acknowledgement received"));
		return false;
	}

	if (!manager.waitAvailableTimeout(1000)) {
		return false;
	}

	uint8_t from;
	if (manager.recvfromAck(_nrf24_buf, &_nrf24_blen, &from)) {
		return true;
	}
	debugln(F("Could not receive 'OK'"));
	return false;
}

bool radioSleep()
{
	driver.setModeIdle();	
	if (driver.sleep())
	{
		return true;
	}
	else
		return false;
}

Solution.sln

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Robot", "Robot\Robot.vcxproj", "{E107B750-A178-4195-BCF5-E1DADA3D52A1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseStation", "BaseStation\BaseStation.vcxproj", "{194F20BC-E954-42EA-99FE-BA4D6577DDA3}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Debug|x64.ActiveCfg = Debug|Win32
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Debug|x86.ActiveCfg = Debug|Win32
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Debug|x86.Build.0 = Debug|Win32
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Release|x64.ActiveCfg = Release|Win32
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Release|x86.ActiveCfg = Release|Win32
		{E107B750-A178-4195-BCF5-E1DADA3D52A1}.Release|x86.Build.0 = Release|Win32
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Debug|x64.ActiveCfg = Debug|x64
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Debug|x64.Build.0 = Debug|x64
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Debug|x86.ActiveCfg = Debug|Win32
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Debug|x86.Build.0 = Debug|Win32
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Release|x64.ActiveCfg = Release|x64
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Release|x64.Build.0 = Release|x64
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Release|x86.ActiveCfg = Release|Win32
		{194F20BC-E954-42EA-99FE-BA4D6577DDA3}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal