Example #1
0
def time_in_range(start, end):
    current_time = datetime.datetime.today().time()
    database = RedisDatabase()

    # current_time = parser.parse(database.get("current_time")).time()
    # print current_time
    if start <= end:
        return start <= current_time <= end
    else:
        return start <= current_time or current_time <= end
Example #2
0
    def __init__(self, trigger, echo, number_of_sample=100):

        self.database = RedisDatabase()
        self.config = configparser.ConfigParser()
        self.config.read("config.ini")

        self.number_of_sample = number_of_sample
        self.GPIO_ECHO = echo
        self.GPIO_TRIGGER = trigger
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(self.GPIO_TRIGGER, GPIO.OUT)  # Trigger
        GPIO.setup(self.GPIO_ECHO, GPIO.IN)  # Echo
        GPIO.output(self.GPIO_TRIGGER, False)
Example #3
0
 def get(self):
     redis = RedisDatabase()
     type_data = self.get_argument("type", "None")
     if type_data in "real":
         self.write(demjson.encode({"water_level":
                                    redis.get_water_level()}))
Example #4
0
 def __init__(self):
     self.redis_database = RedisDatabase()
     self.mongo_client = MongoClient()
     self.mongo_database = self.mongo_client["smart_aqua"]
     self.stat = self.mongo_database.statistic
Example #5
0
from Class.RedisDatabase import RedisDatabase
from lib_tft24T import TFT24T

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

DC = 22
RST = 18
LED = 23

TFT = TFT24T(spidev.SpiDev(), GPIO, landscape=True)

TFT.initLCD(DC, RST, LED, ce=1)
draw = TFT.draw()
TFT.clear((255, 255, 255))
database = RedisDatabase()
database.test_connect()
#  # Image of calculator !!!
font = ImageFont.truetype('THSarabunNew.ttf', 22)
i = 1
while True:
    TFT.load_wallpaper("bg.jpg")
    text = u'ระดับน้ำ : 2 '

    text1 = u'อุณหภูมิ :'
    draw.text((10, 80), text1, fill=(32, 32, 32), font=font)
    draw.text((10, 100), text, fill=(32, 32, 32), font=font)
    draw.text((10, 120), str(i), fill=(32, 32, 32), font=font)
    draw.textwrapped((10, 140), str(i), 38, 10, font, fill=(32, 32, 32))
    TFT.display()
    i += 1