code comments added, rotary encoder overflow fixed

This commit is contained in:
2025-05-27 16:34:14 +02:00
parent 6ceefa6705
commit 8691bc05eb
2 changed files with 18 additions and 8 deletions

View File

@ -124,10 +124,12 @@ void loop() {
// Serial.println(ENC.getRevolutions());
// }
// LED Ring leeren
for (int i = 0; i < 48; i++) {
ui_pixels.setPixelColor(i + 3, edge_pixels.Color(0, 0, 0));
}
// flag = true when a button is pushed
if (flag) {
int val = TCA.read16();
Serial.println(val, BIN);
@ -143,6 +145,7 @@ void loop() {
if (HAPTIC) {
digitalWrite(6, HIGH);
}
// Make beep
if (AURAL) {
digitalWrite(7, HIGH);
click = true;
@ -150,19 +153,21 @@ void loop() {
click = false;
digitalWrite(7, LOW);
}
// Make vibration
if(HAPTIC){
if(!AURAL) delay(50);
digitalWrite(6, LOW);
}
// Flash led ring
for (int i = 0; i < 48; i++) {
ui_pixels.setPixelColor(i + 3, edge_pixels.Color(0, 15, 0));
}
// Switch through LED matrix
if(buttons[RIGHT]) active++;
if(buttons[LEFT]) active--;
if(active == 13) active = 0;
if(active == -1) active = 12;
}
// 11111110 11111111 button right
// EDGE LEDs
for (int i = 0; i < 8; i++) {
@ -174,18 +179,22 @@ void loop() {
ui_pixels.setPixelColor(1, edge_pixels.Color(0, 0, 15));
ui_pixels.setPixelColor(2, edge_pixels.Color(0, 0, 15));
// empty LED matrix
for (int i = 0; i < 13; i++) {
ui_pixels.setPixelColor(i + 3 + 48 + 4, edge_pixels.Color(0, 0, 0));
}
// set active LED matrix LED
ui_pixels.setPixelColor(active + 3 + 48 + 4, edge_pixels.Color(255, 255, 255));
active_led_ring = abs((position / 256) % 48);
if(position < 0) position += 4096;
active_led_ring = (position / 32) % 48;
// set active LED ring LED
ui_pixels.setPixelColor(active_led_ring + 3, edge_pixels.Color(255, 255, 255));
// put your main code here, to run repeatedly:
edge_pixels.show(); // Set all pixel colors to 'off'
ui_pixels.show(); // Set all pixel colors to 'off'
edge_pixels.show();
ui_pixels.show();
delay(1);
delay(1); // wait 1ms
}