Merge branch 'master' of https://git.binary-kitchen.de/buddhabrot/fusion-zauberstab
This commit is contained in:
commit
823a377235
@ -2,12 +2,19 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
|
#include<Wire.h>
|
||||||
|
#include<ADXL345_WE.h>
|
||||||
|
|
||||||
|
#define ADXL345_I2CADDR 0x53 // 0x1D if SDO = HIGH
|
||||||
|
|
||||||
#define LED_PIN 12
|
#define LED_PIN 12
|
||||||
#define NUM_LEDS 144
|
#define NUM_LEDS 48
|
||||||
#define MIC_PIN 15
|
#define MIC_PIN 15
|
||||||
|
|
||||||
extern CRGB leds[NUM_LEDS];
|
extern CRGB leds[NUM_LEDS];
|
||||||
|
extern ADXL345_WE myAcc;
|
||||||
|
|
||||||
int zauberstab_init();
|
int zauberstab_init();
|
||||||
float get_sample();
|
float get_sample();
|
||||||
|
void switch_app();
|
||||||
|
bool acc_has_event();
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
[env]
|
[env]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = fastled/FastLED @ ^3.5.0
|
lib_deps =
|
||||||
|
fastled/FastLED @ ^3.5.0
|
||||||
|
wollewald/ADXL345_WE @ ^2.1.4
|
||||||
|
|
||||||
[env:esp32doit-devkit-v1]
|
[env:esp32doit-devkit-v1]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
|
@ -22,25 +22,72 @@ std::vector<std::reference_wrapper<App>> apps = {
|
|||||||
std::ref<App>(fackel_app)
|
std::ref<App>(fackel_app)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
unsigned int current_app = 1;
|
unsigned int current_app = 1;
|
||||||
unsigned int next_app;
|
unsigned int next_app;
|
||||||
|
=======
|
||||||
|
static unsigned int current_app = 0;
|
||||||
|
static unsigned int next_app;
|
||||||
|
static bool init_successfull = false;
|
||||||
|
static bool sleep_active=false;
|
||||||
|
|
||||||
|
void switch_app() {
|
||||||
|
if (!sleep_active) {
|
||||||
|
next_app = current_app + 1;
|
||||||
|
} else {
|
||||||
|
sleep_active = false;
|
||||||
|
next_app = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next_app >= apps.size()) {
|
||||||
|
next_app = 0;
|
||||||
|
// Turn off leds before going to sleep
|
||||||
|
fadeToBlackBy(leds, NUM_LEDS, 0xFF);
|
||||||
|
FastLED.show();
|
||||||
|
|
||||||
|
//configure wakeup source
|
||||||
|
esp_sleep_enable_ext0_wakeup(GPIO_NUM_4, 1);
|
||||||
|
|
||||||
|
//bedtime
|
||||||
|
sleep_active = true;
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
next_app = next_app % apps.size();
|
||||||
|
}
|
||||||
|
>>>>>>> update main app handling to include an off state
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
next_app = current_app;
|
next_app = current_app;
|
||||||
|
<<<<<<< HEAD
|
||||||
zauberstab_init();
|
zauberstab_init();
|
||||||
//Serial.begin(115200);
|
//Serial.begin(115200);
|
||||||
|
=======
|
||||||
|
if (zauberstab_init() != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Serial.begin(115200);
|
||||||
|
>>>>>>> update main app handling to include an off state
|
||||||
|
|
||||||
|
init_successfull = true;
|
||||||
apps[current_app].get().init();
|
apps[current_app].get().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
/* EVERY_N_SECONDS(30)
|
if (!init_successfull) {
|
||||||
{
|
return;
|
||||||
next_app++;
|
}
|
||||||
next_app = next_app % apps.size();
|
|
||||||
} */
|
if (acc_has_event()) {
|
||||||
|
String axes = myAcc.getActTapStatusAsString();
|
||||||
|
byte intSource = myAcc.readAndClearInterrupts();
|
||||||
|
|
||||||
|
if (myAcc.checkInterrupt(intSource, ADXL345_DOUBLE_TAP)) {
|
||||||
|
switch_app();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (next_app != current_app)
|
if (next_app != current_app)
|
||||||
{
|
{
|
||||||
|
@ -4,16 +4,42 @@
|
|||||||
DcCancelation<float> dc_blocker{0.95};
|
DcCancelation<float> dc_blocker{0.95};
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
static int16_t mic_offset = 0;
|
static int16_t mic_offset = 0;
|
||||||
|
static bool acc_event = false;
|
||||||
|
ADXL345_WE myAcc = ADXL345_WE(ADXL345_I2CADDR);
|
||||||
|
|
||||||
static uint16_t read_mic()
|
static uint16_t read_mic()
|
||||||
{
|
{
|
||||||
return analogRead(MIC_PIN);
|
return analogRead(MIC_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void double_tab_int() {
|
||||||
|
acc_event = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool acc_has_event() {
|
||||||
|
return acc_event;
|
||||||
|
}
|
||||||
|
|
||||||
int zauberstab_init()
|
int zauberstab_init()
|
||||||
{
|
{
|
||||||
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
|
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
|
||||||
|
FastLED.addLeds<WS2812, 14, GRB>(leds, NUM_LEDS);
|
||||||
|
FastLED.addLeds<WS2812, 27, GRB>(leds, NUM_LEDS);
|
||||||
// FastLED.setMaxPowerInVoltsAndMilliamps(5, 300);
|
// FastLED.setMaxPowerInVoltsAndMilliamps(5, 300);
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
if (!myAcc.init()){
|
||||||
|
Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
myAcc.setDataRate(ADXL345_DATA_RATE_200);
|
||||||
|
myAcc.setRange(ADXL345_RANGE_8G);
|
||||||
|
myAcc.setGeneralTapParameters(ADXL345_XY0, 3.0, 30, 100.0);
|
||||||
|
myAcc.setAdditionalDoubleTapParameters(false, 250);
|
||||||
|
myAcc.setInterrupt(ADXL345_DOUBLE_TAP, INT_PIN_1);
|
||||||
|
attachInterrupt(digitalPinToInterrupt(4), double_tab_int, RISING);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user