Skip to content

Commit

Permalink
Fix: off by one on the euclide sequence. how embarassing!
Browse files Browse the repository at this point in the history
  • Loading branch information
poetaster committed Jun 20, 2024
1 parent 04c5e47 commit 7e7c602
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions firmware/Pikobeats/Pikobeats.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions firmware/Pikobeats/euclid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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) {
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion firmware/Pikobeats/euclid.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#define NUMBER_OF_STEPS 16
#define NUMBER_OF_STEPS 15

class euclid {

Expand Down

0 comments on commit 7e7c602

Please sign in to comment.