Skip to content

Add haptics functionality#4183

Draft
RKBoss6 wants to merge 13 commits intoespruino:masterfrom
RKBoss6:haptics
Draft

Add haptics functionality#4183
RKBoss6 wants to merge 13 commits intoespruino:masterfrom
RKBoss6:haptics

Conversation

@RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Feb 27, 2026

Since we now have the new Bangle.haptic() function and option, this updates settings and boot to allow you to show and modify enabling/disabling haptics, and the strength. In bootupdate, it adds a line in boot0 to keep it persistent. More info is here

Copilot AI review requested due to automatic review settings February 27, 2026 17:34
Added information about Haptics settings for devices with firmware version 2v29.14 and customization options for haptic strength.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds haptics functionality support to the Bangle.js settings and boot system, enabling users to configure haptic feedback for devices with firmware 2v29.14+. The changes introduce UI controls to enable/disable haptics and adjust feedback strength, while ensuring persistence across reboots through boot0 updates.

Changes:

  • Added haptics configuration settings with default values (enabled: true, strength: 25)
  • Implemented a new "Haptics" menu in system settings with toggle and strength slider controls
  • Updated bootupdate to persist haptics settings by adding Bangle.setOptions calls to boot0

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
apps/setting/settings.min.json Added hapticsEnabled and hapticStrength default values to the settings template
apps/setting/settings.js Added hapticsEnabled and hapticStrength to resetSettings(), created hapticsMenu() function with enable/disable toggle and strength slider, integrated menu into systemMenu() when Bangle.haptic is available
apps/setting/metadata.json Bumped version from 0.82 to 0.83
apps/setting/ChangeLog Documented addition of Haptics section for firmware 2v29.14+
apps/boot/metadata.json Bumped version from 0.69 to 0.70
apps/boot/bootupdate.js Added logic to generate Bangle.setOptions({hapticTime: value}) in boot0 based on hapticsEnabled and hapticStrength settings, with backwards compatibility for undefined settings
apps/boot/ChangeLog Documented addition of haptic settings support for firmware 2v29.14+

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

settings.hapticsEnabled=v;
if(!v){
Bangle.setOptions({hapticTime:0})
}else{
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after "else". For consistency with the rest of the codebase, format as "} else {".

Suggested change
}else{
} else {

Copilot uses AI. Check for mistakes.
onchange: function (v) {
settings.hapticsEnabled=v;
if(!v){
Bangle.setOptions({hapticTime:0})
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces around curly braces. For consistency with the rest of the codebase, format as "{ hapticTime: 0 }".

Copilot uses AI. Check for mistakes.
popMenu(systemMenu());
},
/*LANG*/'Use Haptics': {
value: !!settings.hapticsEnabled, // strength 0 = disabled
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistency in handling undefined hapticsEnabled. When upgrading from an older version without haptics settings, bootupdate.js (line 81) treats undefined as enabled (defaulting to strength 25), but this UI element treats undefined as disabled (!!undefined = false). This means after upgrade, haptics will be active but the UI will show them as disabled. Consider handling undefined explicitly to match the bootupdate.js behavior: "value: settings.hapticsEnabled !== false" or "value: settings.hapticsEnabled === undefined ? true : settings.hapticsEnabled".

Suggested change
value: !!settings.hapticsEnabled, // strength 0 = disabled
value: settings.hapticsEnabled !== false, // strength 0 = disabled; undefined defaults to enabled

Copilot uses AI. Check for mistakes.
RKBoss6 and others added 2 commits February 27, 2026 12:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@RKBoss6 RKBoss6 marked this pull request as draft February 27, 2026 18:41
// Apply any settings-specific stuff
if (s.options) boot+=`Bangle.setOptions(${E.toJS(s.options)});\n`;
if (s.brightness!==undefined && s.brightness!=1) boot+=`Bangle.setLCDBrightness(${s.brightness});\n`;
if (Bangle.haptic) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's if (s.options) boot+=Bangle.setOptions(${E.toJS(s.options)}); 2 lines above, so I don't think this is needed. Literally all you need to do is ensure that the setting you change is s.options.hapticTime and not s.hapticStrength?

And rather that having a whole new menu, can we not just have a single menu item for Haptic Strength that's got a value, or Off which maps to zero? That seems way easier, and needs less taps to change things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good - is there any way to force the swipe menu for numbers to be displayed? I rather like that style of displaying/changing , and it looks nice particularly for changes like these...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set noList:true on the object - or it'll do it automatically if there would have been more than 20 menu items (eg you set the step small enough)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants