asergunov / 7segment_gpio

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

multiplex display and button at same time #11

Closed I-hate-2FA closed 2 months ago

I-hate-2FA commented 2 months ago

i have got a new board, this time with 3 7 segment display and 6 button, but the button is multiplexed with the display, is it possible to do in esphome, the original mcu had 14 gpio, if we seprate the button itll be 19, which is too much for esp32

I-hate-2FA commented 2 months ago

IMG_20240908_032625

asergunov commented 2 months ago

Hi, can you show schematic to of button multiplexing you mean?

If I calculate pins 7 segments + dot + 3 digits =11 pins for display.

You have 3 remains for buttons.

asergunov commented 2 months ago

You can use 2 for shift register and one for sense.

Another option use one frame of display to take button state. Connect buttons to segment pins one end and to one free pin. So when you power this extra pin from controller you can read levels from segment pins in theory.

asergunov commented 2 months ago

Another option is to put between pins buttons with opposite diodes between each of 3 pins. So you can pull low 2 of pins and send third to high to read two buttons. Then cycle to read another two and so on.

asergunov commented 2 months ago

And there is always analog option. You'll need one pin and 7 resistors. Connect all buttons and one resistor sequential and put resistor in parallel with each button. If you choose button resistors like 1K 2K 4K 8K 16K 32K each press combination will give you unique resistance. 7-th resistor just other hand of voltage divider.

asergunov commented 2 months ago

Another option is use one display refresh cycle to reuse 8 segment pins and one extra pin. I guess that what you meant. Button with diodes connected to segments one end and extra pin another end. So we can listen segment pins one cycle of screen powering them from extra pin. This sounds doable. But you'll need a diode for each button to make sure press will not affect the screen.

I-hate-2FA commented 2 months ago

the display is using only the number which is 7 segment pin and 3 digit pin with transistor, resistor is on the segment, and the 6 button is connected to 6 of the 7 segment pins, other side of button is connected through a 1k resistor together to another mcu pin, so the display and button used a total of 11 pins, plus pwm,buzzer,ir receiver its a total of 14

I-hate-2FA commented 2 months ago

the button press will not effect the screen because the button is controled by gpio so when button is scanning display is off

I-hate-2FA commented 2 months ago

but i ultimately gave up on the project, not because the multiplexing problem, but because the motor is not driven by pwm like i think it is

it is a digital fan which only have 3 wire to motor, but seems it is using some serial communication, it wouldnt make sense to hack it then

https://github.com/user-attachments/assets/d84f2a0c-0e29-4721-8377-9b0b871b2b09

asergunov commented 2 months ago

the button press will not effect the screen because the button is controled by gpio so when button is scanning display is off

I see. Yous it's doable. We just need to add a button sense iteration in display cycle.

I-hate-2FA commented 2 months ago

yeah next time if we meet this we can try to make it work, but id better get a new one for modding this time

asergunov commented 2 months ago

For the board you showed I'd socket the IC first. So you can easily take it out, replace it or plug the esp using custom adapter.

The IC is definitely controller. So you can read microcode from it and analyse with IDA Pro or Ghidra.

You can write your own microcode for sure but looks like esp via adapter will be much easier to code.

I-hate-2FA commented 2 months ago

it is otp micro controller, it is not important, it will have to be replaced with esp32 no matter what