PRE2015 4 Groep5 Code: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 16: | Line 16: | ||
===BaseStation=== | ===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
upload.tool=avrdude
upload.protocol=arduino
bootloader.tool=avrdude
bootloader.low_fuses=0xFF
bootloader.unlock_bits=0x3F
bootloader.lock_bits=0x0F
build.f_cpu=16000000L
build.board=AVR_DUEMILANOVE
build.core=arduino
build.variant=standard
menu.cpu.atmega328=ATmega328
menu.cpu.atmega328.upload.maximum_size=30720
menu.cpu.atmega328.upload.maximum_data_size=2048
menu.cpu.atmega328.upload.speed=57600
menu.cpu.atmega328.bootloader.high_fuses=0xDA
menu.cpu.atmega328.bootloader.extended_fuses=0x05
menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
menu.cpu.atmega328.build.mcu=atmega328p
menu.cpu.atmega168=ATmega168
menu.cpu.atmega168.upload.maximum_size=14336
menu.cpu.atmega168.upload.maximum_data_size=1024
menu.cpu.atmega168.upload.speed=19200
menu.cpu.atmega168.bootloader.high_fuses=0xdd
menu.cpu.atmega168.bootloader.extended_fuses=0x00
menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
menu.cpu.atmega168.build.mcu=atmega168
runtime.ide.path=C:\Program Files (x86)\Arduino
build.system.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr\system
runtime.ide.version=10609
target_package=arduino
target_platform=avr
runtime.hardware.path=C:\Program Files (x86)\Arduino\hardware\arduino
originalid=diecimila
intellisense.tools.path={runtime.tools.avr-gcc.path}/
intellisense.include.paths={intellisense.tools.path}avr/include/;{intellisense.tools.path}/avr/include/avr/;{intellisense.tools.path}lib\gcc\avr\4.8.1\include
tools.atprogram.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
tools.atprogram.cmd.setwinpath=true
tools.atprogram.program.params.verbose=-v
tools.atprogram.program.params.quiet=-q
tools.atprogram.program.pattern="{cmd.path}" -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"
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"
tools.atprogram.erase.params.verbose=-v
tools.atprogram.erase.params.quiet=-q
tools.atprogram.bootloader.params.verbose=-v
tools.atprogram.bootloader.params.quiet=-q
tools.atprogram.bootloader.pattern="{cmd.path}" -d {build.mcu} {bootloader.verbose} program -c -f "{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}"
version=1.6.11
compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
compiler.path={runtime.tools.avr-gcc.path}/bin/
compiler.c.cmd=avr-gcc
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
compiler.c.elf.cmd=avr-gcc
compiler.S.flags=-c -g -x assembler-with-cpp
compiler.cpp.cmd=avr-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
compiler.ar.cmd=avr-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=avr-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=avr-objcopy
compiler.ldflags=
compiler.size.cmd=avr-size
build.extra_flags=
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=
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}"
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}"
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}"
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
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
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"
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"
recipe.output.tmp_file={build.project_name}.hex
recipe.output.save_file={build.project_name}.{build.variant}.hex
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
preproc.includes.flags=-w -x c++ -M -MG -MP
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}"
preproc.macros.flags=-w -x c++ -E -CC
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}"
tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd.path={path}/bin/avrdude
tools.avrdude.config.path={path}/etc/avrdude.conf
tools.avrdude.upload.params.verbose=-v
tools.avrdude.upload.params.quiet=-q -q
tools.avrdude.upload.params.noverify=-V
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"
tools.avrdude.program.params.verbose=-v
tools.avrdude.program.params.quiet=-q -q
tools.avrdude.program.params.noverify=-V
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"
tools.avrdude.erase.params.verbose=-v
tools.avrdude.erase.params.quiet=-q -q
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
tools.avrdude.bootloader.params.verbose=-v
tools.avrdude.bootloader.params.quiet=-q -q
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
tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu}
build.usb_manufacturer="Unknown"
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
vm.platform.root.path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\nctamhse.x5i\Micro Platforms\arduino16x
avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v1
avrisp.program.protocol=stk500v1
avrisp.program.tool=avrdude
avrisp.program.extra_params=-P{serial.port}
avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
avrispmkii.program.protocol=stk500v2
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=-Pusb
usbtinyisp.name=USBtinyISP
usbtinyisp.protocol=usbtiny
usbtinyisp.program.tool=avrdude
usbtinyisp.program.extra_params=
arduinoisp.name=ArduinoISP
arduinoisp.protocol=arduinoisp
arduinoisp.program.tool=avrdude
arduinoisp.program.extra_params=
usbasp.name=USBasp
usbasp.communication=usb
usbasp.protocol=usbasp
usbasp.program.protocol=usbasp
usbasp.program.tool=avrdude
usbasp.program.extra_params=-Pusb
parallel.name=Parallel Programmer
parallel.protocol=dapa
parallel.force=true
parallel.program.tool=avrdude
parallel.program.extra_params=-F
arduinoasisp.name=Arduino as ISP
arduinoasisp.communication=serial
arduinoasisp.protocol=stk500v1
arduinoasisp.speed=19200
arduinoasisp.program.protocol=stk500v1
arduinoasisp.program.speed=19200
arduinoasisp.program.tool=avrdude
arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}
usbGemma.name=Arduino Gemma
usbGemma.protocol=arduinogemma
usbGemma.program.tool=avrdude
usbGemma.program.extra_params=
usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf
stk500.name=Atmel STK500 development board
stk500.communication=serial
stk500.protocol=stk500
stk500.program.protocol=stk500
stk500.program.tool=avrdude
stk500.program.extra_params=-P{serial.port}
buspirate.name=BusPirate as ISP
buspirate.communication=serial
buspirate.protocol=buspirate
buspirate.program.protocol=buspirate
buspirate.program.tool=avrdude
buspirate.program.extra_params=-P{serial.port}
runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
runtime.tools.avrdude-6.0.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
runtime.tools.avr-gcc-4.8.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
upload.maximum_size=30720
upload.maximum_data_size=2048
upload.speed=57600
bootloader.high_fuses=0xDA
bootloader.extended_fuses=0x05
bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
build.mcu=atmega328p
runtime.vm.boardinfo.id=diecimila_atmega328
runtime.vm.boardinfo.name=diecimila_atmega328
runtime.vm.boardinfo.desc=Arduino Duemilanove or Diecimila w/ ATmega328
runtime.vm.boardinfo.src_location=C:\Program Files (x86)\Arduino\hardware\arduino\avr
ide.hint=For use with Arduino.cc 1.6.2+ ide
ide.location.key=Arduino16x
ide.location.ide.winreg=Arduino 1.6.x Application
ide.location.sketchbook.winreg=Arduino 1.6.x Sketchbook
ide.location.sketchbook.preferences=sketchbook.path
ide.default.revision_name=1.6.9
ide.default.version=10609
ide.default.package=arduino
ide.default.platform=avr
ide.multiplatform=true
ide.includes=arduino.h
ide.exe_name=arduino
ide.platformswithoutpackage=false
ide.includes.fallback=wprogram.h
ide.extension=ino
ide.extension.fallback=pde
ide.versionGTEQ=160
ide.exe=arduino.exe
ide.hosts=atmel
ide.url=http://arduino.cc/en/Main/Software
ide.help.reference.path=reference\arduino.cc\en\Reference
ide.help.reference.path2=reference\www.arduino.cc\en\Reference
ide.help.reference.serial=reference\www.arduino.cc\en\Serial
vm.debug=true
software=ARDUINO
ssh.user.name=root
ssh.user.default.password=arduino
ssh.host.wwwfiles.path=/www/sd
build.working_directory={runtime.ide.path}
ide.location.preferences.portable={runtime.ide.path}\portable
ide.location.preferences=%VM_APPDATA_LOCAL%\arduino15\preferences.txt
ide.location.preferences_fallback=%VM_APPDATA_ROAMING%\arduino15\preferences.txt
ide.location.contributions=%VM_APPDATA_LOCAL%\arduino15
ide.location.contributions_fallback=%VM_APPDATA_ROAMING%\arduino15
ide.contributions.boards.allow=true
ide.contributions.boards.ignore_unless_rewrite_found=true
ide.contributions.libraries.allow=true
ide.contributions.boards.support.urls.wiki=https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls
ide.create_platforms_from_boardsTXT.teensy=build.core
ide.appid=arduino16x
location.sketchbook=C:\Users\s133140\Documents\Arduino
vm.core.include=arduino.h
vm.boardsource.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr
runtime.platform.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr
vm.platformname.name=avr
build.arch=AVR
build.architecture=avr
vmresolved.compiler.path=C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\
vmresolved.tools.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
" 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=== | ===Robot=== | ||
===Shared=== | ===Shared=== |
Revision as of 17:00, 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
 upload.tool=avrdude
 upload.protocol=arduino
 bootloader.tool=avrdude
 bootloader.low_fuses=0xFF
 bootloader.unlock_bits=0x3F
 bootloader.lock_bits=0x0F
 build.f_cpu=16000000L
 build.board=AVR_DUEMILANOVE
 build.core=arduino
 build.variant=standard
 menu.cpu.atmega328=ATmega328
 menu.cpu.atmega328.upload.maximum_size=30720
 menu.cpu.atmega328.upload.maximum_data_size=2048
 menu.cpu.atmega328.upload.speed=57600
 menu.cpu.atmega328.bootloader.high_fuses=0xDA
 menu.cpu.atmega328.bootloader.extended_fuses=0x05
 menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
 menu.cpu.atmega328.build.mcu=atmega328p
 menu.cpu.atmega168=ATmega168
 menu.cpu.atmega168.upload.maximum_size=14336
 menu.cpu.atmega168.upload.maximum_data_size=1024
 menu.cpu.atmega168.upload.speed=19200
 menu.cpu.atmega168.bootloader.high_fuses=0xdd
 menu.cpu.atmega168.bootloader.extended_fuses=0x00
 menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
 menu.cpu.atmega168.build.mcu=atmega168
 runtime.ide.path=C:\Program Files (x86)\Arduino
 build.system.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr\system
 runtime.ide.version=10609
 target_package=arduino
 target_platform=avr
 runtime.hardware.path=C:\Program Files (x86)\Arduino\hardware\arduino
 originalid=diecimila
 intellisense.tools.path={runtime.tools.avr-gcc.path}/
 intellisense.include.paths={intellisense.tools.path}avr/include/;{intellisense.tools.path}/avr/include/avr/;{intellisense.tools.path}lib\gcc\avr\4.8.1\include
 tools.atprogram.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
 tools.atprogram.cmd.setwinpath=true
 tools.atprogram.program.params.verbose=-v
 tools.atprogram.program.params.quiet=-q
 tools.atprogram.program.pattern="{cmd.path}" -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"
 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"
 tools.atprogram.erase.params.verbose=-v
 tools.atprogram.erase.params.quiet=-q
 tools.atprogram.bootloader.params.verbose=-v
 tools.atprogram.bootloader.params.quiet=-q
 tools.atprogram.bootloader.pattern="{cmd.path}" -d {build.mcu} {bootloader.verbose} program -c -f "{runtime.ide.path}/hardware/arduino/avr/bootloaders/{bootloader.file}"
 version=1.6.11
 compiler.warning_flags=-w
 compiler.warning_flags.none=-w
 compiler.warning_flags.default=
 compiler.warning_flags.more=-Wall
 compiler.warning_flags.all=-Wall -Wextra
 compiler.path={runtime.tools.avr-gcc.path}/bin/
 compiler.c.cmd=avr-gcc
 compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD
 compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
 compiler.c.elf.cmd=avr-gcc
 compiler.S.flags=-c -g -x assembler-with-cpp
 compiler.cpp.cmd=avr-g++
 compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
 compiler.ar.cmd=avr-ar
 compiler.ar.flags=rcs
 compiler.objcopy.cmd=avr-objcopy
 compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
 compiler.elf2hex.flags=-O ihex -R .eeprom
 compiler.elf2hex.cmd=avr-objcopy
 compiler.ldflags=
 compiler.size.cmd=avr-size
 build.extra_flags=
 compiler.c.extra_flags=
 compiler.c.elf.extra_flags=
 compiler.S.extra_flags=
 compiler.cpp.extra_flags=
 compiler.ar.extra_flags=
 compiler.objcopy.eep.extra_flags=
 compiler.elf2hex.extra_flags=
 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}"
 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}"
 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}"
 archive_file_path={build.path}/{archive_file}
 recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
 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
 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"
 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"
 recipe.output.tmp_file={build.project_name}.hex
 recipe.output.save_file={build.project_name}.{build.variant}.hex
 recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
 recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
 recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
 recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
 preproc.includes.flags=-w -x c++ -M -MG -MP
 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}"
 preproc.macros.flags=-w -x c++ -E -CC
 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}"
 tools.avrdude.path={runtime.tools.avrdude.path}
 tools.avrdude.cmd.path={path}/bin/avrdude
 tools.avrdude.config.path={path}/etc/avrdude.conf
 tools.avrdude.upload.params.verbose=-v
 tools.avrdude.upload.params.quiet=-q -q
 tools.avrdude.upload.params.noverify=-V
 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"
 tools.avrdude.program.params.verbose=-v
 tools.avrdude.program.params.quiet=-q -q
 tools.avrdude.program.params.noverify=-V
 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"
 tools.avrdude.erase.params.verbose=-v
 tools.avrdude.erase.params.quiet=-q -q
 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
 tools.avrdude.bootloader.params.verbose=-v
 tools.avrdude.bootloader.params.quiet=-q -q
 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
 tools.avrdude_remote.upload.pattern=/usr/bin/run-avrdude /tmp/sketch.hex {upload.verbose} -p{build.mcu}
 build.usb_manufacturer="Unknown"
 build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
 vm.platform.root.path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\nctamhse.x5i\Micro Platforms\arduino16x
 avrisp.name=AVR ISP
 avrisp.communication=serial
 avrisp.protocol=stk500v1
 avrisp.program.protocol=stk500v1
 avrisp.program.tool=avrdude
 avrisp.program.extra_params=-P{serial.port}
 avrispmkii.name=AVRISP mkII
 avrispmkii.communication=usb
 avrispmkii.protocol=stk500v2
 avrispmkii.program.protocol=stk500v2
 avrispmkii.program.tool=avrdude
 avrispmkii.program.extra_params=-Pusb
 usbtinyisp.name=USBtinyISP
 usbtinyisp.protocol=usbtiny
 usbtinyisp.program.tool=avrdude
 usbtinyisp.program.extra_params=
 arduinoisp.name=ArduinoISP
 arduinoisp.protocol=arduinoisp
 arduinoisp.program.tool=avrdude
 arduinoisp.program.extra_params=
 usbasp.name=USBasp
 usbasp.communication=usb
 usbasp.protocol=usbasp
 usbasp.program.protocol=usbasp
 usbasp.program.tool=avrdude
 usbasp.program.extra_params=-Pusb
 parallel.name=Parallel Programmer
 parallel.protocol=dapa
 parallel.force=true
 parallel.program.tool=avrdude
 parallel.program.extra_params=-F
 arduinoasisp.name=Arduino as ISP
 arduinoasisp.communication=serial
 arduinoasisp.protocol=stk500v1
 arduinoasisp.speed=19200
 arduinoasisp.program.protocol=stk500v1
 arduinoasisp.program.speed=19200
 arduinoasisp.program.tool=avrdude
 arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}
 usbGemma.name=Arduino Gemma
 usbGemma.protocol=arduinogemma
 usbGemma.program.tool=avrdude
 usbGemma.program.extra_params=
 usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf
 stk500.name=Atmel STK500 development board
 stk500.communication=serial
 stk500.protocol=stk500
 stk500.program.protocol=stk500
 stk500.program.tool=avrdude
 stk500.program.extra_params=-P{serial.port}
 buspirate.name=BusPirate as ISP
 buspirate.communication=serial
 buspirate.protocol=buspirate
 buspirate.program.protocol=buspirate
 buspirate.program.tool=avrdude
 buspirate.program.extra_params=-P{serial.port}
 runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
 runtime.tools.avrdude-6.0.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
 runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
 runtime.tools.avr-gcc-4.8.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
 upload.maximum_size=30720
 upload.maximum_data_size=2048
 upload.speed=57600
 bootloader.high_fuses=0xDA
 bootloader.extended_fuses=0x05
 bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
 build.mcu=atmega328p
 runtime.vm.boardinfo.id=diecimila_atmega328
 runtime.vm.boardinfo.name=diecimila_atmega328
 runtime.vm.boardinfo.desc=Arduino Duemilanove or Diecimila w/ ATmega328
 runtime.vm.boardinfo.src_location=C:\Program Files (x86)\Arduino\hardware\arduino\avr
 ide.hint=For use with Arduino.cc 1.6.2+ ide
 ide.location.key=Arduino16x
 ide.location.ide.winreg=Arduino 1.6.x Application
 ide.location.sketchbook.winreg=Arduino 1.6.x Sketchbook
 ide.location.sketchbook.preferences=sketchbook.path
 ide.default.revision_name=1.6.9
 ide.default.version=10609
 ide.default.package=arduino
 ide.default.platform=avr
 ide.multiplatform=true
 ide.includes=arduino.h
 ide.exe_name=arduino
 ide.platformswithoutpackage=false
 ide.includes.fallback=wprogram.h
 ide.extension=ino
 ide.extension.fallback=pde
 ide.versionGTEQ=160
 ide.exe=arduino.exe
 ide.hosts=atmel
 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
 runtime.platform.path=C:\Program Files (x86)\Arduino\hardware\arduino\avr
 vm.platformname.name=avr
 build.arch=AVR
 build.architecture=avr
 vmresolved.compiler.path=C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\
 vmresolved.tools.path=C:\Program Files (x86)\Arduino\hardware\tools\avr
 " 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
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