donbing / Bitbot

Simple python app to drive Pimoroni e-ink displays with finance candle charts
GNU General Public License v3.0
29 stars 2 forks source link

KiloBitBot function of buttons #61

Closed uududde closed 2 years ago

uududde commented 2 years ago

I got my 5.7 inky color eink and attached it to my pi zero which was running the waveshare test as installation from the image but that sadly didn't work. So I went to install it from fresh via CLI and that had no problems whatsoever. It started running and I was amazed! I absolutely love it. Thank you. Now all I need is one of those nice aluminium stands (as an enhancement here it could maybe be an option if it could have a slight angle so it's not a 90 degrees stand but a 70 or 80 degrees angle for better viewing when standing on the desk - something like this one: https://www.thingiverse.com/thing:4664346 ).

It would be nice to be able to add functions to the buttons of the 5.7 inky display (the 2.7inch waveshare also has these buttons and maybe the same functions could be added here too):

The only issue I have is that I cannot get into the config webserver using a browser. Maybe I'll try configuring via CLI.

donbing commented 2 years ago

Thanks @uududde, glad it's working well for you (altho, what was the problem with the image based install?)

Currently, the button mappings are as follows (these did work on an inky impression), I'll give it a test to see if it's broken somehow.

5: self.toggle_picure_frame_mode,
6: self.refresh_display,
16: self.toggle_volume,
24: self.toggle_extended_view,

The config webserver has to be started as a separate python app.

Add cron jobs to start the app and config-server after reboot

(crontab -l 2>/dev/null; echo "@reboot sleep 30 && cd /home/pi/bitbot && python3 run.py") | crontab -
(crontab -l 2>/dev/null; echo "@reboot sleep 30 && cd /home/pi/bitbot && python3 src/config_webserver.py") | crontab -
donbing commented 2 years ago

@uududde the buttons are working on my 5.6" impression when using the main branch.

uududde commented 2 years ago

@donbing cool, I didn't know they were already implemented... so my idea of button three changing the style is even almost the same option you came up with.

I guess I should've watched syslog in the first place when trying out the buttons. Button 1 delivers an error, button 3 does not do anything (mybe broken), button 2 & 4 work as expected.

Button 1 gives me:

[CRITICAL] root: Uncaught exception
Traceback (most recent call last):
  File "/home/pi/bitbot/src/buttons.py", line 25, in <lambda>
    lambda pin: self.BUTTONS[pin](),
  File "/home/pi/bitbot/src/configuration/log_decorator.py", line 12, in wrapper
    result = func(*args, **kwargs)
  File "/home/pi/bitbot/src/buttons.py", line 34, in toggle_picure_frame_mode
    self.config.toggle_photo_mode(newstate)
TypeError: toggle_photo_mode() missing 1 required positional argument: 'cycle_state'

The problem with the image method was that directly after flashing even though delivering wpa data in the specific file and activating ssh via file before first boot the pi zero would not connect to the wifi.

Thanks I didn't see that the config server should be started by itself. Log says it's running but browser doesn't open it.

donbing commented 2 years ago

The cycle_state error should now be fixed in main. I'm pretty sure that I've broken the refresh button by checking for config changes before updating the screen. That's going to be a bit fiddly to fix, so I might go with your suggestion of switching between currencies instead, thanks!

I've a feeling that the disk image doesn't support wpa_supplicant, it's based on comitup. it starts it's own hotspot allowing you to configure the WiFi from your phone/laptop, I'll check

uududde commented 2 years ago

The cycle_state error is gone... now I receive:

[CRITICAL] root: Uncaught exception
Traceback (most recent call last):
  File "/home/pi/bitbot/src/input/buttons.py", line 26, in <lambda>
    lambda pin: self.BUTTONS[pin](),
  File "/home/pi/bitbot/src/configuration/log_decorator.py", line 12, in wrapper
    result = func(*args, **kwargs)
  File "/home/pi/bitbot/src/input/buttons.py", line 35, in toggle_picure_frame_mode
    self.config.toggle_photo_mode(newstate, False)
  File "/home/pi/bitbot/src/configuration/bitbot_config.py", line 100, in toggle_photo_mode
    self.config['picture_frame_mode']["cycle_pictures"] = cycle_state
  File "/usr/lib/python3.9/configparser.py", line 1258, in __setitem__
    self._parser._validate_value_types(option=key, value=value)
  File "/usr/lib/python3.9/configparser.py", line 1185, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings
donbing commented 2 years ago

@uududde thanks for the error report, the branch called photo_button_fail introduces currency cycling instead.. I've not had time to test it yet, but i'll merge it into main once i have