5
Vote

smooth day rotation

I've tried to make a smooth day rotation and here is my (quick & dirty) solution:
photoshop: draw a circle path and place numbers (01 - 31) [text ring layer doesn't work] - save it as an image; load it into watchmaker

-- lua testscript for smooth day rotation
start_rotation     = -3     -- in this example, our real 0 position is -3
day_degrees        = 11,86  -- degrees until next day (360/31 = 11,61)
var_s_daterotation = 0      -- this is our rotation

-- *** we need some global vars to test ***
-- date vars
dd   = {dd}         -- day
ddim = {ddim}       -- day of month
-- hour vars
dh24 = {dh24}       -- hour
dm   = {dm}         -- minute
ds   = {ds}         -- second

function get_start_rotation(dd, dh, dm, ds)
    r = day_degrees * (dd - 1)          -- r = start rotation
    r = r * -1                          -- we rotate counterclockwise, so multiply with -1
    r = r + start_rotation

    -- r is now our rotation from (today, 00:00:00)

    dp = day_degrees / 86400            -- each second, we will rotate x percent more
    s = (dh * 3600) + (dm * 60) + ds    -- our actually seconds    

    return r + ((s * dp) * -1)          -- give our real rotation back
end

-- *** init our rotation ***
var_s_daterotation = get_start_rotation(dd, dh24, dm, ds)

-- *** just testing, but nessessary ***
x = 51       -- in real, change to 1 (I've add 51 to each second & minute for testing)

function on_second()
    ds = ds + x
    if ds > 59 then
        ds = 0
        dm = dm + x
        if dm > 59 then
         dm = 0
            dh24 = dh24 + 1
            if dh24 > 23 then
                dh24 = 0
                dd = dd + 1
                if dd > ddim then
                    dd = 1
                    ddim = {ddim}
                end
            end
        end
    end

    var_s_daterotation = get_start_rotation(dd, dh24, dm, ds)
end

 

 

Published by Sabine Mayerhagen on 17 March 2017WatchMaker Tips & Tricks Posted

This Website and It's Resources are Powered by:
  
WatchMaker Beautiful Watches for Android Wear

No smartwatch required!! Best clock wallpaper for Android!
  
WatchMaker Live WallPaper

Introducing the Perfect Companion App for WatchMaker...
  
GearsPro (OBD 2 & Car)