diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c516ac5 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +cpp_src = $(wildcard *.cpp) + +cpp_obj = $(cpp_src:.cpp=.o) +c_obj = $(c_src:.c=.o) +CC = g++ +CFLAGS = -Wall -pedantic -li2c +LDFLAGS = +EXEC = runtest + + +all : $(EXEC) + +$(EXEC): $(cpp_obj) $(c_obj) + $(CC) -o $@ $^ $(LDFLAGS) + +clean: + rm -rf $(c_obj) $(cpp_obj) $(EXEC) + +cleanall: + rm -rf $(c_obj) $(cpp_obj) $(EXEC) diff --git a/display.cpp b/display.cpp new file mode 100644 index 0000000..12045c9 --- /dev/null +++ b/display.cpp @@ -0,0 +1,22 @@ +#include "display.hpp" + +#include <iostream> +#include"utils.hpp" + +Display::Display() +{ + +} + +void Display::showTime(const uint8_t& minutes, + const uint8_t& secconds) +{ + std::cout << "time: " << + +clip<uint8_t>(minutes, 0, 99) <<" : " << + +clip<uint8_t>(secconds,0,59)<< std::endl; +} + +void Display::showMode(modes mode) +{ + +} \ No newline at end of file diff --git a/display.hpp b/display.hpp new file mode 100644 index 0000000..9fea960 --- /dev/null +++ b/display.hpp @@ -0,0 +1,26 @@ +#ifndef _DISPLAY_HPP_ +#define _DISPLAY_HPP_ + +#include <stdint.h> + +class Display +{ + public: + + enum modes{ + A, + B + }; + + Display(); + + void showTime(const uint8_t& minutes, + const uint8_t& secconds); + + void showMode(modes mode); + + private: + +}; + +#endif // _DISPLAY_HPP_ \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..867bb0b --- /dev/null +++ b/main.cpp @@ -0,0 +1,12 @@ +#include"timer.hpp" + + +int main(void) +{ + + Timer timer; + + timer.run(); + + while(1); +} \ No newline at end of file diff --git a/runtest b/runtest new file mode 100755 index 0000000..8322f3d Binary files /dev/null and b/runtest differ diff --git a/timer.cpp b/timer.cpp new file mode 100644 index 0000000..3ad16ca --- /dev/null +++ b/timer.cpp @@ -0,0 +1,23 @@ +#include "timer.hpp" + +#include <iostream> + + +Timer::Timer() +{ + +} + +void Timer::run() +{ + + std::cout << "timer now starting up..." << std::endl; + + std::cout << "...timer running now!" << std::endl; + + display.showTime(100, 100); + while(1) + { + + } +} \ No newline at end of file diff --git a/timer.hpp b/timer.hpp new file mode 100644 index 0000000..a19c269 --- /dev/null +++ b/timer.hpp @@ -0,0 +1,21 @@ +#ifndef _TIMER_HPP_ +#define _TIMER_HPP_ + + +#include "display.hpp" + +class Timer +{ + public: + + Timer(); + + void run(); + + private: + + Display display; +}; + + +#endif // _TIMER_HPP_ \ No newline at end of file diff --git a/utils.hpp b/utils.hpp new file mode 100644 index 0000000..5587e7e --- /dev/null +++ b/utils.hpp @@ -0,0 +1,8 @@ +#include <algorithm> + +// https://stackoverflow.com/questions/9323903/most-efficient-elegant-way-to-clip-a-number +template <typename T> +T clip(const T& n, const T& lower, const T& upper) { + return std::max(lower, std::min(n, upper)); +} +