Guest User

Untitled

a guest
Oct 5th, 2021
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 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. // Get and show the current time
  40. dc.setColor(SelectedColor, Graphics.COLOR_TRANSPARENT);
  41. dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, Lang.format("$1$", [clockTime.hour.format("%02d")]), Graphics.TEXT_JUSTIFY_RIGHT);
  42. dc.drawText(dc.getWidth() / 2, dc.getHeight()*0.2284, dateFont, dateString, Graphics.TEXT_JUSTIFY_CENTER);
  43. if (Application.getApp().getProperty("ShowSeconds") == true) {
  44. dc.drawText(dc.getWidth() *0.8534, dc.getHeight()*0.46875, secFont, Lang.format("$1$", [clockTime.sec.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);}
  45. dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
  46. dc.drawText(dc.getWidth() / 2.1, dc.getHeight()*0.32452, customFont, ":" + Lang.format("$1$", [clockTime.min.format("%02d")]), Graphics.TEXT_JUSTIFY_LEFT);
  47. }
  48.  
  49. }
  50.  
  51. function onHide() as Void {}
  52.  
  53. // The user has just looked at their watch. Timers and animations may be started here.
  54. function onExitSleep() as Void {}
  55.  
  56. // Terminate any active timers and prepare for slow updates.
  57. function onEnterSleep() as Void {}
Advertisement
Add Comment
Please, Sign In to add comment