Skip to content

Commit

Permalink
Merge pull request #12 from BlueAndi/release/v1.0.x
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
gabryelreyes authored Jul 2, 2024
2 parents 0d02008 + 572ce5d commit ee4bbd5
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 75 deletions.
38 changes: 38 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
BasedOnStyle: Microsoft
AccessModifierOffset: '-4'
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignTrailingComments: 'true'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakTemplateDeclarations: 'true'
BreakAfterJavaFieldAnnotations: 'true'
BreakBeforeBraces: Allman
BreakConstructorInitializers: AfterColon
ColumnLimit: '120'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentWidth: '4'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: 'false'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
TabWidth: '4'
UseTab: Never
4 changes: 3 additions & 1 deletion examples/example/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ lib_deps =
MainNative
HAL
Webots
BlueAndi/ZumoHALWebots @ ~0.2.0
#BlueAndi/ZumoHALWebots @ ~1.0.0
https://github.com/BlueAndi/ZumoHALInterfaces#release/1.0.x
https://github.com/BlueAndi/ZumoHALWebots#release/v1.0.x
extra_scripts =
pre:$PROJECT_LIBDEPS_DIR/$PIOENV/ZumoHALWebots/scripts/create_webots_library.py
pre:$PROJECT_LIBDEPS_DIR/$PIOENV/ZumoHALWebots/scripts/copy_sounds.py
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ZumoHALWebots",
"version": "0.2.1",
"version": "1.0.0",
"description": "Zumo C++ hardware abstraction layer for the Webots simulation.",
"authors": [{
"name": "Andreas Merkle",
Expand All @@ -20,7 +20,7 @@
}, {
"owner": "BlueAndi",
"name": "ZumoHALInterfaces",
"version": "~0.2.0"
"version": "~1.0.0"
}, {
"owner": "bblanchon",
"name": "ArduinoJson",
Expand Down
5 changes: 0 additions & 5 deletions src/ButtonA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ bool ButtonA::isPressed()
return m_keyboard.buttonAPressed();
}

void ButtonA::waitForRelease()
{
m_keyboard.waitForReleaseA();
}

/******************************************************************************
* Protected Methods
*****************************************************************************/
Expand Down
9 changes: 2 additions & 7 deletions src/ButtonA.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ButtonA : public IButton
*
* @param[in] keyboard The robot keyboard.
*/
ButtonA(Keyboard& keyboard) : IButton(), m_keyboard(keyboard)
ButtonA(Keyboard &keyboard) : IButton(), m_keyboard(keyboard)
{
}

Expand All @@ -82,13 +82,8 @@ class ButtonA : public IButton
*/
bool isPressed() final;

/**
* Wait until button A is released.
*/
void waitForRelease() final;

private:
Keyboard& m_keyboard; /**< Robot keyboard */
Keyboard &m_keyboard; /**< Robot keyboard */

/* Default constructor not allowed. */
ButtonA();
Expand Down
5 changes: 0 additions & 5 deletions src/ButtonB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ bool ButtonB::isPressed()
return m_keyboard.buttonBPressed();
}

void ButtonB::waitForRelease()
{
m_keyboard.waitForReleaseB();
}

/******************************************************************************
* Protected Methods
*****************************************************************************/
Expand Down
9 changes: 2 additions & 7 deletions src/ButtonB.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ButtonB : public IButton
*
* @param[in] keyboard The robot keyboard.
*/
ButtonB(Keyboard& keyboard) : IButton(), m_keyboard(keyboard)
ButtonB(Keyboard &keyboard) : IButton(), m_keyboard(keyboard)
{
}

Expand All @@ -82,13 +82,8 @@ class ButtonB : public IButton
*/
bool isPressed() final;

/**
* Wait until button B is released.
*/
void waitForRelease() final;

private:
Keyboard& m_keyboard; /**< Robot keyboard */
Keyboard &m_keyboard; /**< Robot keyboard */

/* Default constructor not allowed. */
ButtonB();
Expand Down
5 changes: 0 additions & 5 deletions src/ButtonC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ bool ButtonC::isPressed()
return m_keyboard.buttonCPressed();
}

void ButtonC::waitForRelease()
{
m_keyboard.waitForReleaseC();
}

/******************************************************************************
* Protected Methods
*****************************************************************************/
Expand Down
9 changes: 2 additions & 7 deletions src/ButtonC.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ButtonC : public IButton
*
* @param[in] keyboard The robot keyboard.
*/
ButtonC(Keyboard& keyboard) : IButton(), m_keyboard(keyboard)
ButtonC(Keyboard &keyboard) : IButton(), m_keyboard(keyboard)
{
}

Expand All @@ -82,13 +82,8 @@ class ButtonC : public IButton
*/
bool isPressed() final;

/**
* Wait until button is released.
*/
void waitForRelease() final;

private:
Keyboard& m_keyboard; /**< Robot keyboard */
Keyboard &m_keyboard; /**< Robot keyboard */

/* Default constructor not allowed. */
ButtonC();
Expand Down
14 changes: 5 additions & 9 deletions src/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ bool Keyboard::isButtonPressed(char lowerCaseChar, char upperCaseChar) const
{
bool buttonPressed = false;

/* Checks if button is existing in the new values, but not the old ones.
* If so, it's newly pressed and true is returned.
/* Checks if button is existing in the recorded key values
*/
if ((false == arrayContains(m_oldKeys, sizeof(m_oldKeys), upperCaseChar, lowerCaseChar)) &&
(true == arrayContains(m_newKeys, sizeof(m_newKeys), upperCaseChar, lowerCaseChar)))
if (true == arrayContains(m_keys, sizeof(m_keys), upperCaseChar, lowerCaseChar))
{
buttonPressed = true;
}
Expand All @@ -86,11 +84,9 @@ bool Keyboard::isButtonReleased(char lowerCaseChar, char upperCaseChar) const
{
bool buttonReleased = false;

/* Checks if button is existing in the new values, but not the old ones.
* If so, it's newly released and true is returned.
/* Checks if button is not existing in the recorded key values
*/
if ((false == arrayContains(m_newKeys, sizeof(m_newKeys), upperCaseChar, lowerCaseChar)) &&
(true == arrayContains(m_oldKeys, sizeof(m_oldKeys), upperCaseChar, lowerCaseChar)))
if (false == arrayContains(m_keys, sizeof(m_keys), upperCaseChar, lowerCaseChar))
{
buttonReleased = true;
}
Expand All @@ -108,7 +104,7 @@ bool Keyboard::arrayContains(const uint16_t array[], uint16_t arraySize, char el
(array[arrayIndex] == static_cast<uint8_t>(elemUppercase)))
{
elementFound = true;
;
break;
}
}

Expand Down
44 changes: 17 additions & 27 deletions src/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class Keyboard
* Constructs the encoders adapter and initialize it.
*/
Keyboard(SimTime& simTime, webots::Keyboard* keyboard) :
m_oldKeys(),
m_newKeys(),
m_keys(),
m_simTime(simTime),
m_keyboard(keyboard)
{
Expand All @@ -85,75 +84,69 @@ class Keyboard
*/
void getPressedButtons()
{
/* Copying the new values into the old values array. */
for (uint8_t arrayIndex = 0; arrayIndex < (sizeof(m_oldKeys) / sizeof(*m_oldKeys)); ++arrayIndex)
{
m_oldKeys[arrayIndex] = m_newKeys[arrayIndex];
}

/* Getting the new values. Currently the limit of the simulation is seven
/* Getting the new key values. Currently the limit of the simulation is seven
* keypresses that can be detected simultaniously.
*/
for (uint8_t keyIndex = 0; keyIndex < (sizeof(m_oldKeys) / sizeof(*m_oldKeys)); ++keyIndex)
for (uint8_t keyIndex = 0; keyIndex < (sizeof(m_keys) / sizeof(*m_keys)); ++keyIndex)
{
m_newKeys[keyIndex] = m_keyboard->getKey();
m_keys[keyIndex] = m_keyboard->getKey();
}
}

/**
* Checks weather the button A was pressed since the last update.
* Checks weather the button A was pressed..
*
* @return Return true if button A was pressed since the last update
* @return Return true if button A was pressed.
*/
bool buttonAPressed()
{
return isButtonPressed(KEY_CODE_A_LOWER_CASE, KEY_CODE_A_UPPER_CASE);
}

/**
* Checks weather the button A was released since the last update.
* Checks weather the button A is released.
*
* @return Return true if button A was released since the last update
* @return Return true if button A is released.
*/
bool buttonAReleased()
{
return isButtonReleased(KEY_CODE_A_LOWER_CASE, KEY_CODE_A_UPPER_CASE);
}

/**
* Checks weather the button B was pressed since the last update.
* Checks weather the button B was pressed..
*
* @return Return true if button B was pressed since the last update
* @return Return true if button B was pressed.
*/
bool buttonBPressed()
{
return isButtonPressed(KEY_CODE_B_LOWER_CASE, KEY_CODE_B_UPPER_CASE);
}

/**
* Checks weather the button B was released since the last update.
* Checks weather the button B was released..
*
* @return Return true if button B was released since the last update
* @return Return true if button B was released.
*/
bool buttonBReleased()
{
return isButtonReleased(KEY_CODE_B_LOWER_CASE, KEY_CODE_B_UPPER_CASE);
}

/**
* Checks weather the button C was pressed since the last update.
* Checks weather the button C was pressed..
*
* @return Return true if button C was pressed since the last update
* @return Return true if button C was pressed.
*/
bool buttonCPressed()
{
return isButtonPressed(KEY_CODE_C_LOWER_CASE, KEY_CODE_C_UPPER_CASE);
}

/**
* Checks weather the button C was released since the last update.
* Checks weather the button C was released..
*
* @return Return true if button C was released since the last update
* @return Return true if button C was released.
*/
bool buttonCReleased()
{
Expand Down Expand Up @@ -236,11 +229,8 @@ class Keyboard
/** The maximum number of keys pressed simultaniously, that the simulation can process. */
static const uint8_t MAX_KEY_NUMBER = 7;

/** The keys presses during the last update. */
uint16_t m_oldKeys[MAX_KEY_NUMBER];

/** The keys pressed during this update. */
uint16_t m_newKeys[MAX_KEY_NUMBER];
uint16_t m_keys[MAX_KEY_NUMBER];

SimTime &m_simTime; /**< Simulation time */

Expand Down

0 comments on commit ee4bbd5

Please sign in to comment.