浏览代码

Coordinates extracted to config.py

master
Dirk Alders 2 年前
父节点
当前提交
65bfc63fc4
共有 2 个文件被更改,包括 8 次插入7 次删除
  1. 3
    0
      examples/config.py
  2. 5
    7
      piface_function.py

+ 3
- 0
examples/config.py 查看文件

@@ -1,5 +1,6 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: UTF-8 -*-
3
+import geo
3 4
 import os
4 5
 import report
5 6
 
@@ -8,6 +9,8 @@ MQTT_PASS = "password"
8 9
 MQTT_SERVER = "host"
9 10
 MQTT_TOPIC = "leyk"
10 11
 
12
+GEO_POSITION = geo.gps.coordinate(lat=49.519167, lon=9.3672222)
13
+
11 14
 #
12 15
 # Logging
13 16
 #

+ 5
- 7
piface_function.py 查看文件

@@ -22,8 +22,6 @@ except ImportError:
22 22
     ROOT_LOGGER_NAME = 'root'
23 23
 logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
24 24
 
25
-geo_position = geo.gps.coordinate(lat=49.976596, lon=9.1481443)
26
-
27 25
 
28 26
 class pi_face(object):
29 27
     LOG_PREFIX = 'PiFace:'
@@ -237,10 +235,10 @@ class state_machine_day_state(state_machine.state_machine):
237 235
             return time.mktime(time.struct_time(tm))
238 236
     
239 237
         def sunrise_time():
240
-            return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60
238
+            return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60
241 239
     
242 240
         def sunset_time():
243
-            return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60
241
+            return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60
244 242
     
245 243
         def sleep_time():
246 244
             tm = time.localtime()
@@ -286,7 +284,7 @@ class state_machine_day_state(state_machine.state_machine):
286 284
         return not self.sm_mode.this_state_is(self.sm_mode.STATE_AUTOMATIC)
287 285
 
288 286
     def report_sunset_sunrise(self):
289
-        state_machine.logger.debug('Sunrise: %s - Sunset: %s;', time.strftime("%H:%M", geo.sun.sunrise(geo_position)), time.strftime("%H:%M", geo.sun.sunset(geo_position))
287
+        state_machine.logger.debug('Sunrise: %s - Sunset: %s;', time.strftime("%H:%M", geo.sun.sunrise(config.GEO_POSITION)), time.strftime("%H:%M", geo.sun.sunset(config.GEO_POSITION))
290 288
 )
291 289
 
292 290
 
@@ -479,10 +477,10 @@ class leyk(object):
479 477
         return time.mktime(time.struct_time(tm))
480 478
 
481 479
     def sunrise_time(self):
482
-        return time.mktime(geo.sun.sunrise(geo_position)) + 30 * 60
480
+        return time.mktime(geo.sun.sunrise(config.GEO_POSITION)) + 30 * 60
483 481
 
484 482
     def sunset_time(self):
485
-        return time.mktime(geo.sun.sunset(geo_position)) - 30 * 60
483
+        return time.mktime(geo.sun.sunset(config.GEO_POSITION)) - 30 * 60
486 484
 
487 485
     def sleep_time(self):
488 486
         tm = time.localtime()

正在加载...
取消
保存