final tuning of amulett

Signed-off-by: dragonchaser <christian@boltares.de>
This commit is contained in:
dragonchaser
2025-07-17 14:07:24 +02:00
parent a8882e4ff1
commit 4909290117

View File

@@ -31,9 +31,9 @@ void Vibrate();
// LED configuration // LED configuration
#define LED_TYPE WS2812B #define LED_TYPE WS2812B
#define LED_DATA_PIN 1 // use 1 for GPIO 1 and 21 for builtin #define LED_DATA_PIN 21 // use 1 for GPIO 1 and 21 for builtin
#define LED_NUM_LEDS 7 // use 1 for builtin and whatever your count is for extern #define LED_NUM_LEDS 7 // use 1 for builtin and whatever your count is for extern
#define LED_COLOR_ORDER RGB // USE GRB for the onboard led and RGB for the chain #define LED_COLOR_ORDER GRB // USE GRB for the onboard led and RGB for the chain
#define LED_BRIGHTNESS 96 #define LED_BRIGHTNESS 96
#define LED_BRIGHTNESS_DIMM 16 #define LED_BRIGHTNESS_DIMM 16
@@ -44,9 +44,8 @@ void Vibrate();
// VIBRATION MOTOR configuration // VIBRATION MOTOR configuration
#define VIBRO_PIN 2 #define VIBRO_PIN 2
#define VIBRO_REPEAT 3 #define VIBRO_REPEAT 10
#define VIBRO_SMALL_DELAY 100 #define VIBRO_DELAY 250
#define VIBRO_BIG_DELAY 500
// DATA maintenance configuration // DATA maintenance configuration
#define UPDATE_INTERVAL 10000 // how often do we update de database? #define UPDATE_INTERVAL 10000 // how often do we update de database?
@@ -61,7 +60,7 @@ void Vibrate();
#define MIN_RSSI_POWER -50 #define MIN_RSSI_POWER -50
// Use Serial interface for debugging true|false // Use Serial interface for debugging true|false
#define USE_SERIAL false #define USE_SERIAL true
// CONSTS // CONSTS
static const PROGMEM std::map<String, String> overrideColors = { static const PROGMEM std::map<String, String> overrideColors = {
@@ -77,7 +76,7 @@ static const PROGMEM std::map<String, void*> blackList = {
#define DEVICE_TYPE_PRIVATE_LAMP 3 #define DEVICE_TYPE_PRIVATE_LAMP 3
#define DEVICE_TYPE_AMULETT 4 #define DEVICE_TYPE_AMULETT 4
#define DEVICE_TYPE DEVICE_TYPE_PUBLIC_LAMP #define DEVICE_TYPE DEVICE_TYPE_AMULETT
#ifndef DEVICE_TYPE #ifndef DEVICE_TYPE
// WE DO NOT HAVE A DEVICETYPE, so we do not have any variables here // WE DO NOT HAVE A DEVICETYPE, so we do not have any variables here
@@ -145,6 +144,8 @@ volatile uint8_t stepSegments;
TimerEvent updateTimer; TimerEvent updateTimer;
uint8_t vibrationCount = 0;
class AdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks { class AdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) { void onResult(BLEAdvertisedDevice advertisedDevice) {
if (advertisedDevice.getRSSI() > MIN_RSSI_POWER) { if (advertisedDevice.getRSSI() > MIN_RSSI_POWER) {
@@ -184,8 +185,8 @@ class AdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
// when the device is not in the database yet, vibrate on first connect // when the device is not in the database yet, vibrate on first connect
if (useVibro) { if (useVibro) {
auto it = deviceDatabase.find(color); auto it = deviceDatabase.find(color);
if (it != deviceDatabase.end()) { if (it == deviceDatabase.end()) {
Vibrate(); vibrationCount = VIBRO_REPEAT;
} }
} }
@@ -267,6 +268,10 @@ void loop() {
} }
FillLEDsFromPaletteColors((startindex++) % LED_PALETTE_SIZE); FillLEDsFromPaletteColors((startindex++) % LED_PALETTE_SIZE);
FastLED.show(); FastLED.show();
if (useVibro && vibrationCount > 0) {
Vibrate();
vibrationCount--;
}
FastLED.delay(1000/LED_FRAMES_PER_SECOND); FastLED.delay(1000/LED_FRAMES_PER_SECOND);
} }
@@ -327,13 +332,9 @@ void UpdatePalette() {
// Causes the vibration motor to vibrate // Causes the vibration motor to vibrate
void Vibrate() { void Vibrate() {
for (int i = 0; i < VIBRO_REPEAT; i++) { for (int j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) { digitalWrite(VIBRO_PIN, HIGH);
delay(VIBRO_SMALL_DELAY); delay(VIBRO_DELAY);
digitalWrite(VIBRO_PIN, HIGH); digitalWrite(VIBRO_PIN, LOW);
delay(VIBRO_SMALL_DELAY);
digitalWrite(VIBRO_PIN, LOW);
}
delay(VIBRO_BIG_DELAY);
} }
} }