Skip to content

Create colorpicker module#4197

Open
RKBoss6 wants to merge 14 commits intoespruino:masterfrom
RKBoss6:color-picker
Open

Create colorpicker module#4197
RKBoss6 wants to merge 14 commits intoespruino:masterfrom
RKBoss6:color-picker

Conversation

@RKBoss6
Copy link
Copy Markdown
Contributor

@RKBoss6 RKBoss6 commented Mar 23, 2026

Creates colorpicker module as an easy way for apps to present users with a color selection menu.
I've been wanting a menu that could do this for a while, as the alternative before was to make a scroll menu with all the colors and have the users scroll through all of them, instead of being able to see them at a glance. Currently this only works on bangle.js 2, I'm not exactly sure how to convert it to bangle.js 1 as well. This can be used in places like clock_bg, where users need to select multiple colors, or even in the theme menu and other system-level places if the need arises.

This is my first module, so let me know if I need to do anything else or did something wrong :)

Single color mode:
d

Multi-select mode:
download (7)

You can look at an example implementation in the Clock Background app on my app loader, and just upload the module to your watch as colorpicker via web ide.

For bangle.js 1 compatibility, would the best course of action be to make the up/down buttons change the highlighted color, then a select is used to select it?

RKBoss6 added 3 commits March 23, 2026 09:28
Added documentation for the color picker module, including usage examples and options.
Added a period at the end of the module description and included an image.
Copilot AI review requested due to automatic review settings March 23, 2026 13:45
@RKBoss6 RKBoss6 marked this pull request as draft March 23, 2026 13:45
Copy link
Copy Markdown
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

Adds a new colorpicker module intended to provide a reusable, at-a-glance color selection UI for apps (targeted at Bangle.js 2 per PR description).

Changes:

  • Introduces modules/colorpicker.js implementing a grid-based color picker with optional full-screen preview.
  • Adds modules/colorpicker.md documenting usage and available options.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
modules/colorpicker.js New module that draws a color grid, handles touch/button input, and returns selected color via callback.
modules/colorpicker.md Documentation for integrating the module and configuring available options.

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

RKBoss6 added 2 commits March 23, 2026 10:07
Refactor color picker logic to handle empty color options and improve haptic feedback.
Added previewTimeout variable to manage color preview timeout.
@RKBoss6 RKBoss6 marked this pull request as ready for review March 23, 2026 15:21
@RKBoss6 RKBoss6 marked this pull request as draft March 23, 2026 18:05
@RKBoss6 RKBoss6 marked this pull request as ready for review March 24, 2026 11:43
@RKBoss6 RKBoss6 marked this pull request as draft March 24, 2026 16:27
@RKBoss6 RKBoss6 requested a review from Copilot March 24, 2026 16:27
Copy link
Copy Markdown
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


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

RKBoss6 and others added 4 commits March 24, 2026 13:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 ready for review March 26, 2026 02:17
@RKBoss6
Copy link
Copy Markdown
Contributor Author

RKBoss6 commented Mar 26, 2026

Alright, this is good to go now :)

Copy link
Copy Markdown
Collaborator

@bobrippling bobrippling left a comment

Choose a reason for hiding this comment

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

Nice idea, seems useful

There's a few mistakes that feel like they're a bit sloppy, is it from an AI or just some changes later on made only in one place?

}

function remove() {
if(previewTimeout)clearTimeout(previewTimeout);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we want:

Suggested change
if(previewTimeout)clearTimeout(previewTimeout);
if(previewTimeout)previewTimeout=clearTimeout(previewTimeout);

if(options.back){
options.back();
}else{
throw new Error("No back function provided");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this not already covered?

remove();
}
}else{
Bangle.haptic()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We test Bangle.haptic above but not here?

if (options.showPreview === undefined || options.showPreview) {
g.setColor(col);
g.fillRect(rect);
previewTimeout=setTimeout(remove, 0.7 * 1000);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we want to clear the timeout first?

@RKBoss6
Copy link
Copy Markdown
Contributor Author

RKBoss6 commented Mar 28, 2026

Ah - I didn't use ai, that was just me making silly mistakes :) I'll get to fixing these, but no promises when as I'll be on vacation this week

@bobrippling
Copy link
Copy Markdown
Collaborator

No worries, thanks for your honesty - let me know if anything isn't clear / if my comments could be more helpful :) And enjoy your vacation!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants