This repository was archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShiftLight.ino
69 lines (54 loc) · 1.65 KB
/
ShiftLight.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <EEPROM.h>
#include <EEPROMAnything.h>
#include <TM1637Display.h>
#include <FreqMeasure.h>
#include <InterruptFreqMeasure.h>
#include <DS1302.h>
#include "Config.h"
#include "RPMMeasure.h"
#include "ButtonSet.h"
#include "MenuItem.h"
#include "PixelAnimator.h"
#include "_menu.h"
#include "_defines.h"
//Initialize required objects.
TM1637Display* display = new TM1637Display(LCDCLK, LCDDIO);
ButtonSet* buttons = new ButtonSet(BTN_LEFT, BTN_UP, BTN_RIGHT, BTN_DOWN);
RPMMeasure* rpm = new RPMMeasure(RPM_INT_PIN, RPM_INT_NUM, RPM_TI1_PIN);
Config* CONFIG = new Config();
PixelAnimator* animator = new PixelAnimator(CONFIG);
DS1302* rtcClock = new DS1302(RTC_CE, RTC_IO, RTC_SCLK);
void setup(){
//Let the debugging begin.
// Serial.begin(9600);
rtcClock->writeProtect(false);
rtcClock->halt(false);
rtcClock->writeProtect(true);
//Load our config from defaults/EEPROM.
CONFIG->load();
//Initialize pixel animator.
animator->setup();
//Bind the required objects to the MenuItems.
MenuItem::setRTCClock(rtcClock);
MenuItem::setConfig(CONFIG);
MenuItem::setRPMMeasure(rpm);
MenuItem::setDisplay(display);
MenuItem::setAnimator(animator);
MenuItem::setButtonSet(buttons);
//Go to the home page.
MenuItem::enter(new HomeMenuItem());
//Initialize RPM sensor.
rpm->setAveragingDepth(CONFIG->RPMBuffer ? BUFFER_DEPTH : 0);
rpm->setPulsesPerRevolution(CONFIG->PPR);
rpm->setMeasureMode(CONFIG->RPMMeasureMode);
rpm->begin();
//Start tracking buttons.
buttons->begin();
}
void loop() {
//Update all the things!
buttons->update();
rpm->update();
MenuItem::update();
delay(UPDATE_INTERVAL);
}