diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b39ac68 --- /dev/null +++ b/.clang-format @@ -0,0 +1,65 @@ +--- +BasedOnStyle: Google +AccessModifierOffset: -2 +ConstructorInitializerIndentWidth: 2 +AlignEscapedNewlinesLeft: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AlwaysBreakTemplateDeclarations: true +AlwaysBreakBeforeMultilineStrings: false +BreakBeforeBinaryOperators: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: true +BinPackParameters: true +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: true +DerivePointerBinding: false +PointerBindsToType: true +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 60 +PenaltyBreakString: 1 +PenaltyBreakFirstLessLess: 1000 +PenaltyExcessCharacter: 1000 +PenaltyReturnTypeOnItsOwnLine: 90 +SpacesBeforeTrailingComments: 2 +Cpp11BracedListStyle: false +Standard: Auto +IndentWidth: 2 +TabWidth: 2 +UseTab: Never +IndentFunctionDeclarationAfterType: false +SpacesInParentheses: false +SpacesInAngles: false +SpaceInEmptyParentheses: false +SpacesInCStyleCastParentheses: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +ContinuationIndentWidth: 4 +SortIncludes: false +SpaceAfterCStyleCast: false + +# Configure each individual brace in BraceWrapping +BreakBeforeBraces: Custom + +# Control of individual brace wrapping cases +BraceWrapping: { + AfterClass: 'true' + AfterControlStatement: 'true' + AfterEnum : 'true' + AfterFunction : 'true' + AfterNamespace : 'true' + AfterStruct : 'true' + AfterUnion : 'true' + BeforeCatch : 'true' + BeforeElse : 'true' + IndentBraces : 'false' +} +... diff --git a/.travis.yml b/.travis.yml index ed0bdf4..5f87608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,14 @@ os: linux language: python +addons: + apt: + packages: + - clang-format + notifications: slack: - secure: DX4zerMP4tLgR8rMBnY36YhrdtULunl+aROFq7dWy0vXvxiegWfvGY0eWU7K36kcVToPV1LJ9ilFGxfOi5VELkFQHsxYCRaBddSgQ4pAxppygVPhlmOUdpkZsGxrJU27ajcy6OY/pwEFBsABIXitoEC2U0yDzx3J9bWjzz+QH14MLfH07zeYuuAfhloZ8IZk6TbSVeg8X/jhc1QUZhn7QgN+hvXo1MMSaq99TXXK7jO7soq5oRbTSOkohSiVm7XgbjL9haoWXQSBJlb82qu94wFlBBZlZ05oEVGzith36d4gVPJ5wbmoRQy5X/shGBBNGiyv8JRQ6Z18zgdsra1sWPNI7Yv5o91sMySx/g+OOqyJqQKq5y5ohb1Y4hI24zy9Xj8Bjac9wt9O4wvgn5+dlz2qgIkXbJeSodEB4OE0lBEeiQACkYpHz9UbxZrcaBtrq9tEHSrl7lwj/AgRckaIIr+6BURvQ21RIqXhajKiaSO05KqL0spyM8pVvNHn+0W1oznVuEMZOywy7bZ83JiodKVZPwJQWPetOAet8r4PnkulUSseJ8ckVpoz5Kfs/IrSAKMSlOeD19AgLm7Q/ejpoimfTJUJsDRgP7asRVuqgzl7ruBuQOwbaWg3FRgaW7WJ66LPmdNwI5bokThaMaE3oB17l2Y+Kt93CAxUDAKSStI= + secure: agpTHpiGJVNU8EtJV+nbiM8LYp7RkXPMpvrpa7yjlNKep4i0jQscFpOyylh+7Toekfh1F7ZMGhyBQfWsgzSKK4OtKgUY36jV3NJ04d1Jjf4CaypUsXe9eQ7KNIHLI+zPgwan+yf1iL6daF8uvRNT8SHCxTdRfVcwWaViQuh6/JbusxpSSojaT/BinCF/lItHC2+ixO1cQ7iFbBsaRyrEI76IUeaoMAUogqoNx+KdAYORMTcFI1i+6bw5TzsWY8Md8Kxn1YhvyeJv87LJjRhLyXLqzhp4XFjPUY0Vb9/iSihX7UfFoAPTPqmrlaATW6TEu0uo5fVJY6MWifAlcsuNGqL//saVqPHTiOqyEg1LcEUtdmR5+ljyMaSirV+pJA/vBNo61bjQeFzBf4d/kXiej0UQfLG1DFjUlYij++t6kr+EklYkwNYbfOQ75cLXrneG+nxjwg8KID2AVkjshLdjOfHFlGuzDTliId4lYU5FMdBl/dVS2u5qvVo8kaaTvvoAWjzp9KfdWHB1BmpAX06PblLWHnXuhJujBEyeT/9+D9eGmCmvYAsfLpky2hxWOHTkTbKGS9K60c2pHIhhzMRiOMZAVmbG7A2+7XdoaeBJ9cEHET09Ep2WY76jX5hTDbbA3xLZJB8e8O6TdCxXxp9xQvoPpmRK3rjsiun3thlFDBI= email: false cache: @@ -13,8 +18,10 @@ cache: install: - pip install -U platformio - platformio update + - platformio lib install script: - platformio run - - platformio check --environment debug -# - platformio test + - platformio test --environment native + - platformio check --fail-on-defect high + - wget -qO- https://raw.githubusercontent.com/Sarcasm/run-clang-format/master/run-clang-format.py | python - -r src include test diff --git a/README.md b/README.md index fa4d922..a9bb9ec 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,19 @@ build the release environment run: pio run -e release This only builds the project. To actually upload the project, connect the -input device and use the `--target (-t)` option. +input device and use the `--target (-t)` option. This will by default upload +the `debug` environment. pio run -t upload +When you run the input device you can read the messages sent over the +USB serial by adding the `monitor` target. + + pio run -t upload -t monitor + +This will build, upload and then print messages sent over the serial +by the input device using `Serial.println()`. + ## 🚀 Launch process The input device can be launched with a ROS serial connection. For this a workspace with the [march repository](https://github.com/project-march/march) diff --git a/examples/Button_example.cpp b/examples/Button_example.cpp deleted file mode 100644 index ecd4e1f..0000000 --- a/examples/Button_example.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "Button.h" - -// Define Pin for button -#define Pin_button 26 - -Button button(Pin_button); - -int button_state; - - -void setup() { - Serial.begin(9600); -} - -void loop() { - // When button is pressed, print - if (button.read_state() == "PUSH") { - Serial.println("Push detected!"); - } -} diff --git a/examples/Joystick_example.cpp b/examples/Joystick_example.cpp deleted file mode 100644 index d73f49e..0000000 --- a/examples/Joystick_example.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include "Joystick.h" - -// Pin definitions -// Joystick -#define JOYSTICK_LEFT 23 -#define JOYSTICK_RIGHT 22 -#define JOYSTICK_UP 21 -#define JOYSTICK_DOWN 19 -#define JOYSTICK_PUSH 18 - -// Create instances -// Joystick -Joystick joystick(JOYSTICK_LEFT, JOYSTICK_RIGHT, JOYSTICK_UP, JOYSTICK_DOWN, JOYSTICK_PUSH); - -void setup() { - Serial.begin(9600); -} - -void loop() { - String pos = joystick.get_position(); - String press = joystick.get_press(); - - if (pos != "HOLDING" && pos != "NEUTRAL"){ - Serial.print("Joystick position: "); - Serial.print(pos); - Serial.print("\n"); - } - if (press != "HOLDING" && press != "NEUTRAL"){ - Serial.print("Joystick press: "); - Serial.print(press); - Serial.print("\n"); - } -} diff --git a/examples/RockerSwitch+Screen_example.cpp b/examples/RockerSwitch+Screen_example.cpp deleted file mode 100644 index bcb5829..0000000 --- a/examples/RockerSwitch+Screen_example.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include "RockerSwitch.h" -#include "SoftwareSerial.h" -#include "Goldelox_Serial_4DLib.h" -#include "Screen.h" -#include "SD_sector_addresses.h" - -// Pin definitions -#define ROCKER_UP 2 -#define ROCKER_DOWN 5 -#define UART_TX 32 //software serial -#define UART_RX 34 //software serial -#define RST 13 -#define BAUD_SCREEN 9600 - -// Rocker switch -RockerSwitch rocker(ROCKER_UP, ROCKER_DOWN); -// Serial communication between Lolin and Screen -SoftwareSerial screenSerial(UART_RX, UART_TX); -// Instance of the screen as in Goldelox_Serial library -Goldelox_Serial_4DLib screenGoldelox(&screenSerial); -// Wrapper instance of the screen -Screen screen(&screenGoldelox, &screenSerial, RST, BAUD_SCREEN); - -int pictureList[] = { SOFA_ADDRESS_HI, SOFA_ADDRESS_LO, - CUP_ADDRESS_HI, CUP_ADDRESS_LO, - SLOPE_ADDRESS_HI, SLOPE_ADDRESS_LO, - STAIRS_ADDRESS_HI, STAIRS_ADDRESS_LO, - SIT_ADDRESS_HI, SIT_ADDRESS_LO}; - -int currentPicture = 4; - -void setup(){ - Serial.begin(9600); - Serial.println("Rockerswitch + screen test"); - - // Set pins as either input or output - pinMode(RST, OUTPUT); - pinMode(UART_TX, OUTPUT); - pinMode(UART_RX, INPUT); - - // initialize screen by resetting, initing uSD card, clearing screen - screen.initialize(); - screen.draw_image(SLOPE_ADDRESS_HI, SLOPE_ADDRESS_LO); - sleep(1); -} - -void loop(){ - String rockerStatus = rocker.get_position(); - if(rockerStatus != "NEUTRAL" && rockerStatus != "HOLDING UP" && rockerStatus != "HOLDING DOWN"){ - Serial.print("Rocker status: "); - Serial.print(rockerStatus); - Serial.print("\n"); - - if(rockerStatus == "UP"){ - // Show picture above current picture - if(currentPicture >= 8){ - currentPicture = 0; - } - else{ - currentPicture += 2; - } - screen.draw_image(pictureList[currentPicture], pictureList[currentPicture+1]); - } - if(rockerStatus == "DOWN"){ - // Show picture below current picture - if(currentPicture <= 0){ - currentPicture = 8; - } - else{ - currentPicture -= 2; - } - screen.draw_image(pictureList[currentPicture], pictureList[currentPicture+1]); - } - } - else{ - screen.draw_image(pictureList[currentPicture], pictureList[currentPicture+1]); - } -} \ No newline at end of file diff --git a/examples/Rockerswitch_example.cpp b/examples/Rockerswitch_example.cpp deleted file mode 100644 index 9199a94..0000000 --- a/examples/Rockerswitch_example.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include "RockerSwitch.h" - -// Pin definitions -#define ROCKER_UP 0 -#define ROCKER_DOWN 5 - -RockerSwitch rocker(ROCKER_UP, ROCKER_DOWN); - -void setup(){ - Serial.begin(9600); - Serial.println("Started Serial communication"); -} - -void loop(){ - String rockerStatus = rocker.get_position(); - if(rockerStatus != "NEUTRAL" && rockerStatus != "HOLDING UP" && rockerStatus != "HOLDING DOWN"){ - Serial.print("Rocker status: "); - Serial.print(rockerStatus); - Serial.print("\n"); - } -} \ No newline at end of file diff --git a/examples/SD_sector_addresses3.h b/examples/SD_sector_addresses3.h deleted file mode 100644 index 823c626..0000000 --- a/examples/SD_sector_addresses3.h +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef SD_ADDRESSES_H -#define SD_ADDRESSES_H - -//Version 3!!! - -// This file defines the sector addresses of the images to be loaded on the screen -// The sector addresses can be found via the 4D Systems Workshop 4D IDE -// The Graphics Composer of this software should be used: -// - To load the desired images on the uSD card -// - To find the sector addresses of said images (via generated .Gc file) - - -// 3HomeSit -#define HomeSit_Hi 0x0000 -#define HomeSit_Lo 0x0A71 - -// 3StandUp -#define StandUp_Hi 0x0000 -#define StandUp_Lo 0x10C5 - -// 3StandUpSelected -#define StandUpSelected_Hi 0x0000 -#define StandUpSelected_Lo 0x1167 - -// 3StandUpActivated -#define StandUpActivated_Hi 0x0000 -#define StandUpActivated_Lo 0x1116 - -// 3TurnOffStart -#define TurnOffStart_Hi 0x0000 -#define TurnOffStart_Lo 0x12AB - -// 3HomeStandStart -#define HomeStandStart_Hi 0x0000 -#define HomeStandStart_Lo 0x0B13 - -// 3Sit -#define Sit_Hi 0x0000 -#define Sit_Lo 0x0C06 - -// 3SitSelected -#define SitSelected_Hi 0x0000 -#define SitSelected_Lo 0x0CA8 - -// 3SitActivated -#define SitActivated_Hi 0x0000 -#define SitActivated_Lo 0x0C57 - -// 3HomeStand -#define HomeStand_Hi 0x0000 -#define HomeStand_Lo 0x0AC2 - -// 3TurnOff -#define TurnOff_Hi 0x0000 -#define TurnOff_Lo 0x125A - -// 3Stairs -#define Stairs_Hi 0x0000 -#define Stairs_Lo 0x0D9B - -// 3StairsUp -#define StairsUp_Hi 0x0000 -#define StairsUp_Lo 0x0EDF - -// 3StairsUpSelected -#define StairsUpSelected_Hi 0x0000 -#define StairsUpSelected_Lo 0x0F81 - -// 3StairsUpActivated -#define StairsUpActivated_Hi 0x0000 -#define StairsUpActivated_Lo 0x0F30 - -// 3StairWalk -#define WalkObstacle_Hi 0x0000 -#define WalkObstacle_Lo 0x0FD2 - -// 3StairWalkSelected, -#define WalkObstacleSelected_Hi 0x0000 -#define WalkObstacleSelected_Lo 0x1074 - -// 3StairWalkActivated, -#define WalkObstacleActivated_Hi 0x0000 -#define WalkObstacleActivated_Lo 0x1023 - -// 3StairsDown, -#define StairsDown_Hi 0x0000 -#define StairsDown_Lo 0x0DEC - -// 3StairsDownSelected, -#define StairsDownSelected_Hi 0x0000 -#define StairsDownSelected_Lo 0x0E8E - -// 3StairsDownActivated -#define StairsDownACtivated_Hi 0x0000 -#define StairsDownActivated_Lo 0x0E3D - -// 3Walk -#define Walk_Hi 0x0000 -#define Walk_Lo 0x12FC - -// 3WalkSmall -#define WalkSmall_Hi 0x0000 -#define WalkSmall_Lo 0x1491 - -// 3WalkNormal -#define WalkNormal_Hi 0x0000 -#define WalkNormal_Lo 0x129E - -// 3WalkLarge -#define WalkLarge_Hi 0x0000 -#define WalkLarge_Lo 0x124D - -// 3WalkNormalSelected -#define WalkNormalSelected_Hi 0x0000 -#define WalkNormalSelected_Lo 0x1440 - -// 3WalkNormalActivated -#define WalkNormalActivated_Hi 0x0000 -#define WalkNormalActivated_Lo 0x13EF - -// SideStep -#define SideStep_Hi 0x0000 -#define SideStep_Lo 0x11B8 - -// Slope -#define Slope_Hi 0x0000 -#define Slope_Lo 0x0CF9 - -// TiltedPath -#define TiltedPath_Hi 0x0000 -#define TiltedPath_Lo 0x1209 - -// RoughTerrain -#define RoughTerrain_Hi 0x0000 -#define RoughTerrain_Lo 0x0B64 - -// Sofa -#define Sofa_Hi 0x0000 -#define Sofa_Lo 0x0D4A - -// SingleStep -#define SingleStep_Hi 0x0000 -#define SingleStep_Lo 0x0BB5 - -// HomeSitSelected unknown -#define HomeSitSelected_Hi 0x0000 -#define HomeSitSelected_Lo 0x14E2 - -// HomeSitActivated unknown -#define HomeSitActivated_Hi 0x0000 -#define HomeSitActivated_Lo 0x14E2 - -// TurnOffStartSelected unknown -#define TurnOffStartSelected_Hi 0x0000 -#define TurnOffStartSelected_Lo 0x14E2 - -// TurnOffStartActivated unknown -#define TurnOffStartActivated_Hi 0x0000 -#define TurnOffStartActivated_Lo 0x14E2 - -// HomeStandStartSelected unknown -#define HomeStandStartSelected_Hi 0x0000 -#define HomeStandStartSelected_Lo 0x14E2 - -// HomeStandStartActivated unknown -#define HomeStandStartActivated_Hi 0x0000 -#define HomeStandStartActivated_Lo 0x14E2 - -// HomeStandSelected unknown -#define HomeStandSelected_Hi 0x0000 -#define HomeStandSelected_Lo 0x14E2 - -// HomeStandActivated unknown -#define HomeStandActivated_Hi 0x0000 -#define HomeStandActivated_Lo 0x14E2 - -// TurnOffSelected unknown -#define TurnOffSelected_Hi 0x0000 -#define TurnOffSelected_Lo 0x14E2 - -// TurnOffActivated unknown -#define TurnOffActivated_Hi 0x0000 -#define TurnOffActivated_Lo 0x14E2 - -// WalkSmallSelected unknown -#define WalkSmallSelected_Hi 0x0000 -#define WalkSmallSelected_Lo 0x14E2 - -// WalkLargeSelected unknown -#define WalkLargeSelected_Hi 0x0000 -#define WalkLargeSelected_Lo 0x14E2 - -// WalkSmallActivated unknown -#define WalkSmallActivated_Hi 0x0000 -#define WalkSmallActivated_Lo 0x14E2 - -// WalkLargeActivated unknown -#define WalkLargeActivated_Hi 0x0000 -#define WalkLargeActivated_Lo 0x14E2 - -// SingleStepSmall unknown -#define SingleStepSmall_Hi 0x0000 -#define SingleStepSmall_Lo 0x14E2 - -// SingleStepNormal unknown -#define SingleStepNormal_Hi 0x0000 -#define SingleStepNormal_Lo 0x14E2 - -// SingleStepLarge unknown -#define SingleStepLarge_Hi 0x0000 -#define SingleStepLarge_Lo 0x14E2 - -// SingleStepSmallSelected unknown -#define SingleStepSmallSelected_Hi 0x0000 -#define SingleStepSmallSelected_Lo 0x14E2 - -// SingleStepNormalSelected unknown -#define SingleStepNormalSelected_Hi 0x0000 -#define SingleStepNormalSelected_Lo 0x14E2 - -// SingleStepLargeSelected unknown -#define SingleStepLargeSelected_Hi 0x0000 -#define SingleStepLargeSelected_Lo 0x14E2 - -// SingleStepSmallActivated unknown -#define SingleStepSmallActivated_Hi 0x0000 -#define SingleStepSmallActivated_Lo 0x14E2 - -// SingleStepNormalActivated unknown -#define SingleStepNormalActivated_Hi 0x0000 -#define SingleStepNormalActivated_Lo 0x14E2 - -// SingleStepLargeActivated unknown -#define SingleStepLargeActivated_Hi 0x0000 -#define SingleStepLargeActivated_Lo 0x14E2 - -// SideStepLeft unknown -#define SideStepLeft_Hi 0x0000 -#define SideStepLeft_Lo 0x14E2 - -// SideStepRight unknown -#define SideStepRight_Hi 0x0000 -#define SideStepRight_Lo 0x14E2 - -// SideStepLeftSelected unknown -#define SideStepLeftSelected_Hi 0x0000 -#define SideStepLeftSelected_Lo 0x14E2 - -// SideStepRightSelected unknown -#define SideStepRightSelected_Hi 0x0000 -#define SideStepRightSelected_Lo 0x14E2 - -// SideStepLeftActivated unknown -#define SideStepLeftActivated_Hi 0x0000 -#define SideStepLeftActivated_Lo 0x14E2 - -// SideStepRightActivated unknown -#define SideStepRightActivated_Hi 0x0000 -#define SideStepRightActivated_Lo 0x14E2 - -// SofaSit unknown -#define SofaSit_Hi 0x0000 -#define SofaSit_Lo 0x14E2 - -// SofaSitSelected unknown -#define SofaSitSelected_Hi 0x0000 -#define SofaSitSelected_Lo 0x14E2 - -// SofaSitActivated unknown -#define SofaSitActivated_Hi 0x0000 -#define SofaSitActivated_Lo 0x14E2 - -// SofaStandUp uknonwn -#define SofaStandUp_Hi 0x0000 -#define SofaStandUp_Lo 0x14E2 - -// SofaStandUpSelected uknonwn -#define SofaStandUpSelected_Hi 0x0000 -#define SofaStandUpSelected_Lo 0x14E2 - -// SofaStandUpActivated unknown -#define SofaStandUpActivated_Hi 0x0000 -#define SofaStandUpActivated_Lo 0x14E2 - -// SlopeUp unknown -#define SlopeUp_Hi 0x0000 -#define SlopeUp_Lo 0x14E2 - -// SlopeUpSelected unknown -#define SlopeUpSelected_Hi 0x0000 -#define SlopeUpSelected_Lo 0x14E2 - -// SlopeUpActivated unknown -#define SlopeUpActivated_Hi 0x0000 -#define SlopeUpActivated_Lo 0x14E2 - -// SlopeDown unknown -#define SlopeDown_Hi 0x0000 -#define SlopeDown_Lo 0x14E2 - -// SlopeDownSelected unknown -#define SlopeDownSelected_Hi 0x0000 -#define SlopeDownSelected_Lo 0x14E2 - -// SlopeDownActivated unknown -#define SlopeDownActivated_Hi 0x0000 -#define SlopeDownActivated_Lo 0x14E2 - - - -// RoughTerrainSelected unknown -#define RoughTerrainSelected_Hi 0x0000 -#define RoughTerrainSelected_Lo 0x14E2 - -// RoughTerrainActivated unknown -#define RoughTerrainActivated_Hi 0x0000 -#define RoughTerrainActivated_Lo 0x14E2 - -// TiltedPathSelected unknown -#define TiltedPathSelected_Hi 0x0000 -#define TiltedPathSelected_Lo 0x14E2 - -// TiltedPathActivated unknown -#define TiltedPathActivated_Hi 0x0000 -#define TiltedPathActivated_Lo 0x14E2 - -#endif //SD_ADDRESSES_H \ No newline at end of file diff --git a/examples/button_example.cpp b/examples/button_example.cpp new file mode 100644 index 0000000..59796df --- /dev/null +++ b/examples/button_example.cpp @@ -0,0 +1,28 @@ +#include "button.h" + +#include + +// Define Pin for button +#define Pin_button 26 + +Button button(Pin_button); + +int button_state; + +void setup() +{ + Serial.begin(9600); +} + +void loop() +{ + // When button is pressed, print + if (button.getState() == ButtonState::PUSH) + { + Serial.println("Push detected!"); + } + if (button.getState() == ButtonState::DOUBLE) + { + Serial.println("Double push detected!"); + } +} diff --git a/examples/joystick_example.cpp b/examples/joystick_example.cpp new file mode 100644 index 0000000..a606045 --- /dev/null +++ b/examples/joystick_example.cpp @@ -0,0 +1,56 @@ +#include "joystick.h" + +#include + +// Pin definitions +// Joystick +#define JOYSTICK_LEFT 23 +#define JOYSTICK_RIGHT 22 +#define JOYSTICK_UP 21 +#define JOYSTICK_DOWN 19 +#define JOYSTICK_PUSH 18 + +// Create instances +// Joystick +Joystick joystick(JOYSTICK_LEFT, JOYSTICK_RIGHT, JOYSTICK_UP, JOYSTICK_DOWN, JOYSTICK_PUSH); + +void setup() +{ + Serial.begin(9600); +} + +void loop() +{ + JoystickState pos = joystick.getState(); + ButtonState press = joystick.getButtonState(); + + switch (pos) + { + case JoystickState::LEFT: + Serial.print("Joystick left"); + break; + case JoystickState::RIGHT: + Serial.print("Joystick right"); + break; + case JoystickState::UP: + Serial.print("Joystick up"); + break; + case JoystickState::DOWN: + Serial.print("Joystick down"); + break; + default: + break; + } + + switch (press) + { + case ButtonState::PUSH: + Serial.println("Joystick pressed"); + break; + case ButtonState::DOUBLE: + Serial.println("Joystick double pressed"); + break; + default: + break; + } +} diff --git a/examples/rocker_switch_example.cpp b/examples/rocker_switch_example.cpp new file mode 100644 index 0000000..527523f --- /dev/null +++ b/examples/rocker_switch_example.cpp @@ -0,0 +1,30 @@ +#include "rocker_switch.h" + +#include + +// Pin definitions +#define ROCKER_UP 0 +#define ROCKER_DOWN 5 + +RockerSwitch rocker(ROCKER_UP, ROCKER_DOWN); + +void setup() +{ + Serial.begin(9600); +} + +void loop() +{ + RockerSwitchState status = rocker.getState(); + switch (status) + { + case RockerSwitchState::UP: + Serial.println("rocker switch up"); + break; + case RockerSwitchState::DOWN: + Serial.println("rocker switch down"); + break; + default: + break; + } +} diff --git a/examples/Screen_example.cpp b/examples/screen_example.cpp similarity index 66% rename from examples/Screen_example.cpp rename to examples/screen_example.cpp index ea054d8..009c85d 100644 --- a/examples/Screen_example.cpp +++ b/examples/screen_example.cpp @@ -1,8 +1,9 @@ +#include "screen.h" +#include "sd_sector_addresses.h" + #include -#include "SoftwareSerial.h" -#include "Goldelox_Serial_4DLib.h" -#include "Screen.h" -#include "SD_sector_addresses.h" +#include +#include // Developed by M. van der Marel for Project MARCH // Required tools for running this code: @@ -12,11 +13,10 @@ // A uSD card set up with the 4D Systems software with images, placed in the uOLED-160G2 board // The sector addresses returned by the 4D Systems software can be placed in 'SD_sector_addresses.h' for easy access - -#define UART_TX 32 //software serial -#define UART_RX 34 //software serial -#define RST 13 -#define BAUD_SCREEN 9600 +#define UART_TX 32 // software serial +#define UART_RX 34 // software serial +#define RST 13 +#define BAUD_SCREEN 9600 // Serial communication between Lolin and Screen SoftwareSerial screenSerial(UART_RX, UART_TX); @@ -25,24 +25,26 @@ Goldelox_Serial_4DLib screenGoldelox(&screenSerial); // Wrapper instance of the screen Screen screen(&screenGoldelox, &screenSerial, RST, BAUD_SCREEN); -void setup() { +void setup() +{ // Set pins as either input or output pinMode(RST, OUTPUT); pinMode(UART_TX, OUTPUT); pinMode(UART_RX, INPUT); // initialize screen by resetting, initing uSD card, clearing screen - screen.initialize(); + screen.init(); } -void loop(void) { +void loop() +{ // Draw different images from the uSD card in a loop - screen.draw_image(CUP_ADDRESS_HI, CUP_ADDRESS_LO); + screen.draw_image(STAIRS); sleep(1); - screen.draw_image(STAIRS_ADDRESS_HI, STAIRS_ADDRESS_LO); + screen.draw_image(SIT); sleep(1); - screen.draw_image(SIT_ADDRESS_HI, SIT_ADDRESS_LO); + screen.draw_image(HOME_STAND); sleep(1); - screen.draw_image(SOFA_ADDRESS_HI, SOFA_ADDRESS_LO); + screen.draw_image(SOFA); sleep(1); } diff --git a/examples/Serial_test.cpp b/examples/serial_example.cpp similarity index 88% rename from examples/Serial_test.cpp rename to examples/serial_example.cpp index 24c7fdd..12a7fa7 100644 --- a/examples/Serial_test.cpp +++ b/examples/serial_example.cpp @@ -3,12 +3,14 @@ // This is a minimal working version for the Lolin D32 Pro // See the examples folder for examples with different peripherals -void setup(){ +void setup() +{ Serial.begin(9600); Serial.println("Setup"); } -void loop(){ +void loop() +{ Serial.println("Loop"); sleep(1); -} \ No newline at end of file +} diff --git a/examples/Vibration_example.cpp b/examples/vibration_example.cpp similarity index 81% rename from examples/Vibration_example.cpp rename to examples/vibration_example.cpp index 635a52d..7ef8ad2 100644 --- a/examples/Vibration_example.cpp +++ b/examples/vibration_example.cpp @@ -1,11 +1,12 @@ +#include #include -#include "Adafruit_DRV2605.h" Adafruit_DRV2605 driver; -uint8_t effect; // Select the desired effect, for now test effect "Buzz 100%" +uint8_t effect; // Select the desired effect, for now test effect "Buzz 100%" -void setup() { +void setup() +{ Serial.begin(9600); // Setup I2C protocol @@ -21,7 +22,8 @@ void setup() { effect = 47; } -void loop() { +void loop() +{ // Set the effect to be played // Waveforms can be combined, to create new wavefroms, see driver datasheet driver.setWaveform(0, effect); // Setup the waveform(s) @@ -31,5 +33,4 @@ void loop() { driver.go(); sleep(1); - -} \ No newline at end of file +} diff --git a/include/Button.h b/include/Button.h deleted file mode 100644 index 8a17242..0000000 --- a/include/Button.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef Button_h -#define Button_h - -#include - -class Button { - public: - Button(int pin); - String read_state(); - - private: - int input_pin; - String lastPosition; - unsigned long lastPrintTime; - const unsigned int bounceTime = 20000; //us. May introduce unwanted behaviour if changed - const unsigned int holdTime = 1000; //ms. Determines how often 'push' is returned if the button is held -}; - -#endif \ No newline at end of file diff --git a/include/Joystick.h b/include/Joystick.h deleted file mode 100644 index 4bcf711..0000000 --- a/include/Joystick.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef Joystick_h -#define Joystick_h - -#include - -class Joystick { -public: - Joystick(int pin_left, int pin_right, int pin_up, int pin_down, int pin_press); - String get_position(); - String get_press(); - -private: - int left_pin; - int right_pin; - int up_pin; - int down_pin; - int press_pin; - - String lastPosition; - String lastPushPosition; - unsigned long lastPrintTime; - unsigned long lastPushPrintTime; - bool recentInitialClick; - bool recentDoubleClick; - bool lastPush; - unsigned long lastPushReleaseTime; - unsigned long lastDoubleClickTime; - - const int bounceTime = 5000; //us. May introduce unwanted behaviour if changed - const unsigned long holdTime = 1000; //ms. Determines how often up or down are returned if the joystick is held. - const unsigned long doubleClickTime = 300; //ms. - const unsigned long doubleClickTimeoutTime = 500; //ms -}; - -#endif \ No newline at end of file diff --git a/include/Led.h b/include/Led.h deleted file mode 100644 index b8b024c..0000000 --- a/include/Led.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef Led_h -#define Led_h - -#include - -class Led { - public: - Led(int pin); - void Blink(int led_delay); - - private: - int output_pin; // Each Led instance has a output pin -}; - -#endif \ No newline at end of file diff --git a/include/RockerSwitch.h b/include/RockerSwitch.h deleted file mode 100644 index 8543397..0000000 --- a/include/RockerSwitch.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RockerSwitch_h -#define RockerSwitch_h - -#include - -class RockerSwitch { -public: - RockerSwitch(int upPin, int downPin); - String get_position(); - -private: - int pinUp; - int pinDown; - String lastPosition; - unsigned long lastPrintTime; - const unsigned int bounceTime = 20000; //us. May introduce unwanted behaviour if changed - const unsigned long holdTime = 1000; //ms. Determines how often up or down are returned if the rocker switch is held up or down. -}; - -#endif \ No newline at end of file diff --git a/include/SD_sector_addresses.h b/include/SD_sector_addresses.h deleted file mode 100644 index 8aedbab..0000000 --- a/include/SD_sector_addresses.h +++ /dev/null @@ -1,567 +0,0 @@ -#ifndef SD_ADDRESSES_H -#define SD_ADDRESSES_H - -// This file defines the sector addresses of the images to be loaded on the screen -// The sector addresses can be found via the 4D Systems Workshop 4D IDE -// The Graphics Composer of this software should be used: -// - To load the desired images on the uSD card -// - To find the sector addresses of said images (via generated .Gc file) - -// HomeSitStart -#define HomeSitStart_Hi 0x0000 -#define HomeSitStart_Lo 0x0000 - -// HomeSitStartSelected -#define HomeSitStartSelected_Hi 0x0000 -#define HomeSitStartSelected_Lo 0x00A2 - -// HomeSitStartActivated -#define HomeSitStartActivated_Hi 0x0000 -#define HomeSitStartActivated_Lo 0x0051 - -// StandUp -#define StandUp_Hi 0x0000 -#define StandUp_Lo 0x1209 - -// StandUpSelected -#define StandUpSelected_Hi 0x0000 -#define StandUpSelected_Lo 0x12AB - -// StandUpActivated -#define StandUpActivated_Hi 0x0000 -#define StandUpActivated_Lo 0x125A - - -// TurnOffStart -#define TurnOffStart_Hi 0x0000 -#define TurnOffStart_Lo 0x14E2 - -// TurnOffStartSelected -#define TurnOffStartSelected_Hi 0x0000 -#define TurnOffStartSelected_Lo 0x1584 - -// TurnOffStartActivated -#define TurnOffStartActivated_Hi 0x0000 -#define TurnOffStartActivated_Lo 0x1533 - - - -// HomeStandStart -#define HomeStandStart_Hi 0x0000 -#define HomeStandStart_Lo 0x01E6 - -// HomeStandStartSelected unknown -#define HomeStandStartSelected_Hi 0x0000 -#define HomeStandStartSelected_Lo 0x0288 - -// HomeStandStartActivated unknown -#define HomeStandStartActivated_Hi 0x0000 -#define HomeStandStartActivated_Lo 0x0237 - - -// Sit -#define Sit_Hi 0x0000 -#define Sit_Lo 0x222C - -// SitSelected -#define SitSelected_Hi 0x0000 -#define SitSelected_Lo 0x0B13 - -// SitActivated -#define SitActivated_Hi 0x0000 -#define SitActivated_Lo 0x0AC2 - -// HomeSit -#define HomeSit_Hi 0x0000 -#define HomeSit_Lo 0x218A - -// HomeSitSelected -#define HomeSitSelected_Hi 0x0000 -#define HomeSitSelected_Lo 0x00A2 - -// HomeSitActivated -#define HomeSitActivated_Hi 0x0000 -#define HomeSitActivated_Lo 0x0051 - -// HomeStand -#define HomeStand_Hi 0x0000 -#define HomeStand_Lo 0x21DB - -// HomeStandSelected unknown -#define HomeStandSelected_Hi 0x0000 -#define HomeStandSelected_Lo 0x0288 - -// HomeStandActivated unknown -#define HomeStandActivated_Hi 0x0000 -#define HomeStandActivated_Lo 0x0237 - - - -// TurnOff -#define TurnOff_Hi 0x0000 -#define TurnOff_Lo 0x227D - -// TurnOffSelected -#define TurnOffSelected_Hi 0x0000 -#define TurnOffSelected_Lo 0x1491 - -// TurnOffActivated -#define TurnOffActivated_Hi 0x0000 -#define TurnOffActivated_Lo 0x1440 - - -// Sofa -#define Sofa_Hi 0x0000 -#define Sofa_Lo 0x2505 - -// SofaSit -#define SofaSit_Hi 0x0000 -#define SofaSit_Lo 0x25F8 - -// SofaSitSelected -#define SofaSitSelected_Hi 0x0000 -#define SofaSitSelected_Lo 0x0E8E - -// SofaSitActivated -#define SofaSitActivated_Hi 0x0000 -#define SofaSitActivated_Lo 0x0E3D - -// SofaStandUp -#define SofaStandUp_Hi 0x0000 -#define SofaStandUp_Lo 0x2649 - -// SofaStandUpSelected -#define SofaStandUpSelected_Hi 0x0000 -#define SofaStandUpSelected_Lo 0x0F81 - -// SofaStandUpActivated -#define SofaStandUpActivated_Hi 0x0000 -#define SofaStandUpActivated_Lo 0x0F30 - - -// // Slope -// #define Slope_Hi 0x0000 -// #define Slope_Lo 0x0B64 - -// // SlopeUp -// #define SlopeUp_Hi 0x0000 -// #define SlopeUp_Lo 0x0CA8 - -// // SlopeUpSelected -// #define SlopeUpSelected_Hi 0x0000 -// #define SlopeUpSelected_Lo 0x0D4A - -// // SlopeUpActivated -// #define SlopeUpActivated_Hi 0x0000 -// #define SlopeUpActivated_Lo 0x0CF9 - -// // SlopeDown -// #define SlopeDown_Hi 0x0000 -// #define SlopeDown_Lo 0x0BB5 - -// // SlopeDownSelected -// #define SlopeDownSelected_Hi 0x0000 -// #define SlopeDownSelected_Lo 0x0C57 - -// // SlopeDownActivated -// #define SlopeDownActivated_Hi 0x0000 -// #define SlopeDownActivated_Lo 0x0C06 - -// // SlopeDownFinal -// #define SlopeDownFinal_Hi 0x0000 -// #define SlopeDownFinal_Lo 0x0BB5 - -// // SlopeDownFinalSelected -// #define SlopeDownFinalSelected_Hi 0x0000 -// #define SlopeDownFinalSelected_Lo 0x0C57 - -// // SlopeDownFinalActivated -// #define SlopeDownFinalActivated_Hi 0x0000 -// #define SlopeDownFinalActivated_Lo 0x0C06 - - -// // RoughTerrain -// #define RoughTerrain_Hi 0x0000 -// #define RoughTerrain_Lo 0x02D9 - -// // RoughTerrainSelected unknown -// #define RoughTerrainSelected_Hi 0x0000 -// #define RoughTerrainSelected_Lo 0x037B - -// // RoughTerrainActivated unknown -// #define RoughTerrainActivated_Hi 0x0000 -// #define RoughTerrainActivated_Lo 0x032A - - -// TiltedPath -#define TiltedPath_Hi 0x0000 -#define TiltedPath_Lo 0x25A7 - -// TiltedPathSelected unknown yet! -#define TiltedPathSelected_Hi 0x0000 -#define TiltedPathSelected_Lo 0x139E - -// TiltedPathActivated unknown yet! -#define TiltedPathActivated_Hi 0x0000 -#define TiltedPathActivated_Lo 0x134D - - -// Stairs -#define Stairs_Hi 0x0000 -#define Stairs_Lo 0x2556 - -// StairsUp -#define StairsUp_Hi 0x0000 -#define StairsUp_Lo 0x26EB - -// StairsUpSelected -#define StairsUpSelected_Hi 0x0000 -#define StairsUpSelected_Lo 0x11B8 - -// StairsUpActivated -#define StairsUpActivated_Hi 0x0000 -#define StairsUpActivated_Lo 0x1167 - -// StairsDown -#define StairsDown_Hi 0x0000 -#define StairsDown_Lo 0x269A - -// StairsDownSelected, -#define StairsDownSelected_Hi 0x0000 -#define StairsDownSelected_Lo 0x10C5 - -// StairsDownActivated -#define StairsDownActivated_Hi 0x0000 -#define StairsDownActivated_Lo 0x1074 - -// StairsDownFinal -// #define StairsDownFinal_Hi 0x0000 -// #define StairsDownFinal_Lo 0x24B4 - -// StairsDownFinalSelected, -// #define StairsDownFinalSelected_Hi 0x0000 -// #define StairsDownFinalSelected_Lo 0x10C5 - -// StairsDownFinalActivated -// #define StairsDownFinalActivated_Hi 0x0000 -// #define StairsDownFinalActivated_Lo 0x1074 - - - -// WalkObstacle -#define WalkObstacle_Hi 0x0000 -#define WalkObstacle_Lo 0x180C - -// WalkObstacleSmall -#define WalkObstacleSmall_Hi 0x0000 -#define WalkObstacleSmall_Lo 0x18FF - -// WalkObstacleNormal -#define WalkObstacleNormal_Hi 0x0000 -#define WalkObstacleNormal_Lo 0x18AE - -// WalkObstacleLarge -#define WalkObstacleLarge_Hi 0x0000 -#define WalkObstacleLarge_Lo 0x185D - -// WalkObstacleSmallSelected -#define WalkObstacleSmallSelected_Hi 0x0000 -#define WalkObstacleSmallSelected_Lo 0x19F2 - -// WalkObstacleNormalSelected -#define WalkObstacleNormalSelected_Hi 0x0000 -#define WalkObstacleNormalSelected_Lo 0x17BB - -// // WalkObstacleLargeSelected -// #define WalkObstacleLargeSelected_Hi 0x0000 -// #define WalkObstacleLargeSelected_Lo 0x16C8 - -// WalkObstacleSmallActivated -#define WalkObstacleSmallActivated_Hi 0x0000 -#define WalkObstacleSmallActivated_Lo 0x19A1 - -// WalkObstacleNormalActivated -#define WalkObstacleNormalActivated_Hi 0x0000 -#define WalkObstacleNormalActivated_Lo 0x176A - -// // WalkObstacleLargeActivated -// #define WalkObstacleLargeActivated_Hi 0x0000 -// #define WalkObstacleLargeActivated_Lo 0x1677 - -// SingleStepObstacle -#define SingleStepObstacle_Hi 0x0000 -#define SingleStepObstacle_Lo 0x083A - -// SingleStepObstacleSmall -#define SingleStepObstacleSmall_Hi 0x0000 -#define SingleStepObstacleSmall_Lo 0x092D - -// SingleStepObstacleNormal -#define SingleStepObstacleNormal_Hi 0x0000 -#define SingleStepObstacleNormal_Lo 0x08DC - -// SingleStepObstacleLarge -#define SingleStepObstacleLarge_Hi 0x0000 -#define SingleStepObstacleLarge_Lo 0x088B - -// // SingleStepObstacleLargeSelected -// #define SingleStepObstacleLargeSelected_Hi 0x0000 -// #define SingleStepObstacleLargeSelected_Lo 0x06F6 - -// SingleStepObstacleSmallSelected -#define SingleStepObstacleSmallSelected_Hi 0x0000 -#define SingleStepObstacleSmallSelected_Lo 0x0A20 - -// SingleStepObstacleNormalSelected -#define SingleStepObstacleNormalSelected_Hi 0x0000 -#define SingleStepObstacleNormalSelected_Lo 0x07E9 - -// SingleStepObstacleSmallActivated -#define SingleStepObstacleSmallActivated_Hi 0x0000 -#define SingleStepObstacleSmallActivated_Lo 0x09CF - -// SingleStepObstacleNormalActivated -#define SingleStepObstacleNormalActivated_Hi 0x0000 -#define SingleStepObstacleNormalActivated_Lo 0x0798 - -// // SingleStepObstacleLargeActivated -// #define SingleStepObstacleLargeActivated_Hi 0x0000 -// #define SingleStepObstacleLargeActivated_Lo 0x06A5 - - - -// Walk -#define Walk_Hi 0x0000 -#define Walk_Lo 0x15D5 - -// WalkSmall -#define WalkSmall_Hi 0x0000 -#define WalkSmall_Lo 0x1950 - -// WalkNormal -#define WalkNormal_Hi 0x0000 -#define WalkNormal_Lo 0x1719 - -// WalkLarge -#define WalkLarge_Hi 0x0000 -#define WalkLarge_Lo 0x1626 - -// WalkNormalSelected -#define WalkNormalSelected_Hi 0x0000 -#define WalkNormalSelected_Lo 0x17BB - -// WalkNormalActivated -#define WalkNormalActivated_Hi 0x0000 -#define WalkNormalActivated_Lo 0x176A - - -// WalkSmallSelected -#define WalkSmallSelected_Hi 0x0000 -#define WalkSmallSelected_Lo 0x19F2 - -// // WalkLargeSelected -// #define WalkLargeSelected_Hi 0x0000 -// #define WalkLargeSelected_Lo 0x16C8 - -// WalkSmallActivated -#define WalkSmallActivated_Hi 0x0000 -#define WalkSmallActivated_Lo 0x19A1 - -// // WalkLargeActivated -// #define WalkLargeActivated_Hi 0x0000 -// #define WalkLargeActivated_Lo 0x1677 - -// SingleStep -#define SingleStep_Hi 0x0000 -#define SingleStep_Lo 0x0603 - -// SingleStepSmall -#define SingleStepSmall_Hi 0x0000 -#define SingleStepSmall_Lo 0x097E - -// SingleStepNormal -#define SingleStepNormal_Hi 0x0000 -#define SingleStepNormal_Lo 0x0747 - -// SingleStepLarge -#define SingleStepLarge_Hi 0x0000 -#define SingleStepLarge_Lo 0x0654 - -// SingleStepSmallSelected -#define SingleStepSmallSelected_Hi 0x0000 -#define SingleStepSmallSelected_Lo 0x0A20 - -// SingleStepNormalSelected -#define SingleStepNormalSelected_Hi 0x0000 -#define SingleStepNormalSelected_Lo 0x07E9 - -// // SingleStepLargeSelected -// #define SingleStepLargeSelected_Hi 0x0000 -// #define SingleStepLargeSelected_Lo 0x06F6 - -// SingleStepSmallActivated -#define SingleStepSmallActivated_Hi 0x0000 -#define SingleStepSmallActivated_Lo 0x09CF - -// SingleStepNormalActivated -#define SingleStepNormalActivated_Hi 0x0000 -#define SingleStepNormalActivated_Lo 0x0798 - -// // SingleStepLargeActivated -// #define SingleStepLargeActivated_Hi 0x0000 -// #define SingleStepLargeActivated_Lo 0x06A5 - -// SideStep -#define SideStep_Hi 0x0000 -#define SideStep_Lo 0x03CC - -// SideStepLeft -#define SideStepLeft_Hi 0x0000 -#define SideStepLeft_Lo 0x041D - -// SideStepRight -#define SideStepRight_Hi 0x0000 -#define SideStepRight_Lo 0x0510 - -// SideStepLeftSelected -#define SideStepLeftSelected_Hi 0x0000 -#define SideStepLeftSelected_Lo 0x04BF - -// SideStepRightSelected -#define SideStepRightSelected_Hi 0x0000 -#define SideStepRightSelected_Lo 0x05B2 - -// SideStepLeftActivated -#define SideStepLeftActivated_Hi 0x0000 -#define SideStepLeftActivated_Lo 0x046E - -// SideStepRightActivated -#define SideStepRightActivated_Hi 0x0000 -#define SideStepRightActivated_Lo 0x0561 - -//SiderStepLeftSmall -#define SideStepLeftSmall_Hi 0x0000 -#define SideStepLeftSmall_Lo 0x2F76 - -//SideStepLeftSmallSelected -#define SideStepLeftSmallSelected_Hi 0x0000 -#define SideStepLeftSmallSelected_Lo 0x3018 - -//SideStepLeftSmallActivated -#define SideStepLeftSmallActivated_Hi 0x0000 -#define SideStepLeftSmallActivated_Lo 0x2FC7 - -//SideStepLeftNormal -#define SideStepLeftNormal_Hi 0x0000 -#define SideStepLeftNormal_Lo 0x2C9D - -//SideStepLeftNormalSelected -#define SideStepLeftNormalSelected_Hi 0x0000 -#define SideStepLeftNormalSelected_Lo 0x2D3F - -//SideStepLeftNormalActivated -#define SideStepLeftNormalActivated_Hi 0x0000 -#define SideStepLeftNormalActivated_Lo 0x2CEE - -//SiderStepRightSmall -#define SideStepRightSmall_Hi 0x0000 -#define SideStepRightSmall_Lo 0x3069 - -//SideStepRightRightSelected -#define SideStepRightSmallSelected_Hi 0x0000 -#define SideStepRightSmallSelected_Lo 0x310B - -//SideStepRightSmallActivated -#define SideStepRightSmallActivated_Hi 0x0000 -#define SideStepRightSmallActivated_Lo 0x30BA - -//SideStepRightNormal -#define SideStepRightNormal_Hi 0x0000 -#define SideStepRightNormal_Lo 0x2D90 - -//SideStepRightNormalSelected -#define SideStepRightNormalSelected_Hi 0x0000 -#define SideStepRightNormalSelected_Lo 0x2E32 - -//SideStepRightNormalActivated -#define SideStepRightNormalActivated_Hi 0x0000 -#define SideStepRightNormalActivated_Lo - -//TiltedPathStartHomeToMin5 -#define TiltedPathStartHomeToMin5_Hi 0x0000 -#define TiltedPathStartHomeToMin5_Lo 0x2B59 - -//TiltedPathStartHomeToMin5Selected -#define TiltedPathStartHomeToMin5Selected_Hi 0x0000 -#define TiltedPathStartHomeToMin5Selected_Lo 0x2BFB - -//TiltedPathStartHomeToMin5Activated -#define TiltedPathStartHomeToMin5Activated_Hi 0x0000 -#define TiltedPathStartHomeToMin5Activated_Lo 0x2BAA - -//FirstStartStep -#define FirstStartStep_Hi 0x0000 -#define FirstStartStep_Lo 0x2A66 - -//FirstStartStepActivated -#define FirstStartStepActivated_Hi 0x0000 -#define FirstStartStepActivated_Lo 0x2A66 - -//SecondStartStep -#define SecondStartStep_Hi 0x0000 -#define SecondStartStep_Lo 0x2F25 - -//SecondStartStepActivated -#define SecondStartStepActivated_Hi 0x0000 -#define SecondStartStepActivated_Lo 0x2F25 - -//HomeStandToMin10 -#define HomeStandToMin10_Hi 0x0000 -#define HomeStandToMin10_Lo 0x2C4C - -//HomeStandToMin10Activated -#define HomeStandToMin10Activated_Hi 0x0000 -#define HomeStandToMin10Activated_Lo 0x2C4C - -//TiltedPathMiddleStep -#define TiltedPathMiddleStep_Hi 0x0000 -#define TiltedPathMiddleStep_Lo 0x2E83 - -//TiltedPathMiddleStepActivated -#define TiltedPathMiddleStepActivated_Hi 0x0000 -#define TiltedPathMiddleStepActivated_Lo 0x2E83 - -//HomeStandToMin5 -#define HomeStandToMin5_Hi 0x0000 -#define HomeStandToMin5_Lo 0x2B08 - -//HomeStandToMin5Activated -#define HomeStandToMin5Activated_Hi 0x0000 -#define HomeStandToMin5Activated_Lo 0x2B08 - -//FirstEndStep -#define FirstEndStep_Hi 0x0000 -#define FirstEndStep_Lo 0x2A15 - -//FirstEndStepActivated -#define FirstEndStepActivated_Hi 0x0000 -#define FirstEndStepActivated_Lo 0x2A15 - -//SecondEndStep -#define SecondEndStep_Hi 0x0000 -#define SecondEndStep_Lo 0x2ED4 - -//SecondEndStepActivated -#define SecondEndStepActivated_Hi 0x0000 -#define SecondEndStepActivated_Lo 0x2ED4 - -//HomeForWalk25 -#define HomeForWalk25_Hi 0x0000 -#define HomeForWalk25_Lo 0x2AB7 - -//HomeForWalk25Activated -#define HomeForWalk25Activated_Hi 0x0000 -#define HomeForWalk25Activated_Lo 0x2AB7 - - -#endif //SD_ADDRESSES_H \ No newline at end of file diff --git a/include/Screen.h b/include/Screen.h deleted file mode 100644 index e14d22c..0000000 --- a/include/Screen.h +++ /dev/null @@ -1,57 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ - * Library implementing the software interface for a 4D Systems uOLED-160G2 microOLED * - * GOLDELOX Display. * - * Hardware consists of a screen with a set of ten pins on the back. * - * Pins "+5V" and "GND" should be connected to their respective voltages. * - * Pin "RES" should be connected to a digital output pin. * - * Pins "RX" and "TX" should be connected to the pins of a UART peripheral * - * interface. Note that the "RX" pin of the screen should be connected to the * - * "TX" pin of the UART interface, and vice versa. * - * The other pins should be unconnected. * - * ┌────────────────────┐ * - * │ 3.3V ──O O─┼── RES * - * │ GND ──O O─┼── GND * - * │ IO1 ──O O─┼── RX * - * │ IO2 ──O O─┼── TX * - * │ 5V OUT ──O O─┼── +5V * - * │ │ * - * │ │ * - * │ │ * - * └────────────────────┘ * - * * - * Created by P. Verton and M. van der Marel for Project MARCH * - * Date: 27-MAR-2018 * -\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef SCREEN_ -#define SCREEN_ -#include -#include "SoftwareSerial.h" -#include "Goldelox_Serial_4DLib.h" - -class Screen -{ -public: -//Constructors - Screen(Goldelox_Serial_4DLib * screen, SoftwareSerial * screenSerial, int rst, int baud); - -//Public member functions - void initialize(); - void clear(); - void reset(); - void draw_image(int addr_hi, int addr_lo); - -private: - SoftwareSerial * m_serial; - Goldelox_Serial_4DLib * m_screen; - int m_mediaInitialized; - int m_baud; - int m_rst; - int m_tx; - int m_rx; - unsigned long m_lastDrawTime; - const int m_waitTimeUs = 500000; // Needed for functioning, can still be optimized - -}; - -#endif //SCREEN_ \ No newline at end of file diff --git a/include/StateMachine.h b/include/StateMachine.h deleted file mode 100644 index adeb519..0000000 --- a/include/StateMachine.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef STATEMACHINE_H -#define STATEMACHINE_H - -#include -#include -#include -#include "SD_sector_addresses.h" - -enum class State { HomeSitStart, - HomeSitStartSelected, - HomeSitStartActivated, - StandUp, - StandUpSelected, - StandUpActivated, - TurnOffStart, - // TurnOffStartSelected, - // TurnOffStartActivated, - HomeStandStart, - HomeStandStartSelected, - HomeStandStartActivated, - - Sit, - SitSelected, - SitActivated, - HomeSit, - HomeSitSelected, - HomeSitActivated, - HomeStand, - HomeStandSelected, - HomeStandActivated, - TurnOff, - // TurnOffSelected, - // TurnOffActivated, - - Walk, - WalkSmall, - WalkNormal, - WalkLarge, - WalkSmallSelected, - WalkNormalSelected, - // WalkLargeSelected, - WalkSmallActivated, - WalkNormalActivated, - // WalkLargeActivated, - SingleStep, - SingleStepSmall, - SingleStepNormal, - SingleStepLarge, - SingleStepSmallSelected, - SingleStepNormalSelected, - // SingleStepLargeSelected, - SingleStepSmallActivated, - SingleStepNormalActivated, - // SingleStepLargeActivated, - SideStep, - SideStepLeft, - SideStepRight, - SideStepLeftNormal, - SideStepLeftNormalSelected, - SideStepLeftNormalActivated, - SideStepLeftSmall, - SideStepLeftSmallSelected, - SideStepLeftSmallActivated, - SideStepRightNormal, - SideStepRightNormalSelected, - SideStepRightNormalActivated, - SideStepRightSmall, - SideStepRightSmallSelected, - SideStepRightSmallActivated, - - Sofa, - SofaSit, - SofaSitSelected, - SofaSitActivated, - SofaStandUp, - SofaStandUpSelected, - SofaStandUpActivated, - - TiltedPath, - TiltedPathStartHomeToMin5, - TiltedPathStartHomeToMin5Selected, - TiltedPathStartHomeToMin5Activated, - FirstStartStep, - FirstStartStepActivated, - SecondStartStep, - SecondStartStepActivated, - HomeStandToMin10, - HomeStandToMin10Activated, - TiltedPathMiddleStep, - TiltedPathMiddleStepActivated, - HomeStandToMin5, - HomeStandToMin5Activated, - FirstEndStep, - FirstEndStepActivated, - SecondEndStep, - SecondEndStepActivated, - HomeForWalk25, - HomeForWalk25Activated, - - Stairs, - StairsUp, - StairsUpSelected, - StairsUpActivated, - StairsDown, - StairsDownSelected, - StairsDownActivated, - // StairsDownFinal, - // StairsDownFinalSelected, - // StairsDownFinalActivated, - - WalkObstacle, - WalkObstacleSmall, - WalkObstacleNormal, - WalkObstacleLarge, - WalkObstacleSmallSelected, // same image as WalkSmallSelected - WalkObstacleNormalSelected, // same image as WalkNormalSelected - // WalkObstacleLargeSelected, // same image as WalkLargeSelected - WalkObstacleSmallActivated, // same image as WalkSmallActivated - WalkObstacleNormalActivated, // same image as WalkNormalActivated - // WalkObstacleLargeActivated, // same image as WalkLargeActivated - SingleStepObstacle, - SingleStepObstacleSmall, - SingleStepObstacleNormal, - SingleStepObstacleLarge, - SingleStepObstacleSmallSelected, // same image as SingleStepSmallSelected - SingleStepObstacleNormalSelected, // same image as SingleStepNormalSelected - // SingleStepObstacleLargeSelected, // same image as SignleStepLargeSelected - SingleStepObstacleSmallActivated, // same image as SingleStepSmallActivated - SingleStepObstacleNormalActivated}; // same image as SingleStepNormalActivated - // SingleStepObstacleLargeActivated}; // same image as SingleStepLargeActivated - - - -class StateMachine -{ -private: - State currentState; - State rememberStateWIB; - State rememberStateSit; - State rememberStateObstacle; - State rememberStateObstacleWIB; - std::map stateToGaitMapping; - -public: - StateMachine(); - void updateState(String joystickState = "NEUTRAL", String joystickPress = "NEUTRAL", String rockerState = "NEUTRAL", String triggerPress = "NEUTRAL"); - int * getScreenImage(); - State getCurrentState(); - std::string getGaitNameOfState(State state); -}; - - - - -#endif // STATEMACHINE_H \ No newline at end of file diff --git a/include/button.h b/include/button.h new file mode 100644 index 0000000..a2e6291 --- /dev/null +++ b/include/button.h @@ -0,0 +1,25 @@ +#ifndef BUTTON_H +#define BUTTON_H +#include "button_state.h" + +#include + +class Button +{ +public: + explicit Button(uint8_t pin); + + ButtonState getState(); + +private: + const uint8_t input_pin_; + ButtonState last_position_ = ButtonState::NEUTRAL; + unsigned long last_print_time_ = 0; + + // Microseconds. May introduce unwanted behaviour if changed + const useconds_t bounce_time_ = 20000; + // Milliseconds. Determines how often 'push' is returned if the button is held + const unsigned long hold_time_ = 1000; +}; + +#endif // BUTTON_H diff --git a/include/button_state.h b/include/button_state.h new file mode 100644 index 0000000..358f37f --- /dev/null +++ b/include/button_state.h @@ -0,0 +1,14 @@ +#ifndef BUTTON_STATE_H +#define BUTTON_STATE_H + +enum class ButtonState +{ + NEUTRAL, + // It is advised to treat HOLDING the same as NEUTRAL + // as it is only used internally. + HOLDING, + PUSH, + DOUBLE, +}; + +#endif // BUTTON_STATE_H diff --git a/include/joystick.h b/include/joystick.h new file mode 100644 index 0000000..dd0aa70 --- /dev/null +++ b/include/joystick.h @@ -0,0 +1,48 @@ +#ifndef JOYSTICK_H +#define JOYSTICK_H +#include "button_state.h" +#include "joystick_state.h" + +#include + +class Joystick +{ +public: + Joystick(uint8_t left_pin, uint8_t right_pin, uint8_t up_pin, uint8_t down_pin, uint8_t press_pin); + + JoystickState getState(); + ButtonState getButtonState(); + +private: + const uint8_t left_pin_; + const uint8_t right_pin_; + const uint8_t up_pin_; + const uint8_t down_pin_; + const uint8_t press_pin_; + + JoystickState last_position_ = JoystickState::NEUTRAL; + ButtonState last_push_position_ = ButtonState::NEUTRAL; + unsigned long last_print_time_ = 0; + unsigned long last_push_print_time_ = 0; + bool recent_initial_click_ = false; + bool recent_double_click_ = false; + bool last_push_ = false; + unsigned long last_push_release_time_ = 0; + unsigned long last_double_click_time_ = 0; + + // Microseconds. May introduce unwanted behaviour if changed + const useconds_t bounce_time_ = 5000; + + // Milliseconds. Determines how often up or down + // are returned if the joystick is held. + const unsigned long hold_time_ = 1000; + + // Milliseconds. The duration before a second press is registered + // as a double click. + const unsigned long double_click_time_ = 300; + // Milliseconds. Timeout after a double click was registered + // before other commands can be registered. + const unsigned long double_click_timeout_time_ = 500; +}; + +#endif // JOYSTICK_H diff --git a/include/joystick_state.h b/include/joystick_state.h new file mode 100644 index 0000000..e76eff5 --- /dev/null +++ b/include/joystick_state.h @@ -0,0 +1,16 @@ +#ifndef JOYSTICK_STATE_H +#define JOYSTICK_STATE_H + +enum class JoystickState +{ + LEFT, + RIGHT, + UP, + DOWN, + NEUTRAL, + // It is advised to treat HOLDING the same as NEUTRAL + // as it is only used internally. + HOLDING, +}; + +#endif // JOYSTICK_STATE_H diff --git a/include/rocker_switch.h b/include/rocker_switch.h new file mode 100644 index 0000000..4fef8ea --- /dev/null +++ b/include/rocker_switch.h @@ -0,0 +1,28 @@ +#ifndef ROCKER_SWITCH_H +#define ROCKER_SWITCH_H +#include "rocker_switch_state.h" + +#include + +class RockerSwitch +{ +public: + explicit RockerSwitch(uint8_t up_pin, uint8_t down_pin); + + RockerSwitchState getState(); + +private: + const uint8_t up_pin_; + const uint8_t down_pin_; + RockerSwitchState last_position_ = RockerSwitchState::NEUTRAL; + unsigned long last_print_time_ = 0; + + // Microseconds. May introduce unwanted behaviour if changed + const useconds_t bounce_time_ = 20000; + + // Milliseconds. Determines how often up or down are returned if the rocker + // switch is held up or down. + const unsigned long hold_time_ = 1000; +}; + +#endif // ROCKER_SWITCH_H diff --git a/include/rocker_switch_state.h b/include/rocker_switch_state.h new file mode 100644 index 0000000..a184c31 --- /dev/null +++ b/include/rocker_switch_state.h @@ -0,0 +1,15 @@ +#ifndef ROCKER_SWITCH_STATE_H +#define ROCKER_SWITCH_STATE_H + +enum class RockerSwitchState +{ + NEUTRAL, + // It is advised to treat HOLDING X the same as NEUTRAL + // outside this function. + HOLDING_UP, + HOLDING_DOWN, + UP, + DOWN, +}; + +#endif // ROCKER_SWITCH_STATE_H diff --git a/include/screen.h b/include/screen.h new file mode 100644 index 0000000..f3342dd --- /dev/null +++ b/include/screen.h @@ -0,0 +1,67 @@ +/* + * Library implementing the software interface for a 4D Systems uOLED-160G2 + * microOLED GOLDELOX Display. + * + * Hardware consists of a screen with a set of ten pins on the back. + * + * * Pins "+5V" and "GND" should be connected to their respective voltages. + * * Pin "RES" should be connected to a digital output pin. + * * Pins "RX" and "TX" should be connected to the pins of a UART peripheral + * interface. Note that the "RX" pin of the screen should be connected + * to the "TX" pin of the UART interface, and vice versa. + * * The other pins should be unconnected. + * ┌────────────────────┐ + * │ 3.3V ──O O─┼── RES + * │ GND ──O O─┼── GND + * │ IO1 ──O O─┼── RX + * │ IO2 ──O O─┼── TX + * │ 5V OUT ──O O─┼── +5V + * │ │ + * │ │ + * │ │ + * └────────────────────┘ + * + * Created by P. Verton and M. van der Marel for Project MARCH + * Date: 27-MAR-2018 + */ +#ifndef SCREEN_H +#define SCREEN_H +#include "sd_sector_addresses.h" + +#include +#include +#include + +class Screen +{ +public: + Screen(Goldelox_Serial_4DLib* screen, SoftwareSerial* screen_serial, uint8_t rst, uint32_t baud); + + void init(); + void clear(); + void draw_image(const SectorAddress& address); + +private: + void reset(); + + void printVersion(); + void mountImages(); + + Goldelox_Serial_4DLib* screen_; + SoftwareSerial* serial_; + + const uint8_t rst_; + const uint32_t baud_; + + // Microseconds. Needed for functioning, can still be optimized + const useconds_t wait_time_ = 500000; + + // Milliseconds, when the screen should start scrolling + const word screen_saver_timeout_ = 10000; + // Must be value in 0-255 (fastest-slowest) + const word screen_saver_scroll_speed_ = 0; + // Milliseconds. Sets the time out limit for screen serial commands to 2 seconds. + const unsigned long time_limit_ = 2000; +}; + +#endif // SCREEN_H diff --git a/include/sd_sector_addresses.h b/include/sd_sector_addresses.h new file mode 100644 index 0000000..eeaeabf --- /dev/null +++ b/include/sd_sector_addresses.h @@ -0,0 +1,143 @@ +#ifndef SD_SECTOR_ADDRESSES_H +#define SD_SECTOR_ADDRESSES_H + +// This file defines the sector addresses of the images to be loaded on the +// screen The sector addresses can be found via the 4D Systems Workshop 4D IDE +// The Graphics Composer of this software should be used: +// - To load the desired images on the uSD card +// - To find the sector addresses of said images (via generated .Gc file) + +// A sector address on the SD card is defined by +// an address consisting of two parts: high and low bits. +// Both parts specify 2 bytes of the complete address +// So, address = hi << 8 | lo +// These two are split, since that is how the 4dsystems +// serial library addresses images on the SD. +struct SectorAddress +{ + unsigned int hi; + unsigned int lo; +}; + +// clang-format off + +/********** + * Start menu + **********/ +#define HOME_SIT_START SectorAddress { 0x0000, 0x0000 } +#define HOME_SIT_START_SELECTED SectorAddress { 0x0000, 0x00A2 } +#define HOME_SIT_START_ACTIVATED SectorAddress { 0x0000, 0x0051 } + +#define STAND_UP SectorAddress { 0x0000, 0x1209 } +#define STAND_UP_SELECTED SectorAddress { 0x0000, 0x12AB } +#define STAND_UP_ACTIVATED SectorAddress { 0x0000, 0x125A } + +#define HOME_STAND_START SectorAddress { 0x0000, 0x01E6 } +#define HOME_STAND_START_SELECTED SectorAddress { 0x0000, 0x0288 } +#define HOME_STAND_START_ACTIVATED SectorAddress { 0x0000, 0x0237 } + +#define TURN_OFF_START SectorAddress { 0x0000, 0x14E2 } +#define TURN_OFF_START_SELECTED SectorAddress { 0x0000, 0x1584 } +#define TURN_OFF_START_ACTIVATED SectorAddress { 0x0000, 0x1533 } +/***** Start menu *****/ + +/********** + * Walk menu + **********/ +#define WALK SectorAddress { 0x0000, 0x15D5 } +#define SIDE_STEP SectorAddress { 0x0000, 0x03CC } +#define SINGLE_STEP SectorAddress { 0x0000, 0x0603 } + +// Walk sizes +#define WALK_SMALL SectorAddress { 0x0000, 0x1950 } +#define WALK_SMALL_SELECTED SectorAddress { 0x0000, 0x19F2 } +#define WALK_SMALL_ACTIVATED SectorAddress { 0x0000, 0x19A1 } + +#define WALK_NORMAL SectorAddress { 0x0000, 0x1719 } +#define WALK_NORMAL_SELECTED SectorAddress { 0x0000, 0x17BB } +#define WALK_NORMAL_ACTIVATED SectorAddress { 0x0000, 0x176A } + +#define WALK_LARGE SectorAddress { 0x0000, 0x1626 } +// Missing WALK_LARGE_SELECTED and WALK_LARGE_ACTIVATED + +// Sidestep +#define SIDE_STEP_LEFT SectorAddress { 0x0000, 0x041D } +#define SIDE_STEP_RIGHT SectorAddress { 0x0000, 0x0510 } + +// Side step left +#define SIDE_STEP_LEFT_SMALL SectorAddress { 0x0000, 0x2F76 } +#define SIDE_STEP_LEFT_SMALL_SELECTED SectorAddress { 0x0000, 0x3018 } +#define SIDE_STEP_LEFT_SMALL_ACTIVATED SectorAddress { 0x0000, 0x2FC7 } + +#define SIDE_STEP_LEFT_NORMAL SectorAddress { 0x0000, 0x2C9D } +#define SIDE_STEP_LEFT_NORMAL_SELECTED SectorAddress { 0x0000, 0x2D3F } +#define SIDE_STEP_LEFT_NORMAL_ACTIVATED SectorAddress { 0x0000, 0x2CEE } + +// Side step right +#define SIDE_STEP_RIGHT_SMALL SectorAddress { 0x0000, 0x3069 } +#define SIDE_STEP_RIGHT_SMALL_SELECTED SectorAddress { 0x0000, 0x310B } +#define SIDE_STEP_RIGHT_SMALL_ACTIVATED SectorAddress { 0x0000, 0x30BA } + +#define SIDE_STEP_RIGHT_NORMAL SectorAddress { 0x0000, 0x2D90 } +#define SIDE_STEP_RIGHT_NORMAL_SELECTED SectorAddress { 0x0000, 0x2E32 } +#define SIDE_STEP_RIGHT_NORMAL_ACTIVATED SectorAddress { 0x0000, 0x0561 } + +// Single steps +#define SINGLE_STEP_SMALL SectorAddress { 0x0000, 0x097E } +#define SINGLE_STEP_SMALL_SELECTED SectorAddress { 0x0000, 0x0A20 } +#define SINGLE_STEP_SMALL_ACTIVATED SectorAddress { 0x0000, 0x09CF } + +#define SINGLE_STEP_NORMAL SectorAddress { 0x0000, 0x0747 } +#define SINGLE_STEP_NORMAL_SELECTED SectorAddress { 0x0000, 0x07E9 } +#define SINGLE_STEP_NORMAL_ACTIVATED SectorAddress { 0x0000, 0x0798 } + +#define SINGLE_STEP_LARGE SectorAddress { 0x0000, 0x0654 } +/***** Walk menu *****/ + +/********** + * Sit menu + **********/ +#define SIT SectorAddress { 0x0000, 0x222C } +#define SIT_SELECTED SectorAddress { 0x0000, 0x0B13 } +#define SIT_ACTIVATED SectorAddress { 0x0000, 0x0AC2 } + +#define HOME_SIT SectorAddress { 0x0000, 0x218A } +#define HOME_SIT_SELECTED SectorAddress { 0x0000, 0x00A2 } +#define HOME_SIT_ACTIVATED SectorAddress { 0x0000, 0x0051 } + +#define HOME_STAND SectorAddress { 0x0000, 0x21DB } +#define HOME_STAND_SELECTED SectorAddress { 0x0000, 0x0288 } +#define HOME_STAND_ACTIVATED SectorAddress { 0x0000, 0x0237 } + +#define TURN_OFF SectorAddress { 0x0000, 0x227D } +#define TURN_OFF_SELECTED SectorAddress { 0x0000, 0x1491 } +#define TURN_OFF_ACTIVATED SectorAddress { 0x0000, 0x1440 } +/***** Sit menu *****/ + +/********** + * Obstacle menu + **********/ +#define SOFA SectorAddress { 0x0000, 0x2505 } + +#define SOFA_SIT SectorAddress { 0x0000, 0x25F8 } +#define SOFA_SIT_SELECTED SectorAddress { 0x0000, 0x0E8E } +#define SOFA_SIT_ACTIVATED SectorAddress { 0x0000, 0x0E3D } + +#define SOFA_STANDUP SectorAddress { 0x0000, 0x2649 } +#define SOFA_STANDUP_SELECTED SectorAddress { 0x0000, 0x0F81 } +#define SOFA_STANDUP_ACTIVATED SectorAddress { 0x0000, 0x0F30 } + +#define STAIRS SectorAddress { 0x0000, 0x2556 } + +#define STAIRS_UP SectorAddress { 0x0000, 0x26EB } +#define STAIRS_UP_SELECTED SectorAddress { 0x0000, 0x11B8 } +#define STAIRS_UP_ACTIVATED SectorAddress { 0x0000, 0x1167 } + +#define STAIRS_DOWN SectorAddress { 0x0000, 0x269A } +#define STAIRS_DOWN_SELECTED SectorAddress { 0x0000, 0x10C5 } +#define STAIRS_DOWN_ACTIVATED SectorAddress { 0x0000, 0x1074 } +/***** Obstacle menu *****/ + +// clang-format on + +#endif // SD_SECTOR_ADDRESSES_H diff --git a/include/state.h b/include/state.h new file mode 100644 index 0000000..6a7d337 --- /dev/null +++ b/include/state.h @@ -0,0 +1,138 @@ +#ifndef STATE_H +#define STATE_H +#include "sd_sector_addresses.h" + +#include + +class State +{ +public: + State(SectorAddress address, const std::string& gait) : gait_(gait), address_(address) + { + } + + State(SectorAddress address) : State(address, "") + { + } + + const std::string& getGaitName() const + { + return this->gait_; + } + + SectorAddress getImage() const + { + return this->address_; + }; + + const State* left() const + { + return this->left_; + } + const State* right() const + { + return this->right_; + } + const State* up() const + { + return this->up_; + } + const State* down() const + { + return this->down_; + } + + const State* back() const + { + return this->back_; + } + const State* select() const + { + return this->select_; + } + const State* activate() const + { + return this->activate_; + } + + State& withLeft(State* left) + { + this->left_ = left; + left->right_ = this; + return *this; + } + + State& withRight(State* right) + { + this->right_ = right; + right->left_ = this; + return *this; + } + + State& withUp(State* up) + { + this->up_ = up; + up->down_ = this; + return *this; + } + + State& upTo(const State* up) + { + this->up_ = up; + return *this; + } + + State& withDown(State* down) + { + this->down_ = down; + down->up_ = this; + return *this; + } + + State& downTo(const State* down) + { + this->down_ = down; + return *this; + } + + State& withBack(State* back) + { + this->back_ = back; + back->select_ = this; + return *this; + } + + State& backTo(const State* back) + { + this->back_ = back; + return *this; + } + + State& withSelect(State* with_select) + { + this->select_ = with_select; + with_select->back_ = this; + return *this; + } + + State& withActivate(const State* activate) + { + this->activate_ = activate; + return *this; + } + +protected: + const std::string gait_; + const SectorAddress address_; + + const State* left_ = this; + const State* right_ = this; + const State* up_ = this; + const State* down_ = this; + + const State* back_ = this; + const State* select_ = this; + const State* activate_ = this; +}; + +#endif // STATE_H diff --git a/include/state_machine.h b/include/state_machine.h new file mode 100644 index 0000000..0ad73a5 --- /dev/null +++ b/include/state_machine.h @@ -0,0 +1,53 @@ +#ifndef STATE_MACHINE_H +#define STATE_MACHINE_H +#include "state.h" + +#include +#include + +class StateMachine +{ +public: + StateMachine() = default; + + void construct(); + + std::string getCurrentGaitName() const; + + SectorAddress getCurrentImage() const; + + size_t size() const; + + bool left(); + bool right(); + bool up(); + bool down(); + + bool back(); + bool select(); + bool activate(); + +private: + void constructWalkMenu(State* from); + void constructSideStepMenu(State* from); + void constructStepMenu(State* from); + void constructSofaMenu(State* from); + void constructStairsMenu(State* from); + + bool hasState() const; + bool setCurrentState(const State* new_state); + + State& createState(const SectorAddress address, const std::string& gait_name = ""); + + State& createGaitState(const SectorAddress addr, const SectorAddress addr_selected, + const SectorAddress addr_activated, const std::string& gait_name, + const State* result = nullptr); + + // This must be list, since that does not reallocate + // Items when it resizes, which a vector does. + // Otherwise all pointers in states would become invalid :) + std::list states_; + const State* current_state_ = nullptr; +}; + +#endif // STATE_MACHINE_H diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..5ecb6b3 --- /dev/null +++ b/include/version.h @@ -0,0 +1,8 @@ +#ifndef VERSION_H +#define VERSION_H + +#define ORGANIZATION "Project\n\rMarch" +#define PROJECT_NAME "input-device" +#define VERSION "v2.0.0-beta.1" + +#endif // VERSION_H diff --git a/include/WirelessConnection.h b/include/wireless_connection.h similarity index 80% rename from include/WirelessConnection.h rename to include/wireless_connection.h index 009065c..72366e4 100644 --- a/include/WirelessConnection.h +++ b/include/wireless_connection.h @@ -1,7 +1,7 @@ // Copyright 2018 Project March. - #ifndef WIRELESS_CONNECTION_H #define WIRELESS_CONNECTION_H +#include ////////////////////// // WiFi Definitions // ////////////////////// @@ -20,19 +20,10 @@ WiFiClient client; void setupWiFi() { WiFi.begin(ssid, password); - Serial.print("\nConnecting to "); - Serial.println(ssid); - uint8_t i = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); - Serial.print("Could not connect to "); - Serial.println(ssid); } - - Serial.print("Ready! Use "); - Serial.print(WiFi.localIP()); - Serial.println(" to access client"); } class WiFiHardware @@ -49,7 +40,8 @@ class WiFiHardware // read a byte from the serial port. -1 = failure int read() { - // Read byte from the TCP connection and returns it. returns -1 when not working + // Read byte from the TCP connection and returns it. returns -1 when not + // working return client.read(); } diff --git a/lib/Adafruit_DRV2605/.library.json b/lib/Adafruit_DRV2605/.library.json deleted file mode 100644 index 745cc79..0000000 --- a/lib/Adafruit_DRV2605/.library.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "Adafruit DRV2605 Library", - "version": "1.0.1", - "keywords": [ - "device", - "control" - ], - "description": "Arduino library for Adafruit DRV2605L Haptic Controller Breakout", - "frameworks": [ - "arduino" - ], - "platforms": [ - "atmelavr", - "atmelsam", - "espressif32", - "espressif8266", - "intel_arc32", - "microchippic32", - "nordicnrf51", - "nordicnrf52", - "ststm32", - "teensy", - "timsp430" - ], - "authors": [ - { - "email": "info@adafruit.com", - "url": null, - "maintainer": true, - "name": "Adafruit" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/adafruit/Adafruit_DRV2605_Library" - }, - "homepage": null, - "export": { - "include": null, - "exclude": [ - "extras", - "docs", - "tests", - "test", - "*.doxyfile", - "*.pdf" - ] - }, - "id": 632 -} \ No newline at end of file diff --git a/lib/Adafruit_DRV2605/examples/audio/audio.ino b/lib/Adafruit_DRV2605/examples/audio/audio.ino deleted file mode 100644 index 4322b9c..0000000 --- a/lib/Adafruit_DRV2605/examples/audio/audio.ino +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include "Adafruit_DRV2605.h" - -Adafruit_DRV2605 drv; - -void setup() { - Serial.begin(9600); - Serial.println("DRV2605 Audio responsive test"); - drv.begin(); - - - drv.setMode(DRV2605_MODE_AUDIOVIBE); - - // ac coupled input, puts in 0.9V bias - drv.writeRegister8(DRV2605_REG_CONTROL1, 0x20); - - // analog input - drv.writeRegister8(DRV2605_REG_CONTROL3, 0xA3); -} - - -void loop() { -} diff --git a/lib/Adafruit_DRV2605/examples/basic/basic.ino b/lib/Adafruit_DRV2605/examples/basic/basic.ino deleted file mode 100644 index b0b2ab5..0000000 --- a/lib/Adafruit_DRV2605/examples/basic/basic.ino +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include "Adafruit_DRV2605.h" - -Adafruit_DRV2605 drv; - -void setup() { - Serial.begin(9600); - Serial.println("DRV test"); - drv.begin(); - - drv.selectLibrary(1); - - // I2C trigger by sending 'go' command - // default, internal trigger when sending GO command - drv.setMode(DRV2605_MODE_INTTRIG); -} - -uint8_t effect = 1; - -void loop() { - Serial.print("Effect #"); Serial.println(effect); - - // set the effect to play - drv.setWaveform(0, effect); // play effect - drv.setWaveform(1, 0); // end waveform - - // play the effect! - drv.go(); - - // wait a bit - delay(500); - - effect++; - if (effect > 117) effect = 1; -} diff --git a/lib/Adafruit_DRV2605/examples/complex/complex.ino b/lib/Adafruit_DRV2605/examples/complex/complex.ino deleted file mode 100644 index 9b68ef6..0000000 --- a/lib/Adafruit_DRV2605/examples/complex/complex.ino +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include "Adafruit_DRV2605.h" - -Adafruit_DRV2605 drv; - -void setup() { - Serial.begin(9600); - Serial.println("DRV test"); - drv.begin(); - - // I2C trigger by sending 'go' command - drv.setMode(DRV2605_MODE_INTTRIG); // default, internal trigger when sending GO command - - drv.selectLibrary(1); - drv.setWaveform(0, 84); // ramp up medium 1, see datasheet part 11.2 - drv.setWaveform(1, 1); // strong click 100%, see datasheet part 11.2 - drv.setWaveform(2, 0); // end of waveforms -} - -void loop() { - drv.go(); - delay(1000); -} diff --git a/lib/Adafruit_DRV2605/examples/realtime/realtime.ino b/lib/Adafruit_DRV2605/examples/realtime/realtime.ino deleted file mode 100644 index 1eedfce..0000000 --- a/lib/Adafruit_DRV2605/examples/realtime/realtime.ino +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include "Adafruit_DRV2605.h" - -Adafruit_DRV2605 drv; - -void setup() { - Serial.begin(9600); - Serial.println("DRV test"); - drv.begin(); - - // Set Real-Time Playback mode - drv.setMode(DRV2605_MODE_REALTIME); -} - -uint8_t rtp_index = 0; -uint8_t rtp[] = { - 0x30, 100, 0x32, 100, - 0x34, 100, 0x36, 100, - 0x38, 100, 0x3A, 100, - 0x00, 100, - 0x40, 200, 0x00, 100, - 0x40, 200, 0x00, 100, - 0x40, 200, 0x00, 100 -}; - -void loop() { - - if (rtp_index < sizeof(rtp)/sizeof(rtp[0])) { - drv.setRealtimeValue(rtp[rtp_index]); - rtp_index++; - delay(rtp[rtp_index]); - rtp_index++; - } else { - drv.setRealtimeValue(0x00); - delay(1000); - rtp_index = 0; - } - -} diff --git a/lib/Adafruit_DRV2605/library.properties b/lib/Adafruit_DRV2605/library.properties deleted file mode 100644 index 8b1c806..0000000 --- a/lib/Adafruit_DRV2605/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=Adafruit DRV2605 Library -version=1.0.1 -author=Adafruit -maintainer=Adafruit -sentence=Arduino library for Adafruit DRV2605L Haptic Controller Breakout -paragraph=Arduino library for Adafruit DRV2605L Haptic Controller Breakout -category=Device Control -url=https://github.com/adafruit/Adafruit_DRV2605_Library -architectures=* diff --git a/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.cpp b/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.cpp deleted file mode 100644 index 0cdbf70..0000000 --- a/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/*************************************************** - This is a library for the Adafruit DRV2605L Haptic Driver - - ----> http://www.adafruit.com/products/2306 - - Check out the links above for our tutorials and wiring diagrams - This motor/haptic driver uses I2C to communicate - - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#include - -#include - -/**************************************************************************/ -/*! - @brief Instantiates a new DRV2605 class -*/ -/**************************************************************************/ -// I2C, no address adjustments or pins -Adafruit_DRV2605::Adafruit_DRV2605() { -} - - -/**************************************************************************/ -/*! - @brief Setups the HW -*/ -/**************************************************************************/ -boolean Adafruit_DRV2605::begin() { - Wire.begin(); - uint8_t id = readRegister8(DRV2605_REG_STATUS); - //Serial.print("Status 0x"); Serial.println(id, HEX); - - writeRegister8(DRV2605_REG_MODE, 0x00); // out of standby - - writeRegister8(DRV2605_REG_RTPIN, 0x00); // no real-time-playback - - writeRegister8(DRV2605_REG_WAVESEQ1, 1); // strong click - writeRegister8(DRV2605_REG_WAVESEQ2, 0); - - writeRegister8(DRV2605_REG_OVERDRIVE, 0); // no overdrive - - writeRegister8(DRV2605_REG_SUSTAINPOS, 0); - writeRegister8(DRV2605_REG_SUSTAINNEG, 0); - writeRegister8(DRV2605_REG_BREAK, 0); - writeRegister8(DRV2605_REG_AUDIOMAX, 0x64); - - // ERM open loop - - // turn off N_ERM_LRA - writeRegister8(DRV2605_REG_FEEDBACK, readRegister8(DRV2605_REG_FEEDBACK) & 0x7F); - // turn on ERM_OPEN_LOOP - writeRegister8(DRV2605_REG_CONTROL3, readRegister8(DRV2605_REG_CONTROL3) | 0x20); - - return true; -} - -void Adafruit_DRV2605::setWaveform(uint8_t slot, uint8_t w) { - writeRegister8(DRV2605_REG_WAVESEQ1+slot, w); -} - -void Adafruit_DRV2605::selectLibrary(uint8_t lib) { - writeRegister8(DRV2605_REG_LIBRARY, lib); -} - -void Adafruit_DRV2605::go() { - writeRegister8(DRV2605_REG_GO, 1); -} - -void Adafruit_DRV2605::setMode(uint8_t mode) { - writeRegister8(DRV2605_REG_MODE, mode); -} - -void Adafruit_DRV2605::setRealtimeValue(uint8_t rtp) { - writeRegister8(DRV2605_REG_RTPIN, rtp); -} - -/********************************************************************/ - -uint8_t Adafruit_DRV2605::readRegister8(uint8_t reg) { - uint8_t x ; - // use i2c - Wire.beginTransmission(DRV2605_ADDR); - Wire.write((byte)reg); - Wire.endTransmission(); - Wire.requestFrom((byte)DRV2605_ADDR, (byte)1); - x = Wire.read(); - - // Serial.print("$"); Serial.print(reg, HEX); - // Serial.print(": 0x"); Serial.println(x, HEX); - - return x; -} - -void Adafruit_DRV2605::writeRegister8(uint8_t reg, uint8_t val) { - // use i2c - Wire.beginTransmission(DRV2605_ADDR); - Wire.write((byte)reg); - Wire.write((byte)val); - Wire.endTransmission(); -} - -/****************/ - - -// Allow users to use ERM motor or LRA motors - -void Adafruit_DRV2605::useERM () -{ - writeRegister8(DRV2605_REG_FEEDBACK, readRegister8(DRV2605_REG_FEEDBACK) & 0x7F); -} - -void Adafruit_DRV2605::useLRA () -{ - writeRegister8(DRV2605_REG_FEEDBACK, readRegister8(DRV2605_REG_FEEDBACK) | 0x80); -} - - - diff --git a/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.h b/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.h deleted file mode 100644 index 48563b0..0000000 --- a/lib/Adafruit_DRV2605/src/Adafruit_DRV2605.h +++ /dev/null @@ -1,93 +0,0 @@ -/*************************************************** - This is a library for the Adafruit DRV2605L Haptic Driver - - ----> http://www.adafruit.com/products/2305 - - Check out the links above for our tutorials and wiring diagrams - This motor/haptic driver uses I2C to communicate - - Adafruit invests time and resources providing this open source code, - please support Adafruit and open-source hardware by purchasing - products from Adafruit! - - Written by Limor Fried/Ladyada for Adafruit Industries. - MIT license, all text above must be included in any redistribution - ****************************************************/ - - -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -#include - -#define DRV2605_ADDR 0x5A - -#define DRV2605_REG_STATUS 0x00 -#define DRV2605_REG_MODE 0x01 -#define DRV2605_MODE_INTTRIG 0x00 -#define DRV2605_MODE_EXTTRIGEDGE 0x01 -#define DRV2605_MODE_EXTTRIGLVL 0x02 -#define DRV2605_MODE_PWMANALOG 0x03 -#define DRV2605_MODE_AUDIOVIBE 0x04 -#define DRV2605_MODE_REALTIME 0x05 -#define DRV2605_MODE_DIAGNOS 0x06 -#define DRV2605_MODE_AUTOCAL 0x07 - - -#define DRV2605_REG_RTPIN 0x02 -#define DRV2605_REG_LIBRARY 0x03 -#define DRV2605_REG_WAVESEQ1 0x04 -#define DRV2605_REG_WAVESEQ2 0x05 -#define DRV2605_REG_WAVESEQ3 0x06 -#define DRV2605_REG_WAVESEQ4 0x07 -#define DRV2605_REG_WAVESEQ5 0x08 -#define DRV2605_REG_WAVESEQ6 0x09 -#define DRV2605_REG_WAVESEQ7 0x0A -#define DRV2605_REG_WAVESEQ8 0x0B - -#define DRV2605_REG_GO 0x0C -#define DRV2605_REG_OVERDRIVE 0x0D -#define DRV2605_REG_SUSTAINPOS 0x0E -#define DRV2605_REG_SUSTAINNEG 0x0F -#define DRV2605_REG_BREAK 0x10 -#define DRV2605_REG_AUDIOCTRL 0x11 -#define DRV2605_REG_AUDIOLVL 0x12 -#define DRV2605_REG_AUDIOMAX 0x13 -#define DRV2605_REG_RATEDV 0x16 -#define DRV2605_REG_CLAMPV 0x17 -#define DRV2605_REG_AUTOCALCOMP 0x18 -#define DRV2605_REG_AUTOCALEMP 0x19 -#define DRV2605_REG_FEEDBACK 0x1A -#define DRV2605_REG_CONTROL1 0x1B -#define DRV2605_REG_CONTROL2 0x1C -#define DRV2605_REG_CONTROL3 0x1D -#define DRV2605_REG_CONTROL4 0x1E -#define DRV2605_REG_VBAT 0x21 -#define DRV2605_REG_LRARESON 0x22 - - -class Adafruit_DRV2605 { - public: - - Adafruit_DRV2605(void); - boolean begin(void); - - void writeRegister8(uint8_t reg, uint8_t val); - uint8_t readRegister8(uint8_t reg); - void setWaveform(uint8_t slot, uint8_t w); - void selectLibrary(uint8_t lib); - void go(void); - void setMode(uint8_t mode); - void setRealtimeValue(uint8_t rtp); - // Select ERM (Eccentric Rotating Mass) or LRA (Linear Resonant Actuator) vibration motor - // The default is ERM, which is more common - void useERM(); - void useLRA(); - - private: - -}; - diff --git a/lib/Goldelox_Serial/Goldelox_Const4D.h b/lib/Goldelox_Serial/Goldelox_Const4D.h deleted file mode 100644 index 208ed41..0000000 --- a/lib/Goldelox_Serial/Goldelox_Const4D.h +++ /dev/null @@ -1,654 +0,0 @@ -// undef windows definitions that are also 4DGL definitions -#ifdef TRANSPARENT - #undef TRANSPARENT -#endif -#ifdef OPAQUE - #undef OPAQUE -#endif -#ifdef BAUD_110 - #undef BAUD_110 -#endif -#ifdef BAUD_300 - #undef BAUD_300 -#endif -#ifdef BAUD_600 - #undef BAUD_600 -#endif -#ifdef BAUD_1200 - #undef BAUD_1200 -#endif -#ifdef BAUD_2400 - #undef BAUD_2400 -#endif -#ifdef BAUD_4800 - #undef BAUD_4800 -#endif -#ifdef BAUD_9600 - #undef BAUD_9600 -#endif -#ifdef BAUD_14400 - #undef BAUD_14400 -#endif -#ifdef BAUD_19200 - #undef BAUD_19200 -#endif -#ifdef BAUD_38400 - #undef BAUD_38400 -#endif -#ifdef BAUD_57600 - #undef BAUD_57600 -#endif -#ifdef BAUD_115200 - #undef BAUD_115200 -#endif - -#ifdef TEXT - #undef TEXT -#endif - -/* - //---------------------------------- - // 4DGL - GOLDELOX-GFX2 PLATFORM - //---------------------------------- - - -*/ -/* - System Primitives for 4DGL GOLDELOX GFX2 Platform -*/ - - -//==============================================// -// initialization table additional commands // -//==============================================// -#define INIT_TABLE_END 0xFF // end of initialization table marker -#define INIT_TABLE_DELAY 0xFE // insert delay value -#define INIT_TABLE_16BIT_INDEX_REG_MODE 0xFD // 16 bit display index register -#define INIT_TABLE_8BIT_INDEX_REG_MODE 0xFC // 8 bit display index register -#define INIT_TABLE_16BIT_DUMMY_READ 0xFB // 16 bit display dummy read -#define INIT_TABLE_PORTRAIT 0xFA // initial screen mode requirement -#define INIT_TABLE_LANDSCAPE 0xF9 -#define INIT_TABLE_PORTRAIT_R 0xF8 -#define INIT_TABLE_LANDSCAPE_R 0xF7 - -//==============================================// -// putch, putstr, putnum and print redirection // -// constants // -//==============================================// -#define APPEND 0x0000 -#define COM0 0xFF04 -#define TEXT 0xFF08 -#define MDA 0xFF10 - -//==============================================// -// general number formatting constants // -// for 'print' and 'putnum' // -//==============================================// - // string processing constants -#define STR 0x0080 // display as string -#define CHR 0x0081 // display as single char - - - - // binary, no leading zeroes -#define BIN4d 0x0002 // binary, 16 digits, no leading zeroes -#define BIN1 0x0102 // binary, 1 digit, no leading zeroes -#define BIN2 0x0202 // binary, 2 digits, no leading zeroes -#define BIN3 0x0302 // binary, 3 digits, no leading zeroes -#define BIN4 0x0402 // binary, 4 digits, no leading zeroes -#define BIN5 0x0502 // binary, 5 digits, no leading zeroes -#define BIN6 0x0602 // binary, 6 digits, no leading zeroes -#define BIN7 0x0702 // binary, 7 digits, no leading zeroes -#define BIN8 0x0802 // binary, 8 digits, no leading zeroes -#define BIN9 0x0902 // binary, 9 digits, no leading zeroes -#define BIN10 0x0A02 // binary, 10 digits, no leading zeroes -#define BIN11 0x0B02 // binary, 11 digits, no leading zeroes -#define BIN12 0x0C02 // binary, 12 digits, no leading zeroes -#define BIN13 0x0D02 // binary, 13 digits, no leading zeroes -#define BIN14 0x0E02 // binary, 14 digits, no leading zeroes -#define BIN15 0x0F02 // binary, 15 digits, no leading zeroes -#define BIN16 0x0002 // binary, 16 digits, no leading zeroes - - // binary, with leading zeroes -#define BINZ 0x1002 // binary, 16 digits, leading zeroes -#define BIN1Z 0x1102 // binary, 1 digit, leading zeroes -#define BIN2Z 0x1202 // binary, 2 digits, leading zeroes -#define BIN3Z 0x1302 // binary, 3 digits, leading zeroes -#define BIN4Z 0x1402 // binary, 4 digits, leading zeroes -#define BIN5Z 0x1502 // binary, 5 digits, leading zeroes -#define BIN6Z 0x1602 // binary, 6 digits, leading zeroes -#define BIN7Z 0x1702 // binary, 7 digits, leading zeroes -#define BIN8Z 0x1802 // binary, 8 digits, leading zeroes -#define BIN9Z 0x1902 // binary, 9 digits, leading zeroes -#define BIN10Z 0x1A02 // binary, 10 digits, leading zeroes -#define BIN11Z 0x1B02 // binary, 11 digits, leading zeroes -#define BIN12Z 0x1C02 // binary, 12 digits, leading zeroes -#define BIN13Z 0x1D02 // binary, 13 digits, leading zeroes -#define BIN14Z 0x1E02 // binary, 14 digits, leading zeroes -#define BIN15Z 0x1F02 // binary, 15 digits, leading zeroes -#define BIN16Z 0x1002 // binary, 16 digits, leading zeroes - - // binary, with leading blanked -#define BINZB 0x2002 // binary, 16 digits, leading blanks -#define BIN1ZB 0x2102 // binary, 1 digit, leading blanks -#define BIN2ZB 0x2202 // binary, 2 digits, leading blanks -#define BIN3ZB 0x2302 // binary, 3 digits, leading blanks -#define BIN4ZB 0x2402 // binary, 4 digits, leading blanks -#define BIN5ZB 0x2502 // binary, 5 digits, leading blanks -#define BIN6ZB 0x2602 // binary, 6 digits, leading blanks -#define BIN7ZB 0x2702 // binary, 7 digits, leading blanks -#define BIN8ZB 0x2802 // binary, 8 digits, leading blanks -#define BIN9ZB 0x2902 // binary, 9 digits, leading blanks -#define BIN10ZB 0x2A02 // binary, 10 digits, leading blanks -#define BIN11ZB 0x2B02 // binary, 11 digits, leading blanks -#define BIN12ZB 0x2C02 // binary, 12 digits, leading blanks -#define BIN13ZB 0x2D02 // binary, 13 digits, leading blanks -#define BIN14ZB 0x2E02 // binary, 14 digits, leading blanks -#define BIN15ZB 0x2F02 // binary, 15 digits, leading blanks -#define BIN16ZB 0x2002 // binary, 16 digits, leading blanks - - // signed decimal, no leading zeroes -#define DEC4d 0x050A // signed decimal, 5 digits, no leading zeroes -#define DEC1 0x010A // signed decimal, 1 digit, no leading zeroes -#define DEC2 0x020A // signed decimal, 2 digits, no leading zeroes -#define DEC3 0x030A // signed decimal, 3 digits, no leading zeroes -#define DEC4 0x040A // signed decimal, 4 digits, no leading zeroes -#define DEC5 0x050A // signed decimal, 5 digits, no leading zeroes - - // signed decimal, with leading zeroes -#define DECZ 0x150A // signed decimal, 5 digits, leading zeroes -#define DEC1Z 0x110A // signed decimal, 1 digit, leading zeroes -#define DEC2Z 0x120A // signed decimal, 2 digits, leading zeroes -#define DEC3Z 0x130A // signed decimal, 3 digits, leading zeroes -#define DEC4Z 0x140A // signed decimal, 4 digits, leading zeroes -#define DEC5Z 0x150A // signed decimal, 5 digits, leading zeroes - - // signed decimal, leading zeroes blanked -#define DECZB 0x250A // signed decimal, 5 digits, leading blanks -#define DEC1ZB 0x210A // signed decimal, 1 digit, leading blanks -#define DEC2ZB 0x220A // signed decimal, 2 digits, leading blanks -#define DEC3ZB 0x230A // signed decimal, 3 digits, leading blanks -#define DEC4ZB 0x240A // signed decimal, 4 digits, leading blanks -#define DEC5ZB 0x250A // signed decimal, 5 digits, leading blanks - - // unsigned decimal, no leading zeroes -#define UDEC 0x450A // unsigned decimal, 5 digits, no leading zeroes -#define UDEC1 0x410A // unsigned decimal, 1 digit, no leading zeroes -#define UDEC2 0x420A // unsigned decimal, 2 digits, no leading zeroes -#define UDEC3 0x430A // unsigned decimal, 3 digits, no leading zeroes -#define UDEC4 0x440A // unsigned decimal, 4 digits, no leading zeroes -#define UDEC5 0x450A // unsigned decimal, 5 digits, no leading zeroes - - // unsigned decimal, with leading zero's -#define UDECZ 0x550A // unsigned decimal, 5 digits, leading zeroes -#define UDEC1Z 0x510A // unsigned decimal, 1 digit, leading zeroes -#define UDEC2Z 0x520A // unsigned decimal, 2 digits, leading zeroes -#define UDEC3Z 0x530A // unsigned decimal, 3 digits, leading zeroes -#define UDEC4Z 0x540A // unsigned decimal, 4 digits, leading zeroes -#define UDEC5Z 0x550A // unsigned decimal, 5 digits, leading zeroes - - // unsigned decimal, leading zeroes blanked -#define UDECZB 0x650A // unsigned decimal, 5 digits, leading blanks -#define UDEC1ZB 0x610A // unsigned decimal, 1 digit, leading blanks -#define UDEC2ZB 0x620A // unsigned decimal, 2 digits, leading blanks -#define UDEC3ZB 0x630A // unsigned decimal, 3 digits, leading blanks -#define UDEC4ZB 0x640A // unsigned decimal, 4 digits, leading blanks -#define UDEC5ZB 0x650A // unsigned decimal, 5 digits, leading blanks - - // hex, with leading zero's -#define HEX4d 0x1410 // hex, 4 digits, leading zeroes -#define HEX1 0x1110 // hex, 1 digit, leading zeroes -#define HEX2 0x1210 // hex, 2 digits, leading zeroes -#define HEX3 0x1310 // hex, 3 digits, leading zeroes -#define HEX4 0x1410 // hex, 4 digits, leading zeroes - - // hex, no leading zero's -#define HEXZ 0x0410 // hex, 4 digits, no leading zeroes -#define HEX1Z 0x0110 // hex, 1 digit, no leading zeroes -#define HEX2Z 0x0210 // hex, 2 digits, no leading zeroes -#define HEX3Z 0x0310 // hex, 3 digits, no leading zeroes -#define HEX4Z 0x0410 // hex, 4 digits, no leading zeroes - - // hex, leading zero's blanked -#define HEXZB 0x2410 // hex, 4 digits, leading blanks -#define HEX1ZB 0x2110 // hex, 1 digit, leading blanks -#define HEX2ZB 0x2210 // hex, 2 digits, leading blanks -#define HEX3ZB 0x2310 // hex, 3 digits, leading blanks -#define HEX4ZB 0x2410 // hex, 4 digits, leading blanks - -// baud divisor rates -#define MIDI 95 -#define BAUD_110 27271 -#define BAUD_300 9999 -#define BAUD_600 4999 -#define BAUD_1200 2499 -#define BAUD_2400 1249 -#define BAUD_4800 624 -#define BAUD_9600 312 -#define BAUD_14400 207 -#define BAUD_19200 155 -#define BAUD_31250 95 -#define BAUD_38400 77 -#define BAUD_56000 53 -#define BAUD_57600 51 -#define BAUD_115200 25 -#define BAUD_128000 22 -#define BAUD_256000 11 -#define BAUD_300000 10 -#define BAUD_375000 8 -#define BAUD_500000 6 -#define BAUD_600000 4 - - -//==============================================// -// generic constants // -//==============================================// -#define ENABLE 1 -#define DISABLE 0 -#define ON 1 -#define OFF 0 -#define TRUE 1 -#define FALSE 0 - -//==============================================// -// joystick() function return constants // -//==============================================// -#define RELEASED 0 -#define UP 1 -#define LEFT 2 -#define DOWN 3 -#define RIGHT 4 -#define FIRE 5 - -//==============================================// -// spi_Init(...) mode arguments // -//==============================================// -#define SPI_SLOW 2 // 750khz -#define SPI_MED 1 // 3mhz -#define SPI_FAST 0 // 12mhz -#define RXMODE_0 0 // receive sample pos -#define RXMODE_1 1 // receive sample pos -#define CKMODE_0 0 // transmit sample pos -#define CKMODE_1 1 // transmit sample pos -#define CKMODE_2 2 // transmit sample pos -#define CKMODE_3 3 // transmit sample pos - -//==============================================// -//Pin related constants // -//==============================================// -#define IO1 0 -#define IO2 1 -#define LO 0 -#define HI 1 -#define OUTPUT4d 0 -#define INPUT4d 1 -#define ANALOGUE_8 2 -#define ANALOGUE_10 3 -#define ONEWIRE 4 -#define SOUND 5 - -//==============================================// -//gfx_Set() related constants // -//==============================================// -#define PEN_SIZE 0 // not necessary to use (legacy mode) -#define BACKGROUND_COLOUR 1 // screen background colour -#define OBJECT_COLOUR 2 // line / circle / rectangle generic colour -#define CLIPPING 3 // clipping ON / OFF -#define TRANSPARENT_COLOUR 4 // (only on displays with specific hware feature) -#define TRANSPARENCY 5 // 0 = OFF, 1 = ON (only on displays with specific hware feature) -#define FRAME_DELAY 6 // legacy mode, see pokeB(IMAGE_DELAY, n); -#define SCREEN_MODE 7 // LANDSCAPE, LANDSCAPE_R, PORTRAIT, PORTRAIT_R -#define OUTLINE_COLOUR 8 // if not BLACK (0) , used for outline around circles and rectanglse -#define CONTRAST 9 // set contrast ratuio in uOLED modules -#define LINE_PATTERN 10 // used for patterned lines, 16bit value (0 = no pattern) -#define COLOUR_MODE 11 // select 8 or 16 bit colour mode - - -#define SOLID 0 // PEN_SIZE argument (gfx_Set legacy mode) -#define OUTLINE 1 // PEN_SIZE argument (gfx_Set legacy mode) - -#define LANDSCAPE 0 // SCREEN_MODE (north) -#define LANDSCAPE_R 1 // SCREEN_MODE (south) -#define PORTRAIT 2 // SCREEN_MODE (west) -#define PORTRAIT_R 3 // SCREEN_MODE (east) - -#define COLOUR8 1 // COLOUR_MODE 8 bit colour mode -#define COLOUR16 0 // COLOUR_MODE 16 bit colour mode - -//==============================================// -//txt_Set() related constants // -//==============================================// -#define TEXT_COLOUR 0 // text foreground colr -#define TEXT_HIGHLIGHT 1 // text background colr -#define FONT_ID 2 // default 0, else points to data statement font -#define TEXT_WIDTH 3 // text width multiplier -#define TEXT_HEIGHT 4 // text height multiplier -#define TEXT_XGAP 5 // horizontal text gap (default 1) -#define TEXT_YGAP 6 // vertical text gap (default 1) -#define TEXT_PRINTDELAY 7 // for 'teletype' like effect when pronting -#define TEXT_OPACITY 8 // text mode flag, TRANSPARENT or OPAQUE -#define TEXT_BOLD 9 // embolden text (auto reset) - legacy -#define TEXT_ITALIC 10 // italicize text (auto reset) -#define TEXT_INVERSE 11 // invert text (auto reset) -#define TEXT_UNDERLINED 12 // underline text (auto reset) -#define TEXT_ATTRIBUTES 13 // controls BOLD/ITALIC/INVERSE/UNDERLINE simultaneously - -//==============================================// -//txt_Set() related arguments // -//==============================================// -#define SYSTEM 0 // internal system font -#define MEDIA 7 // font is at uSD_add - - -#define TRANSPARENT 0 // TEXT_OPACITY transparent text -#define OPAQUE 1 // TEXT_OPACITY opaque text - -#define BOLD 16 // TEXT_ATTRIBUTES bold text (auto reset) -#define ITALIC 32 // TEXT_ATTRIBUTES italic text (auto reset) -#define INVERSE 64 // TEXT_ATTRIBUTES inverse text (auto reset) -#define UNDERLINED 128 // TEXT_ATTRIBUTES underlined text (auto reset) - - -//==============================================// -// Memory MAP // -// system BYTE variables accesible with // -// peekB and pokeB // -//==============================================// -#define VX1 128 // display hardware x1 pos -#define VY1 129 // display hardware y1 pos -#define VX2 130 // display hardware x2 pos -#define VY2 131 // display hardware y2 pos -#define SYS_X_MAX 132 // display hardware X res-1 -#define SYS_Y_MAX 133 // display hardware Y res-1 -#define WRITE_GRAM_REG 134 // device register address for write operation -#define READ_GRAM_REG 135 // device register address for write operation -#define IMAGE_WIDTH 136 // width of currently loaded image -#define IMAGE_HEIGHT 137 // height of currently loaded image -#define IMAGE_DELAY 138 // 0 if image, else inter frame delay for movie -#define IMAGE_MODE 139 // bit 4 determines colr mode, other bits reserved -#define CLIP_LEFT_POS 140 // left clipping point (set with gfx_ClipWindow(...) -#define CLIP_TOP_POS 141 // top clipping point (set with gfx_ClipWindow(...) -#define CLIP_RIGHT_POS 142 // right clipping point (set with gfx_ClipWindow(...) -#define CLIP_BOTTOM_POS 143 // bottom clipping point (set with gfx_ClipWindow(...) -#define CLIP_LEFT 144 // current clip value (reads as full size if clipping turned off) -#define CLIP_TOP 145 // current clip value (reads as full size if clipping turned off) -#define CLIP_RIGHT 146 // current clip value (reads as full size if clipping turned off) -#define CLIP_BOTTOM 147 // current clip value (reads full size if clipping turned off) -#define FONT_TYPE 148 // font type, 0 = system font, else pointer to user or media font -#define FONT_MAX 149 // number of chars in current font -#define FONT_OFFSET 150 // starting offset (normally 0x20) -#define FONT_WIDTH 151 // current font width -#define FONT_HEIGHT 152 // current font height -#define TEXT_XMAG 153 // text width magnification -#define TEXT_YMAG 154 // text height magnification -#define TEXT_MARGIN 155 // left column for carriage return -#define TEXT_DELAY 156 // print delay -#define TEXT_X_GAP 157 // text horizontal gap size -#define TEXT_Y_GAP 158 // text vertical gap size -#define GFX_XMAX 159 // current display width-1 determined by portrait / landscape swapping -#define GFX_YMAX 160 // current display width-1 determined by portrait / landscape swapping -#define GFX_SCREENMODE 161 // holds current screen mode - // - - -//==============================================// -// system WORD variables accesible with peekW // -// and pokeW or pointer access // -//==============================================// -#define VM_OVERFLOW 83 // 16bit overflow of 32bit results (see OVF() funtion) -#define VM_COLOUR 84 // general working var for colour -#define VM_RETVAL 85 // last value returned from any function -#define GFX_BACK_COLOUR 86 // screen background colour -#define GFX_OBJECT_COLOUR 87 // graphics object colour -#define GFX_TEXT_COLOUR 88 // text forground colour -#define GFX_TEXT_BGCOLOUR 89 // text background colour -#define GFX_OUTLINE_COLOUR 90 // screen background colour -#define GFX_LINE_PATTERN 91 // line draw 16bit linear pattern -#define IMG_PIXEL_COUNT 92 // pixel count of current object (may be altered by clipping) -#define IMG_FRAME_COUNT 93 // count of frames in currently loaded video -#define MEDIA_HEAD 94 // media sector head position -#define SYS_OSTREAM 95 // system output redirection -#define GFX_LEFT 96 // virtual left point for current image -#define GFX_TOP 97 // virtual top point for current image -#define GFX_RIGHT 98 // virtual right point for current image -#define GFX_BOTTOM 99 // virtual bottom point for current image -#define GFX_X1 100 // clipped left point for current image -#define GFX_Y1 101 // clipped top point for current image -#define GFX_X2 102 // clipped right point for current image -#define GFX_Y2 103 // clipped bottom point for current image -#define GFX_X_ORG 104 // current Y origin -#define GFX_Y_ORG 105 // current Y origin -#define RANDOM_LO 106 // random number generator LO word -#define RANDOM_HI 107 // random number generator LO word -#define MEDIA_ADDR_LO 108 // uSD/FLASH absolute byte address LO -#define MEDIA_ADDR_HI 109 // uSD/FLASH absolute byte address HI -#define SECTOR_ADDR_LO 110 // uSD/FLASH sector address LO -#define SECTOR_ADDR_HI 111 // uSD/FLASH sector address HI -#define SYSTEM_TIMER_LO 112 // 1msec 32 bit free running timer LO word -#define SYSTEM_TIMER_HI 113 // 1msec 32 bit free running timer HI word -#define TIMER04d 114 // user timer0 -#define TIMER14d 115 // user timer1 -#define TIMER24d 116 // user timer2 -#define TIMER34d 117 // user timer3 (10msec resolution) -#define INCVAL 118 // incrementer size -#define TEMP_MEDIA_ADDRLO 119 // temp stroage while printing font from media storage -#define TEMP_MEDIA_ADDRHI 120 // temp stroage while printing font from media storage -#define GFX_TRANSPARENTCOLOUR 121 // image transparency colour -#define GFX_STRINGMETRIX 122 // low byte = string width, hi byte = string height -#define GFX_TEMPSTORE1 123 // low byte = last char printed, hi byte = frame timer over-ride - // reserved 124 // internal use - // reserved 125 // internal use -#define SYS_FLAGS1 126 // system control flags word 1 -#define SYS_FLAGS2 127 // system control flags word 2 - -//==============================================// -// bit constants for SYS_FLAGS1 // -//==============================================// -#define _STREAMLOCK 0x0001 // Used internally -#define _PENSIZE 0x0002 // object, 0=solid,1=outline -#define _OPACITY 0x0004 // text, 0=transparent,1=opaque -#define _OUTLINED 0x0008 // box/circle outline 0=off,1=on -#define _BOLD 0x0010 // text, 0=normal,1=bold (auto reset) -#define _ITALIC 0x0020 // Text, 0=normal,1=italic (auto reset) -#define _INVERSE 0x0040 // Text, 0=normal,1=inverse (auto reset) -#define _UNDERLINED 0x0080 // Text, 0=normal,1=underlined (auto reset) -#define _CLIPPING 0x0100 // Used internally, 0-clipping off, 1-clipping on -#define _STRMODE 0x0200 // Used internally -#define _SERMODE 0x0400 // Used internally -#define _TXTMODE 0x0800 // Used internally -#define _MEDIAMODE 0x1000 // Used internally -#define _PATTERNED 0x2000 // Used internally -#define _COLOUR8 0x4000 // Display mode, 0=16bit, 1=8bit -#define _MEDIAFONT 0x8000 // 0=internal font, 1=media font - -//==============================================// -// bit constants for SYS_FLAGS2 // -//==============================================// -#define _MEDIA_INSTALLED 0x0001 // SD of FLASH device is installed -#define _MEDIA_TYPE 0x0002 // 0=SD, 1=FLASH media device detected -#define _MEDIA_READ 0x0004 // 1=MEDIA read in progress -#define _MEDIA_WRITE 0x0008 // 1=MEDIA write in progress -#define _OW_PIN 0x0010 // 0=IO1, 1=IO2 (Dallas OW Pin) -#define _PTR_TYPE 0x0020 // Used internally -#define _TEMP1 0x0040 // Used internally -#define _TEMP2 0x0080 // Used internally -#define _RUNMODE 0x0100 // 1=running pcode from media -#define _SIGNED 0x0200 // 0=number printed '-' prepend -#define _RUNFLAG 0x0400 // 1=EVE processor is running SYSTEM -#define _SINGLESTEP 0x0800 // 1=set breakpoint for debugger -#define _COMMINT 0x1000 // 1=buffered comms active -#define _DUMMY16 0x2000 // 1=display needs 16bit dummy -#define _DISP16 0x4000 // 1=display is 16bit interface -#define _PROPFONT 0x8000 // 1=current font is proportional - - -//==============================================// -// EVE User Resources // -//==============================================// -#define USR_SP 128 // EVE user defined stack pointer -#define USRVARS 129 // EVE user variables VARS[255] -#define USRSTACK 384 // EVE machine stack STACK[128] - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ - -/* - 16 bit RGB (565) Colour Chart - Original work by 4D Forum Member: skadoo -*/ - - - -#define ALICEBLUE 0xF7DF -#define ANTIQUEWHITE 0xFF5A -#define AQUA 0x07FF -#define AQUAMARINE 0x7FFA -#define AZURE 0xF7FF -#define BEIGE 0xF7BB -#define BISQUE 0xFF38 -#define BLACK 0x0000 -#define BLANCHEDALMOND 0xFF59 -#define BLUE 0x001F -#define BLUEVIOLET 0x895C -#define BROWN 0xA145 -#define BURLYWOOD 0xDDD0 -#define CADETBLUE 0x5CF4 -#define CHARTREUSE 0x7FE0 -#define CHOCOLATE 0xD343 -#define CORAL 0xFBEA -#define CORNFLOWERBLUE 0x64BD -#define CORNSILK 0xFFDB -#define CRIMSON 0xD8A7 -#define CYAN 0x07FF -#define DARKBLUE 0x0011 -#define DARKCYAN 0x0451 -#define DARKGOLDENROD 0xBC21 -#define DARKGRAY 0xAD55 -#define DARKGREEN 0x0320 -#define DARKKHAKI 0xBDAD -#define DARKMAGENTA 0x8811 -#define DARKOLIVEGREEN 0x5345 -#define DARKORANGE 0xFC60 -#define DARKORCHID 0x9999 -#define DARKRED 0x8800 -#define DARKSALMON 0xECAF -#define DARKSEAGREEN 0x8DF1 -#define DARKSLATEBLUE 0x49F1 -#define DARKSLATEGRAY 0x2A69 -#define DARKTURQUOISE 0x067A -#define DARKVIOLET 0x901A -#define DEEPPINK 0xF8B2 -#define DEEPSKYBLUE 0x05FF -#define DIMGRAY 0x6B4D -#define DODGERBLUE 0x1C9F -#define FIREBRICK 0xB104 -#define FLORALWHITE 0xFFDE -#define FORESTGREEN 0x2444 -#define FUCHSIA 0xF81F -#define GAINSBORO 0xDEFB -#define GHOSTWHITE 0xFFDF -#define GOLD 0xFEA0 -#define GOLDENROD 0xDD24 -#define GRAY 0x8410 -#define GREEN 0x0400 -#define GREENYELLOW 0xAFE5 -#define HONEYDEW 0xF7FE -#define HOTPINK 0xFB56 -#define INDIANRED 0xCAEB -#define INDIGO 0x4810 -#define IVORY 0xFFFE -#define KHAKI 0xF731 -#define LAVENDER 0xE73F -#define LAVENDERBLUSH 0xFF9E -#define LAWNGREEN 0x7FE0 -#define LEMONCHIFFON 0xFFD9 -#define LIGHTBLUE 0xAEDC -#define LIGHTCORAL 0xF410 -#define LIGHTCYAN 0xE7FF -#define LIGHTGOLD 0xFFDA -#define LIGHTGREEN 0x9772 -#define LIGHTGREY 0xD69A -#define LIGHTPINK 0xFDB8 -#define LIGHTSALMON 0xFD0F -#define LIGHTSEAGREEN 0x2595 -#define LIGHTSKYBLUE 0x867F -#define LIGHTSLATEGRAY 0x7453 -#define LIGHTSTEELBLUE 0xB63B -#define LIGHTYELLOW 0xFFFC -#define LIME 0x07E0 -#define LIMEGREEN 0x3666 -#define LINEN 0xFF9C -#define MAGENTA 0xF81F -#define MAROON 0x8000 -#define MEDIUMAQUAMARINE 0x6675 -#define MEDIUMBLUE 0x0019 -#define MEDIUMORCHID 0xBABA -#define MEDIUMPURPLE 0x939B -#define MEDIUMSEAGREEN 0x3D8E -#define MEDIUMSLATEBLUE 0x7B5D -#define MEDIUMSPRINGGREEN 0x07D3 -#define MEDIUMTURQUOISE 0x4E99 -#define MEDIUMVIOLETRED 0xC0B0 -#define MIDNIGHTBLUE 0x18CE -#define MINTCREAM 0xF7FF -#define MISTYROSE 0xFF3C -#define MOCCASIN 0xFF36 -#define NAVAJOWHITE 0xFEF5 -#define NAVY 0x0010 -#define OLDLACE 0xFFBC -#define OLIVE 0x8400 -#define OLIVEDRAB 0x6C64 -#define ORANGE 0xFD20 -#define ORANGERED 0xFA20 -#define ORCHID 0xDB9A -#define PALEGOLDENROD 0xEF55 -#define PALEGREEN 0x9FD3 -#define PALETURQUOISE 0xAF7D -#define PALEVIOLETRED 0xDB92 -#define PAPAYAWHIP 0xFF7A -#define PEACHPUFF 0xFED7 -#define PERU 0xCC27 -#define PINK 0xFE19 -#define PLUM 0xDD1B -#define POWDERBLUE 0xB71C -#define PURPLE 0x8010 -#define RED 0xF800 -#define ROSYBROWN 0xBC71 -#define ROYALBLUE 0x435C -#define SADDLEBROWN 0x8A22 -#define SALMON 0xFC0E -#define SANDYBROWN 0xF52C -#define SEAGREEN 0x2C4A -#define SEASHELL 0xFFBD -#define SIENNA 0xA285 -#define SILVER 0xC618 -#define SKYBLUE 0x867D -#define SLATEBLUE 0x6AD9 -#define SLATEGRAY 0x7412 -#define SNOW 0xFFDF -#define SPRINGGREEN 0x07EF -#define STEELBLUE 0x4416 -#define TAN 0xD5B1 -#define TEAL 0x0410 -#define THISTLE 0xDDFB -#define TOMATO 0xFB08 -#define TURQUOISE 0x471A -#define VIOLET 0xEC1D -#define WHEAT 0xF6F6 -#define WHITE 0xFFFF -#define WHITESMOKE 0xF7BE -#define YELLOW 0xFFE0 -#define YELLOWGREEN 0x9E66 - - - - - - - - - - diff --git a/lib/Goldelox_Serial/Goldelox_Const4DSerial.h b/lib/Goldelox_Serial/Goldelox_Const4DSerial.h deleted file mode 100644 index 428c157..0000000 --- a/lib/Goldelox_Serial/Goldelox_Const4DSerial.h +++ /dev/null @@ -1,71 +0,0 @@ -#define F_charheight 1 -#define F_charwidth 2 -#define F_gfx_BGcolour -146 -#define F_gfx_ChangeColour -66 -#define F_gfx_Circle -51 -#define F_gfx_CircleFilled -52 -#define F_gfx_Clipping -148 -#define F_gfx_ClipWindow -65 -#define F_gfx_Cls -41 -#define F_gfx_Contrast -154 -#define F_gfx_FrameDelay -151 -#define F_gfx_GetPixel -54 -#define F_gfx_Line -46 -#define F_gfx_LinePattern -155 -#define F_gfx_LineTo -44 -#define F_gfx_MoveTo -42 -#define F_gfx_Orbit 3 -#define F_gfx_OutlineColour -153 -#define F_gfx_Polygon 4 -#define F_gfx_Polyline 5 -#define F_gfx_PutPixel -53 -#define F_gfx_Rectangle -49 -#define F_gfx_RectangleFilled -50 -#define F_gfx_ScreenMode -152 -#define F_gfx_Set -40 -#define F_gfx_SetClipRegion -68 -#define F_gfx_Transparency -150 -#define F_gfx_TransparentColour -149 -#define F_gfx_Triangle -55 -#define F_media_Flush -78 -#define F_media_Image -77 -#define F_media_Init -79 -#define F_media_ReadByte -73 -#define F_media_ReadWord -74 -#define F_media_SetAdd -71 -#define F_media_SetSector -72 -#define F_media_Video -69 -#define F_media_VideoFrame -70 -#define F_media_WriteByte -75 -#define F_media_WriteWord -76 -#define F_putCH -2 -#define F_putstr 6 -#define F_txt_Attributes -142 -#define F_txt_BGcolour -130 -#define F_txt_Bold -138 -#define F_txt_FGcolour -129 -#define F_txt_FontID -131 -#define F_txt_Height -133 -#define F_txt_Inverse -140 -#define F_txt_Italic -139 -#define F_txt_MoveCursor -28 -#define F_txt_Opacity -137 -#define F_txt_Set -29 -#define F_txt_Underline -141 -#define F_txt_Width -132 -#define F_txt_Xgap -134 -#define F_txt_Ygap -135 -#define F_BeeP -38 -#define F_sys_GetModel 7 -#define F_sys_GetVersion 8 -#define F_sys_GetPmmC 9 -#define F_blitComtoDisplay 10 -#define F_setbaudWait 11 -#define F_peekW -11 -#define F_pokeW -13 -#define F_peekB -10 -#define F_pokeB -12 -#define F_joystick -39 -#define F_SSTimeout 12 -#define F_SSSpeed 13 -#define F_SSMode 14 diff --git a/lib/Goldelox_Serial/Goldelox_Serial_4DLib.cpp b/lib/Goldelox_Serial/Goldelox_Serial_4DLib.cpp deleted file mode 100644 index f8a0b8f..0000000 --- a/lib/Goldelox_Serial/Goldelox_Serial_4DLib.cpp +++ /dev/null @@ -1,1226 +0,0 @@ -/* - Goldelox_Serial_4DLib.cpp - Library for 4D Systems Serial Environment. - */ - -#include "Goldelox_Serial_4DLib.h" - -#if (ARDUINO >= 100) - #include "Arduino.h" // for Arduino 1.0 -#else - #include "WProgram.h" // for Arduino 23 -#endif - -Goldelox_Serial_4DLib::Goldelox_Serial_4DLib(Stream * virtualPort) { - _virtualPort = virtualPort; -#ifndef _SAM3XA_ - // Only done on non Arduino Due Boards - _virtualPort->flush(); -#endif -} - -//*********************************************************************************************// -//**********************************Intrinsic 4D Routines**************************************// -//*********************************************************************************************// - -void Goldelox_Serial_4DLib::WriteChars(char * charsout) -{ - unsigned char wk ; - do - { - wk = *charsout++ ; - _virtualPort->write(wk) ; - } while (wk) ; -} - -void Goldelox_Serial_4DLib::WriteBytes(char * Source, int Size) -{ - unsigned char wk ; - int i ; - for (i = 0; i < Size; i++) - { - wk = *Source++ ; - _virtualPort->write(wk) ; - } -} - -void Goldelox_Serial_4DLib::WriteWords(word * Source, int Size) -{ - word wk ; - int i ; - for (i = 0; i < Size; i++) - { - wk = *Source++ ; - _virtualPort->write(wk >> 8) ; - _virtualPort->write(wk) ; - } -} - -void Goldelox_Serial_4DLib::getbytes(char * data, int size) -{ - int read ; - unsigned long sttime ; - int readc ; - readc = 0 ; - sttime = millis() ; - while ((readc != size) && (millis() - sttime < TimeLimit4D)) - { - if(_virtualPort->available()) - { - data[readc++] = _virtualPort->read() ; - } - } - if (readc != size) - { - Error4D = Err4D_Timeout ; - if (Callback4D != NULL) - Callback4D(Error4D, Error4D_Inv) ; - } -} - -void Goldelox_Serial_4DLib::GetAck(void) -{ - int read ; - unsigned char readx ; - unsigned long sttime ; - Error4D = Err4D_OK ; - sttime = millis(); - read = 0 ; - while ((read != 1) && (millis() - sttime < TimeLimit4D)) - { - if(_virtualPort->available() != 0) - { - readx = _virtualPort->read() ; - read = 1 ; - } - } - if (read == 0) - { - Error4D = Err4D_Timeout ; - if (Callback4D != NULL) - Callback4D(Error4D, Error4D_Inv) ; - } - else if (readx != 6) - { - Error4D = Err4D_NAK ; - Error4D_Inv = readx ; - if (Callback4D != NULL) - Callback4D(Error4D, Error4D_Inv) ; - } -} - -word Goldelox_Serial_4DLib::GetWord(void) -{ - unsigned char readx[2] ; - int readc ; - unsigned long sttime ; - - if (Error4D != Err4D_OK) - return 0 ; - sttime = millis(); - readc = 0 ; - while ((readc != 2) && (millis() - sttime < TimeLimit4D)) - { - if(_virtualPort->available()) - { - readx[readc++] = _virtualPort->read() ; - } - } - - if (readc != 2) - { - Error4D = Err4D_Timeout ; - if (Callback4D != NULL) - Callback4D(Error4D, Error4D_Inv) ; - return 0 ; - } - else - return readx[0] << 8 | readx[1] ; -} - -void Goldelox_Serial_4DLib::getString(char * outStr, int strLen) -{ - unsigned char readx[2] ; - int readc ; - unsigned long sttime ; - - if (Error4D != Err4D_OK) - { - outStr[0] = 0 ; - return ; - } - sttime = millis(); - readc = 0 ; - while ((readc != strLen) && (millis() - sttime < TimeLimit4D)) - { - if(_virtualPort->available()) - { - outStr[readc++] = _virtualPort->read() ; - } - } - - if (readc != strLen) - { - Error4D = Err4D_Timeout ; - if (Callback4D != NULL) - Callback4D(Error4D, Error4D_Inv) ; - } - outStr[readc] = 0 ; -} - -word Goldelox_Serial_4DLib::GetAckResp(void) -{ - GetAck() ; - return GetWord() ; -} - -word Goldelox_Serial_4DLib::GetAckRes2Words(word * word1, word * word2) -{ - int Result ; - GetAck() ; - Result = GetWord() ; - *word1 = GetWord() ; - *word2 = GetWord() ; - return Result ; -} - -void Goldelox_Serial_4DLib::GetAck2Words(word * word1, word * word2) -{ - GetAck() ; - *word1 = GetWord() ; - *word2 = GetWord() ; -} - -word Goldelox_Serial_4DLib::GetAckResStr(char * OutStr) -{ - int Result ; - GetAck() ; - Result = GetWord() ; - getString(OutStr, Result) ; - return Result ; -} -/* -word Goldelox_Serial_4DLib::GetAckResData(t4DByteArray OutData, word size) -{ - int Result ; - GetAck() ; - Result = GetWord() ; - getbytes(OutData, size) ; - return Result ; -} -*/ -void Goldelox_Serial_4DLib::SetThisBaudrate(int Newrate) -{ - int br ; - _virtualPort->flush() ; -// _virtualPort->end() ; - switch(Newrate) - { - /* case BAUD_110 : br = 110 ; - break ; - case BAUD_300 : br = 300 ; - break ; - case BAUD_600 : br = 600 ; - break ; - case BAUD_1200 : br = 1200 ; - break ; - case BAUD_2400 : br = 2400 ; - break ; - case BAUD_4800 : br = 4800 ; - break ;*/ - case BAUD_9600 : br = 9600 ; - break ; -// case BAUD_14400 : br = 14400 ; -// break ; - case BAUD_19200 : br = 19200 ; - break ; - /* case BAUD_31250 : br = 31250 ; - break ; - case BAUD_38400 : br = 38400 ; - break ; - case BAUD_56000 : br = 56000 ; - break ; - case BAUD_57600 : br = 57600 ; - break ; - case BAUD_115200 : br = 115200 ; - break ; - case BAUD_128000 : br = 133928 ; // actual rate is not 128000 ; - break ; - case BAUD_256000 : br = 281250 ; // actual rate is not 256000 ; - break ; - case BAUD_300000 : br = 312500 ; // actual rate is not 300000 ; - break ; - case BAUD_375000 : br = 401785 ; // actual rate is not 375000 ; - break ; - case BAUD_500000 : br = 562500 ; // actual rate is not 500000 ; - break ; - case BAUD_600000 : br = 703125 ; // actual rate is not 600000 ; - break ;*/ - } -// _virtualPort->begin(br) ; - delay(50) ; // Display sleeps for 100 - _virtualPort->flush() ; -} - -//*********************************************************************************************// -//**********************************Compound 4D Routines***************************************// -//*********************************************************************************************// - -word Goldelox_Serial_4DLib::charheight(char TestChar) -{ - _virtualPort->print((char)(F_charheight >> 8)) ; - _virtualPort->print((char)(F_charheight)) ; - _virtualPort->print((char)(TestChar)) ; - return GetAckResp() ; -} - -word Goldelox_Serial_4DLib::charwidth(char TestChar) -{ - _virtualPort->print((char)(F_charwidth >> 8)) ; - _virtualPort->print((char)(F_charwidth)) ; - _virtualPort->print((char)(TestChar)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::gfx_BGcolour(word Color) -{ - _virtualPort->print((char)(F_gfx_BGcolour >> 8)) ; - _virtualPort->print((char)(F_gfx_BGcolour)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_ChangeColour(word OldColor, word NewColor) -{ - _virtualPort->print((char)(F_gfx_ChangeColour >> 8)) ; - _virtualPort->print((char)(F_gfx_ChangeColour)) ; - _virtualPort->print((char)(OldColor >> 8)) ; - _virtualPort->print((char)(OldColor)) ; - _virtualPort->print((char)(NewColor >> 8)) ; - _virtualPort->print((char)(NewColor)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Circle(word X, word Y, word Radius, word Color) -{ - _virtualPort->print((char)(F_gfx_Circle >> 8)) ; - _virtualPort->print((char)(F_gfx_Circle)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - _virtualPort->print((char)(Radius >> 8)) ; - _virtualPort->print((char)(Radius)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_CircleFilled(word X, word Y, word Radius, word Color) -{ - _virtualPort->print((char)(F_gfx_CircleFilled >> 8)) ; - _virtualPort->print((char)(F_gfx_CircleFilled)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - _virtualPort->print((char)(Radius >> 8)) ; - _virtualPort->print((char)(Radius)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Clipping(word OnOff) -{ - _virtualPort->print((char)(F_gfx_Clipping >> 8)) ; - _virtualPort->print((char)(F_gfx_Clipping)) ; - _virtualPort->print((char)(OnOff >> 8)) ; - _virtualPort->print((char)(OnOff)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_ClipWindow(word X1, word Y1, word X2, word Y2) -{ - _virtualPort->print((char)(F_gfx_ClipWindow >> 8)) ; - _virtualPort->print((char)(F_gfx_ClipWindow)) ; - _virtualPort->print((char)(X1 >> 8)) ; - _virtualPort->print((char)(X1)) ; - _virtualPort->print((char)(Y1 >> 8)) ; - _virtualPort->print((char)(Y1)) ; - _virtualPort->print((char)(X2 >> 8)) ; - _virtualPort->print((char)(X2)) ; - _virtualPort->print((char)(Y2 >> 8)) ; - _virtualPort->print((char)(Y2)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Cls() -{ - _virtualPort->print((char)(F_gfx_Cls >> 8)) ; - _virtualPort->print((char)(F_gfx_Cls)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Contrast(word Contrast) -{ - _virtualPort->print((char)(F_gfx_Contrast >> 8)) ; - _virtualPort->print((char)(F_gfx_Contrast)) ; - _virtualPort->print((char)(Contrast >> 8)) ; - _virtualPort->print((char)(Contrast)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_FrameDelay(word Msec) -{ - _virtualPort->print((char)(F_gfx_FrameDelay >> 8)) ; - _virtualPort->print((char)(F_gfx_FrameDelay)) ; - _virtualPort->print((char)(Msec >> 8)) ; - _virtualPort->print((char)(Msec)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::gfx_GetPixel(word X, word Y) -{ - _virtualPort->print((char)(F_gfx_GetPixel >> 8 )) ; - _virtualPort->print((char)(F_gfx_GetPixel )) ; - _virtualPort->print((char)(X >> 8 )) ; - _virtualPort->print((char)(X )) ; - _virtualPort->print((char)(Y >> 8 )) ; - _virtualPort->print((char)(Y )) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::gfx_Line(word X1, word Y1, word X2, word Y2, word Color) -{ - _virtualPort->print((char)(F_gfx_Line >> 8 )) ; - _virtualPort->print((char)(F_gfx_Line )) ; - _virtualPort->print((char)(X1 >> 8 )) ; - _virtualPort->print((char)(X1 )) ; - _virtualPort->print((char)(Y1 >> 8 )) ; - _virtualPort->print((char)(Y1 )) ; - _virtualPort->print((char)(X2 >> 8 )) ; - _virtualPort->print((char)(X2 )) ; - _virtualPort->print((char)(Y2 >> 8 )) ; - _virtualPort->print((char)(Y2 )) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_LinePattern(word Pattern) -{ - _virtualPort->print((char)(F_gfx_LinePattern >> 8 )) ; - _virtualPort->print((char)(F_gfx_LinePattern )) ; - _virtualPort->print((char)(Pattern >> 8 )) ; - _virtualPort->print((char)(Pattern )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_LineTo(word X, word Y) -{ - _virtualPort->print((char)(F_gfx_LineTo >> 8 )) ; - _virtualPort->print((char)(F_gfx_LineTo )) ; - _virtualPort->print((char)(X >> 8 )) ; - _virtualPort->print((char)(X )) ; - _virtualPort->print((char)(Y >> 8 )) ; - _virtualPort->print((char)(Y )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_MoveTo(word X, word Y) -{ - _virtualPort->print((char)(F_gfx_MoveTo >> 8 )) ; - _virtualPort->print((char)(F_gfx_MoveTo )) ; - _virtualPort->print((char)(X >> 8 )) ; - _virtualPort->print((char)(X )) ; - _virtualPort->print((char)(Y >> 8 )) ; - _virtualPort->print((char)(Y )) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::gfx_Orbit(word Angle, word Distance, word * Xdest, word * Ydest) -{ - _virtualPort->print((char)(F_gfx_Orbit >> 8 )) ; - _virtualPort->print((char)(F_gfx_Orbit )) ; - _virtualPort->print((char)(Angle >> 8 )) ; - _virtualPort->print((char)(Angle )) ; - _virtualPort->print((char)(Distance >> 8 )) ; - _virtualPort->print((char)(Distance )) ; - GetAck2Words(Xdest,Ydest) ; - return 0 ; -} - -void Goldelox_Serial_4DLib::gfx_OutlineColour(word Color) -{ - _virtualPort->print((char)(F_gfx_OutlineColour >> 8 )) ; - _virtualPort->print((char)(F_gfx_OutlineColour )) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Polygon(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color) -{ - _virtualPort->print((char)(F_gfx_Polygon >> 8 )) ; - _virtualPort->print((char)(F_gfx_Polygon )) ; - _virtualPort->print((char)(n >> 8 )) ; - _virtualPort->print((char)(n )) ; - WriteWords(Xvalues, n) ; - WriteWords(Yvalues, n) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Polyline(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color) -{ - _virtualPort->print((char)(F_gfx_Polyline >> 8 )) ; - _virtualPort->print((char)(F_gfx_Polyline )) ; - _virtualPort->print((char)(n >> 8 )) ; - _virtualPort->print((char)(n )) ; - WriteWords(Xvalues, n) ; - WriteWords(Yvalues, n) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_PutPixel(word X, word Y, word Color) -{ - _virtualPort->print((char)(F_gfx_PutPixel >> 8 )) ; - _virtualPort->print((char)(F_gfx_PutPixel )) ; - _virtualPort->print((char)(X >> 8 )) ; - _virtualPort->print((char)(X )) ; - _virtualPort->print((char)(Y >> 8 )) ; - _virtualPort->print((char)(Y )) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Rectangle(word X1, word Y1, word X2, word Y2, word Color) -{ - _virtualPort->print((char)(F_gfx_Rectangle >> 8 )) ; - _virtualPort->print((char)(F_gfx_Rectangle )) ; - _virtualPort->print((char)(X1 >> 8 )) ; - _virtualPort->print((char)(X1 )) ; - _virtualPort->print((char)(Y1 >> 8 )) ; - _virtualPort->print((char)(Y1 )) ; - _virtualPort->print((char)(X2 >> 8 )) ; - _virtualPort->print((char)(X2 )) ; - _virtualPort->print((char)(Y2 >> 8 )) ; - _virtualPort->print((char)(Y2 )) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_RectangleFilled(word X1, word Y1, word X2, word Y2, word Color) -{ - _virtualPort->print((char)(F_gfx_RectangleFilled >> 8 )) ; - _virtualPort->print((char)(F_gfx_RectangleFilled )) ; - _virtualPort->print((char)(X1 >> 8 )) ; - _virtualPort->print((char)(X1 )) ; - _virtualPort->print((char)(Y1 >> 8 )) ; - _virtualPort->print((char)(Y1 )) ; - _virtualPort->print((char)(X2 >> 8 )) ; - _virtualPort->print((char)(X2 )) ; - _virtualPort->print((char)(Y2 >> 8 )) ; - _virtualPort->print((char)(Y2 )) ; - _virtualPort->print((char)(Color >> 8 )) ; - _virtualPort->print((char)(Color )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_ScreenMode(word ScreenMode) -{ - _virtualPort->print((char)(F_gfx_ScreenMode >> 8 )) ; - _virtualPort->print((char)(F_gfx_ScreenMode )) ; - _virtualPort->print((char)(ScreenMode >> 8 )) ; - _virtualPort->print((char)(ScreenMode )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Set(word Func, word Value) -{ - _virtualPort->print((char)(F_gfx_Set >> 8 )) ; - _virtualPort->print((char)(F_gfx_Set )) ; - _virtualPort->print((char)(Func >> 8 )) ; - _virtualPort->print((char)(Func )) ; - _virtualPort->print((char)(Value >> 8 )) ; - _virtualPort->print((char)(Value )) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_SetClipRegion() -{ - _virtualPort->print((char)(F_gfx_SetClipRegion >> 8)) ; - _virtualPort->print((char)(F_gfx_SetClipRegion)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Transparency(word OnOff) -{ - _virtualPort->print((char)(F_gfx_Transparency >> 8)) ; - _virtualPort->print((char)(F_gfx_Transparency)) ; - _virtualPort->print((char)(OnOff >> 8)) ; - _virtualPort->print((char)(OnOff)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_TransparentColour(word Color) -{ - _virtualPort->print((char)(F_gfx_TransparentColour >> 8)) ; - _virtualPort->print((char)(F_gfx_TransparentColour)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::gfx_Triangle(word X1, word Y1, word X2, word Y2, word X3, word Y3, word Color) -{ - _virtualPort->print((char)(F_gfx_Triangle >> 8)) ; - _virtualPort->print((char)(F_gfx_Triangle)) ; - _virtualPort->print((char)(X1 >> 8)) ; - _virtualPort->print((char)(X1)) ; - _virtualPort->print((char)(Y1 >> 8)) ; - _virtualPort->print((char)(Y1)) ; - _virtualPort->print((char)(X2 >> 8)) ; - _virtualPort->print((char)(X2)) ; - _virtualPort->print((char)(Y2 >> 8)) ; - _virtualPort->print((char)(Y2)) ; - _virtualPort->print((char)(X3 >> 8)) ; - _virtualPort->print((char)(X3)) ; - _virtualPort->print((char)(Y3 >> 8)) ; - _virtualPort->print((char)(Y3)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::media_Flush() -{ - _virtualPort->print((char)(F_media_Flush >> 8)) ; - _virtualPort->print((char)(F_media_Flush)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::media_Image(word X, word Y) -{ - _virtualPort->print((char)(F_media_Image >> 8)) ; - _virtualPort->print((char)(F_media_Image)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::media_Init() -{ - _virtualPort->print((char)(F_media_Init >> 8)) ; - _virtualPort->print((char)(F_media_Init)) ; - return GetAckResp() ; -} - -word Goldelox_Serial_4DLib::media_ReadByte() -{ - _virtualPort->print((char)(F_media_ReadByte >> 8)) ; - _virtualPort->print((char)(F_media_ReadByte)) ; - return GetAckResp() ; -} - -word Goldelox_Serial_4DLib::media_ReadWord() -{ - _virtualPort->print((char)(F_media_ReadWord >> 8)) ; - _virtualPort->print((char)(F_media_ReadWord)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::media_SetAdd(word HiWord, word LoWord) -{ - _virtualPort->print((char)(F_media_SetAdd >> 8)) ; - _virtualPort->print((char)(F_media_SetAdd)) ; - _virtualPort->print((char)(HiWord >> 8)) ; - _virtualPort->print((char)(HiWord)) ; - _virtualPort->print((char)(LoWord >> 8)) ; - _virtualPort->print((char)(LoWord)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::media_SetSector(word HiWord, word LoWord) -{ - _virtualPort->print((char)(F_media_SetSector >> 8)) ; - _virtualPort->print((char)(F_media_SetSector)) ; - _virtualPort->print((char)(HiWord >> 8)) ; - _virtualPort->print((char)(HiWord)) ; - _virtualPort->print((char)(LoWord >> 8)) ; - _virtualPort->print((char)(LoWord)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::media_Video(word X, word Y) -{ - _virtualPort->print((char)(F_media_Video >> 8)) ; - _virtualPort->print((char)(F_media_Video)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::media_VideoFrame(word X, word Y, word Framenumber) -{ - _virtualPort->print((char)(F_media_VideoFrame >> 8)) ; - _virtualPort->print((char)(F_media_VideoFrame)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - _virtualPort->print((char)(Framenumber >> 8)) ; - _virtualPort->print((char)(Framenumber)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::media_WriteByte(word Byte) -{ - _virtualPort->print((char)(F_media_WriteByte >> 8)) ; - _virtualPort->print((char)(F_media_WriteByte)) ; - _virtualPort->print((char)(Byte >> 8)) ; - _virtualPort->print((char)(Byte)) ; - return GetAckResp() ; -} - -word Goldelox_Serial_4DLib::media_WriteWord(word Word) -{ - _virtualPort->print((char)(F_media_WriteWord >> 8)) ; - _virtualPort->print((char)(F_media_WriteWord)) ; - _virtualPort->print((char)(Word >> 8)) ; - _virtualPort->print((char)(Word)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::putCH(word WordChar) -{ - _virtualPort->print((char)(F_putCH >> 8)) ; - _virtualPort->print((char)(F_putCH)) ; - _virtualPort->print((char)(WordChar >> 8)) ; - _virtualPort->print((char)(WordChar)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::putstr(char * InString) -{ - _virtualPort->print((char)(F_putstr >> 8)) ; - _virtualPort->print((char)(F_putstr)) ; - WriteChars(InString) ; - GetAck() ; -} -////////////////////////////////////////////////////// -//-----------------print---------------------------------- - -#ifdef AVR -void Goldelox_Serial_4DLib::print(const __FlashStringHelper *ifsh) -{ - PGM_P p = reinterpret_cast(ifsh); - size_t n = 0; - while (1) { - unsigned char c = pgm_read_byte(p++); - if (c == 0) break; - putCH(c); - } -} -#endif - -void Goldelox_Serial_4DLib::print(const String &s) -{ - int len = s.length(); - char arr[len + 1]; - s.toCharArray(arr,len + 1); - //putstr(arr); - for(int x=0; x=0; x--) - { - putCH(buf[x]); - } -} - -void Goldelox_Serial_4DLib::printFloat(double number, uint8_t digits) -{ - size_t n = 0; - if (isnan(number)) print("nan"); - else if (isinf(number)) print("inf"); - else if (number > 4294967040.0) print ("ovf"); // constant determined empirically - else if (number <-4294967040.0) print ("ovf"); // constant determined empirically - else{ - // Handle negative numbers - if (number < 0.0) - { - putCH('-'); - number = -number; - } - - // Round correctly so that print(1.999, 2) prints as "2.00" - double rounding = 0.5; - for (uint8_t i=0; i 0) { - putCH('.'); - } - - // Extract digits from the remainder one at a time - while (digits-- > 0) - { - remainder *= 10.0; - int toPrint = int(remainder); - printNumber((unsigned long)toPrint, 10); - remainder -= toPrint; - } - } -} - - -//-------------------------------------------------------- - - - - -////////////////////////////////////////////////////// - -void Goldelox_Serial_4DLib::txt_Attributes(word Attribs) -{ - _virtualPort->print((char)(F_txt_Attributes >> 8)) ; - _virtualPort->print((char)(F_txt_Attributes)) ; - _virtualPort->print((char)(Attribs >> 8)) ; - _virtualPort->print((char)(Attribs)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_BGcolour(word Color) -{ - _virtualPort->print((char)(F_txt_BGcolour >> 8)) ; - _virtualPort->print((char)(F_txt_BGcolour)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Bold(word Bold) -{ - _virtualPort->print((char)(F_txt_Bold >> 8)) ; - _virtualPort->print((char)(F_txt_Bold)) ; - _virtualPort->print((char)(Bold >> 8)) ; - _virtualPort->print((char)(Bold)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_FGcolour(word Color) -{ - _virtualPort->print((char)(F_txt_FGcolour >> 8)) ; - _virtualPort->print((char)(F_txt_FGcolour)) ; - _virtualPort->print((char)(Color >> 8)) ; - _virtualPort->print((char)(Color)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_FontID(word FontNumber) -{ - _virtualPort->print((char)(F_txt_FontID >> 8)) ; - _virtualPort->print((char)(F_txt_FontID)) ; - _virtualPort->print((char)(FontNumber >> 8)) ; - _virtualPort->print((char)(FontNumber)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Height(word Multiplier) -{ - _virtualPort->print((char)(F_txt_Height >> 8)) ; - _virtualPort->print((char)(F_txt_Height)) ; - _virtualPort->print((char)(Multiplier >> 8)) ; - _virtualPort->print((char)(Multiplier)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Inverse(word Inverse) -{ - _virtualPort->print((char)(F_txt_Inverse >> 8)) ; - _virtualPort->print((char)(F_txt_Inverse)) ; - _virtualPort->print((char)(Inverse >> 8)) ; - _virtualPort->print((char)(Inverse)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Italic(word Italic) -{ - _virtualPort->print((char)(F_txt_Italic >> 8)) ; - _virtualPort->print((char)(F_txt_Italic)) ; - _virtualPort->print((char)(Italic >> 8)) ; - _virtualPort->print((char)(Italic)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_MoveCursor(word Line, word Column) -{ - _virtualPort->print((char)(F_txt_MoveCursor >> 8)) ; - _virtualPort->print((char)(F_txt_MoveCursor)) ; - _virtualPort->print((char)(Line >> 8)) ; - _virtualPort->print((char)(Line)) ; - _virtualPort->print((char)(Column >> 8)) ; - _virtualPort->print((char)(Column)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Opacity(word TransparentOpaque) -{ - _virtualPort->print((char)(F_txt_Opacity >> 8)) ; - _virtualPort->print((char)(F_txt_Opacity)) ; - _virtualPort->print((char)(TransparentOpaque >> 8)) ; - _virtualPort->print((char)(TransparentOpaque)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Set(word Func, word Value) -{ - _virtualPort->print((char)(F_txt_Set >> 8)) ; - _virtualPort->print((char)(F_txt_Set)) ; - _virtualPort->print((char)(Func >> 8)) ; - _virtualPort->print((char)(Func)) ; - _virtualPort->print((char)(Value >> 8)) ; - _virtualPort->print((char)(Value)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Underline(word Underline) -{ - _virtualPort->print((char)(F_txt_Underline >> 8)) ; - _virtualPort->print((char)(F_txt_Underline)) ; - _virtualPort->print((char)(Underline >> 8)) ; - _virtualPort->print((char)(Underline)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Width(word Multiplier) -{ - _virtualPort->print((char)(F_txt_Width >> 8)) ; - _virtualPort->print((char)(F_txt_Width)) ; - _virtualPort->print((char)(Multiplier >> 8)) ; - _virtualPort->print((char)(Multiplier)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Xgap(word Pixels) -{ - _virtualPort->print((char)(F_txt_Xgap >> 8)) ; - _virtualPort->print((char)(F_txt_Xgap)) ; - _virtualPort->print((char)(Pixels >> 8)) ; - _virtualPort->print((char)(Pixels)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::txt_Ygap(word Pixels) -{ - _virtualPort->print((char)(F_txt_Ygap >> 8)) ; - _virtualPort->print((char)(F_txt_Ygap)) ; - _virtualPort->print((char)(Pixels >> 8)) ; - _virtualPort->print((char)(Pixels)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::BeeP(word Note, word Duration) -{ - _virtualPort->print((char)(F_BeeP >> 8)) ; - _virtualPort->print((char)(F_BeeP)) ; - _virtualPort->print((char)(Note >> 8)) ; - _virtualPort->print((char)(Note)) ; - _virtualPort->print((char)(Duration >> 8)) ; - _virtualPort->print((char)(Duration)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::sys_GetModel(char * ModelStr) -{ - _virtualPort->print((char)(F_sys_GetModel >> 8)) ; - _virtualPort->print((char)(F_sys_GetModel)) ; - return GetAckResStr(ModelStr) ; -} - -word Goldelox_Serial_4DLib::sys_GetVersion() -{ - _virtualPort->print((char)(F_sys_GetVersion >> 8)) ; - _virtualPort->print((char)(F_sys_GetVersion)) ; - return GetAckResp() ; -} - -word Goldelox_Serial_4DLib::sys_GetPmmC() -{ - _virtualPort->print((char)(F_sys_GetPmmC >> 8)) ; - _virtualPort->print((char)(F_sys_GetPmmC)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::blitComtoDisplay(word X, word Y, word Width, word Height, t4DByteArray Pixels) -{ - _virtualPort->print((char)(F_blitComtoDisplay >> 8)) ; - _virtualPort->print((char)(F_blitComtoDisplay)) ; - _virtualPort->print((char)(X >> 8)) ; - _virtualPort->print((char)(X)) ; - _virtualPort->print((char)(Y >> 8)) ; - _virtualPort->print((char)(Y)) ; - _virtualPort->print((char)(Width >> 8)) ; - _virtualPort->print((char)(Width)) ; - _virtualPort->print((char)(Height >> 8)) ; - _virtualPort->print((char)(Height)) ; - WriteBytes(Pixels, Width*Height*2) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::setbaudWait(word Newrate) -{ - _virtualPort->print((char)(F_setbaudWait >> 8)) ; - _virtualPort->print((char)(F_setbaudWait)) ; - _virtualPort->print((char)(Newrate >> 8)) ; - _virtualPort->print((char)(Newrate)) ; - SetThisBaudrate(Newrate) ; // change this systems baud rate to match new display rate, ACK is 100ms away - GetAck() ; -} - -word Goldelox_Serial_4DLib::peekW(word Address) -{ - _virtualPort->print((char)(F_peekW >> 8)) ; - _virtualPort->print((char)(F_peekW)) ; - _virtualPort->print((char)(Address >> 8)) ; - _virtualPort->print((char)(Address)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::pokeW(word Address, word WordValue) -{ - _virtualPort->print((char)(F_pokeW >> 8)) ; - _virtualPort->print((char)(F_pokeW)) ; - _virtualPort->print((char)(Address >> 8)) ; - _virtualPort->print((char)(Address)) ; - _virtualPort->print((char)(WordValue >> 8)) ; - _virtualPort->print((char)(WordValue)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::peekB(word Address) -{ - _virtualPort->print((char)(F_peekB >> 8)) ; - _virtualPort->print((char)(F_peekB)) ; - _virtualPort->print((char)(Address >> 8)) ; - _virtualPort->print((char)(Address)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::pokeB(word Address, word ByteValue) -{ - _virtualPort->print((char)(F_pokeB >> 8)) ; - _virtualPort->print((char)(F_pokeB)) ; - _virtualPort->print((char)(Address >> 8)) ; - _virtualPort->print((char)(Address)) ; - _virtualPort->print((char)(ByteValue >> 8)) ; - _virtualPort->print((char)(ByteValue)) ; - GetAck() ; -} - -word Goldelox_Serial_4DLib::joystick() -{ - _virtualPort->print((char)(F_joystick >> 8)) ; - _virtualPort->print((char)(F_joystick)) ; - return GetAckResp() ; -} - -void Goldelox_Serial_4DLib::SSTimeout(word Seconds) -{ - _virtualPort->print((char)(F_SSTimeout >> 8)) ; - _virtualPort->print((char)(F_SSTimeout)) ; - _virtualPort->print((char)(Seconds >> 8)) ; - _virtualPort->print((char)(Seconds)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::SSSpeed(word Speed) -{ - _virtualPort->print((char)(F_SSSpeed >> 8)) ; - _virtualPort->print((char)(F_SSSpeed)) ; - _virtualPort->print((char)(Speed >> 8)) ; - _virtualPort->print((char)(Speed)) ; - GetAck() ; -} - -void Goldelox_Serial_4DLib::SSMode(word Parm) -{ - _virtualPort->print((char)(F_SSMode >> 8)) ; - _virtualPort->print((char)(F_SSMode)) ; - _virtualPort->print((char)(Parm >> 8)) ; - _virtualPort->print((char)(Parm)) ; - GetAck() ; -} diff --git a/lib/Goldelox_Serial/Goldelox_Serial_4DLib.h b/lib/Goldelox_Serial/Goldelox_Serial_4DLib.h deleted file mode 100644 index d52136d..0000000 --- a/lib/Goldelox_Serial/Goldelox_Serial_4DLib.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - 4DSerial - Library for 4D Systems Serial Environment. - Released into the public domain. -*/ - -#ifndef Goldelox_Serial_4DLib_h -#define Goldelox_Serial_4DLib_h - -#if (ARDUINO >= 100) - #include "Arduino.h" // for Arduino 1.0 -#else - #include "WProgram.h" // for Arduino 23 -#endif - -#define Err4D_OK 0 -#define Err4D_Timeout 1 -#define Err4D_NAK 2 // other than ACK received - -#include "Goldelox_Types4D.h" // Defines for 4dgl constants, generated by conversion of 4DGL constants to target language -#include "Goldelox_Const4DSerial.h" // Defines for 4dgl constants, generated by conversion of 4DGL constants to target language -#include "Goldelox_Const4D.h" // Defines for 4dgl constants, generated by conversion of 4DGL constants to target language - -#include - -#define DEC 10 -#define HEX 16 -#define OCT 8 -#define BIN 2 - -typedef void (*Tcallback4D)(int, unsigned char); - -class Goldelox_Serial_4DLib -{ - public: - Goldelox_Serial_4DLib(Stream * virtualPort); - Tcallback4D Callback4D ; - - //Compound 4D Routines - void blitComtoDisplay(word X, word Y, word Width, word Height, t4DByteArray Pixels) ; - void gfx_BGcolour(word Color) ; - void gfx_ChangeColour(word OldColor, word NewColor) ; - void gfx_Circle(word X, word Y, word Radius, word Color) ; - void gfx_CircleFilled(word X, word Y, word Radius, word Color) ; - void gfx_Clipping(word OnOff) ; - void gfx_ClipWindow(word X1, word Y1, word X2, word Y2) ; - void gfx_Cls(void) ; - void gfx_Contrast(word Contrast) ; - void gfx_FrameDelay(word Msec) ; - void gfx_Line(word X1, word Y1, word X2, word Y2, word Color) ; - void gfx_LinePattern(word Pattern) ; - void gfx_LineTo(word X, word Y) ; - void gfx_MoveTo(word X, word Y) ; - void gfx_OutlineColour(word Color) ; - void gfx_Polygon(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color) ; - void gfx_Polyline(word n, t4DWordArray Xvalues, t4DWordArray Yvalues, word Color) ; - void gfx_PutPixel(word X, word Y, word Color) ; - void gfx_Rectangle(word X1, word Y1, word X2, word Y2, word Color) ; - void gfx_RectangleFilled(word X1, word Y1, word X2, word Y2, word Color) ; - void gfx_ScreenMode(word ScreenMode) ; - void gfx_Set(word Func, word Value) ; - void gfx_Transparency(word OnOff) ; - void gfx_TransparentColour(word Color) ; - void gfx_Triangle(word X1, word Y1, word X2, word Y2, word X3, word Y3, word Color) ; - void media_Image(word X, word Y) ; - void media_SetAdd(word Hiword, word Loword) ; - void media_SetSector(word Hiword, word Loword) ; - void media_Video(word X, word Y) ; - void media_VideoFrame(word X, word Y, word Framenumber) ; - void pokeB(word Address, word ByteValue) ; - void pokeW(word Address, word wordValue) ; - void putCH(word wordChar) ; - //---------------------print----------------------/ - - void print(const __FlashStringHelper *); - void print(const String &); - void print(const char[]); - void print(char); - void print(unsigned char, int = DEC); - void print(int, int = DEC); - void print(unsigned int, int = DEC); - void print(long, int = DEC); - void print(unsigned long n, int = DEC); - void print(double, int = 2); - - void println(const __FlashStringHelper *); - void println(const String &); - void println(const char[]); - void println(char); - void println(unsigned char, int = DEC); - void println(int, int = DEC); - void println(unsigned int, int = DEC); - void println(long, int = DEC); - void println(unsigned long, int = DEC); - void println(double, int = 2); - - //------------------------------------------------/ - - void setbaudWait(word Newrate) ; - void SSMode(word Parm) ; - void SSSpeed(word Speed) ; - void SSTimeout(word Seconds) ; - void txt_Attributes(word Attribs) ; - void txt_BGcolour(word Color) ; - void txt_Bold(word Bold) ; - void txt_FGcolour(word Color) ; - void txt_FontID(word FontNumber) ; - void txt_Height(word Multiplier) ; - void txt_Inverse(word Inverse) ; - void txt_Italic(word Italic) ; - void txt_MoveCursor(word Line, word Column) ; - void txt_Opacity(word TransparentOpaque) ; - void txt_Set(word Func, word Value) ; - void txt_Underline(word Underline) ; - void txt_Width(word Multiplier) ; - void txt_Xgap(word Pixels) ; - void txt_Ygap(word Pixels) ; - void BeeP(word Note, word Duration) ; - word charheight(char TestChar) ; - word charwidth(char TestChar) ; - word gfx_GetPixel(word X, word Y) ; - word gfx_Orbit(word Angle, word Distance, word * Xdest, word * Ydest) ; - void gfx_SetClipRegion(void) ; - word joystick(void) ; - word media_Flush(void) ; - word media_Init(void) ; - word media_ReadByte(void) ; - word media_ReadWord(void) ; - word media_WriteByte(word Byte) ; - word media_WriteWord(word word) ; - word peekB(word Address) ; - word peekW(word Address) ; - void putstr(char * InString) ; - word sys_GetModel(char * ModelStr) ; - word sys_GetPmmC(void) ; - word sys_GetVersion(void) ; - - void GetAck(void); - - //4D Global Variables Used - int Error4D; // Error indicator, used and set by Intrinsic routines - unsigned char Error4D_Inv; // Error byte returned from com port, onl set if error = Err_Invalid - // int Error_Abort4D; // if true routines will abort when detecting an error - unsigned long TimeLimit4D; // time limit in ms for total serial command duration, 2000 (2 seconds) should be adequate for most commands - // assuming a reasonable baud rate AND low latency AND 0 for the Serial Delay Parameter - // temporary increase might be required for very long (bitmap write, large image file opens) - // or indeterminate (eg file_exec, file_run, file_callFunction) commands - - private: - Stream * _virtualPort; - - //Intrinsic 4D Routines - void WriteChars(char * charsout); - void WriteBytes(char * Source, int Size); - void WriteWords(word * Source, int Size); - void getbytes(char * data, int size); - word GetWord(void); - void getString(char * outStr, int strLen); - word GetAckResp(void); - word GetAckRes2Words(word * word1, word * word2); - void GetAck2Words(word * word1, word * word2); - word GetAckResStr(char * OutStr); - // word GetAckResData(t4DByteArray OutData, word size); - void SetThisBaudrate(int Newrate); - - void printNumber(unsigned long, uint8_t); - void printFloat(double number, uint8_t digits); -}; - -#endif diff --git a/lib/Goldelox_Serial/Goldelox_Types4D.h b/lib/Goldelox_Serial/Goldelox_Types4D.h deleted file mode 100644 index 4e105dc..0000000 --- a/lib/Goldelox_Serial/Goldelox_Types4D.h +++ /dev/null @@ -1,3 +0,0 @@ -#define t4DWordArray word * -#define t4DByteArray char * -//#define t4DSector unsigned char * diff --git a/lib/SoftwareSerial/SoftwareSerial.cpp b/lib/SoftwareSerial/SoftwareSerial.cpp deleted file mode 100644 index 67756af..0000000 --- a/lib/SoftwareSerial/SoftwareSerial.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - -SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266. -Copyright (c) 2015-2016 Peter Lerup. All rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -// The Arduino standard GPIO routines are not enough, -// must use some from the Espressif SDK as well -extern "C" { - #include "esp32-hal-gpio.h" -} - -#include - -#define MAX_PIN 35 -#define DEFAULT_BUAD_RATE 9600 - -// As the Arduino attachInterrupt has no parameter, lists of objects -// and callbacks corresponding to each possible GPIO pins have to be defined -SoftwareSerial *ObjList[MAX_PIN+1]; - -void IRAM_ATTR sws_isr_0() { ObjList[0]->rxRead(); }; -void IRAM_ATTR sws_isr_1() { ObjList[1]->rxRead(); }; -void IRAM_ATTR sws_isr_2() { ObjList[2]->rxRead(); }; -void IRAM_ATTR sws_isr_3() { ObjList[3]->rxRead(); }; -void IRAM_ATTR sws_isr_4() { ObjList[4]->rxRead(); }; -void IRAM_ATTR sws_isr_5() { ObjList[5]->rxRead(); }; -// Pin 6 to 11 can not be used -void IRAM_ATTR sws_isr_12() { ObjList[12]->rxRead(); }; -void IRAM_ATTR sws_isr_13() { ObjList[13]->rxRead(); }; -void IRAM_ATTR sws_isr_14() { ObjList[14]->rxRead(); }; -void IRAM_ATTR sws_isr_15() { ObjList[15]->rxRead(); }; -void IRAM_ATTR sws_isr_16() { ObjList[16]->rxRead(); }; -void IRAM_ATTR sws_isr_17() { ObjList[17]->rxRead(); }; -void IRAM_ATTR sws_isr_18() { ObjList[18]->rxRead(); }; -void IRAM_ATTR sws_isr_19() { ObjList[19]->rxRead(); }; -void IRAM_ATTR sws_isr_20() { ObjList[20]->rxRead(); }; -void IRAM_ATTR sws_isr_21() { ObjList[21]->rxRead(); }; -void IRAM_ATTR sws_isr_22() { ObjList[22]->rxRead(); }; -void IRAM_ATTR sws_isr_23() { ObjList[23]->rxRead(); }; -void IRAM_ATTR sws_isr_24() { ObjList[24]->rxRead(); }; -void IRAM_ATTR sws_isr_25() { ObjList[25]->rxRead(); }; -void IRAM_ATTR sws_isr_26() { ObjList[26]->rxRead(); }; -void IRAM_ATTR sws_isr_27() { ObjList[27]->rxRead(); }; -void IRAM_ATTR sws_isr_28() { ObjList[28]->rxRead(); }; -void IRAM_ATTR sws_isr_29() { ObjList[29]->rxRead(); }; -void IRAM_ATTR sws_isr_30() { ObjList[30]->rxRead(); }; -void IRAM_ATTR sws_isr_31() { ObjList[31]->rxRead(); }; -void IRAM_ATTR sws_isr_32() { ObjList[32]->rxRead(); }; -void IRAM_ATTR sws_isr_33() { ObjList[33]->rxRead(); }; -void IRAM_ATTR sws_isr_34() { ObjList[34]->rxRead(); }; -void IRAM_ATTR sws_isr_35() { ObjList[35]->rxRead(); }; - -static void (*ISRList[MAX_PIN+1])() = { - sws_isr_0, - sws_isr_1, - sws_isr_2, - sws_isr_3, - sws_isr_4, - sws_isr_5, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - sws_isr_12, - sws_isr_13, - sws_isr_14, - sws_isr_15, - sws_isr_16, - sws_isr_17, - sws_isr_18, - sws_isr_19, - sws_isr_20, - sws_isr_21, - sws_isr_22, - sws_isr_23, - sws_isr_24, - sws_isr_25, - sws_isr_26, - sws_isr_27, - sws_isr_28, - sws_isr_29, - sws_isr_30, - sws_isr_31, - sws_isr_32, - sws_isr_33, - sws_isr_34, - sws_isr_35 -}; - -SoftwareSerial::SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) { - m_rxValid = m_txValid = m_txEnableValid = false; - m_buffer = NULL; - m_invert = inverse_logic; - m_overflow = false; - m_rxEnabled = false; - if (isValidGPIOpin(receivePin)) { - m_rxPin = receivePin; - m_buffSize = buffSize; - m_buffer = (uint8_t*)malloc(m_buffSize); - if (m_buffer != NULL) { - m_rxValid = true; - m_inPos = m_outPos = 0; - pinMode(m_rxPin, INPUT); - ObjList[m_rxPin] = this; - enableRx(true); - } - } - if (isValidGPIOpin(transmitPin)) { - m_txValid = true; - m_txPin = transmitPin; - pinMode(m_txPin, OUTPUT); - digitalWrite(m_txPin, !m_invert); - } - // Default speed - //begin(DEFAULT_BUAD_RATE); -} - -SoftwareSerial::~SoftwareSerial() { - enableRx(false); - if (m_rxValid) - ObjList[m_rxPin] = NULL; - if (m_buffer) - free(m_buffer); -} - -bool SoftwareSerial::isValidGPIOpin(int pin) { - return (pin >= 0 && pin <= 5) || (pin >= 12 && pin <= MAX_PIN); -} - -void SoftwareSerial::begin(long speed) { - // Use getCycleCount() loop to get as exact timing as possible - m_bitTime = ESP.getCpuFreqMHz()*1000000/speed; - - if (!m_rxEnabled) - enableRx(true); -} - -long SoftwareSerial::baudRate() { - return ESP.getCpuFreqMHz()*1000000/m_bitTime; -} - -void SoftwareSerial::setTransmitEnablePin(int transmitEnablePin) { - if (isValidGPIOpin(transmitEnablePin)) { - m_txEnableValid = true; - m_txEnablePin = transmitEnablePin; - pinMode(m_txEnablePin, OUTPUT); - digitalWrite(m_txEnablePin, LOW); - } else { - m_txEnableValid = false; - } -} - -void SoftwareSerial::enableRx(bool on) { - if (m_rxValid) { - if (on) - attachInterrupt(m_rxPin, ISRList[m_rxPin], m_invert ? RISING : FALLING); - else - detachInterrupt(m_rxPin); - m_rxEnabled = on; - } -} - -int SoftwareSerial::read() { - if (!m_rxValid || (m_inPos == m_outPos)) return -1; - uint8_t ch = m_buffer[m_outPos]; - m_outPos = (m_outPos+1) % m_buffSize; - return ch; -} - -int SoftwareSerial::available() { - if (!m_rxValid) return 0; - int avail = m_inPos - m_outPos; - if (avail < 0) avail += m_buffSize; - return avail; -} - -#define WAIT { while (ESP.getCycleCount()-start < wait); wait += m_bitTime; } - -size_t SoftwareSerial::write(uint8_t b) { - if (!m_txValid) return 0; - - if (m_invert) b = ~b; - // Disable interrupts in order to get a clean transmit - cli(); - if (m_txEnableValid) digitalWrite(m_txEnablePin, HIGH); - unsigned long wait = m_bitTime; - digitalWrite(m_txPin, HIGH); - unsigned long start = ESP.getCycleCount(); - // Start bit; - digitalWrite(m_txPin, LOW); - WAIT; - for (int i = 0; i < 8; i++) { - digitalWrite(m_txPin, (b & 1) ? HIGH : LOW); - WAIT; - b >>= 1; - } - // Stop bit - digitalWrite(m_txPin, HIGH); - WAIT; - if (m_txEnableValid) digitalWrite(m_txEnablePin, LOW); - sei(); - return 1; -} - -void SoftwareSerial::flush() { - m_inPos = m_outPos = 0; -} - -bool SoftwareSerial::overflow() { - bool res = m_overflow; - m_overflow = false; - return res; -} - -int SoftwareSerial::peek() { - if (!m_rxValid || (m_inPos == m_outPos)) return -1; - return m_buffer[m_outPos]; -} - -void IRAM_ATTR SoftwareSerial::rxRead() { - // Advance the starting point for the samples but compensate for the - // initial delay which occurs before the interrupt is delivered - unsigned long wait = m_bitTime + m_bitTime/3 - 500; - unsigned long start = ESP.getCycleCount(); - uint8_t rec = 0; - for (int i = 0; i < 8; i++) { - WAIT; - rec >>= 1; - if (digitalRead(m_rxPin)) - rec |= 0x80; - } - if (m_invert) rec = ~rec; - // Stop bit - WAIT; - // Store the received value in the buffer unless we have an overflow - int next = (m_inPos+1) % m_buffSize; - if (next != m_outPos) { - m_buffer[m_inPos] = rec; - m_inPos = next; - } else { - m_overflow = true; - } - // Must clear this bit in the interrupt register, - // it gets set even when interrupts are disabled - GPIO_REG_WRITE(GPIO.status_w1tc, 1 << m_rxPin); -} diff --git a/lib/SoftwareSerial/SoftwareSerial.h b/lib/SoftwareSerial/SoftwareSerial.h deleted file mode 100644 index 3b1a001..0000000 --- a/lib/SoftwareSerial/SoftwareSerial.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -SoftwareSerial.h - -SoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266. -Copyright (c) 2015-2016 Peter Lerup. All rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#ifndef SoftwareSerial_h -#define SoftwareSerial_h - -#include -#include - - -// This class is compatible with the corresponding AVR one, -// the constructor however has an optional rx buffer size. -// Speed up to 115200 can be used. - - -class SoftwareSerial : public Stream -{ -public: - SoftwareSerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64); - ~SoftwareSerial(); - - void begin(long speed); - long baudRate(); - void setTransmitEnablePin(int transmitEnablePin); - - bool overflow(); - int peek(); - - virtual size_t write(uint8_t byte); - virtual int read(); - virtual int available(); - virtual void flush(); - operator bool() {return m_rxValid || m_txValid;} - - // Disable or enable interrupts on the rx pin - void enableRx(bool on); - - void rxRead(); - - // AVR compatibility methods - bool listen() { enableRx(true); return true; } - void end() { stopListening(); } - bool isListening() { return m_rxEnabled; } - bool stopListening() { enableRx(false); return true; } - - using Print::write; - -private: - bool isValidGPIOpin(int pin); - - // Member variables - int m_rxPin, m_txPin, m_txEnablePin; - bool m_rxValid, m_rxEnabled; - bool m_txValid, m_txEnableValid; - bool m_invert; - bool m_overflow; - unsigned long m_bitTime; - unsigned int m_inPos, m_outPos; - int m_buffSize; - uint8_t *m_buffer; - -}; - -// If only one tx or rx wanted then use this as parameter for the unused pin -#define SW_SERIAL_UNUSED_PIN -1 - - -#endif diff --git a/lib/ros_lib/actionlib/TestAction.h b/lib/ros_lib/actionlib/TestAction.h deleted file mode 100644 index ef50b96..0000000 --- a/lib/ros_lib/actionlib/TestAction.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestAction_h -#define _ROS_actionlib_TestAction_h - -#include -#include -#include -#include "ros/msg.h" -#include "actionlib/TestActionGoal.h" -#include "actionlib/TestActionResult.h" -#include "actionlib/TestActionFeedback.h" - -namespace actionlib -{ - - class TestAction : public ros::Msg - { - public: - typedef actionlib::TestActionGoal _action_goal_type; - _action_goal_type action_goal; - typedef actionlib::TestActionResult _action_result_type; - _action_result_type action_result; - typedef actionlib::TestActionFeedback _action_feedback_type; - _action_feedback_type action_feedback; - - TestAction(): - action_goal(), - action_result(), - action_feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->action_goal.serialize(outbuffer + offset); - offset += this->action_result.serialize(outbuffer + offset); - offset += this->action_feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->action_goal.deserialize(inbuffer + offset); - offset += this->action_result.deserialize(inbuffer + offset); - offset += this->action_feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestAction"; }; - const char * getMD5(){ return "991e87a72802262dfbe5d1b3cf6efc9a"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestActionFeedback.h b/lib/ros_lib/actionlib/TestActionFeedback.h deleted file mode 100644 index 3fd85bf..0000000 --- a/lib/ros_lib/actionlib/TestActionFeedback.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestActionFeedback_h -#define _ROS_actionlib_TestActionFeedback_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TestFeedback.h" - -namespace actionlib -{ - - class TestActionFeedback : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TestFeedback _feedback_type; - _feedback_type feedback; - - TestActionFeedback(): - header(), - status(), - feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestActionFeedback"; }; - const char * getMD5(){ return "6d3d0bf7fb3dda24779c010a9f3eb7cb"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestActionGoal.h b/lib/ros_lib/actionlib/TestActionGoal.h deleted file mode 100644 index 5c2cb95..0000000 --- a/lib/ros_lib/actionlib/TestActionGoal.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestActionGoal_h -#define _ROS_actionlib_TestActionGoal_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalID.h" -#include "actionlib/TestGoal.h" - -namespace actionlib -{ - - class TestActionGoal : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalID _goal_id_type; - _goal_id_type goal_id; - typedef actionlib::TestGoal _goal_type; - _goal_type goal; - - TestActionGoal(): - header(), - goal_id(), - goal() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->goal_id.serialize(outbuffer + offset); - offset += this->goal.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->goal_id.deserialize(inbuffer + offset); - offset += this->goal.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestActionGoal"; }; - const char * getMD5(){ return "348369c5b403676156094e8c159720bf"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestActionResult.h b/lib/ros_lib/actionlib/TestActionResult.h deleted file mode 100644 index e6f92ec..0000000 --- a/lib/ros_lib/actionlib/TestActionResult.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestActionResult_h -#define _ROS_actionlib_TestActionResult_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TestResult.h" - -namespace actionlib -{ - - class TestActionResult : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TestResult _result_type; - _result_type result; - - TestActionResult(): - header(), - status(), - result() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->result.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->result.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestActionResult"; }; - const char * getMD5(){ return "3d669e3a63aa986c667ea7b0f46ce85e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestFeedback.h b/lib/ros_lib/actionlib/TestFeedback.h deleted file mode 100644 index a059f79..0000000 --- a/lib/ros_lib/actionlib/TestFeedback.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _ROS_actionlib_TestFeedback_h -#define _ROS_actionlib_TestFeedback_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TestFeedback : public ros::Msg - { - public: - typedef int32_t _feedback_type; - _feedback_type feedback; - - TestFeedback(): - feedback(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_feedback; - u_feedback.real = this->feedback; - *(outbuffer + offset + 0) = (u_feedback.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_feedback.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_feedback.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_feedback.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->feedback); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_feedback; - u_feedback.base = 0; - u_feedback.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_feedback.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_feedback.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_feedback.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->feedback = u_feedback.real; - offset += sizeof(this->feedback); - return offset; - } - - const char * getType(){ return "actionlib/TestFeedback"; }; - const char * getMD5(){ return "49ceb5b32ea3af22073ede4a0328249e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestGoal.h b/lib/ros_lib/actionlib/TestGoal.h deleted file mode 100644 index 018b66f..0000000 --- a/lib/ros_lib/actionlib/TestGoal.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _ROS_actionlib_TestGoal_h -#define _ROS_actionlib_TestGoal_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TestGoal : public ros::Msg - { - public: - typedef int32_t _goal_type; - _goal_type goal; - - TestGoal(): - goal(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_goal; - u_goal.real = this->goal; - *(outbuffer + offset + 0) = (u_goal.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_goal.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_goal.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_goal.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->goal); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_goal; - u_goal.base = 0; - u_goal.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_goal.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_goal.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_goal.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->goal = u_goal.real; - offset += sizeof(this->goal); - return offset; - } - - const char * getType(){ return "actionlib/TestGoal"; }; - const char * getMD5(){ return "18df0149936b7aa95588e3862476ebde"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestAction.h b/lib/ros_lib/actionlib/TestRequestAction.h deleted file mode 100644 index 8bf3ea2..0000000 --- a/lib/ros_lib/actionlib/TestRequestAction.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestAction_h -#define _ROS_actionlib_TestRequestAction_h - -#include -#include -#include -#include "ros/msg.h" -#include "actionlib/TestRequestActionGoal.h" -#include "actionlib/TestRequestActionResult.h" -#include "actionlib/TestRequestActionFeedback.h" - -namespace actionlib -{ - - class TestRequestAction : public ros::Msg - { - public: - typedef actionlib::TestRequestActionGoal _action_goal_type; - _action_goal_type action_goal; - typedef actionlib::TestRequestActionResult _action_result_type; - _action_result_type action_result; - typedef actionlib::TestRequestActionFeedback _action_feedback_type; - _action_feedback_type action_feedback; - - TestRequestAction(): - action_goal(), - action_result(), - action_feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->action_goal.serialize(outbuffer + offset); - offset += this->action_result.serialize(outbuffer + offset); - offset += this->action_feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->action_goal.deserialize(inbuffer + offset); - offset += this->action_result.deserialize(inbuffer + offset); - offset += this->action_feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestAction"; }; - const char * getMD5(){ return "dc44b1f4045dbf0d1db54423b3b86b30"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestActionFeedback.h b/lib/ros_lib/actionlib/TestRequestActionFeedback.h deleted file mode 100644 index 95e3dd3..0000000 --- a/lib/ros_lib/actionlib/TestRequestActionFeedback.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestActionFeedback_h -#define _ROS_actionlib_TestRequestActionFeedback_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TestRequestFeedback.h" - -namespace actionlib -{ - - class TestRequestActionFeedback : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TestRequestFeedback _feedback_type; - _feedback_type feedback; - - TestRequestActionFeedback(): - header(), - status(), - feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestActionFeedback"; }; - const char * getMD5(){ return "aae20e09065c3809e8a8e87c4c8953fd"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestActionGoal.h b/lib/ros_lib/actionlib/TestRequestActionGoal.h deleted file mode 100644 index 8ccf742..0000000 --- a/lib/ros_lib/actionlib/TestRequestActionGoal.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestActionGoal_h -#define _ROS_actionlib_TestRequestActionGoal_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalID.h" -#include "actionlib/TestRequestGoal.h" - -namespace actionlib -{ - - class TestRequestActionGoal : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalID _goal_id_type; - _goal_id_type goal_id; - typedef actionlib::TestRequestGoal _goal_type; - _goal_type goal; - - TestRequestActionGoal(): - header(), - goal_id(), - goal() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->goal_id.serialize(outbuffer + offset); - offset += this->goal.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->goal_id.deserialize(inbuffer + offset); - offset += this->goal.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestActionGoal"; }; - const char * getMD5(){ return "1889556d3fef88f821c7cb004e4251f3"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestActionResult.h b/lib/ros_lib/actionlib/TestRequestActionResult.h deleted file mode 100644 index 63038f6..0000000 --- a/lib/ros_lib/actionlib/TestRequestActionResult.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestActionResult_h -#define _ROS_actionlib_TestRequestActionResult_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TestRequestResult.h" - -namespace actionlib -{ - - class TestRequestActionResult : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TestRequestResult _result_type; - _result_type result; - - TestRequestActionResult(): - header(), - status(), - result() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->result.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->result.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestActionResult"; }; - const char * getMD5(){ return "0476d1fdf437a3a6e7d6d0e9f5561298"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestFeedback.h b/lib/ros_lib/actionlib/TestRequestFeedback.h deleted file mode 100644 index 4a104be..0000000 --- a/lib/ros_lib/actionlib/TestRequestFeedback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestFeedback_h -#define _ROS_actionlib_TestRequestFeedback_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TestRequestFeedback : public ros::Msg - { - public: - - TestRequestFeedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return "actionlib/TestRequestFeedback"; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestGoal.h b/lib/ros_lib/actionlib/TestRequestGoal.h deleted file mode 100644 index ea49774..0000000 --- a/lib/ros_lib/actionlib/TestRequestGoal.h +++ /dev/null @@ -1,215 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestGoal_h -#define _ROS_actionlib_TestRequestGoal_h - -#include -#include -#include -#include "ros/msg.h" -#include "ros/duration.h" - -namespace actionlib -{ - - class TestRequestGoal : public ros::Msg - { - public: - typedef int32_t _terminate_status_type; - _terminate_status_type terminate_status; - typedef bool _ignore_cancel_type; - _ignore_cancel_type ignore_cancel; - typedef const char* _result_text_type; - _result_text_type result_text; - typedef int32_t _the_result_type; - _the_result_type the_result; - typedef bool _is_simple_client_type; - _is_simple_client_type is_simple_client; - typedef ros::Duration _delay_accept_type; - _delay_accept_type delay_accept; - typedef ros::Duration _delay_terminate_type; - _delay_terminate_type delay_terminate; - typedef ros::Duration _pause_status_type; - _pause_status_type pause_status; - enum { TERMINATE_SUCCESS = 0 }; - enum { TERMINATE_ABORTED = 1 }; - enum { TERMINATE_REJECTED = 2 }; - enum { TERMINATE_LOSE = 3 }; - enum { TERMINATE_DROP = 4 }; - enum { TERMINATE_EXCEPTION = 5 }; - - TestRequestGoal(): - terminate_status(0), - ignore_cancel(0), - result_text(""), - the_result(0), - is_simple_client(0), - delay_accept(), - delay_terminate(), - pause_status() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_terminate_status; - u_terminate_status.real = this->terminate_status; - *(outbuffer + offset + 0) = (u_terminate_status.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_terminate_status.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_terminate_status.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_terminate_status.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->terminate_status); - union { - bool real; - uint8_t base; - } u_ignore_cancel; - u_ignore_cancel.real = this->ignore_cancel; - *(outbuffer + offset + 0) = (u_ignore_cancel.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->ignore_cancel); - uint32_t length_result_text = strlen(this->result_text); - varToArr(outbuffer + offset, length_result_text); - offset += 4; - memcpy(outbuffer + offset, this->result_text, length_result_text); - offset += length_result_text; - union { - int32_t real; - uint32_t base; - } u_the_result; - u_the_result.real = this->the_result; - *(outbuffer + offset + 0) = (u_the_result.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_the_result.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_the_result.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_the_result.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->the_result); - union { - bool real; - uint8_t base; - } u_is_simple_client; - u_is_simple_client.real = this->is_simple_client; - *(outbuffer + offset + 0) = (u_is_simple_client.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->is_simple_client); - *(outbuffer + offset + 0) = (this->delay_accept.sec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->delay_accept.sec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->delay_accept.sec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->delay_accept.sec >> (8 * 3)) & 0xFF; - offset += sizeof(this->delay_accept.sec); - *(outbuffer + offset + 0) = (this->delay_accept.nsec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->delay_accept.nsec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->delay_accept.nsec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->delay_accept.nsec >> (8 * 3)) & 0xFF; - offset += sizeof(this->delay_accept.nsec); - *(outbuffer + offset + 0) = (this->delay_terminate.sec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->delay_terminate.sec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->delay_terminate.sec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->delay_terminate.sec >> (8 * 3)) & 0xFF; - offset += sizeof(this->delay_terminate.sec); - *(outbuffer + offset + 0) = (this->delay_terminate.nsec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->delay_terminate.nsec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->delay_terminate.nsec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->delay_terminate.nsec >> (8 * 3)) & 0xFF; - offset += sizeof(this->delay_terminate.nsec); - *(outbuffer + offset + 0) = (this->pause_status.sec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->pause_status.sec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->pause_status.sec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->pause_status.sec >> (8 * 3)) & 0xFF; - offset += sizeof(this->pause_status.sec); - *(outbuffer + offset + 0) = (this->pause_status.nsec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->pause_status.nsec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->pause_status.nsec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->pause_status.nsec >> (8 * 3)) & 0xFF; - offset += sizeof(this->pause_status.nsec); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_terminate_status; - u_terminate_status.base = 0; - u_terminate_status.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_terminate_status.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_terminate_status.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_terminate_status.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->terminate_status = u_terminate_status.real; - offset += sizeof(this->terminate_status); - union { - bool real; - uint8_t base; - } u_ignore_cancel; - u_ignore_cancel.base = 0; - u_ignore_cancel.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->ignore_cancel = u_ignore_cancel.real; - offset += sizeof(this->ignore_cancel); - uint32_t length_result_text; - arrToVar(length_result_text, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_result_text; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_result_text-1]=0; - this->result_text = (char *)(inbuffer + offset-1); - offset += length_result_text; - union { - int32_t real; - uint32_t base; - } u_the_result; - u_the_result.base = 0; - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->the_result = u_the_result.real; - offset += sizeof(this->the_result); - union { - bool real; - uint8_t base; - } u_is_simple_client; - u_is_simple_client.base = 0; - u_is_simple_client.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->is_simple_client = u_is_simple_client.real; - offset += sizeof(this->is_simple_client); - this->delay_accept.sec = ((uint32_t) (*(inbuffer + offset))); - this->delay_accept.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->delay_accept.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->delay_accept.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->delay_accept.sec); - this->delay_accept.nsec = ((uint32_t) (*(inbuffer + offset))); - this->delay_accept.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->delay_accept.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->delay_accept.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->delay_accept.nsec); - this->delay_terminate.sec = ((uint32_t) (*(inbuffer + offset))); - this->delay_terminate.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->delay_terminate.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->delay_terminate.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->delay_terminate.sec); - this->delay_terminate.nsec = ((uint32_t) (*(inbuffer + offset))); - this->delay_terminate.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->delay_terminate.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->delay_terminate.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->delay_terminate.nsec); - this->pause_status.sec = ((uint32_t) (*(inbuffer + offset))); - this->pause_status.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->pause_status.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->pause_status.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->pause_status.sec); - this->pause_status.nsec = ((uint32_t) (*(inbuffer + offset))); - this->pause_status.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->pause_status.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->pause_status.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->pause_status.nsec); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestGoal"; }; - const char * getMD5(){ return "db5d00ba98302d6c6dd3737e9a03ceea"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestRequestResult.h b/lib/ros_lib/actionlib/TestRequestResult.h deleted file mode 100644 index b2814ec..0000000 --- a/lib/ros_lib/actionlib/TestRequestResult.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _ROS_actionlib_TestRequestResult_h -#define _ROS_actionlib_TestRequestResult_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TestRequestResult : public ros::Msg - { - public: - typedef int32_t _the_result_type; - _the_result_type the_result; - typedef bool _is_simple_server_type; - _is_simple_server_type is_simple_server; - - TestRequestResult(): - the_result(0), - is_simple_server(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_the_result; - u_the_result.real = this->the_result; - *(outbuffer + offset + 0) = (u_the_result.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_the_result.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_the_result.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_the_result.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->the_result); - union { - bool real; - uint8_t base; - } u_is_simple_server; - u_is_simple_server.real = this->is_simple_server; - *(outbuffer + offset + 0) = (u_is_simple_server.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->is_simple_server); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_the_result; - u_the_result.base = 0; - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_the_result.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->the_result = u_the_result.real; - offset += sizeof(this->the_result); - union { - bool real; - uint8_t base; - } u_is_simple_server; - u_is_simple_server.base = 0; - u_is_simple_server.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->is_simple_server = u_is_simple_server.real; - offset += sizeof(this->is_simple_server); - return offset; - } - - const char * getType(){ return "actionlib/TestRequestResult"; }; - const char * getMD5(){ return "61c2364524499c7c5017e2f3fce7ba06"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TestResult.h b/lib/ros_lib/actionlib/TestResult.h deleted file mode 100644 index 10e6bc5..0000000 --- a/lib/ros_lib/actionlib/TestResult.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _ROS_actionlib_TestResult_h -#define _ROS_actionlib_TestResult_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TestResult : public ros::Msg - { - public: - typedef int32_t _result_type; - _result_type result; - - TestResult(): - result(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_result; - u_result.real = this->result; - *(outbuffer + offset + 0) = (u_result.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_result.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_result.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_result.base >> (8 * 3)) & 0xFF; - offset += sizeof(this->result); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int32_t real; - uint32_t base; - } u_result; - u_result.base = 0; - u_result.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_result.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_result.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_result.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - this->result = u_result.real; - offset += sizeof(this->result); - return offset; - } - - const char * getType(){ return "actionlib/TestResult"; }; - const char * getMD5(){ return "034a8e20d6a306665e3a5b340fab3f09"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsAction.h b/lib/ros_lib/actionlib/TwoIntsAction.h deleted file mode 100644 index 573ffcd..0000000 --- a/lib/ros_lib/actionlib/TwoIntsAction.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsAction_h -#define _ROS_actionlib_TwoIntsAction_h - -#include -#include -#include -#include "ros/msg.h" -#include "actionlib/TwoIntsActionGoal.h" -#include "actionlib/TwoIntsActionResult.h" -#include "actionlib/TwoIntsActionFeedback.h" - -namespace actionlib -{ - - class TwoIntsAction : public ros::Msg - { - public: - typedef actionlib::TwoIntsActionGoal _action_goal_type; - _action_goal_type action_goal; - typedef actionlib::TwoIntsActionResult _action_result_type; - _action_result_type action_result; - typedef actionlib::TwoIntsActionFeedback _action_feedback_type; - _action_feedback_type action_feedback; - - TwoIntsAction(): - action_goal(), - action_result(), - action_feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->action_goal.serialize(outbuffer + offset); - offset += this->action_result.serialize(outbuffer + offset); - offset += this->action_feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->action_goal.deserialize(inbuffer + offset); - offset += this->action_result.deserialize(inbuffer + offset); - offset += this->action_feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsAction"; }; - const char * getMD5(){ return "6d1aa538c4bd6183a2dfb7fcac41ee50"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsActionFeedback.h b/lib/ros_lib/actionlib/TwoIntsActionFeedback.h deleted file mode 100644 index cad817d..0000000 --- a/lib/ros_lib/actionlib/TwoIntsActionFeedback.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsActionFeedback_h -#define _ROS_actionlib_TwoIntsActionFeedback_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TwoIntsFeedback.h" - -namespace actionlib -{ - - class TwoIntsActionFeedback : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TwoIntsFeedback _feedback_type; - _feedback_type feedback; - - TwoIntsActionFeedback(): - header(), - status(), - feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsActionFeedback"; }; - const char * getMD5(){ return "aae20e09065c3809e8a8e87c4c8953fd"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsActionGoal.h b/lib/ros_lib/actionlib/TwoIntsActionGoal.h deleted file mode 100644 index 6b99941..0000000 --- a/lib/ros_lib/actionlib/TwoIntsActionGoal.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsActionGoal_h -#define _ROS_actionlib_TwoIntsActionGoal_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalID.h" -#include "actionlib/TwoIntsGoal.h" - -namespace actionlib -{ - - class TwoIntsActionGoal : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalID _goal_id_type; - _goal_id_type goal_id; - typedef actionlib::TwoIntsGoal _goal_type; - _goal_type goal; - - TwoIntsActionGoal(): - header(), - goal_id(), - goal() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->goal_id.serialize(outbuffer + offset); - offset += this->goal.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->goal_id.deserialize(inbuffer + offset); - offset += this->goal.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsActionGoal"; }; - const char * getMD5(){ return "684a2db55d6ffb8046fb9d6764ce0860"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsActionResult.h b/lib/ros_lib/actionlib/TwoIntsActionResult.h deleted file mode 100644 index e3943fd..0000000 --- a/lib/ros_lib/actionlib/TwoIntsActionResult.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsActionResult_h -#define _ROS_actionlib_TwoIntsActionResult_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "actionlib/TwoIntsResult.h" - -namespace actionlib -{ - - class TwoIntsActionResult : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef actionlib::TwoIntsResult _result_type; - _result_type result; - - TwoIntsActionResult(): - header(), - status(), - result() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->result.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->result.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsActionResult"; }; - const char * getMD5(){ return "3ba7dea8b8cddcae4528ade4ef74b6e7"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsFeedback.h b/lib/ros_lib/actionlib/TwoIntsFeedback.h deleted file mode 100644 index 2cd4f60..0000000 --- a/lib/ros_lib/actionlib/TwoIntsFeedback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsFeedback_h -#define _ROS_actionlib_TwoIntsFeedback_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TwoIntsFeedback : public ros::Msg - { - public: - - TwoIntsFeedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsFeedback"; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsGoal.h b/lib/ros_lib/actionlib/TwoIntsGoal.h deleted file mode 100644 index 2e3fb5c..0000000 --- a/lib/ros_lib/actionlib/TwoIntsGoal.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsGoal_h -#define _ROS_actionlib_TwoIntsGoal_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TwoIntsGoal : public ros::Msg - { - public: - typedef int64_t _a_type; - _a_type a; - typedef int64_t _b_type; - _b_type b; - - TwoIntsGoal(): - a(0), - b(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_a; - u_a.real = this->a; - *(outbuffer + offset + 0) = (u_a.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_a.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_a.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_a.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_a.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_a.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_a.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_a.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->a); - union { - int64_t real; - uint64_t base; - } u_b; - u_b.real = this->b; - *(outbuffer + offset + 0) = (u_b.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_b.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_b.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_b.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_b.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_b.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_b.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_b.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->b); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_a; - u_a.base = 0; - u_a.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_a.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->a = u_a.real; - offset += sizeof(this->a); - union { - int64_t real; - uint64_t base; - } u_b; - u_b.base = 0; - u_b.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_b.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->b = u_b.real; - offset += sizeof(this->b); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsGoal"; }; - const char * getMD5(){ return "36d09b846be0b371c5f190354dd3153e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib/TwoIntsResult.h b/lib/ros_lib/actionlib/TwoIntsResult.h deleted file mode 100644 index afae9b0..0000000 --- a/lib/ros_lib/actionlib/TwoIntsResult.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_actionlib_TwoIntsResult_h -#define _ROS_actionlib_TwoIntsResult_h - -#include -#include -#include -#include "ros/msg.h" - -namespace actionlib -{ - - class TwoIntsResult : public ros::Msg - { - public: - typedef int64_t _sum_type; - _sum_type sum; - - TwoIntsResult(): - sum(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_sum; - u_sum.real = this->sum; - *(outbuffer + offset + 0) = (u_sum.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_sum.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_sum.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_sum.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_sum.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_sum.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_sum.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_sum.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->sum); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_sum; - u_sum.base = 0; - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_sum.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->sum = u_sum.real; - offset += sizeof(this->sum); - return offset; - } - - const char * getType(){ return "actionlib/TwoIntsResult"; }; - const char * getMD5(){ return "b88405221c77b1878a3cbbfff53428d7"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib_msgs/GoalID.h b/lib/ros_lib/actionlib_msgs/GoalID.h deleted file mode 100644 index 160ca8a..0000000 --- a/lib/ros_lib/actionlib_msgs/GoalID.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _ROS_actionlib_msgs_GoalID_h -#define _ROS_actionlib_msgs_GoalID_h - -#include -#include -#include -#include "ros/msg.h" -#include "ros/time.h" - -namespace actionlib_msgs -{ - - class GoalID : public ros::Msg - { - public: - typedef ros::Time _stamp_type; - _stamp_type stamp; - typedef const char* _id_type; - _id_type id; - - GoalID(): - stamp(), - id("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF; - offset += sizeof(this->stamp.sec); - *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF; - offset += sizeof(this->stamp.nsec); - uint32_t length_id = strlen(this->id); - varToArr(outbuffer + offset, length_id); - offset += 4; - memcpy(outbuffer + offset, this->id, length_id); - offset += length_id; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - this->stamp.sec = ((uint32_t) (*(inbuffer + offset))); - this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->stamp.sec); - this->stamp.nsec = ((uint32_t) (*(inbuffer + offset))); - this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->stamp.nsec); - uint32_t length_id; - arrToVar(length_id, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_id; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_id-1]=0; - this->id = (char *)(inbuffer + offset-1); - offset += length_id; - return offset; - } - - const char * getType(){ return "actionlib_msgs/GoalID"; }; - const char * getMD5(){ return "302881f31927c1df708a2dbab0e80ee8"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib_msgs/GoalStatus.h b/lib/ros_lib/actionlib_msgs/GoalStatus.h deleted file mode 100644 index 52e58af..0000000 --- a/lib/ros_lib/actionlib_msgs/GoalStatus.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _ROS_actionlib_msgs_GoalStatus_h -#define _ROS_actionlib_msgs_GoalStatus_h - -#include -#include -#include -#include "ros/msg.h" -#include "actionlib_msgs/GoalID.h" - -namespace actionlib_msgs -{ - - class GoalStatus : public ros::Msg - { - public: - typedef actionlib_msgs::GoalID _goal_id_type; - _goal_id_type goal_id; - typedef uint8_t _status_type; - _status_type status; - typedef const char* _text_type; - _text_type text; - enum { PENDING = 0 }; - enum { ACTIVE = 1 }; - enum { PREEMPTED = 2 }; - enum { SUCCEEDED = 3 }; - enum { ABORTED = 4 }; - enum { REJECTED = 5 }; - enum { PREEMPTING = 6 }; - enum { RECALLING = 7 }; - enum { RECALLED = 8 }; - enum { LOST = 9 }; - - GoalStatus(): - goal_id(), - status(0), - text("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->goal_id.serialize(outbuffer + offset); - *(outbuffer + offset + 0) = (this->status >> (8 * 0)) & 0xFF; - offset += sizeof(this->status); - uint32_t length_text = strlen(this->text); - varToArr(outbuffer + offset, length_text); - offset += 4; - memcpy(outbuffer + offset, this->text, length_text); - offset += length_text; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->goal_id.deserialize(inbuffer + offset); - this->status = ((uint8_t) (*(inbuffer + offset))); - offset += sizeof(this->status); - uint32_t length_text; - arrToVar(length_text, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_text; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_text-1]=0; - this->text = (char *)(inbuffer + offset-1); - offset += length_text; - return offset; - } - - const char * getType(){ return "actionlib_msgs/GoalStatus"; }; - const char * getMD5(){ return "d388f9b87b3c471f784434d671988d4a"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/actionlib_msgs/GoalStatusArray.h b/lib/ros_lib/actionlib_msgs/GoalStatusArray.h deleted file mode 100644 index e658c50..0000000 --- a/lib/ros_lib/actionlib_msgs/GoalStatusArray.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_actionlib_msgs_GoalStatusArray_h -#define _ROS_actionlib_msgs_GoalStatusArray_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" - -namespace actionlib_msgs -{ - - class GoalStatusArray : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - uint32_t status_list_length; - typedef actionlib_msgs::GoalStatus _status_list_type; - _status_list_type st_status_list; - _status_list_type * status_list; - - GoalStatusArray(): - header(), - status_list_length(0), status_list(NULL) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - *(outbuffer + offset + 0) = (this->status_list_length >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->status_list_length >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->status_list_length >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->status_list_length >> (8 * 3)) & 0xFF; - offset += sizeof(this->status_list_length); - for( uint32_t i = 0; i < status_list_length; i++){ - offset += this->status_list[i].serialize(outbuffer + offset); - } - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - uint32_t status_list_lengthT = ((uint32_t) (*(inbuffer + offset))); - status_list_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - status_list_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - status_list_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->status_list_length); - if(status_list_lengthT > status_list_length) - this->status_list = (actionlib_msgs::GoalStatus*)realloc(this->status_list, status_list_lengthT * sizeof(actionlib_msgs::GoalStatus)); - status_list_length = status_list_lengthT; - for( uint32_t i = 0; i < status_list_length; i++){ - offset += this->st_status_list.deserialize(inbuffer + offset); - memcpy( &(this->status_list[i]), &(this->st_status_list), sizeof(actionlib_msgs::GoalStatus)); - } - return offset; - } - - const char * getType(){ return "actionlib_msgs/GoalStatusArray"; }; - const char * getMD5(){ return "8b2b82f13216d0a8ea88bd3af735e619"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/Gait.h b/lib/ros_lib/march_shared_resources/Gait.h deleted file mode 100644 index 151d146..0000000 --- a/lib/ros_lib/march_shared_resources/Gait.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _ROS_march_shared_resources_Gait_h -#define _ROS_march_shared_resources_Gait_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class Gait : public ros::Msg - { - public: - typedef const char* _gait_name_type; - _gait_name_type gait_name; - typedef double _step_size_type; - _step_size_type step_size; - - Gait(): - gait_name(""), - step_size(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_gait_name = strlen(this->gait_name); - varToArr(outbuffer + offset, length_gait_name); - offset += 4; - memcpy(outbuffer + offset, this->gait_name, length_gait_name); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_step_size; - u_step_size.real = this->step_size; - *(outbuffer + offset + 0) = (u_step_size.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_step_size.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_step_size.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_step_size.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_step_size.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_step_size.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_step_size.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_step_size.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->step_size); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_gait_name; - arrToVar(length_gait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_name-1]=0; - this->gait_name = (char *)(inbuffer + offset-1); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_step_size; - u_step_size.base = 0; - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->step_size = u_step_size.real; - offset += sizeof(this->step_size); - return offset; - } - - const char * getType(){ return "march_shared_resources/Gait"; }; - const char * getMD5(){ return "ff98d402c494c993ddd86edf09731c1a"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/GaitAction.h b/lib/ros_lib/march_shared_resources/GaitAction.h index 64d32e8..ff65b78 100644 --- a/lib/ros_lib/march_shared_resources/GaitAction.h +++ b/lib/ros_lib/march_shared_resources/GaitAction.h @@ -48,7 +48,7 @@ namespace march_shared_resources } const char * getType(){ return "march_shared_resources/GaitAction"; }; - const char * getMD5(){ return "c85799c93718e9625224b00f52bb84cf"; }; + const char * getMD5(){ return "cefddf7f6db8e5953001d960f0a2e7ac"; }; }; diff --git a/lib/ros_lib/march_shared_resources/GaitActionGoal.h b/lib/ros_lib/march_shared_resources/GaitActionGoal.h index 776481a..90a7cc9 100644 --- a/lib/ros_lib/march_shared_resources/GaitActionGoal.h +++ b/lib/ros_lib/march_shared_resources/GaitActionGoal.h @@ -48,7 +48,7 @@ namespace march_shared_resources } const char * getType(){ return "march_shared_resources/GaitActionGoal"; }; - const char * getMD5(){ return "8e4739ca52f8b8c0d762799c41212a05"; }; + const char * getMD5(){ return "8b330ab474fa41e3badfee238768ff05"; }; }; diff --git a/lib/ros_lib/march_shared_resources/GaitGoal.h b/lib/ros_lib/march_shared_resources/GaitGoal.h index 98ecdbe..96dc887 100644 --- a/lib/ros_lib/march_shared_resources/GaitGoal.h +++ b/lib/ros_lib/march_shared_resources/GaitGoal.h @@ -59,7 +59,7 @@ namespace march_shared_resources } const char * getType(){ return "march_shared_resources/GaitGoal"; }; - const char * getMD5(){ return "1bbe0ea9e2df05297b8428716718f7d2"; }; + const char * getMD5(){ return "de1744cba95645d4a7c6f1406b2d6f43"; }; }; diff --git a/lib/ros_lib/march_shared_resources/GaitInput.h b/lib/ros_lib/march_shared_resources/GaitInput.h deleted file mode 100644 index 8f5506c..0000000 --- a/lib/ros_lib/march_shared_resources/GaitInput.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef _ROS_SERVICE_GaitInput_h -#define _ROS_SERVICE_GaitInput_h -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - -static const char GAITINPUT[] = "march_shared_resources/GaitInput"; - - class GaitInputRequest : public ros::Msg - { - public: - typedef const char* _gait_name_type; - _gait_name_type gait_name; - typedef double _time_type; - _time_type time; - - GaitInputRequest(): - gait_name(""), - time(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_gait_name = strlen(this->gait_name); - varToArr(outbuffer + offset, length_gait_name); - offset += 4; - memcpy(outbuffer + offset, this->gait_name, length_gait_name); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_time; - u_time.real = this->time; - *(outbuffer + offset + 0) = (u_time.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_time.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_time.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_time.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_time.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_time.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_time.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_time.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->time); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_gait_name; - arrToVar(length_gait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_name-1]=0; - this->gait_name = (char *)(inbuffer + offset-1); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_time; - u_time.base = 0; - u_time.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->time = u_time.real; - offset += sizeof(this->time); - return offset; - } - - const char * getType(){ return GAITINPUT; }; - const char * getMD5(){ return "2d623642030e07b94e6482959561c22f"; }; - - }; - - class GaitInputResponse : public ros::Msg - { - public: - typedef bool _is_successful_type; - _is_successful_type is_successful; - typedef const char* _message_type; - _message_type message; - - GaitInputResponse(): - is_successful(0), - message("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_is_successful; - u_is_successful.real = this->is_successful; - *(outbuffer + offset + 0) = (u_is_successful.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->is_successful); - uint32_t length_message = strlen(this->message); - varToArr(outbuffer + offset, length_message); - offset += 4; - memcpy(outbuffer + offset, this->message, length_message); - offset += length_message; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_is_successful; - u_is_successful.base = 0; - u_is_successful.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->is_successful = u_is_successful.real; - offset += sizeof(this->is_successful); - uint32_t length_message; - arrToVar(length_message, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_message; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_message-1]=0; - this->message = (char *)(inbuffer + offset-1); - offset += length_message; - return offset; - } - - const char * getType(){ return GAITINPUT; }; - const char * getMD5(){ return "92814ca95de64c716f615f50abf3a8c8"; }; - - }; - - class GaitInput { - public: - typedef GaitInputRequest Request; - typedef GaitInputResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/GaitInstruction.h b/lib/ros_lib/march_shared_resources/GaitInstruction.h index b1e24c6..f759a17 100644 --- a/lib/ros_lib/march_shared_resources/GaitInstruction.h +++ b/lib/ros_lib/march_shared_resources/GaitInstruction.h @@ -15,11 +15,10 @@ namespace march_shared_resources public: typedef std_msgs::Header _header_type; _header_type header; - typedef int16_t _type_type; + typedef int8_t _type_type; _type_type type; typedef const char* _gait_name_type; _gait_name_type gait_name; - enum { INPUT_DEVICE_LOST = -1 }; enum { STOP = 0 }; enum { GAIT = 1 }; enum { PAUSE = 2 }; @@ -37,12 +36,11 @@ namespace march_shared_resources int offset = 0; offset += this->header.serialize(outbuffer + offset); union { - int16_t real; - uint16_t base; + int8_t real; + uint8_t base; } u_type; u_type.real = this->type; *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF; offset += sizeof(this->type); uint32_t length_gait_name = strlen(this->gait_name); varToArr(outbuffer + offset, length_gait_name); @@ -57,12 +55,11 @@ namespace march_shared_resources int offset = 0; offset += this->header.deserialize(inbuffer + offset); union { - int16_t real; - uint16_t base; + int8_t real; + uint8_t base; } u_type; u_type.base = 0; - u_type.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_type.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); + u_type.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); this->type = u_type.real; offset += sizeof(this->type); uint32_t length_gait_name; @@ -78,7 +75,7 @@ namespace march_shared_resources } const char * getType(){ return "march_shared_resources/GaitInstruction"; }; - const char * getMD5(){ return "33baee28fc7d9ee7dee1e42d340e1783"; }; + const char * getMD5(){ return "33391f0a380b417c7e824a1f2d772540"; }; }; diff --git a/lib/ros_lib/march_shared_resources/GaitInstructionResponse.h b/lib/ros_lib/march_shared_resources/GaitInstructionResponse.h new file mode 100644 index 0000000..e88be6b --- /dev/null +++ b/lib/ros_lib/march_shared_resources/GaitInstructionResponse.h @@ -0,0 +1,59 @@ +#ifndef _ROS_march_shared_resources_GaitInstructionResponse_h +#define _ROS_march_shared_resources_GaitInstructionResponse_h + +#include +#include +#include +#include "ros/msg.h" + +namespace march_shared_resources +{ + + class GaitInstructionResponse : public ros::Msg + { + public: + typedef int8_t _result_type; + _result_type result; + enum { GAIT_REJECTED = -1 }; + enum { GAIT_ACCEPTED = 0 }; + enum { GAIT_FINISHED = 1 }; + + GaitInstructionResponse(): + result(0) + { + } + + virtual int serialize(unsigned char *outbuffer) const + { + int offset = 0; + union { + int8_t real; + uint8_t base; + } u_result; + u_result.real = this->result; + *(outbuffer + offset + 0) = (u_result.base >> (8 * 0)) & 0xFF; + offset += sizeof(this->result); + return offset; + } + + virtual int deserialize(unsigned char *inbuffer) + { + int offset = 0; + union { + int8_t real; + uint8_t base; + } u_result; + u_result.base = 0; + u_result.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); + this->result = u_result.real; + offset += sizeof(this->result); + return offset; + } + + const char * getType(){ return "march_shared_resources/GaitInstructionResponse"; }; + const char * getMD5(){ return "0a9a7173d5945f6df13f205af2597eb4"; }; + + }; + +} +#endif diff --git a/lib/ros_lib/march_shared_resources/GaitRequest.h b/lib/ros_lib/march_shared_resources/GaitRequest.h deleted file mode 100644 index e79c007..0000000 --- a/lib/ros_lib/march_shared_resources/GaitRequest.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef _ROS_SERVICE_GaitRequest_h -#define _ROS_SERVICE_GaitRequest_h -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - -static const char GAITREQUEST[] = "march_shared_resources/GaitRequest"; - - class GaitRequestRequest : public ros::Msg - { - public: - typedef const char* _gait_file_type; - _gait_file_type gait_file; - - GaitRequestRequest(): - gait_file("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_gait_file = strlen(this->gait_file); - varToArr(outbuffer + offset, length_gait_file); - offset += 4; - memcpy(outbuffer + offset, this->gait_file, length_gait_file); - offset += length_gait_file; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_gait_file; - arrToVar(length_gait_file, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_file; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_file-1]=0; - this->gait_file = (char *)(inbuffer + offset-1); - offset += length_gait_file; - return offset; - } - - const char * getType(){ return GAITREQUEST; }; - const char * getMD5(){ return "f891f6238cf59a5f9f2daa63e7a355a4"; }; - - }; - - class GaitRequestResponse : public ros::Msg - { - public: - typedef bool _success_type; - _success_type success; - typedef const char* _message_type; - _message_type message; - - GaitRequestResponse(): - success(0), - message("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.real = this->success; - *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->success); - uint32_t length_message = strlen(this->message); - varToArr(outbuffer + offset, length_message); - offset += 4; - memcpy(outbuffer + offset, this->message, length_message); - offset += length_message; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.base = 0; - u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->success = u_success.real; - offset += sizeof(this->success); - uint32_t length_message; - arrToVar(length_message, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_message; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_message-1]=0; - this->message = (char *)(inbuffer + offset-1); - offset += length_message; - return offset; - } - - const char * getType(){ return GAITREQUEST; }; - const char * getMD5(){ return "937c9679a518e3a18d831e57125ea522"; }; - - }; - - class GaitRequest { - public: - typedef GaitRequestRequest Request; - typedef GaitRequestResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/GaitStatus.h b/lib/ros_lib/march_shared_resources/GaitStatus.h deleted file mode 100644 index ace7597..0000000 --- a/lib/ros_lib/march_shared_resources/GaitStatus.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _ROS_march_shared_resources_GaitStatus_h -#define _ROS_march_shared_resources_GaitStatus_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class GaitStatus : public ros::Msg - { - public: - typedef int64_t _type_type; - _type_type type; - typedef const char* _gait_name_type; - _gait_name_type gait_name; - - GaitStatus(): - type(0), - gait_name("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_type; - u_type.real = this->type; - *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_type.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_type.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_type.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_type.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->type); - uint32_t length_gait_name = strlen(this->gait_name); - varToArr(outbuffer + offset, length_gait_name); - offset += 4; - memcpy(outbuffer + offset, this->gait_name, length_gait_name); - offset += length_gait_name; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_type; - u_type.base = 0; - u_type.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_type.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->type = u_type.real; - offset += sizeof(this->type); - uint32_t length_gait_name; - arrToVar(length_gait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_name-1]=0; - this->gait_name = (char *)(inbuffer + offset-1); - offset += length_gait_name; - return offset; - } - - const char * getType(){ return "march_shared_resources/GaitStatus"; }; - const char * getMD5(){ return "ac2e94188f865942da982b5b64401ab2"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitAction.h b/lib/ros_lib/march_shared_resources/MoveToGaitAction.h deleted file mode 100644 index 9c6f69a..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitAction.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitAction_h -#define _ROS_march_shared_resources_MoveToGaitAction_h - -#include -#include -#include -#include "ros/msg.h" -#include "march_shared_resources/MoveToGaitActionGoal.h" -#include "march_shared_resources/MoveToGaitActionResult.h" -#include "march_shared_resources/MoveToGaitActionFeedback.h" - -namespace march_shared_resources -{ - - class MoveToGaitAction : public ros::Msg - { - public: - typedef march_shared_resources::MoveToGaitActionGoal _action_goal_type; - _action_goal_type action_goal; - typedef march_shared_resources::MoveToGaitActionResult _action_result_type; - _action_result_type action_result; - typedef march_shared_resources::MoveToGaitActionFeedback _action_feedback_type; - _action_feedback_type action_feedback; - - MoveToGaitAction(): - action_goal(), - action_result(), - action_feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->action_goal.serialize(outbuffer + offset); - offset += this->action_result.serialize(outbuffer + offset); - offset += this->action_feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->action_goal.deserialize(inbuffer + offset); - offset += this->action_result.deserialize(inbuffer + offset); - offset += this->action_feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitAction"; }; - const char * getMD5(){ return "7f6f08d79e3be16de203dd0c4d237a26"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitActionFeedback.h b/lib/ros_lib/march_shared_resources/MoveToGaitActionFeedback.h deleted file mode 100644 index eb45b31..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitActionFeedback.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitActionFeedback_h -#define _ROS_march_shared_resources_MoveToGaitActionFeedback_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "march_shared_resources/MoveToGaitFeedback.h" - -namespace march_shared_resources -{ - - class MoveToGaitActionFeedback : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef march_shared_resources::MoveToGaitFeedback _feedback_type; - _feedback_type feedback; - - MoveToGaitActionFeedback(): - header(), - status(), - feedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->feedback.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->feedback.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitActionFeedback"; }; - const char * getMD5(){ return "aae20e09065c3809e8a8e87c4c8953fd"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitActionGoal.h b/lib/ros_lib/march_shared_resources/MoveToGaitActionGoal.h deleted file mode 100644 index 0ee544f..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitActionGoal.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitActionGoal_h -#define _ROS_march_shared_resources_MoveToGaitActionGoal_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalID.h" -#include "march_shared_resources/MoveToGaitGoal.h" - -namespace march_shared_resources -{ - - class MoveToGaitActionGoal : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalID _goal_id_type; - _goal_id_type goal_id; - typedef march_shared_resources::MoveToGaitGoal _goal_type; - _goal_type goal; - - MoveToGaitActionGoal(): - header(), - goal_id(), - goal() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->goal_id.serialize(outbuffer + offset); - offset += this->goal.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->goal_id.deserialize(inbuffer + offset); - offset += this->goal.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitActionGoal"; }; - const char * getMD5(){ return "035864cd1ebe4d6ec52034ce69b023da"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitActionResult.h b/lib/ros_lib/march_shared_resources/MoveToGaitActionResult.h deleted file mode 100644 index 895df1f..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitActionResult.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitActionResult_h -#define _ROS_march_shared_resources_MoveToGaitActionResult_h - -#include -#include -#include -#include "ros/msg.h" -#include "std_msgs/Header.h" -#include "actionlib_msgs/GoalStatus.h" -#include "march_shared_resources/MoveToGaitResult.h" - -namespace march_shared_resources -{ - - class MoveToGaitActionResult : public ros::Msg - { - public: - typedef std_msgs::Header _header_type; - _header_type header; - typedef actionlib_msgs::GoalStatus _status_type; - _status_type status; - typedef march_shared_resources::MoveToGaitResult _result_type; - _result_type result; - - MoveToGaitActionResult(): - header(), - status(), - result() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - offset += this->header.serialize(outbuffer + offset); - offset += this->status.serialize(outbuffer + offset); - offset += this->result.serialize(outbuffer + offset); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - offset += this->header.deserialize(inbuffer + offset); - offset += this->status.deserialize(inbuffer + offset); - offset += this->result.deserialize(inbuffer + offset); - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitActionResult"; }; - const char * getMD5(){ return "1eb06eeff08fa7ea874431638cb52332"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitFeedback.h b/lib/ros_lib/march_shared_resources/MoveToGaitFeedback.h deleted file mode 100644 index 2d9312e..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitFeedback.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitFeedback_h -#define _ROS_march_shared_resources_MoveToGaitFeedback_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class MoveToGaitFeedback : public ros::Msg - { - public: - - MoveToGaitFeedback() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitFeedback"; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitGoal.h b/lib/ros_lib/march_shared_resources/MoveToGaitGoal.h deleted file mode 100644 index d2b2a1c..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitGoal.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitGoal_h -#define _ROS_march_shared_resources_MoveToGaitGoal_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class MoveToGaitGoal : public ros::Msg - { - public: - typedef const char* _name_type; - _name_type name; - typedef const char* _subgait_name_type; - _subgait_name_type subgait_name; - typedef const char* _gait_name_type; - _gait_name_type gait_name; - - MoveToGaitGoal(): - name(""), - subgait_name(""), - gait_name("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_name = strlen(this->name); - varToArr(outbuffer + offset, length_name); - offset += 4; - memcpy(outbuffer + offset, this->name, length_name); - offset += length_name; - uint32_t length_subgait_name = strlen(this->subgait_name); - varToArr(outbuffer + offset, length_subgait_name); - offset += 4; - memcpy(outbuffer + offset, this->subgait_name, length_subgait_name); - offset += length_subgait_name; - uint32_t length_gait_name = strlen(this->gait_name); - varToArr(outbuffer + offset, length_gait_name); - offset += 4; - memcpy(outbuffer + offset, this->gait_name, length_gait_name); - offset += length_gait_name; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_name; - arrToVar(length_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_name-1]=0; - this->name = (char *)(inbuffer + offset-1); - offset += length_name; - uint32_t length_subgait_name; - arrToVar(length_subgait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_subgait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_subgait_name-1]=0; - this->subgait_name = (char *)(inbuffer + offset-1); - offset += length_subgait_name; - uint32_t length_gait_name; - arrToVar(length_gait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_name-1]=0; - this->gait_name = (char *)(inbuffer + offset-1); - offset += length_gait_name; - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitGoal"; }; - const char * getMD5(){ return "0dc8656b4dc6724d9fd4f6a17ec2f6a9"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/MoveToGaitResult.h b/lib/ros_lib/march_shared_resources/MoveToGaitResult.h deleted file mode 100644 index c88eb86..0000000 --- a/lib/ros_lib/march_shared_resources/MoveToGaitResult.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _ROS_march_shared_resources_MoveToGaitResult_h -#define _ROS_march_shared_resources_MoveToGaitResult_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class MoveToGaitResult : public ros::Msg - { - public: - - MoveToGaitResult() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return "march_shared_resources/MoveToGaitResult"; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/PerformGait.h b/lib/ros_lib/march_shared_resources/PerformGait.h deleted file mode 100644 index 3dc5203..0000000 --- a/lib/ros_lib/march_shared_resources/PerformGait.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef _ROS_march_shared_resources_PerformGait_h -#define _ROS_march_shared_resources_PerformGait_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class PerformGait : public ros::Msg - { - public: - typedef const char* _gait_name_type; - _gait_name_type gait_name; - typedef double _time_type; - _time_type time; - typedef int64_t _repeat_type; - _repeat_type repeat; - - PerformGait(): - gait_name(""), - time(0), - repeat(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_gait_name = strlen(this->gait_name); - varToArr(outbuffer + offset, length_gait_name); - offset += 4; - memcpy(outbuffer + offset, this->gait_name, length_gait_name); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_time; - u_time.real = this->time; - *(outbuffer + offset + 0) = (u_time.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_time.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_time.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_time.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_time.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_time.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_time.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_time.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->time); - union { - int64_t real; - uint64_t base; - } u_repeat; - u_repeat.real = this->repeat; - *(outbuffer + offset + 0) = (u_repeat.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_repeat.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_repeat.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_repeat.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_repeat.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_repeat.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_repeat.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_repeat.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->repeat); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_gait_name; - arrToVar(length_gait_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_gait_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_gait_name-1]=0; - this->gait_name = (char *)(inbuffer + offset-1); - offset += length_gait_name; - union { - double real; - uint64_t base; - } u_time; - u_time.base = 0; - u_time.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_time.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->time = u_time.real; - offset += sizeof(this->time); - union { - int64_t real; - uint64_t base; - } u_repeat; - u_repeat.base = 0; - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_repeat.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->repeat = u_repeat.real; - offset += sizeof(this->repeat); - return offset; - } - - const char * getType(){ return "march_shared_resources/PerformGait"; }; - const char * getMD5(){ return "c2856c4d066eecb97166932dc6907aa4"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/PlayInput.h b/lib/ros_lib/march_shared_resources/PlayInput.h deleted file mode 100644 index 1f7c0e4..0000000 --- a/lib/ros_lib/march_shared_resources/PlayInput.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef _ROS_SERVICE_PlayInput_h -#define _ROS_SERVICE_PlayInput_h -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - -static const char PLAYINPUT[] = "march_shared_resources/PlayInput"; - - class PlayInputRequest : public ros::Msg - { - public: - typedef int64_t _play_input_type; - _play_input_type play_input; - - PlayInputRequest(): - play_input(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_play_input; - u_play_input.real = this->play_input; - *(outbuffer + offset + 0) = (u_play_input.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_play_input.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_play_input.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_play_input.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_play_input.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_play_input.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_play_input.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_play_input.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->play_input); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_play_input; - u_play_input.base = 0; - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->play_input = u_play_input.real; - offset += sizeof(this->play_input); - return offset; - } - - const char * getType(){ return PLAYINPUT; }; - const char * getMD5(){ return "fc968e449017caef1e2788eccc41a159"; }; - - }; - - class PlayInputResponse : public ros::Msg - { - public: - typedef bool _is_successful_type; - _is_successful_type is_successful; - typedef const char* _message_type; - _message_type message; - - PlayInputResponse(): - is_successful(0), - message("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_is_successful; - u_is_successful.real = this->is_successful; - *(outbuffer + offset + 0) = (u_is_successful.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->is_successful); - uint32_t length_message = strlen(this->message); - varToArr(outbuffer + offset, length_message); - offset += 4; - memcpy(outbuffer + offset, this->message, length_message); - offset += length_message; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_is_successful; - u_is_successful.base = 0; - u_is_successful.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->is_successful = u_is_successful.real; - offset += sizeof(this->is_successful); - uint32_t length_message; - arrToVar(length_message, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_message; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_message-1]=0; - this->message = (char *)(inbuffer + offset-1); - offset += length_message; - return offset; - } - - const char * getType(){ return PLAYINPUT; }; - const char * getMD5(){ return "92814ca95de64c716f615f50abf3a8c8"; }; - - }; - - class PlayInput { - public: - typedef PlayInputRequest Request; - typedef PlayInputResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/PlayInputMaster.h b/lib/ros_lib/march_shared_resources/PlayInputMaster.h deleted file mode 100644 index 25a47ca..0000000 --- a/lib/ros_lib/march_shared_resources/PlayInputMaster.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_march_shared_resources_PlayInputMaster_h -#define _ROS_march_shared_resources_PlayInputMaster_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class PlayInputMaster : public ros::Msg - { - public: - typedef int64_t _play_input_type; - _play_input_type play_input; - - PlayInputMaster(): - play_input(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_play_input; - u_play_input.real = this->play_input; - *(outbuffer + offset + 0) = (u_play_input.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_play_input.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_play_input.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_play_input.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_play_input.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_play_input.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_play_input.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_play_input.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->play_input); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - int64_t real; - uint64_t base; - } u_play_input; - u_play_input.base = 0; - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_play_input.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->play_input = u_play_input.real; - offset += sizeof(this->play_input); - return offset; - } - - const char * getType(){ return "march_shared_resources/PlayInputMaster"; }; - const char * getMD5(){ return "fc968e449017caef1e2788eccc41a159"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/StepSize.h b/lib/ros_lib/march_shared_resources/StepSize.h deleted file mode 100644 index 7c619f9..0000000 --- a/lib/ros_lib/march_shared_resources/StepSize.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_march_shared_resources_StepSize_h -#define _ROS_march_shared_resources_StepSize_h - -#include -#include -#include -#include "ros/msg.h" - -namespace march_shared_resources -{ - - class StepSize : public ros::Msg - { - public: - typedef double _step_size_type; - _step_size_type step_size; - - StepSize(): - step_size(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - double real; - uint64_t base; - } u_step_size; - u_step_size.real = this->step_size; - *(outbuffer + offset + 0) = (u_step_size.base >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (u_step_size.base >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (u_step_size.base >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (u_step_size.base >> (8 * 3)) & 0xFF; - *(outbuffer + offset + 4) = (u_step_size.base >> (8 * 4)) & 0xFF; - *(outbuffer + offset + 5) = (u_step_size.base >> (8 * 5)) & 0xFF; - *(outbuffer + offset + 6) = (u_step_size.base >> (8 * 6)) & 0xFF; - *(outbuffer + offset + 7) = (u_step_size.base >> (8 * 7)) & 0xFF; - offset += sizeof(this->step_size); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - double real; - uint64_t base; - } u_step_size; - u_step_size.base = 0; - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); - u_step_size.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); - this->step_size = u_step_size.real; - offset += sizeof(this->step_size); - return offset; - } - - const char * getType(){ return "march_shared_resources/StepSize"; }; - const char * getMD5(){ return "76290af81b223bb4ba79cf43558301b6"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/march_shared_resources/Subgait.h b/lib/ros_lib/march_shared_resources/Subgait.h index c65e222..41301e2 100644 --- a/lib/ros_lib/march_shared_resources/Subgait.h +++ b/lib/ros_lib/march_shared_resources/Subgait.h @@ -22,6 +22,8 @@ namespace march_shared_resources _version_type version; typedef const char* _description_type; _description_type description; + typedef const char* _gait_type_type; + _gait_type_type gait_type; uint32_t setpoints_length; typedef march_shared_resources::Setpoint _setpoints_type; _setpoints_type st_setpoints; @@ -39,6 +41,7 @@ namespace march_shared_resources name(""), version(""), description(""), + gait_type(""), setpoints_length(0), setpoints(NULL), trajectory(), duration(), @@ -64,6 +67,11 @@ namespace march_shared_resources offset += 4; memcpy(outbuffer + offset, this->description, length_description); offset += length_description; + uint32_t length_gait_type = strlen(this->gait_type); + varToArr(outbuffer + offset, length_gait_type); + offset += 4; + memcpy(outbuffer + offset, this->gait_type, length_gait_type); + offset += length_gait_type; *(outbuffer + offset + 0) = (this->setpoints_length >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->setpoints_length >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->setpoints_length >> (8 * 2)) & 0xFF; @@ -124,6 +132,15 @@ namespace march_shared_resources inbuffer[offset+length_description-1]=0; this->description = (char *)(inbuffer + offset-1); offset += length_description; + uint32_t length_gait_type; + arrToVar(length_gait_type, (inbuffer + offset)); + offset += 4; + for(unsigned int k= offset; k< offset+length_gait_type; ++k){ + inbuffer[k-1]=inbuffer[k]; + } + inbuffer[offset+length_gait_type-1]=0; + this->gait_type = (char *)(inbuffer + offset-1); + offset += length_gait_type; uint32_t setpoints_lengthT = ((uint32_t) (*(inbuffer + offset))); setpoints_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); setpoints_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); @@ -163,7 +180,7 @@ namespace march_shared_resources } const char * getType(){ return "march_shared_resources/Subgait"; }; - const char * getMD5(){ return "56dd95f06d51574a3fc7a0eac6b1b780"; }; + const char * getMD5(){ return "7ce6c0af68699674ac863f06f39674ac"; }; }; diff --git a/lib/ros_lib/roscpp/Empty.h b/lib/ros_lib/roscpp/Empty.h deleted file mode 100644 index df021b7..0000000 --- a/lib/ros_lib/roscpp/Empty.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_SERVICE_Empty_h -#define _ROS_SERVICE_Empty_h -#include -#include -#include -#include "ros/msg.h" - -namespace roscpp -{ - -static const char EMPTY[] = "roscpp/Empty"; - - class EmptyRequest : public ros::Msg - { - public: - - EmptyRequest() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return EMPTY; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class EmptyResponse : public ros::Msg - { - public: - - EmptyResponse() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return EMPTY; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class Empty { - public: - typedef EmptyRequest Request; - typedef EmptyResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/roscpp/GetLoggers.h b/lib/ros_lib/roscpp/GetLoggers.h deleted file mode 100644 index 35f67fb..0000000 --- a/lib/ros_lib/roscpp/GetLoggers.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef _ROS_SERVICE_GetLoggers_h -#define _ROS_SERVICE_GetLoggers_h -#include -#include -#include -#include "ros/msg.h" -#include "roscpp/Logger.h" - -namespace roscpp -{ - -static const char GETLOGGERS[] = "roscpp/GetLoggers"; - - class GetLoggersRequest : public ros::Msg - { - public: - - GetLoggersRequest() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return GETLOGGERS; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class GetLoggersResponse : public ros::Msg - { - public: - uint32_t loggers_length; - typedef roscpp::Logger _loggers_type; - _loggers_type st_loggers; - _loggers_type * loggers; - - GetLoggersResponse(): - loggers_length(0), loggers(NULL) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - *(outbuffer + offset + 0) = (this->loggers_length >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->loggers_length >> (8 * 1)) & 0xFF; - *(outbuffer + offset + 2) = (this->loggers_length >> (8 * 2)) & 0xFF; - *(outbuffer + offset + 3) = (this->loggers_length >> (8 * 3)) & 0xFF; - offset += sizeof(this->loggers_length); - for( uint32_t i = 0; i < loggers_length; i++){ - offset += this->loggers[i].serialize(outbuffer + offset); - } - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t loggers_lengthT = ((uint32_t) (*(inbuffer + offset))); - loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); - loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); - loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); - offset += sizeof(this->loggers_length); - if(loggers_lengthT > loggers_length) - this->loggers = (roscpp::Logger*)realloc(this->loggers, loggers_lengthT * sizeof(roscpp::Logger)); - loggers_length = loggers_lengthT; - for( uint32_t i = 0; i < loggers_length; i++){ - offset += this->st_loggers.deserialize(inbuffer + offset); - memcpy( &(this->loggers[i]), &(this->st_loggers), sizeof(roscpp::Logger)); - } - return offset; - } - - const char * getType(){ return GETLOGGERS; }; - const char * getMD5(){ return "32e97e85527d4678a8f9279894bb64b0"; }; - - }; - - class GetLoggers { - public: - typedef GetLoggersRequest Request; - typedef GetLoggersResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/roscpp/Logger.h b/lib/ros_lib/roscpp/Logger.h deleted file mode 100644 index 64c68f3..0000000 --- a/lib/ros_lib/roscpp/Logger.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _ROS_roscpp_Logger_h -#define _ROS_roscpp_Logger_h - -#include -#include -#include -#include "ros/msg.h" - -namespace roscpp -{ - - class Logger : public ros::Msg - { - public: - typedef const char* _name_type; - _name_type name; - typedef const char* _level_type; - _level_type level; - - Logger(): - name(""), - level("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_name = strlen(this->name); - varToArr(outbuffer + offset, length_name); - offset += 4; - memcpy(outbuffer + offset, this->name, length_name); - offset += length_name; - uint32_t length_level = strlen(this->level); - varToArr(outbuffer + offset, length_level); - offset += 4; - memcpy(outbuffer + offset, this->level, length_level); - offset += length_level; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_name; - arrToVar(length_name, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_name; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_name-1]=0; - this->name = (char *)(inbuffer + offset-1); - offset += length_name; - uint32_t length_level; - arrToVar(length_level, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_level; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_level-1]=0; - this->level = (char *)(inbuffer + offset-1); - offset += length_level; - return offset; - } - - const char * getType(){ return "roscpp/Logger"; }; - const char * getMD5(){ return "a6069a2ff40db7bd32143dd66e1f408e"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/roscpp/SetLoggerLevel.h b/lib/ros_lib/roscpp/SetLoggerLevel.h deleted file mode 100644 index 64f2a24..0000000 --- a/lib/ros_lib/roscpp/SetLoggerLevel.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef _ROS_SERVICE_SetLoggerLevel_h -#define _ROS_SERVICE_SetLoggerLevel_h -#include -#include -#include -#include "ros/msg.h" - -namespace roscpp -{ - -static const char SETLOGGERLEVEL[] = "roscpp/SetLoggerLevel"; - - class SetLoggerLevelRequest : public ros::Msg - { - public: - typedef const char* _logger_type; - _logger_type logger; - typedef const char* _level_type; - _level_type level; - - SetLoggerLevelRequest(): - logger(""), - level("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_logger = strlen(this->logger); - varToArr(outbuffer + offset, length_logger); - offset += 4; - memcpy(outbuffer + offset, this->logger, length_logger); - offset += length_logger; - uint32_t length_level = strlen(this->level); - varToArr(outbuffer + offset, length_level); - offset += 4; - memcpy(outbuffer + offset, this->level, length_level); - offset += length_level; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_logger; - arrToVar(length_logger, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_logger; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_logger-1]=0; - this->logger = (char *)(inbuffer + offset-1); - offset += length_logger; - uint32_t length_level; - arrToVar(length_level, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_level; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_level-1]=0; - this->level = (char *)(inbuffer + offset-1); - offset += length_level; - return offset; - } - - const char * getType(){ return SETLOGGERLEVEL; }; - const char * getMD5(){ return "51da076440d78ca1684d36c868df61ea"; }; - - }; - - class SetLoggerLevelResponse : public ros::Msg - { - public: - - SetLoggerLevelResponse() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return SETLOGGERLEVEL; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class SetLoggerLevel { - public: - typedef SetLoggerLevelRequest Request; - typedef SetLoggerLevelResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/rosserial_arduino/Adc.h b/lib/ros_lib/rosserial_arduino/Adc.h deleted file mode 100644 index 23e48d6..0000000 --- a/lib/ros_lib/rosserial_arduino/Adc.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef _ROS_rosserial_arduino_Adc_h -#define _ROS_rosserial_arduino_Adc_h - -#include -#include -#include -#include "ros/msg.h" - -namespace rosserial_arduino -{ - - class Adc : public ros::Msg - { - public: - typedef uint16_t _adc0_type; - _adc0_type adc0; - typedef uint16_t _adc1_type; - _adc1_type adc1; - typedef uint16_t _adc2_type; - _adc2_type adc2; - typedef uint16_t _adc3_type; - _adc3_type adc3; - typedef uint16_t _adc4_type; - _adc4_type adc4; - typedef uint16_t _adc5_type; - _adc5_type adc5; - - Adc(): - adc0(0), - adc1(0), - adc2(0), - adc3(0), - adc4(0), - adc5(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc0); - *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc1); - *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc2); - *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc3); - *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc4); - *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc5); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - this->adc0 = ((uint16_t) (*(inbuffer + offset))); - this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc0); - this->adc1 = ((uint16_t) (*(inbuffer + offset))); - this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc1); - this->adc2 = ((uint16_t) (*(inbuffer + offset))); - this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc2); - this->adc3 = ((uint16_t) (*(inbuffer + offset))); - this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc3); - this->adc4 = ((uint16_t) (*(inbuffer + offset))); - this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc4); - this->adc5 = ((uint16_t) (*(inbuffer + offset))); - this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc5); - return offset; - } - - const char * getType(){ return "rosserial_arduino/Adc"; }; - const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/rosserial_arduino/Test.h b/lib/ros_lib/rosserial_arduino/Test.h deleted file mode 100644 index cd806db..0000000 --- a/lib/ros_lib/rosserial_arduino/Test.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef _ROS_SERVICE_Test_h -#define _ROS_SERVICE_Test_h -#include -#include -#include -#include "ros/msg.h" - -namespace rosserial_arduino -{ - -static const char TEST[] = "rosserial_arduino/Test"; - - class TestRequest : public ros::Msg - { - public: - typedef const char* _input_type; - _input_type input; - - TestRequest(): - input("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_input = strlen(this->input); - varToArr(outbuffer + offset, length_input); - offset += 4; - memcpy(outbuffer + offset, this->input, length_input); - offset += length_input; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_input; - arrToVar(length_input, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_input; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_input-1]=0; - this->input = (char *)(inbuffer + offset-1); - offset += length_input; - return offset; - } - - const char * getType(){ return TEST; }; - const char * getMD5(){ return "39e92f1778057359c64c7b8a7d7b19de"; }; - - }; - - class TestResponse : public ros::Msg - { - public: - typedef const char* _output_type; - _output_type output; - - TestResponse(): - output("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_output = strlen(this->output); - varToArr(outbuffer + offset, length_output); - offset += 4; - memcpy(outbuffer + offset, this->output, length_output); - offset += length_output; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_output; - arrToVar(length_output, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_output; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_output-1]=0; - this->output = (char *)(inbuffer + offset-1); - offset += length_output; - return offset; - } - - const char * getType(){ return TEST; }; - const char * getMD5(){ return "0825d95fdfa2c8f4bbb4e9c74bccd3fd"; }; - - }; - - class Test { - public: - typedef TestRequest Request; - typedef TestResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/rosserial_mbed/Adc.h b/lib/ros_lib/rosserial_mbed/Adc.h deleted file mode 100644 index d46fc40..0000000 --- a/lib/ros_lib/rosserial_mbed/Adc.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef _ROS_rosserial_mbed_Adc_h -#define _ROS_rosserial_mbed_Adc_h - -#include -#include -#include -#include "ros/msg.h" - -namespace rosserial_mbed -{ - - class Adc : public ros::Msg - { - public: - typedef uint16_t _adc0_type; - _adc0_type adc0; - typedef uint16_t _adc1_type; - _adc1_type adc1; - typedef uint16_t _adc2_type; - _adc2_type adc2; - typedef uint16_t _adc3_type; - _adc3_type adc3; - typedef uint16_t _adc4_type; - _adc4_type adc4; - typedef uint16_t _adc5_type; - _adc5_type adc5; - - Adc(): - adc0(0), - adc1(0), - adc2(0), - adc3(0), - adc4(0), - adc5(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc0); - *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc1); - *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc2); - *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc3); - *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc4); - *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF; - *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF; - offset += sizeof(this->adc5); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - this->adc0 = ((uint16_t) (*(inbuffer + offset))); - this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc0); - this->adc1 = ((uint16_t) (*(inbuffer + offset))); - this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc1); - this->adc2 = ((uint16_t) (*(inbuffer + offset))); - this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc2); - this->adc3 = ((uint16_t) (*(inbuffer + offset))); - this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc3); - this->adc4 = ((uint16_t) (*(inbuffer + offset))); - this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc4); - this->adc5 = ((uint16_t) (*(inbuffer + offset))); - this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); - offset += sizeof(this->adc5); - return offset; - } - - const char * getType(){ return "rosserial_mbed/Adc"; }; - const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; }; - - }; - -} -#endif diff --git a/lib/ros_lib/rosserial_mbed/Test.h b/lib/ros_lib/rosserial_mbed/Test.h deleted file mode 100644 index 6a2658f..0000000 --- a/lib/ros_lib/rosserial_mbed/Test.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef _ROS_SERVICE_Test_h -#define _ROS_SERVICE_Test_h -#include -#include -#include -#include "ros/msg.h" - -namespace rosserial_mbed -{ - -static const char TEST[] = "rosserial_mbed/Test"; - - class TestRequest : public ros::Msg - { - public: - typedef const char* _input_type; - _input_type input; - - TestRequest(): - input("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_input = strlen(this->input); - varToArr(outbuffer + offset, length_input); - offset += 4; - memcpy(outbuffer + offset, this->input, length_input); - offset += length_input; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_input; - arrToVar(length_input, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_input; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_input-1]=0; - this->input = (char *)(inbuffer + offset-1); - offset += length_input; - return offset; - } - - const char * getType(){ return TEST; }; - const char * getMD5(){ return "39e92f1778057359c64c7b8a7d7b19de"; }; - - }; - - class TestResponse : public ros::Msg - { - public: - typedef const char* _output_type; - _output_type output; - - TestResponse(): - output("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - uint32_t length_output = strlen(this->output); - varToArr(outbuffer + offset, length_output); - offset += 4; - memcpy(outbuffer + offset, this->output, length_output); - offset += length_output; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - uint32_t length_output; - arrToVar(length_output, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_output; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_output-1]=0; - this->output = (char *)(inbuffer + offset-1); - offset += length_output; - return offset; - } - - const char * getType(){ return TEST; }; - const char * getMD5(){ return "0825d95fdfa2c8f4bbb4e9c74bccd3fd"; }; - - }; - - class Test { - public: - typedef TestRequest Request; - typedef TestResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/std_srvs/Empty.h b/lib/ros_lib/std_srvs/Empty.h deleted file mode 100644 index b040dd2..0000000 --- a/lib/ros_lib/std_srvs/Empty.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _ROS_SERVICE_Empty_h -#define _ROS_SERVICE_Empty_h -#include -#include -#include -#include "ros/msg.h" - -namespace std_srvs -{ - -static const char EMPTY[] = "std_srvs/Empty"; - - class EmptyRequest : public ros::Msg - { - public: - - EmptyRequest() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return EMPTY; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class EmptyResponse : public ros::Msg - { - public: - - EmptyResponse() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return EMPTY; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class Empty { - public: - typedef EmptyRequest Request; - typedef EmptyResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/std_srvs/SetBool.h b/lib/ros_lib/std_srvs/SetBool.h deleted file mode 100644 index 1feb34e..0000000 --- a/lib/ros_lib/std_srvs/SetBool.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef _ROS_SERVICE_SetBool_h -#define _ROS_SERVICE_SetBool_h -#include -#include -#include -#include "ros/msg.h" - -namespace std_srvs -{ - -static const char SETBOOL[] = "std_srvs/SetBool"; - - class SetBoolRequest : public ros::Msg - { - public: - typedef bool _data_type; - _data_type data; - - SetBoolRequest(): - data(0) - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_data; - u_data.real = this->data; - *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->data); - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_data; - u_data.base = 0; - u_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->data = u_data.real; - offset += sizeof(this->data); - return offset; - } - - const char * getType(){ return SETBOOL; }; - const char * getMD5(){ return "8b94c1b53db61fb6aed406028ad6332a"; }; - - }; - - class SetBoolResponse : public ros::Msg - { - public: - typedef bool _success_type; - _success_type success; - typedef const char* _message_type; - _message_type message; - - SetBoolResponse(): - success(0), - message("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.real = this->success; - *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->success); - uint32_t length_message = strlen(this->message); - varToArr(outbuffer + offset, length_message); - offset += 4; - memcpy(outbuffer + offset, this->message, length_message); - offset += length_message; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.base = 0; - u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->success = u_success.real; - offset += sizeof(this->success); - uint32_t length_message; - arrToVar(length_message, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_message; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_message-1]=0; - this->message = (char *)(inbuffer + offset-1); - offset += length_message; - return offset; - } - - const char * getType(){ return SETBOOL; }; - const char * getMD5(){ return "937c9679a518e3a18d831e57125ea522"; }; - - }; - - class SetBool { - public: - typedef SetBoolRequest Request; - typedef SetBoolResponse Response; - }; - -} -#endif diff --git a/lib/ros_lib/std_srvs/Trigger.h b/lib/ros_lib/std_srvs/Trigger.h deleted file mode 100644 index 34d1e48..0000000 --- a/lib/ros_lib/std_srvs/Trigger.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _ROS_SERVICE_Trigger_h -#define _ROS_SERVICE_Trigger_h -#include -#include -#include -#include "ros/msg.h" - -namespace std_srvs -{ - -static const char TRIGGER[] = "std_srvs/Trigger"; - - class TriggerRequest : public ros::Msg - { - public: - - TriggerRequest() - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - return offset; - } - - const char * getType(){ return TRIGGER; }; - const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; - - }; - - class TriggerResponse : public ros::Msg - { - public: - typedef bool _success_type; - _success_type success; - typedef const char* _message_type; - _message_type message; - - TriggerResponse(): - success(0), - message("") - { - } - - virtual int serialize(unsigned char *outbuffer) const - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.real = this->success; - *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; - offset += sizeof(this->success); - uint32_t length_message = strlen(this->message); - varToArr(outbuffer + offset, length_message); - offset += 4; - memcpy(outbuffer + offset, this->message, length_message); - offset += length_message; - return offset; - } - - virtual int deserialize(unsigned char *inbuffer) - { - int offset = 0; - union { - bool real; - uint8_t base; - } u_success; - u_success.base = 0; - u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); - this->success = u_success.real; - offset += sizeof(this->success); - uint32_t length_message; - arrToVar(length_message, (inbuffer + offset)); - offset += 4; - for(unsigned int k= offset; k< offset+length_message; ++k){ - inbuffer[k-1]=inbuffer[k]; - } - inbuffer[offset+length_message-1]=0; - this->message = (char *)(inbuffer + offset-1); - offset += length_message; - return offset; - } - - const char * getType(){ return TRIGGER; }; - const char * getMD5(){ return "937c9679a518e3a18d831e57125ea522"; }; - - }; - - class Trigger { - public: - typedef TriggerRequest Request; - typedef TriggerResponse Response; - }; - -} -#endif diff --git a/platformio.ini b/platformio.ini index 5ae559e..ddc9de6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,29 +12,61 @@ description = Embedded software for the input device embedded in the crutch default_envs = debug [env] -platform = espressif32 -board = lolin_d32_pro -framework = arduino - ; If Platformio gives a upload error, please specify this for your respective COM port upload_port = /dev/ttyUSB0 upload_speed = 230400 +monitor_port = /dev/ttyUSB0 +monitor_speed = 57600 +monitor_flags = + --encoding + UTF-8 + check_tool = cppcheck, clangtidy check_severity = low, medium, high +check_flags = + clangtidy: --checks=*,-fuchsia-default-arguments,-fuchsia-statically-constructed-objects,-cert-err58-cpp check_patterns = include/*.h src/*.cpp +lib_deps = + Adafruit DRV2605 Library + EspSoftwareSerial + Goldelox-Serial-Arduino-Library + ; Demo build environment that enables demo purposes for the input device. [env:demo] +platform = espressif32 +board = lolin_d32_pro +framework = arduino + build_type = debug -build_flags = -D DEBUG -D DEMO_INPUT_DEVICE +build_flags = -std=c++11 -D DEBUG -D DEMO_INPUT_DEVICE [env:debug] +platform = espressif32 +board = lolin_d32_pro +framework = arduino + build_type = debug -build_flags = -D DEBUG +build_flags = -std=c++11 -g -D DEBUG [env:release] +platform = espressif32 +board = lolin_d32_pro +framework = arduino + build_type = release -build_flags = -D RELEASE +build_flags = -std=c++11 -O3 -D RELEASE + +[env:native] +platform = native +build_flags = -std=c++11 +test_build_project_src = true +test_filter = test_state, test_state_machine +src_filter = + + + + + + + + diff --git a/src/Button.cpp b/src/Button.cpp deleted file mode 100644 index 1b214a6..0000000 --- a/src/Button.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include - -Button::Button(int pin) { - pinMode(pin, INPUT_PULLUP); - - this->input_pin = pin; - this->lastPrintTime = millis(); - this->lastPosition = "NEUTRAL"; -} - -// Returns either "NEUTRAL", "PUSH" or "HOLDING" -// It is advised to treat "HOLDING" the same as "NEUTRAL" outside this function -String Button::read_state() { - String returnString; - if(!digitalRead(this->input_pin)){ - if(this->lastPosition != "PUSH" || (millis() - this->lastPrintTime) > this->holdTime){ - this->lastPrintTime = millis(); - this->lastPosition = "PUSH"; - returnString = "PUSH"; - } - else{ - returnString = "HOLDING"; - } - } - else{ - this->lastPosition = "NEUTRAL"; - returnString = "NEUTRAL"; - } - // To prevent multiple 'up's and 'down's per press due to bouncing - usleep(this->bounceTime); - return returnString; -} \ No newline at end of file diff --git a/src/Joystick.cpp b/src/Joystick.cpp deleted file mode 100644 index 6c7622f..0000000 --- a/src/Joystick.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include - -Joystick::Joystick(int pin_left, int pin_right, int pin_up, int pin_down, int pin_press) { - pinMode(pin_left, INPUT_PULLUP); - pinMode(pin_right, INPUT_PULLUP); - pinMode(pin_up, INPUT_PULLUP); - pinMode(pin_down, INPUT_PULLUP); - pinMode(pin_press, INPUT_PULLUP); - - this->left_pin = pin_left; - this->right_pin = pin_right; - this->up_pin = pin_up; - this->down_pin = pin_down; - this->press_pin = pin_press; - - this->lastPrintTime = millis(); - this->lastPushPrintTime = millis(); - this->lastPosition = "NEUTRAL"; - this->lastPushPosition = "NEUTRAL"; -} - -// Returns either "NEUTRAL", "[DIRECTION]" or "HOLDING" -// It is advised to treat "HOLDING" the same as "NEUTRAL" outside this function -String Joystick::get_position() { - String returnString; - if(!digitalRead(this->left_pin)){ - if(this->lastPosition != "LEFT" || (millis()-this->lastPrintTime) > this->holdTime){ - returnString = "LEFT"; - this->lastPrintTime = millis(); - this->lastPosition = "LEFT"; - } - else{ - returnString = "HOLDING"; - } - }else if(!digitalRead(this->right_pin)){ - if(this->lastPosition != "RIGHT" || (millis()-this->lastPrintTime) > this->holdTime){ - returnString = "RIGHT"; - this->lastPrintTime = millis(); - this->lastPosition = "RIGHT"; - } - else{ - returnString = "HOLDING"; - } - }else if(!digitalRead(this->up_pin)){ - if(this->lastPosition != "UP" || (millis()-this->lastPrintTime) > this->holdTime){ - returnString = "UP"; - this->lastPrintTime = millis(); - this->lastPosition = "UP"; - } - else{ - returnString = "HOLDING"; - } - }else if(!digitalRead(this->down_pin)){ - if(this->lastPosition != "DOWN" || (millis()-this->lastPrintTime) > this->holdTime){ - returnString = "DOWN"; - this->lastPrintTime = millis(); - this->lastPosition = "DOWN"; - } - else{ - returnString = "HOLDING"; - } - }else{ - returnString = "NEUTRAL"; - this->lastPosition = "NEUTRAL"; - } - // To prevent multiple prints per action due to bouncing - usleep(this->bounceTime); - return returnString; -} - -// Returns either "NEUTRAL", "PUSH" or "DOUBLE" -String Joystick::get_press(){ - String returnString; - if(this->recentDoubleClick){ - if(millis() - this->lastDoubleClickTime > this->doubleClickTimeoutTime){ - this->recentDoubleClick = false; // Go back to an mode where we can publish stuff - } - } - if(this->recentInitialClick && !this->recentDoubleClick){ - if(millis() - this->lastPushReleaseTime > this->doubleClickTime && digitalRead(this->press_pin)){ // Enough time has elapsed since last push release time and not pressed - this->lastPush = false; - returnString = "PUSH"; // No second click, so publish the single click - this->recentInitialClick = false; - } - else if(!digitalRead(this->press_pin)){ // Joystick is pressed - this->lastPush = true; - returnString = "DOUBLE"; // A second click, so publish the double click - this->recentInitialClick = false; - this->recentDoubleClick = true; - this->lastDoubleClickTime = millis(); - } - else{ // Joystick not pressed, not just released and recent enough initial click - this->lastPush = false; - returnString = "NEUTRAL"; - } - } - else{ // No recent initial click or a recent double click - if(!digitalRead(this->press_pin)){ // Pressed - this->lastPush = true; - } - else{ // Not pressed - if(this->lastPush){ // Just released - this->recentInitialClick = true; - this->lastPushReleaseTime = millis(); - } - else{ - this->recentInitialClick = false; - } - this->lastPush = false; - } - returnString = "NEUTRAL"; - } - // To prevent multiple prints per action due to bouncing - usleep(this->bounceTime); - return returnString; -} \ No newline at end of file diff --git a/src/Led.cpp b/src/Led.cpp deleted file mode 100644 index 56c00b3..0000000 --- a/src/Led.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -Led::Led(int pin) { - pinMode(pin, OUTPUT); // Specify that pin is a output - output_pin = pin; -} - -void Led::Blink(int led_delay) { - digitalWrite(output_pin, HIGH); // Set 3.3V at output_pin - delay(led_delay); // Wait half the period - digitalWrite(output_pin, LOW); // Pull output_pin to GND - delay(led_delay); // Wait half the period -} \ No newline at end of file diff --git a/src/RockerSwitch.cpp b/src/RockerSwitch.cpp deleted file mode 100644 index 16532aa..0000000 --- a/src/RockerSwitch.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include - -RockerSwitch::RockerSwitch(int upPin, int downPin){ - pinMode(upPin, INPUT_PULLUP); - pinMode(downPin, INPUT_PULLUP); - - this->pinUp = upPin; - this->pinDown = downPin; - this->lastPosition = "NEUTRAL"; - this->lastPrintTime = millis(); -} - -// Returns either "NEUTRAL", "UP", "HOLDING UP", "DOWN" or "HOLDING DOWN" -// It is advised to treat "HOLDING X" the same as "NEUTRAL" outside this function -String RockerSwitch::get_position(){ - String returnString; - if (!digitalRead(this->pinUp)){ - if(this->lastPosition != "UP" || (millis() - this->lastPrintTime) > this->holdTime){ - // reset lastPrintTime - this->lastPrintTime = millis(); - this->lastPosition = "UP"; - returnString = "UP"; - } - else{ - returnString = "HOLDING UP"; - } - } - else if (!digitalRead(this->pinDown)){ - if(this->lastPosition != "DOWN" || (millis() - this->lastPrintTime) > this->holdTime){ - // reset lastPrintTime - this->lastPrintTime = millis(); - this->lastPosition = "DOWN"; - returnString = "DOWN"; - } - else{ - returnString = "HOLDING DOWN"; - } - } - else{ - this->lastPosition = "NEUTRAL"; - returnString = "NEUTRAL"; - } - // To prevent multiple 'up's and 'down's per press due to bouncing - usleep(this->bounceTime); - return returnString; -} \ No newline at end of file diff --git a/src/Screen.cpp b/src/Screen.cpp deleted file mode 100644 index 63abd21..0000000 --- a/src/Screen.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "Screen.h" - -Screen::Screen(Goldelox_Serial_4DLib * screen, SoftwareSerial * screenSerial, int rst, int baud) -{ - this->m_serial = screenSerial; - this->m_screen = screen; - this->m_mediaInitialized = 0; - this->m_baud = baud; - this->m_rst = rst; -} - -void Screen::initialize(){ - - digitalWrite(m_rst, 1); - - m_serial->begin(m_baud); - - this->reset(); - - m_mediaInitialized = m_screen->media_Init(); - usleep(m_waitTimeUs); - - char str[100]; - sprintf(str, "SD Init status = 0x%02X\n", m_mediaInitialized); - m_screen->print(str); - usleep(m_waitTimeUs); - - this->clear(); - - this->m_lastDrawTime = millis(); -}; - -void Screen::clear(){ - m_screen->gfx_Cls(); - usleep(m_waitTimeUs); -} - -void Screen::reset(){ - digitalWrite(m_rst, 0); - usleep(m_waitTimeUs); - - digitalWrite(m_rst, 1); - sleep(3); -}; - -void Screen::draw_image(int addr_hi, int addr_lo){ - if((millis() - m_lastDrawTime)*1000 > m_waitTimeUs){ - m_screen->media_SetSector(addr_hi, addr_lo); - m_screen->media_Image(0,0); - this->m_lastDrawTime = millis(); - } -} diff --git a/src/StateMachine.cpp b/src/StateMachine.cpp deleted file mode 100644 index c4edd04..0000000 --- a/src/StateMachine.cpp +++ /dev/null @@ -1,1762 +0,0 @@ -#include - -// Constructor -StateMachine::StateMachine() -{ - this->currentState = State::HomeSitStart; - this->rememberStateObstacle = State::Sofa; - this->rememberStateObstacleWIB = State::TiltedPath; - stateToGaitMapping[State::HomeSitStartActivated] = "home_sit"; - stateToGaitMapping[State::StandUpActivated] = "gait_stand"; - stateToGaitMapping[State::HomeStandStartActivated] = "home_stand"; - - stateToGaitMapping[State::WalkNormalActivated] = "gait_walk"; - stateToGaitMapping[State::WalkSmallActivated] = "gait_walk_small"; - stateToGaitMapping[State::SingleStepNormalActivated] = "gait_single_step_normal"; - stateToGaitMapping[State::SingleStepSmallActivated] = "gait_single_step_small"; - - stateToGaitMapping[State::SitActivated] = "gait_sit"; - stateToGaitMapping[State::HomeSitActivated] = "home_sit"; - stateToGaitMapping[State::HomeStandActivated] = "home_stand"; - - stateToGaitMapping[State::WalkObstacleNormalActivated] = "gait_walk"; - stateToGaitMapping[State::WalkObstacleSmallActivated] = "gait_walk_small"; - stateToGaitMapping[State::SingleStepObstacleNormalActivated] = "gait_single_step_normal"; - stateToGaitMapping[State::SingleStepObstacleSmallActivated] = "gait_single_step_small"; - - stateToGaitMapping[State::SofaSitActivated] = "gait_sofa_sit"; - stateToGaitMapping[State::SofaStandUpActivated] = "gait_sofa_stand"; - - stateToGaitMapping[State::StairsUpActivated] = "gait_stairs_up"; - stateToGaitMapping[State::StairsDownActivated] = "gait_stairs_down"; - - stateToGaitMapping[State::SideStepLeftNormalActivated] = "gait_side_step_left"; - stateToGaitMapping[State::SideStepRightNormalActivated] = "gait_side_step_right"; - stateToGaitMapping[State::SideStepLeftSmallActivated] = "gait_side_step_left_small"; - stateToGaitMapping[State::SideStepRightSmallActivated] = "gait_side_step_right_small"; - - stateToGaitMapping[State::TiltedPathStartHomeToMin5Activated] = "gait_set_ankle_from_2_5_to_min5"; - stateToGaitMapping[State::FirstStartStepActivated] = "gait_tilted_path_first_starting_step"; - stateToGaitMapping[State::SecondStartStepActivated] = "gait_tilted_path_second_starting_step"; - stateToGaitMapping[State::HomeStandToMin10Activated] = "gait_set_ankle_from_min5_to_min10"; - stateToGaitMapping[State::TiltedPathMiddleStepActivated] = "gait_tilted_path_middle_step"; - stateToGaitMapping[State::HomeStandToMin5Activated] = "gait_set_ankle_from_min10_to_min5"; - stateToGaitMapping[State::FirstEndStepActivated] = "gait_tilted_path_first_ending_step"; - stateToGaitMapping[State::SecondEndStepActivated] = "gait_tilted_path_second_ending_step"; - stateToGaitMapping[State::HomeForWalk25Activated] = "gait_set_ankle_from_min5_to_2_5"; -} - -State StateMachine::getCurrentState(){ - return this->currentState; -} - -std::string StateMachine::getGaitNameOfState(State state){ - if(stateToGaitMapping.count(state) > 0){ - return stateToGaitMapping[state]; - } - return ""; -} - -// Updates the current state based on the button inputs -void StateMachine::updateState(String joystickState, String joystickPress, String rockerState, String triggerPress){ - switch (this->currentState) - { - //Start menu - //Scroll - case State::HomeSitStart: - if(joystickState == "RIGHT"){ - this->currentState = State::StandUp; - } - else if(joystickState == "LEFT"){ - this->currentState = State::TurnOffStart; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::HomeSitStartSelected; - } - break; - case State::StandUp: - if(joystickState == "RIGHT"){ - this->currentState = State::HomeStandStart; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeSitStart; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::StandUpSelected; - } - break; - case State::HomeStandStart: - if(joystickState == "RIGHT"){ - this->currentState = State::TurnOffStart; - } - else if(joystickState == "LEFT"){ - this->currentState = State::StandUp; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::HomeStandStartSelected; - } - break; - case State::TurnOffStart: - if(joystickState =="RIGHT"){ - this->currentState = State::HomeSitStart; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeStandStart; - } - break; - - //Selected - case State::HomeSitStartSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::HomeSitStartActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::HomeSitStart; - } - break; - case State::StandUpSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::StandUpActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::StandUp; - } - break; - case State::HomeStandStartSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::HomeStandStartActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::HomeStandStart; - } - break; - - - //Activated - case State::HomeSitStartActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::StandUp; //Automatically - } - break; - case State::StandUpActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::Walk; //Automatically - } - break; - case State::HomeStandStartActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::Walk; //Automatically - } - break; - - - //Sit menu - //Scroll - case State::Sit: - if(joystickState == "RIGHT"){ - this->currentState = State::HomeSit; - } - else if(joystickState == "LEFT"){ - this->currentState = State::TurnOff; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SitSelected; - } - else if(joystickState == "UP"){ - this->currentState = State::Walk; - - } - break; - - case State::HomeSit: - if(joystickState == "RIGHT"){ - this->currentState = State::HomeStand; - } - else if(joystickState == "LEFT"){ - this->currentState = State::Sit; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::HomeSitSelected; - } - else if(joystickState == "UP"){ - this->currentState = State::Walk; - } - break; - - case State::HomeStand: - if(joystickState == "RIGHT"){ - this->currentState = State::TurnOff; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeSit; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::HomeStandSelected; - } - else if(joystickState == "UP"){ - this->currentState = State::Walk; - } - break; - case State::TurnOff: - if(joystickState == "RIGHT"){ - this->currentState = State::Sit; - } - else if(joystickState =="LEFT"){ - this->currentState = State::HomeStand; - } - else if(joystickState == "UP"){ - this->currentState = State::Walk; - } - break; - - //Selected - case State::SitSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SitActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Sit; - } - break; - case State::HomeSitSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::HomeSitActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::HomeSit; - } - break; - - case State::HomeStandSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::HomeStandActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::HomeStand; - } - break; - - - //Activated - case State::SitActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::StandUp; //Automatically - } - break; - case State::HomeSitActivated: - if(triggerPress = "EXIT_GAIT"){ - this->currentState = State::StandUp; //Automatically - } - break; - case State::HomeStandActivated: - if(triggerPress = "EXIT_GAIT"){ - this->currentState = State::Walk; //Automatically - } - break; - - - //WIB menu - //Scroll - case State::Walk: - if(joystickState == "RIGHT"){ - this->currentState = State::SingleStep; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SideStep; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::WalkNormal; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SingleStep: - if(joystickState == "RIGHT"){ - this->currentState = State::SideStep; - } - else if(joystickState == "LEFT"){ - this->currentState = State::Walk; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepNormal; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SideStep: - if(joystickState == "RIGHT"){ - this->currentState = State::Walk; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SingleStep; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepLeft; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - - //Choose step size - case State::WalkNormal: - if(rockerState == "DOWN"){ - this->currentState = State::WalkSmall; - } - else if(rockerState =="UP"){ - this->currentState = State::WalkLarge; - } - else if(joystickState =="RIGHT"){ - this->currentState = State::WalkLarge; - } - else if(joystickState =="LEFT"){ - this->currentState = State::WalkSmall; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::WalkNormalSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Walk; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::WalkSmall: - if(rockerState =="UP"){ - this->currentState = State::WalkNormal; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::WalkNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::WalkSmallSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Walk; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::WalkLarge: - if(rockerState =="DOWN"){ - this->currentState = State::WalkNormal; - } - else if (joystickState == "LEFT"){ - this->currentState = State::WalkNormal; - } - // else if(joystickPress == "PUSH"){ - // this->currentState = State::WalkLargeSelected; - // } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Walk; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SingleStepNormal: - if(rockerState == "DOWN"){ - this->currentState = State::SingleStepSmall; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SingleStepSmall; - } - else if(rockerState =="UP"){ - this->currentState = State::SingleStepLarge; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SingleStepLarge; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepNormalSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStep; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SingleStepSmall: - if(rockerState =="UP"){ - this->currentState = State::SingleStepNormal; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SingleStepNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepSmallSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStep; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SingleStepLarge: - if(rockerState =="DOWN"){ - this->currentState = State::SingleStepNormal; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SingleStepNormal; - } - // else if(joystickPress == "PUSH"){ - // this->currentState = State::SingleStepLargeSelected; - // } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStep; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - case State::SideStepLeft: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepRight; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepRight; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepLeftNormal; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStep; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - - case State::SideStepRight: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepLeft; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepLeft; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepRightNormal; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStep; - } - else if(joystickState =="UP"){ - this->currentState = rememberStateObstacle; - } - else if(joystickState == "DOWN"){ - this->currentState = State::Sit; - } - break; - - case State::SideStepLeftNormal: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepLeftSmall; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepLeftSmall; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepLeftNormalSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepLeft; - } - break; - - case State::SideStepLeftSmall: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepLeftNormal; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepLeftNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepLeftSmallSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepLeft; - } - break; - - case State::SideStepRightNormal: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepRightSmall; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepRightSmall; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepRightNormalSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepRight; - } - break; - - case State::SideStepRightSmall: - if (joystickState == "LEFT"){ - this->currentState = State::SideStepRightNormal; - } - else if (joystickState == "RIGHT"){ - this->currentState = State::SideStepRightNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SideStepRightSmallSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepRight; - } - break; - - - - //Selected - case State::WalkSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::WalkSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkSmall; - } - break; - case State::WalkNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::WalkNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkNormal; - } - break; - // case State::WalkLargeSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::WalkLargeActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::WalkLarge; - // } - // break; - case State::SingleStepSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SingleStepSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStepSmall; - } - break; - case State::SingleStepNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SingleStepNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStepNormal; - } - break; - // case State::SingleStepLargeSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::SingleStepLargeActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::SingleStepLarge; - // } - // break; - case State::SideStepLeftNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SideStepLeftNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepLeftNormal; - } - break; - - case State::SideStepLeftSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SideStepLeftSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepLeftSmall; - } - break; - - case State::SideStepRightNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SideStepRightNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepRightNormal; - } - break; - - case State::SideStepRightSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SideStepRightSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SideStepRightSmall; - } - break; - - - //Activated - case State::WalkSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::Walk; //Automatically - } - break; - case State::WalkNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::Walk; //Automatically - } - break; - // case State::WalkLargeActivated: - // if(triggerPress == "EXIT_GAIT"){ - // this->currentState = State::Walk; //Automatically - // } - // break; - case State::SingleStepSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SingleStep; //Automatically - } - break; - case State::SingleStepNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SingleStep; //Automatically - } - break; - // case State::SingleStepLargeActivated: - // if(triggerPress == "EXIT_GAIT"){ - // this->currentState = State::SingleStep; //Automatically - // } - // break; - case State::SideStepLeftNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SideStep; //Automatically - } - break; - case State::SideStepLeftSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SideStep; //Automatically - } - break; - case State::SideStepRightSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SideStep; //Automatically - } - break; - case State::SideStepRightNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SideStep; //Automatically - } - break; - - //Obstacle menu - //Scroll - case State::Sofa: - if(joystickState == "RIGHT"){ - this->currentState = State::Stairs; - } - else if(joystickState == "LEFT"){ - this->currentState = State::TiltedPath; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SofaSit; - } - else if(joystickState =="DOWN"){ - this->rememberStateObstacle = currentState; - this->currentState = State::Walk; - } - break; - - case State::Stairs: - if(joystickState == "RIGHT"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::Sofa; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::StairsUp; - } - else if(joystickState =="DOWN"){ - this->rememberStateObstacle = currentState; - this->currentState = State::Walk; - } - break; - - case State::TiltedPath: - if(joystickState == "RIGHT"){ - this->currentState = State::Sofa; - } - else if(joystickState == "LEFT"){ - this->currentState = State::Stairs; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::TiltedPathStartHomeToMin5; - } - else if(joystickState =="DOWN"){ - this->rememberStateObstacle = currentState; - this->currentState = State::Walk; - } - break; - - - //Submenu obstacles - //Sofa - case State::SofaSit: - if(joystickPress == "PUSH"){ - this->currentState = State::SofaSitSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Sofa; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SofaStandUp; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SofaStandUp; - } - break; - - case State::SofaStandUp: - if(triggerPress == "PUSH"){ - this->currentState = State::SofaStandUpActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Sofa; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SofaSit; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SofaSit; - } - break; - - case State::SofaSitSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SofaSitActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SofaSit; - } - break; - - case State::SofaSitActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SofaStandUp; //Automatically - } - break; - - // case State::SofaStandUpSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::SofaStandUpActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::SofaStandUp; - // } - // break; - - case State::SofaStandUpActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::WalkObstacle; //Automatically - this->rememberStateObstacleWIB = State::Stairs; - } - break; - - - - - //Stairs - case State::StairsUp: - if(joystickPress == "PUSH"){ - this->currentState = State::StairsUpSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Stairs; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::StairsDown; - } - else if(joystickState == "LEFT"){ - this->currentState = State::StairsDown; // old: this->currentState = State::StairsDownFinal; - } - break; - - case State::StairsDown: - if(joystickPress == "PUSH"){ - this->currentState = State::StairsDownSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::Stairs; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::StairsUp; // old: this->currentState = State::StairsDownFinal; - } - else if(joystickState == "LEFT"){ - this->currentState = State::StairsUp; - } - break; - - case State::StairsUpSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::StairsUpActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::StairsUp; - } - break; - - case State::StairsUpActivated: - if(triggerPress == "EXIT_GAIT"){ - this->rememberStateObstacleWIB = State::StairsDown; - this->currentState = State::WalkObstacle; //Automatically - } - break; - case State::StairsDownSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::StairsDownActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::StairsDown; - } - break; - - case State::StairsDownActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::WalkObstacle; //Automatically - this->rememberStateObstacleWIB = State::TiltedPath; - } - break; - // case State::StairsDownFinalSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::StairsDownFinalActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::StairsDownFinal; - // } - // break; - // case State::StairsDownFinalActivated: - // if(triggerPress == "EXIT_GAIT"){ - // this->rememberStateObstacleWIB = State::TiltedPath; - // this->currentState = State::WalkObstacle; //Automatically - // } - // break; - - - - // case State::StairsDownFinal: - // if(joystickPress == "PUSH"){ - // this->currentState = State::StairsDownFinalSelected; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::Stairs; - // } - // else if(joystickState == "RIGHT"){ - // this->currentState = State::StairsUp; - // } - // else if(joystickState == "LEFT"){ - // this->currentState = State::StairsDown; - // } - // break; - - //Selected and activated submenus - - //Tilted Path - case State::TiltedPathStartHomeToMin5: // first home ankles to -5 before going on the tilted path - if(joystickPress == "PUSH"){ - this->currentState = State::TiltedPathStartHomeToMin5Selected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeForWalk25; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::FirstStartStep; - } - break; - - case State::TiltedPathStartHomeToMin5Selected: // we want the first gait to be selected & activated, to others only need to be triggered - if(triggerPress == "PUSH"){ - this->currentState = State::TiltedPathStartHomeToMin5Activated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPathStartHomeToMin5; - } - break; - - case State::TiltedPathStartHomeToMin5Activated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::FirstStartStep; //Automatically - } - break; - - - case State::FirstStartStep: // first step on the tilted path - if(triggerPress == "PUSH"){ - this->currentState = State::FirstStartStepActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::TiltedPathStartHomeToMin5; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SecondStartStep; - } - break; - - case State::FirstStartStepActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SecondStartStep; //Automatically - } - break; - - - - case State::SecondStartStep: // second step on tilted path, after this gait we will stand on the middle part - if(triggerPress == "PUSH"){ - this->currentState = State::SecondStartStepActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::FirstStartStep; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::HomeStandToMin10; - } - break; - - case State::SecondStartStepActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::HomeStandToMin10; //Automatically - } - break; - - - case State::HomeStandToMin10: // before doing side steps on the middle part we have to home to an ankle position -10 - if(triggerPress == "PUSH"){ - this->currentState = State::HomeStandToMin10Activated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SecondStartStep; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::TiltedPathMiddleStep; - } - break; - - case State::HomeStandToMin10Activated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::TiltedPathMiddleStep; //Automatically - } - break; - - - case State::TiltedPathMiddleStep: // after activating a side step for the middle part you can do this action again, when you are at the end you have to push the joystick to the right. - if(triggerPress == "PUSH"){ - this->currentState = State::TiltedPathMiddleStepActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeStandToMin10; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::HomeStandToMin5; - } - break; - - case State::TiltedPathMiddleStepActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::TiltedPathMiddleStep; //Automatically - } - break; - - case State::HomeStandToMin5: // before going off the tilted path we have to home ankles to -5 - if(triggerPress == "PUSH"){ - this->currentState = State::HomeStandToMin5Activated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::TiltedPathMiddleStep; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::FirstEndStep; - } - break; - - case State::HomeStandToMin5Activated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::FirstEndStep; //Automatically - } - break; - - case State::FirstEndStep: // first step for the end of the tilted path - if(triggerPress == "PUSH"){ - this->currentState = State::FirstEndStepActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::HomeStandToMin5; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SecondEndStep; - } - break; - - case State::FirstEndStepActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SecondEndStep; //Automatically - } - break; - - case State::SecondEndStep: // second step for the end of the tilted path - if(triggerPress == "PUSH"){ - this->currentState = State::SecondEndStepActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::FirstEndStep; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::HomeForWalk25; - } - break; - - case State::SecondEndStepActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::HomeForWalk25; //Automatically - } - break; - - case State::HomeForWalk25: // We are now finished with the tilted path, but before we can walk we have to set ankles back to 2.5 for walking -> home. - if(triggerPress == "PUSH"){ - this->currentState = State::HomeForWalk25Activated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::TiltedPath; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SecondEndStep; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::TiltedPathStartHomeToMin5; - } - break; - - case State::HomeForWalk25Activated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::WalkObstacle; //Automatically - this->rememberStateObstacleWIB = State::Sofa; - } - break; - - - //Walk in between obstacles - case State::WalkObstacle: - if(joystickPress == "PUSH"){ - this->currentState = State::WalkObstacleNormal; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SingleStepObstacle; - } - break; - case State::SingleStepObstacle: - if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepObstacleNormal; - } - else if(joystickState == "RIGHT"){ - this->currentState = rememberStateObstacleWIB; - } - else if(joystickState == "LEFT"){ - this->currentState = State::WalkObstacle; - } - break; - - //Choose step size - case State::WalkObstacleNormal: - if(rockerState == "DOWN"){ - this->currentState = State::WalkObstacleSmall; - } - else if(joystickState == "LEFT"){ - this->currentState = State::WalkObstacleSmall; - } - else if(rockerState =="UP"){ - this->currentState = State::WalkObstacleLarge; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::WalkObstacleLarge; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::WalkObstacleNormalSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkObstacle; - } - break; - case State::WalkObstacleSmall: - if(rockerState =="UP"){ - this->currentState = State::WalkObstacleNormal; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::WalkObstacleNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::WalkObstacleSmallSelected; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkObstacle; - } - break; - case State::WalkObstacleLarge: - if(rockerState =="DOWN"){ - this->currentState = State::WalkObstacleNormal; - } - else if(joystickState == "LEFT"){ - this->currentState = State::WalkObstacleNormal; - } - // else if(joystickPress == "PUSH"){ - // this->currentState = State::WalkObstacleLargeSelected; - // } - else if(joystickState == "DOUBLE"){ - this->currentState = State::WalkObstacle; - } - break; - case State::SingleStepObstacleNormal: - if(rockerState == "DOWN"){ - this->currentState = State::SingleStepObstacleSmall; - } - else if(rockerState =="UP"){ - this->currentState = State::SingleStepObstacleLarge; - } - else if(joystickState == "LEFT"){ - this->currentState = State::SingleStepObstacleSmall; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SingleStepObstacleLarge; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepObstacleNormalSelected; - } - else if(joystickState == "DOUBLE"){ - this->currentState = State::SingleStepObstacle; - } - break; - case State::SingleStepObstacleSmall: - if(rockerState =="UP"){ - this->currentState = State::SingleStepObstacleNormal; - } - else if(joystickState == "RIGHT"){ - this->currentState = State::SingleStepObstacleNormal; - } - else if(joystickPress == "PUSH"){ - this->currentState = State::SingleStepObstacleSmallSelected; - } - else if(joystickState == "DOUBLE"){ - this->currentState = State::SingleStepObstacle; - } - break; - case State::SingleStepObstacleLarge: - if(rockerState =="DOWN"){ - this->currentState = State::SingleStepObstacleNormal; - } - else if (joystickState == "LEFT"){ - this->currentState = State::SingleStepObstacleNormal; - } - // else if(joystickPress == "PUSH"){ - // this->currentState = State::SingleStepObstacleLargeSelected; - // } - else if(joystickState == "DOUBLE"){ - this->currentState = State::SingleStepObstacle; - } - break; - - - //Selected - case State::WalkObstacleSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::WalkObstacleSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkObstacleSmall; - } - break; - case State::WalkObstacleNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::WalkObstacleNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::WalkObstacleNormal; - } - break; - // case State::WalkObstacleLargeSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::WalkObstacleLargeActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::WalkObstacleLarge; - // } - // break; - case State::SingleStepObstacleSmallSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SingleStepObstacleSmallActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStepObstacleSmall; - } - break; - case State::SingleStepObstacleNormalSelected: - if(triggerPress == "PUSH"){ - this->currentState = State::SingleStepObstacleNormalActivated; - } - else if(joystickPress == "DOUBLE"){ - this->currentState = State::SingleStepObstacleNormal; - } - break; - // case State::SingleStepObstacleLargeSelected: - // if(triggerPress == "PUSH"){ - // this->currentState = State::SingleStepObstacleLargeActivated; - // } - // else if(joystickPress == "DOUBLE"){ - // this->currentState = State::SingleStepObstacleLarge; - // } - // break; - - //Activated - case State::WalkObstacleSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SingleStepObstacle; //Automatically - } - break; - case State::WalkObstacleNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = State::SingleStepObstacle; //Automatically - } - break; - // case State::WalkObstacleLargeActivated: - // if(triggerPress == "EXIT_GAIT"){ - // this->currentState = State::SingleStepObstacle; //Automatically - // } - // break; - case State::SingleStepObstacleSmallActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = rememberStateObstacleWIB; //Automatically - } - break; - case State::SingleStepObstacleNormalActivated: - if(triggerPress == "EXIT_GAIT"){ - this->currentState = rememberStateObstacleWIB; //Automatically - } - break; - // case State::SingleStepObstacleLargeActivated: - // if(triggerPress == "EXIT_GAIT"){ - // this->currentState = rememberStateObstacleWIB; //Automatically - // } - // break; - - default: - break; - } -} - - -// Return the SD addresses of the image that should be drawn in the current state -int * StateMachine::getScreenImage(){ - static int currentSdAddresses[2] = {0, 0}; - switch (this->currentState) - { - //Start menu - case State::HomeSitStart: - currentSdAddresses[0] = HomeSitStart_Hi; - currentSdAddresses[1] = HomeSitStart_Lo; - break; - case State::HomeSitStartSelected: - currentSdAddresses[0] = HomeSitStartSelected_Hi; - currentSdAddresses[1] = HomeSitStartSelected_Lo; - break; - case State::HomeSitStartActivated: - currentSdAddresses[0] = HomeSitStartActivated_Hi; - currentSdAddresses[1] = HomeSitStartActivated_Lo; - break; - case State::StandUp: - currentSdAddresses[0] = StandUp_Hi; - currentSdAddresses[1] = StandUp_Lo; - break; - case State::StandUpSelected: - currentSdAddresses[0] = StandUpSelected_Hi; - currentSdAddresses[1] = StandUpSelected_Lo; - break; - case State::StandUpActivated: - currentSdAddresses[0] = StandUpActivated_Hi; - currentSdAddresses[1] = StandUpActivated_Lo; - break; - case State::HomeStandStart: - currentSdAddresses[0] = HomeStandStart_Hi; - currentSdAddresses[1] = HomeStandStart_Lo; - break; - case State::HomeStandStartSelected: - currentSdAddresses[0] = HomeStandStartSelected_Hi; - currentSdAddresses[1] = HomeStandStartSelected_Lo; - break; - case State::HomeStandStartActivated: - currentSdAddresses[0] = HomeStandStartActivated_Hi; - currentSdAddresses[1] = HomeStandStartActivated_Lo; - break; - case State::TurnOffStart: - currentSdAddresses[0] = TurnOffStart_Hi; - currentSdAddresses[1] = TurnOffStart_Lo; - break; - - - - //Sit menu - case State::Sit: - currentSdAddresses[0] = Sit_Hi; - currentSdAddresses[1] = Sit_Lo; - break; - case State::SitSelected: - currentSdAddresses[0] = SitSelected_Hi; - currentSdAddresses[1] = SitSelected_Lo; - break; - case State::SitActivated: - currentSdAddresses[0] = SitActivated_Hi; - currentSdAddresses[1] = SitActivated_Lo; - break; - case State::HomeSit: - currentSdAddresses[0] = HomeSit_Hi; - currentSdAddresses[1] = HomeSit_Lo; - break; - case State::HomeSitSelected: - currentSdAddresses[0] = HomeSitSelected_Hi; - currentSdAddresses[1] = HomeSitSelected_Lo; - break; - case State::HomeSitActivated: - currentSdAddresses[0] = HomeSitActivated_Hi; - currentSdAddresses[1] = HomeSitActivated_Lo; - break; - case State::HomeStand: - currentSdAddresses[0] = HomeStand_Hi; - currentSdAddresses[1] = HomeStand_Lo; - break; - case State::HomeStandSelected: - currentSdAddresses[0] = HomeStandSelected_Hi; - currentSdAddresses[1] = HomeStandSelected_Lo; - break; - case State::HomeStandActivated: - currentSdAddresses[0] = HomeStandActivated_Hi; - currentSdAddresses[1] = HomeStandActivated_Lo; - break; - case State::TurnOff: - currentSdAddresses[0] = TurnOff_Hi; - currentSdAddresses[1] = TurnOff_Lo; - break; - - - //Obstacle menu - case State::Sofa: - currentSdAddresses[0] = Sofa_Hi; - currentSdAddresses[1] = Sofa_Lo; - break; - case State::SofaSit: - currentSdAddresses[0] = SofaSit_Hi; - currentSdAddresses[1] = SofaSit_Lo; - break; - case State::SofaSitSelected: - currentSdAddresses[0] = SofaSitSelected_Hi; - currentSdAddresses[1] = SofaSitSelected_Lo; - break; - case State::SofaSitActivated: - currentSdAddresses[0] = SofaSitActivated_Hi; - currentSdAddresses[1] = SofaSitActivated_Lo; - break; - case State::SofaStandUp: - currentSdAddresses[0] = SofaStandUp_Hi; - currentSdAddresses[1] = SofaStandUp_Lo; - break; - case State::SofaStandUpSelected: - currentSdAddresses[0] = SofaStandUpSelected_Hi; - currentSdAddresses[1] = SofaStandUpSelected_Lo; - break; - case State::SofaStandUpActivated: - currentSdAddresses[0] = SofaStandUpActivated_Hi; - currentSdAddresses[1] = SofaStandUpActivated_Lo; - break; - - - case State::TiltedPath: - currentSdAddresses[0] = TiltedPath_Hi; - currentSdAddresses[1] = TiltedPath_Lo; - break; - case State::TiltedPathStartHomeToMin5: - currentSdAddresses[0] = TiltedPathStartHomeToMin5_Hi; - currentSdAddresses[1] = TiltedPathStartHomeToMin5_Lo; - break; - case State::TiltedPathStartHomeToMin5Selected: - currentSdAddresses[0] = TiltedPathStartHomeToMin5Selected_Hi; - currentSdAddresses[1] = TiltedPathStartHomeToMin5Selected_Lo; - break; - case State::TiltedPathStartHomeToMin5Activated: - currentSdAddresses[0] = TiltedPathStartHomeToMin5Activated_Hi; - currentSdAddresses[1] = TiltedPathStartHomeToMin5Activated_Lo; - break; - case State::FirstStartStep: - currentSdAddresses[0] = FirstStartStep_Hi; - currentSdAddresses[1] = FirstStartStep_Lo; - break; - case State::FirstStartStepActivated: - currentSdAddresses[0] = FirstStartStepActivated_Hi; - currentSdAddresses[1] = FirstStartStepActivated_Lo; - break; - case State::SecondStartStep: - currentSdAddresses[0] = SecondStartStep_Hi; - currentSdAddresses[1] = SecondStartStep_Lo; - break; - case State::SecondStartStepActivated: - currentSdAddresses[0] = SecondStartStepActivated_Hi; - currentSdAddresses[1] = SecondStartStepActivated_Lo; - break; - case State::HomeStandToMin10: - currentSdAddresses[0] = HomeStandToMin10_Hi; - currentSdAddresses[1] = HomeStandToMin10_Lo; - break; - case State::HomeStandToMin10Activated: - currentSdAddresses[0] = HomeStandToMin10Activated_Hi; - currentSdAddresses[1] = HomeStandToMin10Activated_Lo; - break; - case State::TiltedPathMiddleStep: - currentSdAddresses[0] = TiltedPathMiddleStep_Hi; - currentSdAddresses[1] = TiltedPathMiddleStep_Lo; - break; - case State::TiltedPathMiddleStepActivated: - currentSdAddresses[0] = TiltedPathMiddleStepActivated_Hi; - currentSdAddresses[1] = TiltedPathMiddleStepActivated_Lo; - break; - case State::HomeStandToMin5: - currentSdAddresses[0] = HomeStandToMin5_Hi; - currentSdAddresses[1] = HomeStandToMin5_Lo; - break; - case State::HomeStandToMin5Activated: - currentSdAddresses[0] = HomeStandToMin5Activated_Hi; - currentSdAddresses[1] = HomeStandToMin5Activated_Lo; - break; - case State::FirstEndStep: - currentSdAddresses[0] = FirstEndStep_Hi; - currentSdAddresses[1] = FirstEndStep_Lo; - break; - case State::FirstEndStepActivated: - currentSdAddresses[0] = FirstEndStepActivated_Hi; - currentSdAddresses[1] = FirstEndStepActivated_Lo; - break; - case State::SecondEndStep: - currentSdAddresses[0] = SecondEndStep_Hi; - currentSdAddresses[1] = SecondEndStep_Lo; - break; - case State::SecondEndStepActivated: - currentSdAddresses[0] = SecondEndStepActivated_Hi; - currentSdAddresses[1] = SecondEndStepActivated_Lo; - break; - case State::HomeForWalk25: - currentSdAddresses[0] = HomeForWalk25_Hi; - currentSdAddresses[1] = HomeForWalk25_Lo; - break; - case State::HomeForWalk25Activated: - currentSdAddresses[0] = HomeForWalk25Activated_Hi; - currentSdAddresses[1] = HomeForWalk25Activated_Lo; - break; - - case State::Stairs: - currentSdAddresses[0] = Stairs_Hi; - currentSdAddresses[1] = Stairs_Lo; - break; - case State::StairsUp: - currentSdAddresses[0] = StairsUp_Hi; - currentSdAddresses[1] = StairsUp_Lo; - break; - case State::StairsUpSelected: - currentSdAddresses[0] = StairsUpSelected_Hi; - currentSdAddresses[1] = StairsUpSelected_Lo; - break; - case State::StairsUpActivated: - currentSdAddresses[0] = StairsUpActivated_Hi; - currentSdAddresses[1] = StairsUpActivated_Lo; - break; - case State::StairsDown: - currentSdAddresses[0] = StairsDown_Hi; - currentSdAddresses[1] = StairsDown_Lo; - break; - case State::StairsDownSelected: - currentSdAddresses[0] = StairsDownSelected_Hi; - currentSdAddresses[1] = StairsDownSelected_Lo; - break; - case State::StairsDownActivated: - currentSdAddresses[0] = StairsDownActivated_Hi; - currentSdAddresses[1] = StairsDownActivated_Lo; - break; - // case State::StairsDownFinal: - // currentSdAddresses[0] = StairsDownFinal_Hi; - // currentSdAddresses[1] = StairsDownFinal_Lo; - // break; - // case State::StairsDownFinalSelected: - // currentSdAddresses[0] = StairsDownFinalSelected_Hi; - // currentSdAddresses[1] = StairsDownFinalSelected_Lo; - // break; - // case State::StairsDownFinalActivated: - // currentSdAddresses[0] = StairsDownFinalActivated_Hi; - // currentSdAddresses[1] = StairsDownFinalActivated_Lo; - // break; - - - -//WIB - case State::WalkObstacle: - currentSdAddresses[0] = WalkObstacle_Hi; - currentSdAddresses[1] = WalkObstacle_Lo; - break; - case State::WalkObstacleSmall: - currentSdAddresses[0] = WalkObstacleSmall_Hi; - currentSdAddresses[1] = WalkObstacleSmall_Lo; - break; - case State::WalkObstacleNormal: - currentSdAddresses[0] = WalkObstacleNormal_Hi; - currentSdAddresses[1] = WalkObstacleNormal_Lo; - break; - case State::WalkObstacleLarge: - currentSdAddresses[0] = WalkObstacleLarge_Hi; - currentSdAddresses[1] = WalkObstacleLarge_Lo; - break; - case State::WalkObstacleNormalSelected: - currentSdAddresses[0] = WalkObstacleNormalSelected_Hi; - currentSdAddresses[1] = WalkObstacleNormalSelected_Lo; - break; - case State::WalkObstacleSmallSelected: - currentSdAddresses[0] = WalkObstacleSmallSelected_Hi; - currentSdAddresses[1] = WalkObstacleSmallSelected_Lo; - break; - case State::WalkObstacleNormalActivated: - currentSdAddresses[0] = WalkObstacleNormalActivated_Hi; - currentSdAddresses[1] = WalkObstacleNormalActivated_Lo; - break; - case State::WalkObstacleSmallActivated: - currentSdAddresses[0] = WalkObstacleSmallActivated_Hi; - currentSdAddresses[1] = WalkObstacleSmallActivated_Lo; - break; - - case State::SingleStepObstacle: - currentSdAddresses[0] = SingleStepObstacle_Hi; - currentSdAddresses[1] = SingleStepObstacle_Lo; - break; - case State::SingleStepObstacleNormal: - currentSdAddresses[0] = SingleStepObstacleNormal_Hi; - currentSdAddresses[1] = SingleStepObstacleNormal_Lo; - break; - case State::SingleStepObstacleSmall: - currentSdAddresses[0] = SingleStepObstacleSmall_Hi; - currentSdAddresses[1] = SingleStepObstacleSmall_Lo; - break; - case State::SingleStepObstacleLarge: - currentSdAddresses[0] = SingleStepObstacleLarge_Hi; - currentSdAddresses[1] = SingleStepObstacleLarge_Lo; - break; - case State::SingleStepObstacleNormalSelected: - currentSdAddresses[0] = SingleStepObstacleNormalSelected_Hi; - currentSdAddresses[1] = SingleStepObstacleNormalSelected_Lo; - break; - case State::SingleStepObstacleSmallSelected: - currentSdAddresses[0] = SingleStepObstacleSmallSelected_Hi; - currentSdAddresses[1] = SingleStepObstacleSmallSelected_Lo; - break; - case State::SingleStepObstacleNormalActivated: - currentSdAddresses[0] = SingleStepObstacleNormalActivated_Hi; - currentSdAddresses[1] = SingleStepObstacleNormalActivated_Lo; - break; - case State::SingleStepObstacleSmallActivated: - currentSdAddresses[0] = SingleStepObstacleSmallActivated_Hi; - currentSdAddresses[1] = SingleStepObstacleSmallActivated_Lo; - break; - - - //Walk Menu - case State::Walk: - currentSdAddresses[0] = Walk_Hi; - currentSdAddresses[1] = Walk_Lo; - break; - case State::WalkSmall: - currentSdAddresses[0] = WalkSmall_Hi; - currentSdAddresses[1] = WalkSmall_Lo; - break; - case State::WalkNormal: - currentSdAddresses[0] = WalkNormal_Hi; - currentSdAddresses[1] = WalkNormal_Lo; - break; - case State::WalkLarge: - currentSdAddresses[0] = WalkLarge_Hi; - currentSdAddresses[1] = WalkLarge_Lo; - break; - case State::WalkNormalSelected: - currentSdAddresses[0] = WalkNormalSelected_Hi; - currentSdAddresses[1] = WalkNormalSelected_Lo; - break; - case State::WalkNormalActivated: - currentSdAddresses[0] = WalkNormalActivated_Hi; - currentSdAddresses[1] = WalkNormalActivated_Lo; - break; - case State::WalkSmallSelected: - currentSdAddresses[0] = WalkSmallSelected_Hi; - currentSdAddresses[1] = WalkSmallSelected_Lo; - break; - case State::WalkSmallActivated: - currentSdAddresses[0] = WalkSmallActivated_Hi; - currentSdAddresses[1] = WalkSmallActivated_Lo; - break; - - case State::SingleStep: - currentSdAddresses[0] = SingleStep_Hi; - currentSdAddresses[1] = SingleStep_Lo; - break; - case State::SingleStepSmall: - currentSdAddresses[0] = SingleStepSmall_Hi; - currentSdAddresses[1] = SingleStepSmall_Lo; - break; - case State::SingleStepNormal: - currentSdAddresses[0] = SingleStepNormal_Hi; - currentSdAddresses[1] = SingleStepNormal_Lo; - break; - case State::SingleStepLarge: - currentSdAddresses[0] = SingleStepLarge_Hi; - currentSdAddresses[1] = SingleStepLarge_Lo; - break; - case State::SingleStepSmallSelected: - currentSdAddresses[0] = SingleStepSmallSelected_Hi; - currentSdAddresses[1] = SingleStepSmallSelected_Lo; - break; - case State::SingleStepNormalSelected: - currentSdAddresses[0] = SingleStepNormalSelected_Hi; - currentSdAddresses[1] = SingleStepNormalSelected_Lo; - break; - case State::SingleStepSmallActivated: - currentSdAddresses[0] = SingleStepSmallActivated_Hi; - currentSdAddresses[1] = SingleStepSmallActivated_Lo; - break; - case State::SingleStepNormalActivated: - currentSdAddresses[0] = SingleStepNormalActivated_Hi; - currentSdAddresses[1] = SingleStepNormalActivated_Lo; - break; - - case State::SideStep: - currentSdAddresses[0] = SideStep_Hi; - currentSdAddresses[1] = SideStep_Lo; - break; - case State::SideStepLeft: - currentSdAddresses[0] = SideStepLeft_Hi; - currentSdAddresses[1] = SideStepLeft_Lo; - break; - case State::SideStepRight: - currentSdAddresses[0] = SideStepRight_Hi; - currentSdAddresses[1] = SideStepRight_Lo; - break; - case State::SideStepLeftSmall: - currentSdAddresses[0] = SideStepLeftSmall_Hi; - currentSdAddresses[1] = SideStepLeftSmall_Lo; - break; - case State::SideStepLeftSmallSelected: - currentSdAddresses[0] = SideStepLeftSmallSelected_Hi; - currentSdAddresses[1] = SideStepLeftSmallSelected_Lo; - break; - case State::SideStepLeftSmallActivated: - currentSdAddresses[0] = SideStepLeftSmallActivated_Hi; - currentSdAddresses[1] = SideStepLeftSmallActivated_Lo; - break; - case State::SideStepLeftNormal: - currentSdAddresses[0] = SideStepLeftNormal_Hi; - currentSdAddresses[1] = SideStepLeftNormal_Lo; - break; - case State::SideStepLeftNormalSelected: - currentSdAddresses[0] = SideStepLeftNormalSelected_Hi; - currentSdAddresses[1] = SideStepLeftNormalSelected_Lo; - break; - case State::SideStepLeftNormalActivated: - currentSdAddresses[0] = SideStepLeftNormalActivated_Hi; - currentSdAddresses[1] = SideStepLeftNormalActivated_Lo; - break; - case State::SideStepRightSmall: - currentSdAddresses[0] = SideStepRightSmall_Hi; - currentSdAddresses[1] = SideStepRightSmall_Lo; - break; - case State::SideStepRightSmallSelected: - currentSdAddresses[0] = SideStepRightSmallSelected_Hi; - currentSdAddresses[1] = SideStepRightSmallSelected_Lo; - break; - case State::SideStepRightSmallActivated: - currentSdAddresses[0] = SideStepRightSmallActivated_Hi; - currentSdAddresses[1] = SideStepRightSmallActivated_Lo; - break; - case State::SideStepRightNormal: - currentSdAddresses[0] = SideStepRightNormal_Hi; - currentSdAddresses[1] = SideStepRightNormal_Lo; - break; - case State::SideStepRightNormalSelected: - currentSdAddresses[0] = SideStepRightNormalSelected_Hi; - currentSdAddresses[1] = SideStepRightNormalSelected_Lo; - break; - case State::SideStepRightNormalActivated: - currentSdAddresses[0] = SideStepRightSmallActivated_Hi; - currentSdAddresses[1] = SideStepRightSmallActivated_Lo; - break; - default: - Serial.println("Can't draw this state"); - currentSdAddresses[0] = 0; - currentSdAddresses[1] = 0; - break; - } - return currentSdAddresses; -} diff --git a/src/button.cpp b/src/button.cpp new file mode 100644 index 0000000..5a04cd9 --- /dev/null +++ b/src/button.cpp @@ -0,0 +1,32 @@ +#include "button.h" + +Button::Button(uint8_t pin) : input_pin_(pin) +{ + pinMode(pin, INPUT_PULLUP); +} + +ButtonState Button::getState() +{ + ButtonState state; + if (digitalRead(this->input_pin_) == LOW) + { + if (this->last_position_ != ButtonState::PUSH || (millis() - this->last_print_time_) > this->hold_time_) + { + this->last_print_time_ = millis(); + this->last_position_ = ButtonState::PUSH; + state = ButtonState::PUSH; + } + else + { + state = ButtonState::HOLDING; + } + } + else + { + this->last_position_ = ButtonState::NEUTRAL; + state = ButtonState::NEUTRAL; + } + // To prevent multiple 'up's and 'down's per press due to bouncing + usleep(this->bounce_time_); + return state; +} diff --git a/src/joystick.cpp b/src/joystick.cpp new file mode 100644 index 0000000..786540e --- /dev/null +++ b/src/joystick.cpp @@ -0,0 +1,136 @@ +#include "joystick.h" + +Joystick::Joystick(uint8_t left_pin, uint8_t right_pin, uint8_t up_pin, uint8_t down_pin, uint8_t press_pin) + : left_pin_(left_pin), right_pin_(right_pin), up_pin_(up_pin), down_pin_(down_pin), press_pin_(press_pin) +{ + pinMode(left_pin, INPUT_PULLUP); + pinMode(right_pin, INPUT_PULLUP); + pinMode(up_pin, INPUT_PULLUP); + pinMode(down_pin, INPUT_PULLUP); + pinMode(press_pin, INPUT_PULLUP); +} + +JoystickState Joystick::getState() +{ + JoystickState position; + if (digitalRead(this->left_pin_) == LOW) + { + if (this->last_position_ != JoystickState::LEFT || (millis() - this->last_print_time_) > this->hold_time_) + { + position = JoystickState::LEFT; + this->last_print_time_ = millis(); + this->last_position_ = JoystickState::LEFT; + } + else + { + position = JoystickState::HOLDING; + } + } + else if (digitalRead(this->right_pin_) == LOW) + { + if (this->last_position_ != JoystickState::RIGHT || (millis() - this->last_print_time_) > this->hold_time_) + { + position = JoystickState::RIGHT; + this->last_print_time_ = millis(); + this->last_position_ = JoystickState::RIGHT; + } + else + { + position = JoystickState::HOLDING; + } + } + else if (digitalRead(this->up_pin_) == LOW) + { + if (this->last_position_ != JoystickState::UP || (millis() - this->last_print_time_) > this->hold_time_) + { + position = JoystickState::UP; + this->last_print_time_ = millis(); + this->last_position_ = JoystickState::UP; + } + else + { + position = JoystickState::HOLDING; + } + } + else if (digitalRead(this->down_pin_) == LOW) + { + if (this->last_position_ != JoystickState::DOWN || (millis() - this->last_print_time_) > this->hold_time_) + { + position = JoystickState::DOWN; + this->last_print_time_ = millis(); + this->last_position_ = JoystickState::DOWN; + } + else + { + position = JoystickState::HOLDING; + } + } + else + { + position = JoystickState::NEUTRAL; + this->last_position_ = JoystickState::NEUTRAL; + } + // To prevent multiple prints per action due to bouncing + usleep(this->bounce_time_); + return position; +} + +ButtonState Joystick::getButtonState() +{ + ButtonState state; + if (this->recent_double_click_) + { + if (millis() - this->last_double_click_time_ > this->double_click_timeout_time_) + { + this->recent_double_click_ = false; // Go back to an mode where we can publish stuff + } + } + if (this->recent_initial_click_ && !this->recent_double_click_) + { + if (millis() - this->last_push_release_time_ > this->double_click_time_ && digitalRead(this->press_pin_) == HIGH) + { // Enough time has elapsed since last + // push release time and not pressed + this->last_push_ = false; + state = ButtonState::PUSH; // No second click, so publish the single click + this->recent_initial_click_ = false; + } + else if (digitalRead(this->press_pin_) == LOW) + { // Joystick is pressed + this->last_push_ = true; + state = ButtonState::DOUBLE; // A second click, so publish the double click + this->recent_initial_click_ = false; + this->recent_double_click_ = true; + this->last_double_click_time_ = millis(); + } + else + { // Joystick not pressed, not just released and recent enough + // initial click + this->last_push_ = false; + state = ButtonState::NEUTRAL; + } + } + else + { // No recent initial click or a recent double click + if (digitalRead(this->press_pin_) == LOW) + { // Pressed + this->last_push_ = true; + } + else + { // Not pressed + if (this->last_push_) + { // Just released + this->recent_initial_click_ = true; + this->last_push_release_time_ = millis(); + } + else + { + this->recent_initial_click_ = false; + } + this->last_push_ = false; + } + state = ButtonState::NEUTRAL; + } + // To prevent multiple prints per action due to bouncing + usleep(this->bounce_time_); + return state; +} diff --git a/src/main.cpp b/src/main.cpp index b240e92..9a15b28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,61 +1,63 @@ +#include "button.h" +#include "joystick.h" +#include "rocker_switch.h" +#include "screen.h" +#include "state_machine.h" +#include "wireless_connection.h" + +#include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include "Adafruit_DRV2605.h" +#include +#include +#include +#include #include -#include -#include #include -#include -#include -#include -#include -// Pin definitions -// Trigger -#define TRIGGER 26 -// Rocker Switch -#define ROCKER_UP 2 -#define ROCKER_DOWN 5 -// Joystick -#define JOYSTICK_LEFT 23 -#define JOYSTICK_RIGHT 14 -#define JOYSTICK_UP 12 -#define JOYSTICK_DOWN 19 -#define JOYSTICK_PUSH 18 -// Screen -#define UART_TX 32 // Software serial -#define UART_RX 34 // Software serial -#define RST 13 // Reset -#define BAUD_SCREEN 9600 +namespace pins +{ +const uint8_t TRIGGER = 26; + +const uint8_t ROCKER_UP = 2; +const uint8_t ROCKER_DOWN = 5; + +const uint8_t JOYSTICK_LEFT = 23; +const uint8_t JOYSTICK_RIGHT = 14; +const uint8_t JOYSTICK_UP = 12; +const uint8_t JOYSTICK_DOWN = 19; +const uint8_t JOYSTICK_PUSH = 18; +const uint8_t UART_TX = 32; // Software serial +const uint8_t UART_RX = 34; // Software serial +const uint8_t RST = 13; // Reset +} // namespace pins + +const uint32_t BAUD_SCREEN = 9600; +const uint64_t BAUD_SERIAL = 57600; + +// Necessary, since the 4dsystems defines these +// and they clash with our joystick definitions +#undef LEFT +#undef RIGHT +#undef UP +#undef DOWN //#define USE_WIRELESS // comment this to use wired connection. -// Trigger -Button trigger(TRIGGER); -// Rocker switch -RockerSwitch rocker(ROCKER_UP, ROCKER_DOWN); -// Joystick -Joystick joystick(JOYSTICK_LEFT, JOYSTICK_RIGHT, JOYSTICK_UP, JOYSTICK_DOWN, JOYSTICK_PUSH); -// Serial communication between Lolin and Screen -SoftwareSerial screenSerial(UART_RX, UART_TX); -// Instance of the screen as in Goldelox_Serial library -Goldelox_Serial_4DLib screenGoldelox(&screenSerial); -// Wrapper instance of the screen -Screen screen(&screenGoldelox, &screenSerial, RST, BAUD_SCREEN); -// State Machine -StateMachine stateMachine; - -// Haptic Driver +Button trigger(pins::TRIGGER); +RockerSwitch rocker(pins::ROCKER_UP, pins::ROCKER_DOWN); +Joystick joystick(pins::JOYSTICK_LEFT, pins::JOYSTICK_RIGHT, pins::JOYSTICK_UP, pins::JOYSTICK_DOWN, + pins::JOYSTICK_PUSH); + +SoftwareSerial screen_serial(pins::UART_RX, pins::UART_TX); +Goldelox_Serial_4DLib screen_goldelox(&screen_serial); +Screen screen(&screen_goldelox, &screen_serial, pins::RST, BAUD_SCREEN); + +StateMachine state_machine; + Adafruit_DRV2605 driver; -uint8_t effect = 14; // Select the desired effect, for now test effect "Buzz 100%" +// Select the desired effect, for now test effect "Buzz 100%" +const uint8_t EFFECT = 14; // Create ros nodehandle with publishers #ifdef USE_WIRELESS @@ -64,30 +66,35 @@ ros::NodeHandle_ nh; ros::NodeHandle nh; #endif -bool received_gait_instruction_response; -bool gait_message_send; -void gaitInstructionResponseCallback(const std_msgs::Bool& msg) +bool received_gait_instruction_response = false; +bool gait_rejected = false; +bool gait_message_send = false; +void gaitInstructionResponseCallback(const march_shared_resources::GaitInstructionResponse& msg) { - received_gait_instruction_response = true; + if (msg.result == msg.GAIT_FINISHED || msg.result == msg.GAIT_REJECTED) + { + received_gait_instruction_response = true; + } } -ros::Subscriber gait_instruction_result_subscriber("/march/input_device/instruction_response", - &gaitInstructionResponseCallback); +ros::Subscriber + gait_instruction_result_subscriber("/march/input_device/instruction_response", &gaitInstructionResponseCallback); -march_shared_resources::GaitInstruction gaitInstructionMessage; -ros::Publisher gait_instruction_publisher("/march/input_device/instruction", &gaitInstructionMessage); -std_msgs::Time timeMessage; -ros::Publisher ping_publisher("/march/input_device/alive", &timeMessage); +march_shared_resources::GaitInstruction gait_instruction_msg; +std_msgs::Time time_msg; +ros::Publisher gait_instruction_publisher("/march/input_device/instruction", &gait_instruction_msg); +ros::Publisher ping_publisher("/march/input_device/alive", &time_msg); -void sendGaitMessage(std::string name) +void sendGaitMessage(const std::string& name) { if (!name.empty() && !gait_message_send) { - gaitInstructionMessage.type = march_shared_resources::GaitInstruction::GAIT; - gaitInstructionMessage.gait_name = name.c_str(); - gait_instruction_publisher.publish(&gaitInstructionMessage); + gait_instruction_msg.type = march_shared_resources::GaitInstruction::GAIT; + gait_instruction_msg.gait_name = name.c_str(); + gait_instruction_publisher.publish(&gait_instruction_msg); gait_message_send = true; #ifdef DEMO_INPUT_DEVICE + sleep(1); received_gait_instruction_response = true; #endif } @@ -95,34 +102,39 @@ void sendGaitMessage(std::string name) void sendStopMessage() { - gaitInstructionMessage.type = march_shared_resources::GaitInstruction::STOP; - gaitInstructionMessage.gait_name = ""; - gait_instruction_publisher.publish(&gaitInstructionMessage); + gait_instruction_msg.type = march_shared_resources::GaitInstruction::STOP; + gait_instruction_msg.gait_name = ""; + gait_instruction_publisher.publish(&gait_instruction_msg); } void sendAliveMessage() { - timeMessage.data = nh.now(); - ping_publisher.publish(&timeMessage); + time_msg.data = nh.now(); + ping_publisher.publish(&time_msg); +} + +void drawCurrentImage() +{ + const SectorAddress& address = state_machine.getCurrentImage(); + screen.draw_image(address); } void setup() { - Serial.begin(57600); - Serial.println("Start Input Device"); + Serial.begin(BAUD_SERIAL); #ifdef USE_WIRELESS setupWiFi(); #endif - // Set screen pins as either input or output - pinMode(RST, OUTPUT); - pinMode(UART_TX, OUTPUT); - pinMode(UART_RX, INPUT); + pinMode(pins::UART_TX, OUTPUT); + pinMode(pins::UART_RX, INPUT); + + // initialize screen by resetting, initing uSD card, clearing screen + screen.init(); // Setup I2C protocol driver.begin(); - // Select the effect library driver.selectLibrary(2); // I2C trigger by sending 'go' command // default, internal trigger when sending GO command @@ -133,68 +145,100 @@ void setup() nh.advertise(gait_instruction_publisher); nh.advertise(ping_publisher); nh.subscribe(gait_instruction_result_subscriber); - Serial.println("ros node initialized"); - // Reset the joystick right pin, this needed after the ROS node init pin 14 is apparently used by ROS. - pinMode(JOYSTICK_RIGHT, INPUT_PULLUP); + // Reset the joystick right pin, this needed after the ROS node init pin 14 is + // apparently used by ROS. + pinMode(pins::JOYSTICK_RIGHT, INPUT_PULLUP); - // initialize screen by resetting, initing uSD card, clearing screen - screen.initialize(); - sleep(1); + state_machine.construct(); + + sleep(2); + drawCurrentImage(); } void loop() { - // Get button states - String rockerState = rocker.get_position(); - String joystickState = joystick.get_position(); - String joystickPress = joystick.get_press(); - String triggerPress = trigger.read_state(); - - // Set the effect to be played hoi - // Waveforms can be combined, to create new wavefroms, see driver datasheet - driver.setWaveform(0, effect); // Setup the waveform(s) - driver.setWaveform(1, 0); // end of waveform waveform + // RockerSwitchState rocker_switch_state = rocker.getState(); + JoystickState joystick_state = joystick.getState(); + ButtonState joystick_button_state = joystick.getButtonState(); + ButtonState trigger_state = trigger.getState(); // When button is pressed, vibrate - if (triggerPress == "PUSH") + if (trigger_state == ButtonState::PUSH) { + // Waveforms can be combined, to create new wavefroms, see driver datasheet + driver.setWaveform(0, EFFECT); // Setup the waveform(s) + driver.setWaveform(1, 0); // end of waveform waveform + driver.go(); } + bool state_has_changed = false; if (received_gait_instruction_response) { // This means gait instruction handled - triggerPress = "EXIT_GAIT"; received_gait_instruction_response = false; gait_message_send = false; + state_has_changed = state_machine.activate(); } - - // Determine new state - stateMachine.updateState(joystickState, joystickPress, rockerState, triggerPress); - - // Draw appropriate image - int* drawSdAddresses = stateMachine.getScreenImage(); - screen.draw_image(*(drawSdAddresses), *(drawSdAddresses + 1)); - - State newState = stateMachine.getCurrentState(); - std::string name = stateMachine.getGaitNameOfState(newState); - - // If there is a transition to a new screen which belongs to a gait send message with this gait. - if (!name.empty()) + else if (gait_message_send) { - sendGaitMessage(name); + if (trigger_state == ButtonState::PUSH) + { + sendStopMessage(); + } } - else if (triggerPress == "PUSH") + else { - // If the trigger press is not to select a gait, it's interpreted as a stop. - sendStopMessage(); + switch (joystick_state) + { + case JoystickState::LEFT: + state_has_changed = state_machine.left(); + break; + case JoystickState::RIGHT: + state_has_changed = state_machine.right(); + break; + case JoystickState::UP: + state_has_changed = state_machine.up(); + break; + case JoystickState::DOWN: + state_has_changed = state_machine.down(); + break; + default: + break; + } + + if (!state_has_changed) + { + if (joystick_button_state == ButtonState::PUSH) + { + state_has_changed = state_machine.select(); + } + else if (joystick_button_state == ButtonState::DOUBLE) + { + state_has_changed = state_machine.back(); + } + else if (trigger_state == ButtonState::PUSH) + { + state_has_changed = state_machine.activate(); + } + } + } + + if (state_has_changed) + { + drawCurrentImage(); + + std::string gait_name = state_machine.getCurrentGaitName(); + if (!gait_name.empty()) + { + sendGaitMessage(gait_name); + } } // Average loop frequency is around 20hz. sendAliveMessage(); - // Spin ros node nh.spinOnce(); } diff --git a/src/rocker_switch.cpp b/src/rocker_switch.cpp new file mode 100644 index 0000000..5e423a0 --- /dev/null +++ b/src/rocker_switch.cpp @@ -0,0 +1,48 @@ +#include "rocker_switch.h" + +RockerSwitch::RockerSwitch(uint8_t up_pin, uint8_t down_pin) : up_pin_(up_pin), down_pin_(down_pin) +{ + pinMode(up_pin, INPUT_PULLUP); + pinMode(down_pin, INPUT_PULLUP); +} + +RockerSwitchState RockerSwitch::getState() +{ + RockerSwitchState state; + if (digitalRead(this->up_pin_) == LOW) + { + if (this->last_position_ != RockerSwitchState::UP || (millis() - this->last_print_time_) > this->hold_time_) + { + // reset lastPrintTime + this->last_print_time_ = millis(); + this->last_position_ = RockerSwitchState::UP; + state = RockerSwitchState::UP; + } + else + { + state = RockerSwitchState::HOLDING_UP; + } + } + else if (digitalRead(this->down_pin_) == LOW) + { + if (this->last_position_ != RockerSwitchState::DOWN || (millis() - this->last_print_time_) > this->hold_time_) + { + // reset lastPrintTime + this->last_print_time_ = millis(); + this->last_position_ = RockerSwitchState::DOWN; + state = RockerSwitchState::DOWN; + } + else + { + state = RockerSwitchState::HOLDING_DOWN; + } + } + else + { + this->last_position_ = RockerSwitchState::NEUTRAL; + state = RockerSwitchState::NEUTRAL; + } + // To prevent multiple 'up's and 'down's per press due to bouncing + usleep(this->bounce_time_); + return state; +} diff --git a/src/screen.cpp b/src/screen.cpp new file mode 100644 index 0000000..5b77e4f --- /dev/null +++ b/src/screen.cpp @@ -0,0 +1,94 @@ +#include "screen.h" +#include "version.h" + +// 16-bit color March blue converted from 24bit 0x126287 +const word MARCH_COLOR = 0x218B; + +Screen::Screen(Goldelox_Serial_4DLib* screen, SoftwareSerial* screen_serial, uint8_t rst, uint32_t baud) + : screen_(screen), serial_(screen_serial), rst_(rst), baud_(baud) +{ + pinMode(rst, OUTPUT); +} + +void Screen::init() +{ + this->reset(); + + this->serial_->begin(this->baud_); + + // Set screen saver (SS) timeout and scroll speed + this->screen_->SSTimeout(this->screen_saver_timeout_); + this->screen_->SSSpeed(this->screen_saver_scroll_speed_); + + this->screen_->TimeLimit4D = this->time_limit_; + + this->clear(); + + this->screen_->gfx_ScreenMode(PORTRAIT); + this->printVersion(); + sleep(5); + this->mountImages(); + this->screen_->gfx_ScreenMode(LANDSCAPE); + + this->clear(); +} + +void Screen::clear() +{ + this->screen_->gfx_Cls(); + usleep(this->wait_time_); +} + +void Screen::reset() +{ + digitalWrite(this->rst_, 1); + usleep(100000); + digitalWrite(this->rst_, 0); + usleep(this->wait_time_); + digitalWrite(this->rst_, 1); + + // Let the display start up + sleep(3); +} + +void Screen::draw_image(const SectorAddress& address) +{ + this->screen_->media_SetSector(address.hi, address.lo); + this->screen_->media_Image(0, 0); +} + +void Screen::printVersion() +{ + this->screen_->txt_Bold(ON); + this->screen_->txt_Width(2); + this->screen_->txt_Height(2); + this->screen_->txt_FGcolour(MARCH_COLOR); + this->screen_->println(ORGANIZATION); + this->screen_->println(""); + + this->screen_->txt_Bold(OFF); + this->screen_->txt_Width(1); + this->screen_->txt_Height(1); + this->screen_->txt_FGcolour(WHITE); + this->screen_->println(PROJECT_NAME); + this->screen_->println(VERSION); + this->screen_->println(""); +} + +void Screen::mountImages() +{ + word initialized = this->screen_->media_Init(); + + if (initialized == 0) + { + this->screen_->txt_FGcolour(RED); + this->screen_->println("Pls insert SD"); + while (initialized == 0) + { + sleep(1); + initialized = this->screen_->media_Init(); + } + this->screen_->txt_FGcolour(WHITE); + this->screen_->println("Done"); + } +} diff --git a/src/state_machine.cpp b/src/state_machine.cpp new file mode 100644 index 0000000..d7119ce --- /dev/null +++ b/src/state_machine.cpp @@ -0,0 +1,233 @@ +#include "state_machine.h" +#include "sd_sector_addresses.h" + +#include + +void StateMachine::construct() +{ + // Walk menu + State& walk = this->createState(WALK); + State& side_step = this->createState(SIDE_STEP); + State& single_step = this->createState(SINGLE_STEP); + + // Sit menu + State& sit = this->createGaitState(SIT, SIT_SELECTED, SIT_ACTIVATED, "gait_sit"); + State& home_sit = this->createGaitState(HOME_SIT, HOME_SIT_SELECTED, HOME_SIT_ACTIVATED, "home_sit"); + State& home_stand = this->createGaitState(HOME_STAND, HOME_STAND_SELECTED, HOME_STAND_ACTIVATED, "home_stand"); + State& turn_off = this->createState(TURN_OFF); + + // Obstacle menu + State& sofa = this->createState(SOFA); + State& stairs = this->createState(STAIRS); + + // Start menu + State& stand_up = this->createGaitState(STAND_UP, STAND_UP_SELECTED, STAND_UP_ACTIVATED, "gait_stand", &walk); + State& home_sit_start = + this->createGaitState(HOME_SIT_START, HOME_SIT_START_SELECTED, HOME_SIT_START_ACTIVATED, "home_sit", &stand_up); + State& home_stand_start = this->createGaitState(HOME_STAND_START, HOME_STAND_START_SELECTED, + HOME_STAND_START_ACTIVATED, "home_stand", &walk); + State& turn_off_start = this->createState(TURN_OFF_START); + + // Sub-menus + this->constructWalkMenu(&walk); + this->constructSideStepMenu(&side_step); + this->constructStepMenu(&single_step); + this->constructSofaMenu(&sofa); + this->constructStairsMenu(&stairs); + + // Menu transitions + walk.withRight(&single_step).upTo(&stairs).downTo(&sit); + single_step.withRight(&side_step).upTo(&stairs).downTo(&sit); + side_step.withRight(&walk).upTo(&stairs).downTo(&sit); + + sit.withRight(&home_sit).upTo(&walk); + home_sit.withRight(&home_stand).upTo(&walk); + home_stand.withRight(&turn_off).upTo(&walk); + turn_off.withRight(&sit).upTo(&walk); + + sofa.withRight(&stairs).downTo(&walk); + stairs.withRight(&sofa).downTo(&walk); + + home_sit_start.withRight(&stand_up); + stand_up.withRight(&home_stand_start); + home_stand_start.withRight(&turn_off_start); + turn_off_start.withRight(&home_sit_start); + + // Set start state + this->current_state_ = &home_sit_start; +} + +void StateMachine::constructWalkMenu(State* from) +{ + State& walk_small = + this->createGaitState(WALK_SMALL, WALK_SMALL_SELECTED, WALK_SMALL_ACTIVATED, "gait_walk_small", from); + State& walk_normal = + this->createGaitState(WALK_NORMAL, WALK_NORMAL_SELECTED, WALK_NORMAL_ACTIVATED, "gait_walk", from); + State& walk_large = this->createState(WALK_LARGE); + + walk_small.backTo(from); + walk_normal.backTo(from).withLeft(&walk_small); + walk_large.backTo(from).withLeft(&walk_normal).withRight(&walk_small); + + from->withSelect(&walk_normal); +} + +void StateMachine::constructSideStepMenu(State* from) +{ + State& side_step_left = this->createState(SIDE_STEP_LEFT); + State& side_step_right = this->createState(SIDE_STEP_RIGHT); + + State& side_step_left_small = + this->createGaitState(SIDE_STEP_LEFT_SMALL, SIDE_STEP_LEFT_SMALL_SELECTED, SIDE_STEP_LEFT_SMALL_ACTIVATED, + "gait_side_step_left_small", from); + + State& side_step_left_normal = this->createGaitState(SIDE_STEP_LEFT_NORMAL, SIDE_STEP_LEFT_NORMAL_SELECTED, + SIDE_STEP_LEFT_NORMAL_ACTIVATED, "gait_side_step_left", from); + + State& side_step_right_small = + this->createGaitState(SIDE_STEP_RIGHT_SMALL, SIDE_STEP_RIGHT_SMALL_SELECTED, SIDE_STEP_RIGHT_SMALL_ACTIVATED, + "gait_side_step_right_small", from); + + State& side_step_right_normal = this->createGaitState(SIDE_STEP_RIGHT_NORMAL, SIDE_STEP_RIGHT_NORMAL_SELECTED, + SIDE_STEP_RIGHT_NORMAL_ACTIVATED, "gait_side_step_right", from); + + side_step_left.backTo(from).withRight(&side_step_right).withSelect(&side_step_left_normal); + side_step_right.backTo(from).withRight(&side_step_left).withSelect(&side_step_right_normal); + + side_step_left_small.backTo(&side_step_left).withRight(&side_step_left_normal); + side_step_left_normal.withRight(&side_step_left_small); + + side_step_right_small.backTo(&side_step_right).withRight(&side_step_right_normal); + side_step_right_normal.withRight(&side_step_right_small); + + from->withSelect(&side_step_left); +} + +void StateMachine::constructStepMenu(State* from) +{ + State& single_step_small = this->createGaitState(SINGLE_STEP_SMALL, SINGLE_STEP_SMALL_SELECTED, + SINGLE_STEP_SMALL_ACTIVATED, "gait_single_step_normal", from); + State& single_step_normal = this->createGaitState(SINGLE_STEP_NORMAL, SINGLE_STEP_NORMAL_SELECTED, + SINGLE_STEP_NORMAL_ACTIVATED, "gait_single_step_normal", from); + State& single_step_large = this->createState(SINGLE_STEP_LARGE); + + single_step_small.backTo(from).withRight(&single_step_normal); + single_step_normal.backTo(from).withRight(&single_step_large); + single_step_large.backTo(from).withRight(&single_step_small); + + from->withSelect(&single_step_normal); +} + +void StateMachine::constructSofaMenu(State* from) +{ + State& sofa_standup = + this->createGaitState(SOFA_STANDUP, SOFA_STANDUP_SELECTED, SOFA_STANDUP_ACTIVATED, "gait_sofa_stand", from); + State& sofa_sit = + this->createGaitState(SOFA_SIT, SOFA_SIT_SELECTED, SOFA_SIT_ACTIVATED, "gait_sofa_sit", &sofa_standup); + + sofa_sit.backTo(from).withRight(&sofa_standup); + sofa_standup.backTo(from).withRight(&sofa_sit); + from->withSelect(&sofa_sit); +} + +void StateMachine::constructStairsMenu(State* from) +{ + State& stairs_up = this->createGaitState(STAIRS_UP, STAIRS_UP_SELECTED, STAIRS_UP_ACTIVATED, "gait_stairs_up", from); + State& stairs_down = + this->createGaitState(STAIRS_DOWN, STAIRS_DOWN_SELECTED, STAIRS_DOWN_ACTIVATED, "gait_stairs_down", from); + + stairs_up.backTo(from).withRight(&stairs_down); + stairs_down.backTo(from).withRight(&stairs_up); + from->withSelect(&stairs_up); +} + +std::string StateMachine::getCurrentGaitName() const +{ + if (this->hasState()) + { + return this->current_state_->getGaitName(); + } + return std::string(); +} + +SectorAddress StateMachine::getCurrentImage() const +{ + if (this->hasState()) + { + return this->current_state_->getImage(); + } + return SectorAddress{ 0, 0 }; +} + +size_t StateMachine::size() const +{ + return this->states_.size(); +} + +bool StateMachine::left() +{ + return this->hasState() && this->setCurrentState(this->current_state_->left()); +} + +bool StateMachine::right() +{ + return this->hasState() && this->setCurrentState(this->current_state_->right()); +} + +bool StateMachine::up() +{ + return this->hasState() && this->setCurrentState(this->current_state_->up()); +} + +bool StateMachine::down() +{ + return this->hasState() && this->setCurrentState(this->current_state_->down()); +} + +bool StateMachine::back() +{ + return this->hasState() && this->setCurrentState(this->current_state_->back()); +} + +bool StateMachine::select() +{ + return this->hasState() && this->setCurrentState(this->current_state_->select()); +} + +bool StateMachine::activate() +{ + return this->hasState() && this->setCurrentState(this->current_state_->activate()); +} + +bool StateMachine::hasState() const +{ + return this->current_state_ != nullptr; +} + +bool StateMachine::setCurrentState(const State* new_state) +{ + bool has_changed = this->current_state_ != new_state; + this->current_state_ = new_state; + return has_changed; +} + +State& StateMachine::createState(const SectorAddress address, const std::string& gait_name) +{ + this->states_.emplace_back(address, gait_name); + return this->states_.back(); +} + +State& StateMachine::createGaitState(const SectorAddress addr, const SectorAddress addr_selected, + const SectorAddress addr_activated, const std::string& gait_name, + const State* result) +{ + State& normal = this->createState(addr); + State& selected = this->createState(addr_selected); + State& activated = this->createState(addr_activated, gait_name); + + normal.withSelect(&selected); + selected.withActivate(&activated); + activated.withActivate(result == nullptr ? &normal : result); + + return normal; +} diff --git a/test/test_state/test_state.cpp b/test/test_state/test_state.cpp new file mode 100644 index 0000000..413f3c6 --- /dev/null +++ b/test/test_state/test_state.cpp @@ -0,0 +1,45 @@ +#include "state.h" + +#include + +#include + +void test_state_get_gait_name() +{ + std::string gait("test"); + State state({ 0, 0 }, gait); + TEST_ASSERT_EQUAL_STRING(gait.c_str(), state.getGaitName().c_str()); +} + +void test_state_get_address() +{ + SectorAddress expected = { 7, 8 }; + State state(expected); + + SectorAddress address = state.getImage(); + TEST_ASSERT_EQUAL(expected.hi, address.hi); + TEST_ASSERT_EQUAL(expected.lo, address.lo); +} + +void test_state_default_transitions() +{ + State state({ 0, 0 }); + TEST_ASSERT_EQUAL(&state, state.left()); + TEST_ASSERT_EQUAL(&state, state.right()); + TEST_ASSERT_EQUAL(&state, state.up()); + TEST_ASSERT_EQUAL(&state, state.down()); + TEST_ASSERT_EQUAL(&state, state.back()); + TEST_ASSERT_EQUAL(&state, state.select()); + TEST_ASSERT_EQUAL(&state, state.activate()); +} + +int main(int argc, char** argv) +{ + UNITY_BEGIN(); + RUN_TEST(test_state_get_gait_name); + RUN_TEST(test_state_get_address); + RUN_TEST(test_state_default_transitions); + UNITY_END(); + + return 0; +} diff --git a/test/test_state_machine/test_state_machine.cpp b/test/test_state_machine/test_state_machine.cpp new file mode 100644 index 0000000..8f1e3d9 --- /dev/null +++ b/test/test_state_machine/test_state_machine.cpp @@ -0,0 +1,50 @@ +#include "state_machine.h" + +#include + +#include + +void test_get_gait_name() +{ + StateMachine state_machine; + std::string gait_name = state_machine.getCurrentGaitName(); + TEST_ASSERT_EQUAL_STRING("", gait_name.c_str()); +} + +void test_get_image() +{ + StateMachine state_machine; + SectorAddress address = state_machine.getCurrentImage(); + TEST_ASSERT_EQUAL(0, address.hi); + TEST_ASSERT_EQUAL(0, address.lo); +} + +void test_state_machine_default_no_transitions() +{ + StateMachine state_machine; + TEST_ASSERT_FALSE(state_machine.left()); + TEST_ASSERT_FALSE(state_machine.right()); + TEST_ASSERT_FALSE(state_machine.up()); + TEST_ASSERT_FALSE(state_machine.down()); + TEST_ASSERT_FALSE(state_machine.back()); + TEST_ASSERT_FALSE(state_machine.select()); + TEST_ASSERT_FALSE(state_machine.activate()); +} + +void test_default_empty() +{ + StateMachine state_machine; + TEST_ASSERT_EQUAL(0, state_machine.size()); +} + +int main(int argc, char** argv) +{ + UNITY_BEGIN(); + RUN_TEST(test_get_gait_name); + RUN_TEST(test_get_image); + RUN_TEST(test_state_machine_default_no_transitions); + RUN_TEST(test_default_empty); + UNITY_END(); + + return 0; +}