added basic outline

master
polymurph 4 years ago
parent ade9089bf2
commit 42c5e945ec

@ -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)

@ -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)
{
}

@ -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_

@ -0,0 +1,12 @@
#include"timer.hpp"
int main(void)
{
Timer timer;
timer.run();
while(1);
}

Binary file not shown.

@ -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)
{
}
}

@ -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_

@ -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));
}
Loading…
Cancel
Save