Skip to content

Commit

Permalink
added STEP and DELTA events to input
Browse files Browse the repository at this point in the history
  • Loading branch information
camilo committed Jun 14, 2024
1 parent 3fd84b4 commit fffecb4
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 60 deletions.
86 changes: 43 additions & 43 deletions doc/pages/_1_background.dox
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
*
* @section q_about About the OS
* QuarkTS++ (the C++ port of <a style="font-weight:bold" href="https://github.com/kmilo17pet/QuarkTS">QuarkTS</a>)
* is an open-source operating system that is built on top of a
* is an open-source operating system that is built on top of a
* <em>RTC cooperative quasistatic scheduler</em>. Its simplified kernel
* implements a specialized round-robin scheme using a linked-chain approach and
* implements a specialized round-robin scheme using a linked-chain approach and
* an event-queue to provide true FIFO priority scheduling.
*
*
* <b> Why cooperative? </b>
*
* Rather than having preemption, tasks manage their own life-cycle. This bring
* significant benefits, fewer re-entrance problems are encountered, because
* Rather than having preemption, tasks manage their own life-cycle. This bring
* significant benefits, fewer re-entrance problems are encountered, because
* tasks cannot be interrupted arbitrarily by other tasks, but only at positions
* permitted by the programmer, so you mostly do not need to worry about pitfalls
* permitted by the programmer, so you mostly do not need to worry about pitfalls
* of the concurrent approach(resource sharing, races, deadlocks, etc...).
*
* <b> What is it made for? </b>

* The design goal of QuarkTS++ is to achieve its stated functionality using a
* small, simple, and (most importantly) robust implementation to make it
* The design goal of QuarkTS++ is to achieve its stated functionality using a
* small, simple, and (most importantly) robust implementation to make it
* suitable on resource-constrained microcontrollers, where a full-preemptive RTOS
* is an overkill and their inclusion adds unnecessary complexity to the firmware
* development. In addition with a @ref q_fsm support, @ref q_qcoroutines, time
* is an overkill and their inclusion adds unnecessary complexity to the firmware
* development. In addition with a @ref q_fsm support, @ref q_qcoroutines, time
* control and the inter-task communication primitives, QuarkTS++ provides a modern
* environment to build stable and predictable event-driven multitasking embedded
* software. Their modularity and reliability make this OS a great choice to
* develop efficiently a wide range of applications in low-cost devices,
* software. Their modularity and reliability make this OS a great choice to
* develop efficiently a wide range of applications in low-cost devices,
* including automotive controls, monitoring and Internet of Things
*
* <b>Why should I choose it?</b>
Expand All @@ -41,20 +41,20 @@
*
* @section q_license License
* QuarkTS++ is licensed under the MIT License. You may copy, distribute and modify
* the software without any restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the OS, and to permit persons to whom the OS is furnished to do so.
* This OS is provided as is in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* the software without any restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the OS, and to permit persons to whom the OS is furnished to do so.
* This OS is provided as is 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.
*
* For more details, see the <a style="font-weight:bold" href="https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html">MIT License</a> line by line.
*
*
*
* @section q_hardwarecompatibility Hardware compatibility
* QuarkTS++ has no direct hardware dependencies, so it is portable to many
* platforms and C compilers.
*
* QuarkTS++ has no direct hardware dependencies, so it is portable to many
* platforms and C compilers.
*
* The following cores have been powered with QuarkTS++ successfully:
*
* - ARM cores(ATMEL, STM32, LPC, Kinetis, Nordic and others)
Expand All @@ -70,48 +70,48 @@
* guidelines and complemented with multiple static-analysis checks targeted to
* safe critical applications.
*
* Simply using QuarkTS++ in an application, does not mean developers can make a
* claim related to the development process and compliance of the OS to any
* requirements or product specification, without first, following a recognized
* system-wide conformance verification process. Conformance evidence must then
* be presented, audited and accepted by a recognized and relevant independent
* Simply using QuarkTS++ in an application, does not mean developers can make a
* claim related to the development process and compliance of the OS to any
* requirements or product specification, without first, following a recognized
* system-wide conformance verification process. Conformance evidence must then
* be presented, audited and accepted by a recognized and relevant independent
* assessment organization. Without undergoing this process of due diligence, no
* claim can be made as to the suitability of QuarkTS++ to be used in any safety or
* otherwise commercially critical application.
*
* Besides the previous information, the OS sets the following clarifications
* Besides the previous information, the OS sets the following clarifications
* regarding coding policies and naming conventions:
*
* - All the QuarkTS++ implementation follows the <b>C++11</b> standard strictly.
* - Dynamic memory allocation is banned to conform the industry standards for
* safety-critical software: @b MISRA-C++, @b DO178B, @b IEC-61508, @b ISO-26262
* safety-critical software: @b MISRA-C++, @b DO178B, @b IEC-61508, @b ISO-26262
* and so on.
* - Because errors in string manipulation have long been recognized as a leading
* source of buffer overflows in C, several mitigation strategies have been
* devised. These include mitigation strategies designed to prevent buffer
* overflows from occurring and strategies designed to detect buffer overflows
* - Because errors in raw-string manipulation have long been recognized as a leading
* source of buffer overflows in C/C++, several mitigation strategies have been
* devised. These include mitigation strategies designed to prevent buffer
* overflows from occurring and strategies designed to detect buffer overflows
* and securely recover without allowing the failure to be exploited.
* - In line with MISRA guides and for portability between platforms, we use the
* @c stdint.h with typedefs that indicate size and signedness in place of the basic
* types.
* - In line with @b MISRA guides, unqualified standard @c char and @c char* types
* - In line with @b MISRA guides, unqualified standard @c char and @c char* types
* are only permitted to hold ASCII characters and strings respectively.
* - The @c _t suffix is used to denote a type definition (i.e @c base_t ,
* - The @c _t suffix is used to denote a type definition (i.e @c base_t ,
* @c signal_t , @c cycles_t, ...).
* - Enum values and constants are written in all upper case.
* - Almost all functions returns a boolean value of type @c bool, where a
* @c true - @c 1u value indicates a successful procedure and @c false - @c 0u,
* @c true - @c 1u value indicates a successful procedure and @c false - @c 0u,
* the failure of the procedure
*
*
* @section q_memusage Memory usage
* As a quasi-static scheduler is implemented here, dynamic scheduling is not
* required and the assignment of tasks must be done before program execution
* begins. The kernel is designed to allow unlimited tasks and kernel objects,
* but of course, the whole application will be constrained by the memory
* As a quasi-static scheduler is implemented here, dynamic scheduling is not
* required and the assignment of tasks must be done before program execution
* begins. The kernel is designed to allow unlimited tasks and kernel objects,
* but of course, the whole application will be constrained by the memory
* specifications of the embedded system.
*
* The kernel's memory footprint can be scaled down to contain only the features
* required for your application, typically @c 3.7Kb of code space and less
* The kernel's memory footprint can be scaled down to contain only the features
* required for your application, typically @c 3.7Kb of code space and less
* than @c 1Kb of data space.
*
* <center>
Expand All @@ -135,5 +135,5 @@
* <tr><td> Remaining utilities <td> 2980
* </table>
* </center>
*
*
*/
4 changes: 2 additions & 2 deletions doc/pages/_2_foundations.dox
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
* by their priority value dictate when a task can change to the @c RUNNING state.
*
* @subsection q_removetask Removing a task
* The qOS::core::removeTask() function removes the task from the scheduling scheme.
* The qOS::core::remove() function removes the task from the scheduling scheme.
* This means the task node will be disconnected from the kernel chain,
* preventing additional overhead provided by the scheduler when it does checks
* over it and course, preventing it from running.
Expand Down Expand Up @@ -434,7 +434,7 @@
* Considering that the kernel is hardware-independent, the application writer
* should provide the necessary piece of code to enable and disable interrupts.
*
* For this, the critical::setInterruptsED() method should be used. In this way,
* For this, the qOS::critical::setInterruptsED() method should be used. In this way,
* communication between ISR and tasks using queued notifications or data queues
* is performed safely.
*
Expand Down
3 changes: 0 additions & 3 deletions doc/pages/_4_events.dox
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
*
* Please review the @ref qOS::event_t class reference for more details.
*
* @note When tasks are defined using the object-oriented programming approach,
* this structure can be obtained within the @c activities method using the
* qOS::task::eventData().
*
* @section q_event_timeelapsed The Time-Elapsed event
* Running tasks at pre-determined rates is desirable in many situations, like
Expand Down
3 changes: 0 additions & 3 deletions doc/pages/ext_fsm.dox
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@
* field. (here, a cast to qOS::event_t is mandatory).
* - @ref qOS::sm::handler_t::StateData (read-only) : State associated data. Storage-pointer.
*
* @note When states are defined using the object-oriented programming approach,
* this structure can be obtained within the @c activities method using the
* qOS::sm::state::getHandler().
*
* Within the callback function of every state or the @c activities method, only one
* level of dispatching (based on the signal) is necessary. Typically this is
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.7.0",
"version": "1.7.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.7.0
version=1.7.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.7.0
VERSION 1.7.1
DESCRIPTION "An open-source OS for small embedded applications"
LANGUAGES CXX )

Expand Down
10 changes: 5 additions & 5 deletions src/QuarkTS.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* @file QuarkTS.h
* @author J. Camilo Gomez C.
* @version 1.7.0
* @version 1.7.1
* @note This file is part of the QuarkTS++ distribution.
* @brief Global inclusion header
**/
Expand Down 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.7.0"
#define QUARKTS_CPP_VERNUM ( 170u )
#define QUARKTS_CPP_VERSION "1.7.1"
#define QUARKTS_CPP_VERNUM ( 171u )
#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 = 7U;
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 = 4135;
constexpr const uint32_t number = 4136;
constexpr const char* date = __DATE__;
constexpr const char* time = __TIME__;
constexpr const char* std = "c++11";
Expand Down
12 changes: 11 additions & 1 deletion src/include/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace qOS {
STEADY_IN_HIGH, /**< Event when the input-channel has been kept on high (or above the high threshold) for the specified time .*/
STEADY_IN_LOW, /**< Event when the input-channel has been kept on low (or below the low threshold) for the specified time .*/
STEADY_IN_BAND, /**< Event when the analog input-channel has remained within the band for the specified time .*/
DELTA, /**< Event when the difference of the last and latest reading of an analog input channel is greater than the defined delta*/
STEP, /**< Event on step reading of the analog-input channel*/
/*! @cond */
MAX_EVENTS
/*! @endcond */
Expand Down Expand Up @@ -332,6 +334,9 @@ namespace qOS {
channelStateFcn_t channelState{ nullptr };
analogValue_t high{ 800 };
analogValue_t low{ 200 };
analogValue_t last{ 0.0F };
analogValue_t delta{ 1.0e+20F };
analogValue_t step{ 1.0e+20F };
analogValue_t hysteresis{ 20 };
qOS::clock_t tSteadyBand{ 0xFFFFFFFFU };

Expand Down Expand Up @@ -367,7 +372,7 @@ namespace qOS {
*/
analogChannel( const uint8_t inputChannel, const analogValue_t lowerThreshold, const analogValue_t upperThreshold, const analogValue_t h = 0.1F ) : channel( inputChannel ), high( upperThreshold ), low( lowerThreshold )
{
hysteresis = ( h < 0 ) ? -h : h;
hysteresis = ( h < 0.0F ) ? -h : h;
}
/**
* @brief Get the channel type.
Expand Down Expand Up @@ -427,6 +432,11 @@ namespace qOS {
reader = r;
return true;
}
/**
* @brief Unshares the specified input channel if was marked as
* shared.
* @return @c true on success. Otherwise @c false.
*/
bool unShare( void ) noexcept override
{
ptrValue = &value;
Expand Down
18 changes: 18 additions & 0 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ void input::digitalChannel::updateReading( void ) noexcept
/*============================================================================*/
void input::analogChannel::updateReading(void) noexcept
{
analogValue_t diff;
value = ( isShared() ) ? ptrValue[ 0 ] : reader( number );
diff = value - last;
if ( diff >= delta ) {
dispatchEvent( input::event::DELTA );
}
if ( diff >= step ) {
auto mult = static_cast<int>( diff/step );
for ( int i = 0 ; i < mult; ++i ) {
dispatchEvent( input::event::STEP );
}
}
last = value;
}
/*============================================================================*/
void input::digitalChannel::fallingEdgeState( input::digitalChannel& c )
Expand Down Expand Up @@ -422,6 +434,12 @@ bool input::analogChannel::setParameter( const input::event e, const analogValue
case input::event::IN_BAND:
hysteresis = p;
break;
case input::event::DELTA:
delta = p;
break;
case input::event::STEP:
step = p;
break;
default:
retValue = false;
break;
Expand Down

0 comments on commit fffecb4

Please sign in to comment.