From 7e7c6023ab4290352b303fd02bbda9ce0cb899b7 Mon Sep 17 00:00:00 2001 From: Mark Washeim Date: Thu, 20 Jun 2024 13:36:24 +0200 Subject: [PATCH] Fix: off by one on the euclide sequence. how embarassing! --- firmware/Pikobeats/Pikobeats.ino | 3 +++ firmware/Pikobeats/euclid.cpp | 8 ++++++-- firmware/Pikobeats/euclid.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/firmware/Pikobeats/Pikobeats.ino b/firmware/Pikobeats/Pikobeats.ino index afde3f4..48a1574 100644 --- a/firmware/Pikobeats/Pikobeats.ino +++ b/firmware/Pikobeats/Pikobeats.ino @@ -81,6 +81,7 @@ Adafruit_SH1106G display = Adafruit_SH1106G(128, 64, &Wire); #define bigfont helvnCB6pt7b // from pikocore for bpm calcs on clk input +// this is unused, deprecate? #include "runningavg.h" RunningAverage ra; volatile int clk_display; @@ -95,8 +96,10 @@ unsigned int SWPin = CLOCKIN; #define TIMER0_INTERVAL_MS 1 #define DEBOUNCING_INTERVAL_MS 2// 80 #define LOCAL_DEBUG 1 + // Init RPI_PICO_Timer, can use any from 0-15 pseudo-hardware timers RPI_PICO_Timer ITimer0(0); + volatile unsigned long rotationTime = 0; float RPM = 0.00; float avgRPM = 0.00; diff --git a/firmware/Pikobeats/euclid.cpp b/firmware/Pikobeats/euclid.cpp index 5cdb5d5..72e964e 100644 --- a/firmware/Pikobeats/euclid.cpp +++ b/firmware/Pikobeats/euclid.cpp @@ -56,13 +56,16 @@ void euclid::generateRandomSequence( uint8_t fills, uint8_t steps){ } void euclid::rotate(uint8_t _steps){ + //Serial.println(this->textSequence); for(int i=0;i<_steps;i++){ - bool temp=euclidianPattern[numberOfSteps]; + bool temp=euclidianPattern[numberOfSteps-1]; for(int j=numberOfSteps;j>0;j--){ euclidianPattern[j]=euclidianPattern[j-1]; } euclidianPattern[0]=temp; } + setTextSequence(); + //Serial.println(this->textSequence); } bool euclid::getStep(uint8_t _step){ @@ -71,6 +74,7 @@ bool euclid::getStep(uint8_t _step){ bool euclid::getCurrentStep(){ return euclidianPattern[stepCounter]; } + void euclid::setRepeats(uint8_t _repeats){ this->repeats = this->repeats + _repeats; if (repeats < 0) { @@ -87,7 +91,7 @@ uint8_t euclid::getRepeats(){ void euclid::setTextSequence(){ for (int i = 0; i < NUMBER_OF_STEPS; i++) textSequence[i] = (euclidianPattern[i] == 0) ? '0' : '1'; - textSequence[NUMBER_OF_STEPS+1] = '\0'; + //textSequence[NUMBER_OF_STEPS+1] = '\0'; //Serial.println(textSequence); } diff --git a/firmware/Pikobeats/euclid.h b/firmware/Pikobeats/euclid.h index 99331e0..919f498 100644 --- a/firmware/Pikobeats/euclid.h +++ b/firmware/Pikobeats/euclid.h @@ -1,5 +1,5 @@ #pragma once -#define NUMBER_OF_STEPS 16 +#define NUMBER_OF_STEPS 15 class euclid {