mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 20:36:51 +01:00
Update solarpositioning to 0.1.10
This commit is contained in:
parent
cdd2392961
commit
bda9948838
@ -229,10 +229,10 @@ dependencies {
|
||||
implementation "no.nordicsemi.android:dfu:1.12.0"
|
||||
implementation "com.github.tony19:logback-android:3.0.0"
|
||||
implementation "org.slf4j:slf4j-api:2.0.13"
|
||||
implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||
implementation "com.github.PhilJay:MPAndroidChart:3.1.0"
|
||||
implementation "com.github.pfichtner:durationformatter:0.1.1"
|
||||
implementation "de.cketti.library.changelog:ckchangelog:1.2.2"
|
||||
implementation "net.e175.klaus:solarpositioning:0.0.9"
|
||||
implementation "net.e175.klaus:solarpositioning:0.1.10"
|
||||
implementation "co.nstant.in:cbor:0.9"
|
||||
// use pristine greendao instead of our custom version, since our custom jitpack-packaged
|
||||
// version contains way too much and our custom patches are in the generator only.
|
||||
|
@ -26,6 +26,7 @@ import android.os.Build;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -87,7 +88,12 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||
float longitude = longlat[0];
|
||||
float latitude = longlat[1];
|
||||
|
||||
GregorianCalendar[] sunriseTransitSetTomorrow = SPA.calculateSunriseTransitSet(dateTimeTomorrow, latitude, longitude, DeltaT.estimate(dateTimeTomorrow));
|
||||
final SunriseTransitSet sunriseTransitSetTomorrow = SPA.calculateSunriseTransitSet(
|
||||
dateTimeTomorrow.toZonedDateTime(),
|
||||
latitude,
|
||||
longitude,
|
||||
DeltaT.estimate(dateTimeTomorrow.toZonedDateTime().toLocalDate())
|
||||
);
|
||||
|
||||
CalendarEventSpec calendarEventSpec = new CalendarEventSpec();
|
||||
calendarEventSpec.durationInSeconds = 0;
|
||||
@ -95,17 +101,17 @@ public class AlarmReceiver extends BroadcastReceiver {
|
||||
|
||||
calendarEventSpec.type = CalendarEventSpec.TYPE_SUNRISE;
|
||||
calendarEventSpec.title = "Sunrise";
|
||||
if (sunriseTransitSetTomorrow[0] != null) {
|
||||
if (sunriseTransitSetTomorrow.getSunrise() != null) {
|
||||
calendarEventSpec.id = id_tomorrow;
|
||||
calendarEventSpec.timestamp = (int) (sunriseTransitSetTomorrow[0].getTimeInMillis() / 1000);
|
||||
calendarEventSpec.timestamp = (int) (sunriseTransitSetTomorrow.getSunrise().toInstant().getEpochSecond());
|
||||
GBApplication.deviceService().onAddCalendarEvent(calendarEventSpec);
|
||||
}
|
||||
|
||||
calendarEventSpec.type = CalendarEventSpec.TYPE_SUNSET;
|
||||
calendarEventSpec.title = "Sunset";
|
||||
if (sunriseTransitSetTomorrow[2] != null) {
|
||||
if (sunriseTransitSetTomorrow.getSunset() != null) {
|
||||
calendarEventSpec.id = id_tomorrow;
|
||||
calendarEventSpec.timestamp = (int) (sunriseTransitSetTomorrow[2].getTimeInMillis() / 1000);
|
||||
calendarEventSpec.timestamp = (int) (sunriseTransitSetTomorrow.getSunset().toInstant().getEpochSecond());
|
||||
GBApplication.deviceService().onAddCalendarEvent(calendarEventSpec);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -146,15 +147,19 @@ public class WeatherHandler {
|
||||
} else {
|
||||
final Location lastKnownLocation = new CurrentPosition().getLastKnownLocation();
|
||||
|
||||
final GregorianCalendar[] sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
date,
|
||||
final SunriseTransitSet sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
date.toZonedDateTime(),
|
||||
lastKnownLocation.getLatitude(),
|
||||
lastKnownLocation.getLongitude(),
|
||||
DeltaT.estimate(date)
|
||||
DeltaT.estimate(date.toZonedDateTime().toLocalDate())
|
||||
);
|
||||
|
||||
epochSunrise = (int) (sunriseTransitSet[0].getTime().getTime() / 1000);
|
||||
epochSunset = (int) (sunriseTransitSet[2].getTime().getTime() / 1000);
|
||||
if (sunriseTransitSet.getSunrise() != null) {
|
||||
epochSunrise = (int) (sunriseTransitSet.getSunrise().toInstant().getEpochSecond());
|
||||
}
|
||||
if (sunriseTransitSet.getSunset() != null) {
|
||||
epochSunset = (int) (sunriseTransitSet.getSunset().toInstant().getEpochSecond());
|
||||
}
|
||||
}
|
||||
|
||||
wind = new Wind(new WeatherValue(dailyForecast.windSpeed * 3.6, "METERS_PER_SECOND"), dailyForecast.windDirection);
|
||||
|
@ -38,6 +38,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.slf4j.Logger;
|
||||
@ -3311,26 +3312,33 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
if (longitude != 0 && latitude != 0) {
|
||||
final GregorianCalendar dateTimeToday = new GregorianCalendar();
|
||||
|
||||
GregorianCalendar[] sunriseTransitSet = SPA.calculateSunriseTransitSet(dateTimeToday, latitude, longitude, DeltaT.estimate(dateTimeToday));
|
||||
final SunriseTransitSet sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
dateTimeToday.toZonedDateTime(),
|
||||
latitude,
|
||||
longitude,
|
||||
DeltaT.estimate(dateTimeToday.toZonedDateTime().toLocalDate())
|
||||
);
|
||||
|
||||
try {
|
||||
TransactionBuilder builder;
|
||||
builder = performInitialized("Sending sunrise/sunset");
|
||||
if (sunriseTransitSet.getSunrise() != null && sunriseTransitSet.getSunset() != null) {
|
||||
try {
|
||||
TransactionBuilder builder;
|
||||
builder = performInitialized("Sending sunrise/sunset");
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(10);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put((byte) 16);
|
||||
buf.putInt(weatherSpec.timestamp);
|
||||
buf.put((byte) (tz_offset_hours * 4));
|
||||
buf.put((byte) sunriseTransitSet[0].get(GregorianCalendar.HOUR_OF_DAY));
|
||||
buf.put((byte) sunriseTransitSet[0].get(GregorianCalendar.MINUTE));
|
||||
buf.put((byte) sunriseTransitSet[2].get(GregorianCalendar.HOUR_OF_DAY));
|
||||
buf.put((byte) sunriseTransitSet[2].get(GregorianCalendar.MINUTE));
|
||||
ByteBuffer buf = ByteBuffer.allocate(10);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put((byte) 16);
|
||||
buf.putInt(weatherSpec.timestamp);
|
||||
buf.put((byte) (tz_offset_hours * 4));
|
||||
buf.put((byte) sunriseTransitSet.getSunrise().getHour());
|
||||
buf.put((byte) sunriseTransitSet.getSunrise().getMinute());
|
||||
buf.put((byte) sunriseTransitSet.getSunset().getHour());
|
||||
buf.put((byte) sunriseTransitSet.getSunset().getMinute());
|
||||
|
||||
writeToChunked(builder, 1, buf.array());
|
||||
builder.queue(getQueue());
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Error sending sunset/sunrise", ex);
|
||||
writeToChunked(builder, 1, buf.array());
|
||||
builder.queue(getQueue());
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Error sending sunset/sunrise", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.google.gson.JsonSerializer;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -245,14 +246,21 @@ public class ZeppOsWeather {
|
||||
}
|
||||
|
||||
private Range getSunriseSunset(final GregorianCalendar date, final Location location) {
|
||||
final GregorianCalendar[] sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
date,
|
||||
final SunriseTransitSet sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
date.toZonedDateTime(),
|
||||
location.getLatitude(),
|
||||
location.getLongitude(),
|
||||
DeltaT.estimate(date)
|
||||
DeltaT.estimate(date.toZonedDateTime().toLocalDate())
|
||||
);
|
||||
|
||||
return getSunriseSunset(sunriseTransitSet[0].getTime(), sunriseTransitSet[2].getTime());
|
||||
if (sunriseTransitSet.getSunrise() != null && sunriseTransitSet.getSunset() != null) {
|
||||
return getSunriseSunset(
|
||||
Date.from(sunriseTransitSet.getSunrise().toInstant()),
|
||||
Date.from(sunriseTransitSet.getSunset().toInstant())
|
||||
);
|
||||
}
|
||||
|
||||
return getSunriseSunset(new Date(), new Date());
|
||||
}
|
||||
|
||||
private Range getSunriseSunset(final Date sunRise, final Date sunSet) {
|
||||
|
@ -17,10 +17,8 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.webview;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
@ -31,6 +29,7 @@ import android.webkit.WebViewClient;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONException;
|
||||
@ -39,7 +38,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -199,12 +199,17 @@ public class GBWebClient extends WebViewClient {
|
||||
|
||||
|
||||
private static JSONObject sysObject(CurrentPosition currentPosition) throws JSONException {
|
||||
GregorianCalendar[] sunrise = SPA.calculateSunriseTransitSet(new GregorianCalendar(), currentPosition.getLatitude(), currentPosition.getLongitude(), DeltaT.estimate(new GregorianCalendar()));
|
||||
final SunriseTransitSet sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
ZonedDateTime.now(),
|
||||
currentPosition.getLatitude(),
|
||||
currentPosition.getLongitude(),
|
||||
DeltaT.estimate(LocalDate.now())
|
||||
);
|
||||
|
||||
JSONObject sys = new JSONObject();
|
||||
sys.put("country", "World");
|
||||
sys.put("sunrise", (sunrise[0].getTimeInMillis() / 1000));
|
||||
sys.put("sunset", (sunrise[2].getTimeInMillis() / 1000));
|
||||
sys.put("sunrise", sunriseTransitSet.getSunrise().toInstant().getEpochSecond());
|
||||
sys.put("sunset", sunriseTransitSet.getSunset().toInstant().getEpochSecond());
|
||||
|
||||
return sys;
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import net.e175.klaus.solarpositioning.DeltaT;
|
||||
import net.e175.klaus.solarpositioning.SPA;
|
||||
import net.e175.klaus.solarpositioning.SunriseTransitSet;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@ -74,9 +75,9 @@ import java.nio.BufferOverflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -1459,7 +1460,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
|
||||
@Override
|
||||
public void onSendWeather(WeatherSpec weatherSpec) {
|
||||
boolean isNight;
|
||||
boolean isNight = false;
|
||||
if (weatherSpec.sunRise != 0 && weatherSpec.sunSet != 0) {
|
||||
isNight = weatherSpec.sunRise * 1000L > System.currentTimeMillis() || weatherSpec.sunSet * 1000L < System.currentTimeMillis();
|
||||
} else {
|
||||
@ -1467,8 +1468,16 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
if (location == null) {
|
||||
location = new CurrentPosition().getLastKnownLocation();
|
||||
}
|
||||
GregorianCalendar[] sunrise = SPA.calculateSunriseTransitSet(new GregorianCalendar(), location.getLatitude(), location.getLongitude(), DeltaT.estimate(new GregorianCalendar()));
|
||||
isNight = sunrise[0].getTimeInMillis() > System.currentTimeMillis() || sunrise[2].getTimeInMillis() < System.currentTimeMillis();
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
final SunriseTransitSet sunriseTransitSet = SPA.calculateSunriseTransitSet(
|
||||
now,
|
||||
location.getLatitude(),
|
||||
location.getLongitude(),
|
||||
DeltaT.estimate(now.toLocalDate())
|
||||
);
|
||||
if (sunriseTransitSet.getSunrise() != null && sunriseTransitSet.getSunset() != null) {
|
||||
isNight = sunriseTransitSet.getSunrise().isAfter(now) || sunriseTransitSet.getSunset().isBefore(now);
|
||||
}
|
||||
}
|
||||
|
||||
long ts = System.currentTimeMillis();
|
||||
|
Loading…
Reference in New Issue
Block a user