Issue trying to use NeoPixel Stick

Just wanted to thank everyone who helped me out with all my crazy questions. Here is the nearly completed project i’ve been working on.

3 Likes

Is there a way to disable the sleep mode on the proffie? Currently, and i dont know why, when the saber sleeps, the code i wrote doesnt run correctly upon wake up, the encoder pulses stop getting tracked or something because the motor just continues to run. I’m using this code to track the pulses

//setup code
attachInterrupt(digitalPinToInterrupt(ENCODER_B_PIN), encoderISR, RISING);
// Encoder Interrupt Service Routine (ISR)
void encoderISR() {
    unsigned long currentTime = micros();  // Use micros() instead of millis()
    if(motor_running) {
      if (currentTime - lastPulseTime > debounceDelay) {  // Only count valid pulses
          pulse_count++;  
          lastPulseTime = currentTime;  // Update timestamp
      }

      //pulse_count++;
      Serial.println("pulses while motor is running");
      Serial.println(pulse_count);
      
    }
}

It seems like attachInterrupt gets detached when the saber sleeps. Its hard to test because it doesn’t enter sleep mode when plugged into the serial port of the computer. Im hoping i can’t just disable the sleep mode in the config file.

You may have to be more specific, because ProffieOS doesn’t really have a sleep mode.
ProffieOS does have a something that clocks down the processor and puts delays in the main thread when it thinks nothing is happening, that code is here:

If the clock control code is the problem, you just need to call ClockControl_AvoidSleep() every now and then to keep it from doing that.

So, if only on battery power, if not used after x amount of time, the green led on the board turns off. If i press the button, the green led turns back on and the saber will work like normal. Is this not a sleep feature to save the battery?

Ill look into the code you provided.

That sounds like IDLE_OFF_TIME.
IDLE_OFF_TIME turns off blades after a timeout, but it does not make the CPU sleep, and it should not affect interrupts.

it’s hard to troubleshoot due to the fact i can’t watch the serial monitor. If it’s plugged into the serial port it doesnt sleep. Can i set this IDLE_OFF_TIME in the config file. Does IDLE_OFF_TIME turn the green LED off? If not, what causes the green LED to turn off after x amount of time idle?

Thanks, i’ll see if IDLE_OFF_TIME is the cause.

Also, in regards to ignition speed. I was reading in the forum about IgnitionTime<0>
My saber extends / retracts in 2 seconds. I’d love to be able to sync the ignition sound to the duration of my extension and also the same for retraction. Will the sound font play longer if the duration is changed? If so, how can i incorporate this functionality into my project, since I’m not using the blade styles.

Thanks for all the help!

Correct, you can use IgnitionTime<0> and RetractionTime<0> to sync to the wav files.

No, the sound doesn’t change if the value there is non-zero. Just the animation length.

What do you mean not using blade syles? (Sorry, admittedly I have not read through this whole thread)

ok, thanks for the info. I’ll just alter the two font wav files and make them fit my ignition and retraction durations. I got a custom setup with with a fully extendable / retractable blade, so i’m not using any blade effects. Check the video i posted earlier in this chat.