Flipklok
 
Loading...
Searching...
No Matches
timeKeeping.h
Go to the documentation of this file.
1/*
2 * calculateTimeDifference.h
3 *
4 * Created on: 21 mrt. 2025
5
6 */
7
8#ifndef CALCULATETIMEDIFFERENCE_H_
9#define CALCULATETIMEDIFFERENCE_H_
10#include <msp430.h>
11#include <stdbool.h>
12#include <stdint.h> // Include to define uint32_t
13
15
19void resetTimeKeeping();
20
23#define timerCountsInDay 60 * 60 * 24 / (capacityTimer / clockFreq)
24
25#define toothGearStepper 15.0
26#define toothGearClock 24.0
27#define gearRatio (toothGearClock / toothGearStepper)
28#define stepsFullRotationStepper 2048.0
29#define stepsClockHour (stepsFullRotationStepper * gearRatio)
30#define stepsClockMinute (stepsClockHour / 60.0)
31#define stepsClockSecond (stepsClockMinute / 60.0)
32#define timePerStep (3600.0 / (stepsFullRotationStepper * gearRatio))
33#define stepsToggleThreshold 20
34#define clockWraparoundThresholdSec (10 * 60)
35#define stepsWrap (stepsClockHour * 24)
36#define secondsInDay 86400
37#define stepsInDay (stepsClockSecond * secondsInDay)
38
39//Needs to be stored in non volatile storage (FRAM), to be persistent across boot
40double mechanicalTimeFloat; //time of mechanical clock mechanism should be in double/floating point
41//uint32_t mechanicalTimeInt; //Integer display of floatingpoint timeMechanical
42
44
45
46volatile bool toggleTimer1Direction; // 1 is up 0 is down
47
48
49#endif /* CALCULATETIMEDIFFERENCE_H_ */
uint32_t stepsRemaining
Definition timeKeeping.h:43
uint32_t timeOfLastDcfMessage
Definition timeKeeping.h:21
uint32_t timeSinceLastCompleteDcfMessage
Definition timeKeeping.h:22
void storeTimeLastCompleteDcfMessage()
double mechanicalTimeFloat
Definition timeKeeping.h:40
bool toggleCalculateTimeDifference
Definition timeKeeping.c:16
void calculateTimeDifference()
calculate the difference between the mechanical time and the current time to have the time difference...
Definition timeKeeping.c:26
volatile bool toggleTimer1Direction
Definition timeKeeping.h:46
void resetTimeKeeping()
Reset the time settings on startup, gets called from main()
uint32_t calculateStepsToTake()