The moment i want to do a action to the display the Wemos does a hard reset.
Doesn't matter if the interrupt is triggered or not.
I'm at it for over 2 days and still i'm nowhere near to get it working.
I'm not even a step closer than when i started.
Please please help
#define InterruptPIN D6
My Libs:
#include <Arduino.h>
#define FASTLED_INTERNAL
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include <FastLED.h>
My Interrupt:
void ISRC() {
buttonState = digitalRead(InterruptPIN);
last = millis() - lastDebounceTime;
if ( last > debounceDelay) {if ( buttonState == LOW ){
Serial.println("Interrupt Detected");
if(_state == 0)
{
msg = "0-NanoHex Ring";
stepRing = true;
stepLED = false;
_state = 1;
p = NanoHex(NUM_RINGS, NUM_LEDS_RING, stepRing, stepLED);
}
else if(_state == 1)
{
msg = "1-NanoHex LED";
stepRing = true;
stepLED = true;
_state = 2;
p = NanoHex(NUM_RINGS, NUM_LEDS_RING, stepRing, stepLED);
}
else if(_state == 2)
{
msg = "2-NanoHex";
stepRing = false;
stepLED = false;
_state = 3;
p = NanoHex(NUM_RINGS, NUM_LEDS_RING, stepRing, stepLED);
} else if(_state == 3)
{
msg = "3-Test 0 pos";
_state = 0;
}
// TODO: Add Fire
Serial.print("stepRing: ");
Serial.println(stepRing);
Serial.print("stepLED: ");
Serial.println(stepLED);
Serial.print("State2: ");
Serial.println(buttonState);
}
lastDebounceTime = millis(); //set the current time
}
}
My Void:
void loop() {
// put your main code here, to run repeatedly:
if(ScreenBacklightOff.ready() && isOn){
isOn = false;
detachInterrupt(digitalPinToInterrupt(InterruptPIN));
delay(40);
//lcd.off();
attachInterrupt(digitalPinToInterrupt(InterruptPIN), ISRC, FALLING);
}if(OldMsg != msg){
detachInterrupt(digitalPinToInterrupt(InterruptPIN));
delay(40);
if(isOn == false){
//lcd.on();
isOn = true;
}
lcd.clear();
lcd.print(msg);
OldMsg = msg;
delay(40);
attachInterrupt(digitalPinToInterrupt(InterruptPIN), ISRC, FALLING);
}if(oneSec.ready()){
Serial.print("Do NaNoHex stuff => ");
Serial.println(x);
if(_state == 0 || _state == 1 || _state == 2){
Serial.println(msg);
p.Draw();
} else if(_state == 3){
Serial.println(msg);
t.Draw();
} else if(_state == 4){
Serial.println(msg);
FastLED.clear();
f.DrawFire();
FastLED.show(g_Brightness);
}
Serial.print("State => ");
Serial.println(_state);
x++;
}