def main(): # this main is for testing on a normal ubuntu system # hard coded defines pathToConfigs = "./config.json" # get current time from wifi # get configs maxIntensity = 100 sleepTimeSec = 60. config = {} try: config = json.load(open(pathToConfigs, "r")) except: print("blink onboard LED") try: maxIntensity = config["max_intensity_percent"] sleepTimeSec = config["alarm_sleep_time_sec"] except: print("blink twice") print("maxIntensityPercent " + str(maxIntensity)) print("sleepTimeSec " + str(sleepTimeSec)) # create instance of sunrise which will be launched by alarm at the correct time # read maximum intensity s = StringPrinter("rise sun!") # set alarm alarm = Alarm(s) alarm.set_sleep_time_spinning_sec(sleepTimeSec) alarm.spin()
s_startup.process() # print("end of sunrise") # turn off the led (why doesn't simply putting low() suffice? machine.PWM(machine.Pin(0, machine.Pin.OUT), freq=20000).duty(1024) ledNum = 0 # use pin without LED branched to if "led_number" in config: ledNum = config["led_number"] # create instance of sunrise which will be launched by alarm at the correct time s = SunriseExp() s.set_led_num(ledNum) s.set_max_intensity_percent(maxIntensity) s.set_sunrise_time(sunriseTimeSec) s.set_exp_vars(5., 3.5) # set alarm timeSetter = TimeSetter(utcDelay) timeSetter.set_verbose(True) alarm = Alarm(s, timeSetter) if "verbose" in config: alarm.set_verbosity(config["verbose"]) alarm.set_sleep_time_spinning_sec(alarmSleepTimeSec) # don't prepone for debugging alarm.set_action_prepone_time_min(0.) alarm.spin()