added vibration notifications

This commit is contained in:
Gareth Coleman 2024-04-18 09:22:31 +01:00
parent 172d271b0b
commit 4b5549be8f

View File

@ -145,20 +145,16 @@ int32_t ExternalNotificationModule::runOnce()
#endif #endif
#ifdef UNPHONE #ifdef UNPHONE
if (rgb_found.type == ScanI2C::RGBLED_CA) { red = colorState & 4; // Red enabled on colorState = 4,5,6,7
red = colorState & 4; // Red enabled on colorState = 4,5,6,7 green = colorState & 2; // Green enabled on colorState = 2,3,6,7
green = colorState & 2; // Green enabled on colorState = 2,3,6,7 blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7
blue = colorState & 1; // Blue enabled on colorState = 1,3,5,7 unphone.rgb(red, green, blue);
unphone.rgb(red, green, blue); counter++; // tick on
LOG_DEBUG("RGB runOnce: %i, %i, %i\n", red, green, blue); if (counter > duration) {
counter = 0;
counter++; // tick on colorState++; // next color
if (counter > duration) { if (colorState > 7) {
counter = 0; colorState = 1;
colorState++; // next color
if (colorState > 7) {
colorState = 1;
}
} }
} }
#endif #endif
@ -209,6 +205,9 @@ void ExternalNotificationModule::setExternalOn(uint8_t index)
switch (index) { switch (index) {
case 1: case 1:
#ifdef UNPHONE
unphone.vibe(true); // the unPhone's vibration motor is on a i2c GPIO expander
#endif
if (moduleConfig.external_notification.output_vibra) if (moduleConfig.external_notification.output_vibra)
digitalWrite(moduleConfig.external_notification.output_vibra, true); digitalWrite(moduleConfig.external_notification.output_vibra, true);
break; break;
@ -228,9 +227,7 @@ void ExternalNotificationModule::setExternalOn(uint8_t index)
} }
#endif #endif
#ifdef UNPHONE #ifdef UNPHONE
if (rgb_found.type == ScanI2C::RGBLED_CA) { unphone.rgb(red, green, blue);
unphone.rgb(red, green, blue);
}
#endif #endif
#ifdef T_WATCH_S3 #ifdef T_WATCH_S3
drv.go(); drv.go();
@ -244,6 +241,9 @@ void ExternalNotificationModule::setExternalOff(uint8_t index)
switch (index) { switch (index) {
case 1: case 1:
#ifdef UNPHONE
unphone.vibe(false); // the unPhone's vibration motor is on a i2c GPIO expander
#endif
if (moduleConfig.external_notification.output_vibra) if (moduleConfig.external_notification.output_vibra)
digitalWrite(moduleConfig.external_notification.output_vibra, false); digitalWrite(moduleConfig.external_notification.output_vibra, false);
break; break;
@ -266,12 +266,10 @@ void ExternalNotificationModule::setExternalOff(uint8_t index)
} }
#endif #endif
#ifdef UNPHONE #ifdef UNPHONE
if (rgb_found.type == ScanI2C::RGBLED_CA) { red = 0;
red = 0; green = 0;
green = 0; blue = 0;
blue = 0; unphone.rgb(red, green, blue);
unphone.rgb(red, green, blue);
}
#endif #endif
#ifdef T_WATCH_S3 #ifdef T_WATCH_S3
drv.stop(); drv.stop();