Guest User

Untitled

a guest
Oct 5th, 2021
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. import Toybox.Graphics;
  2. import Toybox.Lang;
  3. import Toybox.System;
  4. import Toybox.WatchUi;
  5. using Toybox.ActivityMonitor as Act;
  6. using Toybox.Activity as Acty;
  7. using Toybox.Time.Gregorian;
  8.  
  9. class DigitalElegantView extends WatchUi.WatchFace {
  10. function initialize() {
  11. WatchFace.initialize();
  12. }
  13. var today = Gregorian.info(Time.now(), Time.FORMAT_MEDIUM);
  14. var dateString = Lang.format(
  15. "$1$ $2$ $3$",
  16. [
  17. today.day_of_week,
  18. today.month,
  19. today.day,
  20.  
  21. ]
  22. ).toUpper();
  23.  
  24. function onLayout(dc as Dc) as Void {}
  25.  
  26. function onShow() as Void {}
  27.  
  28. function onUpdate(dc as Dc) as Void {
  29. dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
  30. dc.clear();
  31. var clockTime = System.getClockTime();
  32. var hour = clockTime.hour;
  33. if (!System.getDeviceSettings().is24Hour) {
  34. hour = hour % 12;
  35. if (hour == 0) {
  36. hour = 12;
  37. }
  38. }
  39.  
  40. function make1224(hr) {
  41. var myHr=hr;
  42. var myAmPm="";
  43.  
  44. if(!is24Hour) {
  45. myHr = hr % 12;
  46. myHr = (myHr == 0) ? 12 : myHr;
  47. myAmPm= (hr>=12) ? "p" : "a";
  48. }
  49. return [myHr,myAmPm];
  50. }
  51.  
  52. // Get and show the current time
  53. dc.setColor(SelectedColor, Graphics.COLOR_TRANSPARENT);
  54. dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, Lang.format("$1$", [clockTime.hour.format("%02d")]), Graphics.TEXT_JUSTIFY_RIGHT);
  55. dc.drawText(dc.getWidth() / 2, dc.getHeight()*0.2284, dateFont, dateString, Graphics.TEXT_JUSTIFY_CENTER);
  56. if (Application.getApp().getProperty("ShowSeconds") == true) {
  57. dc.drawText(dc.getWidth() *0.8534, dc.getHeight()*0.46875, secFont, Lang.format("$1$", [clockTime.sec.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);}
  58. dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
  59. dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, ":" + Lang.format("$1$", [clockTime.min.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);
  60. }
  61.  
  62. }
  63.  
  64. function onHide() as Void {}
  65.  
  66. // The user has just looked at their watch. Timers and animations may be started here.
  67. function onExitSleep() as Void {}
  68.  
  69. // Terminate any active timers and prepare for slow updates.
  70. function onEnterSleep() as Void {}
Advertisement
Add Comment
Please, Sign In to add comment