1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00
CLK/Storage/Storage.hpp
Thomas Harte 2332f72875 Formalised clock-rate multiplication within disk drives, discovered that the stepper didn't have ideal behaviour for my timed event loop and hence nailed down the semantics a ilttle more.
(obiter: the 1540 now appears to discern the correct sequence of bits. Framing is off in my test printfs but that's neither here nor there).
2016-07-31 13:32:30 -04:00

35 lines
582 B
C++

//
// Storage.hpp
// Clock Signal
//
// Created by Thomas Harte on 10/07/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef Storage_hpp
#define Storage_hpp
#include "../NumberTheory/Factors.hpp"
namespace Storage {
struct Time {
unsigned int length, clock_rate;
inline void simplify()
{
unsigned int common_divisor = NumberTheory::greatest_common_divisor(length, clock_rate);
length /= common_divisor;
clock_rate /= common_divisor;
}
inline float get_float()
{
return (float)length / (float)clock_rate;
}
};
}
#endif /* Storage_h */