Skip to content

Commit

Permalink
Merge pull request #5 from sascha-hemi/master
Browse files Browse the repository at this point in the history
Updated both Display.py files
  • Loading branch information
phiten authored Apr 26, 2024
2 parents 42a4c0a + 9b46774 commit 5cfb67a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
39 changes: 14 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
# esphome IKEA LED matrix components for Frekvens & Obegränsad
# ESPHome IKEA LED matrix components for Frekvens & Obegränsad
Both Frekvens and Obegränsad are 16 by 16 LED Matrixes from IKEA and they are Hackable for Usage with HomeAssistant / ESPHome.

A custom component for esphome to interface with IKEA's Frekvens Cube and Obegränsad panel.
This Repository is a custom component for ESPHome to interface these two Matrixes.

## Sources
I will create a custom PCB for both Frekvens Cube and Obegränsad Panel that you can build yourself for a sleek integration. ❗❗❗TODO❗❗❗

This repo is heavily based on the original [FrekvensPanel library by @frumperino](https://github.com/frumperino/FrekvensPanel).
## Wiring

It's also inspired from the esphome component PCD8544.
You have to wire your ESP32 or ESP8266 according to this Schematics.

## Usage
### Frekvens

Currently there is a dependency upon Adafruit GFX library. In your esphome config, add these lines:
❗❗❗TODO❗❗❗

- Declare necessary libraries
- Define frekvenspanel component
### Obegränsad

```yaml
lib_deps:
- Wire # Also required by GFX.
- SPI # Also required by GFX.
- adafruit/Adafruit BusIO # Required by GFX Library.
- adafruit/Adafruit GFX Library # Required for FrekvensPanel.
- me-no-dev/ESPAsyncTCP
```
❗❗❗TODO❗❗❗

## Software

Here is a short config to demonstrate the usage to display time on Frekvens and Obegränsad:

Expand All @@ -41,7 +36,7 @@ esphome:
- me-no-dev/ESPAsyncTCP

external_components:
- source: github://phiten/esphome-ikea-led-matrix@master
- source: github://sascha-hemi/esphome-ikea-led-matrix@master
components: [ frekvens_panel ]

light:
Expand Down Expand Up @@ -96,7 +91,7 @@ esphome:
- me-no-dev/ESPAsyncTCP

external_components:
- source: github://phiten/esphome-ikea-led-matrix@master
- source: github://sascha-hemi/esphome-ikea-led-matrix@master
components: [ obegraensad_panel ]

light:
Expand Down Expand Up @@ -135,9 +130,3 @@ display:
it.strftime(4, 8, id(b03), "%M", id(ntp_time).now());
```
## License
[TBD] the original library does not specify the license. This repo is consecutively not licensed yet either.
## Credits
Thanks to @speckij
2 changes: 1 addition & 1 deletion components/frekvens_panel/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ async def to_code(config):

if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))
6 changes: 4 additions & 2 deletions components/obegraensad_panel/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
CONF_PAGES,
CONF_CONTRAST,
)
from esphome.const import __version__ as ESPHOME_VERSION

DEPENDENCIES = []

Expand Down Expand Up @@ -38,7 +39,8 @@
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])

await cg.register_component(var, config)
if cv.Version.parse(ESPHOME_VERSION) < cv.Version.parse("2023.12.0"):
await cg.register_component(var, config)
await display.register_display(var, config)

cg.add(var.set_pins(
Expand All @@ -49,6 +51,6 @@ async def to_code(config):

if CONF_LAMBDA in config:
lambda_ = await cg.process_lambda(
config[CONF_LAMBDA], [(display.DisplayBufferRef, "it")], return_type=cg.void
config[CONF_LAMBDA], [(display.DisplayRef, "it")], return_type=cg.void
)
cg.add(var.set_writer(lambda_))
11 changes: 8 additions & 3 deletions components/obegraensad_panel/obegraensad-panel.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "esphome/core/defines.h"
#include "esphome/core/version.h"
#include "esphome/core/component.h"
#include "esphome/components/display/display_buffer.h"

Expand All @@ -9,8 +11,11 @@
namespace esphome {
namespace obegraensadpanel {

class Panel : public PollingComponent,
public display::DisplayBuffer {
#if ESPHOME_VERSION_CODE >= VERSION_CODE(2023, 12, 0)
class Panel : public display::DisplayBuffer {
#else
class Panel : public PollingComponent, public display::DisplayBuffer {
#endif // VERSION_CODE(2023, 12, 0)
public:
int p_latch;
int p_clock;
Expand All @@ -23,7 +28,7 @@ class Panel : public PollingComponent,
}

float get_setup_priority() const override { return setup_priority::PROCESSOR; }

display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_BINARY; }

void data(uint8_t value);
Expand Down

0 comments on commit 5cfb67a

Please sign in to comment.