Esempio n. 1
0
 def __init__(self):
     # initialize beeper output bit on D3 connector
     self._myI2C = busio.I2C(board.SCL, board.SDA)
     self._rtc = adafruit_pcf8523.PCF8523(self._myI2C)
     self._current_hour = 0
     self._current_min = 0
     self._ampm = "am"
     self._current_time_from_clock = self._rtc.datetime
Esempio n. 2
0
    def __init__(self, spi, i2c):
        cs = digitalio.DigitalInOut(board.D10)
        sdcard = adafruit_sdcard.SDCard(spi, cs)
        vfs = storage.VfsFat(sdcard)
        storage.mount(vfs, '/sd')

        # Location on the sd-card where the information is saved
        self.pressure_path = '/sd/pressure.txt'

        # The storage unit responsible for time
        self.rtc = adafruit_pcf8523.PCF8523(i2c)
print("====================")
print_directory("/sd")

data = open("/sd/cheer.mp3", "rb")
mp3 = audiomp3.MP3Decoder(data)
#a = audioio.AudioOut(board.A0) # mono
a = audioio.AudioOut(board.A0,
                     right_channel=board.A1)  # stereo sound through A0 & A1

i2c = io.I2C(board.SCL,
             board.SDA)  # Change to the appropriate I2C clock & data
# pins here!

# Create the RTC instance:
#rtc = adafruit_ds3231.DS3231(i2c)
rtc = adafruit_pcf8523.PCF8523(i2c)

# Lookup table for names of days (nicer printing).
days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
        "Saturday")

# selected time
# 24 hour time
playhour = 19
playmin = 0

# pylint: disable-msg=bad-whitespace
# pylint: disable-msg=using-constant-test
# no DST adjustment yet!
if False:  # change to True if you want to set the time!
    #                     year, mon, date, hour, min, sec, wday, yday, isdst
Esempio n. 4
0
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_ble_berrymed_pulse_oximeter import BerryMedPulseOximeterService

# Logging setup
SD_CS = board.D10
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(SD_CS)
sd_card = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sd_card)
storage.mount(vfs, "/sd_card")

log_interval = 2  # you can adjust this to log at a different rate

# RTC setup
I2C = busio.I2C(board.SCL, board.SDA)
rtc = adafruit_pcf8523.PCF8523(I2C)

days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
        "Saturday")

set_time = False
if set_time:  # change to True if you want to write the time!
    #             year, mon, date, hour, min, sec, wday, yday, isdst
    t = time.struct_time((2020, 4, 21, 18, 13, 0, 2, -1, -1))
    # you must set year, mon, date, hour, min, sec and weekday
    # yearday  not supported, isdst can be set but we don't use it at this time
    print("Setting time to:", t)  # uncomment for debugging
    rtc.datetime = t
    print()

# PyLint can't find BLERadio for some reason so special case it here.
DISPLAY_RATE = 1       # screen refresh rate
#-------------------------------------------------------------------------

# Get sekrets from a secrets.py file
try:
    from secrets import secrets
    totp_keys = secrets["totp_keys"]
except ImportError:
    print("Secrets are kept in secrets.py, please add them there!")
    raise
except KeyError:
    print("TOTP info not found in secrets.py.")
    raise

# set board to use PCF8523 as its RTC
pcf = adafruit_pcf8523.PCF8523(board.I2C())
rtc.set_time_source(pcf)

#-------------------------------------------------------------------------
#                       H I D    S E T U P
#-------------------------------------------------------------------------
time.sleep(1)  # Sleep for a bit to avoid a race condition on some systems
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)  # We're in the US :)

#-------------------------------------------------------------------------
#                    D I S P L A Y    S E T U P
#-------------------------------------------------------------------------
display = board.DISPLAY

# Secret Code font by Matthew Welch
# SPDX-License-Identifier: MIT

import time
import rtc
import busio
import board
import adafruit_pcf8523
import uschedule as schedule


def greet():
    print("Hello, world!")


i2c = busio.I2C(board.SCL, board.SDA)
rtc_device = adafruit_pcf8523.PCF8523(i2c)
rtc.RTC().datetime = rtc_device.datetime

# schedule every 10 seconds
schedule.every(10).seconds.do(greet)

# schedule every 10 minutes
schedule.every(10).minutes.do(greet)

# schedule once a day
schedule.every().day.at("10:30").do(greet)

# schedule from 5 to 10 minutes
schedule.every(5).to(10).minutes.do(greet)

# schedule on a particular day