This is a simple watchface for the Pebble smartwatch that display the time for the 5 Daily Muslim Prayers. It is open source, so if anyone wants to make improvements, the source will be on Github soon. This is a page on how the watchface should work. It’s more to help me remember 5 months from now, what the code is supposed to do.
When you first switch to the watchface, it looks at the settings in configuration page and how to calculate the prayer times. If it’s the first time loading the watchface, these are the default settings:
if (options === null) options = {
“use_gps” : “true”,
“location” : “90210”, //not needed initially. Set only to show example
“calc” : “ISNA”,
“asr” : “Standard”,
“time_format” : “12hNS”,
“invert_color” : “false”
};
Based on these initial settings, the watchface requests GPS location coordinates from your phone. If unsuccessful, it sets the city to “Loc Unavailable” and ends. This should only happen IF the phone’s location services are off. If that’s the case, then you need to adjust the settings and turn the “Use GPS” toggle off and enter a location. If successful, it queries the open-source API at www.openweathermap.org using these coordinates to figure out the city for those coordinates. Every once in a while, openweathermap.org doesn’t respond properly. In that case, the city is again set to “Loc Unavailable,” but the process continues. Since the calculations are done locally, as long as we have latitude and longitude, we can proceed, even without the actual city name. Next it sends three variables: latitude, longitude, and city (actual city name or “Loc Unavailable”) to the final command which actually does the calculations.
The calculations are done by the wonderful open source project at www.praytimes.org. Luckily the praytimes.org API is written in JavaScript, and the Pebble backend also uses JavaScript. A perfect combination. Anyways, based on these initial settings, the calculations will use the ISNA method, use standard calculation for Asr prayer, and also display the time in 12 hour format. Now let’s go over what the actual settings do, even though they are pretty self explanatory.
- Use GPS – Self explanatory. This uses your phones location services to request GPS coordinates. Unless you have your phones location services off, this setting should stay on.
- Location – This field is disabled if the “Use GPS” setting is on. If it’s off, then you can enter a specific location here. This heavily relies on the openweathermap.org API. It queries the API for the text entered, either zip code or city name. From that, it gets the GPS coordinates required to do the prayer calculations, and the actual city name. If the API is down, prayer times will not be calculated.
- Prayer Calculation Method – There are different opinions on the proper way to calculate prayer times. This page gives a bit more detail on the differences and where it is mostly used.
- Asr Calculation Method – There are two major schools of thought on how to calculate the Asr prayer. This page gives a bit more detail on the differences.
- Prayer Time Format – Should the calculation/display be in 12 hour format or 24 hour format.
- Invert Colors – By default, the watchface displays white text on a black background. If you prefer, you can invert the colors and show black text on a white background.
For any support issues, please use the contact form, for now. Or for bug reports, use the bug tracker below.
Current Version – 1.0.0
Known Issues
- If using GPS, API from openweathermap.org that is used to get city doesn’t always respond correctly and city shows “Loc Unavailable.” Times still calculate correctly since that’s done locally with phone supplied coordinates.
- If using location, and not GPS, and openweathermap.org doesn’t respond correctly, times won’t calculate, showing “—” and city will show “Loc Unavailable.”
- Prayer time display format is set separately from current time display format.
Future Enhancements (if possible)
- Store prayer times locally so it only updates once a day. Should have option to update more often.
- Display battery all the time. (Possible toggle)
- New geolocation API
- Set prayer time display format to use Pebble option.
[bugerator=1]