-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrols-debug.ino_
More file actions
117 lines (97 loc) · 2.53 KB
/
controls-debug.ino_
File metadata and controls
117 lines (97 loc) · 2.53 KB
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
#define ARDUINO 1000
#include <arduino.h>
#include "Screen.h"
#include "Controls.h"
#include "PushButton.h"
#include "Potentiometer.h"
Screen screen;
Controls controls(
PushButton(PIN2),
PushButton(PIN3),
PushButton(PIN4),
Potentiometer(A2),
Potentiometer(A3),
Potentiometer(A4),
Potentiometer(A5));
void handleBtn1();
void handleBtn2();
void handleBtn3();
void handlePot1(uint8_t oldValue, uint8_t newValue);
void handlePot2(uint8_t oldValue, uint8_t newValue);
void handlePot3(uint8_t oldValue, uint8_t newValue);
void handlePot4(uint8_t oldValue, uint8_t newValue);
uint8_t cursorX = 0;
uint8_t cursorY = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Debugging controls ...");
Serial.flush();
controls.setHandleBtn1(handleBtn1);
controls.setHandleBtn2(handleBtn2);
controls.setHandleBtn3(handleBtn3);
controls.setHandlePot1(handlePot1, 0, 15);
controls.setHandlePot2(handlePot2, 0, 31);
controls.setHandlePot3(handlePot3, 0, 1);
controls.setHandlePot4(handlePot4, 0, 127);
}
void loop()
{
controls.loop();
}
void handleBtn1()
{
Serial.println("Button 1 pressed (randomize screen)");
randomSeed(millis());
for (uint8_t i = 0; i < 32; i++)
{
for (uint8_t j = 0; j < 16; j++)
{
screen.setPixel(i, j, random(100) > 30);
}
}
screen.repaint();
}
void handleBtn2()
{
Serial.println("Button 2 pressed (set pot 4 to another handler with another range)");
controls.setHandlePot4(otherHandler, 1, 8);
}
void handleBtn3()
{
Serial.println("Button 3 pressed (restore pot 4 defaults)");
controls.setHandlePot4(handlePot4, 0, 127);
}
void handlePot1(uint8_t oldValue, uint8_t newValue)
{
Serial.print("Pot 1 set to ");
Serial.println(newValue);
screen.setPixel(cursorX, oldValue, false);
screen.setPixel(cursorX, newValue, true);
screen.repaint();
cursorY = newValue;
}
void handlePot2(uint8_t oldValue, uint8_t newValue)
{
Serial.print("Pot 2 set to ");
Serial.println(newValue);
screen.setPixel(oldValue, cursorY, false);
screen.setPixel(newValue, cursorY, true);
screen.repaint();
cursorX = newValue;
}
void handlePot3(uint8_t oldValue, uint8_t newValue)
{
Serial.print("Pot 3 set to ");
Serial.println(newValue);
}
void handlePot4(uint8_t oldValue, uint8_t newValue)
{
Serial.print("Pot 4 set to ");
Serial.println(newValue);
}
void otherHandler(uint8_t oldValue, uint8_t newValue)
{
Serial.print("This is another handler ");
Serial.println(newValue);
}