Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed EALib
Fork of header_main_publish by
timeslice.cpp
- Committer:
- klauss
- Date:
- 2014-09-09
- Revision:
- 0:4d17cd9c8f9d
File content as of revision 0:4d17cd9c8f9d:
#include "timeslice.h"
Timeslice::Timeslice(){
for( register int i = 0; i < __MAX_TIMESLICES__; i++ ) timeslice[ i ] = 0x00;
}
Timeslice::~Timeslice(){
// do something here
}
uint8_t Timeslice::get_timeslice(){
for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ )
if( timeslice[ i ] == 0x00 ){
timeslice[ i ] = 0x01;
return( i + 1 );
}
return( 0x00 );
}
void Timeslice::return_timeslice( uint8_t ts ){
if( ts <= __MAX_TIMESLICES__ && ts > 0 ) timeslice[ ts - 1 ] = 0x00;
}
void Timeslice::reset(){
for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ )
timeslice[ i ] = 0x00;
}
uint8_t Timeslice::remain_timeslices( void ){
uint8_t sum = 0x00;
for( register uint8_t i = 0x00; i < __MAX_TIMESLICES__; i++ ){
if( timeslice[ i ] == 0x00 ) sum++;
}
return( sum );
}
