-
Notifications
You must be signed in to change notification settings - Fork 12
/
pgHW.h
184 lines (123 loc) · 3.27 KB
/
pgHW.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
pgHW.cpp library
this library is to be used with standuino MicroGranny hardware
MOZZI library compatible
documentation of the library you find here:
pgHW library
Created by Vaclav Pelousek 2013 www.pelousek.eu
for Standuino wwww.standuino.eu
*/
#ifndef pgHW_h
#define pgHW_h
#include "Arduino.h"
#include <avr/pgmspace.h>
#include <shiftRegisterFast.h>
#include <portManipulations.h>
#define DEFAULT 0
#define UNFREEZE_EXTERNALY 1
#define SEG_A 0 //Display pin 14
#define SEG_B 1 //Display pin 16
#define SEG_C 2 //Display pin 13
#define SEG_D 3 //Display pin 3
#define SEG_E 4 //Display pin 5
#define SEG_F 7 //Display pin 11
#define SEG_G 6 //Display pin 15
#define SEG_DOT 5
#define LED_R_PIN 5
#define LED_G_PIN 4
#define LED_B_PIN 3
#define LED_1_PIN 6
#define LED_2_PIN 7
//const unsigned char bigButton[NUMBER_OF_BIG_BUTTONS]={BIG_1,BIG_2,BIG_3,BIG_4,BIG_5,BIG_6};
#define KNOB_TOLERANCE 11
#define KNOB_FREEZE_DISTANCE 128
#define NUMBER_OF_KNOBS 2
#define NUMBER_OF_BUTTONS 6
//#define NUMBER_OF_DIGITS 4
#define FACTORY_CLEAR_PIN 2
#define FACTORY_CLEAR_SIGNAL_PIN 13
#define VOID 36
#define MINUS 37
#define LINES 38
#define SLASH 39
#define ZERO 0
//const unsigned char knobLed[NUMBER_OF_KNOBS]={KNOB_LED_1_PIN,KNOB_LED_2_PIN,KNOB_LED_3_PIN,KNOB_LED_4_PIN};
#define LED_R 9
#define LED_G 12
#define LED_B 8
#define NUMBER_OF_COLORS 8
#define BLACK 0
#define RED 1
#define GREEN 2
#define BLUE 3
#define YELLOW 4
#define MAGENTA 5
#define CIAN 6
#define WHITE 7
/*
Segments
- A
F / / B
- G
E / / C
- D
*/
class pgHW
{
public:
pgHW(); // constructor
void initialize();
void update();
//void updateButtons();
void dimForRecord(unsigned char _BUTTON);
void setLed(unsigned char _LED, boolean _STATE);
void setColor(unsigned char _COLOR);
boolean buttonState(unsigned char _BUTTON);
boolean justPressed(unsigned char _BUTTON);
boolean justReleased(unsigned char _BUTTON);
boolean knobFreezed(unsigned char _KNOB);
boolean knobMoved(unsigned char _KNOB);
void freezeAllKnobs();
void unfreezeAllKnobs();
void freezeKnob(unsigned char _KNOB);
void unfreezeKnob(unsigned char _KNOB);
int getCvValue();
int knobValue(unsigned char _KNOB);
int lastKnobValue(unsigned char _KNOB);
void setLastKnobValue(unsigned char _KNOB,int _val);
// void setFreezeType(unsigned char _TYPE);
void flipSwitch(unsigned char _SWITCH);
void setSwitch(unsigned char _SWITCH, boolean _STATE);
boolean switchState(unsigned char _SWITCH);
void resetSwitches();
void displayText(char *text);
void displayChar(char whichChar) ;
void lightNumber(int numberToDisplay);
void displayNumber(int _number);
void setDot( boolean _state);
unsigned char soundFromSwitches();
unsigned char soundFromButtons();
// boolean factoryClear();
// void factoryCleared();
void updateKnobs();
void updateButtons();
void updateDisplay();
int _row;
unsigned char displayBuffer[2];
unsigned char lastDisplayBuffer[2];
private:
uint8_t _knob;
int buttonStateHash;
int lastButtonStateHash;
int switchStateHash;
int justPressedHash;
int justReleasedHash;
int ledStateHash;
unsigned char knobFreezedHash;
unsigned char knobChangedHash;
int knobValues[3];
int lastKnobValues[3];
boolean mozzi;
boolean unfreezeExternaly;
};
#endif