asergunov / 7segment_gpio

7-digits GPIO display platform for esphome
MIT License
2 stars 0 forks source link

add option to disable decimal point and digit pin #3

Closed I-hate-2FA closed 2 days ago

I-hate-2FA commented 3 days ago

i am using single digit 7 segment display with just 8 connection without decimal point, and single digit does not need digit pin for multiplex, it can be connected directly to 3v3, since 7 segment display without shift register is already such a waste of pins, i want to save these 2 for other use, i hope you can add option to ommit it

btw using gpio38 will cause kernel panic

[18:23:08][I][logger:156]: Log initialized
[18:23:08][C][safe_mode:079]: There have been 9 suspected unsuccessful boot attempts
[18:23:08][D][esp32.preferences:114]: Saving 1 preferences to flash...
[18:23:08][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[18:23:08][I][app:029]: Running through setup()...
[18:23:08][D][esp-idf:000]: E (39) gpio: io_num=38 can only be input
[18:23:08]
[18:23:08][D][esp-idf:000]: E (50) gpio: gpio_set_level(226): GPIO output gpio_num error
[18:23:08]
[18:23:08][D][esp-idf:000]: E (60) gpio: io_num=37 can only be input
[18:23:08]
[18:23:08][D][esp-idf:000]: E (61) gpio: gpio_set_level(226): GPIO output gpio_num error
[18:23:08]
[18:23:08][D][esp-idf:000]: E (71) gpio: io_num=36 can only be input
[18:23:08]
[18:23:08][D][esp-idf:000]: E (72) gpio: gpio_set_level(226): GPIO output gpio_num error
[18:23:08]
[18:23:08][D][esp-idf:000]: E (82) gpio: io_num=35 can only be input
[18:23:08]
[18:23:08][D][esp-idf:000]: E (93) gpio: gpio_set_level(226): GPIO output gpio_num error
[18:23:08]
[18:23:08][D][esp-idf:000]: E (104) gpio: gpio_set_level(226): GPIO output gpio_num error
[18:23:08]
[18:23:09][D][esp-idf:000]: E (105) gpio:Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1). 
[18:23:09]
[18:23:09]Core  1 register dump:
[18:23:09]PC      : 0x400965e6  PS      : 0x00060135  A0      : 0x8009530a  A1      : 0x3ffbed1c  
[18:23:09]A2      : 0x3ffbc874  A3      : 0x3ffcdabc  A4      : 0x00000004  A5      : 0x00060123  
[18:23:09]A6      : 0x00060123  A7      : 0x00000001  A8      : 0x3ffcdabc  A9      : 0x00000018  
[18:23:09]A10     : 0x3ffcdabc  A11     : 0x00000018  A12     : 0x00000004  A13     : 0x00060123  
[18:23:09]A14     : 0x007bf0d8  A15     : 0x003fffff  SAR     : 0x00000004  EXCCAUSE: 0x00000006  
[18:23:09]EXCVADDR: 0x00000000  LBEG    : 0x400913d5  LEND    : 0x400913e5  LCOUNT  : 0xffffffe8  
[18:23:09]Core  1 was running in ISR context:
[18:23:09]EPC1    : 0x400fd7f7  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x00000000
[18:23:09]
[18:23:09]
[18:23:09]Backtrace:0x400965e3:0x3ffbed1c |<-CORRUPTED
[18:23:09]
[18:23:09]
[18:23:09]Core  0 register dump:
[18:23:09]PC      : 0x4009676b  PS      : 0x00060035  A0      : 0x80094f33  A1      : 0x3ffbea2c  
[18:23:09]A2      : 0x3ffbf0d8  A3      : 0xb33fffff  A4      : 0x0000abab  A5      : 0x00060023  
[18:23:09]A6      : 0x00060021  A7      : 0x0000cdcd  A8      : 0x0000abab  A9      : 0xffffffff  
[18:23:09]A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3ffc3d4c  A13     : 0x00000007  
[18:23:09]A14     : 0x007bf0d8  A15     : 0x003fffff  SAR     : 0x0000001a  EXCCAUSE: 0x00000006  
[18:23:09]EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
[18:23:09]
[18:23:09]
[18:23:09]Backtrace:0x40096768:0x3ffbea2c |<-CORRUPTED
[18:23:09]
[18:23:09]
[18:23:09]
[18:23:09]
[18:23:09]ELF file SHA256: 0000000000000000
[18:23:09]
[18:23:09]Rebooting...
asergunov commented 2 days ago

Sounds awesome. It's easy to implement making pin optional or maybe esphome has some fake pin. Feel free to implement. I'll help in PR even if will not work right away.

asergunov commented 2 days ago

btw using gpio38 will cause kernel panic

That's strange. I have it in use:

esphome:
  name: furnace
  platformio_options: 
    board_build.f_cpu: '240000000L'

esp32:
  board: esp32-s2-saola-1
  framework:
    type: arduino

external_components:
  - source: "github://asergunov/7segment_gpio"
    refresh: 0s

display:
- platform: 7segment_gpio
  id: lcd
  digit_pins: [1,2,6,4]
  iterate_digits: false
  segment_pins:
    - 21 # g
    - 40 # f
    - 14 # e
    - 10 # d
    - 36 # c
    - 17 # b
    - 34 # a
    - 8  # .
  colon_pin: 38
  degree_pin: 13
  update_interval: 1s

Maybe framework or board is different? Or ESPHome version. I'm using 2024.5.5. Which is yours?

Edit: looks like you are using ESP32

asergunov commented 2 days ago

Looks good? https://github.com/asergunov/7segment_gpio/pull/5

I-hate-2FA commented 2 days ago

yes i am using original esp32, gpio34-38 hardware does not allow output, i just thought it as good way to disable that output, but it didnt work

I-hate-2FA commented 2 days ago

Sounds awesome. It's easy to implement making pin optional or maybe esphome has some fake pin. Feel free to implement. I'll help in PR even if will not work right away.

idk how to make external component, as you can see i am still relying on custom sensor which technically is depricated

I-hate-2FA commented 2 days ago

i am using version 2024.6.4

asergunov commented 2 days ago

yes i am using original esp32, gpio34-38 hardware does not allow output, i just thought it as good way to disable that output, but it didnt work

Yup. You need another pins.

I-hate-2FA commented 2 days ago

so latest version allow to use these pin as placeholder now? because there is breaking bug in esphome now, everytime i want to compile i need uninstall and reinstall esphome addon https://github.com/esphome/issues/issues/5998 it is very hard to test things

asergunov commented 2 days ago

@I-hate-2FA I've made code changes but not tested. Could please let me know if it works? https://github.com/asergunov/7segment_gpio/pull/6

Just remove or comment out your digit_pins

asergunov commented 2 days ago

reinstall esphome addon

I'm using the local install. Hardest part is to create venv

python -m venv `.venv`

and activate it

What OS you are using? On Linux it will be

source ./.venv/bin/activate

Then just install esphome

pip install esphome

and you are ready to go

I-hate-2FA commented 2 days ago

i am using windows on my pc, and home assistant os on server if i can acess inside container, i can probably just delete the old build file manually, but because home assistant os is lock down i cannot, so install esphome on pc is a option

I-hate-2FA commented 2 days ago

Just remove or comment out your digit_pins

how can i update the external component to latest

asergunov commented 2 days ago

You can find how activate venv on windows here

asergunov commented 2 days ago
external_components:
  - source: "github://asergunov/7segment_gpio@one-digit-support"
    refresh: 0s

Just add branch name and make sure refresh is 0s so it will pull repo every build

asergunov commented 2 days ago

For the dot I can't see any limitations in code. Looks like it should work if you specify just 7 segment pins.

I-hate-2FA commented 2 days ago

For the dot I can't see any limitations in code. Looks like it should work if you specify just 7 segment pins.

i tried that the first time, but i didnt look closely at the error so i thought it wont work

I-hate-2FA commented 2 days ago

seems to work with current config:

display:
- platform: 7segment_gpio
  id: sevenseg
  segment_pins: 
    - number: 4
      inverted: True
    - number: 16
      inverted: True 
    - number: 17
      inverted: True
    - number: 5
      inverted: True
    - number: 18
      inverted: True
    - number: 23
      inverted: True
    - number: 19
      inverted: True
  update_interval: 100ms
  lambda: |-
    if(id(keepon).state){
      if((millis()%2000) < 500){
        it.printf(0,"O");
      }else if((millis()%2000) < 1000){
        it.printf(0,"P");
      }else if((millis()%2000) < 1500){
        it.printf(0,"E");
      }else{
        it.printf(0,"n");
      } 
    }else if(id(ledr).state){
      it.printf(0,"%d",id(timer));
    }else{  
      it.printf(0,"H");
    }

thanks allot! it is very helpful project

asergunov commented 2 days ago

Awesome. I've merged PR and removed branch. Please remove @one-digit-support to make it work

asergunov commented 2 days ago

For pin inversion I've opened #8 . Feel free to implement. Doesn't look hard

I-hate-2FA commented 2 days ago

https://youtu.be/pTHbhletz8g

asergunov commented 2 days ago

Thanks for sharing. Feels good! Thanks for contribution!

asergunov commented 2 days ago

Look at that. I've spotted a bug. That's why it was not stop on generation stage https://github.com/asergunov/7segment_gpio/pull/9

Could please check if it work so I could merge it?

asergunov commented 2 days ago

Thanks! Looks like everything is resolved here. Can we close it?