Giter Club home page Giter Club logo

Comments (7)

forrestguice avatar forrestguice commented on August 20, 2024 1

Non-repeating alarms will be pretty easy. It just requires a bit of UI.

Repeating alarms are more challenging. It requires that Suntimes Alarms somehow know how to schedule these "roman hour events" (preferably without hardcoding that into the alarm clock itself).

I think I've found a pattern that can make this work.. Add-ons could provide their own custom events by implementing an interface (ContentProvider), and advertise that as part of their manifest. It should supply two methods; one that returns a list of event names, and another that returns the next timestamp for a given event. Suntimes Alarms would then scan for implementations when it starts and show any custom events in the alarm dialog. Internally it would continue to store the event name (no changes to the database), which could be extended to encode the ContentProvider uri. Later when a repeating alarm needs to be (re)scheduled and one of these uri's is encountered, the next timestamp could be queried - the scheduling is delegated to the addon (vs running an algorithm directly).

Something similar was done in the latest Suntimes Calendars implementation, where addons can now advertise a "calendar provider" in their manifest, which is then queried to create the list of available calendars. That allows the SolunarPeriods app to provide a "hunting and fishing" calendar.

Anyhow, thinking aloud.. This is probably some uninteresting detail, but it helps me to talk it through.

from naturalhour.

forrestguice avatar forrestguice commented on August 20, 2024 1

The alarms branch can now do this, when used with a version of Suntimes from the alarm-addon branch. Its necessary to rebuild both apps.

The plan is to release Suntimes v0.14.0 some time in January, and then Natural Hour v0.2.0 with the alarm feature after that.

from naturalhour.

forrestguice avatar forrestguice commented on August 20, 2024 1

These are 'moments', similar to minutes, except 40 to an "hour", with variable length. I think I remember reading this was a medieval thing. The hour is divided into quarters, and then each quarter divided into ten. It is basically just a fraction though (20/40 is half past), and I was considering simplifying it.

from naturalhour.

XanderLeaDaren avatar XanderLeaDaren commented on August 20, 2024

Nice and elegant way of integrating the event names and timestamps!

from naturalhour.

XanderLeaDaren avatar XanderLeaDaren commented on August 20, 2024

Thank you for this, setting and launching alarms on times related to roman hours is working. πŸ‘πŸ½

Out of interest: Δ° have 39 subdivisions for every day-hours and night-hours even if they are not as long. How is the calculation done?

from naturalhour.

forrestguice avatar forrestguice commented on August 20, 2024

How is the calculation done?

In case you were actually asking about code.. The scheduling algorithm

public static long calculateAlarmTime(@NonNull Context context, @Nullable String alarmID, HashMap<String, String> selectionMap)

basically reduces the moment to a float [0,1], then calls this function

public Calendar getNaturalHour(int hourNum, float moments)

which multiplies it by the length of the hour (day-hour vs night-hour), and adds to it. It basically boils down to..

Calendar calendar = Calendar.getInstance();
float hourLength = (hourNum >= 12) ? (naturalHours[13] - naturalHours[12]) : (naturalHours[1] - naturalHours[0]);
long momentMillis = (long)(hourLength * moments);
calendar.setTimeInMillis(naturalHours[hourNum] + momentMillis);

where naturalHours[] contains timestamps (milliseconds) for each hour, previously assigned by

public boolean calculateData(ContentResolver resolver, @NonNull NaturalHourData data, boolean includeTwilights, boolean includeSolsticeEquinox)

from naturalhour.

XanderLeaDaren avatar XanderLeaDaren commented on August 20, 2024

Thank you for these detailed answers! πŸ™‚

from naturalhour.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.