You are reading a single comment by @HughB and its replies. Click here to read the full conversation.
  • I'm trying a clock_info to simplest clock.
    I have done a new version of simplest clock that uses the new clock loading style. IE all the code between an opening and closing brace.

    I'm getting the following error on the console when I try BTN1 and BTN3.

    1. >
    2. Uncaught Error: Function "d" not found!
    3. at line 1 col 15
    4. 120>e.x||(k(),d(88<e.y?1:-1))
    5. ^
    6. in function called from system
    7. >

    Here's my code for simplest clock

    1. {
    2. // must be inside our own scope here so that when we are unloaded everything disappears
    3. // we also define functions using 'let fn = function() {..}' for the same reason. function decls are global
    4. const h = g.getHeight();
    5. const w = g.getWidth();
    6. let draw = function() {
    7. var date = new Date();
    8. var timeStr = require("locale").time(date,1);
    9. g.reset();
    10. g.setColor(g.theme.bg);
    11. g.fillRect(Bangle.appRect);
    12. g.setFont('Vector', w/3);
    13. g.setFontAlign(0, 0);
    14. g.setColor(g.theme.fg);
    15. g.drawString(timeStr, w/2, h/2);
    16. // schedule a draw for the next minute
    17. if (drawTimeout) clearTimeout(drawTimeout);
    18. drawTimeout = setTimeout(function() {
    19. drawTimeout = undefined;
    20. draw();
    21. }, 60000 - (Date.now() % 60000));
    22. };
    23. // future use
    24. let prevInfo = function() {
    25. console.log("prevInfo");
    26. };
    27. // future use
    28. let nextInfo = function() {
    29. console.log("nextInfo");
    30. };
    31. // timeout used to update every minute
    32. var drawTimeout;
    33. g.clear();
    34. // Show launcher when middle button pressed, add updown button handlers
    35. Bangle.setUI({
    36. mode : "clockupdown",
    37. btn : function (n) {
    38. if (n<0) prevInfo();
    39. if (n>0) nextInfo();
    40. draw();
    41. }
    42. });
    43. // Load widgets
    44. Bangle.loadWidgets();
    45. draw();
    46. setTimeout(Bangle.drawWidgets,0);
    47. } // end of clock
About

Avatar for HughB @HughB started