46
46
#include < JsonListener.h>
47
47
#include < OpenWeatherMapCurrent.h>
48
48
#include < OpenWeatherMapForecast.h>
49
- #include < Astronomy.h>
50
49
#include < MiniGrafx.h>
51
50
#include < Carousel.h>
52
51
#include < ILI9341_SPI.h>
@@ -93,9 +92,7 @@ CalibrationCallback calibration = &calibrationCallback;
93
92
94
93
OpenWeatherMapCurrentData currentWeather;
95
94
OpenWeatherMapForecastData forecasts[MAX_FORECASTS];
96
-
97
- Astronomy::MoonData moonData;
98
- // SunMoonCalc::Moon moonData;
95
+ SunMoonCalc::Moon moonData;
99
96
100
97
void updateData ();
101
98
void drawProgress (uint8_t percentage, String text);
@@ -360,18 +357,12 @@ void updateData() {
360
357
delete forecastClient;
361
358
forecastClient = nullptr ;
362
359
363
- drawProgress (80 , " Updating astronomy..." );
364
- Astronomy *astronomy = new Astronomy ();
365
- moonData = astronomy->calculateMoonData (now);
366
- moonData.phase = astronomy->calculateMoonPhase (now);
367
- delete astronomy;
368
- astronomy = nullptr ;
369
- // https://github.com/ThingPulse/esp8266-weather-station/issues/144 prevents using this
370
- // // 'now' has to be UTC, lat/lng in degrees not raadians
371
- // SunMoonCalc *smCalc = new SunMoonCalc(now - dstOffset, currentWeather.lat, currentWeather.lon);
372
- // moonData = smCalc->calculateSunAndMoonData().moon;
373
- // delete smCalc;
374
- // smCalc = nullptr;
360
+ drawProgress (80 , " Updating astronomy data..." );
361
+ // 'now' has to be UTC, lat/lng in degrees not radians
362
+ SunMoonCalc *smCalc = new SunMoonCalc (now, currentWeather.lat , currentWeather.lon );
363
+ moonData = smCalc->calculateSunAndMoonData ().moon ;
364
+ delete smCalc;
365
+ smCalc = nullptr ;
375
366
Serial.printf (" Free mem: %d\n " , ESP.getFreeHeap ());
376
367
377
368
delay (1000 );
@@ -511,7 +502,7 @@ void drawAstronomy() {
511
502
gfx.setFont (ArialRoundedMTBold_14);
512
503
gfx.setTextAlignment (TEXT_ALIGN_CENTER);
513
504
gfx.setColor (MINI_YELLOW);
514
- gfx.drawString (120 , 250 , MOON_PHASES[moonData.phase ]);
505
+ gfx.drawString (120 , 250 , MOON_PHASES[moonData.phase . index ]);
515
506
516
507
gfx.setTextAlignment (TEXT_ALIGN_LEFT);
517
508
gfx.setColor (MINI_YELLOW);
@@ -528,12 +519,10 @@ void drawAstronomy() {
528
519
gfx.setColor (MINI_YELLOW);
529
520
gfx.drawString (235 , 250 , SUN_MOON_TEXT[3 ]);
530
521
gfx.setColor (MINI_WHITE);
531
- float lunarMonth = 29.53 ;
532
- // approximate moon age
533
- gfx.drawString (235 , 276 , String (moonData.phase <= 4 ? lunarMonth * moonData.illumination / 2.0 : lunarMonth - moonData.illumination * lunarMonth / 2.0 , 1 ) + " d" );
534
- gfx.drawString (235 , 291 , String (moonData.illumination * 100 , 0 ) + " %" );
535
522
gfx.drawString (190 , 276 , SUN_MOON_TEXT[4 ] + " :" );
523
+ gfx.drawString (235 , 276 , String (moonData.age , 1 ) + " d" );
536
524
gfx.drawString (190 , 291 , SUN_MOON_TEXT[5 ] + " :" );
525
+ gfx.drawString (235 , 291 , String (moonData.illumination * 100 , 0 ) + " %" );
537
526
}
538
527
539
528
void drawCurrentWeatherDetail () {
0 commit comments