• hi,

    the "alarm and timer ETA" widget currently dont show stopwatch e.g. "stopwatch touch" at the status bar.

    I would like to change that.

    indeed with the "digital clock widget", we can have clock in status bar and stopwatch in the app;
    so i wish at the clock face, we can have time + stopwatch too.

    ps: this beat the legends like casio f-91, which can only show either clock OR stopwatch, but not both:

    I briefly asked gpt4,
    let's see how good it is later.
    :
    You can extend the widget to support the stopwatch by modifying the code to consider the stopwatch's state and time. Here is a modified version of your provided code that should incorporate the stopwatch's display into the widget. The main idea is to read the stopwatch's state and remaining time from its JSON storage and display it on the widget if it's running.

    1. Update the loadSettings function to also load the stopwatch settings.
    2. Modify the draw function to consider the stopwatch state and display its time if it's running.
    3. Make necessary adjustments in other parts of the code to accommodate the stopwatch display.

    Here is the modified version of your provided widget code to incorporate the stopwatch:

    javascript
    (() => {
      let config, stopwatchConfig;
    
      function loadSettings() {
        config = Object.assign({
          // ... (your existing settings)
        }, require("Storage").readJSON("widalarmeta­.json",1) || {});
    
        stopwatchConfig = require("Storage").readJSON("stopwatch.j­son",1) || {};
    
        // ... (your existing code to load fonts, etc.)
      }
      loadSettings();
    
      // ... (your existing functions like getNextAlarm)
    
      function draw(_w, fromInterval) {
        let next;
    
        if (stopwatchConfig.state && stopwatchConfig.state.running) {
          next = Date.now() - stopwatchConfig.state.start;
        } else {
          if (this.nextAlarm === undefined) {
            let alarm = getNextAlarm();
            // ... (your existing code)
          }
          next = this.nextAlarm !== undefined ? require("sched").getTimeToAlarm(this.nex­tAlarm) : 0;
        }
    
        // ... (your existing code to display time, handle font and width calculations, etc.)
    
        // Add an additional condition to redraw if the stopwatch is running
        const period = stopwatchConfig.state.running ? 1000 :
                       next === 0 ? 3600000 :
                       (drawSeconds ? 1000 : 60000);
    
        // ... (your existing code to set timeout and redraw, etc.)
      }
    
      // ... (your existing code to add the widget and other functionalities, etc.)
    })();
    

    Changes made:

    • Loaded the stopwatch settings along with the alarm settings.
    • Checked if the stopwatch is running and updated the next variable accordingly.
    • Added an additional condition to set the redraw period to every second if the stopwatch is running to update the stopwatch display in real-time.

    You might need to adjust the display format or layout as per your needs. Ensure to test thoroughly to make sure it works as expected and doesn’t interfere with other functionalities.

  • How about installing the 'clockinfo widget'? 'clockinfo' can include alarms, timers and stopwatch right now - so all you need to do is install that widget and the relevant other clockinfo apps and you can swipe through them

  • hi, thx for suggestion.
    however i found the "stopwatch touch" very attractive,
    i'll rather contact the author for more info as he claimed also keen to make it into the widget, thanks

  • Thanks for the tip, wasn't aware of that widget!

  • is there a central organization place/scheme for the alarms, timers, stopwatch or indeep each of these apps work on their own?

    i mean, bangle got several stopwatch apps. will a single widget grab info from all of them by some system calls or indeep these stopwatches currently only work on their own?

    thanks

  • is there a central organization place/scheme for the alarms, timers, stopwatch or indeep each of these apps work on their own?

    There is the scheduler library that should be used for these things. Some older apps have still not been refactored with it.

    The scheduler was discussed here prior to its introduction: https://github.com/espruino/BangleApps/i­ssues/1555.

  • this library doesn't include the stopwatch?

    i'll then see should i modify specific for "stopwatch touch" or modify the library then.

    thanks

  • Ah, sorry. Yes I don't think stopwatch functionality is included in sched library. I guess stopwatches aren't really used for scheduling things 😉

  • able to display the current time + alarm/ETA, timer, stopwatch etc is superior to classic casio watches.

    but currenlty those timer/stop watchers work on their own, and may even stop counting when swiped back to the clock. in future should have centralized them?

    thanks

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[BJv2, 0%] Modify Alarm&Timer widget so it also show "stopwatch" esp "stopwatch touch".

Posted by Avatar for ccchan @ccchan

Actions