Collections of BERTL libraries

Committer:
DongExpander
Date:
Mon Apr 18 12:30:42 2016 +0000
Revision:
2:4a9ed5ca8a9a
Feature; Added functions_bertl and class_software

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DongExpander 2:4a9ed5ca8a9a 1 #include "mbed.h"
DongExpander 2:4a9ed5ca8a9a 2 #include "class_software.h"
DongExpander 2:4a9ed5ca8a9a 3
DongExpander 2:4a9ed5ca8a9a 4 Logfile::Logfile() {
DongExpander 2:4a9ed5ca8a9a 5 array_lenght = MAX_LOG;
DongExpander 2:4a9ed5ca8a9a 6
DongExpander 2:4a9ed5ca8a9a 7 for ( int i = 0; i < array_lenght; i++ )
DongExpander 2:4a9ed5ca8a9a 8 array[i]=0;
DongExpander 2:4a9ed5ca8a9a 9 }
DongExpander 2:4a9ed5ca8a9a 10
DongExpander 2:4a9ed5ca8a9a 11 Logfile::Logfile(int lenght) {
DongExpander 2:4a9ed5ca8a9a 12 if ( lenght < array_lenght )
DongExpander 2:4a9ed5ca8a9a 13 array_lenght = lenght;
DongExpander 2:4a9ed5ca8a9a 14 else
DongExpander 2:4a9ed5ca8a9a 15 array_lenght = MAX_LOG;
DongExpander 2:4a9ed5ca8a9a 16
DongExpander 2:4a9ed5ca8a9a 17 for (int i = 0; i < array_lenght; i++)
DongExpander 2:4a9ed5ca8a9a 18 array[i]=0;
DongExpander 2:4a9ed5ca8a9a 19 }
DongExpander 2:4a9ed5ca8a9a 20
DongExpander 2:4a9ed5ca8a9a 21 void Logfile::push(unsigned char input) {
DongExpander 2:4a9ed5ca8a9a 22 if (input != array[0]) {
DongExpander 2:4a9ed5ca8a9a 23 for (int i = array_lenght; i > 0; i--)
DongExpander 2:4a9ed5ca8a9a 24 array[i]=array[i-1];
DongExpander 2:4a9ed5ca8a9a 25
DongExpander 2:4a9ed5ca8a9a 26 array[0]=input;
DongExpander 2:4a9ed5ca8a9a 27 }
DongExpander 2:4a9ed5ca8a9a 28 }
DongExpander 2:4a9ed5ca8a9a 29
DongExpander 2:4a9ed5ca8a9a 30 unsigned char Logfile::last() {
DongExpander 2:4a9ed5ca8a9a 31 return array[0];
DongExpander 2:4a9ed5ca8a9a 32 }
DongExpander 2:4a9ed5ca8a9a 33
DongExpander 2:4a9ed5ca8a9a 34 unsigned char Logfile::at(int pos) {
DongExpander 2:4a9ed5ca8a9a 35 if( pos < MAX_LOG )
DongExpander 2:4a9ed5ca8a9a 36 return array[pos];
DongExpander 2:4a9ed5ca8a9a 37
DongExpander 2:4a9ed5ca8a9a 38 return 0;
DongExpander 2:4a9ed5ca8a9a 39 }
DongExpander 2:4a9ed5ca8a9a 40
DongExpander 2:4a9ed5ca8a9a 41