Skip to content

Commit

Permalink
Rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
trip5 committed Sep 9, 2023
1 parent 1cbaa4d commit c4746aa
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
40 changes: 31 additions & 9 deletions EHLPClock.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
substitutions:
name: led-pixelclock-blue
friendly_name: Led-PixelClock-Blue
waiting: " EHLPC " # shows when waiting for time
time_zone: "Asia/Seoul" # This will be your 'home' Timezone. Check https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
waiting: "EHLPClock . . . " # shows when waiting for time
time_zone: "Asia/Seoul" # Check https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
scl_pin: GPIO4
sda_pin: GPIO5
clk_pin: GPIO14
Expand All @@ -17,7 +17,7 @@ esphome:
comment: "EHLPClock from Trip5"
project:
name: "Trip5.EspHomeLedPixelClock"
version: "2023.09.09"
version: "2023.09.10"
on_boot:
then:
- ds1307.read_time:
Expand All @@ -31,11 +31,12 @@ wifi:
password: !secret wifi_password

font:
- file: fonts/MatrixClock-Chunky8X.bdf #
# Get the fonts from https://github.com/trip5/MatrixClockFonts (but you can use others too!)
- file: fonts/MatrixClock-Chunky8X.bdf
id: default_font
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°
- file: fonts/MatrixClock-Light8X.bdf #
- file: fonts/MatrixClock-Light8X.bdf
id: message_font
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°{|}~¡¢£¤¥¦§¨©ª«¬®¯±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
Expand Down Expand Up @@ -148,10 +149,22 @@ binary_sensor:
- delayed_on: 10ms
- delayed_off: 10ms
on_multi_click:
#Click will toggle 12-hour mode
#Click will display the last message for 10 seconds
- timing:
- ON for at most 0.5s
- OFF for at least 0.5s
then:
lambda: |-
if (id(message) != "") {
id(message_alive_time) = 10;
id(message_display_time) = 10;
}
#Double-Click will toggle 12-hour mode
- timing:
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.1s
then:
- switch.toggle: hour12_select
#Hold will show the IP Address
Expand All @@ -169,11 +182,12 @@ binary_sensor:
display:
# https://community.home-assistant.io/t/reusable-function-for-lambdas/296435/10
- platform: max7219digit
id: matrix
cs_pin: $cs_pin
num_chips: 4
update_interval: 1s
reverse_enable: true # true for button-side up / false for down
rotate_chip: 0 # 0 for button-side up (default) / 180 for down
reverse_enable: true # true for button-side up / false for down (be warned that if you change these 2 settings you may get a garbled display)
rotate_chip: 0 # 0 for button-side up (default) / 180 for down (you could switch them but then I would recommend go change the inverted settting for the gpio)
scroll_mode: continuous
lambda: |-
// Display the message if all conditions are met
Expand Down Expand Up @@ -207,6 +221,14 @@ display:
it.print((32 / 2), (8 / 2), id(default_font), TextAlign::CENTER, "$waiting");
}
it.intensity(id(brightness_level));
// This next section allows the rotation sensor to work - need to directly change settings in the component: https://esphome.io/api/max7219_8h
if (id(rotation_mode).state == 1) {
id(matrix)->set_reverse(0);
id(matrix)->set_chip_orientation(2);
} else {
id(matrix)->set_reverse(1);
id(matrix)->set_chip_orientation(0);
}
globals:
- id: brightness_level
Expand Down Expand Up @@ -259,7 +281,7 @@ button:
id(message_alive_time) = 10;
id(message_display_time) = 10;
id(message_clock_time) = 0;
id(message) = (" IP " + id(wifi_ip).state);
id(message) = (" IP : " + id(wifi_ip).state + " . . . . . ");
switch:
- platform: template
Expand Down
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ You should then connect to the hotspot (with a mobile phone) and then go to 192.
The clock will display its IP address on boot and also by holding down the set button for more than 1 second. When returning home, you will have to go through this process again.
Be sure if you are using this clock as a travel clock to NOT use Home Assistant as a time source (it doesn't by default anyways).

There does appear to be some errors with "Component preferences took a long time for an operation" but it only happens when saving persistent variables to flash and doesn't seem to affect functionality, unless you try to change a variable during this moment.

### Screenshot

Ideally, this would look a lot prettier than it does but there's not a lot I can with the default ESPHome WebUI.
Expand All @@ -40,24 +38,19 @@ Ideally, this would look a lot prettier than it does but there's not a lot I can

### Button Functions

There's only one useable button on this clock but thanks to multi-click, we can use it for a few functions. I'll start with 2 for now.
There's only one useable button on this clock but thanks to multi-click, we can use it for a few functions.

| Download Button | Functionality |
| ------------------- | ---------------------- |
| Short-click | Toggle 12/24-hour mode |
| Short-click | Show last message for 10 seconds |
| Double-click | Toggle 12/24-hour mode |
| Long-press 1 second | Show the clock's IP address |

Of course, this is ESPHome, so you can change the button functions by editing the YAML. There's also a rotation sensor. Originally it was supposed to allow the clock display to flip 180 degrees but I'm not sure I can integrate this functionality.

### Time Zones

(Not included yet but will be soon.)
Of course, this is ESPHome, so you can change the button functions by editing the YAML.

It's up to you how to handle time zones. I prefer to keep my home time zone (Korea) as the one I live in and use the offset option according to the time difference with Korea.
The offsets I include are mostly for demonstration purposes. You can use positive or negative values and decimal places in your choices (ie. 2, -2, 1.5).
### Rotation Sensor

You could set your home time zone to GMT and make the default offset match your home. I haven't really experimented with this way so your mileage may vary,
especially if you live in an area that uses Daylight Savings Time.
This clock has a rotation sensor. It seems to be just a mercury-like bulb that detects if the clock has been flipped. This is functional to flip the clock but you could also use it for other things (ie)

## Integration with Home Assistant

Expand All @@ -67,7 +60,7 @@ This example will send a message that will display for 3 seconds before revertin

## Tasmota Notes

Some people would prefer to use Tasmota. I did use Tasmota at first but I found it a bit lacking. I made some notes that I'll include here:
Some people would prefer to use Tasmota. I did use Tasmota at first but I found it a bit lacking, namely that doesn't seem possible to replace the default font. I made some notes that I'll include here:

First, using [`Gitpod`](https://gitpod.io/#https://github.com/arendst/Tasmota/tree/master), add these lines to user_config_override.h:
````
Expand Down

0 comments on commit c4746aa

Please sign in to comment.