/
Brightness.ino
137 lines (114 loc) · 2.4 KB
/
Brightness.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
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
//TEEEEMP
int brightnessLevels[] =
{
50,
30,
20,
10,
5,
1,
1, // Redded, 6
0,
};
uint16_t dotCol = colors[displayCol2];
int BrightnessReturn(bool setNow)
{
int prevbright = brightnessLevel;
brightnessGuage = brightnessLevel;
while (1 < 2)
{
matrix.fillScreen(0);
pirrana(-2, 0, 500);
brightnessGuage = ReadRotary(brightnessGuage, false);
brightnessGuage = constrain(brightnessGuage, 0, 7);
matrix.drawLine(0, 0, 0, 8, colors[displayCol2]);
matrix.drawPixel(0, brightnessGuage, colors[displayCol1]);
if (brightnessGuage == 7)
matrix.fillScreen(0);
SetBrightnessTemp(brightnessGuage);
SetLight();
if (brightnessGuage == 6)
redColours();
else
unRedColours();
if (buttonPressed())
{
if (!setNow)
{
SetBrightness(prevbright);
unRedColours();
}
return brightnessGuage;
}
if (digitalRead(2) == LOW)
canPress = true;
delay(20);
matrix.show();
}
}
void brightnessProfile()
{
//Brightness Profile
//Force the cursor pos and get input
cursorPos = ReadRotary(cursorPos, true);
cursorPos = constrain(cursorPos, 0, 6);
//Button press
if (buttonPressed())
{
if (cursorPos == 6)
{
EEPROM.put(10, BProfile);
cursorPos = 0;
oke(0);
}
else
{
if (BProfile[cursorPos].active)
{
BProfile[cursorPos].active = false;
BProfile[cursorPos].time = { 0,0 };
}
else
{
BProfile[cursorPos].active = true;
BProfile[cursorPos].time = TimeSetReturn(false, {0, 0});
BProfile[cursorPos].level = BrightnessReturn(false);
oke(1);
}
}
}
//Display the time above selection
if (cursorPos == 6)
backIcon(0, 0, colors[displayCol2], false);
else if (BProfile[cursorPos].active)
displayTimeSimple(BProfile[cursorPos].time, Med, false, false);
//Draw Pixels
for (int i = 0; i < 6; i++)
{
if (BProfile[i].active)
matrix.drawPixel(i + 1, 7, colors[1]);
else
matrix.drawPixel(i + 1, 7, colors[6]);
}
matrix.drawPixel(7, 7, colors[displayCol1]);
//Cursor
matrix.drawPixel(cursorPos + 1, 7, matrix.Color(0, 0, 0));
delay(50);
}
void SetBrightness(int level)
{
brightnessLevel = level;
targetBrightness = brightnessLevels[level];
if (level == 6)
redColours();
else
unRedColours();
EEPROM.write(7, brightnessLevel);
Serial.println("Writing brightnes to EEPROM");
}
//Don't write to the eepRom
void SetBrightnessTemp(int level)
{
brightnessLevel = level;
targetBrightness = brightnessLevels[level];
}