-
Notifications
You must be signed in to change notification settings - Fork 0
/
sekvojHW.h
150 lines (94 loc) · 3.66 KB
/
sekvojHW.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "sekvojHW_settings.h"
#ifndef SEKVOJHW_H_
#define SEKVOJHW_H_
#include <IHWLayer.h>
#include <ILEDsAndButtonsHW.h>
#include <Arduino.h>
class sekvojHW : public ILEDsAndButtonsHW {
public:
// sets up all the pins, timers and SPI interface
// call this before using any other method from this class
void init();
void setup(void(*clockInCallback)(),void(*rstInCallback)());
/***KNOBS***/
//Disabled function in SEKVOJ
virtual uint8_t getKnobValue(uint8_t index){return 0;};
/***LEDS***/
// set the state of a led
virtual void setLED(uint8_t number, ILEDHW::LedState state);
// print the state arrays to the Serial terminal
void printLEDStates();
/***BUTTONS***/
// the the state of a button identified by its id
virtual IButtonHW::ButtonState getButtonState(uint8_t number);
virtual bool isButtonDown(uint8_t number);
// print the read button states to serial terminal
void printButtonStates();
/***TRIGGER***/
//void setTrigger(uint8_t number, ILEDsAndButtonsHW::TriggerState state);
virtual void setTrigger(uint8_t number, bool state, bool autoOff);
/***RAM***/
// write a byte to the given address
virtual void writeSRAM(long address, uint8_t data){}
// write a number of bytes starting at the given address
virtual void writeSRAM(long address, uint8_t* buf, uint16_t len){}
// read the byte stored at the given address
virtual uint8_t readSRAM(long address){return 0;}
// read a number of bytes starting from the given address
virtual void readSRAM(long address, uint8_t* buf, uint16_t len){}
/**TIMING**/
// the number of bastl cycles elapsed since startup
// this number will overflow after some minutes; you have to deal with that in the layer above
// using a longer datatype would prevent this but at the cost of longer computation time
uint16_t getElapsedBastlCycles();
// returns the relation between bastl cycles and seconds
// this value is dependent on the hardware update frequency that you can set by a define
// use this to map real time processes (like BMP) to bastlCycles
uint16_t getBastlCyclesPerSecond(uint16_t & leftovers);
void setResetState(bool _rstMaster){ rstMaster=_rstMaster;};
void setMutes(uint8_t mutes);
void setTriggerLength(uint8_t triggerLength);
uint8_t getTriggerLength();
// only called by ISR routine.
// they would be declared private but this would prevent the ISR from accessing them
// there are workarounds for this but as they come at a cost I just left it like this
void isr_updateNextLEDRow();
void isr_updateButtons();
void isr_updateTriggerStates();
void isr_updateClockIn();
void isr_updateClockOut();
void isr_updateReset();
inline void incrementBastlCycles() {bastlCycles++;}
/**EEPROM**/
virtual void readEEPROM(uint8_t pageNumb, uint8_t* byteArray, uint16_t numbBytes){}
virtual void readEEPROMDirect(uint16_t address, uint8_t* byteArray, uint16_t numbBytes){}
virtual bool isEEPROMBusy(){return true;}
uint32_t xorshift96();
unsigned char getRandom(unsigned char min, unsigned char max);
void setBitWrapper(unsigned char &variable, unsigned char index, bool value);
void setIgnoreMutes(bool ignoreMutes);
private:
/**TRIGGERS**/
uint8_t trigMutesState;
uint8_t ignoredTrigMutes;
uint8_t trigLength;
uint8_t trigState;
uint8_t trigAutoOff;
uint8_t triggerCountdown[8];
uint8_t triggerBuffer[8];
/**TIMING**/
uint16_t bastlCycles;
/**LEDS**/
uint8_t ledStatesBeg[4];
uint8_t ledStatesEnd[4];
/**BUTTONS**/
uint8_t newButtonStates[4];
uint8_t buttonStates[4];
void compareButtonStates();
void (*buttonChangeCallback)(uint8_t number);
void (*clockInCallback)();
void (*rstInCallback)();
uint32_t rnd_x, rnd_y, rnd_z;
bool rstMaster;
};
#endif