#Aresenovich
from machine import Pin
from utime import sleep
print("Hello, ESP32!")
led = Pin(15, Pin.OUT)
from machine import I2C
#i2c = I2C(0)
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)
print(i2c.scan())
from ds1307 import DS1307
from machine import I2C, Pin
# DS1307 on 0x68
I2C_ADDR = 0x68 # DEC 104, HEX 0x68
# define custom I2C interface, default is 'I2C(0)'
# check the docs of your device for further details and pin infos
# this are the pins for the Raspberry Pi Pico adapter board
ds1307 = DS1307(addr=I2C_ADDR, i2c=i2c)
# get the current RTC time
# print("Current RTC time: {}".format(ds1307.datetime))
# Print the date and time in ISO8601 format: 2023-04-18T21:14:22
# print("Today is {:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}".format(
# ds1307.year, ds1307.month, ds1307.day,
# ds1307.hour, ds1307.minute, ds1307.second))
from ssd1306 import SSD1306_I2C
oled = SSD1306_I2C(128, 64, i2c)
# oled.fill(1)
# oled.show()
# sleep(1)
# oled.fill(0)
# oled.show()
#oled.text('Hello', 0, 0)
#oled.text('World', 0, 10)
# oled.text(str(ds1307.year), 64, 32)
# oled.show()
while True:
if ds1307.weekday in [2, 4, 6]:
if ds1307.hour > 9 and ds1307.hour < 17:
if ds1307.second < 10:
oled.fill(0)
led.off()
oled.fill(0)
oled.fill_rect(0, 0, 32, 32, 1)
oled.fill_rect(2, 2, 28, 28, 0)
oled.vline(9, 8, 22, 1)
oled.vline(16, 2, 22, 1)
oled.vline(23, 8, 22, 1)
oled.fill_rect(26, 24, 2, 4, 1)
oled.text('MicroPython', 40, 0, 1)
oled.text('SSD1306', 40, 12, 1)
oled.text('OLED 128x64', 40, 24, 1)
oled.show()
oled.text(str(ds1307.second), 64, 42)
oled.show()
led.on()