diff --git a/esphome/esp32-c3-mini.yaml b/esphome/esp32-c3-mini.yaml index 19ac318..564c5dd 100644 --- a/esphome/esp32-c3-mini.yaml +++ b/esphome/esp32-c3-mini.yaml @@ -19,6 +19,10 @@ ota: - platform: esphome password: "b36a083936b983a368c61e1706fbe467" +time: + - platform: homeassistant + id: ha_time + wifi: ssid: !secret wifi_ssid password: !secret wifi_password @@ -42,7 +46,7 @@ display: height: 320 offset_height: 0 offset_width: 0 - dc_pin: 2 + dc_pin: 5 # GPIO2 대신 strapping 핀이 아닌 GPIO5로 변경 reset_pin: 1 cs_pin: 0 eightbitcolor: true @@ -51,25 +55,30 @@ display: lambda: |- + it.fill(Color(0, 0, 0)); - it.fill(Color(0, 0, 0)); // 배경 검은색 + auto time = id(ha_time).now(); + static const char *weekday_names[] = {"일", "월", "화", "수", "목", "금", "토"}; + bool pm = time.hour >= 12; + int hour12 = time.hour % 12; + if (hour12 == 0) { + hour12 = 12; + } - // 이미지 출력 (좌표 10, 10에 출력) - it.image(0, 0, id(my_logo)); + it.printf(120, 60, id(date_font), Color(255, 255, 255), TextAlign::CENTER, + "%02d/%02d %s요일", time.month, time.day_of_month, weekday_names[time.day_of_week]); - // 텍스트와 함께 출력 - it.print(50, 250, id(my_font),Color(255, 255, 0), "박향기"); + it.printf(120, 180, id(time_font), Color(255, 255, 0), TextAlign::CENTER, + "%s %02d:%02d", pm ? "PM" : "AM", hour12, time.minute); font: - file: "IBMPlexSansKR-Text.ttf" - id: my_font - size: 65 - glyphs: "0123456789:-박향기" + id: date_font + size: 35 + glyphs: "0123456789/ APM월화수목금토요일" - -image: - - file: "zen.png" - id: my_logo - #resize: 50x50 # 원하는 크기로 조절 - type: RGB # 컬러 디스플레이이므로 COLOR 설정esphome + - file: "IBMPlexSansKR-Text.ttf" + id: time_font + size: 100 + glyphs: "0123456789: APM"