Collections of BERTL libraries
Diff: class_software.cpp
- Revision:
- 2:4a9ed5ca8a9a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/class_software.cpp Mon Apr 18 12:30:42 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "class_software.h" + +Logfile::Logfile() { + array_lenght = MAX_LOG; + + for ( int i = 0; i < array_lenght; i++ ) + array[i]=0; +} + +Logfile::Logfile(int lenght) { + if ( lenght < array_lenght ) + array_lenght = lenght; + else + array_lenght = MAX_LOG; + + for (int i = 0; i < array_lenght; i++) + array[i]=0; +} + +void Logfile::push(unsigned char input) { + if (input != array[0]) { + for (int i = array_lenght; i > 0; i--) + array[i]=array[i-1]; + + array[0]=input; + } +} + +unsigned char Logfile::last() { + return array[0]; +} + +unsigned char Logfile::at(int pos) { + if( pos < MAX_LOG ) + return array[pos]; + + return 0; +} + +