Skip to content

Want to Respond to Alarm with Button Click #3752

@voloved

Description

@voloved

Hello,

My goal is to be able to press the physical button to end an alarm.
My use-case is that I often wake up before my alarm, so I have a buzzing watch on my wrist while driving to work and I don't want to navigate with the touchscreen while driving to silence it.

Plan is to add a function called E.showPromptBtnCancel in apps/sched/sched.js. From looking at the code, this is the function that runs when an alarm is called. I am modifying it according to this doc.

I am running into multiple issues:

  1. How do I modify E.showPrompt to treat BTN1 the same way as cancel?
    a. I see this logic:Bangle.setUI({mode: "leftright", remove: options.remove, redraw:draw, back:options.back}, dir=>{, but I cannot find the definition of leftright or what dir returns in the References. My hope is that BTN1 is also a callback coming from leftright, but I want to make sure.
  2. I am unit-testing E.showPromptBtnCancel in a simple app here and whenever I run this code on my watch, it hangs on a loading screen forever and a reset of the watch is needed. I tested this code on the Web IDE emulator and got no issues. Is there something I'm doing wrong when moving from Simulating to testing on hardware?
  3. When copying the default showPrompt logic, it always returns that I pressed the first option. The snippet below is how I call showPrompt in my testing. I first use the default function and Stop pressed prints when I press Stop. But when I copy the default logic, the screen appears the same, but Snooze Pressed diplays when I press Stop. Is the default function I'm referencing in the repo up-to-date?
E.showPrompt("the", Also, { if there is a forum or Discord that I can join, please let me know!
title: "ALARM!",
buttons: { /*LANG*/"Snooze": true, /*LANG*/"Stop": false }
}).then(ok => {
if (ok) print("snooze pressed");
else print("stop pressed");
});

Edit: I found my mistake on items 2 and 3; in the modifications doc, it notes that _Q3 is used for Bangle.js 2, so I was supposed to be using this as my default.

Edit2: I got item 1 working how I want. Here's how.

Please let me know if there's anything I'm misunderstanding or if there are resources I missed.
Also, if there is a forum or Discord that I can join, please let me know!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions