Skip to content

Commit

Permalink
refactores methods on input. bump to 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
camilo committed Jun 7, 2024
1 parent 869b287 commit 7ae559d
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 96 deletions.
2 changes: 1 addition & 1 deletion doc/Doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "OS"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v1.6.0
PROJECT_NUMBER = v1.6.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"maintainer": true
}
],
"version": "1.6.0",
"version": "1.6.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=QuarkTS
version=1.6.0
version=1.6.1
license=MIT
author=J. Camilo Gomez C. <kmilo17pet@gmail.com>
maintainer=J. Camilo Gomez C. <kmilo17pet@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required( VERSION 3.2 )
project( quarkts-cpp
VERSION 1.6.0
VERSION 1.6.1
DESCRIPTION "An open-source OS for small embedded applications"
LANGUAGES CXX )

Expand Down
8 changes: 4 additions & 4 deletions src/QuarkTS.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ This file is part of the QuarkTS++ OS distribution.
#ifndef QOS_CPP_H
#define QOS_CPP_H

#define QUARKTS_CPP_VERSION "1.6.0"
#define QUARKTS_CPP_VERNUM ( 160u )
#define QUARKTS_CPP_VERSION "1.6.1"
#define QUARKTS_CPP_VERNUM ( 161u )
#define QUARKTS_CPP_CAPTION "QuarkTS++ OS " QUARKTS_CPP_VERSION

#include "config/config.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace qOS {
constexpr const uint8_t number = QUARKTS_CPP_VERNUM;
constexpr const uint8_t mayor = 1U;
constexpr const uint8_t minor = 6U;
constexpr const uint8_t rev = 0U;
constexpr const uint8_t rev = 1U;
}
namespace product {
constexpr const char* author = "J. Camilo Gomez C.";
Expand All @@ -84,7 +84,7 @@ namespace qOS {
}

namespace build {
constexpr const uint32_t number = 4123;
constexpr const uint32_t number = 4125;
constexpr const char* date = __DATE__;
constexpr const char* time = __TIME__;
constexpr const char* std = "c++11";
Expand Down
121 changes: 49 additions & 72 deletions src/include/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,37 +165,25 @@ namespace qOS {
return ( &value != ptrValue );
}
/**
* @brief Set the timeout for the steady in high event.
* @brief Set the timeout for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] t The value of the timeout.
* @return @c true on success. Otherwise @c false.
*/
inline bool setSteadyHighTime( const qOS::duration_t t ) noexcept
{
bool retValue = false;

if ( t > 0U ) {
tSteadyHigh = static_cast<qOS::clock_t>( t );
retValue = true;
}

return retValue;
}
virtual bool setTime( const event e, const qOS::duration_t t ) noexcept = 0;
/**
* @brief Set the timeout for the steady in low event.
* @param[in] t The value of the timeout.
* @brief Set the parameter for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] p The value of the parameter.
* @return @c true on success. Otherwise @c false.
*/
inline bool setSteadyLowTime( const qOS::duration_t t ) noexcept
{
bool retValue = false;

if ( t > 0U ) {
tSteadyLow = static_cast<qOS::clock_t>( t );
retValue = true;
}

return retValue;
}
virtual bool setParameter( const event e, const int value ) noexcept = 0;
/**
* @brief Get pulsation count for the digital input.
* @note No valid on analog inputs
* @return The current pulsation count.
*/
virtual uint8_t getCount( void ) const noexcept = 0;
friend class watcher;
};

Expand Down Expand Up @@ -243,29 +231,26 @@ namespace qOS {
return type::DIGITAL;
}
/**
* @brief Set/Change the interval duration between multiple
* pulsations for a digital input
* @param[in] interval The specified interval
* @brief Set the timeout for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] t The value of the timeout.
* @return @c true on success. Otherwise @c false.
*/
inline bool setPulsationInterval( qOS::duration_t interval ) noexcept
{
bool retValue = false;

if ( interval > 50 ) {
pulsationInterval = interval;
retValue = true;
}

return retValue;
}
bool setTime( const event e, const qOS::duration_t t ) noexcept override;
/**
* @brief Set the parameter for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] p The value of the parameter.
* @return @c true on success. Otherwise @c false.
*/
bool setParameter( const event e, const int value ) noexcept override;
/**
* @brief Get the pulsation count the digital input.
* @note Returned value should be only trusted if is read from
* the input event-callback.
* @return The pulsation count.
* @brief Get pulsation count for the digital input.
* @note No valid on analog inputs
* @return The current pulsation count.
*/
inline uint8_t getPulsationCount( void ) const noexcept {
uint8_t getCount( void ) const noexcept override
{
return pulsationCount;
}
friend class watcher;
Expand Down Expand Up @@ -319,48 +304,33 @@ namespace qOS {
* @brief Get the channel type.
* @return The channel type.
*/

type getType( void ) const noexcept override
{
return type::ANALOG;
}
/**
* @brief Set the timeout for the steady in band event.
* @brief Set the timeout for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] t The value of the timeout.
* @return @c true on success. Otherwise @c false.
*/
inline bool setSteadyBandTime( const qOS::duration_t t ) noexcept
{
bool retValue = false;

if ( ( t > 0U ) ) {
tSteadyBand = static_cast<qOS::clock_t>( t );
retValue = true;
}

return retValue;
}
bool setTime( const event e, const qOS::duration_t t ) noexcept = 0;
/**
* @brief Set the low threshold for the analog input channel
* @param[in] lowThreshold The lower threshold value.
* @brief Set the parameter for the specified event.
* @param[in] e The event where the timeout will be set.
* @param[in] p The value of the parameter.
* @return @c true on success. Otherwise @c false.
*/
inline bool setLowThreshold( const int lowThreshold ) noexcept
{
low = lowThreshold;
return true;
}
bool setParameter( const event e, const int p ) noexcept override;
/**
* @brief Set the high threshold for the analog input channel
* @param[in] lowThreshold The lower threshold value.
* @return @c true on success. Otherwise @c false.
* @brief Get pulsation count for the digital input.
* @note No valid on analog inputs
* @return The current pulsation count.
*/
inline bool setHighThreshold( const int highThreshold ) noexcept
uint8_t getCount( void ) const noexcept override
{
high = highThreshold;
return true;
return 0;
}

friend class watcher;
};

Expand All @@ -380,6 +350,7 @@ namespace qOS {
watcher( watcher const& ) = delete;
void operator=( watcher const& ) = delete;
public:
virtual ~watcher() {}
/**
* @brief Constructor for the input-watcher instance
* @param[in] rFcn A pointer to a function that reads the specific
Expand All @@ -388,7 +359,7 @@ namespace qOS {
* bounce of the digital input channels
* @return @c true on success. Otherwise @c false.
*/
watcher( const channelReaderFcn_t& rDigital, const channelReaderFcn_t& rAnalog, const qOS::duration_t timeDebounce ) :
watcher( const channelReaderFcn_t& rDigital, const channelReaderFcn_t& rAnalog, const qOS::duration_t timeDebounce = 100_ms ) :
debounceTime( timeDebounce ), digitalReader( rDigital ), analogReader( rAnalog ) {}
/**
* @brief Add a channel to the watcher instance
Expand All @@ -409,6 +380,12 @@ namespace qOS {
* updated cycle. Otherwise @c false.
*/
bool watch( void ) noexcept;
/*! @cond */
inline void operator()( void )
{
watch();
}
/*! @endcond */
};
/** @}*/
}
Expand Down
Loading

0 comments on commit 7ae559d

Please sign in to comment.